Skip to content

Commit 60ecb33

Browse files
committed
feat(memory): Add LLM-native memory system
1 parent 5976413 commit 60ecb33

5 files changed

Lines changed: 4089 additions & 0 deletions

File tree

src/sochdb/memory/__init__.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Copyright 2025 Sushanth (https://github.com/sushanthpy)
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
SochDB Memory Module - LLM-Native Memory Management
17+
18+
This module provides a complete memory system for AI agents:
19+
20+
1. **Extraction Pipeline** - Compile LLM outputs into typed, validated facts
21+
2. **Consolidation** - Event-sourced canonicalization without data loss
22+
3. **Hybrid Retrieval** - RRF-based retrieval with pre-filtering
23+
4. **Namespace Isolation** - Multi-tenant memory with strict scoping
24+
25+
All components support both embedded (FFI) and server (gRPC) modes.
26+
"""
27+
28+
from .extraction import (
29+
Entity,
30+
Relation,
31+
Assertion,
32+
ExtractionResult,
33+
ExtractionSchema,
34+
MemoryBackend,
35+
FFIMemoryBackend,
36+
GrpcMemoryBackend,
37+
InMemoryBackend,
38+
ExtractionPipeline,
39+
create_extraction_pipeline,
40+
)
41+
42+
from .consolidation import (
43+
RawAssertion,
44+
CanonicalFact,
45+
ConsolidationConfig,
46+
ConsolidationBackend,
47+
FFIConsolidationBackend,
48+
GrpcConsolidationBackend,
49+
InMemoryConsolidationBackend,
50+
Consolidator,
51+
create_consolidator,
52+
)
53+
54+
from .retrieval import (
55+
RetrievalConfig,
56+
RetrievalResult,
57+
RetrievalResponse,
58+
RetrievalBackend,
59+
FFIRetrievalBackend,
60+
GrpcRetrievalBackend,
61+
InMemoryRetrievalBackend,
62+
HybridRetriever,
63+
AllowedSet,
64+
create_retriever,
65+
)
66+
67+
from .isolation import (
68+
NamespaceId,
69+
NamespacePolicy,
70+
NamespaceGrant,
71+
ScopedQuery,
72+
ScopedNamespace,
73+
NamespaceBackend,
74+
FFINamespaceBackend,
75+
GrpcNamespaceBackend,
76+
InMemoryNamespaceBackend,
77+
NamespaceManager,
78+
create_namespace_manager,
79+
)
80+
81+
__all__ = [
82+
# Extraction
83+
"Entity",
84+
"Relation",
85+
"Assertion",
86+
"ExtractionResult",
87+
"ExtractionSchema",
88+
"MemoryBackend",
89+
"FFIMemoryBackend",
90+
"GrpcMemoryBackend",
91+
"InMemoryBackend",
92+
"ExtractionPipeline",
93+
"create_extraction_pipeline",
94+
# Consolidation
95+
"RawAssertion",
96+
"CanonicalFact",
97+
"ConsolidationConfig",
98+
"ConsolidationBackend",
99+
"FFIConsolidationBackend",
100+
"GrpcConsolidationBackend",
101+
"InMemoryConsolidationBackend",
102+
"Consolidator",
103+
"create_consolidator",
104+
# Retrieval
105+
"RetrievalConfig",
106+
"RetrievalResult",
107+
"RetrievalResponse",
108+
"RetrievalBackend",
109+
"FFIRetrievalBackend",
110+
"GrpcRetrievalBackend",
111+
"InMemoryRetrievalBackend",
112+
"HybridRetriever",
113+
"AllowedSet",
114+
"create_retriever",
115+
# Namespace Isolation
116+
"NamespaceId",
117+
"NamespacePolicy",
118+
"NamespaceGrant",
119+
"ScopedQuery",
120+
"ScopedNamespace",
121+
"NamespaceBackend",
122+
"FFINamespaceBackend",
123+
"GrpcNamespaceBackend",
124+
"InMemoryNamespaceBackend",
125+
"NamespaceManager",
126+
"create_namespace_manager",
127+
]

0 commit comments

Comments
 (0)