显示 HN:一个会遗忘、整合并检测矛盾的内存数据库
Show HN: A memory database that forgets, consolidates, and detects contradiction

原始链接: https://github.com/yantrikos/yantrikdb-server

## YantrikDB:认知记忆引擎 YantrikDB是一种新型内存数据库,旨在克服传统向量数据库在规模和“遗忘”方面的局限性。与简单的存储和检索不同,YantrikDB会*思考*其数据,主动整合记忆、检测矛盾并优先考虑相关性。 主要特性包括时间衰减(可配置半衰期)、用于关系映射的实体图谱以及从记忆模式推导出的个性。它使用多信号评分系统——考虑新近性、重要性、相似性和图谱邻近性——以实现准确的回忆。 YantrikDB可作为嵌入式库(Python/Rust)、服务器提供,或通过MCP与AI代理集成。它具有高性能(召回p50约为112毫秒,拥有1689条记忆),并内置了HA集群、加密和死锁检测等强大功能。 它解决了现有方案的不足——向量数据库缺乏内存管理,知识图谱难以处理模糊数据,而框架仅仅是包装器。基准测试表明,与基于文件的记忆方法相比,YantrikDB可以显著节省token并提高精度。YantrikDB旨在超越简单的搜索,为AI创建一个真正*认知*的记忆系统。

## YantrikDB:认知记忆数据库 YantrikDB是一个新的、基于Rust的内存数据库,旨在解决传统向量数据库在使用于AI智能体时存在的局限性。与简单的存储不同,YantrikDB通过整合重复信息、检测矛盾并实施时间衰减(本质上是“忘记”不重要的信息)来*管理*记忆,从而在记忆库增长时保持回忆质量。 开发者在与ChromaDB在约5000条记忆时性能下降后构建了YantrikDB,具体问题在于过时的事实和自我矛盾。它提供单个二进制文件、HTTP/二进制协议,以及通过Docker或Kubernetes提供的、经过严格可靠性测试的高可用(HA)集群设置。 目前处于Alpha阶段,开发者正在寻求反馈:这是否解决了其他构建AI智能体的人面临的实际问题,或者它只是一个针对非常具体、狭窄用例的解决方案?他们正在寻找第二位用户来帮助验证其效用。
相关文章

原文

A memory database that forgets, consolidates, and detects contradictions.

Vector databases store memories. They don't manage them. After 10,000 memories, recall quality degrades because there's no consolidation, no forgetting, no conflict resolution. Your AI agent just gets noisier.

YantrikDB is different. It's a cognitive memory engine — embed it, run it as a server, or connect via MCP. It thinks about what it stores.

Crates.io PyPI Docker License: AGPL-3.0


Three things no other database does

db.record("read the SLA doc by Friday", importance=0.4, half_life=86400)  # 1 day
# 24 hours later, this memory's relevance score has decayed
# 7 days later, recall stops surfacing it unless explicitly queried
# 20 similar memories about the same meeting
for note in meeting_notes:
    db.record(note, namespace="standup-2026-04-12")

db.think()
# → {"consolidation_count": 5}  # collapsed 20 fragments into 5 canonical memories

3. It detects contradictions

db.record("CEO is Alice")
db.record("CEO is Bob")  # added later in another conversation

db.think()
# → {"conflicts_found": 1, "conflicts": [{"memory_a": "CEO is Alice",
#                                         "memory_b": "CEO is Bob",
#                                         "type": "factual_contradiction"}]}

Plus: temporal decay with configurable half-life, entity graph with relationship edges, personality derivation from memory patterns, session-aware context surfacing, multi-signal scoring (recency × importance × similarity × graph proximity).


docker run -p 7438:7438 ghcr.io/yantrikos/yantrikdb:latest
curl -X POST http://localhost:7438/v1/remember -d '{"text":"hello"}'

Single Rust binary. HTTP + binary wire protocol. 2-voter + 1-witness HA cluster via Docker Compose or Kubernetes. Per-tenant quotas, Prometheus metrics, AES-256-GCM at-rest encryption, runtime deadlock detection. See docker-compose.cluster.yml and k8s manifests.

As an MCP server (Claude Code, Cursor, Windsurf)

pip install yantrikdb-mcp

Add to your MCP client config — the agent auto-recalls context, auto-remembers decisions, auto-detects contradictions. No prompting needed. See yantrikdb-mcp.

As an embedded library (Python or Rust)

