dsh-memu-memory 1.2.2 → 1.2.3

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 CHANGED
@@ -48,6 +48,8 @@
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
51
53
  ```
52
54
 
53
55
  ---
@@ -61,7 +63,7 @@ node scripts/acceptance-local.mjs # 50/50
61
63
  npm run check # node --check + i18n + package.json + 文档预算
62
64
  ```
63
65
 
64
- **结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。测试数字只作**带日期快照**引用(2026-11-01 实测 1210 tests / 1208 pass / 0 fail / 2 skipped;两条真实引擎用例按设计跳过,历史 505/493/463/409/392 等不再代表当前),不当成当前保证。提交前逐条对 `docs/contributing.md` §10。
66
+ **结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。测试数字只作**带日期快照**引用(2026-11-01 实测 1277 tests / 1275 pass / 0 fail / 2 skipped;两条真实引擎用例按设计跳过,历史 1273/1210/505/493/463/409/392 等不再代表当前),不当成当前保证。提交前逐条对 `docs/contributing.md` §10。
65
67
 
66
68
  ---
67
69
 
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.2. 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.
33
+ > **Status:** 1.2.3. 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, Relations tab |
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.
@@ -356,6 +362,8 @@ The suite includes two optional real-engine integration cases: curator writing r
356
362
 
357
363
  ## Changelog
358
364
 
365
+ **1.2.3 (2026-11-01)**: the six todolist work orders. Emotion now shows on the card (arousal / dominance / source, read-only); dated open loops re-raise every `openLoopRemindDays` instead of going quiet after one mention, and never repeat in a turn that already named them; recalled memory that looks time-sensitive gets one conditional `<memory-freshness>` line nudging the model to verify with a search tool *if* the conversation has one; optional `salientWake` (off by default, experimental) asks the host scheduler to wake the bound conversation on the day; entity merge candidates with two-click confirmation in the graph page (RPC methods 93 → 95). Also a loopback-only injection measurement harness (`scripts/mock-llm.mjs` + `scripts/drive-session.mjs`) so later tuning can be counted instead of argued about. No new dependencies, no build step, no data migration.
366
+
359
367
  **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
368
 
361
369
  **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.
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.2。首个公开发布版本为 1.0.0。细节文档已迁到 [`docs/`](docs/),[`AGENTS.md`](AGENTS.md) 只做索引。升级前请备份 `~/.dsh/dsh-memu-memory`;如果要存无法重建的数据,请先读[兼容性与边界](#兼容性与边界)。
33
+ > **状态:** 1.2.3。首个公开发布版本为 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 工作区里开写代码的对话不必事后再去侧边栏切换。
@@ -342,6 +348,8 @@ node --import ./tests/loader-register.mjs scripts/preview.mjs --port 7789
342
348
 
343
349
  ## 更新日志
344
350
 
351
+ **1.2.3(2026-11-01)**:`todolist` 六条设想的施工版本。情绪四轴上卡片(激活/掌控/来源,只读);带日期的未了之事过期后按 `openLoopRemindDays` 复提,且同回合不会和纪念日重复念;召回里带时间敏感信号的条目会在块尾收到一条条件式时效提示(引导模型在有搜索工具时先核实);可选的 `salientWake` 用宿主定时任务在日子当天唤醒会话(默认关闭、实验特性);节点图新增实体合并候选与两次点击确认(RPC 方法 93 → 95)。另有一套只监听本机的注入实测台(`scripts/mock-llm.mjs` + `scripts/drive-session.mjs`),让后续调参能被计数而不是靠争论。无新增依赖、无构建步骤、无数据迁移。
352
+
345
353
  **1.2.2(2026-11-01)**:锚点/召回改为标题卡(正文留在 recall 工具与抽屉);词典自动入库与卡片管理;私有自动关联/实体枢纽;帮助页 v2;WebUI 布局与选择器优化;并合并此前未单独发布的 curator 三段式、全局关联、absorb 撤销、审核模式与词典库基线。远程整理提示词保持无工具、标题统一 8–40 字;PTC worker 挂载 5 写 + 3 读工具;无新增依赖或构建步骤。
346
354
 
347
355
  **1.2.1(2026-10-31)**:事实级去重(写入近似门 + 召回按簇折叠);PTC(run_code)会话整理可用;侧边栏整理失败提醒(跨会话、可清除、可跳转);「当前已入向量库」计数跟随真实增减;记忆墙私有/全局分组与多选批量操作;全局记忆一键查看;关系图删除级联与孤儿回收;整理写入计数说真话。
@@ -23,6 +23,7 @@
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)。
26
27
  - 设置项 = 即时保存 + 250ms trailing debounce,一次重试 + `console.warn`,`pagehide` 时 flush。反馈用 toast(2.6s),不用常驻 error/notice 字符串。
