dsh-memu-memory 1.2.1 → 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.
Files changed (105) hide show
  1. package/AGENTS.md +3 -1
  2. package/README.md +23 -8
  3. package/README.zh.md +16 -6
  4. package/docs/client-conventions.md +1 -0
  5. package/docs/contributing.md +18 -4
  6. package/docs/emotion-model-spec.md +2 -2
  7. package/docs/env-and-commands.md +20 -0
  8. package/docs/host-api.md +22 -1
  9. package/docs/memory-semantics.md +30 -2
  10. package/docs/troubleshooting.md +76 -5
  11. package/lib/activity-log.js +1 -1
  12. package/lib/backup.js +24 -2
  13. package/lib/binding-diagnostics.js +2 -2
  14. package/lib/client.js +1511 -153
  15. package/lib/consolidation-worker.js +30 -8
  16. package/lib/curator-evidence.js +131 -0
  17. package/lib/curator-policy.js +81 -0
  18. package/lib/curator.js +1252 -91
  19. package/lib/cycle.js +12 -1
  20. package/lib/embedding-download.js +39 -4
  21. package/lib/engine.js +6 -3
  22. package/lib/freshness.js +97 -0
  23. package/lib/global-graph.js +282 -0
  24. package/lib/graph.js +295 -11
  25. package/lib/inbound.js +19 -0
  26. package/lib/inject.js +396 -25
  27. package/lib/lexicon.js +1115 -0
  28. package/lib/local-vector-service.js +8 -6
  29. package/lib/managed-runtime.js +33 -2
  30. package/lib/memory.js +365 -34
  31. package/lib/memu.js +2 -2
  32. package/lib/migrate.js +83 -2
  33. package/lib/private-links.js +587 -0
  34. package/lib/private.js +32 -3
  35. package/lib/prompts/global-curator.md +76 -19
  36. package/lib/prompts/private-consolidation.coding.md +4 -1
  37. package/lib/prompts/private-consolidation.md +3 -1
  38. package/lib/prompts/private-consolidation.mixed.md +3 -1
  39. package/lib/prompts/private-consolidation.rp.md +3 -1
  40. package/lib/prompts.js +1 -1
  41. package/lib/rpc.js +589 -10
  42. package/lib/salient-wake.js +402 -0
  43. package/lib/state.js +95 -1
  44. package/lib/text-retrieval.js +661 -0
  45. package/lib/text-similarity.js +36 -18
  46. package/lib/tools.js +168 -10
  47. package/lib/webui/standalone.css +17 -0
  48. package/lib/webui/standalone.js +2 -0
  49. package/package.json +1 -1
  50. package/scripts/acceptance-local.mjs +8 -5
  51. package/scripts/curator-pair-calibrate.mjs +259 -0
  52. package/scripts/drive-session.mjs +853 -0
  53. package/scripts/lexicon-calibrate.mjs +230 -0
  54. package/scripts/lexicon-dedupe.mjs +318 -0
  55. package/scripts/mock-llm.mjs +903 -0
  56. package/tests/absorb-review.test.mjs +353 -0
  57. package/tests/appendix-b2.test.mjs +2 -2
  58. package/tests/client-export.test.mjs +520 -0
  59. package/tests/client-render.test.mjs +32 -4
  60. package/tests/consolidation-fork.test.mjs +14 -12
  61. package/tests/consolidation-snapshot.test.mjs +39 -0
  62. package/tests/curator-absorb.test.mjs +443 -0
  63. package/tests/curator-calibrate.test.mjs +173 -0
  64. package/tests/curator-clusters.test.mjs +281 -0
  65. package/tests/curator-commit.test.mjs +52 -5
  66. package/tests/curator-evidence.test.mjs +102 -0
  67. package/tests/curator-link.test.mjs +316 -0
  68. package/tests/curator-pairing.test.mjs +252 -0
  69. package/tests/curator-probe.test.mjs +15 -6
  70. package/tests/curator-review-mode.test.mjs +314 -0
  71. package/tests/disclosure.test.mjs +2 -1
  72. package/tests/entity-merge.test.mjs +261 -0
  73. package/tests/fixtures/curator-pairs/labeled.v1.jsonl +90 -0
  74. package/tests/fixtures/lexicon-stub-hooks.mjs +15 -0
  75. package/tests/fixtures/lexicon-stub.mjs +284 -0
  76. package/tests/fixtures/mock-llm/reply.txt +1 -0
  77. package/tests/freshness.test.mjs +140 -0
  78. package/tests/graph-cascade.test.mjs +35 -2
  79. package/tests/graph.test.mjs +96 -0
  80. package/tests/help-page.test.mjs +415 -0
  81. package/tests/inbound.test.mjs +6 -3
  82. package/tests/inject-guide.test.mjs +28 -0
  83. package/tests/inject.test.mjs +157 -5
  84. package/tests/injection-chain.test.mjs +176 -0
  85. package/tests/lexicon-calibrate.test.mjs +48 -0
  86. package/tests/lexicon-dedupe.test.mjs +171 -0
  87. package/tests/lexicon-frequency.test.mjs +179 -0
  88. package/tests/lexicon-inject.test.mjs +410 -0
  89. package/tests/lexicon-perf.test.mjs +436 -0
  90. package/tests/lexicon-ui.test.mjs +547 -0
  91. package/tests/lexicon.test.mjs +922 -0
  92. package/tests/managed-runtime.test.mjs +32 -0
  93. package/tests/mock-llm.test.mjs +225 -0
  94. package/tests/open-loop-date.test.mjs +406 -0
  95. package/tests/private-links.test.mjs +445 -0
  96. package/tests/prompts.test.mjs +35 -0
  97. package/tests/recall-dedup.test.mjs +33 -4
  98. package/tests/salient-wake.test.mjs +362 -0
  99. package/tests/settings-plumbing.test.mjs +76 -0
  100. package/tests/sidebar.test.mjs +5 -1
  101. package/tests/stubs/dsh-schedule.js +105 -0
  102. package/tests/tool-schema.test.mjs +1 -1
  103. package/tests/tools.test.mjs +112 -3
  104. package/tests/webui-auth.test.mjs +352 -2
  105. package/tests/webui.test.mjs +188 -0
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-10-29 W7/W8 集成后实测 505 tests / 504 pass / 1 skipped;同日更早的 W7 为 493/492/1、W3–W9 为 463/462/1、W1/W2 为 409/408/1 与 392/391/1,321/327/333 原报告缺失、不可复核),不当成当前保证。提交前逐条对 `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.1. 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
 
@@ -57,7 +57,9 @@ All screenshots are the real WebUI on isolated example data, not anyone's memori
57
57
  ## What it remembers
58
58
 
59
59
  - **Three layers, one timeline.** `short_term` drafts expire after 72 hours by default; `long_term` is the body of ordinary memory; `must_remember` needs a reason and a source, decays over 365 days with a 0.35 strength floor, and can be *marginalized* but never auto-deleted to make room.
60
- - **Recall is a moment, not a dump.** The first turn after a session starts (or after compaction) gets an anchor block with budgets for pinned, core and global memory. After that, each user turn gets at most one recall. Deduplication and a token budget are enforced in code, not left to the prompt.
60
+ - **Recall is a moment, not a dump.** The first turn after a session starts (or after compaction) gets an anchor block with budgets for pinned, core and global memory. After that, each user turn gets at most one recall. Deduplication and a token budget are enforced in code, not left to the prompt. Anchor and recall entries are **title cards**: title, id and semantic tags only. The body stays in the drawer and behind `memu_private_recall` / `memu_global_recall`, so the same budget exposes far more memories without pasting text the model never asked for.
61
+ - **A private lexicon writes itself.** The consolidation worker extracts stable, evidenced slang, memes and project terms with one term per entry. Ordinary entries become active immediately (no human review queue), while sensitive triggers and sensitive edits stay user-only. The lexicon page is a card flow with active/archived tabs, edit, archive/restore and two-step permanent delete.
62
+ - **Private links are algorithm-first.** After consolidation, a zero-token pass connects memories that share a rare name or alias in the same context/track and creates/reuses an entity hub (for example `yuike`). Uncertain pairs are handed to the consolidation worker for an evidence-based decision. Links are metadata (`source: 'auto'`), shown with an “Auto” badge in the graph and removable; they never rewrite a body, write a vector or delete anything.
61
63
  - **A date is either an anniversary or one day.** `MM-DD` recurs every year (a birthday); `YYYY-MM-DD` fires the day before and the day itself, then is spent. A memory that says "tomorrow" is stored as the dated form, so an appointment does not come back every year.
62
64
  - **Memory fades unevenly.** Recency, access count, peak and end effects, primacy, habituation and flashbulb accuracy feed one strength score. Mood is described by four components (joy / anger / sorrow / fear, summing to 1) plus arousal (intensity) and dominance (sense of control); a compound mood such as jealousy is a named mix of the four, not a new axis. Mood only reorders recall: it never enters the injected text and never rewrites a memory body. Gating is the OR of three independent conditions — the dominant share is >= 0.35, |arousal - 0.35| >= 0.1, or |dominance| >= 0.25; when none holds, both multipliers are exactly 1. Older entries carry no emotion and keep the old valence path; the four axes are never inferred back from valence. A vivid memory can be more confident than it is accurate, and the UI says so.
63
65
  - **Provenance is a fact, not a style.** Every entry carries `source` (`user_said` / `inferred` / `imagined` / `told`), `confidence`, `accuracy`, and disclosure rules. A vague recollection cannot impersonate a quote.
@@ -105,13 +107,13 @@ The sidebar has exactly **one** entry: **MemU WebUI**. The memory wall and all s
105
107
 
106
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.
107
109
 
108
- 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.
109
111
 
110
112
  | Page | What it is for |
111
113
  |---|---|
112
- | 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 |
113
115
  | Engine & connection | Optional MemU engine install/switch, embedding endpoint, backups and restore |
114
- | 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 |
115
117
  | Folders | Folder-level private/global ceiling, expandable conversations and their own switches |
116
118
  | Libraries | Create, rename, archive, restore, explicitly delete libraries |
117
119
  | Memory browser | Full-text editing, attachments, review queue, graph and bounded canvas, JSON/ZIP import/export |
@@ -123,7 +125,13 @@ Settings save as you change them (250 ms debounce), with about 2.5 s cross-windo
123
125
 
124
126
  ### Injection token budgets
125
127
 
126
- `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.
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
+
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.
127
135
 