pip install yantrikdb
# or
cargo add yantrikdb
import yantrikdb
db = yantrikdb.YantrikDB("memory.db", embedding_dim=384)
db.set_embedder(SentenceTransformer("all-MiniLM-L6-v2"))
db.record("Alice leads engineering", importance=0.8)
db.recall("who leads the team?", top_k=3)
db.think()  # consolidate, detect conflicts, derive personality

Live numbers from a 2-core LXC cluster with 1689 memories:

Operation Latency
Recall p50 112ms (most is query embedding ~100ms)
Recall p99 190ms
Batch write 76 writes/sec
Engine lock acquire <0.1ms
Deep health probe <1ms

For pre-computed embeddings (skip query-time embedding), recall p50 drops to ~5ms.


v0.5.11 — hardened alpha. The embeddable engine has been used in production by the YantrikOS ecosystem since early 2026. The network server is newer — running live on a 3-node Proxmox cluster with multiple tenants for the past few weeks.

A 42-task hardening sprint just completed across 8 epics:

  • parking_lot mutexes everywhere with runtime deadlock detection (caught a self-deadlock that would have taken hours to find with std::sync)
  • Per-handler Prometheus metrics, structured JSON logging, deep health checks
  • Chaos-tested failover (leader kill, network partition, kill-9 mid-write)
  • Per-tenant quotas, load shedding, control plane replication
  • 1178 core tests + chaos harness + cargo-fuzz + CRDT property tests
  • 5 operational runbooks, watchdog with auto-restart

Read the maturity notes: https://yantrikdb.com/server/quickstart/#maturity

Current AI memory is:

Store everything → Embed → Retrieve top-k → Inject into context → Hope it helps.

That's not memory. That's a search engine with extra steps.

Real memory is hierarchical, compressed, contextual, self-updating, emotionally weighted, time-aware, and predictive. YantrikDB is built for that.

Why Not Existing Solutions?

Solution What it does What it lacks
Vector DBs (Pinecone, Weaviate) Nearest-neighbor lookup No decay, no causality, no self-organization
Knowledge Graphs (Neo4j) Structured relations Poor for fuzzy memory, not adaptive
Memory Frameworks (LangChain, Mem0) Retrieval wrappers Not a memory architecture — just middleware
File-based (CLAUDE.md, memory files) Dump everything into context O(n) token cost, no relevance filtering

Benchmark: Selective Recall vs. File-Based Memory

Memories File-Based YantrikDB Token Savings Precision
100 1,770 tokens 69 tokens 96% 66%
500 9,807 tokens 72 tokens 99.3% 77%
1,000 19,988 tokens 72 tokens 99.6% 84%
5,000 101,739 tokens 53 tokens 99.9% 88%

At 500 memories, file-based exceeds 32K context windows. At 5,000, it doesn't fit in any context window — not even 200K. YantrikDB stays at ~70 tokens per query. Precision improves with more data — the opposite of context stuffing.

  • Embedded, not client-server — single file, no server process (like SQLite)
  • Local-first, sync-native — works offline, syncs when connected
  • Cognitive operations, not SQLrecord(), recall(), relate(), not SELECT
  • Living system, not passive store — does work between conversations
  • Thread-safeSend + Sync with internal Mutex/RwLock, safe for concurrent access
┌──────────────────────────────────────────────────────┐
│                   YantrikDB Engine                    │
│                                                      │
│  ┌──────────┬──────────┬──────────┬──────────┐       │
│  │  Vector  │  Graph   │ Temporal │  Decay   │       │
│  │  (HNSW)  │(Entities)│ (Events) │  (Heap)  │       │
│  └──────────┴──────────┴──────────┴──────────┘       │
│  ┌──────────┐                                        │
│  │ Key-Value│  WAL + Replication Log (CRDT)          │
│  └──────────┘                                        │
└──────────────────────────────────────────────────────┘
  1. Vector Index (HNSW) — semantic similarity search across memories
  2. Graph Index — entity relationships, profile aggregation, bridge detection
  3. Temporal Index — time-aware queries ("what happened Tuesday", "upcoming deadlines")
  4. Decay Heap — importance scores that degrade over time, like human memory
  5. Key-Value Store — fast facts, session state, scoring weights

