recallnest 2.2.0 → 2.3.0

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.
Files changed (249) hide show
  1. package/.env +4 -0
  2. package/CLAUDE.md +1 -1
  3. package/README.md +30 -5
  4. package/README_CN.md +30 -5
  5. package/config.json +55 -0
  6. package/connectors/examples/email-adapter.ts +73 -0
  7. package/connectors/examples/logs-adapter.ts +103 -0
  8. package/connectors/examples/rss-adapter.ts +95 -0
  9. package/logs/daily-recall.error.log +0 -0
  10. package/logs/daily-recall.log +60 -0
  11. package/logs/ingest-2026-04-11.log +110 -0
  12. package/logs/ingest-2026-04-12.log +90 -0
  13. package/logs/ingest-2026-04-13.log +87 -0
  14. package/logs/launchagent-stderr.log +0 -0
  15. package/logs/launchagent-stdout.log +0 -0
  16. package/package.json +1 -1
  17. package/src/cli.ts +30 -0
  18. package/src/connector-types.ts +57 -0
  19. package/src/conversation-importer.ts +25 -1
  20. package/src/data-checkup.ts +31 -1
  21. package/src/doctor.ts +29 -0
  22. package/src/ingest.ts +203 -0
  23. package/src/mcp-server.ts +2 -2
  24. package/src/obsidian-connector.ts +282 -0
  25. package/src/session-schema.ts +2 -2
  26. package/src/source-heartbeat.ts +108 -0
  27. package/.claude-plugin/CLAUDE.md +0 -29
  28. package/.claude-plugin/marketplace.json +0 -18
  29. package/.dockerignore +0 -11
  30. package/.github/workflows/ci.yml +0 -28
  31. package/.mcp.json +0 -9
  32. package/CHANGELOG.md +0 -51
  33. package/DEMO.md +0 -94
  34. package/Dockerfile +0 -20
  35. package/EVAL.md +0 -89
  36. package/FAILURES.md +0 -75
  37. package/OPERATIONS.md +0 -59
  38. package/ROADMAP.md +0 -245
  39. package/SKILL.md +0 -250
  40. package/assets/dashboard.png +0 -0
  41. package/assets/knowledge-graph.png +0 -0
  42. package/assets/recallnest-workbench.png +0 -0
  43. package/assets/screenshots/ui-full.png +0 -0
  44. package/assets/screenshots/ui-overview.png +0 -0
  45. package/assets/screenshots/ui-search.png +0 -0
  46. package/assets/ui/app.js +0 -1031
  47. package/assets/ui/index.html +0 -224
  48. package/assets/ui/styles.css +0 -781
  49. package/assets/wechat-qr.jpg +0 -0
  50. package/bun.lock +0 -337
  51. package/daily-reflections/2026-03-05.md +0 -15
  52. package/daily-reflections/2026-03-06.md +0 -15
  53. package/daily-reflections/2026-03-07.md +0 -7
  54. package/daily-reflections/2026-03-08.md +0 -34
  55. package/daily-reflections/2026-03-09.md +0 -35
  56. package/daily-reflections/2026-03-10.md +0 -36
  57. package/daily-reflections/2026-03-11.md +0 -35
  58. package/daily-reflections/2026-03-12.md +0 -36
  59. package/daily-reflections/2026-03-13.md +0 -35
  60. package/daily-reflections/2026-03-14.md +0 -35
  61. package/daily-reflections/2026-03-15.md +0 -35
  62. package/daily-reflections/2026-03-16.md +0 -41
  63. package/daily-reflections/2026-03-17.md +0 -10
  64. package/daily-reflections/2026-03-18.md +0 -10
  65. package/daily-reflections/2026-03-19.md +0 -10
  66. package/daily-reflections/2026-03-20.md +0 -10
  67. package/daily-reflections/2026-03-21.md +0 -10
  68. package/daily-reflections/2026-03-22.md +0 -10
  69. package/daily-reflections/2026-03-23.md +0 -10
  70. package/daily-reflections/2026-03-24.md +0 -10
  71. package/daily-reflections/2026-03-25.md +0 -32
  72. package/daily-reflections/2026-03-26.md +0 -37
  73. package/daily-reflections/2026-03-27.md +0 -35
  74. package/daily-reflections/2026-03-28.md +0 -35
  75. package/daily-reflections/2026-03-29.md +0 -35
  76. package/daily-reflections/2026-03-30.md +0 -36
  77. package/daily-reflections/2026-03-31.md +0 -35
  78. package/daily-reflections/2026-04-01.md +0 -35
  79. package/daily-reflections/2026-04-02.md +0 -35
  80. package/daily-reflections/2026-04-03.md +0 -37
  81. package/daily-reflections/2026-04-04.md +0 -37
  82. package/daily-reflections/2026-04-05.md +0 -35
  83. package/daily-reflections/2026-04-06.md +0 -36
  84. package/daily-reflections/2026-04-07.md +0 -35
  85. package/daily-reflections/2026-04-08.md +0 -35
  86. package/daily-reflections/2026-04-12.md +0 -35
  87. package/data/alias-map.example.json +0 -22
  88. package/docs/api-reference.md +0 -1291
  89. package/docs/architecture.md +0 -168
  90. package/docs/memory-boundary-contract.md +0 -226
  91. package/docs/memory-categories.md +0 -119
  92. package/docs/pipeline-audit-ultramemory.md +0 -177
  93. package/docs/plans/2026-03-08-query-expansion.md +0 -270
  94. package/docs/plans/2026-03-16-continuity-layer.md +0 -196
  95. package/docs/plans/2026-04-01-recall-boost.md +0 -100
  96. package/docs/plans/mcp-tiering-plan.md +0 -126
  97. package/docs/research/recall-quality-audit-2026-03-22.md +0 -153
  98. package/docs/self-evolution.md +0 -198
  99. package/docs/superpowers/plans/2026-03-19-ingest-pipeline-upgrade.md +0 -782
  100. package/docs/superpowers/plans/2026-04-11-constructive-retrieval-emotion.md +0 -1195
  101. package/docs/superpowers/specs/2026-03-19-ingest-pipeline-upgrade-design.md +0 -77
  102. package/docs/superpowers/specs/2026-03-23-pull-claude-desktop-design.md +0 -95
  103. package/docs/superpowers/specs/2026-04-11-constructive-retrieval-emotion-design.md +0 -398
  104. package/eval/continuity/results-2026-03-16.md +0 -117
  105. package/eval/continuity/results-2026-03-19.md +0 -453
  106. package/eval/continuity/runbook.md +0 -110
  107. package/eval/continuity/seed-cases.md +0 -54
  108. package/eval/reports/2026-03-06-abstract-query-baseline.md +0 -96
  109. package/eval/reports/2026-03-06-aws-ssh-baseline.md +0 -82
  110. package/eval/reports/2026-03-06-baseline.md +0 -82
  111. package/eval/reports/query-expansion.md +0 -138
  112. package/glama.json +0 -6
  113. package/lm +0 -19
  114. package/plan-philosophy-upgrades.md +0 -363
  115. package/plan-product-upgrades.md +0 -155
  116. package/plan-v1.2-distributable.md +0 -105
  117. package/plan.md +0 -140
  118. package/research-memory-evolution.md +0 -440
  119. package/research-rl-agent-memory.md +0 -330
  120. package/scripts/archive-distilled-junk.ts +0 -116
  121. package/scripts/backfill-anchors.ts +0 -130
  122. package/scripts/backfill-l0l1l2.ts +0 -98
  123. package/scripts/blind-scan.ts +0 -588
  124. package/scripts/cleanup-step1-exact-dups.ts +0 -117
  125. package/scripts/cleanup-step2-template-dups.ts +0 -113
  126. package/scripts/cleanup-step3-stale-content.ts +0 -149
  127. package/scripts/cleanup-step4-orphan-scopes.ts +0 -131
  128. package/scripts/delete-distilled-junk.ts +0 -88
  129. package/scripts/diagnose-vector-search.ts +0 -132
  130. package/scripts/distill-facts.ts +0 -305
  131. package/scripts/health-check.ts +0 -343
  132. package/scripts/incremental-ingest.sh +0 -71
  133. package/scripts/migrate-language.ts +0 -75
  134. package/scripts/mlp-health-check.ts +0 -382
  135. package/scripts/pull-claude-desktop.ts +0 -515
  136. package/scripts/re-ingest-cc.sh +0 -66
  137. package/scripts/rebalance-memory-health.ts +0 -181
  138. package/scripts/run-desktop-ingest.sh +0 -11
  139. package/scripts/start-server.sh +0 -12
  140. package/scripts/verify-emotion-decay.ts +0 -148
  141. package/scripts/viz-dashboard.html +0 -423
  142. package/scripts/viz-export.ts +0 -703
  143. package/src/__tests__/access-tracker-novelty.test.ts +0 -228
  144. package/src/__tests__/activity-counter.test.ts +0 -96
  145. package/src/__tests__/admission-control.test.ts +0 -206
  146. package/src/__tests__/anchor-generator.test.ts +0 -67
  147. package/src/__tests__/auto-consolidation.test.ts +0 -168
  148. package/src/__tests__/auto-recall.test.ts +0 -131
  149. package/src/__tests__/babel-integration.test.ts +0 -139
  150. package/src/__tests__/batch-dedup.test.ts +0 -65
  151. package/src/__tests__/capture-engine.test.ts +0 -1144
  152. package/src/__tests__/capture-heuristic.test.ts +0 -171
  153. package/src/__tests__/cascade-forget.test.ts +0 -210
  154. package/src/__tests__/category-min-scores.test.ts +0 -33
  155. package/src/__tests__/cc8-cc1-essential-context.test.ts +0 -298
  156. package/src/__tests__/circuit-breaker.test.ts +0 -99
  157. package/src/__tests__/cluster-consolidation.test.ts +0 -712
  158. package/src/__tests__/confidence-metadata.test.ts +0 -125
  159. package/src/__tests__/confidence-tracker.test.ts +0 -249
  160. package/src/__tests__/conflict-advisor.test.ts +0 -206
  161. package/src/__tests__/conflict-escalation.test.ts +0 -149
  162. package/src/__tests__/conflict-lifecycle.test.ts +0 -83
  163. package/src/__tests__/conflict-output.test.ts +0 -85
  164. package/src/__tests__/conflict-store.test.ts +0 -374
  165. package/src/__tests__/consolidation-engine.test.ts +0 -181
  166. package/src/__tests__/constructive-retrieval.test.ts +0 -509
  167. package/src/__tests__/context-collapse-renderer.test.ts +0 -214
  168. package/src/__tests__/context-composer-pins.test.ts +0 -64
  169. package/src/__tests__/context-composer-task-selection.test.ts +0 -24
  170. package/src/__tests__/context-reconstructor.test.ts +0 -65
  171. package/src/__tests__/context-renderer.test.ts +0 -91
  172. package/src/__tests__/continuity-eval.test.ts +0 -275
  173. package/src/__tests__/continuity-schema.test.ts +0 -97
  174. package/src/__tests__/conversation-importer.test.ts +0 -692
  175. package/src/__tests__/core-recall-eval.test.ts +0 -235
  176. package/src/__tests__/core-summary.test.ts +0 -109
  177. package/src/__tests__/data-checkup.test.ts +0 -225
  178. package/src/__tests__/decay-exemption.test.ts +0 -84
  179. package/src/__tests__/dedup-actions.test.ts +0 -58
  180. package/src/__tests__/dedup-guard.test.ts +0 -39
  181. package/src/__tests__/deterministic-id.test.ts +0 -39
  182. package/src/__tests__/distill-lock.test.ts +0 -176
  183. package/src/__tests__/doctor.test.ts +0 -303
  184. package/src/__tests__/dream-pipeline.test.ts +0 -232
  185. package/src/__tests__/drill-down.test.ts +0 -108
  186. package/src/__tests__/embedder.test.ts +0 -122
  187. package/src/__tests__/emotion-decay.test.ts +0 -46
  188. package/src/__tests__/emotion-detector.test.ts +0 -56
  189. package/src/__tests__/emotion-phase1-integration.test.ts +0 -153
  190. package/src/__tests__/emotion-retrieval.test.ts +0 -56
  191. package/src/__tests__/entity-resolver.test.ts +0 -58
  192. package/src/__tests__/ethics-layer.test.ts +0 -476
  193. package/src/__tests__/event-segmenter.test.ts +0 -153
  194. package/src/__tests__/feature-flags-integration.test.ts +0 -54
  195. package/src/__tests__/frequency-tracker.test.ts +0 -113
  196. package/src/__tests__/graph-export.test.ts +0 -489
  197. package/src/__tests__/hotness-blend.test.ts +0 -76
  198. package/src/__tests__/ingest.test.ts +0 -360
  199. package/src/__tests__/interference-detector.test.ts +0 -203
  200. package/src/__tests__/kg-extractor.test.ts +0 -184
  201. package/src/__tests__/kg-store.test.ts +0 -198
  202. package/src/__tests__/llm-consolidation.test.ts +0 -226
  203. package/src/__tests__/mcp-efficiency.test.ts +0 -288
  204. package/src/__tests__/memory-boundaries.test.ts +0 -237
  205. package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +0 -243
  206. package/src/__tests__/memory-evolution.test.ts +0 -271
  207. package/src/__tests__/memory-health-rebalance.test.ts +0 -144
  208. package/src/__tests__/memory-lint.test.ts +0 -271
  209. package/src/__tests__/memory-output.test.ts +0 -215
  210. package/src/__tests__/multi-vector.test.ts +0 -242
  211. package/src/__tests__/narrative-architecture.test.ts +0 -456
  212. package/src/__tests__/pending-review.test.ts +0 -77
  213. package/src/__tests__/post-retrieval-filter.test.ts +0 -178
  214. package/src/__tests__/ppr-traversal.test.ts +0 -256
  215. package/src/__tests__/prediction-engine.test.ts +0 -349
  216. package/src/__tests__/predictive-prospective-memory.test.ts +0 -416
  217. package/src/__tests__/preference-guard-smoke.test.ts +0 -211
  218. package/src/__tests__/preference-matcher.test.ts +0 -230
  219. package/src/__tests__/preference-slots.test.ts +0 -205
  220. package/src/__tests__/prospective-memory.test.ts +0 -283
  221. package/src/__tests__/query-entity-detector.test.ts +0 -171
  222. package/src/__tests__/query-expander-alias.test.ts +0 -89
  223. package/src/__tests__/query-expander.test.ts +0 -34
  224. package/src/__tests__/recall-governor.test.ts +0 -227
  225. package/src/__tests__/recall-mode.test.ts +0 -64
  226. package/src/__tests__/result-synthesizer.test.ts +0 -198
  227. package/src/__tests__/resume-context.test.ts +0 -4898
  228. package/src/__tests__/retrieval-trace.test.ts +0 -213
  229. package/src/__tests__/retriever-boundary-weight.test.ts +0 -136
  230. package/src/__tests__/retroactive-boost.test.ts +0 -223
  231. package/src/__tests__/salience-scoring.test.ts +0 -106
  232. package/src/__tests__/scope-inventory.test.ts +0 -200
  233. package/src/__tests__/scope-policy.test.ts +0 -69
  234. package/src/__tests__/session-checkpoint.test.ts +0 -259
  235. package/src/__tests__/session-distiller.test.ts +0 -611
  236. package/src/__tests__/session-gc.test.ts +0 -215
  237. package/src/__tests__/skill-engine.test.ts +0 -546
  238. package/src/__tests__/skill-promotion.test.ts +0 -349
  239. package/src/__tests__/store-scope-audit.test.ts +0 -81
  240. package/src/__tests__/supersede-chain.test.ts +0 -154
  241. package/src/__tests__/temporal-parser.test.ts +0 -241
  242. package/src/__tests__/temporal-validity.test.ts +0 -160
  243. package/src/__tests__/term-registry.test.ts +0 -121
  244. package/src/__tests__/tool-output-compressor.test.ts +0 -133
  245. package/src/__tests__/topic-tag.test.ts +0 -113
  246. package/src/__tests__/trusted-memory.test.ts +0 -828
  247. package/src/__tests__/version-manager.test.ts +0 -213
  248. package/src/__tests__/workflow-observation.test.ts +0 -400
  249. package/src/__tests__/write-verifier.test.ts +0 -122
