Skip to content

hanzo-brain: pure-CPU algorithm primitives + BLAKE3 byte-equivalent across all 5 runtimes#7

Closed
hanzo-dev wants to merge 10 commits into
mainfrom
ci/canonical-docker-build-1776996310
Closed

hanzo-brain: pure-CPU algorithm primitives + BLAKE3 byte-equivalent across all 5 runtimes#7
hanzo-dev wants to merge 10 commits into
mainfrom
ci/canonical-docker-build-1776996310

Conversation

@hanzo-dev
Copy link
Copy Markdown
Member

Summary

Adds hanzo-libs/hanzo-brain — the canonical Rust port of the Hanzo Brain algorithm surface inside the node workspace. Brain's recall / search / ingest are now first-class node calls; no sidecar needed.

Five runtimes ship the same algorithm surface, byte-equivalent on the wire:

Runtime Where Hash
TypeScript hanzoai/brain@hanzo/bot-memory @noble/hashes/blake3
Python hanzoai/python-sdkhanzo-memory blake3 pip (mirror: hanzoai/blake3-py)
Go hanzoai/bot-gopkg/brain lukechampine.com/blake3 (mirror: hanzoai/blake3-go)
Rust (node) this PR — hanzo-libs/hanzo-brain blake3 crate (hanzoai/blake3 fork)
Rust (mcp) hanzoai/mcp blake3 crate
C++ hanzoai/bot-cpp vendored BLAKE3 ref (tracked from hanzoai/blake3)

Wallet address for [0u8; 32]hanzo:UFC8qCW8LRUmpfyRq2qnAvYi11cqftY3b on every runtime.

Commits

  • c0e3bf30e hanzo-brain crate (38 unit tests passing)
  • d3a2e64e6 silence unused_mut warning + tighten lib doc
  • e74a64405 swap sha2 stand-in for the workspace blake3 crate

75adceda7 (ci: add id-token: write to caller permissions) is a pre-existing CI fix that was already on this branch — included as-is.

Test plan

  • cargo build -p hanzo-brain — clean
  • cargo test -p hanzo-brain --lib — 38 / 38 passed
  • Cross-runtime address verification — five runtimes produce identical base58check string

Sister crates already inside the node workspace that the brain wires into:

  • hanzo-libs/hanzo-consensus (Quasar metastable consensus)
  • hanzo-libs/hanzo-zap (ZAP transport)
  • hanzo-libs/hanzo-pqc (post-quantum signatures)
  • hanzo-libs/hanzo-machine (threshold crypto)
  • hanzo-libs/hanzo-db-sqlite (SQLite + FTS5 default storage)

Chain layer (validators, bridge, DEX, faucet, explorer, wallet) lives in the hanzonet org and is inherited by the node.

Lists the 3-VM triumvirate (cevm GPU EVM, dexvm CLOB, thresholdvm
FHE) plus all 8 other optional VMs that hanzod inherits via
github.com/luxfi/node/app.New. The actual registration happens in
luxfi/node/node/vms.go (registerOptionalVMs).

Useful for smoke-testing that the daemon links the luxcpp 3-VM
bindings correctly without needing to start the full network.
Add `lux-crypto-sys` (FFI to luxcpp/crypto C-ABI) as a workspace path
dep alongside existing `oqs` / `k256` / `ed25519-dalek` so a future
PR can migrate ML-KEM / ML-DSA / SLH-DSA call sites in hanzo-pqc to
the canonical C-ABI without touching this manifest.

No call sites are migrated in this commit -- the crate continues to
use `oqs` and friends. This is forward groundwork only.
…rgo features

Adds a `lux-crypto-impl` cargo feature that routes ML-DSA, ML-KEM, SLH-DSA
and Ed25519 through the canonical luxcpp/crypto FFI (`lux_crypto::*`).

The legacy backends are gated behind `legacy-oqs` and `legacy-ed25519-dalek`
and remain bundled in `default` because the canonical luxcpp
ML-DSA/ML-KEM/SLH-DSA C-ABI symbols presently return CRYPTO_ERR_NOTIMPL.
Default build keeps existing behaviour; once the canonical impls land,
flip default to ["lux-crypto-impl", ...] and drop the legacy features.

Adds tests/lux_crypto_parity.rs with byte-equal RFC 8032 Ed25519 test
vectors against both backends, plus ML-DSA/ML-KEM functional roundtrip
checks that honestly skip when the canonical impl returns NotImpl.

hanzo-mining and hanzo-kbs need no migration: hanzo-mining has no
oqs/k256/ed25519-dalek/secp256k1 call sites; hanzo-kbs is excluded from
the workspace per its own Cargo.toml note.

Test: cargo test -p hanzo-pqc → 47 lib + 10 integration + 1 parity = 58 pass
Test: cargo test -p hanzo-mining --lib → 31 pass
Cargo.lock catches up to lux-crypto sub-crate split (keccak/ripemd160/
secp256k1/sha256). docs/vms/ adds reference for hanzod's D-Chain/C-Chain/
T-Chain split per recent VM subcommand work.
Required for hanzoai/.github/.github/workflows/docker-build.yml@main —
without it the workflow_call dies as startup_failure with no jobs
dispatched. Caller permissions are a CEILING.
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.
@gitguardian
Copy link
Copy Markdown

gitguardian Bot commented May 11, 2026

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
32161365 Triggered Generic High Entropy Secret 003d708 hanzo-libs/hanzo-pqc/tests/lux_crypto_parity.rs View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@hanzo-dev
Copy link
Copy Markdown
Member Author

Superseded by clean cherry-pick branch — see new PR.

@hanzo-dev hanzo-dev closed this May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant