Repository navigation
Releases
联合记忆 v2 · 0.1.4(可观测)
联合记忆 v2 · 0.1.4 —— 让「召回失灵」不再长得像「没有记忆」
中文在前,English version below(英文版在后半段,从
# English开始)。
给 AI 用的四层长时记忆。markdown 是唯一真相,索引是派生的。
MCP stdio · 零依赖 · Node ≥ 20 · MIT · 28 文件 / 121,546 B
0.1.4 是可观测性版本:不改召回行为,只让它坏的时候看得出来。
一、它是什么
真实的回忆有层级,也有代价:你记不住三年前某个下午的每句话,但记得「好像有过那么一天」,然后再慢慢挖。
| 层 | 里面是什么 | 想起来的代价 | 存在哪 |
|---|---|---|---|
| 上下文 | 当下对话原文 | 0 | 宿主窗口,它不管 |
| 索引 | 一句话的经验 | 一两秒 | experiences/YYYY-MM.md |
| 冷库 | 压缩前的总结(不是全文) | 要「想一会儿」 | summaries/<id>.md |
| 备份 | 每段会话的完整内容 | 要翻很久 | archive/YYYY-MM-DD/ |
上下文 → 索引 → 冷库 → 备份 → 「你并没有这段记忆」
索引没命中不等于没有这段记忆,往下翻就是了。衰减只发生在索引层(艾宾浩斯 R = 0.5^(t/H),H = 7 天 × (1 + 召回次数));备份永久,永不衰减。
二、这一版改了什么(相对 0.1.3)
0.1.3 修掉了「自动召回恒空」的两个 bug,但根子还在:注入点按设计静默失败,它坏了和它没东西可给,在提示里一模一样。0.1.4 只补「看得见」:
- 召回健康账:适配器每轮把一次求值写进
<root>/recall-health.json——outcome、命中条数、查询长度、耗时、是否走了关键词兜底、错误摘要,外加最近 20 条。不存查询正文,只存长度。 jmv2_stats多一个recallHealth:last+consecutiveEmpty+consecutiveError+recent+stale(30 分钟没上报当旧账,别当现状)。- 面板亮出来:右下角面板多一行召回状态;连续空 ≥ 5 或异常 ≥ 1 时变红,并写「⚠ 自动召回可能失灵,别当成『没记忆』」。
- 测试补真:适配器自检不再 stub 掉注入点,真跑「拼查询 → search」,并加了 0.1.2 那个 bug 的回归用例(会话尾部大半是工具 JSON)。
两条设计取舍:别让假警报淹了真警报
- 跳过不算失败:查询太短(< 8 字)只记
skipped,不动计数器——否则一句「嗯」就能把连续空清零,警报永远响不起来。 - 去重和预算也不算失败:同一轮里已经塞过的记忆会被去重(
reason: deduped)、或预算装不下(reason: budget),记skipped;只有真的「查了但没命中」才算empty(reason: no-hits)。
这条是上线后现场发现的:一轮里反复求值,consecutiveEmpty直接被顶到 3,面板差点误报。
三、健康账怎么读
cat ~/.joint-memory/recall-health.json
# 或者让模型自己看:jmv2_stats 里的 recallHealthoutcome |
意思 | 该紧张吗 |
|---|---|---|
injected |
真塞进去了 | 不,这是好状态 |
empty |
查了,但没命中(no-hits) |
偶尔正常;连续很多轮就该查查询构造 |
skipped |
没查或有命中没塞(query-too-short / deduped / budget) |
不,这是正常噪音 |
error / timeout |
真出事了,看 last.error |
是,连续 ≥ 1 就看 |
consecutiveEmpty / consecutiveError 是连续计数:一旦 injected 就双双归零。
四、怎么装
DSH —— 走插件总线,热插拔、不重启:
bus_install_plugin spec = /path/to/joint-memory-v2
或在 cordis.patch.yml 里挂 joint-memory-v2/adapters/dsh(完整片段见包内 GUIDE.md)。
其他 MCP 宿主:JOINT_MEMORY_DIR=$HOME/.joint-memory node src/mcp/serve.mjs,无需 npm install。
五、装完怎么确认它活着
- 工具列表有 12 个
jmv2_*。 jmv2_stats能回各层条数(不报错)。- 系统提示顶部出现
## pub …热层段(priv段永不进提示,这是设计)。 - 正常聊两轮,出现
【相关记忆 · 自动召回】;recallHealth.last.outcome变成injected。
六、校验
- 28 文件 / 121,546 B
- sha256
43fed1925ac1d3c1c46110cd6e925d8c5e51e37085dab187b4f4d4dac48b2184 npm test189 项全绿(smoke 26 / vertical 53 / attack 39 / guide 8 / migrate 18 / 回归 18 / DSH 适配器 27)
七、已知限制
- 还没上真正的向量层:关键词 + 艾宾浩斯加权,换一种说法可能召不回。
- 只在 Node 22 真机跑过;Node ≥ 20 是声明,20/24 只有语法级验证。
- 召回是「够用」不是「聪明」:一轮最多 3 条、480 字预算。
- 健康账只有适配器会写;只挂 MCP 不挂适配器时
recallHealth.available = false,那是正常的。 - 高负载时偶发
timeout(400 ms 预算);计数会涨,但不会把对话弄挂——这是注入点该有的样子。
八、升级与迁移
- 从 0.1.3 升级:换包即可,数据一个字不用动。
- 从 v1(
joint-memory 0.0.x)迁:数据格式不通用,别指同一目录;v1 老库只读留着,需要哪段用jmv2_write的archive层搬。v1 发布页已下架。
九、数据在哪、怎么卸
默认 ~/.joint-memory。卸载插件不删数据:删包和配置项即可;要清库自己删目录(先备份)。健康账也在里面,删掉会重建。
English — joint-memory v2 · 0.1.4
Four-layer long-term memory for AI agents. Markdown is the single source of truth; every index is derived.
MCP stdio · zero dependencies · Node ≥ 20 · MIT · 28 files / 121,546 B
0.1.4 is the observability release: recall behaviour is unchanged, but failures are now visible.
What it is
| Layer | Holds | Cost to recall |
|---|---|---|
| context | the live conversation | 0 |
| index | one-line experiences | ~1 s |
| cold store | pre-compaction summaries (not transcripts) | "think for a moment" |
| backup | full session content | search for a while |
Read order: context → index → cold store → backup → "you do not have this memory". Decay applies to the index layer only; the backup layer never decays.
What changed since 0.1.3
0.1.3 fixed the silently-broken auto-recall. The root cause remained: the injection point swallows errors by design, so failure and "nothing to recall" look identical. 0.1.4 adds sight, not behaviour:
- Health ledger at
<root>/recall-health.json: outcome, hits, query length, duration, whether the keyword retry ran, error summary, plus the last 20 entries. The query text is never stored — only its length. jmv2_statsreturnsrecallHealth:last,consecutiveEmpty,consecutiveError,recent,stale(no report for 30 minutes means it is stale history, not current state).- Panel shows one line of recall status; red when
consecutiveEmpty ≥ 5orconsecutiveError ≥ 1, with the warning "auto-recall may be broken — do not read this as 'no memories'". - Real tests: the adapter self-check no longer stubs the injection point; it runs query-building and search for real, including a regression case for the 0.1.2 bug (session tail dominated by tool JSON).
Two deliberate rules
- Skipped is not failed: a query under 8 characters only records
skipped; otherwise a single "ok" would reset the counter and the alarm could never fire. - Dedupe and budget are not failures: memories already injected in this turn (
reason: deduped) or those that do not fit in the budget (reason: budget) recordskipped; only a real miss isempty(reason: no-hits). Found in production: repeated evaluation within one turn pushedconsecutiveEmptyto 3 and nearly triggered a false alarm.
Reading recallHealth
outcome |
Meaning | Worry? |
|---|---|---|
injected |
memories actually injected | no |
empty |
searched, nothing matched (no-hits) |
occasionally normal; a long streak means look at query building |
skipped |
not searched, or matched but not injected (query-too-short / deduped / budget) |
no |
error / timeout |
something actually broke — read last.error |
yes |
Both consecutive counters reset as soon as an injected outcome arrives.
Install
DSH: bus_install_plugin spec = /path/to/joint-memory-v2 (hot-pluggable, no restart), or mount joint-memory-v2/adapters/dsh from cordis.patch.yml.
Any MCP host: JOINT_MEMORY_DIR=$HOME/.joint-memory node src/mcp/serve.mjs.
Verify
12 jmv2_* tools; jmv2_stats returns layer counts; a ## pub … section appears at the top of the system prompt (priv never does); after a turn or two recallHealth.last.outcome is injected.
Checksums
28 files / 121,546 B, sha256 43fed1925ac1d3c1c46110cd6e925d8c5e51e37085dab187b4f4d4dac48b2184, npm test 189/189 green.
Known limitations
- No real vector layer yet: keyword matching plus Ebbinghaus weighting, so paraphrases can miss.
- Only Node 22 has been exercised on real hardware.
- At most 3 memories and 480 characters per turn — good enough, not clever.
recallHealthis only written by the DSH adapter; with a bare MCP hostavailableisfalse, which is expected.- Occasional
timeoutunder heavy load (400 ms budget): the counter rises, the conversation keeps running — which is exactly what an injection point should do.
Upgrading
From 0.1.3: swap the package, data untouched. From v1 (joint-memory 0.0.x): the data format is not shared, do not point both at one directory; keep the old store read-only and copy what you need with jmv2_write layer: archive. The v1 release page has been delisted.
Data and uninstall
Default ~/.joint-memory. Uninstalling the plugin does not delete data. The health ledger lives there too and is rebuilt on demand.
猫猫省 Token 插件
1.0.1 · 2026-10-29:作者优化了版本,更新了内部代码,以获得更快的速度。建议使用 1.0.1。
dsh-token-saver
每轮开始把旧的工具输出折成「开头 + 提示 + 结尾」,压小上下文。
长会话烧钱,大头不是思考,是每一步都把整段上下文重新发一遍;其中体积最大的是工具输出。
- 每轮只折一次(改历史会让 prompt cache 失效,折太勤反而更贵)
- 最近 6 条原样保留,更早的超过 800 字才折
- 折叠走
surfaceOp: replace,原文还在会话日志里,不会丢 - 面板「省 token」页可调力度,即时生效
- 本机实测:首轮折叠 39 条 / 92,447 字符
安装
plugin_manager install_bundle target:/path/to/dsh-token-saversha256: 05f363930d172d1467a354ce3b2b9098cd8193700231bea4a04011e0faacc72f
作者:猫猫(YumeNoNaka)
猫猫 QQ 接管插件
1.0.1 · 2026-10-29:作者优化了版本,更新了内部代码,以获得更快的速度。建议使用 1.0.1。
dsh-qq-brain
让 QQ 上的猫,用 DSH 里的这只猫当大脑。同一人格、同一记忆、同一模型、同一套工具。
QQ 只是另一个入口,回复本身由 DSH 里的 agent 生成:
QQ → OneBot v11 → 传话进程 → POST /maomao-qq/api/chat → DSH 会话 → 回复
- 每个聊天一个专属会话(私聊 / 群 分开),自动创建复用
- 白名单放行
private:<QQ号>与group:<群号>,其余 403 - 同一 chat 串行、240 秒超时 abort、token 定长比较
- 实测一次往返约 6 秒
安装
plugin_manager install_bundle target:/path/to/dsh-qq-brainsha256: f7f1edc5bb5cd06e84dd241d9ebe6acee129f7ba6e2856d6dd6a134fd813575f
作者:猫猫(YumeNoNaka)
dsh-memory-fs 1.1.1
历史版本已下架(2026-10-31):
dsh-memory-fs-1.0.1.zip、dsh-memory-fs-1.1.0.zip已移除。
原因:两个版本都缺少本次安全整改(recall空参越权、hot可读 priv 段、/api/*无来源校验)。
请使用 1.1.1;数据格式兼容,直接覆盖升级不会丢记忆。想考古改动看CHANGELOG.md。
dsh-memory-fs 1.1.1
按「内容与隐私审计」整改:修掉两处群聊越权和一处无鉴权接口。
安全修复
- 接口只认本机:
/memory-fs/api/*校验来源为回环地址,外部来源直接 403;反代过来仍是本机地址,面板不受影响 - 修
recall空参越权:不带参数时原来直接返回今天全部条目(含[private]),现在同样过 scope 过滤 - 修
hot越权:memory_hot接exec,群会话show只返回pub段、add只能写pub - 隔离可收紧:
groupIsolation: 'strict',映射缺失 / 解析失败 / 会话不在映射里,一律按群聊处理(fail-closed) - 新增
memory_forget:按日期 +tag/scope/contains真删,先备份、失败中止、重建索引、记reflections/forget.md;默认只预览 - 备份收紧权限:目录
700、文件600 offload摘要默认private,不再写进群聊可检索的[self]/state去掉绝对路径;复盘提示词要求不写凭据、隐私细节抽象化- qq-brain:
sessions.json与config.json统一 600
校验
sha256 9a0d42f7b3a1813064d0a6abec014bf28c36af7f37f2038cfe7fc26bf9f54d90
size 42,610 B
安装
解压后把目录装进 DSH profile(install_bundle 或 cordis.patch.yml insert):
- insert:
- id: memory-fs
name: '@local/memory-fs'
config:
reviewTime: '23:30:00'
# 需要严格隔离时再加:
# groupIsolation: 'strict'