27
28
 
28
29
  ### 7.4 数据与刷新
@@ -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 实测 1210 tests / 1208 pass / 0 fail / 2 skipped(curator 真实引擎与备份 venv/WAL 两条为 opt-in,按设计跳过);更早的 505 / 392 / 321 / 327 / 333 等是历史快照或转述,不能当作当前保证。
23
+ **结果口径**:以 `node --test` 输出的 `ℹ tests / pass / fail / skipped` 为准。用例数变了先问「是不是我加的」,失败先问「是不是并发写了同一个库」——这仓库真会多个会话同时改它。文档里出现的测试数字一律当作**带日期的快照**:2026-11-01 实测 1277 tests / 1275 pass / 0 fail / 2 skipped(curator 真实引擎与备份 venv/WAL 两条为 opt-in,按设计跳过);更早的 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: 93 -->
78
+ <!-- rpc-method-count: 95 -->
79
79
 
80
- 1. `lib/rpc.js` 的 `switch` 加 case(共 93 个方法,按功能分组,别乱插)。
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` 白名单 + 类型校验,需要 clamp 的在这里。
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 恒人审。三处注册:DEFAULT_SETTINGS / updateSettings.enums / rpc setSettings+resetSettings。
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 | 文档与只读展示 | 完成;WebUI 编辑控件按 §1.2 不做 |
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 编写,不迁就实现)+ 全量 `npm test` 944 / 942 pass / 0 fail / exit 0。
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 项断言全通过。
@@ -73,4 +73,24 @@ 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.6 注入实测台(1.2.3 工单 B,仅评测用)
77
+
78
+ **目的**:注入「发了什么」不等于「模型收到了什么」。这两个脚本只量最后一环——宿主真正发给模型的请求体里出现了哪些记忆块、出现几次。它们**不是运行时依赖**,`lib/` 永不 import,日志只记长度/哈希与标记计数(不记正文)。
79
+
80
+ ```bash
81
+ node scripts/mock-llm.mjs --port 8123 --log ./mock-llm-<日期>.jsonl # 伪 OpenAI 端点,只监听 127.0.0.1,无鉴权
82
+ node scripts/mock-llm.mjs --reply-file ./tests/fixtures/mock-llm/reply.txt --port 8123 --log ./mock.jsonl
83
+ node scripts/mock-llm.mjs --report ./mock-llm-<日期>.jsonl > mock-llm-report-<日期>.md
84
+ node scripts/drive-session.mjs --session <id> --turns 50 --dry-run # 只打印将要发的请求,不发
85
+ node scripts/drive-session.mjs --session <id> --turns 50 \
86
+ --base http://127.0.0.1:<gateway 端口> --allow-api-route --requests-out ./requests.jsonl
87
+ ```
88
+
89
+ - 用法:DSH 的 provider profile 把 `baseURL` 指到 `http://127.0.0.1:8123/v1`(apiKey 随意),测试会话绑定一个手写播种库,再用 `drive-session.mjs` 灌轮数;`--report` 出「每轮 × 标记矩阵 + 汇总」。
90
+ - 标记表 pin 在 `scripts/mock-llm.mjs` 的 `MARKERS`(`MARKER_SET_VERSION` 记插件版本)。**改 `lib/inject.js` 的块标记必须同处更新并 bump 版本**,否则报告把新块记成 0。
91
+ - `drive-session.mjs` 走宿主公开的 `sessionController.prompt`(`POST <base>/api/session/prompt` 的 Connection carrier 形状),并且**默认拒绝发送**:没有 `--allow-api-route` 就打印等价的手工请求并退出码 3。轮结束只认持久 session log 里本轮 `turn/end` 的 `reason.kind === 'completed'`。
92
+ - 退出码:`0` 全部完成 / `1` 某轮或传输失败 / `2` 用法错 / `3` 未授权传输(手工降级)/ `4` 观察不到 session log。
93
+ - 数据是**要丢弃的**:报告文件名带日期,别把捕获的对话提交进仓库,也别把伪端点当日常后端。
94
+ - **1.2.3 只交付了这套量具,还没跑过基线**:仓库里没有 `mock-llm-report-*.md`,所以任何「注入次数变化」的说法都还没有数据支撑。C/D 合入后的对照数据是待做项,跑法就是上面四条命令;报告里每个 0 注入的轮都要能解释(去重 / 预算 / 太短 / 无库),解释不了的轮次视为数据不可用。
95
+
76
96
  ---
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
 
