superlocalmemory 2.4.2 → 2.5.1

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.
package/CHANGELOG.md CHANGED
@@ -16,6 +16,68 @@ SuperLocalMemory V2 - Intelligent local memory system for AI coding assistants.
16
16
 
17
17
  ---
18
18
 
19
+ ## [2.5.1] - 2026-02-13
20
+
21
+ **Release Type:** Framework Integration Release — "Plugged Into the Ecosystem"
22
+ **Backward Compatible:** Yes (additive packages only, no core changes)
23
+
24
+ ### The Big Picture
25
+ SuperLocalMemory is now a first-class memory backend for LangChain and LlamaIndex — the two largest AI/LLM frameworks. Two pip-installable packages, zero cloud dependencies.
26
+
27
+ ### Added
28
+ - **LangChain Integration** (`langchain-superlocalmemory`): Persistent chat message history backed by local SQLite. Works with `RunnableWithMessageHistory` and LCEL chains. `pip install langchain-superlocalmemory`
29
+ - **LlamaIndex Integration** (`llama-index-storage-chat-store-superlocalmemory`): Full `BaseChatStore` implementation. Works with `ChatMemoryBuffer` and `SimpleChatEngine`. `pip install llama-index-storage-chat-store-superlocalmemory`
30
+ - **Example scripts** for both frameworks in `examples/` directory — runnable without API keys
31
+ - **Session isolation**: Framework memories are tagged separately and never appear in normal `slm recall`
32
+
33
+ ---
34
+
35
+ ## [2.5.0] - 2026-02-12
36
+
37
+ **Release Type:** Major Feature Release — "Your AI Memory Has a Heartbeat"
38
+ **Backward Compatible:** Yes (additive tables, columns, and modules only)
39
+
40
+ ### The Big Picture
41
+ SuperLocalMemory transforms from passive storage to **active coordination layer**. Every memory operation now triggers real-time events. Agents are tracked. Trust is scored. The dashboard is live.
42
+
43
+ ### Added
44
+ - **DbConnectionManager** (`src/db_connection_manager.py`): SQLite WAL mode, 5s busy timeout, thread-local read pool, serialized write queue. Fixes "database is locked" errors when multiple agents write simultaneously
45
+ - **Event Bus** (`src/event_bus.py`): Real-time event broadcasting — every memory write/update/delete fires events to SSE, WebSocket, and Webhook subscribers. Tiered retention (hot 48h, warm 14d, cold 30d)
46
+ - **Subscription Manager** (`src/subscription_manager.py`): Durable + ephemeral event subscriptions with filters (event type, importance, protocol)
47
+ - **Webhook Dispatcher** (`src/webhook_dispatcher.py`): Background HTTP POST delivery with exponential backoff retry (3 attempts)
48
+ - **Agent Registry** (`src/agent_registry.py`): Tracks which AI agents connect — protocol, write/recall counters, last seen, metadata
49
+ - **Provenance Tracker** (`src/provenance_tracker.py`): Tracks who created each memory — created_by, source_protocol, trust_score, provenance_chain
50
+ - **Trust Scorer** (`src/trust_scorer.py`): Bayesian trust signal collection — positive (cross-agent recall, high importance), negative (quick delete, burst write). Silent collection in v2.5, enforcement in v2.6
51
+ - **SSE endpoint** (`/events/stream`): Real-time Server-Sent Events with cross-process DB polling, Last-Event-ID replay, event type filtering
52
+ - **Dashboard: Live Events tab**: Real-time event stream with color-coded types, filter dropdown, stats counters
53
+ - **Dashboard: Agents tab**: Connected agents table with protocol badges, trust scores, write/recall counters, trust overview
54
+ - **4 new database tables**: `memory_events`, `subscriptions`, `agent_registry`, `trust_signals`
55
+ - **4 new columns on `memories`**: `created_by`, `source_protocol`, `trust_score`, `provenance_chain`
56
+ - **28 API endpoints** across 8 modular route files
57
+ - **Architecture document**: `docs/ARCHITECTURE-V2.5.md`
58
+
59
+ ### Changed
60
+ - **`memory_store_v2.py`**: Replaced 15 direct `sqlite3.connect()` calls with `DbConnectionManager` (read pool + write queue). Added EventBus, Provenance, Trust integration. Fully backward compatible — falls back to direct SQLite if new modules unavailable
61
+ - **`mcp_server.py`**: Replaced 9 per-call `MemoryStoreV2(DB_PATH)` instantiations with shared singleton. Added agent registration and provenance tracking for MCP calls
62
+ - **`ui_server.py`**: Refactored from 2008-line monolith to 194-line app shell + 9 route modules in `routes/` directory using FastAPI APIRouter
63
+ - **`ui/app.js`**: Split from 1588-line monolith to 13 modular files in `ui/js/` directory (largest: 230 lines)
64
+
65
+ ### Fixed
66
+ - **"Database is locked" errors**: WAL mode + write serialization eliminates concurrent access failures
67
+ - **Fresh database crashes**: `/api/stats`, `/api/graph`, `/api/clusters` now return graceful empty responses when `graph_nodes`/`graph_edges`/`sessions` tables don't exist yet
68
+ - **Per-call overhead**: MCP tool handlers no longer rebuild TF-IDF vectorizer on every call
69
+
70
+ ### Testing
71
+ - 63 pytest tests (unit, concurrency, regression, security, edge cases, Docker/new-user scenarios)
72
+ - 27 end-to-end tests (all v2.5 components + 50 concurrent writes + reads during writes)
73
+ - 15 fresh-database edge case tests
74
+ - 17 backward compatibility tests against live v2.4.2 database
75
+ - All CLI commands and skill scripts verified
76
+ - Profile isolation verified across 2 profiles
77
+ - Playwright dashboard testing (all 8 tabs, SSE stream, profile switching)
78
+
79
+ ---
80
+
19
81
  ## [2.4.2] - 2026-02-11
