artl-memory 0.2.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.
- artl_memory-0.2.0/LICENSE +201 -0
- artl_memory-0.2.0/PKG-INFO +176 -0
- artl_memory-0.2.0/README.md +158 -0
- artl_memory-0.2.0/artl_memory/__init__.py +33 -0
- artl_memory-0.2.0/artl_memory/memory_store.py +255 -0
- artl_memory-0.2.0/artl_memory/memview.py +64 -0
- artl_memory-0.2.0/artl_memory/port.py +84 -0
- artl_memory-0.2.0/artl_memory/py.typed +1 -0
- artl_memory-0.2.0/artl_memory/service.py +293 -0
- artl_memory-0.2.0/artl_memory/sqlite.py +552 -0
- artl_memory-0.2.0/artl_memory/types.py +26 -0
- artl_memory-0.2.0/artl_memory.egg-info/PKG-INFO +176 -0
- artl_memory-0.2.0/artl_memory.egg-info/SOURCES.txt +18 -0
- artl_memory-0.2.0/artl_memory.egg-info/dependency_links.txt +1 -0
- artl_memory-0.2.0/artl_memory.egg-info/top_level.txt +1 -0
- artl_memory-0.2.0/pyproject.toml +44 -0
- artl_memory-0.2.0/setup.cfg +4 -0
- artl_memory-0.2.0/tests/test_adversarial.py +119 -0
- artl_memory-0.2.0/tests/test_conformance.py +226 -0
- artl_memory-0.2.0/tests/test_regressions.py +478 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or any Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any Derivative Works regarding such redistribution as long as
|
|
127
|
+
such use, reproduction, and distribution of the Work is permitted
|
|
128
|
+
by the Licensor and is not in violation of the terms of this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of this
|
|
133
|
+
License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the origin of the Work.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your use of the Licensor's permissions.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as copyright) or agreed
|
|
156
|
+
to in writing, will any Contributor be liable to You for damages,
|
|
157
|
+
including any direct, indirect, special, incidental, or consequential
|
|
158
|
+
damages of any character arising as a result of this License or out
|
|
159
|
+
of the use or inability to use the Work (including but not limited
|
|
160
|
+
to damages for personal injury or loss of goodwill, work stoppage,
|
|
161
|
+
computer failure or malfunction, or any and all other commercial
|
|
162
|
+
damages or losses), even if such Contributor has been advised of the
|
|
163
|
+
possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on behalf of You and on Your sole responsibility, not on behalf of
|
|
171
|
+
any other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: artl-memory
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: The multi-person memory layer for agents: verbatim utterances, per-person isolation, evidence chain, confidence. It remembers everyone in the room — separately.
|
|
5
|
+
Author: ARTL family
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/ARTL-family/artl-memory
|
|
8
|
+
Keywords: agent,memory,multi-person,evidence-chain,local-first,sqlite
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# artl-memory
|
|
20
|
+
|
|
21
|
+
**The multi-person memory layer for agents.**
|
|
22
|
+
Verbatim utterances · per-person isolation · evidence chains · confidence scores.
|
|
23
|
+
|
|
24
|
+
> It remembers everyone in the room — separately.
|
|
25
|
+
> We don't promise understanding. We promise not to forget.
|
|
26
|
+
|
|
27
|
+
[中文文档](README.zh-CN.md)
|
|
28
|
+
|
|
29
|
+
artl-memory is extracted from a production assistant. It does **not** "summarize a
|
|
30
|
+
profile of you and pretend to know you" — it stores **who said exactly what, and when**,
|
|
31
|
+
each memory carrying its source utterance and a confidence score. When a fact is
|
|
32
|
+
corrected, the old entry is marked expired — never silently overwritten — and the
|
|
33
|
+
evidence chain stays in place.
|
|
34
|
+
|
|
35
|
+
> **Scope: the ledger, not the ears.** artl-memory contains no audio, no ASR, no
|
|
36
|
+
> voiceprint. Your upstream pipeline (diarization, voiceprint, manual labels)
|
|
37
|
+
> decides *who* said what and hands this library the name — it keeps the books.
|
|
38
|
+
> That is what makes it dependency-free: usable without ears, plug-and-play with
|
|
39
|
+
> them.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install . # from source (PyPI package not yet published)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Which memory layer should you pick?
|
|
46
|
+
|
|
47
|
+
Everyone arriving here has Mem0 (~60k★) as their reference point, so let's be direct
|
|
48
|
+
about it. These four tools answer **different questions** — this table is for picking
|
|
49
|
+
the right one, not for ranking them.
|
|
50
|
+
|
|
51
|
+
| | **artl-memory** | **Mem0** | **memoripy v4** | **MCP memory (official)** |
|
|
52
|
+
|---|---|---|---|---|
|
|
53
|
+
| Needs an LLM to write memory | **No** — zero model calls | Yes — extraction LLM on every `add()` | No required — deterministic extractor, bring-your-own optional | No — the agent itself decides what to store |
|
|
54
|
+
| What gets stored | **Verbatim utterances** + derived facts | LLM-extracted summaries | Evidence + derived memory, versioned | Entities / relations / observations |
|
|
55
|
+
| Can you trace a memory to its source? | Yes — `source_event` + confidence on every entry | Partial — extraction rewrites wording | Yes — citations and receipts | No |
|
|
56
|
+
| Multi-person isolation | **First-class** — per-person ledger, skills get scoped `MemView`s | Per-`user_id` scoping | Per-`user_id` scoping | No — one shared graph |
|
|
57
|
+
| Deletion | **Hard delete** — `secure_delete` + `VACUUM` + WAL truncation, verified by byte-level scan | API delete; vector-store semantics | `forget` tooling | Delete tools on the JSONL file |
|
|
58
|
+
| Works fully offline | Yes | No (LLM + vector store calls) | Yes | Yes |
|
|
59
|
+
| Semantic (vector) search | **No** — explainable bigram scoring, on purpose | Yes | Optional embeddings | No — substring match |
|
|
60
|
+
| Dependencies | **0** (stdlib `sqlite3`) | LLM client + vector DB + embedder | 0 required (v4) | Node.js runtime |
|
|
61
|
+
|
|
62
|
+
Be fair to each of them:
|
|
63
|
+
|
|
64
|
+
- **Pick Mem0** if you want automatic "talk → extracted profile" with semantic search,
|
|
65
|
+
mature framework integrations (LangChain, CrewAI, AutoGen) and published benchmark
|
|
66
|
+
numbers. That's a lot of real value. The trade-offs are documented by its own
|
|
67
|
+
community: an audit of 10,134 Mem0 entries found 97.8% junk, including hallucinated
|
|
68
|
+
user profiles that get re-extracted and amplified across sessions
|
|
69
|
+
([mem0#4573](https://github.com/mem0ai/mem0/issues/4573)); the HaluMem benchmark
|
|
70
|
+
found extraction-stage hallucination is systemic across LLM-based memory systems
|
|
71
|
+
([arXiv:2511.03506](https://arxiv.org/abs/2511.03506)). If the wording of a memory
|
|
72
|
+
doesn't have to be provably what a human said, that trade may be fine for you.
|
|
73
|
+
- **Pick memoripy** if you like the evidence-first philosophy on a **single-user**
|
|
74
|
+
workload and want an official MCP server out of the box.
|
|
75
|
+
- **Pick the official MCP memory server** if you need a minimal scratchpad for one
|
|
76
|
+
agent on one machine. It calls itself a reference implementation, and it is honest
|
|
77
|
+
about being one.
|
|
78
|
+
- **Pick artl-memory** if the question is *"several people talk to one agent — in a
|
|
79
|
+
meeting room, a family, a mediation session — and the record has to hold up later"*:
|
|
80
|
+
who said which exact sentence, how confident was the transcription, what did the
|
|
81
|
+
agent believe before the correction, and can 王强's utterances really be erased
|
|
82
|
+
byte-for-byte when he asks. If a smart profile matters more than a trustworthy
|
|
83
|
+
ledger, we are the wrong tool — and this README will tell you so again below.
|
|
84
|
+
|
|
85
|
+
## Why multi-person
|
|
86
|
+
|
|
87
|
+
Most agent memory systems are **single-user** models: one user, one profile.
|
|
88
|
+
artl-memory was a multi-person model from day one:
|
|
89
|
+
|
|
90
|
+
- **Per-person isolation**: 王强's utterances never leak into 李四's recall; skills and
|
|
91
|
+
plugins only see their own slot through `MemView`, which holds no store handle
|
|
92
|
+
(same-process introspection can still dig — for hostile code, use process isolation)
|
|
93
|
+
- **Verbatim first**: the original sentence is stored before any judgement; rewriting
|
|
94
|
+
history does not exist on this path
|
|
95
|
+
- **Evidence chains**: every memory carries `source_event` (which utterance it came
|
|
96
|
+
from) and `confidence`; corrections expire the old entry and link it via
|
|
97
|
+
`supersedes` — **expiry is not deletion**
|
|
98
|
+
- **Time-based downgrade**: utterances older than N days are pruned — unreferenced
|
|
99
|
+
rows are deleted, referenced rows keep their snippet so the chain never dangles
|
|
100
|
+
- **Right to be forgotten**: `store.purge_designer("王强")` physically erases all five
|
|
101
|
+
tables' worth of his data (`PRAGMA secure_delete` + `VACUUM` + WAL truncation),
|
|
102
|
+
and returns per-table deletion counts
|
|
103
|
+
|
|
104
|
+
## Quickstart (30 seconds)
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from artl_memory import SqliteMemoryStore, MemoryService, MemView
|
|
108
|
+
|
|
109
|
+
store = SqliteMemoryStore("memory.db")
|
|
110
|
+
mem = MemoryService(store, designer="heima")
|
|
111
|
+
|
|
112
|
+
mem.remember("preference", "王强:预算", "三十万",
|
|
113
|
+
source="utterance:wq-001", confidence=0.9)
|
|
114
|
+
mem.recall("王强的预算") # relevance × confidence × time decay — every factor explainable
|
|
115
|
+
|
|
116
|
+
view = MemView(store, owner="skill:render", designer="heima")
|
|
117
|
+
view.put("风格", "奶油风") # this skill's memory; nobody else's gets in
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Run the multi-person example:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
python examples/two_people.py
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Zero dependencies, two backends
|
|
127
|
+
|
|
128
|
+
- **Zero hard dependencies**: standard library only (`sqlite3` is built in). A memory
|
|
129
|
+
layer should not drag a dependency tree through your door.
|
|
130
|
+
- `InMemoryStore` for tests and trials (not thread-safe); `SqliteMemoryStore` with
|
|
131
|
+
WAL, single connection, auto-reopen after close, corrupt-file quarantine, and a
|
|
132
|
+
versioned schema.
|
|
133
|
+
- The same conformance suite runs against both backends:
|
|
134
|
+
`python tests/test_conformance.py` (pytest-compatible)
|
|
135
|
+
- Adversarial tests cover "undocumented but must not explode":
|
|
136
|
+
`python tests/test_adversarial.py`
|
|
137
|
+
- Regression tests pin every bug ever found by external review:
|
|
138
|
+
`python tests/test_regressions.py`
|
|
139
|
+
|
|
140
|
+
## Boundaries (stated plainly)
|
|
141
|
+
|
|
142
|
+
- Values are stored JSON-serialized: `tuple` comes back as `list`; serialize custom
|
|
143
|
+
objects yourself.
|
|
144
|
+
- `recall` is O(n) full-scan scoring — deliberately index-free for explainability.
|
|
145
|
+
The scan window is `MemoryService(recall_window=...)`, default 10000 entries; when
|
|
146
|
+
the window fills up you get a loud `RuntimeWarning`, never silent truncation.
|
|
147
|
+
For bulk imports use `remember_many(...)` (one fsync per batch, ~100x faster than
|
|
148
|
+
per-item commits) and make sure the window exceeds your total entry count.
|
|
149
|
+
- **recall scores by literal token overlap; it does not paraphrase.** Rephrasing or
|
|
150
|
+
mixing languages will miss: `who pays thirty万 for the living room` does not
|
|
151
|
+
recall the Chinese entry「三十万」. If you need semantic search, layer embeddings
|
|
152
|
+
on top of `recall`.
|
|
153
|
+
- Time decay floors at 0.4: very old high-confidence entries keep participating in
|
|
154
|
+
ranking, just discounted. To retire an old memory from ranking entirely, `forget`
|
|
155
|
+
it (expiry, not deletion).
|
|
156
|
+
- Empty query returns an empty list — when there is no question, it does not pretend
|
|
157
|
+
to understand one.
|
|
158
|
+
- Lock boundaries: `MemoryService.remember` is thread-safe via the service lock;
|
|
159
|
+
`InMemoryStore` itself is not thread-safe — use it through the service layer.
|
|
160
|
+
Multi-process writes to the same SQLite file are guarded by database-level unique
|
|
161
|
+
constraints (only one active entry per slot+key); the loser re-reads and
|
|
162
|
+
converges automatically.
|
|
163
|
+
- Isolation is at the API surface. Nothing in-process is cryptographically hidden —
|
|
164
|
+
if plugins are adversarial, put them behind a process boundary.
|
|
165
|
+
|
|
166
|
+
## Explicitly not doing
|
|
167
|
+
|
|
168
|
+
- **No vector retrieval.** bigram recall is deliberate: you can always see *why* it
|
|
169
|
+
remembered this entry. Need embeddings? Layer them on top of `recall`.
|
|
170
|
+
- **No cloud sync, no multi-machine.** Your data is your file. Feature, not bug.
|
|
171
|
+
- **No LLM calls.** The memory layer doesn't know LLMs exist — swap brains freely,
|
|
172
|
+
the memory stays.
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
Apache-2.0 · ARTL family
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# artl-memory
|
|
2
|
+
|
|
3
|
+
**The multi-person memory layer for agents.**
|
|
4
|
+
Verbatim utterances · per-person isolation · evidence chains · confidence scores.
|
|
5
|
+
|
|
6
|
+
> It remembers everyone in the room — separately.
|
|
7
|
+
> We don't promise understanding. We promise not to forget.
|
|
8
|
+
|
|
9
|
+
[中文文档](README.zh-CN.md)
|
|
10
|
+
|
|
11
|
+
artl-memory is extracted from a production assistant. It does **not** "summarize a
|
|
12
|
+
profile of you and pretend to know you" — it stores **who said exactly what, and when**,
|
|
13
|
+
each memory carrying its source utterance and a confidence score. When a fact is
|
|
14
|
+
corrected, the old entry is marked expired — never silently overwritten — and the
|
|
15
|
+
evidence chain stays in place.
|
|
16
|
+
|
|
17
|
+
> **Scope: the ledger, not the ears.** artl-memory contains no audio, no ASR, no
|
|
18
|
+
> voiceprint. Your upstream pipeline (diarization, voiceprint, manual labels)
|
|
19
|
+
> decides *who* said what and hands this library the name — it keeps the books.
|
|
20
|
+
> That is what makes it dependency-free: usable without ears, plug-and-play with
|
|
21
|
+
> them.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install . # from source (PyPI package not yet published)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Which memory layer should you pick?
|
|
28
|
+
|
|
29
|
+
Everyone arriving here has Mem0 (~60k★) as their reference point, so let's be direct
|
|
30
|
+
about it. These four tools answer **different questions** — this table is for picking
|
|
31
|
+
the right one, not for ranking them.
|
|
32
|
+
|
|
33
|
+
| | **artl-memory** | **Mem0** | **memoripy v4** | **MCP memory (official)** |
|
|
34
|
+
|---|---|---|---|---|
|
|
35
|
+
| Needs an LLM to write memory | **No** — zero model calls | Yes — extraction LLM on every `add()` | No required — deterministic extractor, bring-your-own optional | No — the agent itself decides what to store |
|
|
36
|
+
| What gets stored | **Verbatim utterances** + derived facts | LLM-extracted summaries | Evidence + derived memory, versioned | Entities / relations / observations |
|
|
37
|
+
| Can you trace a memory to its source? | Yes — `source_event` + confidence on every entry | Partial — extraction rewrites wording | Yes — citations and receipts | No |
|
|
38
|
+
| Multi-person isolation | **First-class** — per-person ledger, skills get scoped `MemView`s | Per-`user_id` scoping | Per-`user_id` scoping | No — one shared graph |
|
|
39
|
+
| Deletion | **Hard delete** — `secure_delete` + `VACUUM` + WAL truncation, verified by byte-level scan | API delete; vector-store semantics | `forget` tooling | Delete tools on the JSONL file |
|
|
40
|
+
| Works fully offline | Yes | No (LLM + vector store calls) | Yes | Yes |
|
|
41
|
+
| Semantic (vector) search | **No** — explainable bigram scoring, on purpose | Yes | Optional embeddings | No — substring match |
|
|
42
|
+
| Dependencies | **0** (stdlib `sqlite3`) | LLM client + vector DB + embedder | 0 required (v4) | Node.js runtime |
|
|
43
|
+
|
|
44
|
+
Be fair to each of them:
|
|
45
|
+
|
|
46
|
+
- **Pick Mem0** if you want automatic "talk → extracted profile" with semantic search,
|
|
47
|
+
mature framework integrations (LangChain, CrewAI, AutoGen) and published benchmark
|
|
48
|
+
numbers. That's a lot of real value. The trade-offs are documented by its own
|
|
49
|
+
community: an audit of 10,134 Mem0 entries found 97.8% junk, including hallucinated
|
|
50
|
+
user profiles that get re-extracted and amplified across sessions
|
|
51
|
+
([mem0#4573](https://github.com/mem0ai/mem0/issues/4573)); the HaluMem benchmark
|
|
52
|
+
found extraction-stage hallucination is systemic across LLM-based memory systems
|
|
53
|
+
([arXiv:2511.03506](https://arxiv.org/abs/2511.03506)). If the wording of a memory
|
|
54
|
+
doesn't have to be provably what a human said, that trade may be fine for you.
|
|
55
|
+
- **Pick memoripy** if you like the evidence-first philosophy on a **single-user**
|
|
56
|
+
workload and want an official MCP server out of the box.
|
|
57
|
+
- **Pick the official MCP memory server** if you need a minimal scratchpad for one
|
|
58
|
+
agent on one machine. It calls itself a reference implementation, and it is honest
|
|
59
|
+
about being one.
|
|
60
|
+
- **Pick artl-memory** if the question is *"several people talk to one agent — in a
|
|
61
|
+
meeting room, a family, a mediation session — and the record has to hold up later"*:
|
|
62
|
+
who said which exact sentence, how confident was the transcription, what did the
|
|
63
|
+
agent believe before the correction, and can 王强's utterances really be erased
|
|
64
|
+
byte-for-byte when he asks. If a smart profile matters more than a trustworthy
|
|
65
|
+
ledger, we are the wrong tool — and this README will tell you so again below.
|
|
66
|
+
|
|
67
|
+
## Why multi-person
|
|
68
|
+
|
|
69
|
+
Most agent memory systems are **single-user** models: one user, one profile.
|
|
70
|
+
artl-memory was a multi-person model from day one:
|
|
71
|
+
|
|
72
|
+
- **Per-person isolation**: 王强's utterances never leak into 李四's recall; skills and
|
|
73
|
+
plugins only see their own slot through `MemView`, which holds no store handle
|
|
74
|
+
(same-process introspection can still dig — for hostile code, use process isolation)
|
|
75
|
+
- **Verbatim first**: the original sentence is stored before any judgement; rewriting
|
|
76
|
+
history does not exist on this path
|
|
77
|
+
- **Evidence chains**: every memory carries `source_event` (which utterance it came
|
|
78
|
+
from) and `confidence`; corrections expire the old entry and link it via
|
|
79
|
+
`supersedes` — **expiry is not deletion**
|
|
80
|
+
- **Time-based downgrade**: utterances older than N days are pruned — unreferenced
|
|
81
|
+
rows are deleted, referenced rows keep their snippet so the chain never dangles
|
|
82
|
+
- **Right to be forgotten**: `store.purge_designer("王强")` physically erases all five
|
|
83
|
+
tables' worth of his data (`PRAGMA secure_delete` + `VACUUM` + WAL truncation),
|
|
84
|
+
and returns per-table deletion counts
|
|
85
|
+
|
|
86
|
+
## Quickstart (30 seconds)
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from artl_memory import SqliteMemoryStore, MemoryService, MemView
|
|
90
|
+
|
|
91
|
+
store = SqliteMemoryStore("memory.db")
|
|
92
|
+
mem = MemoryService(store, designer="heima")
|
|
93
|
+
|
|
94
|
+
mem.remember("preference", "王强:预算", "三十万",
|
|
95
|
+
source="utterance:wq-001", confidence=0.9)
|
|
96
|
+
mem.recall("王强的预算") # relevance × confidence × time decay — every factor explainable
|
|
97
|
+
|
|
98
|
+
view = MemView(store, owner="skill:render", designer="heima")
|
|
99
|
+
view.put("风格", "奶油风") # this skill's memory; nobody else's gets in
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Run the multi-person example:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
python examples/two_people.py
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Zero dependencies, two backends
|
|
109
|
+
|
|
110
|
+
- **Zero hard dependencies**: standard library only (`sqlite3` is built in). A memory
|
|
111
|
+
layer should not drag a dependency tree through your door.
|
|
112
|
+
- `InMemoryStore` for tests and trials (not thread-safe); `SqliteMemoryStore` with
|
|
113
|
+
WAL, single connection, auto-reopen after close, corrupt-file quarantine, and a
|
|
114
|
+
versioned schema.
|
|
115
|
+
- The same conformance suite runs against both backends:
|
|
116
|
+
`python tests/test_conformance.py` (pytest-compatible)
|
|
117
|
+
- Adversarial tests cover "undocumented but must not explode":
|
|
118
|
+
`python tests/test_adversarial.py`
|
|
119
|
+
- Regression tests pin every bug ever found by external review:
|
|
120
|
+
`python tests/test_regressions.py`
|
|
121
|
+
|
|
122
|
+
## Boundaries (stated plainly)
|
|
123
|
+
|
|
124
|
+
- Values are stored JSON-serialized: `tuple` comes back as `list`; serialize custom
|
|
125
|
+
objects yourself.
|
|
126
|
+
- `recall` is O(n) full-scan scoring — deliberately index-free for explainability.
|
|
127
|
+
The scan window is `MemoryService(recall_window=...)`, default 10000 entries; when
|
|
128
|
+
the window fills up you get a loud `RuntimeWarning`, never silent truncation.
|
|
129
|
+
For bulk imports use `remember_many(...)` (one fsync per batch, ~100x faster than
|
|
130
|
+
per-item commits) and make sure the window exceeds your total entry count.
|
|
131
|
+
- **recall scores by literal token overlap; it does not paraphrase.** Rephrasing or
|
|
132
|
+
mixing languages will miss: `who pays thirty万 for the living room` does not
|
|
133
|
+
recall the Chinese entry「三十万」. If you need semantic search, layer embeddings
|
|
134
|
+
on top of `recall`.
|
|
135
|
+
- Time decay floors at 0.4: very old high-confidence entries keep participating in
|
|
136
|
+
ranking, just discounted. To retire an old memory from ranking entirely, `forget`
|
|
137
|
+
it (expiry, not deletion).
|
|
138
|
+
- Empty query returns an empty list — when there is no question, it does not pretend
|
|
139
|
+
to understand one.
|
|
140
|
+
- Lock boundaries: `MemoryService.remember` is thread-safe via the service lock;
|
|
141
|
+
`InMemoryStore` itself is not thread-safe — use it through the service layer.
|
|
142
|
+
Multi-process writes to the same SQLite file are guarded by database-level unique
|
|
143
|
+
constraints (only one active entry per slot+key); the loser re-reads and
|
|
144
|
+
converges automatically.
|
|
145
|
+
- Isolation is at the API surface. Nothing in-process is cryptographically hidden —
|
|
146
|
+
if plugins are adversarial, put them behind a process boundary.
|
|
147
|
+
|
|
148
|
+
## Explicitly not doing
|
|
149
|
+
|
|
150
|
+
- **No vector retrieval.** bigram recall is deliberate: you can always see *why* it
|
|
151
|
+
remembered this entry. Need embeddings? Layer them on top of `recall`.
|
|
152
|
+
- **No cloud sync, no multi-machine.** Your data is your file. Feature, not bug.
|
|
153
|
+
- **No LLM calls.** The memory layer doesn't know LLMs exist — swap brains freely,
|
|
154
|
+
the memory stays.
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
Apache-2.0 · ARTL family
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""artl-memory — ARTL 家族的记忆层。
|
|
3
|
+
|
|
4
|
+
逐句原话 · 按人隔离 · 证据链 · 把握度。
|
|
5
|
+
It remembers everyone in the room — separately.
|
|
6
|
+
|
|
7
|
+
from artl_memory import SqliteMemoryStore, InMemoryStore, MemoryService, MemView
|
|
8
|
+
|
|
9
|
+
store = SqliteMemoryStore("memory.db")
|
|
10
|
+
mem = MemoryService(store, designer="heima")
|
|
11
|
+
mem.remember("fact", "预算", "三十万", source="utterance:123", confidence=0.9)
|
|
12
|
+
mem.recall("客厅预算多少")
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from .memview import MemView
|
|
16
|
+
from .memory_store import InMemoryStore
|
|
17
|
+
from .port import MemoryStore
|
|
18
|
+
from .service import MemoryItem, MemoryService
|
|
19
|
+
from .sqlite import SqliteMemoryStore
|
|
20
|
+
from .types import Op
|
|
21
|
+
|
|
22
|
+
__version__ = "0.2.0"
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"InMemoryStore",
|
|
26
|
+
"MemoryItem",
|
|
27
|
+
"MemoryService",
|
|
28
|
+
"MemoryStore",
|
|
29
|
+
"MemView",
|
|
30
|
+
"Op",
|
|
31
|
+
"SqliteMemoryStore",
|
|
32
|
+
"__version__",
|
|
33
|
+
]
|