dsh-memu-memory 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +11 -3
- package/CHANGELOG.md +57 -3
- package/README.md +6 -11
- package/README.zh.md +6 -11
- package/assets/screenshots/drawer.jpg +0 -0
- package/assets/screenshots/mobile.jpg +0 -0
- package/assets/screenshots/relations.jpg +0 -0
- package/assets/screenshots/settings.jpg +0 -0
- package/assets/screenshots/stats.jpg +0 -0
- package/assets/screenshots/webui-dark.jpg +0 -0
- package/assets/screenshots/webui-memory.jpg +0 -0
- package/docs/client-conventions.md +21 -0
- package/docs/contributing.md +5 -2
- package/docs/memory-semantics.md +17 -0
- package/docs/troubleshooting.md +44 -0
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +125 -18
- package/lib/consolidation-snapshot.js +101 -5
- package/lib/consolidation-worker.js +1 -1
- package/lib/cycle.js +19 -1
- package/lib/index.js +83 -2
- package/lib/private.js +450 -165
- package/lib/rpc.js +14 -1
- package/lib/state.js +11 -1
- package/lib/turn-log.js +522 -0
- package/lib/webui/graph-view.bundle.js +1 -1
- package/lib/webui/graph-view.js +53 -25
- package/lib/webui/standalone.css +4 -29
- package/lib/worker-pool.js +741 -0
- package/package.json +1 -1
- package/scripts/acceptance-local.mjs +6 -5
- package/scripts/build-graph.mjs +32 -4
- package/scripts/check-all.mjs +2 -0
- package/scripts/check-idle-compositing.mjs +61 -0
- package/scripts/make-readme-shots.mjs +59 -0
- package/scripts/prune-turnlogs.mjs +30 -0
- package/tests/browser.test.mjs +27 -0
- package/tests/client-render.test.mjs +171 -0
- package/tests/consolidation-snapshot.test.mjs +89 -1
- package/tests/graph-view.test.mjs +60 -3
- package/tests/loader.mjs +2 -0
- package/tests/salience-domain.test.mjs +139 -0
- package/tests/settings-coverage.test.mjs +97 -0
- package/tests/stubs/dsh-session-query.js +26 -0
- package/tests/turn-log.test.mjs +474 -0
- package/tests/webui.test.mjs +19 -0
- package/tests/worker-lifecycle.test.mjs +1046 -0
- package/docs/recall-benchmark.md +0 -238
package/AGENTS.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
给**改这个仓库的人和 agent** 的**索引**:只答「去哪份文件找」。细节全在 `docs/`,本文件刻意短。
|
|
4
4
|
|
|
5
|
-
仓库事实:纯 JS、ESM
|
|
5
|
+
仓库事实:纯 JS、ESM、**只有一个构建步骤**——图谱引擎 bundle(改 `lib/webui/graph-view.js` 必须 `npm run build:graph`,浏览器加载的是产物不是源码);源码与测试**全 CRLF**;全量测试 + 验收 50 条(均由脚本核对);版本见 `package.json`;MIT。
|
|
6
6
|
|
|
7
7
|
2026-10-28:包名 `dsh-memu-memory`(目录仍由用户手动改名)。旧 `/dsh-memu` 路由兼容正式前缀;旧数据目录在没有新 `state.json` 时原地使用,不自动搬迁。WebUI 的 MemU 记忆墙与九页设置是同一个 SettingsPage,仅一个入口。旧「整理失败也标记已睡」的口径作废,失败必须退避重试。能力与限制 → `README.md`。
|
|
8
8
|
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
8. **不碰共享 `/api`**:RPC 只走 `/dsh-memu-memory` 前缀(`webServer.register` + `connection.requestRejection`)。
|
|
23
23
|
9. **日志与提示词里不放 API key。**
|
|
24
24
|
10. **注入失败 fail-open,但必须留可观测信号。** 吞掉异常是允许的,但**不许把真实故障一起吞**:fail-open 必配 `logger.warn` + binding 上的 `lastRecallError`(侧边栏可见),单测断言**召回到的 id**,不能只断言「消息插进去了」。**不能靠「没报错就是好了」。** 成因与守卫 → `docs/troubleshooting.md` §3.1。
|
|
25
|
+
11. **跑批与复测的输出一律重定向文件**(`> logs/x.log 2>&1`),禁用 `| tail` 管道——管道只留尾巴,故障段不可回查。清理宿主数据必须先确认宿主进程完全退出(活宿主的内存态会回写覆盖清理结果)。
|
|
26
|
+
12. **整理快照必须做持久日志交叉核对**:`captureSessionSnapshot` 的活视图(observeSession/readSession)落后于持久日志时,用 `sessionPersistence` + `readColdSessionLog` 冷读并取更长的日志(source `persisted-ahead`);只信活视图 = 外部追加不可见 → 快照冻结/整理洪水。`host`/`custom` 模型模式也不得探测父会话 route(resume 会把父会话钉成活视图)。成因链与排错路线 → `docs/troubleshooting.md` §3.29。
|
|
25
27
|
|
|
26
28
|
---
|
|
27
29
|
|
|
@@ -52,6 +54,8 @@
|
|
|
52
54
|
日期到点没唤醒 → T3.21 时效提示没出现 → T3.22
|
|
53
55
|
实体合并 / 怕丢记忆 → T3.23
|
|
54
56
|
失败一轮后锚点/日期没了 → T3.24
|
|
57
|
+
图谱改了没生效 / 缩到最小打架 → T3.27
|
|
58
|
+
WebUI 开着 GPU 占用高 / 时钟钉高档 → T3.28
|
|
55
59
|
```
|
|
56
60
|
|
|
57
61
|
---
|
|
@@ -62,9 +66,11 @@
|
|
|
62
66
|
node --check lib/<改过的文件>.js # 语法(源码是 ESM,别用 require 试)
|
|
63
67
|
npm test # 全量;真实引擎用例默认跳过
|
|
64
68
|
node scripts/acceptance-local.mjs # 50/50
|
|
65
|
-
npm run check # node --check + i18n + package.json + 文档预算
|
|
69
|
+
npm run check # node --check + i18n + package.json + 文档预算 + 图谱 bundle 漂移
|
|
66
70
|
```
|
|
67
71
|
|
|
72
|
+
**图谱引擎是唯一的产物**:改 `lib/webui/graph-view.js` 后先 `npm run build:graph` 再验证——单测 import 源码、浏览器加载 bundle,不重打包就是「测试全绿、页面照旧」(→ `docs/troubleshooting.md` §3.27)。
|
|
73
|
+
|
|
68
74
|
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。测试数字只作**带日期快照**引用(2026-11-06 实测 1473 tests / 1471 pass / 0 fail / 2 skipped;两条真实引擎用例按设计跳过,历史 1293/1291/1287/1280/1277/1273/1210/505/493/463/409/392 等不再代表当前),不当成当前保证。提交前逐条对 `docs/contributing.md` §10。
|
|
69
75
|
|
|
70
76
|
---
|
|
@@ -77,12 +83,14 @@ npm run check # node --check + i18n + package.json + 文
|
|
|
77
83
|
| `docs/contributing.md` | §4 改动流程(四步 / 验证三件套 / 连带清单 / 文档同步)+ §5 六个扩展点 + §10 提交前清单 |
|
|
78
84
|
| `docs/host-api.md` | §6.1 / 6.2 / 6.4–6.8:embedding、workspaceRegistry、历史会话与标题、fork/followup、定时器、RPC+slot+折叠、预设工具面真机证据边界 |
|
|
79
85
|
| `docs/host-adaptation.md` | 宿主版本适配手册:事实来源、memu 的宿主面清单、新版本检查流程、隔离真机搭法、0.2.2-rc.1 实测记录与陷阱 |
|
|
80
|
-
| `docs/client-conventions.md` | §7:两个壳一份实现、颜色 token
|
|
86
|
+
| `docs/client-conventions.md` | §7:两个壳一份实现、颜色 token、控件纪律、数据与刷新、文案与结构、图谱工作台(§7.6)、合成负载(§7.7) |
|
|
81
87
|
| `docs/memory-semantics.md` | §8:三层、写入规则、全局记忆、注入(含预设会话首步 `<memory-guide>` 一次性投放)、提示词管理 |
|
|
82
88
|
| `docs/env-and-commands.md` | §9:Windows 跑命令的 env、CRLF 补丁法、本地 link、引擎安装与回滚、本地向量受管运行时的安装/状态命令(§9.5)、MemU CLI 事实 |
|
|
83
89
|
|
|
84
90
|
**W8(助手重复提示)已决定不做,不再重做。** 理由:120 次合成 A/B 未证明改善重复回答率,事实词面完整性反而下降。证据文档已删除,不得据此宣称“已证明任何防复读技术无效”。
|
|
85
91
|
|
|
92
|
+
**整理执行器(实验功能)**:设置 → 记忆维护 →「整理执行器」,`fork`(默认,每窗新 fork)/ `worker`(持久 worker,按 200k 字符 / 16 窗换新)。作用、差异与回滚 → `docs/memory-semantics.md` §8.18。
|
|
93
|
+
|
|
86
94
|
节号跨文件不变:看到「(§8.4)」就去 `docs/memory-semantics.md` 找 §8.4。
|
|
87
95
|
|
|
88
96
|
## 5. 三条容易记反的
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# 更新日志 / Changelog
|
|
2
2
|
|
|
3
|
+
## [1.3.4] - 2026-11-14
|
|
4
|
+
|
|
5
|
+
> 整理执行器(实验功能)与增量回合日志:设置页可选 fork / 持久 worker(worker 按 200k 字符 / 16 窗换新,窗内批量写);整理快照增加持久日志交叉核对,修掉外部追加不可见导致的整理冻结;WebUI 空闲合成负载归零。产品文档移除 benchmark 记录与文档(测试资产不进产品文档)。
|
|
6
|
+
|
|
7
|
+
### 整理(实验功能)
|
|
8
|
+
|
|
9
|
+
- **设置页可选「整理执行器」**:设置 → 记忆维护 →「整理执行器」,红色「实验功能」标记。`fork`(默认)= 每个窗口新建一次整理会话;`worker` = 跨窗复用同一后台会话,按模型上下文分档换新(≤128k 上下文 → 120k 字符/8 窗,其余 → 200k 字符/16 窗),新 epoch 用交接包接续。切换从下一窗生效,无需重启;「恢复默认」回到 fork,数据层没有依赖。
|
|
10
|
+
- **窗口内批量写**:worker 任务书要求把本窗新增条目合并成一次 `memu_private_remember_batch` 提交,只有 1 条时才逐条写;更新也合并在同一轮。原有「批量参数畸形 → 下一轮退回逐条写」的回退保留。
|
|
11
|
+
- **增量回合日志(`lib/turn-log.js`)**:按回合落盘,作为持久 worker 的上下文缓存;`consolidationTurnLog=off` 时退回现场压缩。配套 `scripts/prune-turnlogs.mjs` 清理旧日志。
|
|
12
|
+
|
|
13
|
+
### 整理可靠性
|
|
14
|
+
|
|
15
|
+
- **快照冷日志交叉核对**:`captureSessionSnapshot` 的活视图落后于持久日志时,用 `sessionPersistence` + `readColdSessionLog` 冷读取更长的一份(source `persisted-ahead`,60s TTL 缓存),避免外部追加不可见导致的快照冻结与整理洪水。
|
|
16
|
+
- **不无意义 resume**:`consolidationModelMode` 为 `host` / `custom` 时不再探测父会话 route,避免把父会话钉成活视图。
|
|
17
|
+
|
|
18
|
+
### WebUI
|
|
19
|
+
|
|
20
|
+
- **空闲合成负载归零**:装饰层去掉无限动画与常驻 `will-change`,`backdrop-filter` 只保留 topbar 与 boot 卡,缩略图改由主画布 `onPaint` 驱动;新增 `scripts/check-idle-compositing.mjs` 真机数帧(空闲 fps > 2 即 FAIL)与 `tests/webui.test.mjs` 静态守卫。
|
|
21
|
+
|
|
22
|
+
### 文档
|
|
23
|
+
|
|
24
|
+
- `docs/memory-semantics.md` 新增 §8.18:整理执行器的作用、fork 与 worker 的差异、epoch/交接/批量写边界与回滚方式。
|
|
25
|
+
- `docs/troubleshooting.md` 新增 §3.28(WebUI 空闲合成负载)与 §3.29(外部追加导致快照冻结);`docs/client-conventions.md` 新增 §7.7(合成负载约定)。
|
|
26
|
+
- `AGENTS.md` §4 增加实验功能指针;移除 benchmark 实测引用。
|
|
27
|
+
- `README.md` / `README.zh.md` 移除 Benchmark/基准测试章节与交叉引用;`CHANGELOG.md` 移除历史 benchmark 成绩记录;删除 `docs/recall-benchmark.md`。测试与 harness 代码保留在仓库内,产品文档不再包含 benchmark 记录。
|
|
28
|
+
|
|
29
|
+
## [1.3.3] - 2026-11-13
|
|
30
|
+
|
|
31
|
+
> 小修复与体验优化版本:关系图谱最小缩放下「节点打架 / 闪现」的根因修掉(分离阈值曾跟缩放挂钩),开着图谱不再白吃 GPU,宿主设置页导航不再被掰竖;记忆库与记忆浏览新增「立即整理」与库内搜索;图谱产物纳入 `npm run check` 漂移闸门,README 截图与图注重录。
|
|
32
|
+
|
|
33
|
+
### 关系图谱
|
|
34
|
+
|
|
35
|
+
- **修掉最小缩放打架**:硬分离阈值原写为 `24 / clamp(viewScale, .06, 5)`,缩到最小(k≈.06)等于要求每对节点保持 400 世界像素间距,斥力与弹簧在 alpha 落地板后已经消失,于是每帧只剩分离力互推、永不收敛。现在阈值只看**世界坐标 + 节点半径**,完全重合时按 id 哈希给确定方向岔开;`viewScale` / `setScale` 一并删除——物理拿不到相机才是根本解。真实浏览器复测(60 节点、k=0.06、点「重新布局」):每 250ms 最大位移 5.92 → 0.02 屏幕像素,静置后漂移 0.06px。
|
|
36
|
+
- 「重新布局」同时重记弹簧原长,避免新位置配旧原长又拉成一团。
|
|
37
|
+
- **冷下来零帧**:模拟落回 alpha 地板后不再申请下一帧,呼吸微动也只在模拟活着时画——WebUI 开着图谱 GPU 占用一路爬升的问题随之消失。
|
|
38
|
+
- 最小缩放的命中迟滞:相邻节点在屏幕上只差 1–2px 时,悬停不再随 1px 抖动来回跳。
|
|
39
|
+
- 缩略图只在主画布真正重绘后才更新(`onPaint` 计数),不再与画布各画各的。
|
|
40
|
+
- 设置里的「关系图谱」改为**一个按钮**,点击直达 WebUI 全屏图谱页;`is-graph-wide` 只在独立外壳生效,宿主设置页保持原本的横排导航。
|
|
41
|
+
|
|
42
|
+
### 记忆库与记忆浏览
|
|
43
|
+
|
|
44
|
+
- 新增「立即整理」:记忆库每一行、记忆浏览页头各一个按钮,两段确认。它复用侧边栏同一条通道——`listSessions`(本次起返回每个会话绑定的 `libraryId`)筛出该库的会话,再逐个调用 `generatePrivate`,**不新增 RPC 方法**;单轮最多起 5 个整理,其余留给下一次扫描,回执说明已开始 / 在跑 / 失败条数。
|
|
45
|
+
- 「当前记忆库」下方新增搜索框:按标题、正文、ID、标签即时过滤当前已加载的库,页签计数与「命中 / 总数」同步,切换记忆库自动清空;关系视图下不显示。
|
|
46
|
+
|
|
47
|
+
### 工程与文档
|
|
48
|
+
|
|
49
|
+
- `npm run check` 新增 **graph bundle 漂移闸门**:`node scripts/build-graph.mjs --check` 把源码重打包到内存与 `lib/webui/graph-view.bundle.js` 逐字节比对。此前改完引擎忘了 `npm run build:graph`,浏览器加载的还是旧产物,会出现「单测全绿、页面照旧」(单测 import 源码,浏览器加载 bundle)。生产安装没有 esbuild 时该项自动 skip,不算失败。
|
|
50
|
+
- 新增 `scripts/make-readme-shots.mjs`:对着隔离数据预览用无头浏览器重录 README 的七张截图;本轮截图与图注已更新(关系图谱独立成页、自研连续力导向引擎、bundle 无第三方运行时),并清掉了残留的「D3 力导向」表述。
|
|
51
|
+
- 文档:`AGENTS.md` 仓库事实改为「只有一个构建步骤」并加 §3.27 指针;`docs/client-conventions.md` 新增 §7.6 图谱工作台约定(物理不读相机、改引擎必重打包、冷下来零帧、命中迟滞、外壳归属、最小缩放必然压住不是 bug、整理不新增 RPC);`docs/troubleshooting.md` 新增 §3.27;`docs/contributing.md` §4.1–§4.4 补构建步骤与截图连带项。
|
|
52
|
+
|
|
53
|
+
### 测试
|
|
54
|
+
|
|
55
|
+
- 引擎:`relayout cools down and separates instead of shoving nodes forever`(位移逐窗衰减 + 零重合 + 物理拿不到相机)、`a cooled layout stops requesting frames even while motion is enabled`、`hover keeps its target through 1px jitter at minimum zoom`。
|
|
56
|
+
- 客户端渲染:`the immersive graph shell stays with the standalone WebUI`、`the manual consolidation button rides the sidebar channel, not a new RPC`、`the browse search box filters the loaded library in place`。
|
|
57
|
+
- `listSessions` 返回库绑定由 `tests/browser.test.mjs` 覆盖。
|
|
58
|
+
|
|
3
59
|
## [1.3.2] - 2026-11-10
|
|
4
60
|
|
|
5
61
|
> 独立「关系图谱」页与确定性自动关联:记忆墙里的内嵌节点图升级为侧边栏独立页面(自研力导向引擎,移除 d3 运行时依赖);自动关联改为断言驱动(已确认实体提及 / 字段证据),默认只出候选,旧库可用脚本迁移。
|
|
@@ -52,7 +108,7 @@
|
|
|
52
108
|
|
|
53
109
|
## [1.3.0] - 2026-11-08
|
|
54
110
|
|
|
55
|
-
> 整理成本与可靠性:worker 工具面 14 → 6、remember/update schema 压缩、窗口 500 事件 / 每窗上限 8 条;新增本地零 Token 的“必写候选”与跨窗顺延;回执对账改为以库 diff 为权威,`snapshot-failed`
|
|
111
|
+
> 整理成本与可靠性:worker 工具面 14 → 6、remember/update schema 压缩、窗口 500 事件 / 每窗上限 8 条;新增本地零 Token 的“必写候选”与跨窗顺延;回执对账改为以库 diff 为权威,`snapshot-failed` 不再被当成完成。
|
|
56
112
|
|
|
57
113
|
### 整理成本
|
|
58
114
|
|
|
@@ -139,7 +195,6 @@
|
|
|
139
195
|
|
|
140
196
|
### 评测
|
|
141
197
|
|
|
142
|
-
- [chat-memory-benchmark](https://github.com/Ornn8/chat-memory-benchmark) 714 题完整卷(2026-11-06,`dys-router / deepseek-v4.1-flash`,high 思考强度):通过 **653 / 714(91.46%)**;同轮**实测记忆成本 ¥16.05**,含非记忆开销的总成本 ¥24.45(谷价,总 token 75,517,851)。
|
|
143
198
|
- 全量 **1473 tests / 1471 pass / 0 fail / 2 skipped**、acceptance 50/50、`npm run check` 全绿。
|
|
144
199
|
- 升级兼容:旧条目缺新字段按空处理,不强制迁移;`disclosure` 行为有变(`never_say` / `only_if_asked` 不再自动注入),需要它们自动出现的旧用法请改回 `can_tell`。
|
|
145
200
|
|
|
@@ -155,7 +210,6 @@
|
|
|
155
210
|
- **召回缓存(`lib/recall-cache.js`)**:`managedRecall` 成功语义召回段进程内 LRU(256 条 / 120s),键含 `memoryRevision()`(全部索引/状态落盘自增,写后无 stale)+ 向量代数 + domain/sessionId/context 等九分量;fail-open + `warn` 留痕,降级/fallback 结果一律不缓存。显式召回命中率 ~0 属正确行为(touchAccess 参与 decay 加成)。文档见 `docs/memory-semantics.md` §8.12。
|
|
156
211
|
- **冲突检测增强**:新增 `polarityAt` 子句级否定作用域(双重否定、对比结构分段、无关子句隔离),`globalConflictCheck` 改用共享锚点双侧极性对比(无共享词回退整文本口径);修复「截止日期 5月1日,别忘了」类无关子句否定与「不是不喜欢」双重否定两类误报。`negationPolarity` 原口径与导出不变。
|
|
157
212
|
- **修复:整理 fork 在 DSH 0.2.2-rc.1 上必挂**——rc.1 的种子校验(`assertAssistantSettlementShape`)要求 `assistant/message.data.stream` 是数组,而插件种子清噪曾直接删除该字段,导致 0.2.2-rc.1 上每个整理 fork 种子被拒("invalid settlement fields";**1.2.6 已发布版同样中招**——`host-adaptation.md` §5.4 声明的未测面被内部真机评测实证)。修复:种子携带**空 stream 数组**(清噪初衷不变——分块日志不进种子;旧宿主不校验该字段,惰性兼容)。新增 `scripts/check-seed-compat.mjs`(用目标宿主自己的 dsh-session 包验证种子兼容性),列入宿主适配检查表必跑项。
|
|
158
|
-
- **基准台(`scripts/bench-recall.mjs`)**:确定性合成语料前后对照。终局:全量 **1406 tests / 1404 pass / 0 fail / 2 skipped**、acceptance 50/50;簇构建较 1.2.6 快约 3%(5041→~4900ms);Recall@10 与基线持平(0.7650 vs 0.7675,差 1/400 条,MRR 0.4200 vs 0.4218)——合成基准只能当回归门。
|
|
159
213
|
- **守卫**:新增 4 个测试文件共 58 条(tokenizer-v2 17、dynamic-rrf 11、recall-cache 14、negation-polarity 14、边界带守卫 2);阈值常量零改动。
|
|
160
214
|
|
|
161
215
|
### RP/混合提示词:生活日常采集线
|
package/README.md
CHANGED
|
@@ -30,11 +30,7 @@ It is **local-first by default**. The default `agent` backend stores full text i
|
|
|
30
30
|
> [!WARNING]
|
|
31
31
|
> **Early-stage software.** This plugin is still early and may contain unforeseen errors, bugs or breaking changes. Back up your data, and please [report an issue](https://github.com/Tkingxiao/dsh-memu-memory/issues) or send a pull request — feedback helps the project improve.
|
|
32
32
|
|
|
33
|
-
> **Status:** 1.3.
|
|
34
|
-
|
|
35
|
-
## Benchmark
|
|
36
|
-
|
|
37
|
-
The public [chat-memory-benchmark](https://github.com/Ornn8/chat-memory-benchmark) full 714-question run (2026-11-06, `dys-router / deepseek-v4.1-flash`, high reasoning) passed **653 / 714 (91.46%)**. The run's actual measured memory cost was **¥16.05**; the full run, including non-memory overhead, cost **¥24.45** (75,517,851 tokens total, at the provider's off-peak rate) — measured end to end, not extrapolated from a single session.
|
|
33
|
+
> **Status:** 1.3.4. The first public release was 1.0.0. The manual now lives in [`docs/`](docs/), with [`AGENTS.md`](AGENTS.md) as a short index. Back up `~/.dsh/dsh-memu-memory` before upgrades, and read [Compatibility & limits](#compatibility--limits) before storing data you cannot re-create.
|
|
38
34
|
|
|
39
35
|
## Screenshots
|
|
40
36
|
|
|
@@ -46,7 +42,7 @@ All screenshots are the real WebUI on isolated example data, not anyone's memori
|
|
|
46
42
|
<td align="center"><img src="assets/screenshots/drawer.jpg" width="470" alt="In-place memory drawer"><br/><em>Edit, archive or restore without leaving the wall</em></td>
|
|
47
43
|
</tr>
|
|
48
44
|
<tr>
|
|
49
|
-
<td align="center"><img src="assets/screenshots/relations.jpg" width="470" alt="
|
|
45
|
+
<td align="center"><img src="assets/screenshots/relations.jpg" width="470" alt="Relationship graph studio"><br/><em>Full-screen relationship graph · canvas and inspector</em></td>
|
|
50
46
|
<td align="center"><img src="assets/screenshots/settings.jpg" width="470" alt="Settings"><br/><em>Injection, budgets, retention and automation</em></td>
|
|
51
47
|
</tr>
|
|
52
48
|
<tr>
|
|
@@ -90,8 +86,6 @@ Four real long sessions from this machine were replayed read-only (no new chat)
|
|
|
90
86
|
|
|
91
87
|
Below-threshold turns on the two small sessions can still wake through starvation; on the 2,000+ event sessions they do not. None of the four had new human input after its real cursor, so none would fork again immediately.
|
|
92
88
|
|
|
93
|
-
End-to-end accuracy and the measured cost of the 714-question run are in [Benchmark](#benchmark).
|
|
94
|
-
|
|
95
89
|
## One WebUI
|
|
96
90
|
|
|
97
91
|
The sidebar has exactly **one** entry: **MemU WebUI**. The memory wall and all settings live in the same navigation, with deep links such as `#/settings/memories`, `#/settings/folders` and `#/settings/stats`. The interface follows the browser locale (Chinese or English).
|
|
@@ -100,9 +94,9 @@ The sidebar has exactly **one** entry: **MemU WebUI**. The memory wall and all s
|
|
|
100
94
|
|
|
101
95
|
**In-place work.** Clicking a memory card opens a right-side drawer with the full text and the fields that decide how it behaves — title, content, tags, disclosure, confidence, open loop — plus save, archive, restore and "open in the browser" for heavier work. Archived memories can be deleted in the same drawer; the first click only arms it and the second confirms. Global memories are read-only in the drawer and link to their own page. Filters and scroll position stay where they were. Cards that carry images use the first usable attachment as a cover, and the drawer opens the full gallery; `secret` and `never_say` entries never receive a pixel URL, so they show a label instead.
|
|
102
96
|
|
|
103
|
-
**
|
|
97
|
+
**One page for the graph.** **Relations** is its own full-screen page in the WebUI (`#/settings/graph`): the canvas on the left, the inspector on the right, and a **Manage** tab for the list view with the same filters. Source (all / automatic only / manual only), rule, library and search all narrow one shared dataset instead of switching modes, and Settings → Relations is a single button that opens that page. The scope selector still carries a **Global memory** entry: nodes are global entries and edges are `related/refines/supports`; the global view is read-only, and edges are removed from the global memory list.
|
|
104
98
|
|
|
105
|
-
The
|
|
99
|
+
The graph runs on a **self-written continuous force engine** — no third-party runtime is bundled. It stays alive while you work, preserves node positions and the camera across background data refreshes, and stops requesting frames the moment it cools down, so an open graph costs no idle GPU. Dragging pins a node exactly where you drop it (release never yanks it back), and only the cluster you touched keeps simulating: frozen clusters act as obstacles the moving one cannot slide through. Repulsion, link distance and centering are adjustable in the panel, labels avoid collisions, and the minimap repaints only after the canvas does. Zoomed all the way out the nodes necessarily merge on screen — separation lives in world coordinates, so spread clusters with repulsion/link distance instead of the zoom. Settings → Relations is a single button that opens the full-screen graph page in the WebUI, where you can also add, edit and delete nodes, and filter edges by the rule that produced them. The layout only visualizes recorded links: it never infers or writes relationships. The graph page also lists **entity merge candidates** (same kind, contained or near-identical spellings) — suggestions only, confirmed by two clicks, and merging redirects links and folds aliases into the main node without deleting any memory.
|
|
106
100
|
|
|
107
101
|
| Page | What it is for |
|
|
108
102
|
|---|---|
|
|
@@ -347,11 +341,12 @@ npm run build:graph # rebuild shipped offline assets after
|
|
|
347
341
|
node scripts/acceptance-local.mjs # 50 automated acceptance checks
|
|
348
342
|
node scripts/migrate-visibility.mjs # report (add --apply to rewrite) libraries that still store the removed session level
|
|
349
343
|
node --import ./tests/loader-register.mjs scripts/preview.mjs --port 7789
|
|
344
|
+
node scripts/make-readme-shots.mjs # re-record the screenshots above against that preview
|
|
350
345
|
```
|
|
351
346
|
|
|
352
347
|
The preview serves the real WebUI against isolated example data at `http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories`.
|
|
353
348
|
|
|
354
|
-
With the preview running, use `npm run test:graph-browser -- http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories` in another terminal to check 200 nodes, desktop/narrow layouts, dragging, refresh stability, themes and load retries. Run `npx playwright install chromium` once, or set `GRAPH_BROWSER_CHANNEL=msedge` on Windows to use installed Edge. Stress data is intercepted only in the test browser and never written to memory. No CDN is needed at runtime;
|
|
349
|
+
With the preview running, use `npm run test:graph-browser -- http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories` in another terminal to check 200 nodes, desktop/narrow layouts, dragging, refresh stability, themes and load retries. Run `npx playwright install chromium` once, or set `GRAPH_BROWSER_CHANNEL=msedge` on Windows to use installed Edge. Stress data is intercepted only in the test browser and never written to memory. No CDN is needed at runtime; the bundle carries no third-party runtime code, which `lib/webui/graph-LICENSE.txt` records.
|
|
355
350
|
|
|
356
351
|
The suite includes two optional real-engine integration cases: curator writing requires `DSH_MEMU_TEST_ENGINE_PYTHON`, and the backup venv/WAL case requires `DSH_MEMU_BACKUP_REAL_ENGINE=1`; both are skipped by default. The 50 automated acceptance checks pass. The optional engine was installed and smoke-tested in an isolated directory with the pinned wheel; embedding tests use a local deterministic server, which proves the protocol, not semantic quality.
|
|
357
352
|
|
package/README.zh.md
CHANGED
|
@@ -30,11 +30,7 @@
|
|
|
30
30
|
> [!WARNING]
|
|
31
31
|
> **早期版本提示。** 本插件仍处于早期阶段,可能存在无法预见的错误、bug 或不兼容变更。请先备份数据;欢迎[提交 Issue](https://github.com/Tkingxiao/dsh-memu-memory/issues) 或 PR 帮助改进。
|
|
32
32
|
|
|
33
|
-
> **状态:** 1.3.
|
|
34
|
-
|
|
35
|
-
## 基准测试
|
|
36
|
-
|
|
37
|
-
公开的 [chat-memory-benchmark](https://github.com/Ornn8/chat-memory-benchmark) 714 题完整卷(2026-11-06,`dys-router / deepseek-v4.1-flash`,high 思考强度)通过 **653 / 714(91.46%)**。同一轮**实测记忆成本为 ¥16.05**;包含非记忆开销的总成本为 **¥24.45**(总 token 75,517,851,谷价),均为端到端实测,不是按单次会话外推。
|
|
33
|
+
> **状态:** 1.3.4。首个公开发布版本为 1.0.0。细节文档已迁到 [`docs/`](docs/),[`AGENTS.md`](AGENTS.md) 只做索引。升级前请备份 `~/.dsh/dsh-memu-memory`;如果要存无法重建的数据,请先读[兼容性与边界](#兼容性与边界)。
|
|
38
34
|
|
|
39
35
|
## 界面
|
|
40
36
|
|
|
@@ -46,7 +42,7 @@
|
|
|
46
42
|
<td align="center"><img src="assets/screenshots/drawer.jpg" width="470" alt="原地详情"><br/><em>不离开记忆墙就能编辑、归档、恢复</em></td>
|
|
47
43
|
</tr>
|
|
48
44
|
<tr>
|
|
49
|
-
<td align="center"><img src="assets/screenshots/relations.jpg" width="470" alt="
|
|
45
|
+
<td align="center"><img src="assets/screenshots/relations.jpg" width="470" alt="关系图谱工作台"><br/><em>全屏关系图谱 · 画布与检视面板</em></td>
|
|
50
46
|
<td align="center"><img src="assets/screenshots/settings.jpg" width="470" alt="设置"><br/><em>注入、预算、留存与自动化</em></td>
|
|
51
47
|
</tr>
|
|
52
48
|
<tr>
|
|
@@ -89,8 +85,6 @@
|
|
|
89
85
|
|
|
90
86
|
两条小会话的未达分数回合仍可能因饥饿唤醒;2000 条事件以上的大会话不会。四个会话在真实游标之后都没有新的真人输入,因此不会立即再 fork。
|
|
91
87
|
|
|
92
|
-
714 题完整卷的通过率与实测成本见[基准测试](#基准测试)。
|
|
93
|
-
|
|
94
88
|
## 一个 WebUI
|
|
95
89
|
|
|
96
90
|
侧边栏只留**一个**入口:**MemU WebUI**。记忆墙与全部设置在同一套导航内,支持深链,如 `#/settings/memories`、`#/settings/folders`、`#/settings/stats`。
|
|
@@ -99,9 +93,9 @@
|
|
|
99
93
|
|
|
100
94
|
**原地操作。** 点记忆卡片会从右侧滑出详情抽屉:完整正文,以及决定它行为的字段——标题、正文、标签、说出口径、置信度、未了之事——外加保存、归档、恢复,以及需要重编辑时的「在记忆浏览中打开」。已归档的记忆可以直接在抽屉里删除:第一次点击只是准备,第二次才真正删除。全局记忆在抽屉里只读,并给出跳转。筛选条件与滚动位置保持不动。带图片的卡片会把第一张可用附件作为封面,抽屉里展开完整图片组;`secret` 与 `never_say` 条目不会拿到像素 URL,只显示标签占位。
|
|
101
95
|
|
|
102
|
-
|
|
96
|
+
**图谱单独一页。** 「关系图谱」是 WebUI 里一个全屏页面(`#/settings/graph`):左边画布、右边检视面板,列表视图在同页的**管理**页签下,用的是同一套筛选。来源(全部 / 仅自动 / 仅手动)、规则、记忆库与搜索都在收窄同一份数据,不是要记得切换的模式;设置里的「关系图谱」只有一个按钮,点了直达这一页。范围选择器仍然带一项**全局记忆**:节点是全局条目、边是 `related/refines/supports`,全局视图只读,移除边仍在全局记忆列表里完成。
|
|
103
97
|
|
|
104
|
-
|
|
98
|
+
图谱用的是**自研的连续力导向引擎**,bundle 里没有第三方运行时:模拟一直活着,后台数据刷新保留节点位置与视角,一旦冷下来就不再申请帧,开着图谱不会白吃 GPU。拖动把节点钉在你松手的地方(松手不会被拽回),并且只有你碰到的那一簇继续模拟,其余冻结簇充当障碍物,动的簇无法穿过去。斥力、连线距离、向心力在面板里可调,标签自动避让,缩略图只在主画布重绘后才更新。缩到最小时节点在屏幕上必然会压在一起——间距是世界坐标里的,要拉开簇请用斥力/连线距离,而不是缩放。设置里的「关系图谱」只有一个按钮,点开就是 WebUI 的全屏图谱页,那里还能新增/编辑/删除节点,并按生成这条边的规则筛选。图谱布局只表达已记录的关联,不会推断或写入新的关系。实体可以直接在图谱里删除(仍被引用时会明确拒绝);永久删除一条记忆会连带清理指向它的边与孤立实体,孤立节点有启动扫描自动回收。节点图页还会列出**实体合并候选**(同 kind、名称包含或写法相近):只是建议,两次点击确认;合并把来源实体的记忆链接改指主节点、别名并入,不删除任何记忆。
|
|
105
99
|
|
|
106
100
|
| 页面 | 用途 |
|
|
107
101
|
|---|---|
|
|
@@ -335,11 +329,12 @@ npm run build:graph # 修改图谱源码后重建随包分
|
|
|
335
329
|
node scripts/acceptance-local.mjs # 50 条自动验收
|
|
336
330
|
node scripts/migrate-visibility.mjs # 报告(--apply 才重写)仍存着旧 session 级别的库
|
|
337
331
|
node --import ./tests/loader-register.mjs scripts/preview.mjs --port 7789
|
|
332
|
+
node scripts/make-readme-shots.mjs # 对着上面这个预览重录本文档的截图
|
|
338
333
|
```
|
|
339
334
|
|
|
340
335
|
预览会在隔离示例数据上启动真实 WebUI:`http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories`。
|
|
341
336
|
|
|
342
|
-
预览运行后,可在另一终端执行 `npm run test:graph-browser -- http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories`,验证 200 节点、桌面/窄屏、拖拽、刷新稳定性、主题与加载重试。首次使用需执行 `npx playwright install chromium`;Windows 也可设置 `GRAPH_BROWSER_CHANNEL=msedge` 使用已安装的 Edge。压力数据仅在测试浏览器内拦截,不写入记忆库。图谱运行时不依赖 CDN,
|
|
337
|
+
预览运行后,可在另一终端执行 `npm run test:graph-browser -- http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories`,验证 200 节点、桌面/窄屏、拖拽、刷新稳定性、主题与加载重试。首次使用需执行 `npx playwright install chromium`;Windows 也可设置 `GRAPH_BROWSER_CHANNEL=msedge` 使用已安装的 Edge。压力数据仅在测试浏览器内拦截,不写入记忆库。图谱运行时不依赖 CDN,bundle 内不含第三方运行时代码,这一点记录在 `lib/webui/graph-LICENSE.txt`。
|
|
343
338
|
|
|
344
339
|
测试包含两条可选真实引擎集成用例:curator 写入需设置 `DSH_MEMU_TEST_ENGINE_PYTHON`,备份 venv/WAL 需设置 `DSH_MEMU_BACKUP_REAL_ENGINE=1`,默认按设计跳过;50 条自动验收全部通过。可选引擎已在隔离目录安装并跑通锁定 wheel 的 smoke;embedding 测试使用本机确定性服务,只证明协议可用,不证明语义质量。
|
|
345
340
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -43,4 +43,25 @@
|
|
|
43
43
|
- `tests/client-render.test.mjs` 把 7 个页面和侧边栏各渲染一遍:渲染期抛错或文本出现 `[object Object]` 即失败。
|
|
44
44
|
- WebUI 打开路径只有一条 `openWebUiPage()`(先新标签,被拦截再用应用内 overlay)。**禁止同标签导航兜底**——会卸载宿主 SPA,「返回」变成整页刷新。
|
|
45
45
|
|
|
46
|
+
### 7.6 关系图谱工作台(`lib/webui/graph-view.js` + `GraphStudioPanel`)
|
|
47
|
+
|
|
48
|
+
- **物理不许读相机。** 力导向里的斥力、弹簧原长、硬分离阈值一律用**世界坐标 + 节点半径**;把缩放塞进物理(曾经的 `24 / clamp(viewScale, .06, 5)`)在最小缩放等于要求 400 世界像素间距,节点每帧互推、永不收敛,用户看到的就是「缩到最小后打架 / 闪现」。缩放只影响**绘制**与**命中半径**。`tests/graph-view.test.mjs` 钉死两件事:`setScale` 之类把相机交给物理的入口不许回来,`relayout()` 后位移必须逐窗衰减且不留重合。
|
|
49
|
+
- **改引擎必须重打包。** 浏览器加载的是 `lib/webui/graph-view.bundle.js`,不是源码;`npm run build:graph` 忘了跑,源码修复在真实页面上根本不存在,而单测照绿(它 import 的是源码)。`npm run check` 现在比对两者字节,漂移即红。
|
|
50
|
+
- **冷下来就要零帧。** 渲染循环只在 `layout.active`(alpha 高于地板)或交互期申请下一帧;呼吸微动也只在模拟活着时画。每帧无条件 `requestAnimationFrame` 会让 GPU 占用一路爬升且不回落。
|
|
51
|
+
- **命中判定带迟滞。** 最小缩放下相邻节点在屏幕上只差 1–2px,纯「最近距离」会在两者之间反复跳;`hit(p, prefer)` 必须优先保留上一个目标(`tests/graph-view.test.mjs` 用 1px 抖动断言)。
|
|
52
|
+
- **`is-graph-wide` 只属于独立外壳**(`standalone && page === PAGE.graph`)。那套样式为全屏画布把导航改成 158px 竖排,套到宿主设置页上就会把原本横排的导航整片掰竖。宿主那一页只给一个按钮,点了走 `openWebUiPage('graph')`。
|
|
53
|
+
- **缩到最小节点必然在屏幕上压在一起**:绘制半径有 2.5px 下限,而世界间距不变。这不是 bug,别去动物理补偿;要拉开簇就用「斥力 / 连线距离」滑杆,它们改的才是世界尺度。
|
|
54
|
+
- **缩略图只跟主画布重绘**:`createGraphView` 的 `onPaint` 计数不变就不 `drawImage`,否则缩略图按自己的节奏重画,和主画布对不上。
|
|
55
|
+
- **整理入口不新增 RPC**:「立即整理」= `listSessions`(带 `libraryId`)筛出该库绑定的会话,再逐个调用侧边栏同一个 `generatePrivate`,两段确认。UI 专用的写方法同时也是一条模型能调的写路径,能复用就别新开。
|
|
56
|
+
|
|
57
|
+
### 7.7 合成负载(GPU 占用)
|
|
58
|
+
|
|
59
|
+
WebUI 的 GPU 问题几乎从来不是算力,是**空闲期仍在持续产帧**:合成器每帧有活干,时钟就降不下来(外部实测:开面板 GPU 时钟 765→1950MHz、功耗 29→72W,util 却只有三四成;关面板立刻回落)。
|
|
60
|
+
|
|
61
|
+
- **装饰层不许有无限动画。** 全屏模糊光斑、品牌图标浮动、状态点脉冲这类 `animation: … infinite` 会让合成器永远不睡。要动效只给交互触发的一次性动画;boot 遮罩例外(ready 后 900ms 移除)。`will-change` likewise 不许常驻在装饰层上。
|
|
62
|
+
- **模糊只给小 chrome。** `backdrop-filter` 只允许 topbar 与 boot 卡;rail、卡片、抽屉、全屏遮罩一律不用——背后只要有东西在动,这些面每帧重算模糊,成本相乘。遮罩用纯色 scrim 就够。
|
|
63
|
+
- **缩略图/副画布由主画布 `onPaint` 驱动**,不许自己 `setInterval` 轮询;主画布冷下来不重绘,副画布就一帧不画。
|
|
64
|
+
- **改完要量**:`node scripts/check-idle-compositing.mjs`(先起预览)用 CDP screencast 数帧 + `document.getAnimations()`,空闲 fps > 2 即 FAIL。静态守卫在 `tests/webui.test.mjs` 的 `the shell keeps no always-on compositor drivers`。
|
|
65
|
+
- **对照环境要先验**:若桌面本身被别的进程钉住时钟(不开浏览器也高频),真 GPU 前后对照在那台机器上无效;以帧计数为准,或到「关面板立刻回落」的宿主上复测。
|
|
66
|
+
|
|
46
67
|
---
|
package/docs/contributing.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
1. **定位链路**:先用 §2.2 那条链找到「这个行为在哪一步决定」,再读那个函数,不要从 UI 往下猜。
|
|
10
10
|
2. **最小改动**:一次只改一个语义,schema/文案/UI 不混在一个提交里——出了事无法二分。
|
|
11
|
-
3. **三层验证**(§4.2):语法 → 针对性单测 → 全量 + 验收 +
|
|
11
|
+
3. **三层验证**(§4.2):语法 → 针对性单测 → 全量 + 验收 + 自检。**只跑自己新写的测试不够**,这个仓库多数回归是被别的文件抓到的。改过 `lib/webui/graph-view.js` 的话,验证之前先 `npm run build:graph`:浏览器加载的是 bundle,单测加载的是源码,不重打包就会出现「测试全绿、页面照旧」。
|
|
12
12
|
4. **同步文档**(§4.4)。文档与代码不一致本身就是缺陷:读者照文档做就会出现「做了却不对」。
|
|
13
13
|
|
|
14
14
|
### 4.2 验证三件套
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
node --check lib/<改过的文件>.js # 语法(源码是 ESM,别用 require 试)
|
|
18
18
|
npm test # 全量;真实引擎用例默认跳过
|
|
19
19
|
node scripts/acceptance-local.mjs # 50/50;视觉证据只证明本次已审查,UI 改动仍须重新看图
|
|
20
|
-
npm run check # node --check + i18n 键对齐 + package.json 可解析
|
|
20
|
+
npm run check # node --check + i18n 键对齐 + package.json 可解析 + 文档预算 + 图谱 bundle 漂移
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。文档里出现的测试数字一律当作**带日期的快照**:2026-11-01 实测 1293 tests / 1291 pass / 0 fail / 2 skipped(curator 真实引擎与备份 venv/WAL 两条为 opt-in,按设计跳过);更早的 1287 / 1280 / 1277 / 1273 / 1210 / 505 / 392 / 321 / 327 / 333 等是历史快照或转述,不能当作当前保证。**计时与日期敏感的断言要按「整包并行 + 一天中的任何时刻」写**:`tests/sidebar.test.mjs` 的大库首屏用 1500ms(空载 378–448ms,整包并行曾到 1808ms,500ms 测的是机器的空闲程度),`tests/client-render.test.mjs` 的短条目过期时刻用相对时间(曾 pin 在当天 09:30Z,下午必红)。
|
|
@@ -34,6 +34,7 @@ npm run check # node --check + i18n 键对齐 + package.j
|
|
|
34
34
|
| UI 任何东西 | §7 全部约定、zh/en 两字典、`renderXxxItem` 拆分 | `client-render`、`webui`、`new-session-gate` |
|
|
35
35
|
| 提示词正文 | 各类型页变体、`{{变量}}` 是否都在 vars、`files` 白名单 | `prompts` |
|
|
36
36
|
| 引擎/安装 | Python 顺序、镜像顺序、prune 白名单、备份内容、切换回滚 | `engine`、`backup` |
|
|
37
|
+
| 图谱引擎 `lib/webui/graph-view.js` | 改完必须 `npm run build:graph`:浏览器只加载 `graph-view.bundle.js`,源码修复不重打包等于没修(`npm run check` 比对两者,漂移即红;生产安装没有 esbuild,该项自动 skip) | `graph-view` |
|
|
37
38
|
| 设置项 | `DEFAULT_SETTINGS`、设置页控件、WebUI `settingRow`、反面语义 `invert`、`memoryStamp` 覆盖 | `state`、`config`、`sidebar-beat` |
|
|
38
39
|
| 统计计数 | `bumpStats` 调用点(只有语义动作能加)、90 天裁剪、零值与降级、`getStats` 不建库 | `stats`、`client-render` |
|
|
39
40
|
|
|
@@ -42,6 +43,8 @@ npm run check # node --check + i18n 键对齐 + package.j
|
|
|
42
43
|
| 改动类别 | 要更新的文档 |
|
|
43
44
|
|---|---|
|
|
44
45
|
| 任何行为变化 | `README.md` 的能力/限制段(写「谁受益」不写「改了哪个函数」)+ `docs/troubleshooting.md` §3 对应小节的「会坏在哪」 |
|
|
46
|
+
| UI 界面变化 | 两份 README 的截图也是产物:起预览后 `node scripts/make-readme-shots.mjs` 重录 `assets/screenshots/*.jpg`,并核对图注文字还描述得对(1.3.3 之前就漏过「关系图谱」独立成页,图注仍写着「与邻接列表同视图」) |
|
|
47
|
+
| UI 动效 / 模糊 / 副画布 | 合成负载(§7.7):装饰层不许无限动画、模糊只给小 chrome、副画布由 `onPaint` 驱动;改完跑 `node scripts/check-idle-compositing.mjs` 数空闲帧 | `webui`(静态守卫) |
|
|
45
48
|
| 设计决策 / 取舍 | `README.md` 限制段 + `docs/memory-semantics.md` §8(**只写为什么,不写施工流水**) |
|
|
46
49
|
| 影响验收方式 | 能自动化的进 `scripts/acceptance-local.mjs`,行为级的进 `tests/`;都进不了说明还没想清楚 |
|
|
47
50
|
| 新增能力 / 数据结构 | `README.md` 能力表 + `tests/` 或验收脚本 |
|
package/docs/memory-semantics.md
CHANGED
|
@@ -228,3 +228,20 @@
|
|
|
228
228
|
**可观测性**:`getState` 增加 `recallCache` 段(`hits/misses/evictions/errors/staleSkipped/generations/...`);`staleSkipped` 统计 TTL 过期、代数清理与按 query 失效时被丢弃的缓存条目。
|
|
229
229
|
|
|
230
230
|
守卫:`tests/temporal.test.mjs`、`tests/memory-fields.test.mjs`、`tests/fact-version.test.mjs`、`tests/inject-conflict.test.mjs`、`tests/speaker-provenance.test.mjs`、`tests/commitment.test.mjs`、`tests/query-decompose.test.mjs`、`tests/recall-intent.test.mjs`、`tests/injection-intent-budget.test.mjs`、`tests/memory-chain.test.mjs`。
|
|
231
|
+
|
|
232
|
+
### 8.18 整理执行器(实验功能):fork 与持久 worker
|
|
233
|
+
|
|
234
|
+
**作用**:决定私有记忆整理在后台以什么形态执行。入口是设置 → 记忆维护 →「整理执行器」(带红色「实验功能」标记),键为 `consolidationRunner`:`fork`(默认)或 `worker`。切换从下一窗生效,不需要重启;「恢复默认」回到 `fork`。两条路径写同一套账本与库,回滚不涉及数据迁移(turn-log 只是缓存,账本与库才是权威)。
|
|
235
|
+
|
|
236
|
+
**fork(默认)**:每个整理窗口新建一次后台整理会话,窗口结束即弃。上下文最干净、单窗开销稳定,是现有生产路径与回滚路径。
|
|
237
|
+
|
|
238
|
+
**worker(实验)**:跨窗复用同一个后台 worker 会话。
|
|
239
|
+
|
|
240
|
+
- **换新**:acquire 时按模型上下文分档检查预算——≤128k 上下文 → 120k 字符 / 8 窗,其余 → 200k 字符 / 16 窗;字符预算或窗口上限到顶、scope 变化、空闲超时、回合失败、连续两次超时都会退役换新。
|
|
241
|
+
- **交接**:除 scope 变化外,新 epoch 用交接包接续——已结算尾部(≤20k 字符)+ 已写入摘要(最近 20 条 id + 标题)+ 记忆目录头;未结算的增量仍按窗口原文下发。尾部只是跨窗指代的参考,不是正确性防线;去重仍由目录、已写入摘要与库级去重兜底。
|
|
242
|
+
- **批量写**:任务书要求把本窗新增条目合并成一次 `memu_private_remember_batch`,只有 1 条时才逐条 `remember`,更新也放在同一轮;批量参数畸形时下一轮退回逐条写(`consolidationSingleOnly`),不会把整窗判死。
|
|
243
|
+
- **代价**:worker 的会话内上下文会随窗口累积,token 总量取决于换新节奏;fork 没有这段累积。
|
|
244
|
+
|
|
245
|
+
**边界**:worker 仍运行在父预设的 system prompt 下(宿主没有公开 API 可替换),身份靠任务书缓解而不是消除;工具面只有 remember / remember_batch / update;失败窗口保持 pending,按原有退避重试。
|
|
246
|
+
|
|
247
|
+
守卫:`tests/worker-lifecycle.test.mjs`(分档、预算、退役、交接、工具面)、`tests/settings-coverage.test.mjs`(`consolidationRunner` 可设置且默认值合法)、`tests/ui-defaults.test.mjs`。
|
package/docs/troubleshooting.md
CHANGED
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
鉴权 / 401/403 行为说不清 → §3.20
|
|
36
36
|
本地向量模型装不上 / 切不过去 / 召回 400 → §3.25
|
|
37
37
|
整理超时(fork 预算不够)→ §3.26
|
|
38
|
+
图谱改了没生效 / 缩到最小打架 / 导航被掰竖 → §3.27
|
|
39
|
+
WebUI 开着 GPU 占用高 / 时钟钉高档 → §3.28
|
|
40
|
+
长链跑批库不增长 / 考试大面积「不知道」→ §3.29
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
## 3. 出过的问题:症状 → 落点 → 守卫
|
|
@@ -323,6 +326,35 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
323
326
|
|
|
324
327
|
**守卫**:`tests/consolidation-fork.test.mjs` 的 `the consolidation wait budget scales with the transcript`、`the seed keeps conversation only, renumbers from zero, and strips replay/stream noise`、`a long tail is cut to one closed-turn window with a remainder`、`the same failed snapshot stops re-forking after the failure cap`,以及 `a fork still running at the deadline reports a timeout instead of silence`。
|
|
325
328
|
|
|
329
|
+
### 3.27 关系图谱:改了引擎没生效 / 缩到最小节点打架 / 导航被掰竖
|
|
330
|
+
|
|
331
|
+
**症状**:三种都来自 1.3.2→1.3.3 这一段。① 明明改了 `lib/webui/graph-view.js`,页面行为一点没变;② 进入关系图谱、缩到最小、点「重新布局」,节点开始互相顶、位置反复闪;③ 在宿主设置页点「关系图谱」,左侧导航整片变成 158px 竖排。
|
|
332
|
+
|
|
333
|
+
**落点**:
|
|
334
|
+
- ①**产物不同步**。图谱引擎是全仓库唯一有构建产物模块:浏览器注入的是 `lib/webui/graph-view.bundle.js`,而 `tests/graph-view.test.mjs` import 的是**源码**——所以「测试全绿 + 页面照旧」是这条路的特征签名。改完必须 `npm run build:graph`;`npm run check` 的 `graph bundle` 项比对两者字节,漂移即红(生产安装没有 esbuild,该项自动 skip,不算失败)。
|
|
335
|
+
- ②**缩放被塞进了物理**。硬分离阈值当年写成 `24 / clamp(viewScale, .06, 5)`:k=.06 时等于命令每对节点保持 400 世界像素,弹簧与斥力在 alpha 落地板后已经没了,于是每帧只剩分离力在互推,整图永远收敛不了。现在阈值只看世界坐标与节点半径(`own = radius + 8`,`minSep = own + other.radius`),重合到 `<.01` 时用 id 哈希给确定方向岔开;`relayout()` 同时重记弹簧原长,否则新位置配旧原长,松手后又拉回一团。`viewScale`/`setScale` 已删——物理拿不到相机才是根本解。
|
|
336
|
+
- ③**全屏外壳没分家**。`.dshm-root.is-graph-wide` 是为独立 WebUI 的全屏画布写的,判定要 `standalone && page === PAGE.graph`;只看 page 就会连宿主设置页一起改竖排。
|
|
337
|
+
|
|
338
|
+
**用户侧的取舍**:缩到最小(k=.06)时整图只占几十像素,绘制半径有 2.5px 下限,**屏幕上必然压在一起**,这不是还在打架——判据是「位移是否逐窗衰减到 0」。要真的拉开簇,用「斥力 / 连线距离」滑杆,它们改的是世界尺度。
|
|
339
|
+
|
|
340
|
+
**守卫**:`tests/graph-view.test.mjs` 的 `relayout cools down and separates instead of shoving nodes forever`(位移逐窗衰减 + 零重合 + 物理拿不到相机)、`a cooled layout stops requesting frames even while motion is enabled`(冷下来零帧,GPU 不再爬升)、`hover keeps its target through 1px jitter at minimum zoom`(命中迟滞);`tests/client-render.test.mjs` 的 `the immersive graph shell stays with the standalone WebUI`(宿主页保持横排 + 一个入口按钮)。`npm run check` 的 `graph bundle` 拦产物漂移。
|
|
341
|
+
|
|
342
|
+
### 3.28 WebUI 开着 GPU 占用高 / 时钟钉在高档 / 风扇转
|
|
343
|
+
|
|
344
|
+
**症状**:打开 WebUI 后 Electron/浏览器 GPU 进程占用翻倍、GPU 时钟从低频钉到接近满载、功耗上涨,而利用率并不高;关掉面板立刻回落,可重复。典型读数(外部测试者,1.3.3):GPU 12.7%→24.8%,时钟 765→1950MHz(满 2100),功耗 29→72W,util 仅 37–44%。**这是持续合成,不是算力占用**:合成器每帧都有活干,时钟就降不下来。
|
|
345
|
+
|
|
346
|
+
**落点**(1.3.3 实测,按贡献排):
|
|
347
|
+
- **装饰层的无限动画**。`standalone.css` 的 `.ambient i` 曾是全屏 `filter: blur(74px)` + `will-change: transform` + `ambient-drift 52s infinite alternate`:一个永远在动的全屏模糊层,合成器永远不睡。同族还有 `.brand-icon` 的 `brand-float 7s infinite`、`.sync-pill i` 的 `dot-pulse 2.8s infinite`。实测空闲产帧 ~99fps,`document.getAnimations()` 列出 5 条 running;**图谱页冷却后也照跑**,因为光斑层在整页背后。
|
|
348
|
+
- **大面 backdrop-filter**。抽屉遮罩 `.dshm-drawer-backdrop` 的全屏 `blur(3px)`、独立壳的 rail / 卡片 / 抽屉 `blur(16–22px)`:背后只要有东西在动(上一条),这些面每帧都要重算模糊,成本相乘。
|
|
349
|
+
- **缩略图轮询**。`GraphStudioMinimap` 曾 `setInterval(paint, 600)`;即使加了「主画布没重绘就不拷贝」的闸门,定时器本身仍常开。现改由主画布 `onPaint` 直接驱动,零定时器。
|
|
350
|
+
- 心跳 `useMemoryBeat` **不是**元凶:marker 不变就 return,不会每 2.5s 重渲染(外部猜测的第 3 条在当前代码不成立)。
|
|
351
|
+
|
|
352
|
+
**现在**:装饰层静态(光斑保留观感、去掉动画与 will-change);模糊只留在小 chrome(topbar)与 boot 卡(boot 900ms 后移除);抽屉遮罩改纯色 scrim;缩略图由 `onPaint` 驱动。实测同三态空闲产帧 99fps → **0.2fps(6 秒 1 帧)**,running 动画清单为空。
|
|
353
|
+
|
|
354
|
+
**怎么自己量**:`node scripts/check-idle-compositing.mjs`(先起预览)用 CDP screencast 数帧 + `document.getAnimations()`;空闲 fps > 2 即 FAIL。**注意对照环境**:若桌面本身被别的进程钉住时钟(本机对照:不开浏览器也 2250MHz),真 GPU 的前后对照在这台机器上无效,要以帧计数为准,或到「关面板立刻回落」的那台宿主上复测。
|
|
355
|
+
|
|
356
|
+
**守卫**:`tests/webui.test.mjs` 的 `the shell keeps no always-on compositor drivers`(无限动画只许出现在 boot;ambient 不许 will-change/animation;backdrop-filter 只许 topbar/boot-card;共享 UI 不许全屏模糊;缩略图不许轮询)+ `scripts/check-idle-compositing.mjs` 真机数帧。
|
|
357
|
+
|
|
326
358
|
|
|
327
359
|
## 守卫索引表
|
|
328
360
|
|
|
@@ -357,6 +389,8 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
357
389
|
| §3.24 | 失败一轮后锚点/日期再不出现 | `tests/injection-rollback.test.mjs`(6 条:撤回+重投、completed 不重复、迟到事件撤不动、已进转录的 500 类失败不误撤、投放前取消撤回、纪念日复提时钟一起撤)。 |
|
|
358
390
|
| §3.25 | 本地向量模型装不上 / 切不过去 / 召回 400 | `tests/embedding-catalog.test.mjs`(三条目指纹钉死、只有非对称前缀需要角色通道)、`tests/local-embedding-protocol.test.mjs`、`tests/local-embedding-worker.test.mjs`(前缀进推理、裸 id 拒且不入推理)、`tests/local-embedding-env.test.mjs`(对称模型 model 串逐字节不变)。 |
|
|
359
391
|
| §3.26 | 整理超时(fork 预算) | `tests/consolidation-fork.test.mjs`:预算随事件数缩放(0/100/200/935/5000/非法值),显式 `maxWaitMs` 仍生效,超时不推进 `lastSleepSeq`。 |
|
|
392
|
+
| §3.27 | 图谱改了没生效 / 缩到最小打架 / 导航被掰竖 | `npm run check` 的 `graph bundle`(源码与 bundle 逐字节比对);`tests/graph-view.test.mjs` 的 relayout 收敛、冷启动零帧、最小缩放命中迟滞;`tests/client-render.test.mjs` 的独立外壳归属。 |
|
|
393
|
+
| §3.28 | WebUI 开着 GPU 占用高 / 时钟钉高档 | `tests/webui.test.mjs` 的 `the shell keeps no always-on compositor drivers`(无限动画只许 boot、ambient 静态、模糊只许小 chrome、缩略图不轮询);`scripts/check-idle-compositing.mjs` 真机数帧(空闲 fps > 2 即 FAIL)。 |
|
|
360
394
|
|
|
361
395
|
## 附录 A · 模块地图(原 §2.1)
|
|
362
396
|
|
|
@@ -475,6 +509,8 @@ section 的 `text(context)` 能拿到 `context.agent`,所以 system prompt **
|
|
|
475
509
|
8. **不碰共享 `/api`**:RPC 只走 `/dsh-memu-memory` 前缀(`webServer.register` + `connection.requestRejection`)。
|
|
476
510
|
9. **日志与提示词里不放 API key。**
|
|
477
511
|
10. **注入失败 fail-open,但必须留可观测信号。** 抛错不许改变宿主的 turn 错误语义(吞掉是允许的),代价是真实故障一起被吞:`inject.js` 若把 pre-step 的 `agent` 当 `exec` 传给 `buildRecall`(正确形状 `{ agent }`,§6.3),`no bound session` 就只被空 catch 吃掉——**每回合召回静默失效、只剩锚点、日志一个字都没有**。所以 fail-open 必配 `logger.warn` + binding 上的 `lastRecallError`(侧边栏可见),单测断言**召回到的 id**,不能只断言「消息插进去了」。**不能靠「没报错就是好了」。**
|
|
512
|
+
11. **跑批与复测的输出一律重定向文件**(`> logs/x.log 2>&1`),禁用 `| tail` 管道——管道只留尾巴,故障段不可回查。清理宿主数据必须先确认宿主进程完全退出(活宿主的内存态会回写覆盖清理结果)。
|
|
513
|
+
12. **整理快照必须做持久日志交叉核对**:`captureSessionSnapshot` 的活视图(observeSession/readSession)落后于持久日志时,用 `sessionPersistence` + `readColdSessionLog` 冷读并取更长的日志(source `persisted-ahead`);只信活视图 = 外部追加不可见 → 快照冻结/整理洪水。`host`/`custom` 模型模式也不得探测父会话 route(resume 会把父会话钉成活视图)。成因链与排错路线 → §3.29。
|
|
478
514
|
|
|
479
515
|
---
|
|
480
516
|
|
|
@@ -530,3 +566,11 @@ section 的 `text(context)` 能拿到 `context.agent`,所以 system prompt **
|
|
|
530
566
|
- **实体确认后没有提及边**:确认只匹配已确认实体的名字/别名;检查名字是否 <2 字、记忆是否 archived/pending_review/secret、实体是否 archived(archived 不可确认)、抑制表是否有同名 (from,to,kind) 键(删过的边会写 `|*` 通配,换 rule 也不复活)、以及 `autoLinkMode` 是否为 `off`(off 连确认也不写)。worker 通过 `memu_private_link` 新建的实体默认 provisional,需要用户在审核区确认。
|
|
531
567
|
- **worker 没裁决不确定候选**:`memu_private_link_suggest` 现在只刷新确定性边并返回统计候选卡,不自动连;worker 未调用或证据不足就保持不连(宁漏勿错)。`lib/private.js` 的结算兜底同样只跑确定性判定,不会把统计候选偷偷连上。自动关联失败只写 warn,不影响整理成功。
|
|
532
568
|
- **要不要数据库/向量重算**:自动关联只是 `links[]` 元数据,不改正文、不写向量;移除边不会触发重建。实体删除仍按既有规则(有引用时需显式 force,避免悬空)。
|
|
569
|
+
|
|
570
|
+
### 3.29 长链跑批整库不增长 / 考试大面积「不知道」(S7 整理 → S1 快照冻结 → S3 账本洪水)
|
|
571
|
+
|
|
572
|
+
**症状**:persona 全链复测通过率腰斩;失败判分理由几乎全是「答不知道、否认已有事实」(无编造/越界);库条数远低于全链累积预期(实测 59 ck 只写出 4 条,涉事事实关键词全零命中)。
|
|
573
|
+
|
|
574
|
+
**根因(2026-11-14 复现实测)**:跑批脚本的 `seed-session.mjs` **直接重写** `session.v4.jsonl.zstd` 追加历史(不走网关 RPC)。宿主的 `observeSession`/`readSession` 都是 live-preferred:会话一旦是活对象,两者都读活视图、不再看持久日志,外部改写完全不可见。把种子会话钉成活对象的是 inherit 模式的 `inheritedAgentOptions` resume 回退;`host`/`custom` 模式本不需要父 route,旧代码却照样探测。于是追加 372 轮后活视图仍冻结在 6 事件 → 每窗恒等 → already-consolidated 洪水 → 游标不推进。**连带**:turn-log 录制器只收 `session/event`,直接改文件同样看不到。跑批侧 `consolidateAll` 又把 already-consolidated 当完成,不校验 `throughSeq`,把可检测故障变成静默腰斩。
|
|
575
|
+
|
|
576
|
+
**守卫**:`captureSessionSnapshot` 在活视图落后于持久日志时,用 `sessionPersistence` + 宿主公开导出的 `readColdSessionLog` 冷读,取更长的一份(source `persisted-ahead`;60 秒 TTL 缓存,正常活会话不受影响)。`consolidationModelMode` 为 `host`/`custom` 时不探测父会话 route,避免无意义 resume。跑批的 `consolidateAll` 对 skipped 结果校验 `through >= targetSeq`,连续 3 次落后判定 `stale` 并终止本轮。
|
|
@@ -54,9 +54,9 @@ export const RUNTIME_STATE = Object.freeze([
|
|
|
54
54
|
{ layer: 'temporary-map', file: 'lib/inbound.js:13', name: 'calls', keyedBy: 'sessionId', clearedBy: 'tool/result or turn/end' },
|
|
55
55
|
{ layer: 'temporary-map', file: 'lib/inbound.js:14', name: 'sessions', keyedBy: 'sessionId', clearedBy: 'session/disposed (releaseInboundSession)' },
|
|
56
56
|
{ layer: 'temporary-map', file: 'lib/media.js:19', name: 'captures', keyedBy: 'sessionId', clearedBy: 'capture settle' },
|
|
57
|
-
{ layer: 'temporary-map', file: 'lib/private.js:
|
|
57
|
+
{ layer: 'temporary-map', file: 'lib/private.js:982', name: 'inFlight', keyedBy: 'sessionId', clearedBy: 'consolidation settle' },
|
|
58
58
|
{ layer: 'temporary-map', file: 'lib/curator.js:56', name: 'jobs', keyedBy: 'job id', clearedBy: 'curation settle' },
|
|
59
|
-
{ layer: 'cache', file: 'lib/state.js:
|
|
59
|
+
{ layer: 'cache', file: 'lib/state.js:1230', name: 'indexCache', keyedBy: 'libraryId', clearedBy: 'next load / external write' },
|
|
60
60
|
{ layer: 'cache', file: 'lib/paths.js:52', name: 'readFailures', keyedBy: 'absolute file', clearedBy: 'a later successful read' },
|
|
61
61
|
])
|
|
62
62
|
|