128
136
  ### Domain Prompts
129
137
 
@@ -236,7 +244,10 @@ Folder policy is a **ceiling, not an initial value**: turning a folder switch of
236
244
  | `memu_private_update` | Edit, without bypassing pin admission, review or visibility rules |
237
245
  | `memu_private_archive` | Archive; never delete |
238
246
  | `memu_private_unpin` | Marginalize a permanent memory with a first-person reason, quota and cooldown |
239
- | `memu_private_link` | Link memories/entities with evidence, or update a relationship snapshot; cannot delete edges |
247
+ | `memu_private_link` | Link memories/entities with evidence, or update a relationship snapshot; also adjudicates `memu_private_link_suggest` candidates; cannot delete edges |
248
+ | `memu_private_link_suggest` | Run the local high-confidence linking/entity-hub pass for ids written this consolidation and return only uncertain candidate pairs |
249
+ | `memu_lexicon_search` | Search active private-lexicon terms; archived and tombstoned terms stay hidden |
250
+ | `memu_lexicon_propose` | Add or update a lexicon term; ordinary entries become active immediately, sensitive triggers remain user-only |
240
251
  | `memu_global_recall` / `memu_global_list` | Read the global layer by domain |
241
252
  | `memu_status` | Storage health, sync heartbeat, recall state and image-turn status |