package/plan.md DELETED
@@ -1,140 +0,0 @@
1
- # RecallNest 架构迭代 Plan
2
-
3
- **目标**:提升 RecallNest 架构能力(不刷分,关注真实场景)
4
- **推送**:全部推河马仓(origin),实用的推公开仓(public)
5
-
6
- ---
7
-
8
- ## 已完成
9
-
10
- ### Step 1: 隐式偏好检测 (preference-slots.ts)
11
- - `ImplicitUsagePreferenceSlot` + 8 种中英文模式 | `6db35d08`
12
-
13
- ### Step 2: Source Diversity (retriever.ts)
14
- - `sourceDiversity` config, round-robin 跨 scope | `6db35d08`
15
-
16
- ### Step 3: Adaptive Candidate Pool (retriever.ts)
17
- - `adaptivePoolMultiplier` config, 聚合 query 自动扩池 | `6db35d08`
18
-
19
- ### Step 4: 隐式偏好双写 (capture-engine.ts)
20
- - 非 preference 记忆自动派生 preference 副本 | `778cd906`
21
-
22
- ### Step 5: Multi-hop 两轮检索 (retriever.ts)
23
- - 实体驱动的两轮检索 + 并行 follow-up | `86a4f0a3`
24
-
25
- ---
26
-
27
- ## 待做:架构改进(借鉴 memL + 自身短板)
28
-
29
- ### Step 7: Recall Governor — auto-recall 治理层 [高优先级]
30
-
31
- **问题**:当前 auto-recall 路径只有 `shouldSkipRetrieval()` (gating) 和 `noise-filter` (事后过滤)。缺少中间治理层:
32
- - 无字符预算控制,注入过多记忆浪费 token
33
- - 无会话去重,同一轮对话里同一条记忆可能被多次注入
34
- - 无状态过滤二次确认(retriever 有 evolution filter 但 auto-recall 路径没有兜底)
35
-
36
- **方案**:新增 `recall-governor.ts`,在 auto-recall.ts 的 retrieve 后、返回前插入 6 层治理:
37
- 1. Gating — 已有 `shouldSkipRetrieval()`,保持
38
- 2. Query 截断 — 超长 query 截断到 1000 chars(省 embedding 成本)
39
- 3. 检索 — 已有 HybridRetriever,保持
40
- 4. 状态过滤 — 排除 archived/superseded, tier=peripheral
41
- 5. 预算控制 — 总字符预算 + 条目数上限(可配置)
42
- 6. 会话去重 — 维护本轮已注入 ID set,不重复注入
43
-
44
- **文件**:`src/recall-governor.ts`(新增), `src/auto-recall.ts`(接入)
45
- **工作量**:约 120 行 + 测试
46
-
47
- ---
48
-
49
- ### Step 8: Admission Control — 写入准入控制 [高优先级]
50
-
51
- **问题**:当前记忆写入只有 noise-filter(检索时才过滤)和 write-verifier(写后验证),没有写前门控。低质量记忆进库再过滤不如一开始就拦。
52
-
53
- **方案**:新增 `admission-control.ts`,在 capture-engine.ts 的 persistMemory 入口加准入检查:
54
- - 最短文本长度(< 10 chars 拒绝)
55
- - noise-filter 前置(写入前就过滤)
56
- - importance 下限(< 0.2 拒绝或标记 pending_review)
57
- - 重复检测(向量相似度 > 0.95 近似重复直接跳过)
58
- - 每 scope 写入频率限制(防 flood)
59
-
60
- **文件**:`src/admission-control.ts`(新增), `src/capture-engine.ts`(接入)
61
- **工作量**:约 80 行 + 测试
62
-
63
- ---
64
-
65
- ### Step 9: LLM 降级策略 — dream-pipeline + capture 容错 [中优先级]
66
-
67
- **问题**:dream-pipeline 和 LLM importance assessment 依赖外部 LLM。LLM 挂了:
68
- - dream-pipeline 直接失败
69
- - importance 静默跳过(fallback 默认 0.7,还行)
70
- - capture-heuristic 是纯 regex 备选但不在同一链路
71
-
72
- **方案**:借鉴 memL 三层降级:
73
- - Level 1: 正常 LLM 调用
74
- - Level 2: 降级 prompt(更短,更高成功率)
75
- - Level 3: 确定性 fallback(零 LLM)
76
- - dream consolidation: 跳过本轮下次再试
77
- - importance: heuristic 规则(文本长度 + category 权重)
78
- - capture: capture-heuristic.ts 的 regex 提取
79
-
80
- **文件**:`src/llm-client.ts`(加 degradation wrapper)
81
- **工作量**:约 60 行 + 测试
82
-
83
- ---
84
-
85
- ### Step 10: Metadata 显式字段 — 去 JSON bag [中优先级,大工作量]
86
-
87
- **问题**:85 处 `JSON.parse(metadata)`。metadata 是 JSON string,塞了 evolution/boundary/anchor/preferenceSlot/pii/tags 等所有东西。每次读都要 parse,LanceDB filter 不能直接用内部字段。
88
-
89
- **方案**:高频字段提升为 MemoryEntry 顶级字段:
90
- ```
91
- 新增:anchor, evolution_status, confidence, access_count,
92
- last_accessed_at, supersedes, superseded_by, tier
93
- 保留 metadata:低频扩展字段仍用 JSON string
94
- ```
95
-
96
- **风险**:LanceDB schema 变更需重建表,需 migration 脚本。
97
- **工作量**:约 300 行 + migration + 大量测试更新
98
- **建议**:单独一个完整 session,不混其他改动
99
-
100
- ---
101
-
102
- ### Step 11: 两段式捕获 — message buffer + batch persist [低优先级]
103
-
104
- **问题**:capture-engine 单条同步写入。高频对话产生碎片记忆。
105
-
106
- **方案**:借鉴 memL 两段式:
107
- - Stage 1: message_received -> 缓存到内存 buffer
108
- - Stage 2: agent_end(或 buffer 满/超时)-> 批量合并后写入
109
-
110
- **价值**:减少碎片,LLM 看到更完整上下文提高提取质量
111
- **工作量**:约 150 行 + event bus 集成
112
- **依赖**:host adapter 需提供 message_received / agent_end 事件
113
-
114
- ---
115
-
116
- ## 停车场(不做)
117
-
118
- | 方案 | 原因 |
119
- |------|------|
120
- | Extraction prompt 加偏好示例 | 针对题型优化 = 刷分 |
121
- | Reader 升级 | 不是 RecallNest 自身能力 |
122
- | L1 Context Engine | memL 的差异化,RecallNest 定位是 L2 记忆引擎 |
123
- | Embedding 模型更换 | 当前够用 |
124
-
125
- ---
126
-
127
- ## 优先级排序
128
-
129
- ```
130
- 高优先级(下一个窗口做)
131
- Step 7: Recall Governor ~120 行 <- 生产环境最需要
132
- Step 8: Admission Control ~80 行 <- 防垃圾记忆入库
133
-
134
- 中优先级(之后做)
135
- Step 9: LLM 降级策略 ~60 行 <- 生产容错
136
- Step 10: Metadata 显式字段 ~300 行 <- 大重构,单独 session
137
-
138
- 低优先级(有空再做)
139
- Step 11: 两段式捕获 ~150 行 <- 需 host adapter 配合
140
- ```
@@ -1,440 +0,0 @@
1
- # Research: Memory Evolution Mechanisms for RecallNest
2
-
3
- > Source: "A Survey on Memory-Augmented LLM Agents" (107 pages), Sections 5.2, 7.7
4
- > Date: 2026-04-01
5
- > Purpose: Feed directly into RecallNest memory evolution implementation (P0 priority)
6
-
7
- ---
8
-
9
- ## Part 1: Memory Consolidation (Section 5.2.1)
10
-
11
- ### What It Is
12
-
13
- Consolidation transforms fragmented short-term traces into structured, generalizable long-term knowledge. Its core mechanism: identify semantic relationships between new and existing memories, then integrate them into higher-level abstractions. Two purposes: (1) reorganize fragments into coherent structures, preventing detail loss; (2) abstract and compress experiential data into reusable patterns for cross-task generalization.
14
-
15
- ### Three Granularities
16
-
17
- #### 1. Local Consolidation (fine-grained, pair-level)
18
-
19
- **Trigger**: New memory arrives that is highly similar to an existing entry.
20
-
21
- **Algorithm**:
22
- - RMM: Each new topic memory retrieves its top-K most similar candidates. An LLM decides whether merging is appropriate. This reduces the risk of incorrect generalization.
23
- - VLN: Triggers a pooling mechanism when capacity is saturated. Identifies the most similar or redundant memory pairs and compresses them into higher-level abstractions.
24
-
25
- **Trade-off**: Refines detailed knowledge while preserving global structure. Improves precision and storage efficiency. BUT cannot capture cluster-level relations or higher-order dependencies that emerge across semantically related memories.
26
-
27
- **RecallNest applicability**: HIGH. This is the simplest starting point. On each `store_memory`, retrieve top-K similar entries, ask LLM "should these be merged?", merge if yes.
28
-
29
- #### 2. Cluster-level Fusion (cross-instance regularities)
30
-
31
- **Trigger**: Memory store grows large enough that cross-instance patterns emerge.
32
-
33
- **Algorithm**:
34
- - PREMem: Aligns new memory clusters with similar existing ones. Applies fusion modes such as "generalization" and "refinement" to form higher-order reasoning units. Clusters extracted factual, experiential, and subjective memories to identify cross-session reasoning patterns.
35
- - EverMemOS: Computes similarity between a newly generated MemCell and the centroids of all MemScenes (clusters). Merges into the MemScene that is sufficiently similar (above threshold).
36
- - TiM (Think-in-Memory): Periodically invokes an LLM to examine memories sharing the same hashing bucket. Merges semantically redundant entries. Uses hash-based grouping for efficiency.
37
- - CAM: Merges all nodes within a target cluster into a representative summary, yielding higher-level cross-sample representations. Handles overlapping clusters via node replication.
38
-
39
- **Trade-off**: Reorganizes memory at broader scale, important step toward structured knowledge. BUT requires a clustering mechanism and periodic maintenance cycles.
40
-
41
- **RecallNest applicability**: MEDIUM. Implement as a background job. Group memories by topic/entity, periodically run LLM-driven cluster summarization.
42
-
43
- #### 3. Global Integration (holistic, system-level)
44
-
45
- **Trigger**: Accumulated experience reaches a threshold where system-level insights can be distilled.
46
-
47
- **Algorithm**:
48
- - MOOM: Constructs stable role profiles by integrating temporary role snapshots with historical traces. Uses rule-based processing + embedding methods + LLM-driven abstraction.
49
- - Matrix: Iterative optimization combining execution trajectories and reflective insights with global memory. Distills task-agnostic principles reusable across scenarios.
50
- - AgentFold / Context Folding: After each step in multi-step interactions, automatically summarize and condense the global context.
51
-
52
- **Trade-off**: Provides reliable contextual foundation, improves generalization and reasoning. BUT highest computational cost, risk of over-abstraction.
53
-
54
- **RecallNest applicability**: LOW for MVP. This is a future feature for generating "insight memories" from accumulated data.
55
-
56
- ### Critical Risk: Information Smoothing
57
-
58
- The survey explicitly warns: consolidation risks "information smoothing" where **outlier events or unique exceptions are lost during the abstraction process**, potentially reducing the agent's sensitivity to anomalies and specific events.
59
-
60
- **Mitigation for RecallNest**: NEVER delete originals during consolidation. Create a new consolidated entry that links back to source entries. Mark originals as `consolidated_into: <id>` but retain them in an archive tier.
61
-
62
- ---
63
-
64
- ## Part 2: Memory Updating (Section 5.2.2)
65
-
66
- ### What It Is
67
-
68
- Memory updating revises or replaces existing memory when conflicts arise or new information is acquired. Goal: maintain factual consistency and continual adaptation without full retraining. Unlike consolidation (which abstracts), updating emphasizes localized correction and synchronization.
69
-
70
- ### Evolution of External Memory Update Mechanisms
71
-
72
- The survey traces a clear progression:
73
-
74
- #### Stage 1: Destructive Replacement (early systems)
75
- - **Systems**: MemGPT, D-SMART, Mem0g
76
- - **Algorithm**: LLM detects conflicts between new information and existing entries, then invokes replace or delete operations.
77
- - **Problem**: Erases valuable historical context and breaks temporal continuity.
78
-
79
- #### Stage 2: Temporal Annotation / Soft Deletion
80
- - **System**: Zep
81
- - **Algorithm**: Marks conflicting facts with `invalid` timestamps rather than deleting them. Preserves both semantic consistency and temporal integrity.
82
- - **Key insight**: Shift from hard replacement to soft, time-aware updating.
83
-
84
- **RecallNest applicability**: CRITICAL. This is the approach to adopt. Add `valid_from` / `valid_until` timestamps. Never hard-delete; mark as superseded.
85
-
86
- #### Stage 3: Dual-Phase Updating
87
- - **Systems**: MOOM, LightMem
88
- - **Algorithm**: Two phases:
89
- 1. **Soft online update**: Real-time responsiveness. Quick, lightweight conflict marking.
90
- 2. **Offline reflective consolidation**: Similar entries merged, conflicts resolved via LLM reasoning.
91
- - **Rationale**: Real-time updates impose significant computational and I/O burdens under high-frequency interaction. Eventual consistency paradigm balances latency and coherence.
92
-
93
- **RecallNest applicability**: HIGH. Online phase = mark conflicts at write time. Offline phase = periodic `distill_memory` enhancement.
94
-
95
- #### Stage 4: Learned Update Policies (RL-driven)
96
- - **System**: Mem-alpha
97
- - **Algorithm**: Formulates memory updating as a policy-learning problem. LLM learns when, how, and whether to update, achieving dynamic trade-offs between stability and freshness.
98
-
99
- **RecallNest applicability**: LOW for MVP. Requires RL training. Future direction only.
100
-
101
- ### Conflict Detection: How Systems Detect Contradictions
102
-
103
- Based on surveyed systems, conflict detection follows these patterns:
104
- 1. **Semantic similarity + LLM judgment**: Retrieve entries similar to the new memory, ask LLM "does new info contradict existing?" (MemGPT, D-SMART, Mem0g approach)
105
- 2. **Entity-based matching**: Extract entities from new memory, find existing memories about same entities, compare predicates (Zep's temporal KG approach)
106
- 3. **Temporal comparison**: Same entity + different attribute value + different timestamp = likely update, not contradiction
107
-
108
- ### The Stability-Plasticity Dilemma
109
-
110
- The survey calls this the key challenge: "determining when to overwrite existing knowledge versus when to treat new information as noise. Incorrect updates can overwrite critical information, leading to knowledge degradation and faulty reasoning."
111
-
112
- **RecallNest design principle**: Default to PRESERVING both old and new, linked with a `supersedes` relationship. Let the retrieval layer handle recency-preference. Only truly merge after explicit confirmation or high-confidence LLM judgment.
113
-
114
- ---
115
-
116
- ## Part 3: Memory Forgetting (Section 5.2.3)
117
-
118
- ### What It Is
119
-
120
- Deliberate removal of outdated, redundant, or low-value information to free capacity and maintain focus. Unlike updating (which resolves conflicts), forgetting prioritizes eliminating outdated information for efficiency and relevance.
121
-
122
- ### The Core Tension
123
-
124
- "Unbounded memory accumulation leads to increased noise, retrieval delays, and interference from outdated knowledge. Controlled forgetting helps mitigate overload. Yet, overly aggressive pruning risks erasing rare but essential knowledge."
125
-
126
- ### Three Forgetting Mechanisms
127
-
128
- #### 1. Time-based Forgetting
129
-
130
- **Trigger**: Memory age exceeds threshold or context overflows.
131
-
132
- **Implementations**:
133
- - **MemGPT**: Evicts earliest messages upon context overflow (FIFO).
134
- - **Xu et al. / Wang et al.**: Stochastic token replacement with ratio K/N, simulating exponential forgetting in human cognition. Discard oldest entries once pool exceeds capacity.
135
- - **MAICC**: Implements **soft forgetting** by gradually decaying memory weights over time. Mirrors natural forgetting. Continuous adaptation without historical overload.
136
-
137
- **Trade-off**: Simple and predictable. BUT old memories may still be critically relevant. Pure time-based decay is too blunt.
138
-
139
- **RecallNest applicability**: MEDIUM. Use as one signal in a composite score, not as sole criterion. Implement as a decay multiplier on retrieval relevance, not as a deletion trigger.
140
-
141
- #### 2. Frequency-based Forgetting (LRU/LFU)
142
-
143
- **Trigger**: Memory access frequency falls below threshold.
144
-
145
- **Implementations**:
146
- - **XMem**: LFU (Least Frequently Used) policy to remove low-frequency entries.
147
- - **KARMA**: Uses **counting Bloom filters** to track access frequency. Space-efficient probabilistic tracking.
148
- - **MemOS**: LRU (Least Recently Used) strategy. Removes long-unused items while **archiving highly active ones**. Maintains storage equilibrium.
149
-
150
- **Key insight from survey**: Time-based decay captures natural temporal aging, while frequency-based forgetting reflects usage dynamics. These two axes are orthogonal and should be combined.
151
-
152
- **RecallNest applicability**: HIGH. Track `access_count` and `last_accessed_at` per memory. Use these in retrieval scoring. MemOS's "archive highly active" pattern is excellent -- frequently accessed memories get promoted, not just retained.
153
-
154
- #### 3. Importance-driven Forgetting (semantic intelligence)
155
-
156
- **Trigger**: LLM judges a memory as low-value relative to current context.
157
-
158
- **Implementations**:
159
- - **Early approaches (Zhong et al., Chen et al.)**: Composite scores combining temporal decay + access frequency. Numeric-based selective forgetting.
160
- - **VLN**: Pools semantically redundant memories via similarity clustering (merge, not delete).
161
- - **Livia**: Incorporates **emotional salience** and contextual relevance. Models emotion-driven selective forgetting.
162
- - **TiM**: Leverages LLM to assess memory importance and explicitly prune less important memories. The LLM reads the memory and rates its importance.
163
- - **MemTool**: Also uses LLM to judge importance. Explicitly prunes or forgets less important memories.
164
-
165
- **Trade-off**: Most sophisticated approach. Agents can perform "conscious forgetting." BUT LLM calls are expensive and introduce latency. Risk of the LLM misjudging what's important.
166
-
167
- **RecallNest applicability**: HIGH for the importance scoring. CAUTIOUS on actual deletion. Use LLM importance scores to deprioritize in retrieval, not to delete.
168
-
169
- ### The Archive vs Delete Debate
170
-
171
- The survey states clearly: **"When storage cost is not a critical constraint, many memory systems avoid directly deleting certain memories."** Heuristic forgetting mechanisms like LRU "may eliminate long-tail knowledge, which is seldom accessed but essential for correct decision-making."
172
-
173
- **RecallNest design principle**: ARCHIVE-FIRST, DELETE-NEVER as default policy. "Forgotten" memories move to a cold tier, excluded from default retrieval but recoverable. Actual deletion only via explicit user request (privacy/GDPR compliance).
174
-
175
- ---
176
-
177
- ## Part 4: Trustworthy Memory (Section 7.7)
178
-
179
- ### Privacy Risks
180
-
181
- **Wang et al. (2025b) finding**: Memory modules can **leak private data through indirect prompt-based attacks**. Risk of memorization and over-retention. The paper references MEXTRA (Wang et al., 2025b), which demonstrated extracting raw dialogue data from memory systems.
182
-
183
- **Implications for RecallNest**:
184
- - An MCP server that persists user memories across sessions is a privacy attack surface.
185
- - Memory entries may contain PII, credentials, or sensitive context that the user didn't intend to persist.
186
-
187
- ### Three Pillars of Trustworthy Memory
188
-
189
- #### 1. Privacy Preservation
190
- - Granular **permissioned memory** (who can read what)
191
- - **User-governed retention policies** (user controls what persists)
192
- - Encrypted or on-device storage
193
- - Federated access where needed
194
- - Techniques: differential privacy, **memory redaction**, adaptive forgetting (decay-based or user-erasure interfaces)
195
-
196
- #### 2. Explainability
197
- - Traceable access paths (which memory was retrieved for which response)
198
- - Self-rationalizing retrievals
199
- - Counterfactual reasoning: "what would have changed without this memory?"
200
- - Visualizations of memory attention, causal graphs of memory influence
201
- - User-facing debugging tools
202
-
203
- #### 3. Hallucination Robustness
204
- - Conflict detection between memories
205
- - Multi-document reasoning
206
- - Uncertainty-aware generation
207
- - Abstention under low-confidence retrieval
208
- - Multi-agent cross-checking
209
-
210
- ### Auditable Updates and Verifiable Forgetting
211
-
212
- Wu et al. (2025g) argues that agent memory systems must support:
213
- - **Explicit mechanisms for access control**
214
- - **Verifiable forgetting**: Proof that data was actually removed, not just hidden
215
- - **Auditable updates**: Log of what changed, when, and why
216
-
217
- ### Future Vision
218
-
219
- The survey envisions "memory systems governed by OS-like abstractions: segmented, **version-controlled**, **auditable**, and jointly managed by agent and user."
220
-
221
- **RecallNest applicability**: Version control is achievable now. Every update creates a new version, old version retained with audit trail. Access control can be per-scope. Verifiable forgetting (actual data erasure on request) is a hard requirement for production use.
222
-
223
- ---
224
-
225
- ## Part 5: Practical Design for RecallNest
226
-
227
- ### 5.1 Minimum Viable Memory Evolution Fields
228
-
229
- Every memory record in RecallNest should gain these fields:
230
-
231
- ```python
232
- # --- Lifecycle metadata ---
233
- created_at: datetime # Already exists
234
- updated_at: datetime # Last modification time
235
- valid_from: datetime # When this fact became true (temporal annotation, Zep-style)
236
- valid_until: datetime | None # When this fact was superseded (None = currently valid)
237
-
238
- # --- Access tracking (frequency-based forgetting) ---
239
- access_count: int # How many times retrieved (for LFU scoring)
240
- last_accessed_at: datetime # When last retrieved (for LRU scoring)
241
-
242
- # --- Evolution tracking ---
243
- importance: float # 0.0-1.0, LLM-assessed or composite score
244
- status: str # "active" | "superseded" | "archived" | "consolidated"
245
- superseded_by: str | None # ID of the memory that replaced this one
246
- consolidated_into: str | None # ID of the consolidated memory this fed into
247
- source_memories: list[str] # IDs of memories that were consolidated into this one
248
- version: int # Incremented on each update (audit trail)
249
-
250
- # --- Decay signal ---
251
- decay_score: float # Composite of time_decay * frequency_score * importance
252
- # Recomputed periodically or at retrieval time
253
- ```
254
-
255
- ### 5.2 Consolidation Algorithm (No Model Training Required)
256
-
257
- **Recommended: Local Consolidation (RMM-style) as MVP**
258
-
259
- ```
260
- TRIGGER: On each store_memory() call, OR periodic background sweep
261
-
262
- ALGORITHM:
263
- 1. For the new memory M_new:
264
- a. Retrieve top-K (K=5) most similar existing memories by embedding similarity
265
- b. Filter to only those with similarity > MERGE_THRESHOLD (e.g., 0.85)
266
- c. For each candidate M_old:
267
- - Ask LLM: "Memory A says: '{M_old.content}'. Memory B says: '{M_new.content}'.
268
- Are these about the same topic? Should they be merged into one?
269
- Or does B update/supersede A? Or are they complementary?"
270
- - LLM returns: MERGE | SUPERSEDE | COMPLEMENT | UNRELATED
271
- d. If MERGE: Create M_consolidated with merged content.
272
- Set M_old.status = "consolidated", M_old.consolidated_into = M_consolidated.id
273
- Set M_new.status = "consolidated", M_new.consolidated_into = M_consolidated.id
274
- Set M_consolidated.source_memories = [M_old.id, M_new.id]
275
- e. If SUPERSEDE: Set M_old.status = "superseded", M_old.superseded_by = M_new.id
276
- Set M_old.valid_until = now()
277
- f. If COMPLEMENT: Store M_new as new entry, add cross-reference link
278
- g. If UNRELATED: Store M_new as new entry, no linking
279
- ```
280
-
281
- **Cluster-level consolidation (phase 2, background job)**:
282
-
283
- ```
284
- TRIGGER: Periodic (daily or on-demand via distill_memory tool)
285
-
286
- ALGORITHM:
287
- 1. Group active memories by scope + topic embedding clusters (k-means or HDBSCAN)
288
- 2. For each cluster with > N members (N=5):
289
- a. Present all cluster members to LLM
290
- b. Ask: "Synthesize these related memories into a single high-level insight.
291
- Preserve any contradictions or temporal evolution."
292
- c. Create insight memory with source_memories linking to all originals
293
- d. Mark originals as consolidated_into the insight (but keep status="active"
294
- so they're still individually retrievable)
295
- ```
296
-
297
- ### 5.3 Forgetting Policy: Archive-First, Delete-Never
298
-
299
- ```
300
- COMPOSITE DECAY SCORE (recomputed at retrieval time or periodically):
301
-
302
- decay_score = (
303
- time_weight * time_decay(created_at, half_life=90_days) +
304
- frequency_weight * frequency_score(access_count, last_accessed_at) +
305
- importance_weight * importance
306
- )
307
-
308
- Where:
309
- - time_decay = 0.5 ^ (days_since_creation / half_life)
310
- - frequency_score = log(1 + access_count) * recency_boost(last_accessed_at)
311
- - importance = LLM-assessed on creation, or default 0.5
312
-
313
- Weights: time=0.2, frequency=0.3, importance=0.5
314
- (Importance dominates because time and frequency are blunt instruments)
315
-
316
- ARCHIVE POLICY:
317
- - Memory with decay_score < ARCHIVE_THRESHOLD (e.g., 0.1) for > 30 days
318
- AND status != "pinned":
319
- -> Set status = "archived"
320
- -> Excluded from default retrieval
321
- -> Still searchable via explicit search_memory with include_archived=true
322
-
323
- - NEVER auto-delete. Delete only on explicit user request (for privacy/GDPR).
324
- - Pinned memories (via pin_memory tool) are exempt from archiving.
325
- ```
326
-
327
- ### 5.4 Conflict Detection Using Existing LLM Capabilities
328
-
329
- **At write time (online phase, lightweight)**:
330
-
331
- ```
332
- 1. On store_memory(content):
333
- a. Extract key entities/claims from content (can be simple: just use the content as query)
334
- b. Retrieve top-3 existing memories by similarity
335
- c. Quick conflict check (can be part of the consolidation LLM call):
336
- "Does the new information contradict any existing memory?
337
- If so, which one and how?"
338
- d. If conflict detected:
339
- - Flag the old memory with valid_until = now()
340
- - Store new memory with a supersedes link
341
- - Log the conflict for audit trail
342
-
343
- 2. Conflict severity levels:
344
- - FACTUAL_UPDATE: "User moved from Singapore to Tokyo" supersedes "User lives in Singapore"
345
- - PREFERENCE_CHANGE: "User now prefers dark mode" supersedes "User prefers light mode"
346
- - CONTRADICTION: Genuinely conflicting info, keep both, flag for human review
347
- - ELABORATION: New info adds detail, no conflict
348
- ```
349
-
350
- **At retrieval time (read-path dedup)**:
351
-
352
- ```
353
- When retrieving memories:
354
- 1. If multiple memories about the same entity/topic are retrieved:
355
- a. Prefer the one with valid_until = None (currently valid)
356
- b. If both are current, prefer higher importance score
357
- c. If conflict detected at retrieval time, include both but annotate:
358
- "[Note: conflicting memories found. Memory A (from DATE) says X.
359
- Memory B (from DATE) says Y.]"
360
- ```
361
-
362
- ### 5.5 Privacy Considerations for MCP Server
363
-
364
- **Immediate (MVP)**:
365
- - Scope-based access isolation (already exists in RecallNest: memories are per-scope)
366
- - No cross-scope memory leakage in retrieval
367
- - Audit log: every memory access logged with timestamp, tool, and scope
368
- - User can list all their memories via `export_memory`
369
- - User can request deletion of specific memories (hard delete on request)
370
-
371
- **Short-term (next quarter)**:
372
- - Memory redaction: ability to mark parts of memory as redacted (PII scrubbing)
373
- - Retention policies per scope: "auto-archive after N days", "auto-delete after N days"
374
- - Content classification on write: flag potential PII/secrets, warn before persisting
375
-
376
- **Long-term**:
377
- - Encrypted at-rest storage for memory content
378
- - Verifiable forgetting: cryptographic proof that data was erased
379
- - Access control lists per memory entry (not just per scope)
380
-
381
- ---
382
-
383
- ## Summary: Priority Implementation Order
384
-
385
- | Priority | Feature | Effort | Source Inspiration |
386
- |----------|---------|--------|--------------------|
387
- | P0 | Add lifecycle fields (valid_from/until, status, version) | Low | Zep temporal annotation |
388
- | P0 | Add access tracking fields (access_count, last_accessed_at) | Low | KARMA, MemOS |
389
- | P0 | Implement supersede-on-conflict (never hard-delete) | Medium | Zep, MOOM |
390
- | P1 | Local consolidation on store_memory (top-K similarity + LLM merge decision) | Medium | RMM |
391
- | P1 | Composite decay scoring for retrieval ranking | Medium | MemoryBank, TiM |
392
- | P1 | Archive policy (status="archived" for low-decay memories) | Low | MemOS archive pattern |
393
- | P2 | Periodic cluster-level consolidation (background distill) | High | PREMem, EverMemOS |
394
- | P2 | LLM-driven importance scoring on store | Medium | TiM, MemTool |
395
- | P2 | Conflict detection at write time | Medium | Mem0g, D-SMART |
396
- | P3 | Audit logging for all memory operations | Medium | Wu et al. trustworthy memory |
397
- | P3 | User-governed retention policies | Medium | Survey 7.7 privacy |
398
- | P3 | Memory redaction / PII detection | High | Wang et al. 2025b |
399
-
400
- ---
401
-
402
- ## Key Quotes from the Survey
403
-
404
- > "A naive strategy is simply appending new entries to the existing memory bank. However, it overlooks the semantic dependencies and potential contradictions between memory entries and neglects the temporal validity of information." (p.55)
405
-
406
- > "When storage cost is not a critical constraint, many memory systems avoid directly deleting certain memories." (p.59)
407
-
408
- > "Heuristic forgetting mechanisms like LRU may eliminate long-tail knowledge, which is seldom accessed but essential for correct decision-making." (p.59)
409
-
410
- > "Memory modules can leak private data through indirect prompt-based attacks, highlighting the risk of memorization and over-retention." (p.75)
411
-
412
- > "Agent memory systems must support explicit mechanisms for access control, verifiable forgetting, and auditable updates to remain trustworthy." (p.75)
413
-
414
- > "The stability-plasticity dilemma: determining when to overwrite existing knowledge versus when to treat new information as noise." (p.58)
415
-
416
- ---
417
-
418
- ## Named Systems Quick Reference
419
-
420
- | System | Key Contribution to Memory Evolution | Paper |
421
- |--------|--------------------------------------|-------|
422
- | RMM | Local consolidation: top-K similar + LLM merge decision | Tan et al., 2025c |
423
- | VLN | Capacity-triggered pooling of redundant memory pairs | Song et al., 2025b |
424
- | PREMem | Cluster-level fusion: align + generalize/refine memory clusters | Kim et al., 2025b |
425
- | EverMemOS | MemCell-to-MemScene centroid similarity merging | Hu et al., 2026a |
426
- | TiM | Hash-bucket periodic LLM merging + importance-driven forgetting | Liu et al., 2023a |
427
- | CAM | Cluster summarization with overlapping cluster handling | Li et al., 2025g |
428
- | MOOM | Dual-phase updating (soft online + offline reflective) + global integration | Chen et al., 2025e |
429
- | Matrix | Iterative optimization for global experiential consolidation | Liu et al., 2024 |
430
- | MemGPT | FIFO eviction + LLM-driven retrieval timing | Packer et al., 2023a |
431
- | Mem0/Mem0g | LLM-driven summarization + entity-level KG + destructive replacement | Chhikara et al., 2025 |
432
- | Zep | Temporal KG + soft deletion via invalid timestamps (not hard delete) | Rasmussen et al., 2025 |
433
- | D-SMART | OWL-compliant dynamic memory graph + conflict detection | Lei et al., 2025 |
434
- | LightMem | Topic-clustered summarization + dual-phase updating | Fang et al., 2025b |
435
- | MemOS | LRU forgetting + archive highly active + MemScheduler routing | Li et al., 2025l |
436
- | KARMA | Counting Bloom filters for access frequency tracking | Wang et al., 2025r |
437
- | MemTool | LLM-driven importance assessment + explicit pruning | Lumer et al., 2025 |
438
- | Livia | Emotional salience + contextual relevance for forgetting | Xi and Wang, 2025 |
439
- | Mem-alpha | RL-trained memory update policy (when/how/whether to update) | Wang et al., 2025p |
440
- | A-MEM | Networked notes with semantic links (structured construction) | Xu et al., 2025c |