hanzo-brain: pure-CPU algorithm primitives + BLAKE3 across all 5 runtimes#8
Merged
Conversation
Adds hanzo-libs/hanzo-brain — the canonical Rust port of the Hanzo
Brain algorithm surface inside the node workspace. Mirrors the TS
canonical (@hanzo/bot-memory), Python (hanzo-memory), Go (bot-go/pkg/
brain), and C++ (bot-cpp) ports. 38 unit tests passing.
Lives alongside the rest of the brain's wire-up inside hanzoai/node:
hanzo-consensus Quasar metastable consensus (storage quorum)
hanzo-zap ZAP transport
hanzo-pqc post-quantum signatures (recipient blocks)
hanzo-machine threshold-crypto primitives (MMPKE01 wraps)
hanzo-db-sqlite SQLite + FTS5 default storage
This makes brain.recall / brain.search / brain.ingest first-class node
RPC methods — any agent talking to a Hanzo Node gets the brain without
a sidecar.
Algorithm surface (mirrored across all five runtimes):
- Retrieval: RRF, RSF, adaptive k + weights, MMR, dedup, two-stage MRL
- Text: Unicode script detection, CJK bigrams, emoji trigrams,
websearch_to_tsquery, FTS5 MATCH renderer
- Embed: model registry, asymmetric E5 prefixes, MRL truncation
- Eval: MRR, recall@k, precision@k, NDCG@k
- Temporal: UUIDv7 floor/ceiling
- Captions: WebVTT / SRT / RTTM
- Crypto: wallet-style content-addressable ids
- Graph: normalize → SNN → PFNET → Louvain
- Inference: provider slug, runtime config (db_override → env →
default), link-type classifier
- algorithms.rs: drop redundant `mut` from the `flush` closure binding in estimate_tokens (the closure is `FnMut` via the captures it needs, not via the binding). Clears the only cargo-build warning the crate emits. - lib.rs: describe siblings as "workspace crates" without org-style links; spell out that this crate lives at hanzo-libs/hanzo-brain/ inside the hanzoai/node Cargo workspace; add hanzo-runtime as a sibling integration. Build clean. cargo test -p hanzo-brain --lib: 38 passed; 0 failed. Algorithm surface unchanged (byte-equivalent with hanzoai/mcp mirror).
Swapped sha2 stand-in for the workspace blake3 crate so wallet addresses match the TS canonical (@noble/hashes/blake3), Python (blake3 pip), Go (lukechampine.com/blake3), and C++ (vendored reference impl) byte- for-byte: encode_address([0u8;32], None) → hanzo:UFC8qCW8LRUmpfyRq2qnAvYi11cqftY3b (all five runtimes) 38 brain tests still pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
hanzo-libs/hanzo-brain— the canonical Rust port of the Hanzo Brain algorithm surface inside the node workspace. Brain'srecall/search/ingestare now first-class node calls; no sidecar needed.Five runtimes ship the same algorithm surface, byte-equivalent on the wire:
hanzoai/brain—@hanzo/bot-memory@noble/hashes/blake3hanzoai/python-sdk—hanzo-memoryblake3pip (mirror:hanzoai/blake3-py)hanzoai/bot-go—pkg/brainlukechampine.com/blake3(mirror:hanzoai/blake3-go)hanzo-libs/hanzo-brainblake3crate (hanzoai/blake3fork)hanzoai/mcpblake3cratehanzoai/bot-cpphanzoai/blake3)Cross-runtime verification —
encode_address([0u8; 32], "hanzo"):hanzo:UFC8qCW8LRUmpfyRq2qnAvYi11cqftY3b(identical on every runtime).
What this adds to the node workspace
hanzo-libs/hanzo-brain(new workspace member)src/algorithms.rs— 1454 lines, 38 unit testssrc/lib.rs— crate root + doc cross-references to sibling cratesCargo.toml— depends onblake3 = { workspace = true }andonce_cellCargo.toml(1 line in[workspace.members])Cargo.lock(regenerated)Commits
hanzo-brain: pure-CPU algorithm primitives shipped as a node-side lib(initial crate)hanzo-brain: silence unused_mut warning + tighten lib dochanzo-brain: BLAKE3 (matches all five brain runtimes)Test plan
cargo build -p hanzo-brain— cleancargo test -p hanzo-brain --lib— 38 / 38 passedSister crates the brain wires into (already in workspace)
hanzo-libs/hanzo-consensus(Quasar metastable consensus)hanzo-libs/hanzo-zap(ZAP transport)hanzo-libs/hanzo-pqc(post-quantum signatures)hanzo-libs/hanzo-db-sqlite(SQLite + FTS5 default storage)Chain layer (validators, bridge, DEX, faucet, explorer, wallet) lives in the
hanzonetorg and is inherited by the node.