242
253
 
@@ -347,10 +358,14 @@ The preview serves the real WebUI against isolated example data at `http://127.0
347
358
 
348
359
  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; bundled D3 licenses are in `lib/webui/graph-LICENSE.txt`.
349
360
 
350
- The suite includes one real-engine integration case that is skipped unless `DSH_MEMU_TEST_ENGINE_PYTHON` is set; 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.
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.
351
362
 
352
363
  ## Changelog
353
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
+
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.
368
+
354
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.
355
370
 
356
371
  **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).
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.1。首个公开发布版本为 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 工作区里开写代码的对话不必事后再去侧边栏切换。
@@ -338,10 +344,14 @@ node --import ./tests/loader-register.mjs scripts/preview.mjs --port 7789
338
344
 
339
345
  预览运行后,可在另一终端执行 `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,D3 许可随资源保存在 `lib/webui/graph-LICENSE.txt`。
340
346
 
341
- 测试包含一条真实引擎集成用例,未设置 `DSH_MEMU_TEST_ENGINE_PYTHON` 时按设计跳过;50 条自动验收全部通过。可选引擎已在隔离目录安装并跑通锁定 wheel 的 smoke;embedding 测试使用本机确定性服务,只证明协议可用,不证明语义质量。
347
+ 测试包含两条可选真实引擎集成用例:curator 写入需设置 `DSH_MEMU_TEST_ENGINE_PYTHON`,备份 venv/WAL 需设置 `DSH_MEMU_BACKUP_REAL_ENGINE=1`,默认按设计跳过;50 条自动验收全部通过。可选引擎已在隔离目录安装并跑通锁定 wheel 的 smoke;embedding 测试使用本机确定性服务,只证明协议可用,不证明语义质量。
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
+
353
+ **1.2.2(2026-11-01)**:锚点/召回改为标题卡(正文留在 recall 工具与抽屉);词典自动入库与卡片管理;私有自动关联/实体枢纽;帮助页 v2;WebUI 布局与选择器优化;并合并此前未单独发布的 curator 三段式、全局关联、absorb 撤销、审核模式与词典库基线。远程整理提示词保持无工具、标题统一 8–40 字;PTC worker 挂载 5 写 + 3 读工具;无新增依赖或构建步骤。
354
+
345
355
  **1.2.1(2026-10-31)**:事实级去重(写入近似门 + 召回按簇折叠);PTC(run_code)会话整理可用;侧边栏整理失败提醒(跨会话、可清除、可跳转);「当前已入向量库」计数跟随真实增减;记忆墙私有/全局分组与多选批量操作;全局记忆一键查看;关系图删除级联与孤儿回收;整理写入计数说真话。
346
356
 
347
357
  **1.1.3(2026-10-30)**:受管本地向量可用(运行时/模型下载、切换重建、进度与失败明细);活动日志与「日志」页;整理结果落到侧边栏按钮下方;归档/还原与列表刷新提速到毫秒级;日期漏填时从正文兜底;默认 topK 5/5;修复设置/WebUI 白屏。
@@ -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-10-29 实测 392 tests / 391 pass / 0 fail / 1 skipped(真实引擎用例按设计跳过);更早的 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: 86 -->
78
+ <!-- rpc-method-count: 95 -->
79
79
 
80
- 1. `lib/rpc.js` 的 `switch` 加 case(共 86 个方法,按功能分组,别乱插)。
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`。
@@ -186,3 +186,17 @@ npm run check # node --check + i18n 键对齐 + package.j
186
186
  - [ ] `npm run check` 输出 `all checks passed`?
187
187
  - [ ] 新文案同时进了 `zh` / `en`?
188
188
  - [ ] `README.md` 能力/限制段同步了?「会坏在哪」补进了 §3 对应段?
189
+
190
+ ### 新增设置
191
+
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
+
194
+ ### 锁顺序不变式
195
+
196
+ 插件有多个文件锁(库索引、entities、词典、整理账本、向量代际闸)。当前唯一允许的嵌套方向是
197
+ `entity(file) → index(file)`(`deleteEntity` 先拿 entities 锁,再在锁内清入边并写索引;1.2.3 的
198
+ `mergeEntities` 同向——实体锁内嵌套索引锁,且**先写索引改指、后删来源实体行**,中途崩溃最多留下可回收的实体,绝不会留下指向已消失实体的边),以及
199
+ `curator(vector) → index/lexicon(file)`(`curator.js` 的 managed 写闸先于索引/词典锁)。**不要**
200
+ 在持有索引锁时回头拿 entities 锁,也不要在词典锁内拿向量闸——AB-BA 死锁不会在单会话测试里
201
+ 稳定复现,但会在大库并发删除/改名时出现。`pruneOrphanEntities` 在 entities 锁内只读索引,不取
202
+ 索引写锁;新增路径若需要写索引,先释放 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
 
@@ -55,6 +74,8 @@ ctx.inject([sidebarRightTabs], ...) + ctx.slots.register({ name: sidebar.right.p
55
74
  ```