@@ -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` 已删除,方法数 93。
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
 
@@ -247,6 +247,34 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
247
247
 
248
248
  **守卫**:`tests/webui-auth.test.mjs`(两前缀各自 handler、401/403/放行、正文零拉取、home 读写探针、快照与附件池绊线)。手工排查时先确认 `requestRejection` 的调用计数为 1,再看拒绝响应体是否只有 `unauthorized`/`forbidden`;不要靠「页面能打开」判断鉴权通过。
249
249
 
250
+ ### 3.21 日期到点没唤醒会话(S6 注入 → 宿主 schedule)
251
+
252
+ **症状**:开了 `salientWake='schedule'`,条目明天到期,第二天会话里什么都没发生;或者宿主的定时任务界面里根本没有 `memu:due:` 任务。
253
+
254
+ **落点**:`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`)就是这条排查线。
255
+
256
+ **已经建了任务但没开口**:投递是 `agent.followup`,宿主进程必须活着;那一回合的 `source.kind==='schedule'`,本插件的召回/纪念日块**不会**运行,能看到的只有唤醒 prompt 自带的内容(这是设计,见 `docs/host-api.md` §6.6)。用户手删的任务会在下一轮 sweep 重建——同一天已 `ended` 的才清理。
257
+
258
+ **守卫**:`tests/salient-wake.test.mjs`(默认 off 不问宿主、无服务只 warn 一次、今天/明天各一条且 prompt 自包含、二次 sweep 幂等、ended 清理、paused 不动、subagent/归档/其它错误只跳过该会话、年度 `MM-DD` 不提前、无效时区不抛错)。真机验收项单独记录:造一条明天到期的条目 → 宿主 schedule UI 出现 `memu:due:` → 到点会话被唤醒 → 次日 sweep 清理。
259
+
260
+ ### 3.22 时效提示没出现(S6 注入)
261
+
262
+ **症状**:明明召回了一条写于半年前、标题带「最新」的记忆,块尾却没有 `<memory-freshness>`。
263
+
264
+ **落点**:这条提示是**追加**在已生成的召回块之后的,前置条件少一个就不出:本回合真的有召回(`autoInject` 不是 `anchor-only`、用户文本过 `minUserChars`、命中非空)、`freshnessHint !== false`、至少一条**进入文本的**条目带信号、`turnTokens` 预算还剩得下这一行。三个信号里年龄那条最容易被误判:`owner=about_project` 的工程事实不按年龄算陈旧,年度 `MM-DD` 日期永不过期。计算异常只 `warn`,召回照常(fail-open)。
265
+
266
+ **守卫**:`tests/freshness.test.mjs`(三信号真值表、缺字段/NaN 不命中、一次性过期 vs 年度日期)+ `tests/injection-chain.test.mjs`(命中出、全基线不出、`anchor-only` 不出、开关关不出)。
267
+
268
+ ### 3.23 实体合并的疑问与风险(S9 图谱)
269
+
270
+ **症状**:节点图里两个人名指同一个人;或者合并后担心「链接改了、记忆是不是丢了」。
271
+
272
+ **落点**:候选来自 `suggestEntityMerges`(纯读,同 `kind` + 包含/编辑距离,上限 20),UI 只列建议,两次点击确认才调 `mergeEntities`。合并改的是**指向**:来源实体的名字进别名(cap 30,超出在回执里明说)、私有索引里 `links[].to` 改指主节点(同 `(to,kind)` 去重)、关系快照按端点对重键(与主节点侧冲突时保留主节点侧),最后删除来源实体并 prune 孤立实体。**记忆正文与条数不变**,`docs/memory-semantics.md` §8.14 是口径。回执数字(改指多少链接、并入多少别名)来自返回值,不是估算。
273
+
274
+ 想回退只能靠备份:`lib/backup.js` 的既有导出/备份路径,合并本身没有 undo。
275
+
276
+ **守卫**:`tests/entity-merge.test.mjs`(链接全改指、别名并集与 cap、快照重键与冲突取舍、kind 不同/自指/未知 id 拒绝且不写、prune、suggest 真值表与纯读、RPC payload 形状);授权矩阵见 `tests/webui-auth.test.mjs`。
277
+
250
278
  ---
251
279
 
252
280
 
@@ -277,12 +305,15 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
277
305
  | §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
306
  | §3.19 | 人格预设会话里完全没有记忆 | `tests/preset-scope.test.mjs`(同树跳过 / 兄弟树挂上 / 只挂一次 / agent 消失就卸载 / 子 agent 跳过);日志 `attached memory injection to preset conversation`;`state.json` 里该会话出现 binding。 |
279
307
  | §3.20 | 鉴权矩阵 / 401/403 副作用 | `tests/webui-auth.test.mjs`:两前缀各自 handler、401/403/放行、正文零拉取、`DSH_MEMU_HOME` 读写探针为 0、库/附件快照不变;真机凭据与宿主路由层未验证。 |
308
+ | §3.21 | 日期到点没唤醒 | `tests/salient-wake.test.mjs`;活动日志 `kind:'wake'` 的 `detail.stage`(service/timezone/index/list/cleanup/create/pass)就是排查线,`state.json` 里先确认 `salientWake` 真的存下了。 |
309
+ | §3.22 | 时效提示没出现 | `tests/freshness.test.mjs` + `tests/injection-chain.test.mjs`;前置条件(真有召回、开关、预算装得下)少一个就不出,不是 bug。 |
310
+ | §3.23 | 实体合并 / 担心丢记忆 | `tests/entity-merge.test.mjs`(链接改指、别名 cap、快照冲突取舍、拒绝形状);合并只改指向,正文与条数不变。 |
280
311
 
281
312
  ## 附录 A · 模块地图(原 §2.1)
282
313
 
283
314
  ### 2.1 模块地图
284
315
 
285
- <!-- rpc-method-count: 93 -->
316
+ <!-- rpc-method-count: 95 -->
286
317
 
287
318
  | 文件 | 职责 / 什么时候碰它 |
288
319
  |---|---|
@@ -292,15 +323,17 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
292
323
  | `lib/memory.js` | 分层、`decayStrength`、`recallScore`、边缘化、领域过滤、`privateRemember/Recall/Update`(改语义最需小心) |
293
324
  | `lib/state.js` | `state.json` 与 `index/*.json` 原子读写、合并写、`memoryRevision`/`memoryStamp`、`syncActivity`、`DEFAULT_SETTINGS` |
294
325
  | `lib/paths.js` | 读失败隔离:`readJsonStrict`、`*.corrupt-*`、写屏障 |
295
- | `lib/tools.js` | 10 个 `defineTool` 工具、输出格式化 |
326
+ | `lib/tools.js` | 13 个 `memu_*` 工具、输出格式化 |
296
327
  | `lib/private.js` | 私有整理:当前对话、历史 fork、notice 消息 |
297
328
  | `lib/curator.js` / `lib/cycle.js` | 全局 curator 与 `pending_review`;空闲整理 pass(过期/降级/晋升/自动整理) |
298
329
  | `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` 的 93 个方法(旧路由别名同一鉴权);九页设置 + 侧边栏 `MemoryTab` + `useMemoryBeat`;独立壳挂载同一 SettingsPage,不复制实现 |
330
+ | `lib/rpc.js` / `lib/client.js` / `lib/webui.js` + `lib/webui/standalone.js` | `/dsh-memu-memory` 的 95 个方法(旧路由别名同一鉴权);九页设置 + 侧边栏 `MemoryTab` + `useMemoryBeat`;独立壳挂载同一 SettingsPage,不复制实现 |
300
331
  | `lib/graph.js` / `lib/context.js` / `lib/media.js` | 关系边与实体;说话人/频道/角色/世界线/知情边界;附件采集、缩略图、受保护路由、ZIP |
301
332
  | `lib/prompts.js` + `lib/prompts/` | 提示词加载/覆盖/恢复/domain 变体解析 |
302
333
  | `lib/engine.js` / `lib/memu.js` / `lib/memu-config.js` | Python 引擎安装探测切换回滚;MemU CLI 适配(**所有 CLI 字符串只在这里**);`~/.memu/config.env` 的 embedding |
303
334
  | `lib/stats.js` | 私有库旁路计数(`written/injected/recalled/archived`,90 天滚动);读失败只降级页面,不碰记忆 |
335
+ | `lib/lexicon.js` / `lib/private-links.js` | 词典条目与 `active/archived` 生命周期、注入行渲染;整理后的本地自动关联候选与枢纽 |
336
+ | `lib/freshness.js` / `lib/salient-wake.js` | 时间敏感信号的只读判定(喂 `<memory-freshness>` 提示);用宿主 `ctx.schedule` 排「到点唤醒」一次性任务(默认关闭) |
304
337
  | `lib/remote-summary.js` | 远程摘要 |
305
338
 
306
339
 
@@ -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:970', name: 'indexCache', keyedBy: 'libraryId', clearedBy: 'next load / external write' },
59
+ { layer: 'cache', file: 'lib/state.js:1061', 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