Expand description
TotalReclaw Memory Backend
Rust implementation of the TotalReclaw E2EE memory pipeline. Produces byte-for-byte identical crypto output to the TypeScript MCP server.
§Modules
crypto— Key derivation (BIP-39 + HKDF-SHA256), XChaCha20-Poly1305 encrypt/decryptblind— Blind index generation (SHA-256 token hashing + Porter stemming)fingerprint— Content fingerprint (HMAC-SHA256 with NFC normalization)lsh— Locality-sensitive hashing (random hyperplane LSH)embedding— Embedding pipeline (Local ONNX, Ollama, ZeroClaw, LLM provider)reranker— BM25 + Cosine + RRF fusion rerankerrelay— HTTP client for TotalReclaw relay serverprotobuf— Minimal protobuf encoder for fact payloadsstore— Encrypt → index → encode → submit pipeline (with Phase 2 KG contradiction check)search— Subgraph query → decrypt → rerank pipelinebackend— ZeroClaw Memory trait implementationsetup— First-use setup wizard (credentials + embedding config)
Re-exports§
pub use backend::MemoryCategory;pub use backend::MemoryEntry;pub use backend::TotalReclawConfig;pub use backend::TotalReclawMemory;pub use store::ContradictionStoreResult;
Modules§
- backend
- ZeroClaw Memory trait implementation.
- billing
- Billing cache with 2-hour TTL and feature flags parsing.
- blind
- Blind index generation (SHA-256 token hashing + Porter stemming).
- crypto
- Key derivation and XChaCha20-Poly1305 encryption.
- debrief
- Session debrief extraction for TotalReclaw.
- embedding
- Embedding pipeline with 4 modes.
- fingerprint
- Content fingerprint (HMAC-SHA256 with NFC normalization).
- hotcache
- In-memory hot cache for recently recalled facts.
- lsh
- Locality-Sensitive Hashing (Random Hyperplane LSH).
- protobuf
- Minimal protobuf encoder for TotalReclaw fact payloads.
- relay
- Relay HTTP client for the TotalReclaw managed service.
- reranker
- Reranker — re-exported from totalreclaw-core.
- search
- Subgraph search pipeline.
- setup
- First-use setup wizard for TotalReclaw.
- stemmer
- Porter Stemmer (Porter 1 algorithm).
- store
- Store pipeline – encrypt, index, encode, submit.
- userop
- Native ERC-4337 UserOperation construction and submission.
- wallet
- Ethereum wallet derivation and Smart Account resolution.
Structs§
- Claim
- Contradiction
- A detected contradiction between two claims that share an entity.
- Decision
LogEntry - A single row in
decisions.jsonl. - Entity
Ref - Memory
Claim V1 - A v1 memory claim per the Memory Taxonomy v1 spec.
- Memory
Entity V1 - Structured entity reference inside a v1 claim.
- Resolution
Outcome - Output of running the resolution formula on a contradiction.
- Resolution
Weights - Weights for the resolution formula. Defaults come from P2-3.
- Score
Components - Per-component breakdown of a claim’s score.
Enums§
- Claim
Category - Claim
Status - Entity
Type - Error
- Crate-level error type.
- Memory
Scope - Life-domain scope for a memory claim. Open-extensible per client, but every v1-compliant client MUST accept all values defined here when reading from a vault written by another client.
- Memory
Source - Provenance source for a memory claim.
- Memory
Type V1 - v1 memory type — closed enum of 6 speech-act-grounded categories.
- Memory
Volatility - Temporal stability of a memory claim. Assigned in the comparative rescoring pass, not at single-claim extraction.
- Resolution
Action - The action to take after checking pin status and tie-zone guard during contradiction resolution.
- Skip
Reason - Why a new claim was skipped in favour of the existing one.
Constants§
- CONTRADICTION_
CANDIDATE_ CAP - Soft cap on candidates fetched per entity during contradiction detection.
- DECISION_
LOG_ MAX_ LINES - Cap on the decisions.jsonl log — oldest lines are dropped above this.
- DEFAULT_
LOWER_ THRESHOLD - Default contradiction detection band lower bound (below = unrelated).
- DEFAULT_
UPPER_ THRESHOLD - Default contradiction detection band upper bound (at/above = duplicate).
- MEMORY_
CLAIM_ V1_ SCHEMA_ VERSION - The required
schema_versionvalue for all v1 claims. - TIE_
ZONE_ SCORE_ TOLERANCE - Tie-zone score tolerance for contradiction resolution.
Functions§
- append_
decision_ entry - Append one decision-log entry (as JSON string) to existing JSONL content.
- build_
feedback_ from_ decision - Build a
FeedbackEntryJSON from a decision-log entry JSON and a pin action. - default_
weights - Structurally defensible default weights from P2-3 of the Phase 2 design doc.
- detect_
contradictions - Detect contradictions between a new claim and existing claims that share at least one entity.
- find_
decision_ for_ pin - Walk
decisions.jsonlcontent in reverse and return the firstsupersede_existingdecision where the fact appears as winner or loser. - find_
loser_ claim_ in_ decision_ log - Walk
decisions.jsonlcontent in reverse and return theloser_claim_jsonfor the most recentsupersede_existingdecision whereexisting_claim_id == fact_id. - is_
pinned_ claim - Check whether a claim has pinned status.
- is_
pinned_ json - Check whether a JSON-serialized claim has pinned status.
- resolve_
pair - Run the resolution formula on two contradicting claims. Returns winner and loser.
Ties (equal weighted totals) favour
claim_adeterministically. - resolve_
with_ candidates - Core orchestration loop for contradiction resolution.
- respect_
pin_ in_ resolution - Apply pin-status and tie-zone checks to a resolution outcome.