Expand description
§claw-core
claw-core is the embedded local database engine for ClawDB — an
agent-native cognitive database. It provides local-first, ultra-low-latency
storage for AI agents, wrapping SQLite with a clean async Rust API that
includes WAL journaling, migrations, LRU caching, FTS5 full-text search,
transactions, and snapshot/restore support.
§Quick start
use claw_core::prelude::*;
#[tokio::main]
async fn main() -> claw_core::ClawResult<()> {
// Open (or create) the database with default settings.
let engine = ClawEngine::open_default().await?;
// Insert a memory record.
let record = MemoryRecord::new(
"The capital of France is Paris",
MemoryType::Semantic,
vec!["geography".to_string()],
None,
);
let id = engine.insert_memory(&record).await?;
// Retrieve it back.
let fetched = engine.get_memory(id).await?;
assert_eq!(fetched.content, "The capital of France is Paris");
// Close the engine cleanly.
engine.close().await;
Ok(())
}§Key types
| Type | Description |
|---|---|
ClawEngine | Root handle for all database operations |
ClawConfig | Runtime configuration built via ClawConfigBuilder |
MemoryRecord | A persistent memory record with type, tags, and TTL |
MemoryType | Enum classifying memory records (Semantic, Episodic, …) |
ClawTransaction | Atomic transaction wrapper |
ClawError | Unified error type |
Re-exports§
pub use cache::CacheStats;pub use config::ClawConfig;pub use config::ClawConfigBuilder;pub use config::JournalMode;pub use engine::ClawEngine;pub use engine::ClawStats;pub use engine::DbStats;pub use error::ClawError;pub use error::ClawResult;pub use journal::CheckpointMode;pub use journal::CheckpointResult;pub use snapshot::SnapshotManifest;pub use snapshot::SnapshotMeta;pub use snapshot::Snapshotter;pub use store::memory::ListOptions;pub use store::memory::MemoryRecord;pub use store::memory::MemoryType;pub use store::session_lifecycle::Session;pub use store::tool_output::ToolOutputRecord as ToolOutput;pub use transaction::CacheOp;pub use transaction::CacheRecord;pub use transaction::ClawTransaction;pub use transaction::StagedOp;
Modules§
- cache
- In-memory LRU cache layer for claw-core.
- config
- Configuration for claw-core.
- engine
- Main engine entry point for claw-core.
- error
- Error types for claw-core.
- index
- Lightweight FTS and B-tree index helpers for claw-core.
- journal
- WAL configuration helpers for claw-core.
- prelude
- The claw-core prelude — import this for the most commonly used types.
- schema
- Schema modules for claw-core.
- snapshot
- Snapshot and restore logic for claw-core.
- store
- Store modules for claw-core.
- transaction
- Transaction wrapper for claw-core.