Skinki
A local-first memory engine exploring how retrieval, provenance and long-term memory can make AI systems more capable.
What problem was framed
Current frontier models rely either on bloated remote context windows (which degrade in retrieval needle recall and leak private data) or naïve vector chunking (which breaks multi-hop joins across conversations separated by weeks).
The core question: Can an intelligent, deterministic memory substrate handle indexing, entity consolidation, multi-hop joins, and causal grounding locally on consumer hardware—allowing a small ~4B parameter model to behave with the long-term context awareness of an enterprise assistant?
Guiding technical constraints
Layered Architecture (L0 to L5)
Skinki is structured as a headless Rust engine with clear layer responsibilities, isolating fast append paths from background graph consolidation and agent context assembly.
┌────────────────────────────────────────────────────────────────────────┐
│ L0 CAPTURE: Append-only raw log (Source of Truth & Provenance Bytes) │
└───────────────────────────────────┬────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────────────┐
│ L1 UNITS: Atomic thoughts & facts referencing L0 byte slices │
└───────────────────┬────────────────────────────────┬───────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────┐ ┌───────────────────────────────┐
│ L2a VECTOR INDEX │ │ L2b KNOWLEDGE GRAPH │
│ Model2Vec first-pass + RaBitQ quant │ │ Entities, relations, temporal │
└───────────────────┬─────────────────┘ └───────────────┬───────────────┘
│ │
└─────────────────┬──────────────────┘
│ (Deferred to idle on power)
▼
┌────────────────────────────────────────────────────────────────────────┐
│ L3 SLEEP CONSOLIDATION: Incremental extraction (LightRAG style), │
│ Leiden community hierarchies (RAPTOR), HippoRAG 2 / PPR associative │
└─────────────────────────────────────┬──────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────────────┐
│ L4 INSIGHT ENGINE: Deterministic discovery ──▶ Stat validation (FDR) │
│ (Separating discovery from LLM narration: "Cite or stay silent") │
└─────────────────────────────────────┬──────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────────────┐
│ L5 AGENT / QUERY / MCP CONTEXT ASSEMBLER │
│ Budgeted, cited facts + pre-joined multi-hop chains for small LLMs │
└────────────────────────────────────────────────────────────────────────┘ Architectural Trade-Off Matrix
| Decision | Why | Alternatives Rejected | Trade-Off Incurred |
|---|---|---|---|
| Rust Core Engine | Predictable RAM, `no_std` hot paths, zero garbage collection pauses on background consolidation. | Python (LangChain/LlamaIndex), Swift-only app | Higher upfront development cost and FFI boundary boilerplate for UI consumers. |
| Sleep-Time Consolidation | Keeps text capture instant (<1ms) and prevents battery drain while typing on laptop. | Realtime graph building on every input | New memories require idle time before appearing in deep community summaries. |
| Coarse-to-Fine Search Hierarchy | 46% relative retrieval gain (0.291 → 0.438) by scoping turn search to relevant dialogue instances. | Flat top-k dense search across all turns | Requires clustering step and two-phase scoring pipeline. |
| Deterministic Statistical Validation | Prevents agent hallucinations by subjecting discovered candidate links to false discovery rate (FDR) gates. | Direct LLM reflection / free-form summarization | Conservative output: engine stays silent if evidence confidence threshold is unmet. |
Benchmarks & Quantitative Signals
GraphRAG Falsification: When Graph Retrieval Fails to Transfer
On a deterministic synthetic corpus, adding a typed relation graph raised multi-hop recall@10 from 0.325 to 0.800. However, when tested on real human dialogue (pooled LongMemEval multi-session instances spanning 9,697 turns), the graph retriever scored 0.168 recall@10, falling below ordinary BM25 (0.193) and dense retrieval (0.291).
| Retriever | Recall@10 | Answer@10 | nDCG@10 |
|---|---|---|---|
| BM25 (Lexical Baseline) | 0.193 | 0.450 | 0.154 |
| Co-mention graph + BM25 | 0.168 | 0.450 | 0.112 |
| Typed-fact graph + BM25 | 0.168 | 0.450 | 0.109 |
| EmbeddingGemma (256 dims) | 0.291 | 0.450 | 0.187 |
| Coarse-to-Fine Dense Hierarchy | 0.438 | 0.500 | 0.245 |
- Schema Coupling: The synthetic generator and retriever shared a causal grammar. Real dialogue broke this with speaker references, paraphrases, and aliases.
- Reachability ≠ Ranking: Adding graph edges brought in relevant chains, but also flooded candidate pools with conversational hub nodes, displacing valid lexical hits during rank fusion.
- Extraction Errors: Mistaken entity resolution in a graph creates false topological shortcuts, redistributing relevance across irrelevant passages.
What is working right now
- L0/L1 Storage Substrate: Append-only log + memory unit indexing with zero-copy byte provenance.
- L2 Vector & Graph Index: Mmap-backed storage with Model2Vec and RaBitQ quantization.
- L3 Sleep Scheduler: Interruptible background consolidation gated by idle/power states.
- Eval Harness: Rigorous synthetic corpus generator with deterministic multi-hop ground truth and regression test suite.
- MCP Server Surface: Standard Model Context Protocol interface exposing memory queries to Claude/Cursor/OpenAI tooling.
Current R&D focus
Building the L4 Insight Engine with statistical discovery filters (FDR control) and causal skepticism, ensuring that multi-hop patterns surfaced to the user are mathematically grounded before being passed to small LLM verbalizers.