Block Hash#

struct Hash128#

Two-word representation used for stable context-cache identities.

Public Members

uint64_t hi = {}#
uint64_t lo = {}#
struct AdapterKey#

Public Members

Hash128 id = {}#
uint64_t generation = {}#
struct MediaSpanKey#

Public Members

Hash128 contentDigest = {}#
Hash128 placementDigest = {}#
int32_t offsetWithinBlock = {}#
int32_t itemOrder = {}#
uint8_t modality = {}#
struct BlockKeyExtras#

Public Members

std::vector<MediaSpanKey> media#

Non-token inputs whose content or placement changes the state produced for this block.

std::optional<AdapterKey> adapter#
std::optional<Hash128> positionDigest#
std::optional<Hash128> customEmbeddingDigest#
std::optional<Hash128> isolationDigest#
template<>
struct hash<trt_edgellm::rt::Hash128>#

Public Functions

inline size_t operator()(
trt_edgellm::rt::Hash128 const &value
) const noexcept#
Hash128 trt_edgellm::rt::hashOpaqueIdentity(std::string_view bytes)#

Deterministically hash exact opaque bytes for adapter, media, or isolation identity. This uses the same non-cryptographic 128-bit FNV-1a primitive as block chaining.

BlockHash trt_edgellm::rt::hashBlock(
BlockHash parent,
int32_t const *tokens,
size_t count,
BlockKeyExtras const &extras,
Hash128 const *perPositionMediaHash
)#

Hash one caller-supplied token block and its non-token identity into its parent chain.

The implementation uses deterministic 128-bit Fowler-Noll-Vo (FNV-1a) over a tagged byte stream. It is a non-cryptographic hash; this layer does not perform a secondary token comparison when two hashes are equal.

When perPositionMediaHash is non-null, at each token position where the entry is non-zero the 128-bit content hash is fed into the byte stream instead of the 4-byte token ID. A zero Hash128 means “use the token ID”. Passing nullptr (default) uses token IDs for all positions.

std::vector<BlockHash> trt_edgellm::rt::hashFullBlocks(
int32_t const *tokens,
size_t tokenCount,
int32_t pageSize,
std::vector<BlockKeyExtras> const &extrasPerBlock,
Hash128 const *perPositionMediaHash
)#

Hash each complete token block in order, chaining from kCHAIN_ROOT and excluding any partial tail.

When perPositionMediaHash is non-null it must cover the full token range (tokenCount entries). The appropriate slice is passed to each block.

BlockHash trt_edgellm::rt::hashExactPrefix(
int32_t const *tokens,
size_t tokenCount,
int32_t pageSize,
std::vector<BlockKeyExtras> const &extrasPerBlock
)#

Hash an exact token prefix, including a partial final block when present.

When extras are supplied, one entry is required for every touched block (ceil(tokenCount / pageSize)). An aligned prefix returns the same digest as its final complete BlockHash; an empty prefix returns kCHAIN_ROOT.