dsh-memu-memory 1.2.2 → 1.2.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 +4 -1
- package/README.md +12 -16
- package/README.zh.md +13 -17
- package/docs/client-conventions.md +2 -0
- package/docs/contributing.md +7 -6
- package/docs/emotion-model-spec.md +2 -2
- package/docs/env-and-commands.md +63 -1
- package/docs/host-api.md +19 -0
- package/docs/memory-semantics.md +10 -1
- package/docs/troubleshooting.md +77 -3
- package/lib/activity-log.js +1 -1
- package/lib/binding-diagnostics.js +1 -1
- package/lib/client.js +223 -19
- package/lib/cycle.js +9 -1
- package/lib/embedding-catalog.js +416 -138
- package/lib/embedding-download.js +36 -11
- package/lib/freshness.js +97 -0
- package/lib/graph.js +244 -2
- package/lib/inject.js +218 -11
- package/lib/local-embedding-manager.js +3 -2
- package/lib/local-embedding-protocol.js +40 -3
- package/lib/local-embedding-worker.js +36 -6
- package/lib/local-vector-service.js +18 -4
- package/lib/memory.js +83 -17
- package/lib/memu.js +15 -7
- package/lib/private.js +25 -5
- package/lib/rpc.js +17 -3
- package/lib/salient-wake.js +402 -0
- package/lib/state.js +173 -1
- package/package.json +3 -2
- package/scripts/drive-session.mjs +864 -0
- package/scripts/mock-llm.mjs +903 -0
- package/scripts/simulate-injection.mjs +298 -0
- package/tests/client-render.test.mjs +69 -2
- package/tests/consolidation-fork.test.mjs +14 -1
- package/tests/drive-session.test.mjs +152 -0
- package/tests/embedding-catalog.test.mjs +116 -8
- package/tests/embedding-download.test.mjs +97 -2
- package/tests/embedding-runtime.test.mjs +21 -13
- package/tests/entity-merge.test.mjs +261 -0
- package/tests/fixtures/mock-llm/reply.txt +1 -0
- package/tests/freshness.test.mjs +140 -0
- package/tests/help-page.test.mjs +4 -4
- package/tests/injection-chain.test.mjs +176 -0
- package/tests/injection-rollback.test.mjs +230 -0
- package/tests/local-embedding-env.test.mjs +51 -0
- package/tests/local-embedding-manager.test.mjs +18 -0
- package/tests/local-embedding-protocol.test.mjs +28 -2
- package/tests/local-embedding-worker.test.mjs +94 -0
- package/tests/mock-llm.test.mjs +225 -0
- package/tests/open-loop-date.test.mjs +406 -0
- package/tests/salient-wake.test.mjs +362 -0
- package/tests/settings-plumbing.test.mjs +76 -0
- package/tests/sidebar.test.mjs +5 -1
- package/tests/simulate-injection.test.mjs +76 -0
- package/tests/stubs/dsh-schedule.js +105 -0
- package/tests/vector-profile.test.mjs +28 -4
- package/tests/webui-auth.test.mjs +4 -0
package/AGENTS.md
CHANGED
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
保存成功但没变 / 字段改不回来 → T3.15 记忆凭空消失 / 侧边栏空 → T3.17
|
|
49
49
|
弹窗选了却两侧都勾上 → T3.16 聊很久一条记忆都没写 → T3.18
|
|
50
50
|
人格预设会话里完全没有记忆 → T3.19 鉴权 401/403 说不清 → T3.20
|
|
51
|
+
日期到点没唤醒 → T3.21 时效提示没出现 → T3.22
|
|
52
|
+
实体合并 / 怕丢记忆 → T3.23
|
|
53
|
+
失败一轮后锚点/日期没了 → T3.24
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
---
|
|
@@ -61,7 +64,7 @@ node scripts/acceptance-local.mjs # 50/50
|
|
|
61
64
|
npm run check # node --check + i18n + package.json + 文档预算
|
|
62
65
|
```
|
|
63
66
|
|
|
64
|
-
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。测试数字只作**带日期快照**引用(2026-11-01 实测
|
|
67
|
+
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。测试数字只作**带日期快照**引用(2026-11-01 实测 1293 tests / 1291 pass / 0 fail / 2 skipped;两条真实引擎用例按设计跳过,历史 1291/1287/1280/1277/1273/1210/505/493/463/409/392 等不再代表当前),不当成当前保证。提交前逐条对 `docs/contributing.md` §10。
|
|
65
68
|
|
|
66
69
|
---
|
|
67
70
|
|
package/README.md
CHANGED
|
@@ -30,7 +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.2.
|
|
33
|
+
> **Status:** 1.2.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.
|
|
34
34
|
|
|
35
35
|
## Screenshots
|
|
36
36
|
|
|
@@ -107,13 +107,13 @@ The sidebar has exactly **one** entry: **MemU WebUI**. The memory wall and all s
|
|
|
107
107
|
|
|
108
108
|
**Graph and list together.** The **Relations** tab renders the graph canvas and the adjacency list side by side (stacked on narrow screens), with the focus selector above them and link/entity/relationship tools below. There is no mode switch to forget.
|
|
109
109
|
|
|
110
|
-
The locally bundled D3 force layout preserves positions and the camera across background data refreshes. Drag nodes, pan the background, zoom with the wheel or pinch, fit the graph, and highlight neighbors. Labels avoid collisions; graph settings adjust repulsion, link distance, labels and live layout. Layout only visualizes recorded links: it never infers or writes relationships.
|
|
110
|
+
The locally bundled D3 force layout preserves positions and the camera across background data refreshes. Drag nodes, pan the background, zoom with the wheel or pinch, fit the graph, and highlight neighbors. Labels avoid collisions; graph settings adjust repulsion, link distance, labels and live layout. 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.
|
|
111
111
|
|
|
112
112
|
| Page | What it is for |
|
|
113
113
|
|---|---|
|
|
114
|
-
| Memories | Private/global grouped wall, source/status/library/preview, in-place drawer, multi-select bulk ops,
|
|
114
|
+
| Memories | Private/global grouped wall, source/status/library/preview, in-place drawer, multi-select bulk ops, node graph tab |
|
|
115
115
|
| Engine & connection | Optional MemU engine install/switch, embedding endpoint, backups and restore |
|
|
116
|
-
| Memory settings | Injection mode, token budgets, topK, relevance threshold, retention, automation |
|
|
116
|
+
| Memory settings | Injection mode, token budgets, topK, relevance threshold, retention, open-loop cadence, freshness hint, date wake-up, automation |
|
|
117
117
|
| Folders | Folder-level private/global ceiling, expandable conversations and their own switches |
|
|
118
118
|
| Libraries | Create, rename, archive, restore, explicitly delete libraries |
|
|
119
119
|
| Memory browser | Full-text editing, attachments, review queue, graph and bounded canvas, JSON/ZIP import/export |
|
|
@@ -127,6 +127,12 @@ Settings save as you change them (250 ms debounce), with about 2.5 s cross-windo
|
|
|
127
127
|
|
|
128
128
|
`anchorTokens` and `turnTokens` bound anchor and recall content independently (default 800 each). `injectionTotalTokens` caps the whole plugin message (default 2000); it does not replace the recall budget. Title cards spend far fewer tokens per entry than full text, so the same budget exposes more memories; the budget itself was deliberately not increased in 1.2.2.
|
|
129
129
|
|
|
130
|
+
### Time-sensitive memory (1.2.3)
|
|
131
|
+
|
|
132
|
+
- **Stale recall says so.** When recalled entries carry a time signal (a one-off date already in the past, wording like "latest / current / price / version", or an entry older than `freshnessDays`), one conditional line is appended after the recall block telling the model to verify with a search tool *if the conversation has one*. It never claims a tool exists, and it is dropped rather than pushing recall over budget.
|
|
133
|
+
- **Dated promises keep asking.** An `open_loop` memory whose `YYYY-MM-DD` has passed is re-raised every `openLoopRemindDays` (default 7) with its date and how late it is — undated promises keep the old "quiet after one mention" behaviour. Closing a loop is always the user's action.
|
|
134
|
+
- **Optional wake-up call.** `salientWake` (default **off**) schedules a one-shot host task per bound conversation so a salient date is spoken about on the day, even if the conversation went cold. The delivered turn carries its own text — recall and anniversary blocks do not run there — and the tasks are visible in the host's schedule UI. Requires the host process to be running; experimental until verified on a real install.
|
|
135
|
+
|
|
130
136
|
### Domain Prompts
|
|
131
137
|
|
|
132
138
|
Resident guidance, writing policies and consolidation prompts follow the current session domain. Local tools and remote JSON consolidation share the domain body, with separate supported output contracts. New conversations default to RP; Coding, Mixed and custom pages stay enabled and can be selected per conversation. The new-conversation memory prompt also offers the four memory domains, so a coding session can be started in an RP workspace without remembering to change the sidebar afterwards.
|
|
@@ -354,20 +360,10 @@ With the preview running, use `npm run test:graph-browser -- http://127.0.0.1:77
|
|
|
354
360
|
|
|
355
361
|
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.
|
|
356
362
|
|
|
357
|
-
## Changelog
|
|
358
|
-
|
|
359
|
-
**1.2.2 (2026-11-01)**: title-card anchor/recall (id + title + semantic tags, body behind recall), automatic lexicon lifecycle and card management, private auto-links/entity hubs, help page v2, and WebUI layout/selector polish; together with the previously unreleased curator three-stage pipeline, global links, absorb/undo, review modes and lexicon store baseline. Prompt contracts are unified (remote curation stays tool-free, title 8–40 characters), the PTC worker mounts 5 write + 3 read tools, and no new dependencies or build steps were added.
|
|
360
|
-
|
|
361
|
-
**1.2.1 (2026-10-31)**: fact-level dedup (write-side gate + recall-side cluster folding); consolidation now works in PTC (run_code) sessions; sidebar consolidation-failure alerts (cross-session, clearable, jump-to-library); the "currently in vector store" count follows real additions and deletions; private/global groups and multi-select bulk ops on the memory wall; one-click view from the global page; graph delete cascades with orphan-entity cleanup; remote consolidation counts only what actually landed.
|
|
362
|
-
|
|
363
|
-
**1.1.3 (2026-10-30)**: managed local vectors are usable end to end (runtime/model download, switch-and-rebuild, progress with per-item failures); activity log with a Logs page; consolidation results move under the sidebar button; archive/restore and list refresh drop from seconds to milliseconds; a date written in the text is picked up when the field is empty; default topK 5/5; fixes the blank settings/WebUI panel (React #310).
|
|
364
|
-
|
|
365
|
-
**1.1.2 (2026-10-29)**: anchor and recall delivery in agent-preset conversations; startup catch-up consolidation; panel TDZ crash fix.
|
|
366
|
-
|
|
367
|
-
Full notes: [`CHANGELOG.md`](CHANGELOG.md).
|
|
368
|
-
|
|
369
363
|
## Documentation
|
|
370
364
|
|
|
365
|
+
- Release notes: [`CHANGELOG.md`](CHANGELOG.md)
|
|
366
|
+
|
|
371
367
|
[`AGENTS.md`](AGENTS.md) is the index for anyone changing this repo — which file answers
|
|
372
368
|
which question. The detail lives in [`docs/`](docs/): failure modes, the change process,
|
|
373
369
|
the host facts, and the UI, memory and environment rules.
|
package/README.zh.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
> [!WARNING]
|
|
31
31
|
> **早期版本提示。** 本插件仍处于早期阶段,可能存在无法预见的错误、bug 或不兼容变更。请先备份数据;欢迎[提交 Issue](https://github.com/Tkingxiao/dsh-memu-memory/issues) 或 PR 帮助改进。
|
|
32
32
|
|
|
33
|
-
> **状态:** 1.2.
|
|
33
|
+
> **状态:** 1.2.4。首个公开发布版本为 1.0.0。细节文档已迁到 [`docs/`](docs/),[`AGENTS.md`](AGENTS.md) 只做索引。升级前请备份 `~/.dsh/dsh-memu-memory`;如果要存无法重建的数据,请先读[兼容性与边界](#兼容性与边界)。
|
|
34
34
|
|
|
35
35
|
## 界面
|
|
36
36
|
|
|
@@ -103,15 +103,15 @@
|
|
|
103
103
|
|
|
104
104
|
**原地操作。** 点记忆卡片会从右侧滑出详情抽屉:完整正文,以及决定它行为的字段——标题、正文、标签、说出口径、置信度、未了之事——外加保存、归档、恢复,以及需要重编辑时的「在记忆浏览中打开」。已归档的记忆可以直接在抽屉里删除:第一次点击只是准备,第二次才真正删除。全局记忆在抽屉里只读,并给出跳转。筛选条件与滚动位置保持不动。带图片的卡片会把第一张可用附件作为封面,抽屉里展开完整图片组;`secret` 与 `never_say` 条目不会拿到像素 URL,只显示标签占位。
|
|
105
105
|
|
|
106
|
-
**关系图与邻接列表一起看。**
|
|
106
|
+
**关系图与邻接列表一起看。** 「节点图」页签把关系画布与邻接列表并排显示(窄屏上下堆叠),焦点选择在上方,建边/实体/关系状态工具在下方;没有需要记得切换的模式。
|
|
107
107
|
|
|
108
|
-
图谱使用本地打包的 D3
|
|
108
|
+
图谱使用本地打包的 D3 力导向布局,后台数据刷新保留节点位置与视角。支持拖拽节点、空白处平移、滚轮/双指缩放、适应全图与关联高亮;标签自动避让,设置中可调整斥力、连线距离,以及关闭标签或动态布局。图谱布局只表达已记录的关联,不会推断或写入新的关系。实体可以直接在图谱里删除(仍被引用时会明确拒绝);永久删除一条记忆会连带清理指向它的边与孤立实体,孤立节点有启动扫描自动回收。节点图页还会列出**实体合并候选**(同 kind、名称包含或写法相近):只是建议,两次点击确认;合并把来源实体的记忆链接改指主节点、别名并入,不删除任何记忆。
|
|
109
109
|
|
|
110
110
|
| 页面 | 用途 |
|
|
111
111
|
|---|---|
|
|
112
|
-
| MemU 记忆 |
|
|
112
|
+
| MemU 记忆 | 私有/全局分组记忆墙、来源/状态/库名/预览、原地详情、多选批量操作、节点图统一视图 |
|
|
113
113
|
| 引擎与连接 | 可选 MemU 引擎的安装与切换、embedding 配置、备份恢复 |
|
|
114
|
-
| 记忆设置 | 注入模式、token 预算、topK
|
|
114
|
+
| 记忆设置 | 注入模式、token 预算、topK、相关度下限、留存、未了之事复提节奏、时效提示、日期唤醒、自动化 |
|
|
115
115
|
| 文件夹 | 文件夹级私有/全局上限,展开对话修改各自选择 |
|
|
116
116
|
| 记忆库 | 新建、改名、归档、恢复、显式删除 |
|
|
117
117
|
| 记忆浏览 | 全文编辑、附件、复核池、有界图谱、JSON/ZIP 导入导出 |
|
|
@@ -125,6 +125,12 @@
|
|
|
125
125
|
|
|
126
126
|
`anchorTokens` 与 `turnTokens` 分别约束锚点与召回内容(均默认 800)。`injectionTotalTokens` 限制整条 plugin 消息(默认 2000),不替代召回预算。
|
|
127
127
|
|
|
128
|
+
### 带时间的记忆(1.2.3)
|
|
129
|
+
|
|
130
|
+
- **召回过时会说一句。** 进入本回合的召回条目若带时间敏感信号——一次性日期已经过了、标题/正文里有「最新 / 现在 / 价格 / 版本」这类词、或条目年龄超过 `freshnessDays`——就在召回块尾追加一行**条件式**提示:「会话里有可用的搜索工具就先核实,没有就如实说明可能过时」。它不声称工具一定存在;预算装不下时丢提示,召回照常。
|
|
131
|
+
- **带日期的约定会再问一次。** `open_loop` 条目的 `YYYY-MM-DD` 过期后,每隔 `openLoopRemindDays`(默认 7 天)重新提一次,并带上日期与「已经过了」;没日期的承诺保持原样(提过一次就静默)。闭环永远由用户来做。
|
|
132
|
+
- **可选的到点唤醒。** `salientWake`(默认**关闭**)会让插件通过宿主的定时任务,在日子当天把绑定会话唤醒并开一整轮。那一回合只带唤醒正文本身(召回与纪念日块不会运行),任务在宿主的定时任务界面可见、需要宿主进程活着。属实验特性,真机验证前保持默认关闭。
|
|
133
|
+
|
|
128
134
|
### 领域提示词
|
|
129
135
|
|
|
130
136
|
常驻指南、写入策略和整理提示词按当前会话领域选择;本地工具整理和远程 JSON 整理共用领域正文,各自使用实际支持的输出协议。新会话默认 RP;Coding、Mixed 与自定义页保持启用,可按会话选择。新会话的记忆弹窗里也能直接选这四个记忆领域,在 RP 工作区里开写代码的对话不必事后再去侧边栏切换。
|
|
@@ -340,20 +346,10 @@ node --import ./tests/loader-register.mjs scripts/preview.mjs --port 7789
|
|
|
340
346
|
|
|
341
347
|
测试包含两条可选真实引擎集成用例:curator 写入需设置 `DSH_MEMU_TEST_ENGINE_PYTHON`,备份 venv/WAL 需设置 `DSH_MEMU_BACKUP_REAL_ENGINE=1`,默认按设计跳过;50 条自动验收全部通过。可选引擎已在隔离目录安装并跑通锁定 wheel 的 smoke;embedding 测试使用本机确定性服务,只证明协议可用,不证明语义质量。
|
|
342
348
|
|
|
343
|
-
## 更新日志
|
|
344
|
-
|
|
345
|
-
**1.2.2(2026-11-01)**:锚点/召回改为标题卡(正文留在 recall 工具与抽屉);词典自动入库与卡片管理;私有自动关联/实体枢纽;帮助页 v2;WebUI 布局与选择器优化;并合并此前未单独发布的 curator 三段式、全局关联、absorb 撤销、审核模式与词典库基线。远程整理提示词保持无工具、标题统一 8–40 字;PTC worker 挂载 5 写 + 3 读工具;无新增依赖或构建步骤。
|
|
346
|
-
|
|
347
|
-
**1.2.1(2026-10-31)**:事实级去重(写入近似门 + 召回按簇折叠);PTC(run_code)会话整理可用;侧边栏整理失败提醒(跨会话、可清除、可跳转);「当前已入向量库」计数跟随真实增减;记忆墙私有/全局分组与多选批量操作;全局记忆一键查看;关系图删除级联与孤儿回收;整理写入计数说真话。
|
|
348
|
-
|
|
349
|
-
**1.1.3(2026-10-30)**:受管本地向量可用(运行时/模型下载、切换重建、进度与失败明细);活动日志与「日志」页;整理结果落到侧边栏按钮下方;归档/还原与列表刷新提速到毫秒级;日期漏填时从正文兜底;默认 topK 5/5;修复设置/WebUI 白屏。
|
|
350
|
-
|
|
351
|
-
**1.1.2(2026-10-29)**:人格预设会话的锚点与召回送达;启动补扫空闲整理;面板 TDZ 崩溃修复。
|
|
352
|
-
|
|
353
|
-
完整记录见 [`CHANGELOG.md`](CHANGELOG.md)。
|
|
354
|
-
|
|
355
349
|
## 文档
|
|
356
350
|
|
|
351
|
+
- 版本记录:[`CHANGELOG.md`](CHANGELOG.md)
|
|
352
|
+
|
|
357
353
|
[`AGENTS.md`](AGENTS.md) 是给改这个仓库的人的索引:哪个问题去哪份文件。
|
|
358
354
|
细节在 [`docs/`](docs/):排错、改动流程、宿主事实,以及 UI、记忆语义与环境规则。
|
|
359
355
|
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
- 动作按钮 = `Button`(`.dshm-btn`,**必须透传 `title`**,漏掉整个界面的悬浮提示静默失效);开关 = `Toggle`;行内删除/关闭 = `.dshm-x`。
|
|
24
24
|
- `<button>` 里**不许**再嵌 `role="button"`(键盘够不到)。
|
|
25
25
|
- 破坏性操作 = **二次点击**(文案变「确认…?」,2.5s 复原),不用 `globalThis.confirm`、不用 modal。
|
|
26
|
+
- **算法给的候选(实体合并、关联建议)只显示、永不自动执行**:列表来自只读 RPC,逐条二次点击确认才写;操作后用一行回执说清影响面(`S.muted` + `V.accent`,自清),数字取 RPC 返回值,**不估算**。参考节点图页的合并候选(`docs/memory-semantics.md` §8.14)。
|
|
27
|
+
- **失败只在 WebUI「全部日志」标红**:活动日志三档 = 失败(`ok===false` 或 `level==='error'`)/ 降级(`level==='warn'` 且没失败)/ 常规,判据集中在 `logRowState`;总日志页用作用域 CSS `.dshm-logrow.is-failed` / `.is-degraded`,并且**同时给文字 Tag**(`logStateFailed`/`logDegraded` + hover 说明)——颜色不能是唯一通道。**侧栏「整理记录」不放失败行**(它只显示正常流水;失败由上方跨会话的「整理提醒」负责,别在两处重复标红),所以侧栏既不过 `logRowClass` 也不上色。判据别写成只看 `level==='error'`:整理超时记的是 `warn + ok=false`,那样失败会长得和正常行一样(真出过)。
|
|
26
28
|
- 设置项 = 即时保存 + 250ms trailing debounce,一次重试 + `console.warn`,`pagehide` 时 flush。反馈用 toast(2.6s),不用常驻 error/notice 字符串。
|
|
27
29
|
|
|
28
30
|
### 7.4 数据与刷新
|
package/docs/contributing.md
CHANGED
|
@@ -20,7 +20,7 @@ node scripts/acceptance-local.mjs # 50/50;视觉证据只证明本次已审
|
|
|
20
20
|
npm run check # node --check + i18n 键对齐 + package.json 可解析
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
**结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。文档里出现的测试数字一律当作**带日期的快照**:2026-11-01 实测
|
|
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,下午必红)。
|
|
24
24
|
|
|
25
25
|
### 4.3 每类改动的连带清单
|
|
26
26
|
|
|
@@ -75,9 +75,9 @@ npm run check # node --check + i18n 键对齐 + package.j
|
|
|
75
75
|
|
|
76
76
|
### 5.3 新增一个 RPC 方法
|
|
77
77
|
|
|
78
|
-
<!-- rpc-method-count:
|
|
78
|
+
<!-- rpc-method-count: 95 -->
|
|
79
79
|
|
|
80
|
-
1. `lib/rpc.js` 的 `switch` 加 case(共
|
|
80
|
+
1. `lib/rpc.js` 的 `switch` 加 case(共 95 个方法,按功能分组,别乱插)。
|
|
81
81
|
2. 返回**形状稳定**:客户端 `call()` 直接解构,列表类给 `{items, total}` 而不是裸数组。
|
|
82
82
|
3. `revisionOnly` 分支只回 `{revision, stamp}`、**不要求 sessionId**(三端轮询,设置页与独立页没会话)、**不塞业务数据**(每 2.5 秒一次);顺带 `noteMemoryBeat()`,`memu_status` 靠它分「没写」与「没人轮询」。
|
|
83
83
|
4. 写成功后 `bumpMemoryRevision()`/`notifyMemoryWrite()`(§7);能让 `state.json` 或索引落盘的写,`state.js` 自动记写事件供 `memu_status` 展示。
|
|
@@ -85,7 +85,7 @@ npm run check # node --check + i18n 键对齐 + package.j
|
|
|
85
85
|
|
|
86
86
|
### 5.4 新增一个设置项 / 设置页
|
|
87
87
|
|
|
88
|
-
1. `lib/state.js` 的 `DEFAULT_SETTINGS` 加键(**唯一权威**),`setSettings`
|
|
88
|
+
1. `lib/state.js` 的 `DEFAULT_SETTINGS` 加键(**唯一权威**),`updateSettings` 里加 range/enum/类型校验,**并且**把键同时登记进 `lib/rpc.js` 的 `setSettings` 白名单与 `resetSettings` key 表——没进白名单的 patch 会被静默丢弃,设置页就成了死控件(回归由 `tests/settings-plumbing.test.mjs` 拦)。设置页里的 `settings.x ?? N` 回落值必须等于 `DEFAULT_SETTINGS.x`(`tests/ui-defaults.test.mjs` 守)。
|
|
89
89
|
2. 设置页:`lib/client.js` 的 `pageDefs`/`pageBlocks`/`PAGE` 三处一致;每页拆 `xxxBlock` + `renderXxxItem`。
|
|
90
90
|
3. 文案 zh/en 两字典都加,跑 `node scripts/check-i18n.mjs`;反面语义 → WebUI `settingRow(..., { invert: true })`。
|
|
91
91
|
4. 独立页(`lib/webui/`)要同步显示就走 `BroadcastChannel` 的 `memory-write`,并让 WebUI `settingRow` 读同一份 `getSettingsState`。
|
|
@@ -189,12 +189,13 @@ npm run check # node --check + i18n 键对齐 + package.j
|
|
|
189
189
|
|
|
190
190
|
### 新增设置
|
|
191
191
|
|
|
192
|
-
`curatorReviewMode`(`auto`/`review-all`,默认 auto)——全局提炼审核模式;conflict
|
|
192
|
+
三处注册缺一不可:`DEFAULT_SETTINGS` / `updateSettings`(range·enum·类型校验)/ `lib/rpc.js` 的 `setSettings` **与** `resetSettings`。1.2.3 新增的六个键:`openLoopRemindDays`(7,`[1,365]`)、`freshnessHint`(默认开)、`freshnessDays`(30,`[1,3650]`)、`salientWake`(`off`/`schedule`,默认 off)、`salientWakeHour`(`HH:mm`)、`salientWakeTimeZone`(空=跟随系统,非空必须有效 IANA)。另有 `curatorReviewMode`(`auto`/`review-all`,默认 auto)——全局提炼审核模式;conflict 恒人审。
|
|
193
193
|
|
|
194
194
|
### 锁顺序不变式
|
|
195
195
|
|
|
196
196
|
插件有多个文件锁(库索引、entities、词典、整理账本、向量代际闸)。当前唯一允许的嵌套方向是
|
|
197
|
-
`entity(file) → index(file)`(`deleteEntity` 先拿 entities
|
|
197
|
+
`entity(file) → index(file)`(`deleteEntity` 先拿 entities 锁,再在锁内清入边并写索引;1.2.3 的
|
|
198
|
+
`mergeEntities` 同向——实体锁内嵌套索引锁,且**先写索引改指、后删来源实体行**,中途崩溃最多留下可回收的实体,绝不会留下指向已消失实体的边),以及
|
|
198
199
|
`curator(vector) → index/lexicon(file)`(`curator.js` 的 managed 写闸先于索引/词典锁)。**不要**
|
|
199
200
|
在持有索引锁时回头拿 entities 锁,也不要在词典锁内拿向量闸——AB-BA 死锁不会在单会话测试里
|
|
200
201
|
稳定复现,但会在大库并发删除/改名时出现。`pruneOrphanEntities` 在 entities 锁内只读索引,不取
|
|
@@ -268,7 +268,7 @@ visibility 只允许当前代码支持的 shared 或 secret;不得再使用已
|
|
|
268
268
|
| P1 | `lib/memory.js` 召回:overlap 路径 + 旧 valence 回落、dominance 乘数、三腿门控、`arousalBias` 的强度代理纳入 `maxShare` | 完成;`moodBias` 实测边界 0.7 / 1.3 |
|
|
269
269
|
| P2 | `state.js` / `tools.js` / `prompts.js` / `remote-summary.js` / `rpc.js` / `client.js` | 完成;remember → list → update → recall 往返通过 |
|
|
270
270
|
| P3 | `private.js` fork 显式 `mood: null`;四份整理提示词按回合还原情绪 | 完成 |
|
|
271
|
-
| P4 | 文档与只读展示 |
|
|
271
|
+
| P4 | 文档与只读展示 | 完成;卡片/抽屉显示 arousal、dominance、emotionSource,编辑控件按 §1.2 不做 |
|
|
272
272
|
|
|
273
273
|
实现期间发现并修正的三处偏差,记在这里避免重犯:
|
|
274
274
|
|
|
@@ -276,6 +276,6 @@ visibility 只允许当前代码支持的 shared 或 secret;不得再使用已
|
|
|
276
276
|
2. **`emotion: null` 曾在工具层被 `?? null` 与"省略"合并**,导致"明确中性"被会话心情覆盖。现在三态分开:`undefined` = 继承,`null` = 明确中性,全零对象 = 规范化为 null。
|
|
277
277
|
3. **`dominanceBias(null, x)` 曾因 `Number(null) === 0` 返回 1.05**。现在缺失或非法一律返回 1。
|
|
278
278
|
|
|
279
|
-
验收:`tests/emotion-contract.test.mjs`(17 条,由独立验收者按 §8 编写,不迁就实现)+
|
|
279
|
+
验收:`tests/emotion-contract.test.mjs`(17 条,由独立验收者按 §8 编写,不迁就实现)+ 展示侧 `tests/client-render.test.mjs`(卡片/抽屉的 arousal/dominance/emotionSource 行);全量门禁的实测数字只看 `AGENTS.md` §3 的带日期快照,本文件不复制份数(复制的那份一定会在下个版本过时)。
|
|
280
280
|
|
|
281
281
|
端到端链路验证覆盖 8 条:读取、写入四态来源、持久化、更新三态、召回、旧条目降级、展示与协议、远程清洗;36 项断言全通过。
|
package/docs/env-and-commands.md
CHANGED
|
@@ -60,7 +60,7 @@ python -m memu commit payload.json --json --db <db>
|
|
|
60
60
|
|
|
61
61
|
`commit` payload:`{ recall_files: [{ name, track: memory, description, content }], resource: [], user: {} }`。
|
|
62
62
|
|
|
63
|
-
### 9.5
|
|
63
|
+
### 9.5 本地向量模型与运行时(受管,2026-10-30 / 2026-11-02)
|
|
64
64
|
|
|
65
65
|
**不再需要手工环境变量**:运行时(`onnxruntime-node` 1.31.1 + `onnxruntime-common` + `@huggingface/tokenizers`)由插件按 catalog pin 装进 `<dataDir>/downloads/embeddings/runtime/`,规格见 §14.13。`DSH_MEMU_EMBED_RUNTIME_DIR` 只剩「显式覆盖」用途:指向的目录里没有那三个包时会被忽略(`warn`)并回落到受管目录;也不需要 Ollama。
|
|
66
66
|
|
|
@@ -73,4 +73,66 @@ node scripts/local-runtime-install.mjs --target <dir> --platform win32-x64 --id
|
|
|
73
73
|
|
|
74
74
|
状态 `installed / absent / unsupported / downloading / verifying / installing / failed / cancelled`;`unsupported` = catalog 没 pin 该平台原生库(如 `darwin-x64`)。装失败只 `warn` + 回词法召回,不会自动改用云端 embedding。
|
|
75
75
|
|
|
76
|
+
#### 9.5.1 五条已核实模型(2026-11-02)
|
|
77
|
+
|
|
78
|
+
每条都 pin 在来源仓库的 HEAD commit,逐文件 `bytes/sha256` 与文件清单双向核对一致,再用受管 ORT 树真跑推理(单位范数、重复编码余弦 1.0)。BGE / MiniLM / e5 走 ModelScope 直连(2026-10-30 的核实口径);两张 Qwen3 卡片的导出仓库在 ModelScope 上不存在(只读核对 `record not found`),所以走 hf-mirror,`huggingface.co` 源站作为可选项。
|
|
79
|
+
|
|
80
|
+
| catalog id | 制品 | 维度 / 窗口 | pooling | 前缀 | 加载 | 一次编码 29 / 380 / 1520 字 | 实测(42 条 recall-bench 草稿,33 条可答) |
|
|
81
|
+
|---|---:|---|---|---|---:|---|---|
|
|
82
|
+
| `bge-small-zh-v1.5-int8` | 24.6 MB | 512 / 512 | cls + L2 | 无 | 254 ms | 5 / 17 / 22 ms | R@1 0.6667 · R@3 0.9697 · MRR 0.8106 |
|
|
83
|
+
| `all-minilm-l6-v2-int8` | 23.9 MB | 384 / 512 | mean + L2 | 无 | 122 ms | 5 / 17 / 30 ms | R@1 0.5455 · R@3 1.0000 · MRR 0.7525 |
|
|
84
|
+
| `multilingual-e5-small` | 135.4 MB | 384 / 512 | mean + L2 | `query: ` / `passage: ` | 787 ms | 6 / 19 / 47 ms | R@1 0.6667 · R@3 1.0000 · MRR 0.8182 |
|
|
85
|
+
| `qwen3-embedding-0.6b-int8` | 600.2 MB | 1024 / 4096 | last + L2 | 官方 `Instruct: …\nQuery:` / 无 | 2.06 s | 91 / 437 / 4286 ms | 带前缀 R@1 0.6970 · R@3 0.9697 · MRR 0.8359;裸文本 0.6667 · 0.9394 · 0.8081 |
|
|
86
|
+
| `qwen3-embedding-0.6b-q4f16` | 541.8 MB | 1024 / 4096 | last + L2 | 同上 | 11.4 s | 110 / 870 / 5863 ms | 带前缀 R@1 0.7273 · R@3 0.9697 · MRR 0.8510;裸文本 0.6667 · 0.9394 · 0.8081 |
|
|
87
|
+
|
|
88
|
+
延迟那一列是**同一批文本、同一个受管 ORT 树**上重测的(29 / 380 / 1520 字三段中文),所以五行之间可以直接比:Qwen3 int8 一次编码是另外三款的 18–195 倍,q4f16 还要再慢一截、加载慢 5.5 倍。
|
|
89
|
+
|
|
90
|
+
**这些数字是同一份合成草稿上的横向对照,不是质量结论**(草稿带刻意保留的词面线索,`docs/recall-benchmark.md` 自己声明它不是金标;33 条可答样本上 0.03 的差就是 1 条)。表里读得出的只有相对关系:e5 与 BGE 同级、MiniLM 在中文上明显弱;Qwen3 两个变体在草稿上略高,但一次编码慢 18–195 倍。英文 paraphrase 余弦 MiniLM 0.62/0.70、BGE 0.65/0.64、e5 0.91/0.93。q4f16 在这份草稿上没有比 int8 差(0.7273 对 0.6970)——差一个样本,不足以给两个变体排质量,能当依据的只有实测到的「加载慢 5.5 倍 + 依赖 com.microsoft 贡献算子」。
|
|
91
|
+
|
|
92
|
+
**角色通道**(e5 与两张 Qwen3 卡片都需要;为什么必须存在、为什么不是猜):MemU 的 embeddings 信封只有 `{model, input, encoding_format}`,没有 role 字段。非对称前缀意味着同一句话有两种读法,所以角色由**启动子进程的一方**写在 model 字符串上——`retrieve` 用 `<id>@<rev>+<proto>:query`,`commit` / `list-files` 用 `:passage`;worker 解析后缀并按 profile 的 `prefixes` 施加前缀,**裸 model id 对这种 profile 直接 400 `LOCAL_VECTOR_ROLE_REQUIRED`**,绝不"默认成文档"。两边同前缀的模型(BGE/MiniLM)保持原样,裸 id 照旧可用。派生规则是 `prefixesRequireRole(entry)` = `prefixes.query !== prefixes.document`,前缀本身在指纹里,所以「要不要角色通道」和「这个向量空间长什么样」永远来自同一份事实(§14.8)。前缀不是装饰:实测同一句话加/不加前缀的余弦,e5 是 0.9811,Qwen3 int8 只有 **0.8284**(q4f16 0.8203)——Qwen3 的 Instruct 前缀真的把向量挪开了,草稿上的读数也对应得上(带前缀比裸前缀 R@1 高 0.03、MRR 高 0.028)。真机验证:五路互切 `MiniLM(g1) → Qwen3-int8(g2) → Qwen3-q4f16(g3) → e5(g4) → BGE(g5)` 各 6/6 条重建、0 失败,每次切换后中英查询都能召回,回滚回到上一空间。
|
|
93
|
+
|
|
94
|
+
**下载来源(provider)**:不传就取目录顺序里第一个已固定的来源,所以 Qwen3 卡片的默认是 **hf-mirror**;`huggingface.co` 源站是同 commit 的同一批文件,可选。选源只走那一个、失败也不回退到别的源(`download(id, { provider })` → RPC `downloadLocalVectorModel` 的 `provider` → 设置页在「有多于一个已固定来源」的卡片上给一行 `is-row` 选择,只有一个来源就不出现「选」这件事)。换源不改向量空间:provider 不进指纹,每个文件落盘前都要过目录里 pin 的同一个 `sha256`。两个真实踩到的坑记在这里:① hf-mirror 对小文件用 chunked 传输、**不发 `content-length`**,头缺失必须当「未知」而不是 0,否则每个小文件都被误判成大小不符(第一次真装 Qwen3 就是被这条挡住的);② 见证制品(基座仓库的 `1_Pooling/config.json`)默认绑死它被核实的那个 provider,多镜像来源要用 `origin.providers` 显式声明,否则换源会把整条封掉。
|
|
95
|
+
|
|
96
|
+
**两张 Qwen3 卡片是两个向量空间**:int8 是 `quantize_dynamic`(QInt8),图侧核实 196/196 个 `MatMulInteger` 的 scale/zero_point 都是 rank-0 标量、per-channel scale 向量为 0 → **per-tensor**,和另外三款 per-channel 不是同一个空间;q4f16 是 `com.microsoft.MatMulNBits`(int4、block_size=128)+ float16 激活,图输出 dtype 也是 float16。`quantization` 进指纹,所以分条目、分 DB,不能混用。两者都是 opset 21 的因果 LM:只有 `input_ids` + `attention_mask`(没有 `token_type_ids`),池化取**最后一个非 pad token**(`pooling=last`,官方 `1_Pooling` 声明 `pooling_mode_lasttoken=true`),且图**导出时固定 batch=1**——一次只能喂一行,worker 的 adapter 本来就逐行编码。分窗取 4096 而不是制品支持的 32768:1520 字实测已 4.29 s,按 32k 跑一条长记忆会直接顶到 worker 的 120 s 请求超时;窗口是指纹字段,所以这是写明的策略而不是疏漏。
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
node scripts/local-vector-verify.mjs # 只读:五条目录条目的 manifest/来源/已装 deep 校验
|
|
100
|
+
node scripts/local-vector-verify.mjs --download --id all-minilm-l6-v2-int8 # 显式联网装该模型(默认落 .tmp-* 临时根)
|
|
101
|
+
node scripts/local-vector-verify.mjs --download --id qwen3-embedding-0.6b-int8 --target <dataDir>/downloads/embeddings
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`--target` 指到插件数据目录就等于设置页的「下载并校验」;该脚本从不写 active profile,切换仍然只能走设置页的「切换并重建」。
|
|
105
|
+
|
|
106
|
+
### 9.6 注入实测台(工单 B,仅评测用)
|
|
107
|
+
|
|
108
|
+
**目的**:注入「发了什么」不等于「模型收到了什么」。这三件脚本只量最后一环——真正发给模型的请求里出现了哪些记忆块、出现几次。它们**不是运行时依赖**,`lib/` 永不 import,日志只记长度/哈希与标记计数(不记正文)。
|
|
109
|
+
|
|
110
|
+
| 工具 | 量的是 | 覆盖不到 |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| `scripts/simulate-injection.mjs` | 插件自己决定了什么:真实 `lib/inject.js` + 真实 `registerInjection('agent/pre-step')`,打在临时库与临时 `DSH_MEMU_HOME` 上 | 宿主的消息组装、真实模型的 tool 轮 |
|
|
113
|
+
| `scripts/mock-llm.mjs` | 收到请求时数标记 + `--report` 出「每轮 × 块矩阵」 | 它只是端点,不产生轮次 |
|
|
114
|
+
| `scripts/drive-session.mjs` | 真机上把轮次灌进绑定会话 | 需要宿主用假模型(见下) |
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm run simulate:injection # 50 轮离线基线,临时目录,cue 概率置 0 便于复现
|
|
118
|
+
node scripts/simulate-injection.mjs --turns 20 --out ./sim-run --json
|
|
119
|
+
node scripts/mock-llm.mjs --port 8123 --log ./mock-llm-<日期>.jsonl # 伪 OpenAI 端点,只监听 127.0.0.1,无鉴权
|
|
120
|
+
node scripts/mock-llm.mjs --reply-file ./tests/fixtures/mock-llm/reply.txt --port 8123 --log ./mock.jsonl
|
|
121
|
+
node scripts/mock-llm.mjs --report ./mock-llm-<日期>.jsonl > mock-llm-report-<日期>.md
|
|
122
|
+
node scripts/drive-session.mjs --session <id> --turns 50 --dry-run # 只打印将要发的请求,不发
|
|
123
|
+
node scripts/drive-session.mjs --session <id> --turns 50 \
|
|
124
|
+
--base http://127.0.0.1:<gateway 端口> --allow-api-route --requests-out ./requests.jsonl
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- **离线模拟器**(1.2.4)在临时 `DSH_MEMU_HOME` 里播种一份"每种块各有一条"的库(明天/今天/已过期的带日期未了之事、年度纪念日、时效词、四个月前的旧条目、近似重复主题对),跑 N 轮,把每次组装好的请求打给本地伪端点,产出 `report.md` / `mock-llm.jsonl` / `settings-snapshot.json` 与一行 JSON 摘要。退出码 `0` / `2` 用法错 / `3` **注入链路自己报了 warn**(模拟器把 warn 当失败,不当噪声)。它**不是真机证据**:宿主侧的折叠、真实模型的 tool 轮都不在里面;两边对不上时以真机为准。
|
|
128
|
+
- 真机用法:DSH 的 provider profile 把 `baseURL` 指到 `http://127.0.0.1:8123/v1`(provider 配置在 `~/.dsh/profiles/<profile>/cordis.patch.yml` 的 `llm-pi-ai`,`- id/config` 是**整份替换不是合并**,改完要重启该 profile 的宿主),测试会话绑定一个手写播种库,再用 `drive-session.mjs` 灌轮数。
|
|
129
|
+
- 标记表 pin 在 `scripts/mock-llm.mjs` 的 `MARKERS`(`MARKER_SET_VERSION` 记插件版本)。**改 `lib/inject.js` 的块标记必须同处更新并 bump 版本**,否则报告把新块记成 0。回归见 `tests/simulate-injection.test.mjs`:它钉的是量具属性(guide 只在首轮一次、标题卡 `body lines` 必须为 0、日志里不许出现正文),不是某次的注入计数。
|
|
130
|
+
- `drive-session.mjs` 走宿主公开的 `sessionController.prompt`(`POST <base>/api/session/prompt` 的 Connection carrier 形状),并且**默认拒绝发送**:没有 `--allow-api-route` 就打印等价的手工请求并退出码 3。轮结束只认持久 session log 里本轮 `turn/end` 的 `reason.kind === 'completed'`。
|
|
131
|
+
- 退出码:`0` 全部完成 / `1` 某轮或传输失败 / `2` 用法错 / `3` 未授权传输(手工降级)/ `4` 观察不到 session log。
|
|
132
|
+
- **真机 50 轮已跑过(2026-11-01,隔离实例)**:`DSH_HOME` 指到 launcher 的独立 home(`…/in.dsh-plug.dsh-launcher/homes/<version>`),profile 只加一个 `dsh-memu-memory` junction,provider 用 `mock-llm` 起在 8090,`dsh --profile <p> --no-open --port 0` 打印带 token 的 URL → `GET /` 303 换 cookie → `drive-session --cookie-file` 灌 50 轮。读数(51 个请求、2 个会话指纹):`guide / anchor / due / anniversary / openLoop / texture` 各 **1** 次(都只在首轮),`ctx` Δ **27** 跨 **26/50** 轮(注入率 52%),`freshness` Δ **18** 跨 17 轮,`media / lexicon / cue / replay` 为 0(无附件、词典空、cue 概率 0、无压缩);标题卡 `bodyLines` 全 0;12 条播种条目全部浮现过(`uniqueIds` max 12)。
|
|
133
|
+
- **离线对照**(同一份 `registerInjection` 代码,`scripts/simulate-injection.mjs`,50 轮):注入 18/50 轮、`ctx` Δ18、`freshness` Δ11、其余块各 1、`bodyLines` 全 0。两边方向一致(首轮一次、逐回合召回、时效提示按需),绝对值不同——真机的转录更长、每轮都会重投新的召回,所以离线数只能读作"插件的决策",不能当装机读数。
|
|
134
|
+
- 这条链上有两个坑,踩过一次写在这里:① `- id/config` 是**整份替换**,profile 里声明 provider 就得把 `providers` 写全;非推理模型的 `reasoningEfforts` 必须是 `false`,写成 `{off: null}` 会被判 `INVALID_CONFIG`(**回合在发出请求前就中止,所以零花费、零外发**,但看着像"没反应")。② 宿主源码树 `packages/boot/app-boot/lib/` 是过期构建(`src` 支持 patch 路径列表,`lib` 不支持)→ 从源码起会崩;用已安装版本目录里的 `@deepseek-ai/dsh/lib/bin.js`。
|
|
135
|
+
- 这条链还顺手抓出一个行为缺口并修了(1.2.4):**从未到达模型的失败回合会消耗掉首轮的一次性内容**(guide / 锚点 / 当日纪念日 / 复提时钟)。插件现在把该轮消费的东西记在 `injectionRollback` 上,并按"本轮注入消息有没有进转录"决定撤不撤:配置无效(`INVALID_CONFIG`)时撤回、下一轮重新投,上游 500 时消息还在转录里就保住记账不重投。机制与边界 → `docs/troubleshooting.md` §3.24。
|
|
136
|
+
- 数据是**要丢弃的**:报告文件名带日期,别把捕获的对话提交进仓库,也别把伪端点当日常后端。
|
|
137
|
+
|
|
76
138
|
---
|
package/docs/host-api.md
CHANGED
|
@@ -41,6 +41,25 @@
|
|
|
41
41
|
|
|
42
42
|
`ctx.schedule`(`@deepseek-ai/dsh-schedule`:create/list/catalog/history/delete/update,`every_seconds | daily | weekly | cron`,最小 60s)**绑定单个 sessionId、往该会话投递 prompt**、需要 sessionPersistence、且拒绝 subagent 会话——**不适合插件级全局清扫**。插件自己的清扫用 `ctx.interval`(cordis 随作用域回收),没有才退回 unref 的 `setInterval`。
|
|
43
43
|
|
|
44
|
+
**一次性到点任务(1.2.3 工单 E 用到的形状,2026-11-01 对照宿主源码核实):**
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
schedule.create({
|
|
48
|
+
title, // ≤120 字,非空
|
|
49
|
+
prompt, // 每次触发发送的正文
|
|
50
|
+
timing: { kind: 'at', at: { date: 'YYYY-MM-DD', time: 'HH:mm', time_zone: 'IANA|UTC' } },
|
|
51
|
+
target: { kind: 'session', sessionId }, // 省略则首次投递时新建会话
|
|
52
|
+
})
|
|
53
|
+
schedule.list({ limit: 500 }) // -> { items, shown, total, limit, offset },不是数组
|
|
54
|
+
schedule.edit({ id, action: 'delete' }) // 已结束的任务同样可以删
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `ScheduleTiming` 另有 `after/at/every/daily/weekly/cron/rrule`;`at` 是 `AtInput = string | {date,time,time_zone}`,结构化形式三个字段都必填。
|
|
58
|
+
- 投递是 `agent.followup(...)`,**会新开一整回合**,冷会话由 `sessionController.resolveAgent` 自动 resume;`source.kind === 'schedule'`,所以本插件的注入管线(只认真实 `user` 消息)不会在那一回合跑召回——prompt 必须自带全部上下文。
|
|
59
|
+
- `ctx.get('schedule')` 是**可选服务**:desktop 组合里有,别的宿主可能是 `undefined` 或抛错,必须 warn 后降级,不能让周期失败。
|
|
60
|
+
- 投递是 at-least-once,receipt 只证明进了 inbox;任务持久化在宿主的 `storages/schedule.json`,用户在宿主 schedule UI 里看得见、也能手删。
|
|
61
|
+
- subagent 会话被 `validateTarget` 拒绝(错误码 `subagent_session`),已归档会话是 `invalid_rule`。
|
|
62
|
+
|
|
44
63
|
事件:`ctx.on("agent/status", { agent, status })`,`AgentStatus = idle | running`;另有 `session/created`、`session/disposed`、`session/flush`;事件类型含 `turn/start`、`turn/end`(`step/*`、`user/message…`)与 `compaction/*`。**`turn/end` 不 await flush,不要在那里读存储;判 fork 成败只读事件对象本身。**
|
|
45
64
|
|
|
46
65
|
|
package/docs/memory-semantics.md
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
- 静态 guide 与动态记忆都走 plugin 消息;当前版本不再注册本插件的 system prompt 段。所有会话(含 `persona` `complete: true`)统一由 `lib/inject.js` 的 `ensureUnifiedGuide` 在**回合首步**投放一条 `<memory-guide rules="…">` 插件消息;`rulesKey` 由协议版本、domain 和实际渲染正文计算,domain/覆盖/默认稿变化或压缩丢失(`guideLost`)时在下一个合法首步替换,同一规则不逐回合重复。旧 binding 只有 `guideMessageAt`、没有 `guideRulesKey` 时视为旧版,补投一次;失败 fail-open,不写新版本。
|
|
40
40
|
- 首轮锚点 + 每用户回合最多一次;长工具回合仅有新的真实人类消息批次时追加一次,普通工具步骤不触发。私有优先、全局补充;冲突时私有胜。
|
|
41
41
|
- **锚点和本回合召回只放标题卡**(1.2.2):`formatPrivateTitle` / `formatGlobalTitle` 输出 `[id]`、标题、`source`、owner、layer、日期/年龄、marginalized/open_loop、accuracy/uncertainty/disclosure 与附件计数,**不输出正文与附件 caption**。工具返回、记忆抽屉与浏览器仍是全文;要正文就按标题关键词或方括号里的 id 调 `memu_private_recall` / `memu_global_recall`。标题为空时回退正文前 40 字;`imagined`、`never_say` 等语义标签不能因为标题化而丢失。
|
|
42
|
+
- **条件式时效提示(工单 D)**:本回合召回块已经生成后,若其中至少一条真正进入文本的条目带时间敏感信号——`salientDate` 是已过去的 `YYYY-MM-DD`(年度 `MM-DD` 不算)、标题/正文命中固定词表 `最新|最近|现在|目前|今年|版本|价格|天气|新闻|比分|汇率`、或 `updatedAt||createdAt` 距现在 ≥ `freshnessDays`(`owner=about_project` 的工程事实不算年龄)——且 `freshnessHint !== false`、用户文本长度 ≥ `minUserChars`,就在最后一个 `</memory-context>` 之后追加**一个** `<memory-freshness>` 块,N 为去重后的 stale 条数。提示与召回共用 `turnTokens` 预算:放不下就丢弃提示,召回本身仍成功(fail-open,计算异常只 `warn`)。它只说「若你的会话里有可用的搜索工具就先核实」,**不声称** `web_search` 一定存在(工具面不确定性见 `docs/host-api.md` §6.8),也不改 `<memory-guide>`/`rulesKey`。`freshnessDays` 默认 30,范围 `[1,3650]`;`freshnessHint` 默认开。
|
|
42
43
|
- **rule 是前言,不是页脚**:`buildAnchor` 先输出锚点头与 `[rule]`,再输出 private/global/short_term 各段;inbound 路径的锚点之后直接衔接 `<memory-context>`,中间不再隔一条规则。
|
|
43
44
|
- **`injectedIds` 只能记真正进入文本的条目**,否则从未展示的记忆被白白压制 8 轮。
|
|
44
45
|
- 锚点分段预算 pin 40% / core 30% / global 30%;pin 装不下时末尾明示「另有 N 条未展开」,**不静默丢弃**。1.2.2 移除了 core≤5 / global≤8 的预先切片:标题卡比正文短,条数应由预算打包器决定,而不是固定上限;`anchorTokens` / `turnTokens` / `injectionTotalTokens` 默认值不变,inbound 的 `floor(turnBudget/2)` 保留。
|
|
@@ -148,9 +149,17 @@
|
|
|
148
149
|
|
|
149
150
|
**标题卡与标题写作。** 锚点/召回的可见单位从正文改为标题卡,标题因此成为索引而不是装饰:提示词要求 8–40 字、含具体人名/物名/事件/结论关键词,禁止「一些事」「那段对话」「关于 XX 的事」;合并/吸收稿的标题要覆盖全部来源关键词。Lexicon 的注入行仍保留「term + ≤80 字短义」(不是裸词),因为词典的唯一价值是解释;UI 卡片也是 term 标题 + meaning 正文。
|
|
150
151
|
|
|
151
|
-
**词典生命周期。** 公开状态只有 `active` / `archived`:用户新建、模型 `memu_lexicon_propose`、curator 带证据抽取都直接 active;`archiveLexiconTerm` / `restoreLexiconTerm` 负责可逆退场,删除只属于管理面。`rejected` 只作为 legacy 墓碑/指纹留在数据里,UI、注入、检索与计数都看不到;`pending` 只作为旧版本迁移输入:新提案 → active(敏感 → archived),revision 草稿 → archived。敏感 trigger 的新建/修改只能由用户完成,模型/curator 得到 typed 拒绝;非用户修改普通 active 词条的敏感字段也直接拒绝,不再生成 pending revision。RPC 的 `lexiconReview`
|
|
152
|
+
**词典生命周期。** 公开状态只有 `active` / `archived`:用户新建、模型 `memu_lexicon_propose`、curator 带证据抽取都直接 active;`archiveLexiconTerm` / `restoreLexiconTerm` 负责可逆退场,删除只属于管理面。`rejected` 只作为 legacy 墓碑/指纹留在数据里,UI、注入、检索与计数都看不到;`pending` 只作为旧版本迁移输入:新提案 → active(敏感 → archived),revision 草稿 → archived。敏感 trigger 的新建/修改只能由用户完成,模型/curator 得到 typed 拒绝;非用户修改普通 active 词条的敏感字段也直接拒绝,不再生成 pending revision。RPC 的 `lexiconReview` 已删除(方法数见 `docs/contributing.md` 的 rpc-method-count 标记)。
|
|
152
153
|
|
|
153
154
|
**私有自动关联。** 整理结算后 `lib/private-links.js` 只做本地算法:同库、同 context/track、可见非 secret、标题共享稀有 name-like token、pairScore < 0.82 且无冲突时,建立 memory↔memory `relation` 并写 `source:'auto'`;≥2 条记忆共享该 token 时复用/创建实体枢纽(人物信号 → `person`,无信号的拉丁名保守 → `thing`,CJK 无信号或 kind 冲突 → 不确定候选)。高置信写库在算法侧完成,不确定候选最多 8 对交给本次整理 worker 用 `memu_private_link_suggest` / `memu_private_link` 带证据裁决;不另起整理、不重读转录。算法/写入失败只记 warn,不能让已经成功的整理失败;自动关联不改正文、不写向量、不删除,边可在关系图移除。worker 写工具为 remember/update/link/link_suggest/lexicon_propose,读工具为 recall/list/lexicon_search,但「有没有写能力」仍只由 remember/update 判定。
|
|
154
155
|
|
|
156
|
+
### 8.14 日期联动、到点唤醒与实体合并(1.2.3)
|
|
157
|
+
|
|
158
|
+
**未了之事与纪念日联动(工单 C)。** `[open loop]` 的常规腿不变:无日期的 `openLoop` 条目要静置满 `OPEN_LOOP_DAYS`(3 天)才提,且**提过一次就永久静默**(走 `injectedIds`)。新增的是过期日期腿:`salientDate` 是已过去的 `YYYY-MM-DD`、条目仍 `openLoop` 且 active 时,**不看 3 天门槛**直接进入候选,文案带上 `date=… 已经过了`,让模型能说清晚了多久而不是编时间。这条腿不受「提过即静默」约束,只受自己的提醒节奏约束:binding 记 `openLoopRemindedAt`(`entryId → ISO 时间戳`,判定时才换算成本地日历日比较),同一条每隔 `openLoopRemindDays`(默认 7,`[1,365]`)复提一次,同日不二提;90 天没再命中的记录会被清掉。每回合仍最多 1 条,优先级是「过期日期 → 常规」。同回合里纪念日块(`<memory-anniversary>` / `<memory-due>`)已经点过名的条目,作为 `excludeIds` 从两条腿都剔掉——且**只有 anniversary 文本真的进入消息才剔**,预算装不下时不该把未了之事一起沉默。到期当天的措辞升级(「今天就是日子」)在 `<memory-due>` 里完成,不新开块。闭环仍然只有用户能做:不自动检测承诺、不自动关闭,关闭走 `memu_private_update`。
|
|
159
|
+
|
|
160
|
+
**纪念日到点唤醒(工单 E,默认关闭)。** `settings.salientWake === 'schedule'` 时,整理周期里的 `runSalientWakePass` 会按**投递时区**(`salientWakeTimeZone`,留空跟随系统)扫描今天/明天命中的 salient date,给每个绑定会话通过宿主公开的 `ctx.schedule` 建一条一次性任务:标题 `memu:due:<sessionId>:<YYYY-MM-DD>`,`timing: { kind:'at', at:{date,time,time_zone} }`(时刻取 `salientWakeHour`,默认 `09:00`;时区留空跟随系统,非空必须是有效 IANA 区),`target: { kind:'session', sessionId }`。**日历日与「这一刻过去了吗」都按投递时区算**(`dayInZone` / `instantInZone`,用 `Intl` 取该时区墙上钟再换算绝对瞬间):按机器墙钟算会在配置时区与系统时区不一致时排错一天,或把那个时区里还没到的时刻当成已过而静默不排。幂等靠 `schedule.list` 对账而不是往 binding 写任务 id:同名 active 任务跳过、paused 不动、ended 删除、已过时刻的当天槽位不补建。投递是 `agent.followup`,**会新开一整回合**,而本插件的注入管线只认 `source.kind==='user'` 的真实用户消息——所以那条回合拿不到锚点、召回和纪念日块,**唤醒 prompt 必须自带正文**(日期、升级措辞、`memu_private_recall` 指引、「已说过不要重复」)。宿主没有 schedule 服务、subagent 会话(`subagent_session`)、已归档会话(`invalid_rule`)都只记 `kind:'wake'` 的活动日志并跳过,不能让整个周期失败。边界:宿主进程必须活着;at-least-once 可能重复投递;用户手删任务下一轮会重建;任务在宿主的定时任务界面可见。真机验证前默认 `off`。
|
|
161
|
+
|
|
162
|
+
**实体主节点合并(工单 F)。** 同一记忆库里写法不同的实体(`林眠` / `林眠儿`)可以由用户合并到主节点。`suggestEntityMerges({libraryId})` 是纯读:同 `kind` 且「归一化后短方(≥2 字)被包含」或「短方 ≥3 字且编辑距离 ≤2」时给出 `{sourceId(短), targetId(长), reason}`,稳定排序、上限 20,**永不自动合并**。`mergeEntities({libraryId,targetId,sourceIds})` 在实体文件锁内一次完成:别名取并集(含来源实体的名字)并 cap 30(超出部分在返回值 `droppedAliases` 里报告,不静默丢);私有索引里所有 `links[].to === sourceId` 改指 target,同 `(to, kind)` 冲突按既有替换规则去重;关系快照按端点对重键,与主节点侧冲突时**保留主节点侧**并计入 `relationships.conflicts`;来源实体删除后再 `pruneOrphanEntities` 兜底(主节点受保护)。合并**不删除任何记忆**,只改指向;活动日志记 `kind:'write' op:'entity-merge'`,失败留 warn。kind 不同的合并请求直接拒绝。WebUI 节点图页给出候选、两次点击确认、合并后回执(改指多少条链接、并入多少别名、丢了多少别名与冲突快照)。跨库、全局↔私有归并不做。
|
|
163
|
+
|
|
155
164
|
---
|
|
156
165
|
|
package/docs/troubleshooting.md
CHANGED
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
聊很久一条记忆都没写 → §3.18
|
|
34
34
|
人格预设会话里完全没有记忆 → §3.19
|
|
35
35
|
鉴权 / 401/403 行为说不清 → §3.20
|
|
36
|
+
本地向量模型装不上 / 切不过去 / 召回 400 → §3.25
|
|
37
|
+
整理超时(fork 预算不够)→ §3.26
|
|
36
38
|
```
|
|
37
39
|
|
|
38
40
|
## 3. 出过的问题:症状 → 落点 → 守卫
|
|
@@ -247,8 +249,72 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
247
249
|
|
|
248
250
|
**守卫**:`tests/webui-auth.test.mjs`(两前缀各自 handler、401/403/放行、正文零拉取、home 读写探针、快照与附件池绊线)。手工排查时先确认 `requestRejection` 的调用计数为 1,再看拒绝响应体是否只有 `unauthorized`/`forbidden`;不要靠「页面能打开」判断鉴权通过。
|
|
249
251
|
|
|
252
|
+
### 3.21 日期到点没唤醒会话(S6 注入 → 宿主 schedule)
|
|
253
|
+
|
|
254
|
+
**症状**:开了 `salientWake='schedule'`,条目明天到期,第二天会话里什么都没发生;或者宿主的定时任务界面里根本没有 `memu:due:` 任务。
|
|
255
|
+
|
|
256
|
+
**落点**:`lib/salient-wake.js` 是整理周期里的一个 pass(`lib/cycle.js`),所以先看周期有没有跑。按顺序排:① 设置真的存下了吗(`setSettings` 的 allowlist 漏 key 会静默丢弃,`state.json` 里应出现 `salientWake: 'schedule'`);② 宿主有没有 schedule 服务(`ctx.get('schedule')` 可能是 undefined,此时只 warn 一次并降级为被动注入);③ 时区(`salientWakeTimeZone` 留空跟随系统,填了无效 IANA 区就整轮跳过并记一条);④ 时刻(`HH:mm`,早于该时刻的当天槽位不补建,只排明天);⑤ 会话状态(`useLibrary=false`、归档会话、subagent 会话会被宿主拒或本插件主动跳过)。活动日志 `kind='wake'` 的 `detail.stage`(`service / timezone / index / list / cleanup / create / pass`)就是这条排查线。
|
|
257
|
+
|
|
258
|
+
**已经建了任务但没开口**:投递是 `agent.followup`,宿主进程必须活着;那一回合的 `source.kind==='schedule'`,本插件的召回/纪念日块**不会**运行,能看到的只有唤醒 prompt 自带的内容(这是设计,见 `docs/host-api.md` §6.6)。用户手删的任务会在下一轮 sweep 重建——同一天已 `ended` 的才清理。
|
|
259
|
+
|
|
260
|
+
**守卫**:`tests/salient-wake.test.mjs`(默认 off 不问宿主、无服务只 warn 一次、今天/明天各一条且 prompt 自包含、二次 sweep 幂等、ended 清理、paused 不动、subagent/归档/其它错误只跳过该会话、年度 `MM-DD` 不提前、无效时区不抛错)。真机验收项单独记录:造一条明天到期的条目 → 宿主 schedule UI 出现 `memu:due:` → 到点会话被唤醒 → 次日 sweep 清理。
|
|
261
|
+
|
|
262
|
+
### 3.22 时效提示没出现(S6 注入)
|
|
263
|
+
|
|
264
|
+
**症状**:明明召回了一条写于半年前、标题带「最新」的记忆,块尾却没有 `<memory-freshness>`。
|
|
265
|
+
|
|
266
|
+
**落点**:这条提示是**追加**在已生成的召回块之后的,前置条件少一个就不出:本回合真的有召回(`autoInject` 不是 `anchor-only`、用户文本过 `minUserChars`、命中非空)、`freshnessHint !== false`、至少一条**进入文本的**条目带信号、`turnTokens` 预算还剩得下这一行。三个信号里年龄那条最容易被误判:`owner=about_project` 的工程事实不按年龄算陈旧,年度 `MM-DD` 日期永不过期。计算异常只 `warn`,召回照常(fail-open)。
|
|
267
|
+
|
|
268
|
+
**守卫**:`tests/freshness.test.mjs`(三信号真值表、缺字段/NaN 不命中、一次性过期 vs 年度日期)+ `tests/injection-chain.test.mjs`(命中出、全基线不出、`anchor-only` 不出、开关关不出)。
|
|
269
|
+
|
|
270
|
+
### 3.23 实体合并的疑问与风险(S9 图谱)
|
|
271
|
+
|
|
272
|
+
**症状**:节点图里两个人名指同一个人;或者合并后担心「链接改了、记忆是不是丢了」。
|
|
273
|
+
|
|
274
|
+
**落点**:候选来自 `suggestEntityMerges`(纯读,同 `kind` + 包含/编辑距离,上限 20),UI 只列建议,两次点击确认才调 `mergeEntities`。合并改的是**指向**:来源实体的名字进别名(cap 30,超出在回执里明说)、私有索引里 `links[].to` 改指主节点(同 `(to,kind)` 去重)、关系快照按端点对重键(与主节点侧冲突时保留主节点侧),最后删除来源实体并 prune 孤立实体。**记忆正文与条数不变**,`docs/memory-semantics.md` §8.14 是口径。回执数字(改指多少链接、并入多少别名)来自返回值,不是估算。
|
|
275
|
+
|
|
276
|
+
想回退只能靠备份:`lib/backup.js` 的既有导出/备份路径,合并本身没有 undo。
|
|
277
|
+
|
|
278
|
+
**守卫**:`tests/entity-merge.test.mjs`(链接全改指、别名并集与 cap、快照重键与冲突取舍、kind 不同/自指/未知 id 拒绝且不写、prune、suggest 真值表与纯读、RPC payload 形状);授权矩阵见 `tests/webui-auth.test.mjs`。
|
|
279
|
+
|
|
280
|
+
### 3.24 某一轮失败之后,整个会话再也不出现锚点/日期/未了之事(S4 注入 → 宿主回合失败)
|
|
281
|
+
|
|
282
|
+
**症状**:逐回合召回 `<memory-context>` 一直正常,但 `===== memory anchor =====`、`<memory-due>`、`<memory-anniversary>`、`[open loop]`、`<memory-guide>` 从某一轮起**整会话消失**,且库里的日期条目明明还在。真机实测台能直接重现:2026-11-01 那次 provider 配置报错,51 个请求里这五类块全为 0,而 `ctx`/`freshness` 照常。
|
|
283
|
+
|
|
284
|
+
**落点**:这些块是**一次性投放**的。`ensureUnifiedGuide` 写 `guideRulesKey`,锚点靠 `ANCHOR_SENTINEL` 进 `injectedIds`,日期/纪念日/未了之事拼在同一条首轮消息里,而记账发生在消息交回决策之后、模型调用之前。宿主随后报 `turn/end`(`reason.kind` 为 `error` 或 `aborted`)——**当时插件不看这个事件**,于是那一次失败吃掉了整个会话的首轮内容。压缩路径(`guideLost` / `reinjectPending`)只管 guide 与锚点的重投,救不了 due/anniversary/open loop。
|
|
285
|
+
|
|
286
|
+
**现在的做法**(1.2.4 起):注入投放时把"这一轮消费掉了一次性内容"记在 binding 上(`injectionRollback`:hostTurn + 那批 ids + guide 的 rulesKey + 纪念日/复提名单),同时在内存里留下**本轮那几条注入消息的 id**。判据来自宿主 `agent-loop` 的 `step()`:它在第一次尝试里就把 `decision.messages` 逐条 `append('user/message')` 进转录,**之后**才去连模型——所以插件只要看见自己那条 id 的 `user/message` 事件,就说明这一轮真的发出去了。`turn/end` 到达时:没见过实证且 `kind` 是 `error`/`aborted` → `rollbackInjectionForTurn` 只撤回**那一轮**的记账,下一轮重新投;见过实证或回合正常收尾 → `consumeInjectionRollback` 删掉记录、记账保住,之后一条迟到的旧事件也撤不动它。监听段排在最前且自带 try,不会被别的监听步骤抛错带走;回滚会写一条 `kind:'system'` 的活动日志与一条 warn,不静默。
|
|
287
|
+
|
|
288
|
+
**边界(重要,别当成万能药)**:这条链只对"请求根本没发出去"那类失败有意义。实测与源码都对得上:provider 配置无效(`INVALID_CONFIG`)在 `prepareRequest` 里抛,那时转录连用户消息都不留——正是需要撤回的情形;而**请求已发出、上游 500 或流式中断**时注入的消息已经在转录里(后续请求会原样重发),撤回只会让下一轮凭空多出第二条规则消息和第二个锚点,所以不撤。实证只在内存里:进程恰好在回合中间重启就查不到证据,此时**宁可漏撤一次也不误投**。逐回合召回本来就不依赖一次性记账,不受影响。
|
|
289
|
+
|
|
290
|
+
**守卫**:`tests/injection-rollback.test.mjs`(6 条)——失败回合后 guide/锚点/召回 id 全部撤回且下一轮重新投出、`completed` 回合不重复投、`completed` 会消费记录所以迟到的旧失败事件撤不动、注入消息已进转录时 500 类失败保住记账、投放前取消同样撤回、当日纪念日与复提时钟一起撤回。真机侧的复现路径见 `docs/env-and-commands.md` §9.6:让 provider 报 `INVALID_CONFIG` 跑一轮,再看转录与 binding 是否一致。
|
|
291
|
+
|
|
292
|
+
### 3.25 本地向量模型装不上 / 切不过去 / 召回 400(S4 受管向量 → 模型目录与角色通道)
|
|
293
|
+
|
|
294
|
+
**症状**:设置页里某个模型点不动;或切到 `multilingual-e5-small` 后召回整段没有,日志里出现 `LOCAL_VECTOR_ROLE_REQUIRED` / `LOCAL_VECTOR_MODEL_MISMATCH`;或换了模型后检索明显变差。
|
|
295
|
+
|
|
296
|
+
**落点**:三条 ModelScope 模型(BGE / MiniLM / e5)与两张 Qwen3 卡片(int8 / q4f16)都只从**固定 commit** 取制品,逐文件 `bytes/sha256` 是硬门槛,所以「下载按钮灰着」先跑 `node scripts/local-vector-verify.mjs` 看报的是 `manifest` 还是 `source`。Qwen3 的导出仓库在 ModelScope 上没有对应条目,默认来源是 hf-mirror、可切 huggingface 源站(同一 commit、同一份 sha256,换源不换向量空间);注意 hf-mirror 对小文件用 chunked 传输、不发 `content-length`,这条已被当作「未知」而不是 0 处理。e5 与 Qwen3 都是**非对称前缀**模型(`query: `/`passage: `、官方 `Instruct: …\nQuery:`),角色由插件写在发给 worker 的 model 字符串后缀上(`retrieve` → `:query`,`commit` / `list-files` → `:passage`);这种 profile 对**裸 model id 直接 400** `LOCAL_VECTOR_ROLE_REQUIRED`,绝不"默认成文档"——默认错一边等于换一个向量空间而 HTTP 还是 200。绕过插件 env 直接手起一个 MemU 进程(自己 export `MEMU_EMBED_MODEL`)就会撞上这条 400,这是设计而不是 bug。
|
|
297
|
+
|
|
298
|
+
**Qwen3 专属**:它是因果 LM,`pooling=last`(取最后一个非 pad token,opset 21),图导出时**固定 batch=1**,所以一次只能喂一行——worker 的 adapter 本来就逐行编码。int8 与 q4f16 是**两个向量空间**(量化方式进指纹),两张卡各自下载、各自重建,切过去不会复用对方的库。q4f16 依赖 `com.microsoft` 贡献算子域且实测**更慢**(加载 11.4 s vs 2.06 s)。延迟口径:短句一次编码 int8 91 ms / q4f16 110 ms,1520 字 4.29 s / 5.86 s,比另外三个模型慢一到两个数量级——「切换后感觉变卡」先看是不是切到了 Qwen3 卡片,分窗也因此只取 4096(制品支持 32k)。
|
|
299
|
+
|
|
300
|
+
**换了模型不等于换得对**:MiniLM 是英文模型,中文锚点召回实测弱于 BGE/e5(同一份合成草稿 R@1 0.5455 对 0.6667),"检索变差"先看设置页当前生效的 `catalogId` 而不是先怀疑注入。口径与实测数字在 `docs/env-and-commands.md` §9.5.1。
|
|
301
|
+
|
|
302
|
+
**守卫**:`tests/embedding-catalog.test.mjs`(三条目指纹钉死、只有非对称前缀需要角色通道)、`tests/local-embedding-protocol.test.mjs` 与 `tests/local-embedding-worker.test.mjs`(角色解析、前缀确实进推理、裸 id 被拒且没进推理)、`tests/local-embedding-env.test.mjs`(对称模型的 `MEMU_EMBED_MODEL` 逐字节不变)。
|
|
303
|
+
|
|
250
304
|
---
|
|
251
305
|
|
|
306
|
+
### 3.26 整理超时(S4 私有整理 → fork 预算)
|
|
307
|
+
|
|
308
|
+
**症状**:整理提醒里出现「整理超时 · fork f-xxxxxx · timeout:consolidation timed out after Ns」,而对话本身一切正常、库里也可能已经多了几条记忆。
|
|
309
|
+
|
|
310
|
+
**落点**:整理是一次**整段会话的 fork**——种子是截止快照的全部事件,worker 先读完整段转录才开始写,所以耗时随会话长度涨。2026-11-02 的真实读数(935 条事件的会话):开始后 **125 s 才写出第一条**,180 s 到点时只写完 3 条 → 超时;退避重试 131 s 完成。也就是说 180 s 的固定预算对大会话必然偏紧,**不是卡死、不是死锁,也不会丢已写入的记忆**。
|
|
311
|
+
|
|
312
|
+
**现在的做法**:预算按范围大小推(`consolidationWaitBudget(eventCount)`,政策 `120 s + 0.35 s/事件`,夹在 `[180 s, 600 s]`;斜率取自上面实测的 0.14–0.2 s/事件并留约 2 倍余量)。显式传 `maxWaitMs` 的调用方(测试、工具)仍然完全由调用方决定。「整理已开始」那条日志现在会写「预算 Ns」,失败行也会写「over N events」,所以下次看到超时能直接判断是不是范围太大。**超时仍然不会推进 `lastSleepSeq`**(没有回执就不算整理过),重试会重读同一段——这是 `§14.8`「先证明覆盖范围再推进」的代价,不能为了省时间改成部分推进。
|
|
313
|
+
|
|
314
|
+
**还能再快的两条路(未做,需拍板)**:① 把 fork 的种子换成脱敏压缩后的转录(远端路径 `condenseEvents` 已有先例,但 fork 的种子来自 `dsh-session.buildForkSeed`,要动得先确认能替换);② 常驻 MemU 进程,替掉「每次工具调用新起 python(导入链 2.05 s)」——这条同时能提速每轮召回与迁移重建。
|
|
315
|
+
|
|
316
|
+
**守卫**:`tests/consolidation-fork.test.mjs` 的 `the consolidation wait budget scales with the transcript`(0/100/200/935/5000/非法值)与既有的 `a fork still running at the deadline reports a timeout instead of silence`(显式 30 ms 仍生效、超时不得推进游标)。
|
|
317
|
+
|
|
252
318
|
|
|
253
319
|
## 守卫索引表
|
|
254
320
|
|
|
@@ -277,12 +343,18 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
277
343
|
| §3.18 | 聊很久一条记忆都没写 | `tests/cycle.test.mjs`(阈值 / 启动补偿 / `sessionGone` 只标一次 / 寒暄不 fork / fork 失败必须退避)+ `tests/consolidation-value.test.mjs`(评估边界)+ `tests/consolidation-fork.test.mjs`(继承父模型路由 / 失败 turn 不推进 `lastSleepSeq`);手工看 `state.json` 的 `lastSleepAt`/`lastSleepSeq`/`sessionGone`/`sleepAttempts`/`lastSleepError`/`sleepRetryAt`。 |
|
|
278
344
|
| §3.19 | 人格预设会话里完全没有记忆 | `tests/preset-scope.test.mjs`(同树跳过 / 兄弟树挂上 / 只挂一次 / agent 消失就卸载 / 子 agent 跳过);日志 `attached memory injection to preset conversation`;`state.json` 里该会话出现 binding。 |
|
|
279
345
|
| §3.20 | 鉴权矩阵 / 401/403 副作用 | `tests/webui-auth.test.mjs`:两前缀各自 handler、401/403/放行、正文零拉取、`DSH_MEMU_HOME` 读写探针为 0、库/附件快照不变;真机凭据与宿主路由层未验证。 |
|
|
346
|
+
| §3.21 | 日期到点没唤醒 | `tests/salient-wake.test.mjs`;活动日志 `kind:'wake'` 的 `detail.stage`(service/timezone/index/list/cleanup/create/pass)就是排查线,`state.json` 里先确认 `salientWake` 真的存下了。 |
|
|
347
|
+
| §3.22 | 时效提示没出现 | `tests/freshness.test.mjs` + `tests/injection-chain.test.mjs`;前置条件(真有召回、开关、预算装得下)少一个就不出,不是 bug。 |
|
|
348
|
+
| §3.23 | 实体合并 / 担心丢记忆 | `tests/entity-merge.test.mjs`(链接改指、别名 cap、快照冲突取舍、拒绝形状);合并只改指向,正文与条数不变。 |
|
|
349
|
+
| §3.24 | 失败一轮后锚点/日期再不出现 | `tests/injection-rollback.test.mjs`(6 条:撤回+重投、completed 不重复、迟到事件撤不动、已进转录的 500 类失败不误撤、投放前取消撤回、纪念日复提时钟一起撤)。 |
|
|
350
|
+
| §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 串逐字节不变)。 |
|
|
351
|
+
| §3.26 | 整理超时(fork 预算) | `tests/consolidation-fork.test.mjs`:预算随事件数缩放(0/100/200/935/5000/非法值),显式 `maxWaitMs` 仍生效,超时不推进 `lastSleepSeq`。 |
|
|
280
352
|
|
|
281
353
|
## 附录 A · 模块地图(原 §2.1)
|
|
282
354
|
|
|
283
355
|
### 2.1 模块地图
|
|
284
356
|
|
|
285
|
-
<!-- rpc-method-count:
|
|
357
|
+
<!-- rpc-method-count: 95 -->
|
|
286
358
|
|
|
287
359
|
| 文件 | 职责 / 什么时候碰它 |
|
|
288
360
|
|---|---|
|
|
@@ -292,15 +364,17 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
292
364
|
| `lib/memory.js` | 分层、`decayStrength`、`recallScore`、边缘化、领域过滤、`privateRemember/Recall/Update`(改语义最需小心) |
|
|
293
365
|
| `lib/state.js` | `state.json` 与 `index/*.json` 原子读写、合并写、`memoryRevision`/`memoryStamp`、`syncActivity`、`DEFAULT_SETTINGS` |
|
|
294
366
|
| `lib/paths.js` | 读失败隔离:`readJsonStrict`、`*.corrupt-*`、写屏障 |
|
|
295
|
-
| `lib/tools.js` |
|
|
367
|
+
| `lib/tools.js` | 13 个 `memu_*` 工具、输出格式化 |
|
|
296
368
|
| `lib/private.js` | 私有整理:当前对话、历史 fork、notice 消息 |
|
|
297
369
|
| `lib/curator.js` / `lib/cycle.js` | 全局 curator 与 `pending_review`;空闲整理 pass(过期/降级/晋升/自动整理) |
|
|
298
370
|
| `lib/mood.js` / `lib/budget.js` / `lib/snippet.js` | 情绪价与峰值;token 换算(中文≈1 字符/token、英文≈3.4,任何 token 都走它);注入片段裁剪 |
|
|
299
|
-
| `lib/rpc.js` / `lib/client.js` / `lib/webui.js` + `lib/webui/standalone.js` | `/dsh-memu-memory` 的
|
|
371
|
+
| `lib/rpc.js` / `lib/client.js` / `lib/webui.js` + `lib/webui/standalone.js` | `/dsh-memu-memory` 的 95 个方法(旧路由别名同一鉴权);九页设置 + 侧边栏 `MemoryTab` + `useMemoryBeat`;独立壳挂载同一 SettingsPage,不复制实现 |
|
|
300
372
|
| `lib/graph.js` / `lib/context.js` / `lib/media.js` | 关系边与实体;说话人/频道/角色/世界线/知情边界;附件采集、缩略图、受保护路由、ZIP |
|
|
301
373
|
| `lib/prompts.js` + `lib/prompts/` | 提示词加载/覆盖/恢复/domain 变体解析 |
|
|
302
374
|
| `lib/engine.js` / `lib/memu.js` / `lib/memu-config.js` | Python 引擎安装探测切换回滚;MemU CLI 适配(**所有 CLI 字符串只在这里**);`~/.memu/config.env` 的 embedding |
|
|
303
375
|
| `lib/stats.js` | 私有库旁路计数(`written/injected/recalled/archived`,90 天滚动);读失败只降级页面,不碰记忆 |
|
|
376
|
+
| `lib/lexicon.js` / `lib/private-links.js` | 词典条目与 `active/archived` 生命周期、注入行渲染;整理后的本地自动关联候选与枢纽 |
|
|
377
|
+
| `lib/freshness.js` / `lib/salient-wake.js` | 时间敏感信号的只读判定(喂 `<memory-freshness>` 提示);用宿主 `ctx.schedule` 排「到点唤醒」一次性任务(默认关闭) |
|
|
304
378
|
| `lib/remote-summary.js` | 远程摘要 |
|
|
305
379
|
|
|
306
380
|
|
package/lib/activity-log.js
CHANGED
|
@@ -13,7 +13,7 @@ import { logsDir, ensureDir, redactSecrets, warn } from './paths.js'
|
|
|
13
13
|
// 3. 出盘前脱敏。message 与 detail 都过 redactSecrets;detail 只留诊断需要的字段,
|
|
14
14
|
// 正文最多 200 字符(召回查询、记忆标题),足够定位问题又不把整段对话抄进日志。
|
|
15
15
|
|
|
16
|
-
export const ACTIVITY_KINDS = Object.freeze(['recall', 'write', 'consolidate', 'curate', 'vector', 'error', 'system', 'check'])
|
|
16
|
+
export const ACTIVITY_KINDS = Object.freeze(['recall', 'write', 'consolidate', 'curate', 'vector', 'error', 'system', 'check', 'wake'])
|
|
17
17
|
const MAX_ENTRIES = 2000
|
|
18
18
|
const MAX_FILE_BYTES = 4 * 1024 * 1024
|
|
19
19
|
const MAX_MESSAGE_CHARS = 300
|
|
@@ -56,7 +56,7 @@ export const RUNTIME_STATE = Object.freeze([
|
|
|
56
56
|
{ layer: 'temporary-map', file: 'lib/media.js:19', name: 'captures', keyedBy: 'sessionId', clearedBy: 'capture settle' },
|
|
57
57
|
{ layer: 'temporary-map', file: 'lib/private.js:347', name: 'inFlight', keyedBy: 'sessionId', clearedBy: 'consolidation settle' },
|
|
58
58
|
{ layer: 'temporary-map', file: 'lib/curator.js:50', name: 'jobs', keyedBy: 'job id', clearedBy: 'curation settle' },
|
|
59
|
-
{ layer: 'cache', file: 'lib/state.js:
|
|
59
|
+
{ layer: 'cache', file: 'lib/state.js:1142', 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
|
|