totalreclaw_core/lib.rs
1//! TotalReclaw Core — Canonical crypto primitives and shared logic.
2//!
3//! This crate is the single source of truth for all TotalReclaw cryptographic
4//! operations. It provides WASM and PyO3 bindings (feature-gated) so that
5//! TypeScript, Python, and Rust consumers share byte-for-byte identical output.
6//!
7//! # Modules
8//!
9//! - [`crypto`] — Key derivation (BIP-39 + HKDF-SHA256), XChaCha20-Poly1305 encrypt/decrypt
10//! - [`lsh`] — Locality-sensitive hashing (random hyperplane LSH)
11//! - [`blind`] — Blind index generation (SHA-256 token hashing + Porter stemming)
12//! - [`stemmer`] — Porter 1 stemmer (hand-rolled, NOT Snowball/Porter 2)
13//! - [`fingerprint`] — Content fingerprint (HMAC-SHA256 with NFC normalization)
14//! - [`protobuf`] — Minimal protobuf encoder for fact payloads
15//! - [`reranker`] — BM25 + Cosine + RRF fusion reranker
16//! - [`debrief`] — Session debrief response parser
17//! - [`store`] — Store pipeline (pure computation: encrypt, index, encode)
18//! - [`search`] — Search pipeline (pure computation: trapdoors, parse, decrypt+rerank; feature: `managed`)
19//! - [`wallet`] — Ethereum wallet derivation (BIP-44 + Keccak256)
20//! - [`userop`] — ERC-4337 v0.7 UserOp building + signing (feature: `managed`)
21//! - [`hotcache`] — Generic in-memory hot cache for semantic query dedup (no WASM binding)
22//! - [`consolidation`] — Store-time near-duplicate detection + supersede logic
23//! - [`smart_import`] — Smart import profiling (prompt construction + response parsing)
24
25pub mod blind;
26pub mod claims;
27pub mod consolidation;
28pub mod contradiction;
29pub mod decision_log;
30pub mod feedback_log;
31pub mod digest;
32pub mod crypto;
33pub mod debrief;
34pub mod fingerprint;
35pub mod hotcache;
36pub mod lsh;
37pub mod protobuf;
38pub mod reranker;
39pub mod smart_import;
40pub mod stemmer;
41pub mod store;
42pub mod wallet;
43
44#[cfg(feature = "managed")]
45pub mod search;
46#[cfg(feature = "managed")]
47pub mod userop;
48
49#[cfg(feature = "wasm")]
50pub mod wasm;
51
52#[cfg(feature = "python")]
53pub mod python;
54
55/// Crate-level error type.
56#[derive(Debug, thiserror::Error)]
57pub enum Error {
58 #[error("crypto error: {0}")]
59 Crypto(String),
60
61 #[error("invalid mnemonic: {0}")]
62 InvalidMnemonic(String),
63
64 #[error("LSH error: {0}")]
65 Lsh(String),
66
67 #[error("reranker error: {0}")]
68 Reranker(String),
69}
70
71pub type Result<T> = std::result::Result<T, Error>;