56
75
 
57
76
  - 客户端当前 session:`sidebar.right.pane.tab` body 的 `sessionId` prop;客户端会话列表:`ctx.sessions.list`(`ObservableSnapshot`)。
77
+ - **库级授权回调(管理/standalone)**:宿主可提供 `c.connection.authorizeLibrary(req, { libraryId, operation })`。插件只接受严格的 `true`;缺失、`false`、非 `true` 或抛错都按 403 处理。嵌入式请求必须携带 `sessionId`,服务端用持久绑定的 `getSessionBinding(sessionId).libraryId` 与目标 `libraryId` 精确比较;显式 `libraryId`、URL、query 或客户端 token 都不是凭据。`operation` 目前为 `read`、`write`、`archive`、`delete`、`rename`、`restore`、`import`、`export`、`attachment.read`、`review.manage`。HTTP handler 先调用 `requestRejection(req)`;ZIP import 在迭代 request body / `importMediaStream` 前完成库授权。
78
+ - `listReviews`/`resolveReview` 是双作用域端点。带私有 `libraryId` 时遵循同一 session/callback 约束;无 `libraryId`(全局审核队列)时:嵌入式请求(携带 `sessionId`)可读队列,但 `resolveReview` 写操作要求该 `sessionId` 存在且绑定仍然有效(空/悬空 sessionId 一律 403);无 `sessionId` 的 standalone/管理请求必须通过 `authorizeLibrary(req, { libraryId: null, operation: 'review.manage' })`,宿主未实现该 operation 时 fail-closed(403)。`browseWall` 必须明确单库,不能无目标枚举私有库。
58
79
  - **注入折叠是宿主自带的,不要自己做。** `dsh-client-ui-chat` 用 `ContextInjectionRow`(一个 `DisclosureRow`)渲染所有带 `source.kind` 的消息:折叠标题 `message.contextInjection`(跨会话召回为 `message.contextRecall`)。宿主认识的 `KNOWN_FORMS = instructions | catalog | snapshot | notice | relay | recall`;表外的 form 走 opaque,仍会折叠。
59
80
  - producer label 就是 **kind 原文**(如 `plugin:dsh-memu-memory`),不可自定义。`form: recall` 只有在 `kind: session-reference` + `references[].label` 时才走专门的召回正文;本插件用 `recall` 只是拿一个折叠行,要一行可读的折叠摘要就用 `form: notice` + `source.summary`。
60
81
 
