mubit-sdk (Rust)
Canonical Rust SDK for MuBit.
Install
Three Layers
The SDK offers three integration depths. Start at the top and drop down only when you need more control.
| Layer | Module | What it does | When to use |
|---|---|---|---|
| Learn | learn |
Explicit enrich_messages() / record() / end() for closed-loop memory with lesson injection |
Closed-loop learning with full async control |
| Helpers | Client |
17 explicit methods for memory write/read, context assembly, reflection, multi-agent coordination | Fine-grained control over what gets remembered, queried, and when reflection triggers |
| Raw | client.auth, client.core, client.control |
Direct 1:1 mappings to every gRPC/HTTP endpoint | Wire debugging, async ingest job polling, compatibility routes |
Layer 1: Learn (Closed-Loop Memory)
The learn module provides explicit methods for closed-loop memory. Unlike Python/JS, Rust does not use monkey-patching — call enrich_messages() before your LLM call and record() after.
use ;
use json;
let session = new.await;
let messages = vec!;
// Enrich with lessons before LLM call
let enriched = session.enrich_messages.await;
// Make your LLM call with enriched messages...
// Record the interaction
session.record.await;
// End run (triggers reflection)
session.end.await;
Key config: inject_lessons, injection_position, max_token_budget, auto_reflect, cache_ttl_seconds, fail_open.
Layer 2: Client Helpers
Quickstart
use ;
use env;
async
Methods by Use Case
| Use case | Methods | What they do |
|---|---|---|
| Basic memory | remember, recall |
Ingest content with intent classification; semantic query with evidence scoring |
| Prompt context | get_context |
Token-budgeted, pre-assembled context block for LLM prompt injection (rules → lessons → facts) |
| Exact artifacts | archive, dereference |
Bit-exact storage with stable reference IDs; retrieval without semantic search |
| Run lifecycle | checkpoint, reflect, record_outcome |
Durable pre-compaction state; LLM-powered lesson extraction; reinforcement feedback |
| Multi-agent | register_agent, list_agents, handoff, feedback |
Scoped read/write access per agent; task transfer between agents |
| Diagnostics | memory_health, diagnose, surface_strategies, forget |
Staleness metrics; contextual error debugging; lesson clustering; deletion |
Helper calls take typed option structs instead of raw serde_json::Value payload bags.
The Learning Loop
1. remember() → ingest facts, traces, lessons into MuBit
2. reflect() → LLM extracts lessons from run evidence
(auto-promotes recurring lessons: run → session → global)
3. get_context() → retrieve relevant lessons for the next LLM call
4. record_outcome() → reinforce what worked, adjust confidence scores
With LearnSession, steps 1 and 3 are handled by record() and enrich_messages(). With helpers, you orchestrate them yourself.
Exact References
use ;
let client = new?;
let mut archive = new;
archive.run_id = Some;
archive.labels = vec!;
let archived = client.archive.await?;
let mut dereference = new;
dereference.run_id = Some;
let exact = client.dereference.await?;
println!;
Layer 3: Raw Domains
Low-level 1:1 mappings to every API endpoint on client.auth, client.core, and client.control.