dsh-memu-memory 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/AGENTS.md +108 -110
  2. package/CHANGELOG.md +173 -868
  3. package/LICENSE +21 -21
  4. package/README.md +368 -374
  5. package/README.zh.md +354 -360
  6. package/assets/icon.svg +7 -7
  7. package/cordis.patch.yml +8 -8
  8. package/docs/active-memory-ab.md +279 -385
  9. package/docs/binding-lifecycle.md +99 -99
  10. package/docs/client-conventions.md +75 -75
  11. package/docs/contributing.md +217 -217
  12. package/docs/emotion-model-spec.md +247 -281
  13. package/docs/env-and-commands.md +149 -152
  14. package/docs/host-adaptation.md +339 -360
  15. package/docs/host-api.md +131 -137
  16. package/docs/host-versions.md +117 -120
  17. package/docs/mcp-porting.md +146 -146
  18. package/docs/memory-semantics.md +271 -259
  19. package/docs/pending-work.md +44 -51
  20. package/docs/troubleshooting.md +909 -854
  21. package/lib/active-memory.js +160 -165
  22. package/lib/activity-log.js +207 -207
  23. package/lib/auto-link/apply.js +248 -249
  24. package/lib/auto-link/candidates.js +163 -163
  25. package/lib/auto-link/decide.js +300 -300
  26. package/lib/auto-link/normalize.js +99 -99
  27. package/lib/auto-link/policy.js +42 -42
  28. package/lib/auto-link/suppression.js +101 -101
  29. package/lib/auto-link/terminology.js +311 -311
  30. package/lib/backup.js +1254 -1254
  31. package/lib/binding-diagnostics.js +634 -634
  32. package/lib/budget.js +118 -118
  33. package/lib/client.js +9820 -9751
  34. package/lib/commitment.js +178 -138
  35. package/lib/consolidation-ledger.js +434 -438
  36. package/lib/consolidation-receipt.js +386 -387
  37. package/lib/consolidation-snapshot.js +420 -405
  38. package/lib/consolidation-worker.js +240 -241
  39. package/lib/context.js +33 -33
  40. package/lib/curator-evidence.js +131 -131
  41. package/lib/curator-policy.js +198 -202
  42. package/lib/curator.js +1813 -1811
  43. package/lib/cycle.js +524 -513
  44. package/lib/diagnostics.js +524 -524
  45. package/lib/embedding-catalog.js +1051 -1055
  46. package/lib/embedding-download.js +637 -607
  47. package/lib/embedding-runtime.js +946 -946
  48. package/lib/engine.js +1103 -1103
  49. package/lib/entity-repair.js +285 -285
  50. package/lib/environment-check.js +394 -394
  51. package/lib/fork-model.js +312 -312
  52. package/lib/freshness.js +128 -121
  53. package/lib/global-graph.js +389 -389
  54. package/lib/graph.js +1193 -1193
  55. package/lib/host-surface.js +30 -30
  56. package/lib/inbound.js +284 -281
  57. package/lib/index.js +506 -511
  58. package/lib/inject.js +2639 -2619
  59. package/lib/lexicon-scope.js +143 -143
  60. package/lib/lexicon.js +1183 -1192
  61. package/lib/lifecycle-audit.js +37 -0
  62. package/lib/local-embedding-entry.js +145 -145
  63. package/lib/local-embedding-manager.js +306 -306
  64. package/lib/local-embedding-protocol.js +210 -210
  65. package/lib/local-embedding-worker.js +682 -682
  66. package/lib/local-vector-service.js +506 -453
  67. package/lib/maintenance-ledger.js +138 -0
  68. package/lib/maintenance-review.js +103 -0
  69. package/lib/maintenance-runner.js +267 -0
  70. package/lib/managed-runtime.js +118 -118
  71. package/lib/media.js +607 -513
  72. package/lib/memory.js +5035 -4941
  73. package/lib/memu-config.js +213 -213
  74. package/lib/memu.js +565 -565
  75. package/lib/migrate.js +200 -200
  76. package/lib/mood.js +300 -300
  77. package/lib/paths.js +453 -457
  78. package/lib/port-surface.js +82 -82
  79. package/lib/preset-mount.js +85 -0
  80. package/lib/preset-scope.js +126 -126
  81. package/lib/private-links.js +567 -567
  82. package/lib/private.js +2198 -2209
  83. package/lib/prompts/global-curator.md +135 -135
  84. package/lib/prompts/image-caption.md +1 -1
  85. package/lib/prompts/private-consolidation.coding.md +39 -39
  86. package/lib/prompts/private-consolidation.md +32 -32
  87. package/lib/prompts/private-consolidation.mixed.md +37 -37
  88. package/lib/prompts/private-consolidation.rp.md +47 -47
  89. package/lib/prompts/private-policy.coding.md +35 -35
  90. package/lib/prompts/private-policy.md +36 -36
  91. package/lib/prompts/private-policy.mixed.md +29 -29
  92. package/lib/prompts/private-policy.rp.md +43 -43
  93. package/lib/prompts/system-guide.coding.md +20 -20
  94. package/lib/prompts/system-guide.md +25 -25
  95. package/lib/prompts/system-guide.mixed.md +22 -22
  96. package/lib/prompts/system-guide.rp.md +23 -23
  97. package/lib/prompts.js +331 -331
  98. package/lib/recall-cache.js +212 -212
  99. package/lib/remote-summary.js +123 -123
  100. package/lib/rpc.js +2531 -2532
  101. package/lib/salient-wake.js +438 -438
  102. package/lib/snippet.js +125 -125
  103. package/lib/state.js +1948 -1928
  104. package/lib/stats.js +236 -236
  105. package/lib/temporal.js +345 -348
  106. package/lib/text-retrieval.js +992 -1001
  107. package/lib/text-similarity.js +305 -305
  108. package/lib/tokenizer-v2.js +271 -271
  109. package/lib/tools.js +1098 -1091
  110. package/lib/turn-log.js +545 -545
  111. package/lib/vector-migration.js +928 -930
  112. package/lib/vector-profile.js +1353 -1359
  113. package/lib/visibility.js +59 -59
  114. package/lib/webui/graph-LICENSE.txt +1 -1
  115. package/lib/webui/graph-view.bundle.js +2 -2
  116. package/lib/webui/graph-view.js +1171 -1175
  117. package/lib/webui/mark.svg +7 -7
  118. package/lib/webui/standalone.css +1178 -1178
  119. package/lib/webui/standalone.js +238 -238
  120. package/lib/webui.js +136 -136
  121. package/lib/worker-pool.js +1020 -979
  122. package/package.json +153 -153
  123. package/requirements.lock +34 -34
  124. package/scripts/acceptance-local.mjs +946 -946
  125. package/scripts/active-memory-ab-live.mjs +653 -655
  126. package/scripts/active-memory-ab.mjs +1302 -1302
  127. package/scripts/audit-memory-lifecycle.mjs +55 -0
  128. package/scripts/bench-recall.mjs +142 -142
  129. package/scripts/build-graph.mjs +44 -45
  130. package/scripts/chain-matrix.mjs +541 -541
  131. package/scripts/check-all.mjs +68 -74
  132. package/scripts/check-doc-drift.mjs +547 -547
  133. package/scripts/check-graph-browser.mjs +261 -261
  134. package/scripts/check-i18n.mjs +81 -83
  135. package/scripts/check-idle-compositing.mjs +61 -61
  136. package/scripts/check-seed-compat.mjs +115 -118
  137. package/scripts/check-text-format.mjs +55 -0
  138. package/scripts/curator-pair-calibrate.mjs +259 -259
  139. package/scripts/diagnose-bindings.mjs +176 -176
  140. package/scripts/drive-session.mjs +863 -864
  141. package/scripts/engine-smoke.mjs +69 -69
  142. package/scripts/entity-dedupe.mjs +110 -110
  143. package/scripts/lexicon-calibrate.mjs +230 -230
  144. package/scripts/lexicon-dedupe.mjs +318 -318
  145. package/scripts/local-runtime-install.mjs +142 -142
  146. package/scripts/local-runtime-verify.mjs +56 -56
  147. package/scripts/local-vector-verify.mjs +93 -93
  148. package/scripts/make-readme-shots.mjs +59 -59
  149. package/scripts/migrate-visibility.mjs +94 -94
  150. package/scripts/mock-llm.mjs +938 -903
  151. package/scripts/preview.mjs +58 -58
  152. package/scripts/prune-sessions.mjs +31 -34
  153. package/scripts/prune-turnlogs.mjs +29 -30
  154. package/scripts/prune-vectors.mjs +24 -24
  155. package/scripts/rebuild-auto-links.mjs +252 -252
  156. package/scripts/recall-bench.mjs +820 -820
  157. package/scripts/repetition-ab-scenarios.mjs +93 -93
  158. package/scripts/repetition-detector-snapshot.mjs +314 -314
  159. package/scripts/repetition-eval-live.mjs +360 -360
  160. package/scripts/repetition-eval.mjs +702 -702
  161. package/scripts/replay.mjs +705 -575
  162. package/scripts/setup.mjs +46 -46
  163. package/scripts/simulate-injection.mjs +299 -301
  164. package/tests/absorb-review.test.mjs +354 -354
  165. package/tests/activation.test.mjs +89 -89
  166. package/tests/active-memory-ab.test.mjs +745 -745
  167. package/tests/active-memory.test.mjs +129 -129
  168. package/tests/activity-log.test.mjs +126 -126
  169. package/tests/activity-wiring.test.mjs +155 -155
  170. package/tests/appendix-b.test.mjs +217 -217
  171. package/tests/appendix-b2.test.mjs +166 -166
  172. package/tests/audit-batch3.test.mjs +247 -247
  173. package/tests/audit-regression.test.mjs +275 -275
  174. package/tests/audit-safety.test.mjs +227 -227
  175. package/tests/auto-link-candidates.test.mjs +245 -245
  176. package/tests/auto-link-decide.test.mjs +512 -512
  177. package/tests/auto-link-migration.test.mjs +133 -133
  178. package/tests/backend-compensation.test.mjs +272 -272
  179. package/tests/backup.test.mjs +793 -793
  180. package/tests/binding-diagnostics.test.mjs +720 -720
  181. package/tests/browser.test.mjs +476 -476
  182. package/tests/client-export.test.mjs +521 -521
  183. package/tests/client-render.test.mjs +2008 -1728
  184. package/tests/coalesce.test.mjs +113 -113
  185. package/tests/commitment.test.mjs +243 -144
  186. package/tests/config.test.mjs +159 -159
  187. package/tests/consolidation-credential.test.mjs +330 -330
  188. package/tests/consolidation-feed.test.mjs +122 -122
  189. package/tests/consolidation-fork.test.mjs +1587 -1539
  190. package/tests/consolidation-ledger.test.mjs +389 -389
  191. package/tests/consolidation-snapshot.test.mjs +567 -505
  192. package/tests/consolidation-value.test.mjs +89 -89
  193. package/tests/context-scope.test.mjs +40 -40
  194. package/tests/cross-library-recall.test.mjs +269 -269
  195. package/tests/cue.test.mjs +58 -58
  196. package/tests/curator-absorb.test.mjs +444 -444
  197. package/tests/curator-calibrate.test.mjs +173 -173
  198. package/tests/curator-clusters.test.mjs +306 -306
  199. package/tests/curator-commit.test.mjs +325 -325
  200. package/tests/curator-contract.test.mjs +191 -191
  201. package/tests/curator-evidence.test.mjs +102 -102
  202. package/tests/curator-link.test.mjs +317 -317
  203. package/tests/curator-pairing.test.mjs +339 -339
  204. package/tests/curator-probe.test.mjs +490 -490
  205. package/tests/curator-review-mode.test.mjs +315 -315
  206. package/tests/curator.test.mjs +152 -152
  207. package/tests/cycle.test.mjs +567 -568
  208. package/tests/diagnostics.test.mjs +278 -278
  209. package/tests/disclosure.test.mjs +249 -249
  210. package/tests/doc-drift.test.mjs +342 -342
  211. package/tests/drive-session.test.mjs +152 -152
  212. package/tests/dynamic-rrf.test.mjs +182 -182
  213. package/tests/dynamic-threshold.test.mjs +52 -52
  214. package/tests/embedding-catalog.test.mjs +374 -374
  215. package/tests/embedding-download.test.mjs +529 -486
  216. package/tests/embedding-runtime.test.mjs +449 -449
  217. package/tests/emotion-chain.test.mjs +84 -84
  218. package/tests/emotion-contract.test.mjs +445 -445
  219. package/tests/engine.test.mjs +108 -108
  220. package/tests/entity-merge.test.mjs +278 -278
  221. package/tests/environment-check.test.mjs +187 -187
  222. package/tests/fact-version.test.mjs +146 -146
  223. package/tests/fixtures/active-memory-ab/README.md +56 -56
  224. package/tests/fixtures/active-memory-ab/cases/01-clean-dense-turn.json +351 -351
  225. package/tests/fixtures/active-memory-ab/cases/02-clean-thin-turn.json +122 -122
  226. package/tests/fixtures/active-memory-ab/cases/03-clean-starved-small.json +125 -125
  227. package/tests/fixtures/active-memory-ab/cases/04-clean-large-thin.json +137 -137
  228. package/tests/fixtures/active-memory-ab/cases/05-clean-half-step.json +166 -166
  229. package/tests/fixtures/active-memory-ab/cases/06-clean-duplicate-reread.json +197 -197
  230. package/tests/fixtures/active-memory-ab/cases/07-clean-recent-recall.json +125 -125
  231. package/tests/fixtures/active-memory-ab/cases/08-global-relevant.json +111 -111
  232. package/tests/fixtures/active-memory-ab/cases/09-global-irrelevant-conflict.json +158 -158
  233. package/tests/fixtures/active-memory-ab/cases/10-no-human-turn.json +97 -97
  234. package/tests/fixtures/active-memory-ab/cases/11-clean-scale-100.json +137 -137
  235. package/tests/fixtures/active-memory-ab/cases/12-clean-scale-1000.json +137 -137
  236. package/tests/fixtures/active-memory-ab/cases/13-clean-scale-5000.json +137 -137
  237. package/tests/fixtures/active-memory-ab/cases/14-clean-scale-20000.json +137 -137
  238. package/tests/fixtures/active-memory-ab/lead-ai-reviewed-reference.json +191 -191
  239. package/tests/fixtures/active-memory-ab/manifest.json +199 -199
  240. package/tests/fixtures/curator-pairs/labeled.v1.jsonl +90 -90
  241. package/tests/fixtures/lexicon-stub-hooks.mjs +15 -15
  242. package/tests/fixtures/lexicon-stub.mjs +284 -284
  243. package/tests/fixtures/mock-llm/reply.txt +1 -1
  244. package/tests/fixtures/recall-bench/01-paraphrase.json +183 -183
  245. package/tests/fixtures/recall-bench/02-exact.json +152 -152
  246. package/tests/fixtures/recall-bench/03-negation.json +172 -172
  247. package/tests/fixtures/recall-bench/04-no-answer.json +161 -161
  248. package/tests/fixtures/recall-bench/05-conflict.json +193 -193
  249. package/tests/fixtures/recall-bench/06-boundary.json +272 -272
  250. package/tests/fixtures/recall-bench/07-secret.json +190 -190
  251. package/tests/fixtures/recall-bench/08-coding.json +163 -163
  252. package/tests/fixtures/recall-bench-gold-candidates/01-paraphrase.json +193 -193
  253. package/tests/fixtures/recall-bench-gold-candidates/02-exact.json +197 -197
  254. package/tests/fixtures/recall-bench-gold-candidates/03-negation.json +244 -244
  255. package/tests/fixtures/recall-bench-gold-candidates/04-no-answer.json +189 -189
  256. package/tests/fixtures/recall-bench-gold-candidates/05-conflict.json +245 -245
  257. package/tests/fixtures/recall-bench-gold-candidates/06-boundary.json +279 -279
  258. package/tests/fixtures/recall-bench-gold-candidates/07-secret.json +224 -224
  259. package/tests/fixtures/recall-bench-gold-candidates/08-coding.json +218 -218
  260. package/tests/fixtures/repetition-eval/01-zh-rp.json +92 -92
  261. package/tests/fixtures/repetition-eval/02-en.json +96 -96
  262. package/tests/fixtures/repetition-eval/03-code.json +90 -90
  263. package/tests/fixtures/repetition-eval/04-names.json +115 -115
  264. package/tests/fixtures/repetition-eval/05-user-quote.json +95 -95
  265. package/tests/fixtures/repetition-eval/06-agreement.json +85 -85
  266. package/tests/fixtures/tokenizer-cases.mjs +27 -27
  267. package/tests/fork-model.test.mjs +345 -345
  268. package/tests/freshness.test.mjs +140 -140
  269. package/tests/global-graph.test.mjs +106 -106
  270. package/tests/global-lifecycle.test.mjs +149 -149
  271. package/tests/graph-cascade.test.mjs +363 -363
  272. package/tests/graph-view.test.mjs +414 -414
  273. package/tests/graph.test.mjs +371 -371
  274. package/tests/help-page.test.mjs +416 -416
  275. package/tests/hook-order.test.mjs +72 -72
  276. package/tests/humanlike.test.mjs +232 -232
  277. package/tests/hybrid-recall.test.mjs +610 -610
  278. package/tests/inbound.test.mjs +441 -441
  279. package/tests/inject-conflict.test.mjs +173 -173
  280. package/tests/inject-guide.test.mjs +513 -513
  281. package/tests/inject.test.mjs +384 -384
  282. package/tests/injection-budget-settings.test.mjs +35 -35
  283. package/tests/injection-budget.test.mjs +165 -165
  284. package/tests/injection-chain.test.mjs +442 -442
  285. package/tests/injection-intent-budget.test.mjs +92 -92
  286. package/tests/injection-rollback.test.mjs +428 -428
  287. package/tests/issue2-chain.test.mjs +169 -169
  288. package/tests/lexical-bm25.test.mjs +171 -171
  289. package/tests/lexicon-calibrate.test.mjs +48 -48
  290. package/tests/lexicon-dedupe.test.mjs +171 -171
  291. package/tests/lexicon-frequency.test.mjs +195 -195
  292. package/tests/lexicon-inject.test.mjs +459 -459
  293. package/tests/lexicon-perf.test.mjs +464 -464
  294. package/tests/lexicon-scope.test.mjs +256 -256
  295. package/tests/lexicon-ui.test.mjs +667 -667
  296. package/tests/lexicon.test.mjs +922 -922
  297. package/tests/lifecycle-audit.test.mjs +56 -0
  298. package/tests/loader-register.mjs +3 -3
  299. package/tests/loader.mjs +17 -17
  300. package/tests/local-embedding-entry.test.mjs +95 -95
  301. package/tests/local-embedding-env.test.mjs +51 -51
  302. package/tests/local-embedding-manager.test.mjs +494 -494
  303. package/tests/local-embedding-protocol.test.mjs +121 -121
  304. package/tests/local-embedding-worker.test.mjs +440 -440
  305. package/tests/local-vector-service.test.mjs +41 -0
  306. package/tests/maintenance-status.test.mjs +77 -0
  307. package/tests/maintenance.test.mjs +438 -0
  308. package/tests/managed-memory.test.mjs +1234 -1234
  309. package/tests/managed-runtime.test.mjs +72 -72
  310. package/tests/media-injection.test.mjs +225 -0
  311. package/tests/media.test.mjs +135 -135
  312. package/tests/memory-chain.test.mjs +169 -169
  313. package/tests/memory-fields.test.mjs +134 -134
  314. package/tests/memu-resident-route.test.mjs +130 -130
  315. package/tests/memu-resident.test.mjs +33 -33
  316. package/tests/migration-payload.test.mjs +40 -42
  317. package/tests/mock-llm.test.mjs +263 -225
  318. package/tests/mood.test.mjs +109 -109
  319. package/tests/multiprocess.test.mjs +29 -29
  320. package/tests/negation-polarity.test.mjs +135 -135
  321. package/tests/new-session-gate.test.mjs +617 -617
  322. package/tests/open-loop-date.test.mjs +416 -416
  323. package/tests/ops-hardening.test.mjs +209 -209
  324. package/tests/package-shipping.test.mjs +88 -88
  325. package/tests/pending-injection.test.mjs +107 -107
  326. package/tests/port-surface.test.mjs +138 -138
  327. package/tests/preset-mount.test.mjs +132 -0
  328. package/tests/preset-scope.test.mjs +212 -212
  329. package/tests/private-links.test.mjs +493 -493
  330. package/tests/prompt-semantics.test.mjs +51 -51
  331. package/tests/prompts.test.mjs +315 -315
  332. package/tests/query-decompose.test.mjs +62 -62
  333. package/tests/react-snapshot.test.mjs +24 -24
  334. package/tests/recall-bench.test.mjs +317 -317
  335. package/tests/recall-cache.test.mjs +292 -292
  336. package/tests/recall-corpus-eligibility.test.mjs +51 -51
  337. package/tests/recall-dedup.test.mjs +446 -446
  338. package/tests/recall-intent.test.mjs +172 -172
  339. package/tests/regression-sweep.test.mjs +311 -311
  340. package/tests/reminder-fairness.test.mjs +55 -0
  341. package/tests/remote.test.mjs +140 -140
  342. package/tests/rename.test.mjs +30 -30
  343. package/tests/repetition-detector-snapshot.test.mjs +231 -231
  344. package/tests/repetition-eval-live.test.mjs +177 -177
  345. package/tests/repetition-eval.test.mjs +373 -373
  346. package/tests/salience-domain.test.mjs +173 -173
  347. package/tests/salient-date.test.mjs +142 -142
  348. package/tests/salient-wake.test.mjs +389 -389
  349. package/tests/settings-beat.test.mjs +222 -222
  350. package/tests/settings-coverage.test.mjs +97 -97
  351. package/tests/settings-plumbing.test.mjs +79 -79
  352. package/tests/short-term.test.mjs +182 -166
  353. package/tests/sidebar-beat.test.mjs +213 -213
  354. package/tests/sidebar-refresh.test.mjs +123 -123
  355. package/tests/sidebar.test.mjs +102 -74
  356. package/tests/simulate-injection.test.mjs +76 -76
  357. package/tests/slot-similarity.test.mjs +153 -153
  358. package/tests/snippet.test.mjs +79 -79
  359. package/tests/source-kind.test.mjs +52 -52
  360. package/tests/speaker-provenance.test.mjs +120 -120
  361. package/tests/stale-maintenance.test.mjs +206 -131
  362. package/tests/state-gc.test.mjs +34 -34
  363. package/tests/state.test.mjs +155 -155
  364. package/tests/stats.test.mjs +112 -112
  365. package/tests/storage.test.mjs +125 -125
  366. package/tests/stubs/child-process-spy.mjs +14 -14
  367. package/tests/stubs/dsh-llm-pi-ai.js +13 -13
  368. package/tests/stubs/dsh-llm.js +5 -5
  369. package/tests/stubs/dsh-schedule.js +140 -140
  370. package/tests/stubs/dsh-session-query.js +26 -26
  371. package/tests/stubs/dsh-session.js +7 -7
  372. package/tests/stubs/dsh-tools.js +101 -101
  373. package/tests/temporal-repair.test.mjs +78 -0
  374. package/tests/temporal.test.mjs +124 -124
  375. package/tests/text-format.test.mjs +24 -0
  376. package/tests/tokenizer-v2.test.mjs +142 -142
  377. package/tests/tool-schema.test.mjs +126 -126
  378. package/tests/tools.test.mjs +810 -810
  379. package/tests/turn-log.test.mjs +487 -487
  380. package/tests/ui-defaults.test.mjs +57 -57
  381. package/tests/update-fields.test.mjs +138 -138
  382. package/tests/vector-gc.test.mjs +37 -37
  383. package/tests/vector-migration.test.mjs +810 -810
  384. package/tests/vector-profile.test.mjs +449 -449
  385. package/tests/visibility-migration.test.mjs +152 -152
  386. package/tests/webui-auth.test.mjs +963 -963
  387. package/tests/webui.test.mjs +421 -421
  388. package/tests/windows-env.test.mjs +89 -89
  389. package/tests/worker-lifecycle.test.mjs +1522 -1429
