pub struct TotalReclawMemory { /* private fields */ }Expand description
TotalReclaw memory backend for ZeroClaw.
Implements the ZeroClaw Memory trait with full E2E encryption.
Implementations§
Source§impl TotalReclawMemory
impl TotalReclawMemory
Sourcepub async fn new(config: TotalReclawConfig) -> Result<Self>
pub async fn new(config: TotalReclawConfig) -> Result<Self>
Create a new TotalReclaw memory backend.
This initializes all crypto keys, derives the EOA and Smart Account, sets up the LSH hasher, the embedding provider, and registers with the relay.
Sourcepub fn wallet_address(&self) -> &str
pub fn wallet_address(&self) -> &str
Get the wallet address.
Sourcepub fn relay(&self) -> &RelayClient
pub fn relay(&self) -> &RelayClient
Get a reference to the relay client.
Sourcepub fn keys(&self) -> &DerivedKeys
pub fn keys(&self) -> &DerivedKeys
Get a reference to the derived keys.
Sourcepub fn private_key(&self) -> &[u8; 32]
pub fn private_key(&self) -> &[u8; 32]
Get a reference to the private key.
Sourcepub async fn store(
&self,
_key: &str,
content: &str,
category: MemoryCategory,
_session_id: Option<&str>,
) -> Result<()>
pub async fn store( &self, _key: &str, content: &str, category: MemoryCategory, _session_id: Option<&str>, ) -> Result<()>
Store a memory entry using native UserOp.
Importance defaults to 10 (max) if not specified. Per the client-consistency
spec, decayScore = importance / 10, so importance=10 -> decayScore=1.0.
Clears the hot cache after storing to avoid stale results.
Sourcepub async fn store_with_importance(
&self,
_key: &str,
content: &str,
category: MemoryCategory,
_session_id: Option<&str>,
importance: f64,
) -> Result<()>
pub async fn store_with_importance( &self, _key: &str, content: &str, category: MemoryCategory, _session_id: Option<&str>, importance: f64, ) -> Result<()>
Store a memory entry with explicit importance (1-10 scale).
Per the client-consistency spec, decayScore = importance / 10.
Sourcepub async fn store_batch(&self, facts: &[(&str, &str)]) -> Result<Vec<String>>
pub async fn store_batch(&self, facts: &[(&str, &str)]) -> Result<Vec<String>>
Store multiple memory entries as a single batched UserOp.
Gas savings: ~64% vs individual submissions for batch of 5.
Sourcepub async fn recall(
&self,
query: &str,
limit: usize,
_session_id: Option<&str>,
) -> Result<Vec<MemoryEntry>>
pub async fn recall( &self, query: &str, limit: usize, _session_id: Option<&str>, ) -> Result<Vec<MemoryEntry>>
Recall memories matching a query.
Uses a hot cache to skip remote queries when a semantically similar query (cosine >= 0.85) was recently answered.
Sourcepub async fn auto_recall(&self, query: &str) -> Result<Vec<MemoryEntry>>
pub async fn auto_recall(&self, query: &str) -> Result<Vec<MemoryEntry>>
Auto-recall: search with the spec-mandated top_k=8.
Per the client-consistency spec, auto-recall at session start uses the raw user message as query and returns top 8 after reranking.
Sourcepub async fn get(&self, key: &str) -> Result<Option<MemoryEntry>>
pub async fn get(&self, key: &str) -> Result<Option<MemoryEntry>>
Get a specific memory entry by key/ID.
Sourcepub async fn list(
&self,
_category: Option<&MemoryCategory>,
_session_id: Option<&str>,
) -> Result<Vec<MemoryEntry>>
pub async fn list( &self, _category: Option<&MemoryCategory>, _session_id: Option<&str>, ) -> Result<Vec<MemoryEntry>>
List all memories (paginated export).
Parses each decrypted envelope to extract the correct category (previously hardcoded to Core).
Sourcepub async fn forget(&self, key: &str) -> Result<bool>
pub async fn forget(&self, key: &str) -> Result<bool>
Forget (soft-delete) a memory entry using native UserOp.
Emits a Memory Taxonomy v1 tombstone (outer protobuf version = 4)
so the subgraph can distinguish v1 deletes from legacy v3 deletes.
Sourcepub async fn store_v1(&self, input: &V1StoreInput) -> Result<String>
pub async fn store_v1(&self, input: &V1StoreInput) -> Result<String>
Store a Memory Taxonomy v1 claim (explicit v1 write path).
Use this when the caller has full v1 context (type, source, scope,
volatility, optional reasoning). Produces a v4 protobuf envelope
with the canonical MemoryClaimV1 JSON inner blob.
For the ZeroClaw Memory trait’s simpler (key, content, category)
shape, store_with_importance() remains the primary entry point
and continues to emit v3 envelopes during the v0→v1 migration
window. Switch your agent to store_v1() when you want v1
provenance-weighted reranking at recall time.
Sourcepub async fn pin(&self, _memory_id: &str) -> Result<()>
pub async fn pin(&self, _memory_id: &str) -> Result<()>
Pin a memory claim — supersede it with a new v1 blob whose
volatility: stable signals “never auto-supersede”.
ZeroClaw implements pin as a supersede operation: fetch the fact,
re-store it as a v1 claim with volatility: stable, then tombstone
the prior version. The new claim’s superseded_by field tracks the
previous id so a future unpin can reverse the chain.
Not-yet-implemented: this method returns an error advising the
caller to run the MCP server’s totalreclaw_pin tool instead.
See ZeroClaw 2.0 Known Gaps in CLAUDE.md.
Sourcepub async fn retype(
&self,
_memory_id: &str,
_new_type: MemorySource,
) -> Result<()>
pub async fn retype( &self, _memory_id: &str, _new_type: MemorySource, ) -> Result<()>
Retype a memory claim — change its v1 type (claim → directive, etc.)
via supersede.
Not-yet-implemented in ZeroClaw’s native trait. The MCP server’s
totalreclaw_retype tool is the canonical path.
Sourcepub async fn set_scope(
&self,
_memory_id: &str,
_new_scope: MemoryScope,
) -> Result<()>
pub async fn set_scope( &self, _memory_id: &str, _new_scope: MemoryScope, ) -> Result<()>
Set or change the v1 scope of a memory claim via supersede.
Not-yet-implemented in ZeroClaw’s native trait. The MCP server’s
totalreclaw_set_scope tool is the canonical path.
Sourcepub async fn health_check(&self) -> bool
pub async fn health_check(&self) -> bool
Health check.
Sourcepub async fn status(&self) -> Result<BillingStatus>
pub async fn status(&self) -> Result<BillingStatus>
Billing status – tier, usage, limits. Also updates the billing cache.
Sourcepub async fn billing_cache(&self) -> Result<BillingCache>
pub async fn billing_cache(&self) -> Result<BillingCache>
Fetch billing cache (from disk or relay, with 2h TTL).
Returns a cached billing status with parsed feature flags.
Sourcepub async fn quota_warning(&self) -> Option<String>
pub async fn quota_warning(&self) -> Option<String>
Check for quota warnings (>80% usage).
Returns a human-readable warning message or None if usage is below 80%. Call at session start (before_agent_start equivalent).
Sourcepub async fn debrief(&self, items: &[DebriefItem]) -> Result<usize>
pub async fn debrief(&self, items: &[DebriefItem]) -> Result<usize>
Store debrief items from a session.
ZeroClaw calls this from its consolidation phase or session-end handler. The caller is responsible for running the LLM and passing parsed results.
Each item is stored via the existing store pipeline with
source: "zeroclaw_debrief".
Sourcepub async fn export(&self) -> Result<Vec<MemoryEntry>>
pub async fn export(&self) -> Result<Vec<MemoryEntry>>
Export all memories as plaintext (decrypted).