claw-core
Embedded local database engine for ClawDB โ an agent-native cognitive database.
Features
- ๐ Local-first โ all data stays on device; no network dependency
- ๐ WAL journaling โ SQLite Write-Ahead Logging for high-concurrency reads
- โก Async Rust โ fully async via
tokio+sqlx - ๐ง LRU cache โ configurable in-memory LRU cache reduces DB round-trips
- ๐ FTS5 search โ full-text search over memory content using SQLite FTS5
- ๐ธ Snapshot/restore โ point-in-time database snapshots
- ๐ Migration system โ embedded, versioned SQL migrations via
sqlx::migrate! - ๐ ACID transactions โ explicit commit/rollback via
ClawTransaction
Quick start
use *;
async
ClawConfig customization
use ;
let config = builder
.db_path
.max_connections
.cache_size_mb
.journal_mode
.snapshot_dir
.auto_migrate
.build
.expect;
Architecture
Caller
โ
โผ
ClawEngine
โโโ LRU Cache (tokio::sync::Mutex<ClawCache>)
โ โโโ MemoryRecord entries (in-memory)
โโโ SqlitePool (sqlx)
โโโ SQLite file (WAL mode)
โโโ memories (+ memories_fts FTS5)
โโโ sessions
โโโ active_memory
โโโ session_state
โโโ tool_output
โโโ context
Performance characteristics
| Operation | Target |
|---|---|
| Cache hit read latency | < 100 ยตs |
| Insert throughput (NVMe) | > 10,000 records/s |
| FTS5 search (10k records) | < 10 ms |
| Tag search (10k records) | < 5 ms |
| WAL checkpoint | < 1 ms (passive) |
Benchmarks:
cargo bench(requirescriterionin dev-dependencies)
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.
- Fork the repository
- Create a feature branch (
git checkout -b feat/my-feature) - Run tests:
cargo test --all-features - Run lints:
cargo clippy -- -D warnings && cargo fmt --check - Submit a pull request
License
Licensed under the Apache-2.0 license.