package/README.md CHANGED
@@ -1,374 +1,368 @@
1
- <p align="center">
2
- <img src="assets/icon-256.png" width="88" height="88" alt="dsh-memu-memory">
3
- </p>
4
-
5
- <h1 align="center">dsh-memu-memory</h1>
6
-
7
- <p align="center">
8
- A local-first memory plugin for <b>DeepSeek Harness</b> — shared by folder, bound to a chat,
9
- written by the agent, curated in the background, and honest about what it does not know.
10
- </p>
11
-
12
- <p align="center">
13
- <a href="https://www.npmjs.com/package/dsh-memu-memory"><img alt="npm version" src="https://img.shields.io/npm/v/dsh-memu-memory?color=4d6bfe"></a>
14
- <a href="https://www.npmjs.com/package/dsh-memu-memory"><img alt="npm monthly downloads" src="https://img.shields.io/npm/dm/dsh-memu-memory?color=4d6bfe"></a>
15
- <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/npm/l/dsh-memu-memory?color=4d6bfe"></a>
16
- <a href="package.json"><img alt="DSH: >=0.2.0-rc.1" src="https://img.shields.io/badge/DSH-%E2%89%A50.2.0--rc.1-4d6bfe"></a>
17
- <a href="package.json"><img alt="Node: >=20.9" src="https://img.shields.io/badge/Node-%E2%89%A520.9-4d6bfe"></a>
18
- </p>
19
-
20
- <p align="center">
21
- English | <a href="README.zh.md">中文</a>
22
- </p>
23
-
24
- ---
25
-
26
- `dsh-memu-memory` is built for long-form RP and companion chats. It gives a DSH conversation a memory that behaves like memory instead of a log: three retention layers that fade, a first-turn anchor plus at most one per-turn recall, provenance that cannot be quietly upgraded from "I inferred it" to "they said it", contradictions that either wait for a decision or — when explicitly versioned — stay side by side with a conflict card instead of being silently merged, near-identical facts collapse to one entry and one recall seat, and an optional relationship graph with evidence. Speakers, characters, worlds and story branches form hard boundaries, and what a character is allowed to know stays separate from what actually happened.
27
-
28
- It is **local-first by default**. The default `agent` backend stores full text in JSON indexes and recalls lexically — no Python, no embedding service, no API key. The `api` backend switches recall to the optional, pinned MemU engine (vector search). MemU is a plugin for people who want it, not a requirement for the plugin to start.
29
-
30
- > [!WARNING]
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
-
33
- > **Status:** 1.3.6. 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
-
35
- ## Screenshots
36
-
37
- All screenshots are the real WebUI on isolated example data, not anyone's memories.
38
-
39
- <table>
40
- <tr>
41
- <td align="center"><img src="assets/screenshots/webui-memory.jpg" width="470" alt="Memory wall"><br/><em>MemU WebUI · cross-library memory wall</em></td>
42
- <td align="center"><img src="assets/screenshots/drawer.jpg" width="470" alt="In-place memory drawer"><br/><em>Edit, archive or restore without leaving the wall</em></td>
43
- </tr>
44
- <tr>
45
- <td align="center"><img src="assets/screenshots/relations.jpg" width="470" alt="Relationship graph studio"><br/><em>Full-screen relationship graph · canvas and inspector</em></td>
46
- <td align="center"><img src="assets/screenshots/settings.jpg" width="470" alt="Settings"><br/><em>Injection, budgets, retention and automation</em></td>
47
- </tr>
48
- <tr>
49
- <td align="center"><img src="assets/screenshots/stats.jpg" width="470" alt="Statistics"><br/><em>Daily activity, hit distribution and archive candidates</em></td>
50
- <td align="center"><img src="assets/screenshots/webui-dark.jpg" width="470" alt="Dark theme"><br/><em>Dark theme · the same surfaces and motion</em></td>
51
- </tr>
52
- <tr>
53
- <td align="center" colspan="2"><img src="assets/screenshots/mobile.jpg" width="360" alt="Narrow layout"><br/><em>Narrow layout · the rail folds into a horizontal strip</em></td>
54
- </tr>
55
- </table>
56
-
57
- ## What it remembers
58
-
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. 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
- - **Invisible memories cannot crowd out visible ones.** Private lexical recall builds its scoring corpus after applying conversation context, speaker and disclosure rules, including the lexical branch of mixed recall. Explicit reads retain their disclosure permissions.
62
- - **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. A **global lexicon** sits beside the per-library ones: every conversation reads it, only you write it. With same-domain cross-library recall on, the anchor, this-turn match and `memu_lexicon_search` merge those libraries too — the page still browses one book at a time.
63
- - **Private links come from assertions, not statistics.** `autoLinkMode` defaults to *candidates only*: a local zero-token pass ranks names into a review queue and writes nothing. Once you confirm an entity, its names and aliases are matched against memory text (`entity-mention`); `conflicts_with` / `supersedes` / the same `fact_key` add field-evidence edges. Lexical similarity, shared tokens and vectors never create an edge. Confirming, renaming, merging or deleting an entity maintains its edges immediately, and a removed auto edge is suppressed so it cannot come back. Links are metadata, shown with an “Auto” badge in the graph; they never rewrite a body, write a vector or delete anything. Existing libraries migrate with `node scripts/rebuild-auto-links.mjs` (dry-run first, `--apply` takes a backup). New names proposed by a model must appear as complete quoted, introduced or delimited names in the source memory; a substring or the link note alone is insufficient. Existing names and aliases remain reusable, and rejected links leave no new entity.
64
- - **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. Relative wording (今天 / 明天 / 下周X / 月底) is resolved against the turn's scene time and stored as an absolute date; a memory that says "tomorrow" is stored as the dated form, so an appointment does not come back every year.
65
- - **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.
66
- - **Provenance is a fact, not a style.** Every entry carries `source` / `source_kind` (`user_said` / `assistant_said` / `told` / `imagined` / `inferred` / `tool`), `speaker_id`, `confidence`, `accuracy`, and disclosure rules. A vague recollection cannot impersonate a quote, and the assistant's own promises or plans cannot be filed as something the user said.
67
- - **Contradictions do not get silently merged.** An ordinary contradiction still lands as `pending_review`: it is not injected, not recalled, and appears in a review queue until someone accepts or rejects it. When the writer explicitly marks two statements as versions of one fact (`conflicts_with`), both stay active, are recalled together and surface as a conflict card; an explicit `supersedes` retires the old row without deleting its text.
68
- - **Secrets stay excluded.** `secret` visibility, group-chat channels, characters, worlds, branches and `knownBy` all constrain reads and edits. Automatic recall never injects a `secret` memory, and a `secret` is still readable by an explicit recall from the same folder — it hides a memory from the prompt, it is not a lock. What actually separates two conversations in one folder is the `context` scope (`channelId` / `characterId` / `worldId` / `branchId`); a blank scope on both sides means one shared scope, which is the point of a folder. The old `visibility: 'session'` level is gone — reading turns it into `shared` with its `context` untouched, and `node scripts/migrate-visibility.mjs` rewrites libraries that still store it (`--apply`, backs up first).
69
- - **People and stories are structured.** Group chat uses stable `speakerId` / `channelId`, not display names. RP uses `characterId` / `worldId` / `branchId`. Relationships are edges with a note and confidence, entities can be renamed without rewriting memory bodies, and the current relationship state (familiarity, trust, warmth, boundaries, promises) is a snapshot that keeps its history and evidence.
70
- - **Images are pointers and captions, not pretend vision.** Attachments are deduplicated by SHA-256, quota-limited and tiered; an image without a description is remembered as "received an image", never as a scene the model did not see.
71
- - **Housekeeping happens in the background.** Consolidation runs in a seeded fork sub-session, never as an editable turn in your chat. Failed runs back off instead of reporting success. Unsupported reasoning-effort combinations are remembered across restarts and omitted on the next fork/new worker, including inherited settings; a new provider/model/effort combination may still fail once before it is learned.
72
-
73
- ### Active memory, measured
74
-
75
- Idle consolidation is not "every quiet session gets a fork". Before a fork the plugin scores the evidence since the last cursor: human turns (`H`), content volume (`C`: human text, assistant text and deduped successful tool results, 2,000 characters per result) and effective tool work units (`U`), with `score = 0.35*min(H/3,2) + 0.45*min(C/4000,2) + 0.20*min(U/20,2)` (default threshold 0.8). A session idle for 15 minutes wakes below that score only when it is small; transcripts of 2,000+ events must earn their fork, because the host seeds the full prefix. A recent consolidation or a recent recall suppresses the idle fork.
76
-
77
- More is not better: thin turns on a large transcript are skipped by the guard (about 37% fewer prompt tokens on the same scenarios, at the cost of roughly 1 in 22 labels arriving a little later), but once the unconsolidated range passes 600 events the check runs unconditionally, so decisions made early in a long session do not stay out of memory forever.
78
-
79
- Four real long sessions from this machine were replayed read-only (no new chat) and their turns were counted:
80
-
81
- | Session | Events | Turns | Score-qualified | Below threshold | Fresh human turns after cursor |
82
- |---|---:|---:|---:|---:|---:|
83
- | `62056bff…` | 5,913 | 12 | 6 | 6 | 0 |
84
- | `adedb9ac…` | 5,766 | 23 | 16 | 7 | 0 |
85
- | `e38a0de0…` | 85 | 2 | 0 | 2 | 0 |
86
- | `edf7dc5c…` | 78 | 4 | 0 | 4 | 0 |
87
-
88
- Below-threshold turns on the two small sessions can still wake through starvation; on the 2,000+ event sessions they do not. None of the four had new human input after its real cursor, so none would fork again immediately.
89
-
90
- ## One WebUI
91
-
92
- The sidebar has exactly **one** entry: **MemU WebUI**. The memory wall and all settings live in the same navigation, with deep links such as `#/settings/memories`, `#/settings/folders` and `#/settings/stats`. The interface follows the browser locale (Chinese or English).
93
-
94
- **Private / global groups with multi-select.** The "Memories" page splits into **Private** and **Global** blocks (private first, default). The private block supports **multi-select**: bulk archive, restore and permanent delete (two-step confirm) — one failed row never eats the rest. Every row on the Global memory page has a "View" action that jumps straight to that entry on the wall.
95
-
96
- **In-place work.** Clicking a memory card opens a right-side drawer with the full text and the fields that decide how it behaves — title, content, tags, disclosure, confidence, open loop — plus save, archive, restore and "open in the browser" for heavier work. Archived memories can be deleted in the same drawer; the first click only arms it and the second confirms. Global memories keep their curator-written content read-only in the drawer, but archive, restore and two-step permanent delete work there just like private ones, and link to their own page. Filters and scroll position stay where they were. Cards that carry images use the first usable attachment as a cover, and the drawer opens the full gallery; `secret` and `never_say` entries never receive a pixel URL, so they show a label instead.
97
-
98
- **One page for the graph.** **Relations** is its own full-screen page in the WebUI (`#/settings/graph`): the canvas on the left, the inspector on the right, and a **Manage** tab using the same domain and search filters. **All libraries** combines private libraries with separate identities for same-id nodes and follows 200-node pages through trailing entities; the canvas retains every loaded node. The editable **Domain** filter accepts built-in or custom domains (for example `coding` or `project:travel`), matches the full normalized name, and shows all domains when empty. Missing memory domains count as `general`; a filtered entity appears when linked to a matching memory. Source and rule filters narrow displayed edges. Settings → Relations opens this page; graph browsing retains the existing library and session authorization boundaries.
99
-
100
- The graph runs on a **self-written continuous force engine** — no third-party runtime is bundled. It stays alive while you work, preserves node positions and the camera across background data refreshes, and stops requesting frames the moment it cools down, so an open graph costs no idle GPU. Dragging pins a node exactly where you drop it (release never yanks it back), and only the cluster you touched keeps simulating: frozen clusters act as obstacles the moving one cannot slide through. Repulsion, link distance and centering are adjustable in the panel, labels avoid collisions, and the minimap repaints only after the canvas does. Zoomed all the way out the nodes necessarily merge on screen — separation lives in world coordinates, so spread clusters with repulsion/link distance instead of the zoom. Settings → Relations is a single button that opens the full-screen graph page in the WebUI, where you can also add, edit and delete nodes, and filter edges by the rule that produced them. The layout only visualizes recorded links: it never infers or writes relationships. The graph page also lists **entity merge candidates** (same kind, contained or near-identical spellings) — suggestions only, confirmed by two clicks, and merging redirects links and folds aliases into the main node without deleting any memory.
101
-
102
- | Page | What it is for |
103
- |---|---|
104
- | Memories | Private/global grouped wall, source/status/library/preview, in-place drawer, multi-select bulk ops, node graph tab |
105
- | Engine & connection | Optional MemU engine install/switch, embedding endpoint, backups and restore; local runtime download shows MB/s, offers npmjs / npmmirror, and supports pause, stop and resume |
106
- | Memory settings | Injection mode, token budgets, topK, same-domain cross-library recall, relevance threshold, retention, open-loop cadence, freshness hint, date wake-up, automation |
107
- | Folders | Folder-level private/global ceiling, expandable conversations and their own switches |
108
- | Libraries | Create, rename, archive, restore, explicitly delete libraries |
109
- | Memory browser | Full-text editing, attachments, review queue, graph and bounded canvas, JSON/ZIP import/export |
110
- | Global memory | Domain-scoped global memories, evidence, review queue and the separate curator; every row can jump to the wall |
111
- | Prompts | General / RP / Coding / Mixed variants, overrides and per-key reset; unanswered conversations use preset/folder detection; the first-run prompt lets you choose the domain |
112
- | Stats | Daily activity, hit distribution, health, never-recalled shortlist, 7-day write/read ratio |
113
-
114
- Settings save as you change them (250 ms debounce), with about 2.5 s cross-window sync and a heartbeat for writes made by tools or another window. The WebUI opens in a new tab; when a popup is blocked it falls back to an in-app overlay without unloading the host SPA. Light, dark, reduced-motion and narrow layouts are supported. Consolidation alerts stack in narrow sidebars; conversation titles remain visible, with timestamps and jump buttons on a separate line.
115
-
116
- ### Injection token budgets
117
-
118
- `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.
119
-
120
- ### Time-sensitive memory (1.2.3)
121
-
122
- - **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.
123
- - **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.
124
- - **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.
125
-
126
- ### Domain Prompts
127
-
128
- 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. Before a domain is chosen, new conversations use preset/folder detection: RP-marked names select RP, other folders select Coding, and no folder selects General. The prompt initially selects RP, but only confirmation makes that an explicit choice. Coding, Mixed and custom pages remain available. “Later” postpones the question until you leave and return; transient checks retry with backoff rather than counting as an answer. A session first observed as blank remains eligible even if its first message arrives before the folder information; historical conversations are not prompted retroactively.
129
-
130
- | Domain | Memory focus |
131
- |---|---|
132
- | Coding | Requirements, acceptance criteria, interfaces, call chains, invariants, root causes, tradeoffs, verification and handoff points. Neutral engineering notes, not character psychology. Preserve necessary minimal code and exact semantics without copying whole files or truncating critical conditions. |
133
- | RP | Evidenced moments, character reactions, names and habits, commitments, boundaries and repair. Let memory shape present choices without repetitive callbacks, invented facts or automatic intimacy. |
134
- | Mixed | The prompt separates technical, character and OOC material per item; it does not automatically change the session domain. Tags aid retrieval, not access control or character knowledge. |
135
- | General | Neutral facts, preferences, decisions with reasons, promises and constraints; no default roleplay. |
136
-
137
- Updated defaults never overwrite custom text. The default-update notice remains until that prompt is saved or reset. Compare, merge or restore individual prompts in **Prompts**; there is no need to clear memories. Regression tests cover routing and output contracts, not a guarantee of naturalness or long-term memory quality, which still requires real-conversation evaluation.
138
-
139
- ## Installation
140
-
141
- ### Requirements
142
-
143
- | | |
144
- |---|---|
145
- | DSH | `>=0.2.0-rc.1` (web profile; verified on `0.2.2-rc.1`, 2026-11-05) |
146
- | Node.js | `>=20.9` |
147
- | OS | Windows, macOS or Linux, wherever DSH's web host runs |
148
- | Optional engine | Python 3.11+ **only** if you choose the vector backend. The default backend needs no Python, no embedding service and no API key. |
149
-
150
- ### Method 1 — npm (recommended)
151
-
152
- ```sh
153
- dsh plugin --profile web add dsh-memu-memory
154
- dsh web
155
- ```
156
-
157
- Restart the host after installing or updating. The plugin appears as **Settings → MemU**, and the right sidebar gets the **MemU WebUI** button.
158
-
159
- > Replace `web` with your profile name if you use another one. Older DSH CLIs accept the shorter form `dsh plugin add dsh-memu-memory` without the profile flag.
160
-
161
- ### Method 2 — npx (no global install)
162
-
163
- ```sh
164
- npx @deepseek-ai/dsh plugin --profile web add dsh-memu-memory
165
- npx @deepseek-ai/dsh web
166
- ```
167
-
168
- ### Method 3 — from a local checkout (development)
169
-
170
- The repository has **no build step**: `lib/` is the runtime. Clone it, link the checkout into your DSH profile, and add the bundle.
171
-
172
- ```sh
173
- git clone <this repository> dsh-memu-memory
174
- cd dsh-memu-memory
175
- npm ci --legacy-peer-deps
176
- ```
177
-
178
- In the profile's `package.json`:
179
-
180
- ```json
181
- {
182
- "dependencies": {
183
- "dsh-memu-memory": "link:/absolute/path/to/dsh-memu-memory"
184
- },
185
- "dsh": {
186
- "profile": {
187
- "bundles": ["dsh-memu-memory"]
188
- }
189
- }
190
- }
191
- ```
192
-
193
- Then restart DSH. A symlinked checkout is picked up on restart; there is no bundle cache.
194
-
195
- ### Optional — vector engine (MemU)
196
-
197
- The default `agent` backend is fully usable without this step. Install the engine from **Settings → MemU → Engine & connection**, or from a terminal:
198
-
199
- ```sh
200
- npx --package dsh-memu-memory dsh-memu-memory-setup
201
- ```
202
-
203
- What it does:
204
-
205
- - installs the pinned `memu-cli==0.11.0b3` into `~/.dsh/dsh-memu-memory/engine/<version>/venv`;
206
- - never installs into the system Python or user site-packages, and leaves no `pip` inside the venv;
207
- - tries PyPI mirrors in order (user-configured → Tsinghua → Aliyun → pypi.org);
208
- - if no usable Python/pip exists, uses a **pinned uv** runtime inside the plugin directory and leaves the system `PATH` untouched;
209
- - downloads roughly 150 MB, runs a real smoke test, and keeps the previous version for rollback.
210
-
211
- The default `memoryBackend="agent"` uses lexical recall and does not call an embedding service. To enable the vector library, choose `memoryBackend="api"`, then select `vectorSource="local"` for managed local embeddings or `vectorSource="api"` for a configured compatible embedding endpoint (which may itself run on localhost). Both sources feed MemU storage and retrieval; installing the MemU engine alone does not enable vectors.
212
-
213
- `memoryMode` (`local` / `cloud`) is a MemU storage-compatibility setting, not the embedding switch or source selector; its cloud option is not a claim that managed local inference is offline cloud storage. Summary generation is configured independently of the vector route: ordinary private consolidation uses an Agent fork; an explicit remote-summary action uses its chat endpoint and commits through the same memory write path. Recall uses neither LLM reranking nor an LLM fallback. Exact memory ids still use the direct path; the plugin does not maintain a parallel vector database.
214
-
215
- Managed model download, progress reporting and profile-switch/migration flows are implemented, but real model/runtime downloads and end-to-end native inference/switching have not been verified in this work. A candidate or `pending` artifact is not available for use; it must not be advertised as downloadable or ready until its artifact and validation gates pass.
216
-
217
- ## First run
218
-
219
- 1. Install, then restart DSH.
220
- 2. Open **MemU WebUI** from the sidebar (or Settings → MemU).
221
- 3. New conversations ask once whether this chat should use memory: private only, global only, both, or none. **Remember my choice** skips the question later. The card you pick **sets both switches at once**, so the sidebar shows the card you chose; the advanced "existing / new library" pick only changes which library the private layer reads, never the two switches.
222
- 4. If you want a folder-wide ceiling, set it under **文件夹** — a folder can forbid private or global memory, and the chat switches will respect that ceiling.
223
- 5. Talk. The agent writes private memories itself. The **MemU 记忆** wall is where you review, edit, archive, link and export them.
224
-
225
- Folder policy is a **ceiling, not an initial value**: turning a folder switch off immediately clamps every conversation in it, and turning it back on restores each conversation's own choice. A folder with both switches off does not prompt, does not create a library and does not inject anything.
226
-
227
- ## Model tools
228
-
229
- | Tool | Purpose |
230
- |---|---|
231
- | `memu_private_remember` | Write a private memory, with source, layer, disclosure, visibility, tags, open loop and attachment references |
232
- | `memu_private_recall` | Keyword snippets or exact-id body pages (`view`, `offset`, `limitChars`, `revision`, optional allowed `libraryId`); search `topK` is a hard 1–20 row limit, conflicts use pointers |
233
- | `memu_private_list` | List the memories usable in the current scope |
234
- | `memu_private_update` | Edit, without bypassing pin admission, review or visibility rules |
235
- | `memu_private_archive` | Archive; never delete |
236
- | `memu_private_unpin` | Marginalize a permanent memory with a first-person reason, quota and cooldown |
237
- | `memu_private_link` | Link memories/entities with evidence, or update a relationship snapshot; also adjudicates uncertain `memu_private_link_suggest` candidates; cannot delete edges |
238
- | `memu_private_link_suggest` | Refresh deterministic edges (confirmed-entity mentions and field evidence) for ids written this consolidation and return only uncertain candidate pairs |
239
- | `memu_lexicon_search` | Search active lexicon terms this conversation can see: bound library + global lexicon (+ same-domain libraries when cross-library recall is on); archived and tombstoned terms stay hidden |
240
- | `memu_lexicon_propose` | Add or update a lexicon term in the bound library (never the global lexicon); ordinary entries become active immediately, sensitive triggers remain user-only |
241
- | `memu_global_recall` / `memu_global_list` | Read the global layer by domain; recall supports snippets or versioned exact-id body pages without broadening eligibility |
242
- | `memu_status` | Storage health, sync heartbeat, recall state and image-turn status |
243
-
244
- The main agent has **no global write tool**. Global memories are produced only by the separate curator.
245
-
246
- ## Privacy, permissions & data
247
-
248
- **What is stored.** Everything lives under `~/.dsh/dsh-memu-memory/` (or `$DSH_MEMU_MEMORY_HOME`; the legacy `$DSH_MEMU_HOME` and `~/.dsh/dsh-memu` are still honoured when no new `state.json` exists):
249
-
250
- ```text
251
- ~/.dsh/dsh-memu-memory/
252
- ├─ state.json settings, folder policies, session bindings
253
- ├─ index/<libraryId>.json private memory bodies (source of truth)
254
- ├─ index/global.json global memories
255
- ├─ index/*.stats.json per-day counters (90-day roll)
256
- ├─ index/*.media.json attachment metadata and reference counts
257
- ├─ index/*.entities.json entities and relationship snapshots
258
- ├─ attachments/<libId>/<sha256>.<ext>
259
- ├─ libraries/*.sqlite3 optional vector layer (acceleration, not truth)
260
- ├─ engine/<version>/venv optional MemU engine
261
- ├─ prompts/ user prompt overrides
262
- ├─ backups/ explicit backups and pre-switch snapshots
263
- └─ logs/ install log only
264
- ```
265
-
266
- - **Text and images are not encrypted at rest.** The directory is inside your home directory. If that is not acceptable, do not store secrets in memories and protect the disk with OS-level encryption.
267
- - **Images are opt-in privacy data.** Only host-approved attachments are captured. `secret` entries never serve their attachments over the HTTP route; `never_say` captions are not echoed. The vision description service is enabled by default, but it only sends an image after you configure an endpoint, and it may cost money. It never uses host credentials automatically.
268
- - **Network.** No telemetry. Outbound traffic happens only for (a) the optional engine installer downloading Python packages/uv from the configured mirrors, (b) the embedding endpoint you configure, (c) the optional remote summary model, and (d) the vision endpoint you configure (enabled by default; no call is made until an endpoint is configured). The default backend makes no external calls for memory operations.
269
- - **Shell and filesystem.** The optional engine installer uses Python/pip in a private venv (and a pinned uv fallback inside the plugin directory). It does not modify system Python, install global packages or change `PATH`. All memory writes are confined to the data directory; config writes use temp-file + rename.
270
- - **Deletion.** Archiving moves a memory out of retrieval; permanent deletion is a separate, guarded action for already-archived entries. Deleting a conversation only unbinds it; it never deletes the library. Library deletion asks for confirmation and is backed up first.
271
-
272
- ## External messages in a long tool turn
273
-
274
- A host turn may remain open while a third-party tool waits for messages.
275
- New human input can trigger one bounded recall at the next model step without
276
- ending that turn or making another model call. Native user messages work directly.
277
- Unmarked tool logs, sleep completions, failed calls and empty polls do not trigger it.
278
- The plugin does not depend on a particular waiting implementation.
279
-
280
- Transport plugins can put this exact object in their own `ToolResult.meta.memoryInbound`:
281
-
282
- ```js
283
- const batch = {
284
- type: 'dsh-memu-memory/inbound-batch',
285
- version: 1,
286
- producer: 'my-message-transport',
287
- batchId: 'delivery-42',
288
- messages: [{
289
- id: 'remote-message-18',
290
- role: 'user',
291
- context: { channelId: 'room-1', speakerId: 'person-7' },
292
- content: [{ type: 'text', text: 'Where is the deployment script we discussed?' }],
293
- }],
294
- }
295
- // A normal ToolResult: keep the original model-facing content and other metadata.
296
- return { content: originalContent, meta: { ...originalMeta, memoryInbound: batch } }
297
- ```
298
-
299
- The channel/character/world/branch must match the conversation's configured memory
300
- scope; omit unavailable identities rather than guessing them. Images must use
301
- `{ type: 'image', attachment: hostAdmittedRef }`, never filesystem paths, URLs or bytes.
302
- If metadata is unavailable, return the complete protocol as JSON text and list
303
- the exact tool name under **External message tool allowlist**. JSON embedded in logs
304
- or code fences is not accepted, nor is JSON from an unapproved tool.
305
-
306
- An in-process integration may instead import
307
- `ingestInboundBatch` from `dsh-memu-memory/integration` and call
308
- `ingestInboundBatch({ sessionId, batch, ctx, session })`. It registers work only:
309
- the producer still delivers the actual incoming content to the model. It does not
310
- wake the agent, append a fake user turn or write fact memories.
311
-
312
- Deduplication uses producer + channel + speaker + message id; changing a delivery id
313
- does not replay an already processed message. Memory cadence advances by human-message
314
- batches even when the host turn number stays fixed. Pending input is capped at 32
315
- messages / eight images / 96 KB, with at most 4000 characters per external text block;
316
- overflow is explicitly refused, never silently discarded. Split oversized batches.
317
- Recall failure preserves the queue with a 30-second retry delay; cancellation does not consume it.
318
- Only the admitted batch is confirmed, so messages arriving during recall remain pending.
319
- Running agents (including waiting tools) and pending batches are not sleep-consolidated;
320
- the idle window starts from real message activity or the agent's return to idle.
321
- `memu_status` reports `inbound` queue/clock/result and `inbound_error` when degraded.
322
-
323
- ## Compatibility & limits
324
-
325
- - **Host:** DSH `>=0.2.0-rc.1`, using public extension points only (tools, injection, session query, subagents, slots, a prefixed HTTP route). No host source modifications. The core surfaces (13 `memu_*` tools, guide injection, settings page, right-sidebar tab, prefixed RPC) were verified on `0.2.2-rc.1` on 2026-11-05; the check table lives in [`docs/host-adaptation.md`](docs/host-adaptation.md). The optional dated-wake feature uses the host-wide `ctx.schedule` task API introduced in `0.2.2`; on `0.2.0`–`0.2.1` (session-scoped reminders) it detects the older shape and skips with one warning instead of retrying every sweep.
326
- - **Recall quality:** the default backend is lexical. Semantic recall depends on the optional engine and the embedding model you choose; the plugin cannot improve a model it does not own. LongMemEval, long-running group-chat A/B and "human-likeness" scores have **not** been run — test counts are not a quality score. A clear lexical topic match can outweigh rank-flattened competitors; recognised QQ/response-style scaffolding is excluded from that dominance evidence, but arbitrary templates and languages are not semantically understood.
327
- - **No cloud sync, no accounts, no cross-device sync.** This is a local plugin with no server-side identity.
328
- - **Images without vision:** without an optional caption/vision endpoint, an image memory is a pointer plus what a person wrote about it. The plugin does not claim to see pixels.
329
- - **Poisoned v4 sessions:** historical `format v4 message requires a producer-owned source kind` rows can be diagnosed but not rewritten; the plugin never edits private session files.
330
- - **Agent presets:** a conversation whose preset (`i-am-yuike`, `yuike-standard`, …) carries its own `cordis.yml` composes its model-facing plugins from that list alone, and its scope never delivers `agent/pre-step` to this plugin. At runtime `lib/preset-scope.js` attaches an injection listener to that agent's own context, so **anchor and recall delivery works**. All conversations now receive the memory rules as one `<memory-guide rules="…">` plugin message on the first step of a turn; the plugin no longer registers a system-prompt section, and the message is replaced after a domain/prompt change or a compaction (`rulesKey` / `guideLost`). The rules message carries a **tool timing map** (recall/global_recall, remember(+batch)/update, list/status, and archive/unpin only on an explicit user request) in all four domains: `general`, `rp`, `coding` and `mixed`. The **final tool list** is a third, separate question: it follows the preset's own plugin list and the host scope, and it cannot be inferred from whether this plugin is listed — observations in this repo record both "no `memu_*` tools" and `memu_private_*` present in some presets' tool chains. **Per-preset tool availability still needs a real-host check (W3)**; until then do not read this as "presets have no tools", nor as "listing the plugin is enough". The plugin never edits anyone's preset files.
331
- - **Reused session ids in IM channels, and domain switches:** `dsh-channel` and similar surfaces reuse a deterministic id (`qq-dm-<uid>`) across restarts, and the host can re-create a same-id session with an empty transcript. The plugin compares the host session identity (`session.createdAt`; when the host does not expose it, a turn number back at 1 plus the first message id) against the stamp kept on the binding, and on a new incarnation it clears the previous incarnation's `guideRulesKey` / `anchorPushed` so the rules and the anchor are delivered again (1.4.1+). Before this, such a conversation could run its whole life without a `<memory-guide>` message. **Switching the memory domain** re-delivers too: the rules message, the anchor, today's anniversaries, open loops and the time-of-day line are all domain-filtered, so a domain change resets them and they are delivered again for the new domain. Guide delivery is also decoupled from recall: a recall exception no longer swallows the rules message.
332
- - **Overdue and stale cleanup:** a short-term draft leaves recall at its deadline and is archived 30 days later (never deleted; the body can still be promoted back to `long_term`). Overdue promises surface at most three per turn, dated open loops once a day, and the consolidation brief ships an "overdue" section so the worker can close them from transcript evidence (`done`/`cancelled`/`expired`); the periodic sweep only writes a hint and never changes a status. Entries whose `valid_to` has passed leave recall and are archived or re-windowed during consolidation. Whether a promise was kept is a factual question — the plugin does not answer it for you.
333
- - **Coding consolidation detail:** the fork seed keeps every coding turn that touched a tool (up to 120 turns, default 60), 2,200 chars of a tool result and 1,000 chars of call arguments; the worker path's turn-log keeps 600-char tool lines and 400-char arguments (default 160/120), and the turn-log-off fallback compaction keeps 1,400/700 (default 400/300). RP/general keep their original caps, and the 500-event window, 12k per-message text and 4,000-char per-record limits still bound everything.
334
- - **Consolidation worker (C 包, 2026-10-30).** An idle or manual pass now works from a *fixed snapshot*: it takes the public `sessionQuery.observeSession()` lease (falling back to `readSession()` when the host offers no lease), cuts at the last complete `turn/end`, and drops unpaired tool calls and half steps — a live transcript whose last turn is still open is **deferred**, never consolidated. A job is settled only by a structured completion receipt that is cross-checked against the library index (an id the library does not contain is not a success, and a rewrite of an existing id counts as an update, not a new memory). Checked / pending / in-flight ranges and a lease are persisted separately in `consolidation.json`, so a crash, a timeout or a failed turn leaves the range pending instead of looking consolidated. **Limits:** the worker still runs inside the parent preset's own system prompt — it receives an explicit "you are a background consolidation worker, not this character" brief, which reduces but does not remove persona carry-over, because the host has no public API to replace that prompt; and when the conversation's tool surface carries no `memu_private_remember` / `memu_private_update` (or exposes memory only through PTC), consolidation reports `unavailable` (`worker-tools-missing` / `worker-tools-ptc-only`) rather than forking a worker that could not write. The parent's library, scope, domain and memory context are re-checked before dispatch, on every worker tool call, and again before any result is credited.
335
- - **Consolidation coverage is conservative lexical evidence.** A matching date or a couple of shared terms does not prove a candidate was written. The local check also requires text coverage, retained characters/words and values, and matching clause polarity; uncertain candidates stay in carry. It can retain a paraphrase that was already saved, and it does not claim semantic equivalence.
336
- - **"Tomorrow" is resolved at write time.** A relative day (今天 / 明天 / 后天 / today / tomorrow) together with a month-day settles into one dated memory; a memory that only says "sometime next month" keeps no date rather than inventing one. A date that was already written as `MM-DD` is not rewritten — the fix applies to new writes.
337
- - **Not in scope:** cloud MemU integration, source backfill for old entries, automatic repair of already-written v4 corruption.
338
-
339
- ## Development & verification
340
-
341
- ```sh
342
- npm ci --legacy-peer-deps
343
- npm test # full suite; the isolated real-engine case skips unless configured
344
- npm run check # syntax + i18n key alignment + package.json
345
- npm run build:graph # rebuild shipped offline assets after graph source changes
346
- node scripts/acceptance-local.mjs # 50 automated acceptance checks
347
- node scripts/migrate-visibility.mjs # report (add --apply to rewrite) libraries that still store the removed session level
348
- node --import ./tests/loader-register.mjs scripts/preview.mjs --port 7789
349
- node scripts/make-readme-shots.mjs # re-record the screenshots above against that preview
350
- ```
351
-
352
- The preview serves the real WebUI against isolated example data at `http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories`.
353
-
354
- With the preview running, use `npm run test:graph-browser -- http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories` in another terminal to check 200 nodes, desktop/narrow layouts, dragging, refresh stability, themes and load retries. Run `npx playwright install chromium` once, or set `GRAPH_BROWSER_CHANNEL=msedge` on Windows to use installed Edge. Stress data is intercepted only in the test browser and never written to memory. No CDN is needed at runtime; the bundle carries no third-party runtime code, which `lib/webui/graph-LICENSE.txt` records.
355
-
356
- The suite includes two optional real-engine integration cases: curator writing requires `DSH_MEMU_TEST_ENGINE_PYTHON`, and the backup venv/WAL case requires `DSH_MEMU_BACKUP_REAL_ENGINE=1`; both are skipped by default. The 50 automated acceptance checks pass. The optional engine was installed and smoke-tested in an isolated directory with the pinned wheel; embedding tests use a local deterministic server, which proves the protocol, not semantic quality.
357
-
358
- ## Documentation
359
-
360
- - Release notes: [`CHANGELOG.md`](CHANGELOG.md)
361
-
362
- [`AGENTS.md`](AGENTS.md) is the index for anyone changing this repo — which file answers
363
- which question. The detail lives in [`docs/`](docs/): failure modes, the change process,
364
- the host facts, and the UI, memory and environment rules.
365
-
366
- ## License
367
-
368
- [MIT](LICENSE) © dsh-memu-memory contributors.
369
-
370
- You may use, modify, distribute and sell this software, provided the copyright notice and permission notice are included. The software is provided **as is**, without warranty of any kind.
371
-
372
- ---
373
-
374
- If this plugin is useful to you, open an issue with the host version and a minimal reproduction — memory bugs are easiest to fix when the transcript and the storage state are both available.
1
+ <p align="center">
2
+ <img src="assets/icon-256.png" width="88" height="88" alt="dsh-memu-memory">
3
+ </p>
4
+
5
+ <h1 align="center">dsh-memu-memory</h1>
6
+
7
+ <p align="center">
8
+ A local-first memory plugin for <b>DeepSeek Harness</b> — shared by folder, bound to a chat,
9
+ written by the agent, curated in the background, and honest about what it does not know.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/dsh-memu-memory"><img alt="npm version" src="https://img.shields.io/npm/v/dsh-memu-memory?color=4d6bfe"></a>
14
+ <a href="https://www.npmjs.com/package/dsh-memu-memory"><img alt="npm monthly downloads" src="https://img.shields.io/npm/dm/dsh-memu-memory?color=4d6bfe"></a>
15
+ <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/npm/l/dsh-memu-memory?color=4d6bfe"></a>
16
+ <a href="package.json"><img alt="DSH: >=0.2.0-rc.1" src="https://img.shields.io/badge/DSH-%E2%89%A50.2.0--rc.1-4d6bfe"></a>
17
+ <a href="package.json"><img alt="Node: >=20.9" src="https://img.shields.io/badge/Node-%E2%89%A520.9-4d6bfe"></a>
18
+ </p>
19
+
20
+ <p align="center">
21
+ English | <a href="README.zh.md">中文</a>
22
+ </p>
23
+
24
+ ---
25
+
26
+ `dsh-memu-memory` is built for long-form RP and companion chats. It gives a DSH conversation a memory that behaves like memory instead of a log: three retention layers that fade, a first-turn anchor plus at most one per-turn recall, provenance that cannot be quietly upgraded from "I inferred it" to "they said it", contradictions that either wait for a decision or — when explicitly versioned — stay side by side with a conflict card instead of being silently merged, near-identical facts collapse to one entry and one recall seat, and an optional relationship graph with evidence. Speakers, characters, worlds and story branches form hard boundaries, and what a character is allowed to know stays separate from what actually happened.
27
+
28
+ It is **local-first by default**. The default `agent` backend stores full text in JSON indexes and recalls lexically — no Python, no embedding service, no API key. The `api` backend switches recall to the optional, pinned MemU engine (vector search). MemU is a plugin for people who want it, not a requirement for the plugin to start.
29
+
30
+ > **Version:** 1.4.4. See [`docs/`](docs/) for the manual and [`AGENTS.md`](AGENTS.md) for the contributor index. Back up `~/.dsh/dsh-memu-memory` before upgrades; see [Compatibility & limits](#compatibility--limits) for storage and integration boundaries.
31
+
32
+ ## Screenshots
33
+
34
+ All screenshots are the real WebUI on isolated example data, not anyone's memories.
35
+
36
+ <table>
37
+ <tr>
38
+ <td align="center"><img src="assets/screenshots/webui-memory.jpg" width="470" alt="Memory wall"><br/><em>MemU WebUI · cross-library memory wall</em></td>
39
+ <td align="center"><img src="assets/screenshots/drawer.jpg" width="470" alt="In-place memory drawer"><br/><em>Edit, archive or restore without leaving the wall</em></td>
40
+ </tr>
41
+ <tr>
42
+ <td align="center"><img src="assets/screenshots/relations.jpg" width="470" alt="Relationship graph studio"><br/><em>Full-screen relationship graph · canvas and inspector</em></td>
43
+ <td align="center"><img src="assets/screenshots/settings.jpg" width="470" alt="Settings"><br/><em>Injection, budgets, retention and automation</em></td>
44
+ </tr>
45
+ <tr>
46
+ <td align="center"><img src="assets/screenshots/stats.jpg" width="470" alt="Statistics"><br/><em>Daily activity, hit distribution and archive candidates</em></td>
47
+ <td align="center"><img src="assets/screenshots/webui-dark.jpg" width="470" alt="Dark theme"><br/><em>Dark theme · the same surfaces and motion</em></td>
48
+ </tr>
49
+ <tr>
50
+ <td align="center" colspan="2"><img src="assets/screenshots/mobile.jpg" width="360" alt="Narrow layout"><br/><em>Narrow layout · the rail folds into a horizontal strip</em></td>
51
+ </tr>
52
+ </table>
53
+
54
+ ## What it remembers
55
+
56
+ - **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.
57
+ - **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.
58
+ - **Invisible memories cannot crowd out visible ones.** Private lexical recall builds its scoring corpus after applying conversation context, speaker and disclosure rules, including the lexical branch of mixed recall. Explicit reads retain their disclosure permissions.
59
+ - **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. A **global lexicon** sits beside the per-library ones: every conversation reads it, only you write it. With same-domain cross-library recall on, the anchor, this-turn match and `memu_lexicon_search` merge those libraries too — the page still browses one book at a time.
60
+ - **Private links come from assertions, not statistics.** `autoLinkMode` defaults to *candidates only*: a local zero-token pass ranks names into a review queue and writes nothing. Once you confirm an entity, its names and aliases are matched against memory text (`entity-mention`); `conflicts_with` / `supersedes` / the same `fact_key` add field-evidence edges. Lexical similarity, shared tokens and vectors never create an edge. Confirming, renaming, merging or deleting an entity maintains its edges immediately, and a removed auto edge is suppressed so it cannot come back. Links are metadata, shown with an “Auto” badge in the graph; they never rewrite a body, write a vector or delete anything. Existing libraries migrate with `node scripts/rebuild-auto-links.mjs` (dry-run first, `--apply` takes a backup). New names proposed by a model must appear as complete quoted, introduced or delimited names in the source memory; a substring or the link note alone is insufficient. Existing names and aliases remain reusable, and rejected links leave no new entity.
61
+ - **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. Relative wording (今天 / 明天 / 下周X / 月底) is resolved against the turn's scene time and stored as an absolute date; a memory that says "tomorrow" is stored as the dated form, so an appointment does not come back every year.
62
+ - **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
+ - **Provenance is a fact, not a style.** Every entry carries `source` / `source_kind` (`user_said` / `assistant_said` / `told` / `imagined` / `inferred` / `tool`), `speaker_id`, `confidence`, `accuracy`, and disclosure rules. A vague recollection cannot impersonate a quote, and the assistant's own promises or plans cannot be filed as something the user said.
64
+ - **Contradictions do not get silently merged.** An ordinary contradiction still lands as `pending_review`: it is not injected, not recalled, and appears in a review queue until someone accepts or rejects it. When the writer explicitly marks two statements as versions of one fact (`conflicts_with`), both stay active, are recalled together and surface as a conflict card; an explicit `supersedes` retires the old row without deleting its text.
65
+ - **Secrets stay excluded.** `secret` visibility, group-chat channels, characters, worlds, branches and `knownBy` all constrain reads and edits. Automatic recall never injects a `secret` memory, and a `secret` is still readable by an explicit recall from the same folder — it hides a memory from the prompt, it is not a lock. What actually separates two conversations in one folder is the `context` scope (`channelId` / `characterId` / `worldId` / `branchId`); a blank scope on both sides means one shared scope, which is the point of a folder. The old `visibility: 'session'` level is gone — reading turns it into `shared` with its `context` untouched, and `node scripts/migrate-visibility.mjs` rewrites libraries that still store it (`--apply`, backs up first).
66
+ - **People and stories are structured.** Group chat uses stable `speakerId` / `channelId`, not display names. RP uses `characterId` / `worldId` / `branchId`. Relationships are edges with a note and confidence, entities can be renamed without rewriting memory bodies, and the current relationship state (familiarity, trust, warmth, boundaries, promises) is a snapshot that keeps its history and evidence.
67
+ - **Images are pointers and captions, not pretend vision.** Attachments are deduplicated by SHA-256, quota-limited and tiered; an image without a description is remembered as "received an image", never as a scene the model did not see.
68
+ - **Housekeeping happens in the background.** Consolidation runs in a seeded fork sub-session, never as an editable turn in your chat. Failed runs back off instead of reporting success. Unsupported reasoning-effort combinations are remembered across restarts and omitted on the next fork/new worker, including inherited settings; a new provider/model/effort combination may still fail once before it is learned.
69
+
70
+ ### Lifecycle maintenance and media delivery
71
+
72
+ An independent maintenance queue can review existing open commitments, unfinished threads and ended validity windows even without a new conversation turn. It obeys private scope and disclosure boundaries, rotates work fairly, records insufficient evidence, and uses a tool-free reviewer followed by revision-checked application. Deadline passage alone never proves an unfulfilled promise. Assistant-only completion claims require confirmation. `memu_status` reports the bound library's queue counts; background model review follows `sleepConsolidation`.
73
+
74
+ `open_loop` no longer invents a commitment or borrows an event date as a deadline. Update patches keep omitted fields; `clear_commitment_due` and `clear_commitment` provide explicit clearing through the host's single-type tool schema. Media bytes remain SHA-deduplicated, while each message occurrence keeps its identity: duplicate display rows merge within a block, new messages can resend the same image, and only displayed occurrences are consumed after host admission.
75
+
76
+ Implementation notes: see [`docs/memory-semantics.md`](docs/memory-semantics.md) §8.19 and [`docs/troubleshooting.md`](docs/troubleshooting.md). Historical audits require an explicit plugin data directory and do not write data: `node scripts/audit-memory-lifecycle.mjs --help`.
77
+
78
+ ### Background consolidation
79
+
80
+ Before starting a consolidation fork, the plugin scores new evidence using human turns (`H`), content volume (`C`) and effective tool work (`U`): `score = 0.35*min(H/3,2) + 0.45*min(C/4000,2) + 0.20*min(U/20,2)`, with a default threshold of 0.8. Each successful tool result contributes at most 2,000 characters to `C`.
81
+
82
+ After 15 idle minutes, small sessions may wake below the score threshold. Transcripts with 2,000 or more events still require sufficient evidence. A pending range above 600 events triggers a check independently; recent consolidation or recall suppresses redundant idle work.
83
+
84
+ ## One WebUI
85
+
86
+ The sidebar has exactly **one** entry: **MemU WebUI**. The memory wall and all settings live in the same navigation, with deep links such as `#/settings/memories`, `#/settings/folders` and `#/settings/stats`. The interface follows the browser locale (Chinese or English).
87
+
88
+ **Private / global groups with multi-select.** The "Memories" page splits into **Private** and **Global** blocks (private first, default). The private block supports **multi-select**: bulk archive, restore and permanent delete (two-step confirm) — one failed row never eats the rest. Every row on the Global memory page has a "View" action that jumps straight to that entry on the wall.
89
+
90
+ **In-place work.** Clicking a memory card opens a right-side drawer with the full text and the fields that decide how it behaves — title, content, tags, disclosure, confidence, open loop — plus save, archive, restore and "open in the browser" for heavier work. Archived memories can be deleted in the same drawer; the first click only arms it and the second confirms. Global memories keep their curator-written content read-only in the drawer, but archive, restore and two-step permanent delete work there just like private ones, and link to their own page. Filters and scroll position stay where they were. Cards that carry images use the first usable attachment as a cover, and the drawer opens the full gallery; `secret` and `never_say` entries never receive a pixel URL, so they show a label instead.
91
+
92
+ **One page for the graph.** **Relations** is its own full-screen page in the WebUI (`#/settings/graph`): the canvas on the left, the inspector on the right, and a **Manage** tab using the same domain and search filters. **All libraries** combines private libraries with separate identities for same-id nodes and follows 200-node pages through trailing entities; the canvas retains every loaded node. The editable **Domain** filter accepts built-in or custom domains (for example `coding` or `project:travel`), matches the full normalized name, and shows all domains when empty. Missing memory domains count as `general`; a filtered entity appears when linked to a matching memory. Source and rule filters narrow displayed edges. Settings → Relations opens this page; graph browsing retains the existing library and session authorization boundaries.
93
+
94
+ The graph runs on a **self-written continuous force engine** — no third-party runtime is bundled. It stays alive while you work, preserves node positions and the camera across background data refreshes, and stops requesting frames the moment it cools down, so an open graph costs no idle GPU. Dragging pins a node exactly where you drop it (release never yanks it back), and only the cluster you touched keeps simulating: frozen clusters act as obstacles the moving one cannot slide through. Repulsion, link distance and centering are adjustable in the panel, labels avoid collisions, and the minimap repaints only after the canvas does. Zoomed all the way out the nodes necessarily merge on screen — separation lives in world coordinates, so spread clusters with repulsion/link distance instead of the zoom. Settings → Relations is a single button that opens the full-screen graph page in the WebUI, where you can also add, edit and delete nodes, and filter edges by the rule that produced them. The layout only visualizes recorded links: it never infers or writes relationships. The graph page also lists **entity merge candidates** (same kind, contained or near-identical spellings) — suggestions only, confirmed by two clicks, and merging redirects links and folds aliases into the main node without deleting any memory.
95
+
96
+ | Page | What it is for |
97
+ |---|---|
98
+ | Memories | Private/global grouped wall, source/status/library/preview, in-place drawer, multi-select bulk ops, node graph tab |
99
+ | Engine & connection | Optional MemU engine install/switch, embedding endpoint, backups and restore; local runtime download shows MB/s, offers npmjs / npmmirror, and supports pause, stop and resume |
100
+ | Memory settings | Injection mode, token budgets, topK, same-domain cross-library recall, relevance threshold, retention, open-loop cadence, freshness hint, date wake-up, automation |
101
+ | Folders | Folder-level private/global ceiling, expandable conversations and their own switches |
102
+ | Libraries | Create, rename, archive, restore, explicitly delete libraries |
103
+ | Memory browser | Full-text editing, attachments, review queue, graph and bounded canvas, JSON/ZIP import/export |
104
+ | Global memory | Domain-scoped global memories, evidence, review queue and the separate curator; every row can jump to the wall |
105
+ | Prompts | General / RP / Coding / Mixed variants, overrides and per-key reset; unanswered conversations use preset/folder detection; the first-run prompt lets you choose the domain |
106
+ | Stats | Daily activity, hit distribution, health, never-recalled shortlist, 7-day write/read ratio |
107
+
108
+ Settings save as you change them (250 ms debounce), with about 2.5 s cross-window sync and a heartbeat for writes made by tools or another window. The WebUI opens in a new tab; when a popup is blocked it falls back to an in-app overlay without unloading the host SPA. Light, dark, reduced-motion and narrow layouts are supported. Consolidation alerts stack in narrow sidebars; conversation titles remain visible, with timestamps and jump buttons on a separate line.
109
+
110
+ ### Injection token budgets
111
+
112
+ `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.
113
+
114
+ ### Time-sensitive memory (1.2.3)
115
+
116
+ - **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.
117
+ - **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 requires explicit source evidence; unsupported completion claims remain open for confirmation.
118
+ - **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.
119
+
120
+ ### Domain Prompts
121
+
122
+ 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. Before a domain is chosen, new conversations use preset/folder detection: RP-marked names select RP, other folders select Coding, and no folder selects General. The prompt initially selects RP, but only confirmation makes that an explicit choice. Coding, Mixed and custom pages remain available. “Later” postpones the question until you leave and return; transient checks retry with backoff rather than counting as an answer. A session first observed as blank remains eligible even if its first message arrives before the folder information; historical conversations are not prompted retroactively.
123
+
124
+ | Domain | Memory focus |
125
+ |---|---|
126
+ | Coding | Requirements, acceptance criteria, interfaces, call chains, invariants, root causes, tradeoffs, verification and handoff points. Neutral engineering notes, not character psychology. Preserve necessary minimal code and exact semantics without copying whole files or truncating critical conditions. |
127
+ | RP | Evidenced moments, character reactions, names and habits, commitments, boundaries and repair. Let memory shape present choices without repetitive callbacks, invented facts or automatic intimacy. |
128
+ | Mixed | The prompt separates technical, character and OOC material per item; it does not automatically change the session domain. Tags aid retrieval, not access control or character knowledge. |
129
+ | General | Neutral facts, preferences, decisions with reasons, promises and constraints; no default roleplay. |
130
+
131
+ Updated defaults never overwrite custom text. The default-update notice remains until that prompt is saved or reset. Compare, merge or restore individual prompts in **Prompts**; there is no need to clear memories. Regression tests cover routing and output contracts, not a guarantee of naturalness or long-term memory quality, which still requires real-conversation evaluation.
132
+
133
+ ## Installation
134
+
135
+ ### Requirements
136
+
137
+ | | |
138
+ |---|---|
139
+ | DSH | `>=0.2.0-rc.1` (web profile; verified on `0.2.2-rc.1`, 2026-11-05) |
140
+ | Node.js | `>=20.9` |
141
+ | OS | Windows, macOS or Linux, wherever DSH's web host runs |
142
+ | Optional engine | Python 3.11+ **only** if you choose the vector backend. The default backend needs no Python, no embedding service and no API key. |
143
+
144
+ ### Method 1 — npm (recommended)
145
+
146
+ ```sh
147
+ dsh plugin --profile web add dsh-memu-memory
148
+ dsh web
149
+ ```
150
+
151
+ Restart the host after installing or updating. The plugin appears as **Settings → MemU**, and the right sidebar gets the **MemU WebUI** button.
152
+
153
+ > Replace `web` with your profile name if you use another one. Older DSH CLIs accept the shorter form `dsh plugin add dsh-memu-memory` without the profile flag.
154
+
155
+ ### Method 2 — npx (no global install)
156
+
157
+ ```sh
158
+ npx @deepseek-ai/dsh plugin --profile web add dsh-memu-memory
159
+ npx @deepseek-ai/dsh web
160
+ ```
161
+
162
+ ### Method 3 — from a local checkout (development)
163
+
164
+ The repository has **no build step**: `lib/` is the runtime. Clone it, link the checkout into your DSH profile, and add the bundle.
165
+
166
+ ```sh
167
+ git clone <this repository> dsh-memu-memory
168
+ cd dsh-memu-memory
169
+ npm ci --legacy-peer-deps
170
+ ```
171
+
172
+ In the profile's `package.json`:
173
+
174
+ ```json
175
+ {
176
+ "dependencies": {
177
+ "dsh-memu-memory": "link:/absolute/path/to/dsh-memu-memory"
178
+ },
179
+ "dsh": {
180
+ "profile": {
181
+ "bundles": ["dsh-memu-memory"]
182
+ }
183
+ }
184
+ }
185
+ ```
186
+
187
+ Then restart DSH. A symlinked checkout is picked up on restart; there is no bundle cache.
188
+
189
+ ### Optional — vector engine (MemU)
190
+
191
+ The default `agent` backend is fully usable without this step. Install the engine from **Settings → MemU → Engine & connection**, or from a terminal:
192
+
193
+ ```sh
194
+ npx --package dsh-memu-memory dsh-memu-memory-setup
195
+ ```
196
+
197
+ What it does:
198
+
199
+ - installs the pinned `memu-cli==0.11.0b3` into `~/.dsh/dsh-memu-memory/engine/<version>/venv`;
200
+ - never installs into the system Python or user site-packages, and leaves no `pip` inside the venv;
201
+ - tries PyPI mirrors in order (user-configured → Tsinghua → Aliyun → pypi.org);
202
+ - if no usable Python/pip exists, uses a **pinned uv** runtime inside the plugin directory and leaves the system `PATH` untouched;
203
+ - downloads roughly 150 MB, runs a real smoke test, and keeps the previous version for rollback.
204
+
205
+ The default `memoryBackend="agent"` uses lexical recall and does not call an embedding service. To enable the vector library, choose `memoryBackend="api"`, then select `vectorSource="local"` for managed local embeddings or `vectorSource="api"` for a configured compatible embedding endpoint (which may itself run on localhost). Both sources feed MemU storage and retrieval; installing the MemU engine alone does not enable vectors.
206
+
207
+ `memoryMode` (`local` / `cloud`) is a MemU storage-compatibility setting, not the embedding switch or source selector; its cloud option is not a claim that managed local inference is offline cloud storage. Summary generation is configured independently of the vector route: ordinary private consolidation uses an Agent fork; an explicit remote-summary action uses its chat endpoint and commits through the same memory write path. Recall uses neither LLM reranking nor an LLM fallback. Exact memory ids still use the direct path; the plugin does not maintain a parallel vector database.
208
+
209
+ Managed model download, progress reporting and profile-switch/migration flows are implemented, but real model/runtime downloads and end-to-end native inference/switching have not been verified in this work. A candidate or `pending` artifact is not available for use; it must not be advertised as downloadable or ready until its artifact and validation gates pass.
210
+
211
+ ## First run
212
+
213
+ 1. Install, then restart DSH.
214
+ 2. Open **MemU WebUI** from the sidebar (or Settings → MemU).
215
+ 3. New conversations ask once whether this chat should use memory: private only, global only, both, or none. **Remember my choice** skips the question later. The card you pick **sets both switches at once**, so the sidebar shows the card you chose; the advanced "existing / new library" pick only changes which library the private layer reads, never the two switches.
216
+ 4. If you want a folder-wide ceiling, set it under **文件夹** — a folder can forbid private or global memory, and the chat switches will respect that ceiling.
217
+ 5. Talk. The agent writes private memories itself. The **MemU 记忆** wall is where you review, edit, archive, link and export them.
218
+
219
+ Folder policy is a **ceiling, not an initial value**: turning a folder switch off immediately clamps every conversation in it, and turning it back on restores each conversation's own choice. A folder with both switches off does not prompt, does not create a library and does not inject anything.
220
+
221
+ ## Model tools
222
+
223
+ | Tool | Purpose |
224
+ |---|---|
225
+ | `memu_private_remember` | Write a private memory, with source, layer, disclosure, visibility, tags, open loop and attachment references |
226
+ | `memu_private_recall` | Keyword snippets or exact-id body pages (`view`, `offset`, `limitChars`, `revision`, optional allowed `libraryId`); search `topK` is a hard 1–20 row limit, conflicts use pointers |
227
+ | `memu_private_list` | List the memories usable in the current scope |
228
+ | `memu_private_update` | Edit, without bypassing pin admission, review or visibility rules |
229
+ | `memu_private_archive` | Archive; never delete |
230
+ | `memu_private_unpin` | Marginalize a permanent memory with a first-person reason, quota and cooldown |
231
+ | `memu_private_link` | Link memories/entities with evidence, or update a relationship snapshot; also adjudicates uncertain `memu_private_link_suggest` candidates; cannot delete edges |
232
+ | `memu_private_link_suggest` | Refresh deterministic edges (confirmed-entity mentions and field evidence) for ids written this consolidation and return only uncertain candidate pairs |
233
+ | `memu_lexicon_search` | Search active lexicon terms this conversation can see: bound library + global lexicon (+ same-domain libraries when cross-library recall is on); archived and tombstoned terms stay hidden |
234
+ | `memu_lexicon_propose` | Add or update a lexicon term in the bound library (never the global lexicon); ordinary entries become active immediately, sensitive triggers remain user-only |
235
+ | `memu_global_recall` / `memu_global_list` | Read the global layer by domain; recall supports snippets or versioned exact-id body pages without broadening eligibility |
236
+ | `memu_status` | Storage health, sync heartbeat, recall state and image-turn status |
237
+
238
+ The main agent has **no global write tool**. Global memories are produced only by the separate curator.
239
+
240
+ ## Privacy, permissions & data
241
+
242
+ **What is stored.** Everything lives under `~/.dsh/dsh-memu-memory/` (or `$DSH_MEMU_MEMORY_HOME`; the legacy `$DSH_MEMU_HOME` and `~/.dsh/dsh-memu` are still honoured when no new `state.json` exists):
243
+
244
+ ```text
245
+ ~/.dsh/dsh-memu-memory/
246
+ ├─ state.json settings, folder policies, session bindings
247
+ ├─ index/<libraryId>.json private memory bodies (source of truth)
248
+ ├─ index/global.json global memories
249
+ ├─ index/*.stats.json per-day counters (90-day roll)
250
+ ├─ index/*.media.json attachment metadata and reference counts
251
+ ├─ index/*.entities.json entities and relationship snapshots
252
+ ├─ attachments/<libId>/<sha256>.<ext>
253
+ ├─ libraries/*.sqlite3 optional vector layer (acceleration, not truth)
254
+ ├─ engine/<version>/venv optional MemU engine
255
+ ├─ prompts/ user prompt overrides
256
+ ├─ backups/ explicit backups and pre-switch snapshots
257
+ └─ logs/ install log only
258
+ ```
259
+
260
+ - **Text and images are not encrypted at rest.** The directory is inside your home directory. If that is not acceptable, do not store secrets in memories and protect the disk with OS-level encryption.
261
+ - **Images are opt-in privacy data.** Only host-approved attachments are captured. `secret` entries never serve their attachments over the HTTP route; `never_say` captions are not echoed. The vision description service is enabled by default, but it only sends an image after you configure an endpoint, and it may cost money. It never uses host credentials automatically.
262
+ - **Network.** No telemetry. Outbound traffic happens only for (a) the optional engine installer downloading Python packages/uv from the configured mirrors, (b) the embedding endpoint you configure, (c) the optional remote summary model, and (d) the vision endpoint you configure (enabled by default; no call is made until an endpoint is configured). The default backend makes no external calls for memory operations.
263
+ - **Shell and filesystem.** The optional engine installer uses Python/pip in a private venv (and a pinned uv fallback inside the plugin directory). It does not modify system Python, install global packages or change `PATH`. All memory writes are confined to the data directory; config writes use temp-file + rename.
264
+ - **Deletion.** Archiving moves a memory out of retrieval; permanent deletion is a separate, guarded action for already-archived entries. Deleting a conversation only unbinds it; it never deletes the library. Library deletion asks for confirmation and is backed up first.
265
+
266
+ ## External messages in a long tool turn
267
+
268
+ A host turn may remain open while a third-party tool waits for messages.
269
+ New human input can trigger one bounded recall at the next model step without
270
+ ending that turn or making another model call. Native user messages work directly.
271
+ Unmarked tool logs, sleep completions, failed calls and empty polls do not trigger it.
272
+ The plugin does not depend on a particular waiting implementation.
273
+
274
+ Transport plugins can put this exact object in their own `ToolResult.meta.memoryInbound`:
275
+
276
+ ```js
277
+ const batch = {
278
+ type: 'dsh-memu-memory/inbound-batch',
279
+ version: 1,
280
+ producer: 'my-message-transport',
281
+ batchId: 'delivery-42',
282
+ messages: [{
283
+ id: 'remote-message-18',
284
+ role: 'user',
285
+ context: { channelId: 'room-1', speakerId: 'person-7' },
286
+ content: [{ type: 'text', text: 'Where is the deployment script we discussed?' }],
287
+ }],
288
+ }
289
+ // A normal ToolResult: keep the original model-facing content and other metadata.
290
+ return { content: originalContent, meta: { ...originalMeta, memoryInbound: batch } }
291
+ ```
292
+
293
+ The channel/character/world/branch must match the conversation's configured memory
294
+ scope; omit unavailable identities rather than guessing them. Images must use
295
+ `{ type: 'image', attachment: hostAdmittedRef }`, never filesystem paths, URLs or bytes.
296
+ If metadata is unavailable, return the complete protocol as JSON text and list
297
+ the exact tool name under **External message tool allowlist**. JSON embedded in logs
298
+ or code fences is not accepted, nor is JSON from an unapproved tool.
299
+
300
+ An in-process integration may instead import
301
+ `ingestInboundBatch` from `dsh-memu-memory/integration` and call
302
+ `ingestInboundBatch({ sessionId, batch, ctx, session })`. It registers work only:
303
+ the producer still delivers the actual incoming content to the model. It does not
304
+ wake the agent, append a fake user turn or write fact memories.
305
+
306
+ Deduplication uses producer + channel + speaker + message id; changing a delivery id
307
+ does not replay an already processed message. Memory cadence advances by human-message
308
+ batches even when the host turn number stays fixed. Pending input is capped at 32
309
+ messages / eight images / 96 KB, with at most 4000 characters per external text block;
310
+ overflow is explicitly refused, never silently discarded. Split oversized batches.
311
+ Recall failure preserves the queue with a 30-second retry delay; cancellation does not consume it.
312
+ Only the admitted batch is confirmed, so messages arriving during recall remain pending.
313
+ Running agents (including waiting tools) and pending batches are not sleep-consolidated;
314
+ the idle window starts from real message activity or the agent's return to idle.
315
+ `memu_status` reports `inbound` queue/clock/result and `inbound_error` when degraded.
316
+
317
+ ## Compatibility & limits
318
+
319
+ - **Host:** DSH `>=0.2.0-rc.1`, using public extension points only (tools, injection, session query, subagents, slots, a prefixed HTTP route). No host source modifications. The core surfaces (13 `memu_*` tools, guide injection, settings page, right-sidebar tab, prefixed RPC) were verified on `0.2.2-rc.1` on 2026-11-05; the check table lives in [`docs/host-adaptation.md`](docs/host-adaptation.md). The optional dated-wake feature uses the host-wide `ctx.schedule` task API introduced in `0.2.2`; on `0.2.0`–`0.2.1` (session-scoped reminders) it detects the older shape and skips with one warning instead of retrying every sweep.
320
+ - **Recall quality:** the default backend is lexical. Semantic recall depends on the optional engine and the embedding model you choose; the plugin cannot improve a model it does not own. LongMemEval, long-running group-chat A/B and "human-likeness" scores have **not** been run — test counts are not a quality score. A clear lexical topic match can outweigh rank-flattened competitors; recognised QQ/response-style scaffolding is excluded from that dominance evidence, but arbitrary templates and languages are not semantically understood.
321
+ - **No cloud sync, no accounts, no cross-device sync.** This is a local plugin with no server-side identity.
322
+ - **Images without vision:** without an optional caption/vision endpoint, an image memory is a pointer plus what a person wrote about it. The plugin does not claim to see pixels.
323
+ - **Poisoned v4 sessions:** historical `format v4 message requires a producer-owned source kind` rows can be diagnosed but not rewritten; the plugin never edits private session files.
324
+ - **Agent presets:** injection, guide delivery and the final tool list are separate integration checks. The plugin attaches injection listeners to the current agent context and supplies a conditional first-step `<memory-guide rules="…">` message. Tool availability depends on the preset declaration and host scope, so verify the actual request tool list in the target host. The plugin uses public extension points and does not edit preset files.
325
+ - **Reused session ids in IM channels, and domain switches:** `dsh-channel` and similar surfaces reuse a deterministic id (`qq-dm-<uid>`) across restarts, and the host can re-create a same-id session with an empty transcript. The plugin compares the host session identity (`session.createdAt`; when the host does not expose it, a turn number back at 1 plus the first message id) against the stamp kept on the binding, and on a new incarnation it clears the previous incarnation's `guideRulesKey` / `anchorPushed` so the rules and the anchor are delivered again (1.4.1+). Before this, such a conversation could run its whole life without a `<memory-guide>` message. **Switching the memory domain** re-delivers too: the rules message, the anchor, today's anniversaries, open loops and the time-of-day line are all domain-filtered, so a domain change resets them and they are delivered again for the new domain. Guide delivery is also decoupled from recall: a recall exception no longer swallows the rules message.
326
+ - **Lifecycle maintenance:** expired short-term drafts leave ordinary recall and are archived after their retention period; the body is retained. Open commitments and ended validity windows can enter independent maintenance review. Automatic closure requires explicit user-source evidence and revision checks; a passed deadline alone does not establish whether a promise was kept.
327
+ - **Coding consolidation detail:** the fork seed keeps every coding turn that touched a tool (up to 120 turns, default 60), 2,200 chars of a tool result and 1,000 chars of call arguments; the worker path's turn-log keeps 600-char tool lines and 400-char arguments (default 160/120), and the turn-log-off fallback compaction keeps 1,400/700 (default 400/300). RP/general keep their original caps, and the 500-event window, 12k per-message text and 4,000-char per-record limits still bound everything.
328
+ - **Consolidation worker (C 包, 2026-10-30).** An idle or manual pass now works from a *fixed snapshot*: it takes the public `sessionQuery.observeSession()` lease (falling back to `readSession()` when the host offers no lease), cuts at the last complete `turn/end`, and drops unpaired tool calls and half steps — a live transcript whose last turn is still open is **deferred**, never consolidated. A job is settled only by a structured completion receipt that is cross-checked against the library index (an id the library does not contain is not a success, and a rewrite of an existing id counts as an update, not a new memory). Checked / pending / in-flight ranges and a lease are persisted separately in `consolidation.json`, so a crash, a timeout or a failed turn leaves the range pending instead of looking consolidated. **Limits:** the worker still runs inside the parent preset's own system prompt — it receives an explicit "you are a background consolidation worker, not this character" brief, which reduces but does not remove persona carry-over, because the host has no public API to replace that prompt; and when the conversation's tool surface carries no `memu_private_remember` / `memu_private_update` (or exposes memory only through PTC), consolidation reports `unavailable` (`worker-tools-missing` / `worker-tools-ptc-only`) rather than forking a worker that could not write. The parent's library, scope, domain and memory context are re-checked before dispatch, on every worker tool call, and again before any result is credited.
329
+ - **Consolidation coverage is conservative lexical evidence.** A matching date or a couple of shared terms does not prove a candidate was written. The local check also requires text coverage, retained characters/words and values, and matching clause polarity; uncertain candidates stay in carry. It can retain a paraphrase that was already saved, and it does not claim semantic equivalence.
330
+ - **"Tomorrow" is resolved at write time.** A relative day (今天 / 明天 / 后天 / today / tomorrow) together with a month-day settles into one dated memory; a memory that only says "sometime next month" keeps no date rather than inventing one. A date that was already written as `MM-DD` is not rewritten — the fix applies to new writes.
331
+ - **Not in scope:** cloud MemU integration, source backfill for old entries, automatic repair of already-written v4 corruption.
332
+
333
+ ## Development & verification
334
+
335
+ ```sh
336
+ npm ci --legacy-peer-deps
337
+ npm test # full suite; the isolated real-engine case skips unless configured
338
+ npm run check # syntax + i18n key alignment + package.json
339
+ npm run build:graph # rebuild shipped offline assets after graph source changes
340
+ node scripts/acceptance-local.mjs # 50 automated acceptance checks
341
+ node scripts/migrate-visibility.mjs # report (add --apply to rewrite) libraries that still store the removed session level
342
+ node --import ./tests/loader-register.mjs scripts/preview.mjs --port 7789
343
+ node scripts/make-readme-shots.mjs # re-record the screenshots above against that preview
344
+ ```
345
+
346
+ The preview serves the real WebUI against isolated example data at `http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories`.
347
+
348
+ With the preview running, use `npm run test:graph-browser -- http://127.0.0.1:7789/dsh-memu-memory/ui#/settings/memories` in another terminal to check 200 nodes, desktop/narrow layouts, dragging, refresh stability, themes and load retries. Run `npx playwright install chromium` once, or set `GRAPH_BROWSER_CHANNEL=msedge` on Windows to use installed Edge. Stress data is intercepted only in the test browser and never written to memory. No CDN is needed at runtime; the bundle carries no third-party runtime code, which `lib/webui/graph-LICENSE.txt` records.
349
+
350
+ Run the automated acceptance checks with `node scripts/acceptance-local.mjs`. Optional engine integration tests require their documented environment settings; protocol checks do not establish model quality.
351
+
352
+ ## Documentation
353
+
354
+ - Release notes: [`CHANGELOG.md`](CHANGELOG.md)
355
+
356
+ [`AGENTS.md`](AGENTS.md) is the index for anyone changing this repo — which file answers
357
+ which question. The detail lives in [`docs/`](docs/): failure modes, the change process,
358
+ the host facts, and the UI, memory and environment rules.
359
+
360
+ ## License
361
+
362
+ [MIT](LICENSE) © dsh-memu-memory contributors.
363
+
364
+ You may use, modify, distribute and sell this software, provided the copyright notice and permission notice are included. The software is provided **as is**, without warranty of any kind.
365
+
366
+ ---
367
+
368
+ If this plugin is useful to you, open an issue with the host version and a minimal reproduction — memory bugs are easiest to fix when the transcript and the storage state are both available.