20
82
 
21
83
  **Release Type:** Bug Fix Release
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  <p align="center">
2
- <img src="https://img.shields.io/badge/🧠_SuperLocalMemory-V2-blueviolet?style=for-the-badge" alt="SuperLocalMemory V2"/>
2
+ <img src="https://varun369.github.io/SuperLocalMemoryV2/assets/branding/icon-512.png" alt="SuperLocalMemory V2" width="200"/>
3
3
  </p>
4
4
 
5
- <h1 align="center">Your AI Finally Remembers You</h1>
5
+ <h1 align="center">SuperLocalMemory V2</h1>
6
+ <p align="center"><strong>Your AI Finally Remembers You</strong></p>
6
7
 
7
8
  <p align="center">
8
9
  <strong>⚡ Created & Architected by <a href="https://github.com/varun369">Varun Pratap Bhardwaj</a> ⚡</strong><br/>
@@ -39,6 +40,63 @@
39
40
 
40
41
  ---
41
42
 
43
+ ## NEW: v2.5 — "Your AI Memory Has a Heartbeat"
44
+
45
+ > **SuperLocalMemory is no longer passive storage — it's a real-time coordination layer.**
46
+
47
+ | What's New | Why It Matters |
48
+ |------------|----------------|
49
+ | **Real-Time Event Stream** | See every memory operation live in the dashboard — no refresh needed. SSE-powered, cross-process. |
50
+ | **No More "Database Locked"** | WAL mode + serialized write queue. 50 concurrent agents writing? Zero errors. |
51
+ | **Agent Tracking** | Know exactly which AI tool wrote what. Claude, Cursor, Windsurf, CLI — all tracked automatically. |
52
+ | **Trust Scoring** | Bayesian trust signals detect spam, quick-deletes, and cross-agent validation. Silent in v2.5, enforced in v2.6. |
53
+ | **Memory Provenance** | Every memory records who created it, via which protocol, with full derivation lineage. |
54
+ | **Production-Grade Code** | 28 API endpoints across 8 modular route files. 13 modular JS files. 63 pytest tests. |
55
+
56
+ **Upgrade:** `npm install -g superlocalmemory@latest`
57
+
58
+ **Dashboard:** `python3 ~/.claude-memory/ui_server.py` then open `http://localhost:8765`
59
+
60
+ [Interactive Architecture Diagram](https://varun369.github.io/SuperLocalMemoryV2/architecture.html) | [Architecture Doc](docs/ARCHITECTURE-V2.5.md) | [Full Changelog](CHANGELOG.md)
61
+
62
+ ---
63
+
64
+ ## NEW: Framework Integrations (v2.5.1)
65
+
66
+ Use SuperLocalMemory as a memory backend in your LangChain and LlamaIndex applications — 100% local, zero cloud.
67
+
68
+ ### LangChain
69
+
70
+ ```bash
71
+ pip install langchain-superlocalmemory
72
+ ```
73
+
74
+ ```python
75
+ from langchain_superlocalmemory import SuperLocalMemoryChatMessageHistory
76
+ from langchain_core.runnables.history import RunnableWithMessageHistory
77
+
78
+ history = SuperLocalMemoryChatMessageHistory(session_id="my-session")
79
+ # Messages persist across sessions, stored locally in ~/.claude-memory/memory.db
80
+ ```
81
+
82
+ ### LlamaIndex
83
+
84
+ ```bash
85
+ pip install llama-index-storage-chat-store-superlocalmemory
86
+ ```
87
+
88
+ ```python
89
+ from llama_index.storage.chat_store.superlocalmemory import SuperLocalMemoryChatStore
90
+ from llama_index.core.memory import ChatMemoryBuffer
91
+
92
+ chat_store = SuperLocalMemoryChatStore()
93
+ memory = ChatMemoryBuffer.from_defaults(chat_store=chat_store, chat_store_key="user-1")
94
+ ```
95
+
96
+ [LangChain Guide](https://github.com/varun369/SuperLocalMemoryV2/wiki/LangChain-Integration) | [LlamaIndex Guide](https://github.com/varun369/SuperLocalMemoryV2/wiki/LlamaIndex-Integration)
97
+
98
+ ---
99
+
42
100
  ## Install in One Command
43
101
 
44
102
  ```bash
@@ -424,6 +482,8 @@ Not another simple key-value store. SuperLocalMemory implements **cutting-edge m
424
482
 
425
483
  ### Multi-Layer Memory Architecture
426
484
 
485
+ **[View Interactive Architecture Diagram](https://varun369.github.io/SuperLocalMemoryV2/architecture.html)** — Click any layer for details, research references, and file paths.
486
+
427
487
  ```
428
488
  ┌─────────────────────────────────────────────────────────────┐
429
489
  │ Layer 9: VISUALIZATION (NEW v2.2.0) │
@@ -0,0 +1,190 @@
1
+ # SuperLocalMemory V2.5 Architecture — "Your AI Memory Has a Heartbeat"
2
+
3
+ **Version:** 2.5.0 | **Date:** February 12, 2026 | **Author:** Varun Pratap Bhardwaj
4
+
5
+ ---
6
+
7
+ ## What Changed in v2.5
8
+
9
+ SuperLocalMemory transforms from **passive storage** (filing cabinet) to **active coordination layer** (nervous system). Every memory write, update, delete, or recall now triggers real-time events visible across all connected tools.
10
+
11
+ ### Before v2.5 (Passive)
12
+ ```
13
+ Claude writes memory → saved to SQLite → done (silent)
14
+ Cursor reads memory → returned → done (silent)
15
+ ```
16
+
17
+ ### After v2.5 (Active)
18
+ ```
19
+ Claude writes memory → saved to SQLite → Event Bus fires
20
+ ├── SSE → Dashboard shows it live
21
+ ├── Agent registered in registry
22
+ ├── Trust signal recorded
23
+ ├── Provenance tracked
24
+ └── Webhook dispatched (if configured)
25
+ ```
26
+
27
+ ---
28
+
29
+ ## System Architecture
30
+
31
+ ```
32
+ ┌─────────────────────────────────────────────────────────────┐
33
+ │ ACCESS LAYER │
34
+ │ MCP Server │ CLI │ REST API │ Skills │ Python Import │ A2A │
35
+ └──────────────────────┬──────────────────────────────────────┘
36
+
37
+ ┌──────────────────────┴──────────────────────────────────────┐
38
+ │ MEMORY STORE V2 │
39
+ │ ┌─────────────────────────────────────────────────────────┐ │
40
+ │ │ DbConnectionManager (Singleton) │ │
41
+ │ │ ├── WAL Mode (concurrent reads + serialized writes) │ │
42
+ │ │ ├── Busy Timeout (5s wait, not fail) │ │
43
+ │ │ ├── Thread-Local Read Pool │ │
44
+ │ │ ├── Serialized Write Queue (threading.Queue) │ │
45
+ │ │ └── Post-Write Hooks → Event Bus │ │
46
+ │ └─────────────────────────────────────────────────────┘ │
47
+ │ │
48
+ │ On every write: │
49
+ │ ├── EventBus.emit() → memory_events table + SSE + WS + WH │
50
+ │ ├── ProvenanceTracker → created_by, source_protocol columns │
51
+ │ ├── AgentRegistry → agent tracking + write/recall counters │
52
+ │ └── TrustScorer → signal collection (silent, no enforcement)│
53
+ └──────────────────────────────────────────────────────────────┘
54
+
55
+ ┌──────────────────────┴──────────────────────────────────────┐
56
+ │ STORAGE LAYER │
57
+ │ SQLite (single file: ~/.claude-memory/memory.db) │
58
+ │ │
59
+ │ Tables: │
60
+ │ ├── memories (+ provenance columns: created_by, │
61
+ │ │ source_protocol, trust_score, provenance_chain) │
62
+ │ ├── memory_events (event log with tiered retention) │
63
+ │ ├── subscriptions (durable + ephemeral event subscriptions) │
64
+ │ ├── agent_registry (connected agents + statistics) │
65
+ │ ├── trust_signals (trust signal audit trail) │
66
+ │ ├── graph_nodes, graph_edges, graph_clusters (knowledge graph)│
67
+ │ ├── identity_patterns (learned preferences) │
68
+ │ ├── sessions, creator_metadata │
69
+ │ └── memories_fts (FTS5 full-text search index) │
70
+ └──────────────────────────────────────────────────────────────┘
71
+
72
+ ┌──────────────────────┴──────────────────────────────────────┐
73
+ │ DASHBOARD LAYER │
74
+ │ FastAPI UI Server (modular routes) │
75
+ │ ├── 8 route modules in routes/ directory │
76
+ │ ├── 28 API endpoints │
77
+ │ ├── SSE /events/stream (real-time, cross-process) │
78
+ │ ├── WebSocket /ws/updates │
79
+ │ ├── 13 modular JS files in ui/js/ │
80
+ │ └── 8 dashboard tabs (Graph, Memories, Clusters, Patterns, │
81
+ │ Timeline, Live Events, Agents, Settings) │
82
+ └──────────────────────────────────────────────────────────────┘
83
+ ```
84
+
85
+ ---
86
+
87
+ ## New Components (v2.5)
88
+
89
+ | Component | File | Purpose |
90
+ |-----------|------|---------|
91
+ | **DbConnectionManager** | `src/db_connection_manager.py` | WAL mode, busy timeout, read pool, write queue, post-write hooks |
92
+ | **EventBus** | `src/event_bus.py` | Event emission, persistence, in-memory buffer, tiered retention |
93
+ | **SubscriptionManager** | `src/subscription_manager.py` | Durable + ephemeral event subscriptions with filters |
94
+ | **WebhookDispatcher** | `src/webhook_dispatcher.py` | Background HTTP POST delivery with retry logic |
95
+ | **AgentRegistry** | `src/agent_registry.py` | Agent tracking, write/recall counters, protocol detection |
96
+ | **ProvenanceTracker** | `src/provenance_tracker.py` | Memory origin tracking (who, how, trust, lineage) |
97
+ | **TrustScorer** | `src/trust_scorer.py` | Bayesian trust scoring with decay, burst detection |
98
+
99
+ ## New Database Tables (v2.5)
100
+
101
+ | Table | Columns | Purpose |
102
+ |-------|---------|---------|
103
+ | `memory_events` | id, event_type, memory_id, source_agent, source_protocol, payload, importance, tier, created_at | Event log with tiered retention |
104
+ | `subscriptions` | id, subscriber_id, channel, filter, webhook_url, durable, last_event_id | Event subscriptions |
105
+ | `agent_registry` | id, agent_id, agent_name, protocol, first_seen, last_seen, memories_written, memories_recalled, trust_score, metadata | Agent tracking |
106
+ | `trust_signals` | id, agent_id, signal_type, delta, old_score, new_score, context, created_at | Trust audit trail |
107
+
108
+ ## New Columns on `memories` Table (v2.5)
109
+
110
+ | Column | Type | Default | Purpose |
111
+ |--------|------|---------|---------|
112
+ | `created_by` | TEXT | 'user' | Agent ID that created this memory |
113
+ | `source_protocol` | TEXT | 'cli' | Protocol used (mcp, cli, rest, python, a2a) |
114
+ | `trust_score` | REAL | 1.0 | Trust score at creation time |
115
+ | `provenance_chain` | TEXT | '[]' | JSON derivation lineage |
116
+
117
+ ---
118
+
119
+ ## Event Types
120
+
121
+ | Event | Trigger |
122
+ |-------|---------|
123
+ | `memory.created` | New memory written |
124
+ | `memory.updated` | Existing memory modified |
125
+ | `memory.deleted` | Memory removed |
126
+ | `memory.recalled` | Memory retrieved by an agent |
127
+ | `graph.updated` | Knowledge graph rebuilt |
128
+ | `pattern.learned` | New pattern detected |
129
+ | `agent.connected` | New agent connects |
130
+ | `agent.disconnected` | Agent disconnects |
131
+
132
+ ## Event Retention Tiers
133
+
134
+ | Tier | Window | Kept |
135
+ |------|--------|------|
136
+ | Hot | 0-48h | All events |
137
+ | Warm | 2-14d | Importance >= 5 only |
138
+ | Cold | 14-30d | Daily aggregates |
139
+ | Archive | 30d+ | Pruned (stats in pattern_learner) |
140
+
141
+ ---
142
+
143
+ ## Trust Scoring (Silent Collection — v2.5)
144
+
145
+ All agents start at trust 1.0. Signals adjust the score with a Bayesian decay factor that stabilizes over time.
146
+
147
+ | Signal | Delta | When |
148
+ |--------|-------|------|
149
+ | `high_importance_write` | +0.015 | Memory with importance >= 7 |
150
+ | `memory_recalled_by_others` | +0.02 | Another agent finds this memory useful |
151
+ | `quick_delete` | -0.03 | Memory deleted within 1 hour |
152
+ | `high_volume_burst` | -0.02 | >20 writes in 5 minutes |
153
+
154
+ **v2.5:** Silent collection only. **v2.6:** Trust-weighted recall ranking. **v3.0:** Active enforcement.
155
+
156
+ ---
157
+
158
+ ## API Endpoints (28 total)
159
+
160
+ | Route | Method | Module | Purpose |
161
+ |-------|--------|--------|---------|
162
+ | `/` | GET | ui_server.py | Dashboard |
163
+ | `/health` | GET | ui_server.py | Health check |
164
+ | `/api/memories` | GET | routes/memories.py | List memories |
165
+ | `/api/graph` | GET | routes/memories.py | Knowledge graph data |
166
+ | `/api/search` | POST | routes/memories.py | Semantic search |
167
+ | `/api/clusters` | GET | routes/memories.py | Cluster info |
168
+ | `/api/clusters/{id}` | GET | routes/memories.py | Cluster detail |
169
+ | `/api/stats` | GET | routes/stats.py | System statistics |
170
+ | `/api/timeline` | GET | routes/stats.py | Timeline aggregation |
171
+ | `/api/patterns` | GET | routes/stats.py | Learned patterns |
172
+ | `/api/profiles` | GET | routes/profiles.py | List profiles |
173
+ | `/api/profiles/{n}/switch` | POST | routes/profiles.py | Switch profile |
174
+ | `/api/profiles/create` | POST | routes/profiles.py | Create profile |
175
+ | `/api/profiles/{n}` | DELETE | routes/profiles.py | Delete profile |
176
+ | `/api/export` | GET | routes/data_io.py | Export memories |
177
+ | `/api/import` | POST | routes/data_io.py | Import memories |
178
+ | `/api/backup/*` | GET/POST | routes/backup.py | Backup management |
179
+ | `/events/stream` | GET | routes/events.py | SSE real-time stream |
180
+ | `/api/events` | GET | routes/events.py | Event polling |
181
+ | `/api/events/stats` | GET | routes/events.py | Event statistics |
182
+ | `/api/agents` | GET | routes/agents.py | Agent list |
183
+ | `/api/agents/stats` | GET | routes/agents.py | Agent statistics |
184
+ | `/api/trust/stats` | GET | routes/agents.py | Trust overview |
185
+ | `/api/trust/signals/{id}` | GET | routes/agents.py | Agent trust signals |
186
+ | `/ws/updates` | WS | routes/ws.py | WebSocket |
187
+
188
+ ---
189
+
190
+ *SuperLocalMemory V2.5 — Created by Varun Pratap Bhardwaj. MIT License.*