# Cuetree API — hashing backends ## Backend selection Cuetree's attribute IDs, POSIX binding IDs and default persistence checksums use unseeded XXH3-64. Their existing owners specify the input bytes and output representation. The default JVM backend uses the pinned hash4j implementation. The host-only seeded MockMediaID remains independent of this SPI and unchanged. A host may register a public no-argument implementation of `link.roadio.cuetree.Xxh3Backend` using Java ServiceLoader. Its resource is `META-INF/services/link.roadio.cuetree.Xxh3Backend`, containing the implementation's fully qualified class name. The interface's class loader discovers providers once, lazily on the first relevant hash. Selection is immutable for that class loader. It accepts exactly one available provider, or the JVM default when none is available. More than one available provider, a broken service declaration or provider initialization failure aborts selection; there is no silent fallback after a selected backend fails. ## Interfaces ```kotlin interface Xxh3Backend { fun isAvailable(): Boolean = true fun hash(bytes: ByteArray): Long fun stream(): Xxh3Stream } interface Xxh3Stream : AutoCloseable { fun update(bytes: ByteArray, offset: Int = 0, length: Int = bytes.size - offset) fun digest(): Long } ``` The backend is shared and must support concurrent callers by creating independent streams. `isAvailable()` must avoid loading facilities absent on that runtime; an unavailable provider must be safe to discover on the JVM. Hashes are seed zero with standard XXH3-64 bit patterns represented as signed Long. An empty input is valid. Hashing must leave caller bytes unchanged. Each stream is owned and closed by its caller, including cancellation/error paths. Updates consume only the requested valid byte range in order; invalid ranges fail. Digest is non-destructive, so further updates remain possible. Streams need not support concurrent use. Closing is idempotent; updates or digest after close fail. A native adapter must release its native state on close. Adapters supply computation only. They do not normalize text, frame attributes, change persistence validation, alter MediaIdGenerator or inject platform imports into Cuetree.