- Rust workspace with stemedb-core crate - Full .claude/ configuration (agents, skills, commands, guides) - ai-lookup/ for token-efficient fact storage - Quality gates: clippy, fmt, jscpd duplication detection - Pre-commit hook with 5-phase quality checks - CLAUDE.md router and CODING_GUIDELINES.md standards Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
51 lines
1.2 KiB
Markdown
51 lines
1.2 KiB
Markdown
# Storage
|
|
|
|
**Last Updated:** 2025-01-31
|
|
**Confidence:** High
|
|
|
|
## Summary
|
|
|
|
Episteme uses a Log-Structured, Content-Addressed storage model. Writes append to WAL, then index asynchronously. Reads query indexes and apply Lenses.
|
|
|
|
**Key Facts:**
|
|
- Append-only (never mutate)
|
|
- WAL for durability (fsync on write)
|
|
- KV store for indexes (sled MVP, trait-abstracted)
|
|
- Content-addressed by BLAKE3 hash
|
|
|
|
**File Pointer:** `crates/stemedb-core/src/store.rs` (planned)
|
|
|
|
## KV Layout
|
|
|
|
| Key Pattern | Value | Purpose |
|
|
|-------------|-------|---------|
|
|
| `H:{Hash}` | `Assertion` (serialized) | Main content store |
|
|
| `S:{Subject}` | `Vec<Hash>` | Subject index |
|
|
| `SP:{Subject}:{Predicate}` | `Vec<Hash>` | Triple index |
|
|
| `A:{AgentId}` | `ReputationScore` | TrustRank storage |
|
|
|
|
## Write Path
|
|
|
|
```
|
|
1. Agent submits signed Assertion
|
|
2. Validate signature
|
|
3. Append to WAL (fsync)
|
|
4. Return 202 Accepted with Hash
|
|
5. Background: tail WAL -> update indexes
|
|
```
|
|
|
|
## Read Path
|
|
|
|
```
|
|
1. Query: GET(Subject, Predicate, Lens)
|
|
2. Lookup: SP:{Subject}:{Predicate} -> [Hash...]
|
|
3. Hydrate: Load assertions from H:{Hash}
|
|
4. Resolve: Apply Lens
|
|
5. Return: Deterministic answer
|
|
```
|
|
|
|
## Related Topics
|
|
|
|
- [Assertion](./assertion.md)
|
|
- [Architecture](../../../architecture.md)
|