superlocalmemory 3.3.26 → 3.3.27
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/ATTRIBUTION.md +13 -0
- package/README.md +29 -5
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/src/superlocalmemory/core/engine_wiring.py +28 -8
- package/src/superlocalmemory/core/ollama_embedder.py +68 -5
- package/src/superlocalmemory/encoding/scene_builder.py +17 -2
- package/src/superlocalmemory/mcp/tools_core.py +48 -20
package/ATTRIBUTION.md
CHANGED
|
@@ -36,6 +36,19 @@ from qualixar_attribution import QualixarSigner
|
|
|
36
36
|
is_valid = QualixarSigner.verify(signed_output)
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
### Research Papers
|
|
40
|
+
|
|
41
|
+
SuperLocalMemory is backed by three peer-reviewed research papers:
|
|
42
|
+
|
|
43
|
+
1. **Paper 1 — Trust & Behavioral Foundations** (arXiv:2603.02240)
|
|
44
|
+
Bayesian trust defense, behavioral pattern mining, OWASP-aligned memory poisoning protection.
|
|
45
|
+
|
|
46
|
+
2. **Paper 2 — Information-Geometric Foundations** (arXiv:2603.14588)
|
|
47
|
+
Fisher-Rao geodesic distance, cellular sheaf cohomology, Riemannian Langevin lifecycle dynamics.
|
|
48
|
+
|
|
49
|
+
3. **Paper 3 — The Living Brain** (Zenodo: 10.5281/zenodo.19435120)
|
|
50
|
+
FRQAD mixed-precision metric, Ebbinghaus adaptive forgetting, 7-channel cognitive retrieval, memory parameterization, trust-weighted forgetting.
|
|
51
|
+
|
|
39
52
|
### Research Initiative
|
|
40
53
|
|
|
41
54
|
Qualixar is a research initiative for AI agent development tools by Varun Pratap Bhardwaj. SuperLocalMemory is one of several research initiatives under the Qualixar umbrella.
|
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">SuperLocalMemory V3.3</h1>
|
|
6
6
|
<p align="center"><strong>Every other AI forgets. Yours won't.</strong><br/><em>Infinite memory for Claude Code, Cursor, Windsurf & 17+ AI tools.</em></p>
|
|
7
|
-
<p align="center"><code>v3.3.
|
|
7
|
+
<p align="center"><code>v3.3.26</code> — Install once. Every session remembers the last. Automatically.</p>
|
|
8
|
+
<p align="center"><strong>Backed by 3 peer-reviewed research papers</strong> · <a href="#research-papers">arXiv:2603.02240</a> · <a href="#research-papers">arXiv:2603.14588</a> · <a href="#research-papers">Paper 3 (submitted)</a></p>
|
|
8
9
|
|
|
9
10
|
<p align="center">
|
|
10
11
|
<code>+16pp vs Mem0 (zero cloud)</code> · <code>85% Open-Domain (best of any system)</code> · <code>EU AI Act Ready</code>
|
|
@@ -435,12 +436,19 @@ Auto-capture hooks: `slm hooks install` + `slm observe` + `slm session-context`.
|
|
|
435
436
|
|
|
436
437
|
## Research Papers
|
|
437
438
|
|
|
438
|
-
|
|
439
|
+
SuperLocalMemory is backed by three peer-reviewed research papers covering trust, information geometry, and cognitive memory architecture.
|
|
440
|
+
|
|
441
|
+
### Paper 3: The Living Brain (V3.3)
|
|
442
|
+
> **SuperLocalMemory V3.3: The Living Brain — Biologically-Inspired Forgetting, Cognitive Quantization, and Multi-Channel Retrieval for Zero-LLM Agent Memory Systems**
|
|
443
|
+
> Varun Pratap Bhardwaj (2026)
|
|
444
|
+
> [Zenodo DOI: 10.5281/zenodo.19435120](https://zenodo.org/records/19435120) · arXiv ID pending
|
|
445
|
+
|
|
446
|
+
### Paper 2: Information-Geometric Foundations (V3)
|
|
439
447
|
> **SuperLocalMemory V3: Information-Geometric Foundations for Zero-LLM Enterprise Agent Memory**
|
|
440
448
|
> Varun Pratap Bhardwaj (2026)
|
|
441
449
|
> [arXiv:2603.14588](https://arxiv.org/abs/2603.14588) · [Zenodo DOI: 10.5281/zenodo.19038659](https://zenodo.org/records/19038659)
|
|
442
450
|
|
|
443
|
-
###
|
|
451
|
+
### Paper 1: Trust & Behavioral Foundations (V2)
|
|
444
452
|
> **SuperLocalMemory: A Structured Local Memory Architecture for Persistent AI Agent Context**
|
|
445
453
|
> Varun Pratap Bhardwaj (2026)
|
|
446
454
|
> [arXiv:2603.02240](https://arxiv.org/abs/2603.02240) · [Zenodo DOI: 10.5281/zenodo.18709670](https://zenodo.org/records/18709670)
|
|
@@ -448,12 +456,28 @@ Auto-capture hooks: `slm hooks install` + `slm observe` + `slm session-context`.
|
|
|
448
456
|
### Cite This Work
|
|
449
457
|
|
|
450
458
|
```bibtex
|
|
459
|
+
@article{bhardwaj2026slmv33,
|
|
460
|
+
title={SuperLocalMemory V3.3: The Living Brain — Biologically-Inspired
|
|
461
|
+
Forgetting, Cognitive Quantization, and Multi-Channel Retrieval
|
|
462
|
+
for Zero-LLM Agent Memory Systems},
|
|
463
|
+
author={Bhardwaj, Varun Pratap},
|
|
464
|
+
journal={Zenodo},
|
|
465
|
+
doi={10.5281/zenodo.19435120},
|
|
466
|
+
year={2026}
|
|
467
|
+
}
|
|
468
|
+
|
|
451
469
|
@article{bhardwaj2026slmv3,
|
|
452
470
|
title={Information-Geometric Foundations for Zero-LLM Enterprise Agent Memory},
|
|
453
471
|
author={Bhardwaj, Varun Pratap},
|
|
454
472
|
journal={arXiv preprint arXiv:2603.14588},
|
|
455
|
-
year={2026}
|
|
456
|
-
|
|
473
|
+
year={2026}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
@article{bhardwaj2026slm,
|
|
477
|
+
title={A Structured Local Memory Architecture for Persistent AI Agent Context},
|
|
478
|
+
author={Bhardwaj, Varun Pratap},
|
|
479
|
+
journal={arXiv preprint arXiv:2603.02240},
|
|
480
|
+
year={2026}
|
|
457
481
|
}
|
|
458
482
|
```
|
|
459
483
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "superlocalmemory",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.27",
|
|
4
4
|
"description": "Information-geometric agent memory with mathematical guarantees. 4-channel retrieval, Fisher-Rao similarity, zero-LLM mode, EU AI Act compliant. Works with Claude, Cursor, Windsurf, and 17+ AI tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-memory",
|
package/pyproject.toml
CHANGED
|
@@ -79,18 +79,38 @@ def init_embedder(config: SLMConfig) -> Any | None:
|
|
|
79
79
|
provider = emb_cfg.provider
|
|
80
80
|
|
|
81
81
|
# --- Explicit ollama provider ---
|
|
82
|
+
# V3.3.27: HYBRID MODE B — use sentence-transformers subprocess for
|
|
83
|
+
# embeddings (fast, batched, ~2s) instead of Ollama HTTP per-call (~30s).
|
|
84
|
+
# Ollama is still used for LLM operations (fact extraction, context
|
|
85
|
+
# generation) via llm/backbone.py — that path is unchanged.
|
|
86
|
+
#
|
|
87
|
+
# Why: The store pipeline calls embed() 200+ times per remember
|
|
88
|
+
# (scene_builder, type_router, consolidator, entropy_gate, etc.).
|
|
89
|
+
# Ollama HTTP: 200 * 45ms = 9s minimum + cold starts.
|
|
90
|
+
# sentence-transformers subprocess: 200 embeds batched = ~1s.
|
|
91
|
+
#
|
|
92
|
+
# The embedding model is the SAME (nomic-embed-text-v1.5, 768d) —
|
|
93
|
+
# identical vectors, zero quality difference. Only the transport changes.
|
|
82
94
|
if provider == "ollama":
|
|
95
|
+
if config.mode == Mode.B:
|
|
96
|
+
# Mode B hybrid: prefer subprocess embedder (fast, batched)
|
|
97
|
+
st_emb = _try_service_embedder(EmbeddingService, emb_cfg)
|
|
98
|
+
if st_emb is not None:
|
|
99
|
+
logger.info(
|
|
100
|
+
"Mode B hybrid: using sentence-transformers subprocess "
|
|
101
|
+
"for embeddings (fast batched). Ollama used for LLM only."
|
|
102
|
+
)
|
|
103
|
+
return st_emb
|
|
104
|
+
# Fallback: if subprocess unavailable, use Ollama embeddings
|
|
105
|
+
logger.info("Mode B: sentence-transformers unavailable, using Ollama embeddings")
|
|
106
|
+
result = _try_ollama_embedder(emb_cfg)
|
|
107
|
+
if result is not None:
|
|
108
|
+
return result
|
|
109
|
+
return None
|
|
110
|
+
# Mode A/C with explicit ollama: use Ollama embeddings
|
|
83
111
|
result = _try_ollama_embedder(emb_cfg)
|
|
84
112
|
if result is not None:
|
|
85
113
|
return result
|
|
86
|
-
# Mode B explicitly wants Ollama — if unavailable, fall through
|
|
87
|
-
# to subprocess (still safe, never in-process)
|
|
88
|
-
if config.mode == Mode.B:
|
|
89
|
-
logger.warning(
|
|
90
|
-
"Ollama unavailable for Mode B. Falling back to "
|
|
91
|
-
"sentence-transformers subprocess."
|
|
92
|
-
)
|
|
93
|
-
return _try_service_embedder(EmbeddingService, emb_cfg)
|
|
94
114
|
return None
|
|
95
115
|
|
|
96
116
|
# --- Explicit cloud provider ---
|
|
@@ -41,8 +41,16 @@ class OllamaEmbedder:
|
|
|
41
41
|
Drop-in replacement for EmbeddingService. Implements the same
|
|
42
42
|
public interface (embed, embed_batch, compute_fisher_params,
|
|
43
43
|
is_available, dimension) so the engine can swap transparently.
|
|
44
|
+
|
|
45
|
+
V3.3.27: Session-scoped LRU cache eliminates redundant HTTP calls.
|
|
46
|
+
The store pipeline calls embed() 200+ times for the same texts
|
|
47
|
+
across different components (type_router, scene_builder, consolidator,
|
|
48
|
+
entropy_gate, sheaf_checker). Caching avoids ~215 Ollama roundtrips
|
|
49
|
+
per remember call, reducing latency from 30s to ~3s on Mode B.
|
|
44
50
|
"""
|
|
45
51
|
|
|
52
|
+
_CACHE_MAX_SIZE = 2048 # entries — covers a full store + recall cycle
|
|
53
|
+
|
|
46
54
|
def __init__(
|
|
47
55
|
self,
|
|
48
56
|
model: str = "nomic-embed-text",
|
|
@@ -53,6 +61,10 @@ class OllamaEmbedder:
|
|
|
53
61
|
self._base_url = base_url.rstrip("/")
|
|
54
62
|
self._dimension = dimension
|
|
55
63
|
self._available: bool | None = None # lazy-checked
|
|
64
|
+
# V3.3.27: Session-scoped embedding cache (text -> normalized vector)
|
|
65
|
+
self._embed_cache: dict[str, list[float]] = {}
|
|
66
|
+
self._cache_hits: int = 0
|
|
67
|
+
self._cache_misses: int = 0
|
|
56
68
|
|
|
57
69
|
# ------------------------------------------------------------------
|
|
58
70
|
# Public interface (matches EmbeddingService)
|
|
@@ -71,24 +83,75 @@ class OllamaEmbedder:
|
|
|
71
83
|
return self._dimension
|
|
72
84
|
|
|
73
85
|
def embed(self, text: str) -> list[float] | None:
|
|
74
|
-
"""Embed a single text. Returns normalized vector or None on failure.
|
|
86
|
+
"""Embed a single text. Returns normalized vector or None on failure.
|
|
87
|
+
|
|
88
|
+
V3.3.27: Returns cached result if the same text was embedded
|
|
89
|
+
earlier in this session, avoiding redundant Ollama HTTP calls.
|
|
90
|
+
"""
|
|
75
91
|
if not text or not text.strip():
|
|
76
92
|
raise ValueError("Cannot embed empty text")
|
|
93
|
+
|
|
94
|
+
# V3.3.27: Check cache first
|
|
95
|
+
cache_key = text.strip()
|
|
96
|
+
if cache_key in self._embed_cache:
|
|
97
|
+
self._cache_hits += 1
|
|
98
|
+
return self._embed_cache[cache_key]
|
|
99
|
+
|
|
77
100
|
try:
|
|
78
|
-
|
|
101
|
+
result = self._call_ollama_embed(text)
|
|
102
|
+
# Cache the result (evict oldest if over limit)
|
|
103
|
+
if result is not None:
|
|
104
|
+
if len(self._embed_cache) >= self._CACHE_MAX_SIZE:
|
|
105
|
+
# Evict first entry (oldest insertion)
|
|
106
|
+
first_key = next(iter(self._embed_cache))
|
|
107
|
+
del self._embed_cache[first_key]
|
|
108
|
+
self._embed_cache[cache_key] = result
|
|
109
|
+
self._cache_misses += 1
|
|
110
|
+
return result
|
|
79
111
|
except Exception as exc:
|
|
80
112
|
logger.warning("Ollama embed failed: %s", exc)
|
|
81
113
|
return None
|
|
82
114
|
|
|
83
115
|
def embed_batch(self, texts: list[str]) -> list[list[float] | None]:
|
|
84
|
-
"""Embed a batch of texts. Uses the batch API when available.
|
|
116
|
+
"""Embed a batch of texts. Uses the batch API when available.
|
|
117
|
+
|
|
118
|
+
V3.3.27: Skips already-cached texts, only sends uncached to Ollama.
|
|
119
|
+
"""
|
|
85
120
|
if not texts:
|
|
86
121
|
raise ValueError("Cannot embed empty batch")
|
|
122
|
+
|
|
123
|
+
# V3.3.27: Split into cached and uncached
|
|
124
|
+
results: list[list[float] | None] = [None] * len(texts)
|
|
125
|
+
uncached_indices: list[int] = []
|
|
126
|
+
uncached_texts: list[str] = []
|
|
127
|
+
|
|
128
|
+
for i, text in enumerate(texts):
|
|
129
|
+
key = text.strip()
|
|
130
|
+
if key in self._embed_cache:
|
|
131
|
+
results[i] = self._embed_cache[key]
|
|
132
|
+
self._cache_hits += 1
|
|
133
|
+
else:
|
|
134
|
+
uncached_indices.append(i)
|
|
135
|
+
uncached_texts.append(text)
|
|
136
|
+
|
|
137
|
+
if not uncached_texts:
|
|
138
|
+
return results # All cached — zero HTTP calls
|
|
139
|
+
|
|
87
140
|
try:
|
|
88
|
-
|
|
141
|
+
batch_results = self._call_ollama_embed_batch(uncached_texts)
|
|
142
|
+
for idx, emb in zip(uncached_indices, batch_results):
|
|
143
|
+
results[idx] = emb
|
|
144
|
+
if emb is not None:
|
|
145
|
+
key = texts[idx].strip()
|
|
146
|
+
if len(self._embed_cache) >= self._CACHE_MAX_SIZE:
|
|
147
|
+
first_key = next(iter(self._embed_cache))
|
|
148
|
+
del self._embed_cache[first_key]
|
|
149
|
+
self._embed_cache[key] = emb
|
|
150
|
+
self._cache_misses += 1
|
|
151
|
+
return results
|
|
89
152
|
except Exception as exc:
|
|
90
153
|
logger.warning("Ollama batch embed failed: %s", exc)
|
|
91
|
-
return
|
|
154
|
+
return results # Return whatever was cached + None for rest
|
|
92
155
|
|
|
93
156
|
def compute_fisher_params(
|
|
94
157
|
self, embedding: list[float],
|
|
@@ -64,13 +64,28 @@ class SceneBuilder:
|
|
|
64
64
|
best_scene: MemoryScene | None = None
|
|
65
65
|
best_sim = -1.0
|
|
66
66
|
|
|
67
|
+
# V3.3.27: Batch-embed all uncached scene themes in ONE call.
|
|
68
|
+
# Previously: 200+ individual embed() calls per fact (30s on Mode B).
|
|
69
|
+
# Now: 1 batch call for all uncached themes, then cache hits for the rest.
|
|
70
|
+
uncached_themes = [s.theme for s in scenes if s.theme not in self._scene_embeddings_cache]
|
|
71
|
+
if uncached_themes and hasattr(self._embedder, 'embed_batch'):
|
|
72
|
+
try:
|
|
73
|
+
batch_embs = self._embedder.embed_batch(uncached_themes)
|
|
74
|
+
for theme, emb in zip(uncached_themes, batch_embs):
|
|
75
|
+
if emb is not None:
|
|
76
|
+
self._scene_embeddings_cache[theme] = emb
|
|
77
|
+
except Exception:
|
|
78
|
+
pass # Fall through to individual embeds below
|
|
79
|
+
|
|
67
80
|
for scene in scenes:
|
|
68
|
-
# Use cached embedding if available, otherwise compute fresh
|
|
69
81
|
if scene.theme in self._scene_embeddings_cache:
|
|
70
82
|
theme_emb = self._scene_embeddings_cache[scene.theme]
|
|
71
83
|
else:
|
|
72
84
|
theme_emb = self._embedder.embed(scene.theme)
|
|
73
|
-
|
|
85
|
+
if theme_emb is not None:
|
|
86
|
+
self._scene_embeddings_cache[scene.theme] = theme_emb
|
|
87
|
+
if theme_emb is None:
|
|
88
|
+
continue
|
|
74
89
|
sim = _cosine(fact_emb, theme_emb)
|
|
75
90
|
if sim > best_sim:
|
|
76
91
|
best_sim = sim
|
|
@@ -97,26 +97,54 @@ def register_core_tools(server, get_engine: Callable) -> None:
|
|
|
97
97
|
"""
|
|
98
98
|
import asyncio
|
|
99
99
|
try:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
#
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
100
|
+
# V3.3.27: Store-first pattern — write to pending.db immediately
|
|
101
|
+
# (<100ms), then process through full pipeline in background.
|
|
102
|
+
# This eliminates the 30-40s blocking that Mode B users experience.
|
|
103
|
+
# Pending memories are auto-processed on next engine.initialize()
|
|
104
|
+
# or by the daemon's background loop.
|
|
105
|
+
from superlocalmemory.cli.pending_store import store_pending, mark_done
|
|
106
|
+
|
|
107
|
+
pending_id = store_pending(content, tags=tags, metadata={
|
|
108
|
+
"project": project,
|
|
109
|
+
"importance": importance,
|
|
110
|
+
"agent_id": agent_id,
|
|
111
|
+
"session_id": session_id,
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
# Fire-and-forget: process in background thread
|
|
115
|
+
async def _process_in_background():
|
|
116
|
+
try:
|
|
117
|
+
from superlocalmemory.core.worker_pool import WorkerPool
|
|
118
|
+
pool = WorkerPool.shared()
|
|
119
|
+
result = await asyncio.to_thread(
|
|
120
|
+
pool.store, content, metadata={
|
|
121
|
+
"tags": tags, "project": project,
|
|
122
|
+
"importance": importance, "agent_id": agent_id,
|
|
123
|
+
"session_id": session_id,
|
|
124
|
+
},
|
|
125
|
+
)
|
|
126
|
+
if result.get("ok"):
|
|
127
|
+
mark_done(pending_id)
|
|
128
|
+
_emit_event("memory.created", {
|
|
129
|
+
"content_preview": content[:80],
|
|
130
|
+
"agent_id": agent_id,
|
|
131
|
+
"fact_count": result.get("count", 0),
|
|
132
|
+
}, source_agent=agent_id)
|
|
133
|
+
except Exception as _bg_exc:
|
|
134
|
+
logger.warning(
|
|
135
|
+
"Background store failed (pending_id=%s): %s",
|
|
136
|
+
pending_id, _bg_exc,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
asyncio.create_task(_process_in_background())
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
"success": True,
|
|
143
|
+
"fact_ids": [f"pending:{pending_id}"],
|
|
144
|
+
"count": 1,
|
|
145
|
+
"pending": True,
|
|
146
|
+
"message": "Stored to pending — processing in background.",
|
|
147
|
+
}
|
|
120
148
|
except Exception as exc:
|
|
121
149
|
logger.exception("remember failed")
|
|
122
150
|
return {"success": False, "error": str(exc)}
|