Memory Types (Tulving's Taxonomy)

Type What it stores Example
Semantic Facts, knowledge "User is a software engineer at Meta"
Episodic Events with context "Had a rough day at work on Feb 20"
Procedural Strategies, what worked "Deploy with blue-green, not rolling update"

All memories carry importance, valence (emotional tone), domain, source, certainty, and timestamps — used in a multi-signal scoring function that goes far beyond cosine similarity.

Relevance-Conditioned Scoring

Not just vector similarity. Every recall combines:

  • Semantic similarity (HNSW) — what's topically related
  • Temporal decay — recent memories score higher
  • Importance weighting — critical decisions beat trivia
  • Graph proximity — entity relationships boost connected memories
  • Retrieval feedback — learns from past recall quality

Weights are tuned automatically from usage patterns.

Conflict Detection & Resolution

When memories contradict, YantrikDB doesn't guess — it creates a conflict segment:

"works at Google" (recorded Jan 15) vs. "works at Meta" (recorded Mar 1)
→ Conflict: identity_fact, priority: high, strategy: ask_user

Resolution is conversational: the AI asks naturally, not programmatically.

After many conversations, memories pile up. think() runs:

  1. Consolidation — merge similar memories, extract patterns
  2. Conflict scan — find contradictions across the knowledge base
  3. Pattern mining — cross-domain discovery ("work stress correlates with health entries")
  4. Trigger evaluation — proactive insights worth surfacing

The engine generates triggers when it detects something worth reaching out about:

  • Memory conflicts needing resolution
  • Approaching deadlines (temporal awareness)
  • Patterns detected across domains
  • High-importance memories about to decay
  • Goal tracking ("how's the marathon training?")

Every trigger is grounded in real memory data — not engagement farming.

Local-first with append-only replication log:

  • CRDT merging — graph edges, memories, and metadata merge without conflicts
  • Vector indexes rebuild locally — raw memories sync, each device rebuilds HNSW
  • Forget propagation — tombstones ensure forgotten memories stay forgotten
  • Conflict detection — contradictions across devices are flagged for resolution

Sessions & Temporal Awareness

sid = db.session_start("default", "claude-code")
db.record("decided to use PostgreSQL")  # auto-linked to session
db.record("Alice suggested Redis for caching")
db.session_end(sid)
# → computes: memory_count, avg_valence, topics, duration

db.stale(days=14)    # high-importance memories not accessed recently
db.upcoming(days=7)  # memories with approaching deadlines
Operation Methods
Core record, record_batch, recall, recall_with_response, recall_refine, forget, correct
Knowledge Graph relate, get_edges, search_entities, entity_profile, relationship_depth, link_memory_entity
Cognition think, get_patterns, scan_conflicts, resolve_conflict, derive_personality
Triggers get_pending_triggers, acknowledge_trigger, deliver_trigger, act_on_trigger, dismiss_trigger
Sessions session_start, session_end, session_history, active_session, session_abandon_stale
Temporal stale, upcoming
Procedural record_procedural, surface_procedural, reinforce_procedural
Lifecycle archive, hydrate, decay, evict, list_memories, stats
Sync extract_ops_since, apply_ops, get_peer_watermark, set_peer_watermark
Maintenance rebuild_vec_index, rebuild_graph_index, learned_weights
Decision Choice Rationale
Core language Rust Memory safety, no GC, ideal for embedded engines
Architecture Embedded (like SQLite) No server overhead, sub-ms reads, single-tenant
Bindings Python (PyO3), TypeScript Agent/AI layer integration
Storage Single file per user Portable, backupable, no infrastructure
Sync CRDTs + append-only log Conflict-free for most operations, deterministic
Thread safety Mutex/RwLock, Send+Sync Safe concurrent access from multiple threads
Query interface Cognitive operations API Not SQL — designed for how agents think
Package What Install
yantrikdb Rust engine cargo add yantrikdb
yantrikdb Python bindings (PyO3) pip install yantrikdb
yantrikdb-mcp MCP server for AI agents pip install yantrikdb-mcp
  • V0 — Embedded engine, core memory model (record, recall, relate, consolidate, decay)
  • V1 — Replication log, CRDT-based sync between devices
  • V2 — Conflict resolution with human-in-the-loop
  • V3 — Proactive cognition loop, pattern detection, trigger system
  • V4 — Sessions, temporal awareness, cross-domain pattern mining, entity profiles
  • V5 — Multi-agent shared memory, federated learning across users

Pranab SarkarORCID · LinkedIn · [email protected]

AGPL-3.0. See LICENSE for the full text.

The MCP server is MIT-licensed — using the engine via the MCP server does not trigger AGPL obligations on your code.

联系我们 contact @ memedata.com