@@ -66,7 +87,7 @@ ctx.inject([sidebarRightTabs], ...) + ctx.slots.register({ name: sidebar.right.p
66
87
 
67
88
  #### 已证实:标准会话
68
89
 
69
- - 标准会话 `session-<redacted-standard-a>`(`agentPreset: "standard"`,21 个非 session 事件):模型请求头 `request/header` 的工具表为 **82 个工具**,首尾两次一致;其中 `memu_*` 共 **10 个**:`memu_private_list`、`memu_private_recall`、`memu_private_remember`、`memu_private_update`、`memu_private_archive`、`memu_private_link`、`memu_private_unpin`、`memu_global_list`、`memu_global_recall`、`memu_status`。同一会话中 `===== memory anchor =====` 出现 1 次,锚点内是真实私有 id。
90
+ - 标准会话 `session-<redacted-standard-a>`(`agentPreset: "standard"`,21 个非 session 事件):模型请求头 `request/header` 的工具表为 **82 个工具**,首尾两次一致;其中 `memu_*` 共 **10 个**(1.1.2 历史快照;1.2.2 当前为 13 个,新增 `memu_lexicon_search`、`memu_lexicon_propose` 与 `memu_private_link_suggest`):`memu_private_list`、`memu_private_recall`、`memu_private_remember`、`memu_private_update`、`memu_private_archive`、`memu_private_link`、`memu_private_unpin`、`memu_global_list`、`memu_global_recall`、`memu_status`。同一会话中 `===== memory anchor =====` 出现 1 次,锚点内是真实私有 id。
70
91
  - 标准会话 `session-<redacted-standard-b>`(`agentPreset: "standard"`,本轮扫描时 1737 个非 session 事件):`<memory-guide>` 只对应 **1 个** plugin 消息 id(`<redacted-plugin-message-id>`),锚点 1 次。该 id 在多个快照/工具记录里重复出现是日志回放,不是重复投放。
71
92
  - 因此“标准会话的工具表里有 `memu_*`”“标准会话 anchor/guide 只投放一次”是**已证实**。注意这是 2026-10-29 的历史快照:当前版本标准和预设都走 `<memory-guide rules="…">` 插件消息,system prompt 不再有本插件段。
72
93
 
@@ -17,7 +17,7 @@
17
17
  ### 8.2 私有记忆的写入规则
18
18
 
19
19
  - 主 agent 自己写;**不做「你是她的记忆」的二次人格**。`must_remember` **满了也不许为腾名额而 unpin**。
20
- - 移出永久记忆 = **边缘化**:`marginalized=true`、`strength × 0.2`、`recallPenalty + 0.2`,**不删除**;条目仍在库里,`marginalReason` 在侧边栏可见(替代人类闸门的**事后**监督)。
20
+ - 移出永久记忆 = **边缘化**:`marginalized=true`、`strength × 0.2`、召回排序里 `marginalized` 乘以 0.35(`recallPenalty` 字段仅作历史记录,当前不参与排序),**不删除**;条目仍在库里,`marginalReason` 在侧边栏可见(替代人类闸门的**事后**监督)。
21
21
  - **unpin 由模型自己判断,侧边栏没有标记按钮、用户不参与。** 三重护栏:① `reason` 必填、第一人称、去空白后 ≥ 20 字符;② 每会话配额 `unpinBudgetPerSession`(默认 2);③ 冷却 `unpinCooldownMinutes`(默认 3)。放行后记 `unpinnedBy: model`、`unpinnedAt`、`originalPinSource`(保留原 pinSource 以便复 pin)。
22
22
  - 正当的 unpin 只有两种:想起它本身正在伤人;它已经不再是我的一部分。不正当的:inconvenient、不想面对、用户这轮没提、永久记忆快满了。**这个区别要写进提示词。**
23
23
  - 矛盾检测:同库同题改写或说法相反 → 新条挂 `pending_review` + `reviewReason` + `conflictingWith`,**不进注入不进召回**,等 `listReviews` / `resolveReview` 裁决(§3.9)。
@@ -26,12 +26,23 @@
26
26
 
27
27
  只有 curator 写,主 agent 只读。domain:`universal / coding / rp / project:<name> / tooling / personal`,**RP 与 coding 冲突分域存,不合并**。RP 剧情事实、关系进度、临时情绪**不写全局**;每条必须有 `evidence` + `confidence`。
28
28
 
29
+ **审核模式(`curatorReviewMode`)**:`auto`(默认)= 有落地证据的提炼结果自动通过;`review-all` = 提炼产物一律进待复核。`conflict`(说法矛盾)与无证据的条目在任何模式下都进人审;rewrite 类操作(merge/supersede/absorb)在 auto 下风险 ≥0.70 也暂扣。每条都带 `reviewRisk/reviewRiskReasons` 供审计与复核排序。
30
+
31
+ **证据落地(grounding)**:evidence 的 quote 必须是本次策划所含会话转录的规范化子串(≥6 字,省略号分段校验,先脱敏)——模型编造的"原话"进不了库;未落地恒 pending 或不落库。
32
+
33
+ **全局关联(link)**:curator 可给两条全局记忆连边(`related/refines/supports`),note 必须含转录逐字引用;每端 ≤20 条、有向边防环、移除只删边不删记忆。前端只读展示,不支持手动全局关联。
34
+
35
+ **集合记忆(absorb)**:多条碎片合成一条集合记忆——合并稿 active、target superseded(absorbedInto)、sources archived(absorbedBy,**不删除**,可还原);`absorbSnapshot` 支持一键撤销合并(人工改动过的条目拒绝撤销);簇外重复 ≥0.90 的合并稿转人审。
36
+
29
37
  ### 8.4 注入
30
38
 
31
39
  - 静态 guide 与动态记忆都走 plugin 消息;当前版本不再注册本插件的 system prompt 段。所有会话(含 `persona` `complete: true`)统一由 `lib/inject.js` 的 `ensureUnifiedGuide` 在**回合首步**投放一条 `<memory-guide rules="…">` 插件消息;`rulesKey` 由协议版本、domain 和实际渲染正文计算,domain/覆盖/默认稿变化或压缩丢失(`guideLost`)时在下一个合法首步替换,同一规则不逐回合重复。旧 binding 只有 `guideMessageAt`、没有 `guideRulesKey` 时视为旧版,补投一次;失败 fail-open,不写新版本。
32
40
  - 首轮锚点 + 每用户回合最多一次;长工具回合仅有新的真实人类消息批次时追加一次,普通工具步骤不触发。私有优先、全局补充;冲突时私有胜。
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` 默认开。
43
+ - **rule 是前言,不是页脚**:`buildAnchor` 先输出锚点头与 `[rule]`,再输出 private/global/short_term 各段;inbound 路径的锚点之后直接衔接 `<memory-context>`,中间不再隔一条规则。
33
44
  - **`injectedIds` 只能记真正进入文本的条目**,否则从未展示的记忆被白白压制 8 轮。
34
- - 锚点分段预算 pin 40% / core 30% / global 30%;pin 装不下时末尾明示「另有 N 条未展开」,**不静默丢弃**。
45
+ - 锚点分段预算 pin 40% / core 30% / global 30%;pin 装不下时末尾明示「另有 N 条未展开」,**不静默丢弃**。1.2.2 移除了 core≤5 / global≤8 的预先切片:标题卡比正文短,条数应由预算打包器决定,而不是固定上限;`anchorTokens` / `turnTokens` / `injectionTotalTokens` 默认值不变,inbound 的 `floor(turnBudget/2)` 保留。
35
46
  - 预算单位是**模型 token**不是字符:中文 ≈1 字符/token、英文 ≈3.4,一律走 `lib/budget.js`,**不要再用 `tokens * 3`**(英文口径,中文超支约 3 倍)。
36
47
  - 压缩后下一条用户消息重注入锚点;子代理不注入。文件夹两开关都关 → 不注入(看 clamp 后生效值,不是 binding 原始值)。召回为空必须留信号(§1.10)。
37
48
  - **召回排序的准确口径**:`privateWeighted` 只服务**私有召回流水线**(`privateRecall` 调用它);全局召回(`globalRecall`)走 `localRecall`,不经过它。cue 会经 `cueRecall` **间接**调用 `privateRecall`,所以**不能**概括成「cue 不走私有排序」。排序里的心境项默认关闭——`privateWeighted` 自己的缺省上下文就是 `moodEnabled: false`,真正打开它的是 `privateRecall`,条件是 `|valence| ≥ MOOD_MIN_STRENGTH` 或 `|arousal − BASE_AROUSAL| ≥ 0.1`(`BASE_AROUSAL` 来自 `lib/mood.js`);平缓对话里两项乘数恒为 1。`privateRecall` 的 topK 兜底是「传入 topK → `settings.privateTopK`(默认 5)→ 4」:引用 3 或 4 时必须说清是**设置默认值**还是**代码兜底值**,两个数不是同一个。
@@ -47,6 +58,7 @@
47
58
  - **职责分工**:`system-guide.*` 是唯一常驻规则,只写领域行为、检索时机、回答口径;`private-policy.*` 保留为字段规约参考,不再投放,避免两套常驻文本互相漂移。
48
59
  - **只有三个 key 分域**:`system-guide`、`private-policy`、`private-consolidation`;`global-curator` 不分域。
49
60
  - **远程与本地共用一份 `private-consolidation`**:正文讲「记什么、字段怎么填」,差异只有输出协议(`CONSOLIDATION_CONTRACTS.local` 调工具 / `.remote` 返回 JSON,代码追加)。不要拆第二份。
61
+ - **1.2.2 起整理稿负责标题质量**:title 按「只看标题就知道具体事实」写(8–40 字、具体关键词、集合稿覆盖全部来源),`global-curator` 同一口径。词典/关联的工具调用属于**本地工作流**:领域整理稿与远程 JSON 路径共用,因此不写 `memu_*` 工具名;领域稿只保留「可抽什么词」的差异,稳定复用的黑话/梗/术语先 `memu_lexicon_search` 再 `memu_lexicon_propose`、写完用 `memu_private_link_suggest` 裁决候选的工具流程只出现在 local worker brief。远程契约明确「没有工具」,title 长度同样是 8–40 字。
50
62
  - RP 与 coding 是**内容**差异:coding 记事实(决定、约束、踩过的坑、工程偏好),召回当「可能过期的事实」,与代码冲突时以代码为准;rp 记经验(具体瞬间、半句原话、身体感觉、没说出口的话),允许模糊记错,不确定就标低 `confidence`。
51
63
  - **KV cache**:section 文本随 domain 变,但同一会话内恒定,缓存不受影响;中途改 domain 会让该会话失效一次缓存。别在文档里写「文本恒定」。
52
64
 
@@ -133,5 +145,21 @@
133
145
 
134
146
  回归与管线测试:`tests/hybrid-recall.test.mjs` 仅保留 RRF、去重、稳定排序、资格过滤与候选上限等通用融合 helper 覆盖;managed vector 行为由 `tests/managed-memory.test.mjs` 覆盖。
135
147
 
148
+ ### 8.13 标题卡、词典生命周期与私有自动关联(1.2.2)
149
+
150
+ **标题卡与标题写作。** 锚点/召回的可见单位从正文改为标题卡,标题因此成为索引而不是装饰:提示词要求 8–40 字、含具体人名/物名/事件/结论关键词,禁止「一些事」「那段对话」「关于 XX 的事」;合并/吸收稿的标题要覆盖全部来源关键词。Lexicon 的注入行仍保留「term + ≤80 字短义」(不是裸词),因为词典的唯一价值是解释;UI 卡片也是 term 标题 + meaning 正文。
151
+
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 标记)。
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 判定。
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
+
136
164
  ---
137
165
 
@@ -205,9 +205,9 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
205
205
  - **新回合被评估为「不值得整理」。** `assessConsolidationValue` 只拒绝两种:`lastSleepSeq` 之后没有任何人类消息;或只有一条纯应答(「谢谢」「好的」「ok」,无工具调用)。其余都会进 fork,由整理提示词决定写不写——**写 0 条是合法结果**,不是故障。
206
206
  - **整理失败一直退避。** 看 binding 的 `lastSleepError` / `sleepRetryAt` / `sleepAttempts`。会话被删会得到 `session "…" not found`,现在会标 `sessionGone: true` 并停止重试(以前会每小时重来)。
207
207
  - **fork 失败被当成成功。** 旧版只等 `whenIdle()`;turn error 也会 resolve,于是 `lastSleepSeq` 被推进。现在 fork 必须继承父 `provider` / `model`(活跃会话取最近一轮 `requestHeader().config`,关闭会话取最后一条 `request/header` 的 `data.header.config`);没有路由就拒绝创建,报 `cannot inherit the parent model/provider`。`whenIdle` 后还要检查 `turn/end.data.reason.kind === 'completed'`,`error` / `aborted` / 没有 `turn/end` 都返回 `ok:false`,不推进游标,由 `runSleepPass` 记 `lastSleepError`、`sleepRetryAt`、`sleepAttempts` 退避重试。
208
- - **PTC 会话(`run_code` 预设)曾被一刀切拒绝(2026-10-31 已修)。** 旧 probe 看到 header 工具表里没有 `memu_private_remember/update` 就判 `worker-tools-ptc-only` 不建 fork——但 PTC 模式下 header 本来就只有 `run_code`,其余工具走 run_code 程序里的 SDK 绑定,header 名单不承载"能不能写"。现在的口径:PTC 不构成否证(probe 返回 `source: 'ptc-header'`),fork 创建后把读写四件(`memu_private_remember/update/recall/list`)挂进 worker 自己的 agent ctx scope(注册表按 scope 链取可见面,只对这个一次性 worker 可见,整理结束即卸载);任务书写明 `await tools.memu_private_remember({...})` 的调用形态。宿主不暴露 agent ctx(记录上没有 `ctx.tools`)时挂载失败只 warn,worker 会按任务书如实回执 `tools-unavailable`,空闲扫描照常退避。证据看活动日志"整理已开始"行的 `detail.probe` 与 `detail.workerToolsAttached`。
208
+ - **PTC 会话(`run_code` 预设)曾被一刀切拒绝(2026-10-31 已修)。** 旧 probe 看到 header 工具表里没有 `memu_private_remember/update` 就判 `worker-tools-ptc-only` 不建 fork——但 PTC 模式下 header 本来就只有 `run_code`,其余工具走 run_code 程序里的 SDK 绑定,header 名单不承载"能不能写"。现在的口径:PTC 不构成否证(probe 返回 `source: 'ptc-header'`),fork 创建后把 worker 的 5 个写工具(remember/update/link/link_suggest/lexicon_propose)与 3 个读工具(recall/list/lexicon_search)挂进 worker 自己的 agent ctx scope(注册表按 scope 链取可见面,只对这个一次性 worker 可见,整理结束即卸载);任务书写明 `await tools.memu_private_remember({...})` 的调用形态。写能力探测仍只认 remember/update,不会被 link/lexicon 工具误判。宿主不暴露 agent ctx(记录上没有 `ctx.tools`)时挂载失败只 warn,worker 会按任务书如实回执 `tools-unavailable`,空闲扫描照常退避。证据看活动日志"整理已开始"行的 `detail.probe` 与 `detail.workerToolsAttached`。
209
209
 
210
- **守卫**:`tests/cycle.test.mjs`(空闲阈值、启动补偿、`sessionGone` 只标记一次、寒暄不 fork、失败 fork 必须退避)+ `tests/consolidation-value.test.mjs`(评估边界:插件通知不算人类消息、纯应答跳过、「我不吃香菜」这种五个字的偏好必须留下、`lastSleepSeq` 之后的尾巴才算)+ `tests/consolidation-fork.test.mjs`(继承父模型、失败 turn 不推进 `lastSleepSeq`、PTC 会话照常 fork 且只挂读写四件、非 PTC 名单缺写工具仍然拒绝)。手工核对:`state.json` 里 `lastSleepAt` / `lastSleepSeq` / `sessionGone` / `sleepAttempts` / `lastSleepError` / `sleepRetryAt` 六个字段。
210
+ **守卫**:`tests/cycle.test.mjs`(空闲阈值、启动补偿、`sessionGone` 只标记一次、寒暄不 fork、失败 fork 必须退避)+ `tests/consolidation-value.test.mjs`(评估边界:插件通知不算人类消息、纯应答跳过、「我不吃香菜」这种五个字的偏好必须留下、`lastSleepSeq` 之后的尾巴才算)+ `tests/consolidation-fork.test.mjs`(继承父模型、失败 turn 不推进 `lastSleepSeq`、PTC 会话照常 fork 且只挂 worker 读写工具、非 PTC 名单缺写工具仍然拒绝)。手工核对:`state.json` 里 `lastSleepAt` / `lastSleepSeq` / `sessionGone` / `sleepAttempts` / `lastSleepError` / `sleepRetryAt` 六个字段。
211
211
 
212
212
  ### 3.19 人格预设(agent preset)的会话里完全没有记忆(S1 绑定 → S4 注入)
213
213
 
@@ -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: 86 -->
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` 的 86 个方法(旧路由别名同一鉴权);九页设置 + 侧边栏 `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
 
@@ -394,3 +427,41 @@ section 的 `text(context)` 能拿到 `context.agent`,所以 system prompt **
394
427
  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**,不能只断言「消息插进去了」。**不能靠「没报错就是好了」。**
395
428
 
396
429
  ---
430
+
431
+
432
+ ## WebUI 403 错误族(2026-11-01)
433
+
434
+ 三个长得不一样、根因同源的错误,都发生在 standalone WebUI 或侧边栏向插件 HTTP 端点发请求时:
435
+
436
+ | 报错 | 阶段 | 含义 |
437
+ |---|---|---|
438
+ | `Unexpected token 'o', "forbidden" is not valid JSON` | standalone fetch 拿到 403 裸文本后 `response.json()` 崩溃 | 1.2.2 之前的 403 响应体是裸文本;已改 JSON 信封 |
439
+ | `Invalid RPC response: 403` | 信封解析成功但无 `result`,客户端只报状态码不报原因 | 已透传服务端 `error.message`,不再只报状态码 |
440
+ | 请求返回 JSON 信封 `dsh-memu-memory/forbidden` | 库级路由授权拒绝(当前态) | 见下方授权模型 |
441
+
442
+ **库级授权模型(`authorizeLibraryRoute`)**:
443
+ - 带 `sessionId` 的请求:持久绑定必须与目标 `libraryId` 完全一致——session A 不能操作库 B;带 sessionId 但解析不出库(空/悬空/非字符串)一律 403(坏凭据 ≠ 无凭据)。
444
+ - 不带 sessionId(standalone 管理面):宿主实现了 `connection.authorizeLibrary(req, { libraryId, operation })` 时严格 `=== true` 才放行(fail-closed);**未实现时回退放行**(HTTP 边界的 requestRejection 仍是门)——fail-closed 会在真实宿主上把 standalone WebUI 全部 403(本条目的来源)。
445
+ - 无 libraryId 的 `browseWall`("全部记忆库"视图)走同一回退模型;实现了 capability 的宿主可拒绝多库枚举。
446
+ - 全局复核队列:嵌入式会话可读、写需活绑定;standalone 需要 `review.manage` grant(capability 缺席时同样回退放行)。
447
+ - 授权拒绝的 403 是 JSON 信封:`{"ok":false,"error":{"code":"dsh-memu-memory/forbidden",...}}`。
448
+
449
+ ## 提炼与词典排错(1.2.2)
450
+
451
+ - **absorb 一直停在待复核**:三种原因——`curatorReviewMode=review-all`、覆盖率不足(sourceCoverage<0.45 或 unionCoverage<0.60)、簇外重复 ≥0.90。复核队列接受前会校验 target/sources 状态与 updatedAt;并发变化会生成 held pending clone(原提案保留、已提交向量行补偿删除,活动日志可见)。
452
+ - **全局 link 没出现**:link 需要落地证据(note 含转录逐字引用),无证据不落边(活动日志 `link rejected`);每端 20 条上限、跨域只允许 related、rp↔coding 禁止;有向边防环 ≤3。
453
+ - **撤销合并失败**:撤销要求合并稿仍 active 且有 `absorbSnapshot`;条目被人工改动过(updatedAt > absorbedAt)会拒绝并给出可读错误——先人工恢复到吸收时状态,或放弃撤销。
454
+ - **词典词条没注入**:1.2.2 起见下节「标题卡、词典自动与私有自动关联排错」;旧版本的 pending 词条会在迁移后转 active/archived,不再需要人审。
455
+ - **词典提案被拒**:rejected fingerprint 只作为 legacy 墓碑拦截同规范词的重复提案(防每轮重放);新版本不再由人审产生 rejected。
456
+
457
+ ## 标题卡、词典自动与私有自动关联排错(1.2.2)
458
+
459
+ - **锚点里为什么只有标题、没有正文**:这是 1.2.2 的设计,不是截断。锚点与本回合召回只放 `[id] + 标题 + 语义标签`,正文在记忆抽屉与 `memu_private_recall` / `memu_global_recall` 工具里。模型需要原文时按标题关键词或方括号里的 id 调工具。标题为空会回退正文前 40 字;如果连回退都没有,才显示 `(untitled)`。
460
+ - **同样预算下锚点条数变了**:core≤5 / global≤8 的固定切片已删除,条数由 pin 40% / core 30% / global 30% 的打包预算决定;标题卡比正文短,所以可见条数增加,但 `anchorTokens` 没有被调大。预算仍以 `lib/budget.js` 的模型 token 口径计算,inbound 路径仍减半。
461
+ - **词典词条没注入**:按顺序查——是否 `archived`(不注入、不检索,可恢复);是否 `secret`(不进锚点摘要,但用户点名时 B 通道可解释);context/knownBy 是否匹配;是否在 30 分钟冷却内;是否被锚点摘要 top8/敏感词单列的名额挤掉。词典没有 pending 人审状态;新词条直接 active。
462
+ - **模型说写了词典但没生效**:`memu_lexicon_propose` 命中 archived 词条会返回 notOwned(不复活);修改敏感字段会被 typed 拒绝;sensitive trigger 只能由用户在词典页管理。检查活动日志/工具回执,不要假设 pending。
463
+ - **旧库里的 pending 词条去哪了**:周期巡检(`runVisibilityMigrationPass` → `migrateLexiconLibraries`)把 pending 新提案转 active、敏感转 archived、pending revision 转 archived;rejected 保留为内部墓碑。迁移只写有变化的文件;损坏的词典文件不会被当空库覆盖,报 `LEXICON_CORRUPT` 并保持只读。
464
+ - **私有自动关联没出现**:算法宁漏勿错。检查两条记忆是否同库、同 context/track、都可见且非 secret;标题是否共享稀有 name-like token(英文 ≥3 字母,或低频 CJK 名称;通用词被停用词表挡掉);pairScore 是否 ≥0.82(重复应走 update/合并)、是否有冲突、是否已有同向 link;每轮还有 2 条/entry、5 条/轮、2 个实体/轮的上限。边上的「自动」Tag 与 `source:'auto'` 是算法写的,可在关系图移除。
465
+ - **实体枢纽名称重复(Yuike / yuike)**:算法按 NFKC/大小写/空白/标点归一化复用实体;`memu_private_link` 的 `entity` 参数也按同一规则复用同名实体。若已存在但 kind 冲突,会拒绝并提示改用既有 kind,而不是静默建第二个。
466
+ - **worker 没裁决不确定候选**:`memu_private_link_suggest` 只返回候选卡,不自动连;worker 未调用或证据不足就保持不连(宁漏勿错)。`lib/private.js` 的结算兜底只重跑高置信算法,不会把不确定候选偷偷连上。自动关联失败只写 warn,不影响整理成功。
467
+ - **要不要数据库/向量重算**:自动关联只是 `links[]` 元数据,不改正文、不写向量;移除边不会触发重建。实体删除仍按既有规则(有引用时需显式 force,避免悬空)。
@@ -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