memblock 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- memblock-0.4.0/LICENSE +38 -0
- memblock-0.4.0/PKG-INFO +472 -0
- memblock-0.4.0/README.md +423 -0
- memblock-0.4.0/pyproject.toml +67 -0
- memblock-0.4.0/setup.cfg +4 -0
- memblock-0.4.0/src/memblock/__init__.py +95 -0
- memblock-0.4.0/src/memblock/async_memblock.py +263 -0
- memblock-0.4.0/src/memblock/block.py +111 -0
- memblock-0.4.0/src/memblock/cli.py +342 -0
- memblock-0.4.0/src/memblock/conflict.py +208 -0
- memblock-0.4.0/src/memblock/context.py +298 -0
- memblock-0.4.0/src/memblock/crypto.py +144 -0
- memblock-0.4.0/src/memblock/decay.py +151 -0
- memblock-0.4.0/src/memblock/dedup.py +104 -0
- memblock-0.4.0/src/memblock/embeddings.py +202 -0
- memblock-0.4.0/src/memblock/errors.py +53 -0
- memblock-0.4.0/src/memblock/extraction.py +387 -0
- memblock-0.4.0/src/memblock/graph.py +235 -0
- memblock-0.4.0/src/memblock/hooks.py +108 -0
- memblock-0.4.0/src/memblock/licensing.py +187 -0
- memblock-0.4.0/src/memblock/memblock.py +1013 -0
- memblock-0.4.0/src/memblock/migrations.py +372 -0
- memblock-0.4.0/src/memblock/ops.py +144 -0
- memblock-0.4.0/src/memblock/query.py +229 -0
- memblock-0.4.0/src/memblock/rerankers.py +248 -0
- memblock-0.4.0/src/memblock/schema.py +145 -0
- memblock-0.4.0/src/memblock/storage/__init__.py +9 -0
- memblock-0.4.0/src/memblock/storage/base.py +160 -0
- memblock-0.4.0/src/memblock/storage/postgresql.py +773 -0
- memblock-0.4.0/src/memblock/storage/sqlite.py +609 -0
- memblock-0.4.0/src/memblock/store.py +335 -0
- memblock-0.4.0/src/memblock/types.py +213 -0
- memblock-0.4.0/src/memblock.egg-info/PKG-INFO +472 -0
- memblock-0.4.0/src/memblock.egg-info/SOURCES.txt +61 -0
- memblock-0.4.0/src/memblock.egg-info/dependency_links.txt +1 -0
- memblock-0.4.0/src/memblock.egg-info/entry_points.txt +2 -0
- memblock-0.4.0/src/memblock.egg-info/requires.txt +37 -0
- memblock-0.4.0/src/memblock.egg-info/top_level.txt +1 -0
- memblock-0.4.0/tests/test_async.py +254 -0
- memblock-0.4.0/tests/test_auto_extraction.py +200 -0
- memblock-0.4.0/tests/test_block.py +216 -0
- memblock-0.4.0/tests/test_cli.py +171 -0
- memblock-0.4.0/tests/test_conflict.py +191 -0
- memblock-0.4.0/tests/test_context.py +135 -0
- memblock-0.4.0/tests/test_crypto.py +86 -0
- memblock-0.4.0/tests/test_decay.py +178 -0
- memblock-0.4.0/tests/test_dedup.py +238 -0
- memblock-0.4.0/tests/test_e2e.py +323 -0
- memblock-0.4.0/tests/test_embeddings.py +323 -0
- memblock-0.4.0/tests/test_errors.py +180 -0
- memblock-0.4.0/tests/test_extraction.py +258 -0
- memblock-0.4.0/tests/test_graph.py +199 -0
- memblock-0.4.0/tests/test_hierarchical.py +160 -0
- memblock-0.4.0/tests/test_hooks.py +177 -0
- memblock-0.4.0/tests/test_licensing.py +299 -0
- memblock-0.4.0/tests/test_metadata_filtering.py +109 -0
- memblock-0.4.0/tests/test_migrations.py +360 -0
- memblock-0.4.0/tests/test_ops.py +108 -0
- memblock-0.4.0/tests/test_query.py +115 -0
- memblock-0.4.0/tests/test_rerankers.py +151 -0
- memblock-0.4.0/tests/test_session.py +149 -0
- memblock-0.4.0/tests/test_sqlite.py +273 -0
- memblock-0.4.0/tests/test_store.py +204 -0
memblock-0.4.0/LICENSE
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Copyright (c) 2025-2026 iexcalibur
|
|
2
|
+
All Rights Reserved.
|
|
3
|
+
|
|
4
|
+
PROPRIETARY SOFTWARE LICENSE
|
|
5
|
+
|
|
6
|
+
This software and associated documentation files (the "Software") are the
|
|
7
|
+
proprietary property of iexcalibur.
|
|
8
|
+
|
|
9
|
+
RESTRICTIONS:
|
|
10
|
+
|
|
11
|
+
1. You may NOT copy, modify, merge, publish, distribute, sublicense, or sell
|
|
12
|
+
copies of the Software without prior written permission from the copyright
|
|
13
|
+
holder.
|
|
14
|
+
|
|
15
|
+
2. You may NOT reverse engineer, decompile, or disassemble the Software.
|
|
16
|
+
|
|
17
|
+
3. You may NOT create derivative works based on the Software.
|
|
18
|
+
|
|
19
|
+
4. You may NOT redistribute the Software in any form, whether source code or
|
|
20
|
+
compiled binaries, without explicit authorization.
|
|
21
|
+
|
|
22
|
+
PERMITTED USE:
|
|
23
|
+
|
|
24
|
+
The Software may only be used by individuals or organizations who have received
|
|
25
|
+
explicit written authorization from the copyright holder. Authorized users may
|
|
26
|
+
use the Software solely for the purposes agreed upon at the time of access
|
|
27
|
+
grant.
|
|
28
|
+
|
|
29
|
+
DISCLAIMER:
|
|
30
|
+
|
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
35
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
36
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
37
|
+
|
|
38
|
+
For licensing inquiries, contact the copyright holder through GitHub: github.com/iexcalibur
|
memblock-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: memblock
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Typed block tree + knowledge graph memory SDK for AI agents
|
|
5
|
+
Author-email: iexcalibur <shubhamkannojia10@gmail.com>
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Project-URL: Homepage, https://github.com/memblock/memblock
|
|
8
|
+
Project-URL: Repository, https://github.com/memblock/memblock
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/memblock/memblock/issues
|
|
10
|
+
Keywords: ai,memory,knowledge-graph,llm,agent
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: cryptography>=41.0
|
|
22
|
+
Provides-Extra: postgres
|
|
23
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "postgres"
|
|
24
|
+
Provides-Extra: tokens
|
|
25
|
+
Requires-Dist: tiktoken>=0.5; extra == "tokens"
|
|
26
|
+
Provides-Extra: llm
|
|
27
|
+
Requires-Dist: openai>=1.0; extra == "llm"
|
|
28
|
+
Requires-Dist: anthropic>=0.20; extra == "llm"
|
|
29
|
+
Provides-Extra: embeddings
|
|
30
|
+
Requires-Dist: fastembed>=0.3; extra == "embeddings"
|
|
31
|
+
Provides-Extra: embeddings-openai
|
|
32
|
+
Requires-Dist: httpx>=0.24; extra == "embeddings-openai"
|
|
33
|
+
Provides-Extra: embeddings-gemini
|
|
34
|
+
Requires-Dist: httpx>=0.24; extra == "embeddings-gemini"
|
|
35
|
+
Provides-Extra: reranker-cohere
|
|
36
|
+
Requires-Dist: httpx>=0.24; extra == "reranker-cohere"
|
|
37
|
+
Provides-Extra: reranker-cross-encoder
|
|
38
|
+
Requires-Dist: sentence-transformers>=2.0; extra == "reranker-cross-encoder"
|
|
39
|
+
Provides-Extra: all
|
|
40
|
+
Requires-Dist: memblock[postgres]; extra == "all"
|
|
41
|
+
Requires-Dist: memblock[tokens]; extra == "all"
|
|
42
|
+
Requires-Dist: memblock[llm]; extra == "all"
|
|
43
|
+
Requires-Dist: memblock[embeddings]; extra == "all"
|
|
44
|
+
Provides-Extra: dev
|
|
45
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
46
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
47
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<h1 align="center">MemBlock</h1>
|
|
52
|
+
<p align="center"><strong>Structured memory SDK for AI agents.</strong></p>
|
|
53
|
+
<p align="center">Give your AI applications persistent, queryable, and intelligent memory — without cloud dependencies.</p>
|
|
54
|
+
<p align="center"><code>Python 3.10+</code> · <code>335 Tests</code> · <code>v0.4.0</code> · <code>Private Distribution</code></p>
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## The Problem
|
|
60
|
+
|
|
61
|
+
Every AI agent has the same problem: **it forgets.**
|
|
62
|
+
|
|
63
|
+
Between sessions, between conversations, between deployments — context disappears. The solutions available today are broken in different ways:
|
|
64
|
+
|
|
65
|
+
- **Vector databases** give you similarity search but nothing else. They can't tell a fact from a preference. No structure, no relationships, no decay.
|
|
66
|
+
- **Cloud memory APIs** lock you into a subscription and store your users' data on someone else's servers. You have zero control over what happens to it.
|
|
67
|
+
- **Custom JSON/file solutions** work until they don't. No search, no dedup, no integrity guarantees. You end up rebuilding the same infrastructure every project.
|
|
68
|
+
- **Conversation history** isn't memory. Dumping 50k tokens of chat history into a context window is expensive, noisy, and doesn't scale.
|
|
69
|
+
|
|
70
|
+
There is no developer-first memory SDK that gives you structure, search, relationships, decay, encryption, and data ownership — all in one package, all running on your own infrastructure.
|
|
71
|
+
|
|
72
|
+
**Until now.**
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## What is MemBlock?
|
|
77
|
+
|
|
78
|
+
MemBlock is a Python SDK that gives AI agents **structured, typed, graph-connected memory** backed by your own database.
|
|
79
|
+
|
|
80
|
+
You control what gets remembered, how it's organized, when it decays, and who can access it. No cloud subscriptions. No vendor lock-in. No "trust us with your data."
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from memblock import MemBlock, BlockType
|
|
84
|
+
|
|
85
|
+
mem = MemBlock(storage="sqlite:///./agent_memory.db")
|
|
86
|
+
|
|
87
|
+
# Store structured memories — not just text blobs
|
|
88
|
+
mem.store("User prefers Python over JavaScript", type=BlockType.PREFERENCE)
|
|
89
|
+
mem.store("User works at Acme Corp", type=BlockType.FACT, confidence=0.95)
|
|
90
|
+
event = mem.store("Deployed v2.0 on March 10", type=BlockType.EVENT)
|
|
91
|
+
|
|
92
|
+
# Query with hybrid search (FTS + vector similarity)
|
|
93
|
+
results = mem.query(text_search="programming language", type=BlockType.PREFERENCE)
|
|
94
|
+
|
|
95
|
+
# Build LLM-ready context — drop straight into your prompt
|
|
96
|
+
context = mem.build_context(query="user preferences", token_budget=4000)
|
|
97
|
+
|
|
98
|
+
# Link related memories into a knowledge graph
|
|
99
|
+
mem.link(results[0].id, event.id, relation="related_to")
|
|
100
|
+
|
|
101
|
+
# Verify nothing has been tampered with
|
|
102
|
+
report = mem.verify()
|
|
103
|
+
|
|
104
|
+
mem.close()
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
That's it. Five lines to go from "my agent forgets everything" to "my agent has structured, searchable, graph-connected memory."
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## MemBlock vs Mem0 — An Honest Comparison (Updated March 2026)
|
|
112
|
+
|
|
113
|
+
Mem0 is the dominant memory layer in the AI ecosystem — ~50k GitHub stars, $24M Series A, AWS Agent SDK partnership, and 50+ integrations. They've earned their position. This comparison is honest: we call out where Mem0 wins, where MemBlock wins, and where it's a tie.
|
|
114
|
+
|
|
115
|
+
### Head-to-Head
|
|
116
|
+
|
|
117
|
+
| Capability | **Mem0** | **MemBlock** | Verdict |
|
|
118
|
+
|---|---|---|---|
|
|
119
|
+
| **Typed memory structure** | Unstructured — memories are text blobs with metadata | **5 built-in types** (Fact, Preference, Event, Entity, Relation) with per-type behavior | **MemBlock** — structure enables smarter retrieval and reasoning |
|
|
120
|
+
| **Knowledge graph** | Neo4j-based graph memory — **Pro tier only ($249/mo)**. LLM extracts entities/relations automatically | **Built-in, no paywall** — 8 typed relationship types with traversal. Manual or auto-extraction | **Depends** — Mem0's auto-extraction is more sophisticated; MemBlock's is free and built-in |
|
|
121
|
+
| **Memory decay** | Memories adapt over time as preferences change. Conflict resolution via update resolver | **Exponential decay + access reinforcement** — configurable per-block. Auto-prune weak memories. TTL support | **MemBlock** — explicit, deterministic decay you can test and tune |
|
|
122
|
+
| **Deduplication** | Automatic duplicate detection and conflict resolution | **Exact hash + semantic similarity** with 4 configurable policies (error, skip, return, merge) | **MemBlock** — more developer control over dedup behavior |
|
|
123
|
+
| **Encryption** | SOC 2, HIPAA compliant. BYOK on enterprise. Platform-managed | **AES-256-GCM, field-level, your keys, always** — STANDARD (content) or SENSITIVE (content + tags) | **MemBlock** — zero-trust encryption without enterprise tier |
|
|
124
|
+
| **Tamper detection** | Audit trails, versioned + timestamped memories. Exportable | **SHA-256 hash chain on every operation** — cryptographic proof of integrity, verifiable in one call | **MemBlock** — cryptographic vs log-based verification |
|
|
125
|
+
| **Search** | Semantic retrieval via embeddings. 22+ vector store backends. Filtering + batch ops | **FTS5 + vector + RRF fusion** — hybrid search combining keyword and semantic | Tie — different strengths. Mem0 has more backend options; MemBlock has hybrid fusion |
|
|
126
|
+
| **Session support** | Three levels: `user_id`, `agent_id`, `run_id` — built-in hierarchy | **5-level hierarchy**: `org_id` → `project_id` → `user_id` → `agent_id` → `session_id` — all opt-in | **MemBlock** — deeper hierarchy with org/project scoping |
|
|
127
|
+
| **Multi-tenancy** | Automatic graph isolation per user. Query time constant as users scale | **User + session isolation** (PostgreSQL). Composite indexes for fast scoped queries | Tie — both isolate by user. Mem0 scales graph isolation; MemBlock scales relational queries |
|
|
128
|
+
| **Ecosystem** | Python, JS/TS, REST API. LangChain, LangGraph, CrewAI, AutoGen, Vercel AI SDK, MCP server, Chrome extension. AWS Agent SDK partner | Python only. Standalone SDK | **Mem0** — significantly broader. Not close |
|
|
129
|
+
| **Community** | ~50k GitHub stars. $24M Series A. 18M+ PyPI downloads | New, private distribution | **Mem0** — massive community and proven at scale |
|
|
130
|
+
| **Cloud option** | Managed platform at api.mem0.ai. Free tier (10K memories) → Pro → Enterprise | No cloud — self-hosted only | **Mem0** — if you want zero infrastructure |
|
|
131
|
+
| **Self-hosted** | Docker Compose (3 containers: API + PostgreSQL/pgvector + Neo4j). Apache 2.0 | `pip install` + SQLite (zero infra) or PostgreSQL | **MemBlock** — simpler self-hosting. No Neo4j or Docker required |
|
|
132
|
+
| **Token optimization** | Claims 91% faster responses, 90% fewer tokens vs full history | Context builder with token budgets and 3 strategies (relevance, graph walk, type grouped) | **Mem0** — more battle-tested optimization at scale |
|
|
133
|
+
| **Data ownership** | Cloud: vendor-hosted. Self-hosted: you own it (Apache 2.0) | **100% your infrastructure, always**. No cloud option means no data risk | Tie — both offer self-hosted. MemBlock has no cloud temptation |
|
|
134
|
+
| **Cost** | Free (10K) → $19/mo (50K) → $249/mo (unlimited + graph) → Enterprise | **One-time license, no subscriptions** | **MemBlock** — no recurring cost. Graph included free |
|
|
135
|
+
| **Setup** | Cloud: API key + 3 lines. Self-hosted: Docker Compose + config | **One line:** `MemBlock(storage="sqlite:///db")` | **MemBlock** — simpler to start. Mem0 cloud is also easy though |
|
|
136
|
+
| **LLM extraction** | Automatic from conversations. Supports 15+ LLM providers | **Built-in (OpenAI, Anthropic)** with configurable triggers and buffer-based extraction | Tie — both handle this. Mem0 supports more providers |
|
|
137
|
+
| **Async API** | Async-by-default since v1.0 | **AsyncMemBlock** — full async wrapper with `asyncio.to_thread()` | Tie — both support async |
|
|
138
|
+
| **Reranking** | Cohere, HuggingFace, BM25 rerankers | **BM25 (zero deps), Cohere, CrossEncoder** — pluggable reranker interface | Tie — similar offerings |
|
|
139
|
+
| **Conflict resolution** | LLM-powered ADD/UPDATE/DELETE decisions on every `add()` | **Opt-in LLM conflict resolution** — same ADD/UPDATE/DELETE/NONE decisions, configurable | Tie — both offer this. Mem0's is on by default |
|
|
140
|
+
| **Event hooks** | Not available | **on_add, on_update, on_delete, on_query** — sync + async callbacks | **MemBlock** — Mem0 doesn't have this |
|
|
141
|
+
| **Metadata filtering** | Arbitrary key-value filters on search | **Custom metadata JSON** with arbitrary key-value filtering on SQLite + PostgreSQL | Tie — both support this |
|
|
142
|
+
| **Auto-extraction on store** | Automatic on every `add()` by default | **Opt-in `auto_extract_on_store`** — extracted blocks linked via DERIVED_FROM | Tie — both offer this. Different defaults |
|
|
143
|
+
| **Offline / air-gapped** | Self-hosted with Ollama — fully offline possible | **SQLite + local FastEmbed** — fully offline, no Docker | **MemBlock** — simpler offline story |
|
|
144
|
+
|
|
145
|
+
### What Mem0 Does Better
|
|
146
|
+
|
|
147
|
+
Let's be direct about where Mem0 wins outright:
|
|
148
|
+
|
|
149
|
+
- **Ecosystem reach** — Python, JS/TS, REST API, Chrome extension, MCP server, AWS partnership. MemBlock is Python only.
|
|
150
|
+
- **Graph intelligence** — Their Neo4j-based graph with LLM-powered entity extraction and conflict resolution is more sophisticated than our manual graph.
|
|
151
|
+
- **Scale proof** — 50k stars, $24M funding, enterprise customers. MemBlock is new and unproven at scale.
|
|
152
|
+
- **Zero-config cloud** — Sign up, get an API key, start storing memories. No infrastructure to think about.
|
|
153
|
+
- **Framework integrations** — Drop-in support for LangChain, CrewAI, AutoGen, and more. MemBlock requires manual integration.
|
|
154
|
+
|
|
155
|
+
### What MemBlock Does Better
|
|
156
|
+
|
|
157
|
+
- **Typed structure** — 5 memory types with per-type behavior vs text blobs. Your agent knows the difference between a fact and a preference.
|
|
158
|
+
- **Free knowledge graph** — Built-in at every tier. Mem0 paywalls graph behind $249/mo.
|
|
159
|
+
- **Deterministic decay** — Exponential decay with access reinforcement, configurable per block. Testable and predictable.
|
|
160
|
+
- **Field-level encryption** — AES-256-GCM with your keys, no enterprise tier required. Encrypt content only or content + tags.
|
|
161
|
+
- **Cryptographic integrity** — SHA-256 hash chain on every operation. One call to verify nothing was tampered with.
|
|
162
|
+
- **Setup simplicity** — `pip install` + one line of Python. No Docker, no Neo4j, no API keys needed for basic use.
|
|
163
|
+
- **Event hooks** — Register callbacks on memory lifecycle events (add, update, delete, query). Mem0 doesn't offer this.
|
|
164
|
+
- **Hierarchical scoping** — 5-level opt-in hierarchy (org → project → user → agent → session) vs Mem0's 3 levels.
|
|
165
|
+
- **Cost** — One license, no subscriptions. Graph, encryption, decay, sessions — all included.
|
|
166
|
+
|
|
167
|
+
### Who should choose MemBlock vs Mem0
|
|
168
|
+
|
|
169
|
+
Use this rule of thumb:
|
|
170
|
+
|
|
171
|
+
**Choose MemBlock if your priority is:**
|
|
172
|
+
- Own data ownership (no memory data sent to external providers by default)
|
|
173
|
+
- Structured memory with typed blocks + built-in graph + decay in one package
|
|
174
|
+
- Private deployment with SQLite/PostgreSQL on your own infrastructure
|
|
175
|
+
- Low recurring cost and private distribution control
|
|
176
|
+
- Deterministic, debuggable behavior under your own CI/security policies
|
|
177
|
+
- Full control over encryption, retention, and schema evolution
|
|
178
|
+
|
|
179
|
+
**Choose Mem0 if your priority is:**
|
|
180
|
+
- Fast managed rollout with less backend operations burden
|
|
181
|
+
- Broad language and orchestration ecosystem integration speed
|
|
182
|
+
- Centralized cloud service model with external API-based scale
|
|
183
|
+
- Team preference for API-first usage over local SDK ownership
|
|
184
|
+
- Faster time-to-production for multi-stack teams
|
|
185
|
+
|
|
186
|
+
**Decision matrix:**
|
|
187
|
+
|
|
188
|
+
| Requirement | MemBlock | Mem0 |
|
|
189
|
+
|---|---|---|
|
|
190
|
+
| Data cannot leave your infra | **Strong fit** | Managed with external dependency |
|
|
191
|
+
| Need private on-prem or VPC style deployments | **Strong fit** | Conditional |
|
|
192
|
+
| Need a mature multi-language integration story | Possible (Python-first) | **Strong fit** |
|
|
193
|
+
| Need local-first + source-level control | **Strong fit** | Limited |
|
|
194
|
+
| Want minimal backend operational responsibility | Possible but you operate it | **Strong fit** |
|
|
195
|
+
| Budget prefers one-time/proprietary licensing model | **Strong fit** | API usage cost model |
|
|
196
|
+
|
|
197
|
+
**Quick rule:**
|
|
198
|
+
Use **MemBlock** when control and privacy are non-negotiable.
|
|
199
|
+
Use **Mem0** when managed operations and broad ecosystem plug-and-play matter more.
|
|
200
|
+
|
|
201
|
+
### The Honest Bottom Line
|
|
202
|
+
|
|
203
|
+
Mem0 is the **market leader** — bigger community, more integrations, managed cloud, $24M in funding, and proven at enterprise scale. If you want the safe, well-supported choice with zero infrastructure work, Mem0 is excellent. Their self-hosted option (Apache 2.0) is also solid.
|
|
204
|
+
|
|
205
|
+
MemBlock is for developers who want **more structure, more control, and a simpler stack**. Typed memories, free knowledge graph, cryptographic integrity, field-level encryption, intelligent decay, and session scoping — all running on SQLite or PostgreSQL with no Docker, no Neo4j, and no subscriptions. It's a different philosophy: everything included, everything you control, everything testable.
|
|
206
|
+
|
|
207
|
+
We're not trying to replace Mem0. We're building for developers who need what Mem0 either paywalls or doesn't offer.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Who is MemBlock For?
|
|
212
|
+
|
|
213
|
+
MemBlock is built with a **developer-first mindset**. No GUIs, no dashboards, no drag-and-drop. Just a clean Python API that works the way you expect.
|
|
214
|
+
|
|
215
|
+
### AI Agent Developers
|
|
216
|
+
Building copilots, assistants, or autonomous agents that need to remember context across sessions. MemBlock gives your agent real memory — not just a bigger context window.
|
|
217
|
+
|
|
218
|
+
### Product Teams Shipping LLM Features
|
|
219
|
+
Need reliable memory across user sessions for your product? MemBlock gives you structured storage, deterministic APIs, and predictable behavior. No black boxes.
|
|
220
|
+
|
|
221
|
+
### Backend Engineers
|
|
222
|
+
You want a memory layer you can test, debug, monitor, and deploy like any other backend component. MemBlock is a library, not a service. It runs in your process, uses your database.
|
|
223
|
+
|
|
224
|
+
### Teams With Data Control Requirements
|
|
225
|
+
Regulated industries, enterprise, healthcare, finance — anyone who can't send user data to a third-party memory service. MemBlock runs entirely on your infrastructure. Your data never leaves your systems.
|
|
226
|
+
|
|
227
|
+
### Solo Builders & Indie Hackers
|
|
228
|
+
Building an AI product and don't want to pay $50/month for a memory API? MemBlock is free to use once licensed. SQLite is all you need to get started.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Core Features
|
|
233
|
+
|
|
234
|
+
### Typed Block Storage
|
|
235
|
+
Store memories as structured blocks — not just raw text. Each block has a **type** (FACT, PREFERENCE, EVENT, ENTITY, RELATION), a **confidence score**, **source tracking**, **tags**, and optional **per-block encryption**. You always know what kind of memory you're dealing with.
|
|
236
|
+
|
|
237
|
+
### Knowledge Graph
|
|
238
|
+
Connect memories with typed edges: `supports`, `contradicts`, `caused_by`, `related_to`, `part_of`, `derived_from`, `supersedes`, `about`. Traverse relationships, detect contradictions, and discover context clusters. Your agent doesn't just remember facts — it understands how they connect.
|
|
239
|
+
|
|
240
|
+
### Hybrid Search
|
|
241
|
+
Full-text search combined with vector similarity, merged using Reciprocal Rank Fusion (RRF). Better retrieval than either approach alone. Supports local embeddings (no API key needed), OpenAI, and Gemini providers.
|
|
242
|
+
|
|
243
|
+
### Memory Decay Engine
|
|
244
|
+
Memories naturally weaken over time using exponential decay. Frequently accessed memories stay strong — just like human memory. Configurable decay rates per block. Auto-prune weak memories. TTL support for time-limited memories.
|
|
245
|
+
|
|
246
|
+
### AES-256 Encryption
|
|
247
|
+
Field-level encryption with AES-256-GCM. Encrypt content only (STANDARD) or content + tags (SENSITIVE). Passphrase-based key derivation — no key management infrastructure required.
|
|
248
|
+
|
|
249
|
+
### Smart Deduplication
|
|
250
|
+
Four policies: `error`, `skip`, `return_existing`, `merge`. Two detection layers: exact content hash and semantic similarity (cosine threshold). Catches both identical and near-identical memories before they pollute your store.
|
|
251
|
+
|
|
252
|
+
### LLM Auto-Extraction
|
|
253
|
+
Extract structured memories from raw conversations using OpenAI or Anthropic models. Buffer messages and trigger extraction at configurable intervals. Automatic type detection, confidence scoring, and relationship linking — turns conversations into structured knowledge.
|
|
254
|
+
|
|
255
|
+
### Context Builder
|
|
256
|
+
Build LLM-ready context strings from relevant memories. Three strategies: **relevance** (best matches), **graph_walk** (follow relationships), **type_grouped** (organized by type). Token budget enforcement ensures you never exceed your context window.
|
|
257
|
+
|
|
258
|
+
### Tamper Detection
|
|
259
|
+
Append-only operation log with SHA-256 hash chain. Every create, update, delete, link, and unlink is recorded. Verify integrity at any time — one method call tells you if anything has been modified outside the SDK.
|
|
260
|
+
|
|
261
|
+
### Session Scoping (Opt-in)
|
|
262
|
+
Multi-session support is **off by default** — all memories live in a single global scope, which is all most agents need. When you're ready for multi-conversation products, just start passing `session_id` to any method. No config changes, no migrations, no feature flags — it just works.
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
# Single-session (default) — no session_id needed
|
|
266
|
+
mem.store("User likes Python", type=BlockType.PREFERENCE)
|
|
267
|
+
mem.query(type=BlockType.PREFERENCE) # returns all blocks
|
|
268
|
+
|
|
269
|
+
# Multi-session (opt-in) — pass session_id when you need it
|
|
270
|
+
mem.store("msg in chat 1", type=BlockType.EVENT, session_id="chat_001")
|
|
271
|
+
mem.store("msg in chat 2", type=BlockType.EVENT, session_id="chat_002")
|
|
272
|
+
mem.query(session_id="chat_001") # only chat_001 blocks
|
|
273
|
+
mem.get_sessions() # ["chat_001", "chat_002"]
|
|
274
|
+
mem.get_session_history("chat_001") # chronological blocks
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
The developer decides. Combined with `user_id` (PostgreSQL), you get user + session isolation for multi-tenant, multi-conversation products.
|
|
278
|
+
|
|
279
|
+
### Async API
|
|
280
|
+
Full async support via `AsyncMemBlock`. Every method is wrapped with `asyncio.to_thread()` so it won't block your event loop. Works with FastAPI, aiohttp, and any async framework.
|
|
281
|
+
|
|
282
|
+
```python
|
|
283
|
+
from memblock import AsyncMemBlock, BlockType
|
|
284
|
+
|
|
285
|
+
async with AsyncMemBlock(storage="sqlite:///./memory.db") as mem:
|
|
286
|
+
block = await mem.store("User prefers Python", type=BlockType.PREFERENCE)
|
|
287
|
+
results = await mem.query(text_search="Python")
|
|
288
|
+
context = await mem.build_context(query="preferences", token_budget=4000)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Reranker Support
|
|
292
|
+
Improve search quality with pluggable rerankers. BM25 (zero dependencies), Cohere (API), or CrossEncoder (local HuggingFace model). Reranking happens automatically after the initial search.
|
|
293
|
+
|
|
294
|
+
```python
|
|
295
|
+
from memblock.rerankers import BM25Reranker, CohereReranker
|
|
296
|
+
|
|
297
|
+
# BM25 — zero dependencies, works offline
|
|
298
|
+
mem = MemBlock(storage="sqlite:///./db", reranker=BM25Reranker())
|
|
299
|
+
|
|
300
|
+
# Cohere — best quality
|
|
301
|
+
mem = MemBlock(storage="sqlite:///./db", reranker=CohereReranker(api_key="co-..."))
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Conflict Resolution via LLM
|
|
305
|
+
When enabled, `store()` finds semantically similar existing memories and asks the LLM to decide: **ADD** (new), **UPDATE** (refine existing), **DELETE** (contradicted), or **NONE** (already known). Same concept as Mem0's inference mode.
|
|
306
|
+
|
|
307
|
+
```python
|
|
308
|
+
mem = MemBlock(
|
|
309
|
+
storage="sqlite:///./db",
|
|
310
|
+
embeddings=True,
|
|
311
|
+
extract_provider="openai",
|
|
312
|
+
extract_api_key="sk-...",
|
|
313
|
+
conflict_resolution=True, # enable LLM conflict resolution
|
|
314
|
+
)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Hierarchical Scoping
|
|
318
|
+
5-level opt-in hierarchy: `org_id` → `project_id` → `user_id` → `agent_id` → `session_id`. Set defaults in the constructor, override per-call. Fully backward compatible — existing code works unchanged.
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
mem = MemBlock(
|
|
322
|
+
storage="postgresql://...",
|
|
323
|
+
org_id="acme_corp",
|
|
324
|
+
project_id="chatbot_v2",
|
|
325
|
+
user_id="u_123",
|
|
326
|
+
agent_id="support_bot",
|
|
327
|
+
)
|
|
328
|
+
mem.store("User prefers email", type=BlockType.PREFERENCE, session_id="chat_001")
|
|
329
|
+
mem.query(org_id="acme_corp", project_id="chatbot_v2") # scoped query
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Custom Metadata Filtering
|
|
333
|
+
Attach arbitrary key-value metadata to any block and filter on it during search.
|
|
334
|
+
|
|
335
|
+
```python
|
|
336
|
+
mem.store("User has Pro plan", type=BlockType.FACT, metadata={"plan": "pro", "region": "us-east"})
|
|
337
|
+
results = mem.query(metadata_filters={"plan": "pro"})
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Event Hooks
|
|
341
|
+
Register callbacks for memory lifecycle events. Sync or async. Errors in hooks never break the main operation.
|
|
342
|
+
|
|
343
|
+
```python
|
|
344
|
+
def on_memory_added(data):
|
|
345
|
+
print(f"New memory: {data['block_id']}")
|
|
346
|
+
|
|
347
|
+
mem = MemBlock(storage="sqlite:///./db")
|
|
348
|
+
mem.on("on_add", on_memory_added)
|
|
349
|
+
mem.on("on_delete", lambda data: log.warning(f"Deleted: {data['block_id']}"))
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Multi-Storage
|
|
353
|
+
**SQLite** for local development and single-user apps. **PostgreSQL** for production multi-tenant deployments with user-level and session-level isolation. Same API — just swap the connection string.
|
|
354
|
+
|
|
355
|
+
### CLI
|
|
356
|
+
```
|
|
357
|
+
memblock init # Initialize a new database
|
|
358
|
+
memblock query # Search memories from the terminal
|
|
359
|
+
memblock stats # Database statistics
|
|
360
|
+
memblock prune # Remove decayed memories
|
|
361
|
+
memblock export # Export to markdown
|
|
362
|
+
memblock reindex # Rebuild search indices
|
|
363
|
+
memblock version # Show version
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## Installation
|
|
369
|
+
|
|
370
|
+
MemBlock is distributed privately. Access is granted on an invite-only basis.
|
|
371
|
+
|
|
372
|
+
### From GitHub Release (authorized users)
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
pip install https://github.com/iexcalibur/memblock/releases/download/v0.4.0/memblock-0.4.0-py3-none-any.whl
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Optional Extras
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# PostgreSQL support
|
|
382
|
+
pip install "memblock[postgres]"
|
|
383
|
+
|
|
384
|
+
# Local embeddings (CPU, no API key needed)
|
|
385
|
+
pip install "memblock[embeddings]"
|
|
386
|
+
|
|
387
|
+
# LLM extraction (OpenAI + Anthropic)
|
|
388
|
+
pip install "memblock[llm]"
|
|
389
|
+
|
|
390
|
+
# Cohere reranker
|
|
391
|
+
pip install "memblock[reranker-cohere]"
|
|
392
|
+
|
|
393
|
+
# Cross-encoder reranker (HuggingFace)
|
|
394
|
+
pip install "memblock[reranker-cross-encoder]"
|
|
395
|
+
|
|
396
|
+
# Everything
|
|
397
|
+
pip install "memblock[all]"
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## API at a Glance
|
|
403
|
+
|
|
404
|
+
| Category | Methods |
|
|
405
|
+
|---|---|
|
|
406
|
+
| **Store** | `store()`, `get()`, `update()`, `delete()` |
|
|
407
|
+
| **Graph** | `link()`, `unlink()`, `neighbors()`, `traverse()` |
|
|
408
|
+
| **Search** | `query()`, `build_context()` |
|
|
409
|
+
| **Extract** | `extract()`, `extract_messages()`, `add_message()`, `flush_extraction()` |
|
|
410
|
+
| **Sessions** | `get_sessions()`, `get_session_history()` |
|
|
411
|
+
| **Hooks** | `on()` — register callbacks for `on_add`, `on_update`, `on_delete`, `on_query` |
|
|
412
|
+
| **Async** | `AsyncMemBlock` — full async wrapper for all methods above |
|
|
413
|
+
| **Manage** | `prune()`, `strongest()`, `weakest()`, `verify()`, `stats()`, `export_markdown()` |
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Architecture
|
|
418
|
+
|
|
419
|
+
MemBlock follows a **composable architecture** — each capability is an independent module composed through a single facade class:
|
|
420
|
+
|
|
421
|
+
```
|
|
422
|
+
MemBlock (facade)
|
|
423
|
+
├── BlockStore — CRUD operations, content hashing, op logging
|
|
424
|
+
├── GraphIndex — Edge management, traversal, neighbor queries
|
|
425
|
+
├── QueryEngine — FTS + vector hybrid search with RRF merge
|
|
426
|
+
├── ContextBuilder — Token-budgeted context generation
|
|
427
|
+
├── DecayEngine — Time-based strength calculation and pruning
|
|
428
|
+
├── DuplicateChecker — Exact + semantic dedup
|
|
429
|
+
├── CryptoLayer — AES-256-GCM field-level encryption
|
|
430
|
+
├── OpLog — Append-only hash chain for tamper detection
|
|
431
|
+
├── HookManager — Event callbacks (on_add, on_update, on_delete, on_query)
|
|
432
|
+
├── ConflictResolver — LLM-powered ADD/UPDATE/DELETE/NONE decisions
|
|
433
|
+
├── Reranker — BM25, Cohere, CrossEncoder (pluggable)
|
|
434
|
+
├── HierarchicalScoping — org → project → user → agent → session
|
|
435
|
+
└── StorageAdapter — SQLite or PostgreSQL (swappable)
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
Every component is testable in isolation. The facade composes them into a single clean API.
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Roadmap
|
|
443
|
+
|
|
444
|
+
Features planned for future releases:
|
|
445
|
+
|
|
446
|
+
- **Multi-language SDKs** — TypeScript and Go clients
|
|
447
|
+
- **REST API server mode** — Run MemBlock as a standalone API server
|
|
448
|
+
- **Multimodal memory** — Store and query images, audio, and documents alongside text
|
|
449
|
+
- **Framework integrations** — LangChain, CrewAI, AutoGen, Vercel AI SDK drop-in support
|
|
450
|
+
- **MCP server** — Model Context Protocol server for IDE and agent integrations
|
|
451
|
+
- **Managed cloud platform** — Optional hosted version for teams that don't want to self-host
|
|
452
|
+
- **Additional vector store backends** — pgvector, Qdrant, Pinecone, ChromaDB support
|
|
453
|
+
- **Token compression** — Smarter context building with LLM-powered summarization
|
|
454
|
+
- **Multi-agent memory sharing** — Shared memory pools between agents with access control
|
|
455
|
+
|
|
456
|
+
Want a feature prioritized? Open an issue or reach out via GitHub.
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## License & Ownership
|
|
461
|
+
|
|
462
|
+
**Copyright (c) 2025-2026 iexcalibur. All Rights Reserved.**
|
|
463
|
+
|
|
464
|
+
This software is **proprietary and confidential**. It is not open-source.
|
|
465
|
+
|
|
466
|
+
- You may **NOT** copy, modify, distribute, sublicense, or sell this software without prior written permission.
|
|
467
|
+
- You may **NOT** reverse engineer, decompile, or create derivative works.
|
|
468
|
+
- You may **NOT** redistribute in any form — source code or compiled — without explicit authorization.
|
|
469
|
+
|
|
470
|
+
Access is granted on an invite-only basis to authorized individuals and organizations.
|
|
471
|
+
|
|
472
|
+
Unauthorized use, reproduction, or distribution of this software is strictly prohibited and may result in legal action.
|