dsh-memu-memory 1.2.7 → 1.2.9

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 (106) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +472 -0
  3. package/README.md +10 -15
  4. package/README.zh.md +10 -15
  5. package/docs/memory-semantics.md +23 -3
  6. package/lib/backup.js +155 -26
  7. package/lib/binding-diagnostics.js +1 -2
  8. package/lib/budget.js +31 -9
  9. package/lib/client.js +221 -128
  10. package/lib/commitment.js +138 -0
  11. package/lib/consolidation-ledger.js +5 -2
  12. package/lib/consolidation-receipt.js +2 -0
  13. package/lib/consolidation-worker.js +3 -0
  14. package/lib/curator-policy.js +23 -0
  15. package/lib/cycle.js +8 -4
  16. package/lib/embedding-download.js +168 -28
  17. package/lib/embedding-runtime.js +76 -17
  18. package/lib/engine.js +0 -6
  19. package/lib/freshness.js +24 -0
  20. package/lib/graph.js +139 -11
  21. package/lib/index.js +71 -20
  22. package/lib/inject.js +167 -17
  23. package/lib/lexicon.js +62 -17
  24. package/lib/local-vector-service.js +25 -2
  25. package/lib/media.js +49 -12
  26. package/lib/memory.js +1202 -123
  27. package/lib/memu.js +4 -0
  28. package/lib/paths.js +0 -7
  29. package/lib/preset-scope.js +6 -1
  30. package/lib/private.js +50 -10
  31. package/lib/prompts/private-consolidation.mixed.md +2 -2
  32. package/lib/prompts/private-consolidation.rp.md +6 -1
  33. package/lib/prompts/private-policy.rp.md +4 -0
  34. package/lib/prompts/system-guide.rp.md +3 -0
  35. package/lib/prompts.js +0 -7
  36. package/lib/recall-cache.js +10 -2
  37. package/lib/rpc.js +104 -19
  38. package/lib/snippet.js +41 -0
  39. package/lib/state.js +109 -30
  40. package/lib/stats.js +2 -2
  41. package/lib/temporal.js +348 -0
  42. package/lib/text-retrieval.js +191 -44
  43. package/lib/text-similarity.js +205 -24
  44. package/lib/tokenizer-v2.js +0 -24
  45. package/lib/tools.js +81 -4
  46. package/lib/vector-migration.js +15 -0
  47. package/lib/vector-profile.js +81 -8
  48. package/lib/visibility.js +0 -4
  49. package/lib/webui/standalone.css +17 -22
  50. package/lib/webui/standalone.js +27 -9
  51. package/lib/webui.js +4 -4
  52. package/package.json +3 -2
  53. package/scripts/acceptance-local.mjs +2 -2
  54. package/scripts/bench-recall.mjs +2 -2
  55. package/scripts/check-all.mjs +3 -1
  56. package/scripts/check-i18n.mjs +35 -1
  57. package/scripts/check-seed-compat.mjs +1 -1
  58. package/scripts/migrate-visibility.mjs +3 -3
  59. package/scripts/prune-sessions.mjs +34 -0
  60. package/scripts/prune-vectors.mjs +24 -0
  61. package/tests/appendix-b.test.mjs +5 -4
  62. package/tests/audit-batch3.test.mjs +247 -0
  63. package/tests/audit-regression.test.mjs +2 -2
  64. package/tests/backup.test.mjs +85 -85
  65. package/tests/browser.test.mjs +6 -1
  66. package/tests/client-render.test.mjs +2 -2
  67. package/tests/commitment.test.mjs +144 -0
  68. package/tests/consolidation-fork.test.mjs +3 -3
  69. package/tests/curator-clusters.test.mjs +18 -0
  70. package/tests/curator-pairing.test.mjs +59 -16
  71. package/tests/disclosure.test.mjs +34 -17
  72. package/tests/dynamic-rrf.test.mjs +22 -19
  73. package/tests/dynamic-threshold.test.mjs +52 -0
  74. package/tests/fact-version.test.mjs +146 -0
  75. package/tests/fixtures/tokenizer-cases.mjs +27 -0
  76. package/tests/graph-cascade.test.mjs +29 -0
  77. package/tests/graph.test.mjs +45 -0
  78. package/tests/help-page.test.mjs +1 -1
  79. package/tests/inject-conflict.test.mjs +112 -0
  80. package/tests/inject-guide.test.mjs +5 -3
  81. package/tests/inject.test.mjs +2 -2
  82. package/tests/injection-intent-budget.test.mjs +92 -0
  83. package/tests/lexical-bm25.test.mjs +171 -0
  84. package/tests/lexicon-frequency.test.mjs +17 -1
  85. package/tests/lexicon-inject.test.mjs +21 -0
  86. package/tests/lexicon-perf.test.mjs +37 -9
  87. package/tests/lexicon-scope.test.mjs +2 -2
  88. package/tests/lexicon-ui.test.mjs +1 -1
  89. package/tests/managed-memory.test.mjs +19 -0
  90. package/tests/memory-chain.test.mjs +140 -0
  91. package/tests/memory-fields.test.mjs +134 -0
  92. package/tests/memu-resident.test.mjs +33 -0
  93. package/tests/ops-hardening.test.mjs +209 -0
  94. package/tests/package-shipping.test.mjs +4 -0
  95. package/tests/prompt-semantics.test.mjs +51 -0
  96. package/tests/query-decompose.test.mjs +62 -0
  97. package/tests/recall-cache.test.mjs +4 -2
  98. package/tests/recall-intent.test.mjs +123 -0
  99. package/tests/slot-similarity.test.mjs +153 -0
  100. package/tests/speaker-provenance.test.mjs +120 -0
  101. package/tests/state-gc.test.mjs +34 -0
  102. package/tests/state.test.mjs +2 -2
  103. package/tests/temporal.test.mjs +124 -0
  104. package/tests/tokenizer-v2.test.mjs +1 -1
  105. package/tests/vector-gc.test.mjs +37 -0
  106. package/tests/webui.test.mjs +27 -0
@@ -269,27 +269,3 @@ export function tokenizeStats(text) {
269
269
  byType: Object.fromEntries(byType),
270
270
  }
271
271
  }
272
-
273
- // —— 测试场景清单(tests/tokenizer-v2.test.mjs 引用)——
274
-
275
- /**
276
- * Test cases for different scenarios
277
- */
278
- export const TEST_CASES = [
279
- {
280
- input: '人工智能是一种技术',
281
- description: '纯中文短句',
282
- },
283
- {
284
- input: '2026-11-05 AI 技术在快速发展',
285
- description: '混合日期、英文缩写和中文',
286
- },
287
- {
288
- input: 'Qwen3-Embedding 在 2026 年发布',
289
- description: '混合产品名、年份和中文',
290
- },
291
- {
292
- input: 'user@example.com 访问 https://example.com',
293
- description: '邮箱和 URL',
294
- },
295
- ]
package/lib/tools.js CHANGED
@@ -275,15 +275,42 @@ export function registerTools(ctx, { only = null } = {}) {
275
275
  pin_reason: { type: 'string', description: 'Required for must_remember; first-person reason.' },
276
276
  pin_source: { type: 'string', description: 'user_explicit, side_event, or self.' },
277
277
  side_event_id: { type: 'string', description: 'Required when pin_source=side_event.' },
278
+ fact_key: { type: 'string', description: 'Optional stable key for the fact, such as "user:floor_color". Passing it declares that an existing active memory with the same key is another version of this fact; the new entry then becomes a conflict pair unless you pass supersedes.' },
279
+ conflicts_with: { type: 'string', description: 'Id of an existing memory that says something different about the same fact. Both versions stay active and are recalled together with a conflict card; use this instead of overwriting or deleting the old claim.' },
280
+ supersedes: { type: 'string', description: 'Id of an existing memory this new statement explicitly replaces. The old row keeps its text but is retired (superseded + valid_to). Use only when the newer statement really is the corrected truth.' },
278
281
  tags: { type: 'array', items: { type: 'string' }, description: 'Optional tags.' },
279
- open_loop: { type: 'boolean', description: 'Mark an unfinished promise/task/unsaid thing.' },
282
+ open_loop: { type: 'boolean', description: 'Mark an unfinished promise/task/unsaid thing. Prefer the commitment object; this boolean remains for compatibility and is kept in sync with commitment.status.' },
283
+ commitment: {
284
+ type: 'object',
285
+ properties: {
286
+ counterparty: { type: 'string' },
287
+ action: { type: 'string' },
288
+ due_at: { type: 'string' },
289
+ status: { type: 'string' },
290
+ closed_by: { type: 'string' },
291
+ evidence_seq: { type: 'integer' },
292
+ },
293
+ additionalProperties: false,
294
+ description: 'A promise or arrangement: counterparty (who it is with), action (what was promised), due_at (YYYY-MM-DD or ISO), status (open/done/cancelled/expired), closed_by / evidence_seq (proof of fulfilment). Use status=open only while it is still owed; update it when it is done or cancelled.',
295
+ },
280
296
  disclosure: { type: 'string', description: 'can_tell, only_if_asked, or never_say.' },
281
297
  owner: { type: 'string', description: 'me, us, about_user, or about_project.' },
282
298
  visibility: { type: 'string', description: 'shared (default: the whole folder) or secret (kept out of the prompt and out of automatic recall; still readable by an explicit recall from the same folder). Scope a memory to one channel / character / world / branch with the context field instead of trying to hide it.' },
283
299
  source: {
284
300
  type: 'string',
285
- description: 'Where this came from: inferred (default — you concluded it), user_said (only when the words are actually theirs and quotable), imagined, or told.',
301
+ description: 'Where this came from: inferred (default — you concluded it), user_said (only when the words are actually theirs and quotable), assistant_said (your own promise, plan or claim), imagined, told, or tool (read from a tool result).',
286
302
  },
303
+ source_kind: { type: 'string', description: 'Provenance detail: user_said, assistant_said, told, imagined, inferred, or tool. Defaults to source. Assistant promises and plans belong here; never file them as user_said.' },
304
+ speaker_id: { type: 'string', description: 'Stable identity of who said it: user, assistant, character:<id>, or group:<id>. Never infer from a display name. Defaults to the conversation speaker or user/assistant by source_kind.' },
305
+ quote_span: {
306
+ type: 'object',
307
+ properties: { seq: { type: 'integer' }, turn: { type: 'integer' }, textHash: { type: 'string' } },
308
+ additionalProperties: false,
309
+ description: 'Optional pointer back to the source turn: seq/turn numbers plus a short text hash. Do not paste the whole quote here.',
310
+ },
311
+ storyline_id: { type: 'string', description: 'Optional storyline / plot thread id when several stories share one library.' },
312
+ branch_id: { type: 'string', description: 'Optional branch id; defaults to the conversation branch.' },
313
+ known_by: { type: 'array', items: { type: 'string' }, description: 'Character identities that know this fact. Omit to inherit the conversation boundary.' },
287
314
  confidence: { type: 'number', description: '0-1 confidence in this memory. Below 0.45 it is injected as a hedge, so use it honestly.' },
288
315
  mood_valence: { type: 'number', description: '派生值:给了 emotion 时由四项算出,-1(坏)到 1(好)。省略则沿用当前会话读数。' },
289
316
  arousal: { type: 'number', description: 'How strongly it hit, 0-1.' },
@@ -298,6 +325,11 @@ export function registerTools(ctx, { only = null } = {}) {
298
325
  peak: { type: 'boolean', description: 'A high point or low point of the arc — peaks and endings stay easier to recall.' },
299
326
  allow_duplicate: { type: 'boolean', description: 'Only for two genuinely independent observations of the same fact (e.g. the same event recorded twice in one day). The default false refuses a near-identical rewrite and returns the existing memory id; passing true states you looked at that existing memory and still want a separate entry.' },
300
327
  salient_date: { type: 'string', description: 'MM-DD for something that comes back every year (a birthday, an anniversary of an event); it resurfaces on that day each year. YYYY-MM-DD for a one-off dated commitment or appointment: it is raised the day before and on the day itself, and never again after it has passed. Use the annual form only when the day really does recur. A relative day (今天/明天/后天/today/tomorrow) must be resolved to the absolute date it points at: sending a bare MM-DD turns one appointment into a yearly reminder. If the content itself names a date, pass it here too: when this field is empty the plugin only falls back to a single unambiguous YYYY-MM-DD found in the text.' },
328
+ observed_at: { type: 'string', description: 'ISO date/time when this statement was made (the scene time). Omit to use the conversation sceneTime. Relative dates are resolved against this instant, never against the wall clock.' },
329
+ absolute_date: { type: 'string', description: 'YYYY-MM-DD this memory is about, when you already know it. The plugin also resolves 今天/明天/下周X/月底 itself against observed_at; pass this only to override or when the wording has no parseable date.' },
330
+ valid_from: { type: 'string', description: 'Optional YYYY-MM-DD from which the fact is true. Omit for facts with no known start.' },
331
+ valid_to: { type: 'string', description: 'Optional YYYY-MM-DD after which the fact is no longer true. Omit for open-ended facts; the entry is hidden from recall after this day.' },
332
+ date_precision: { type: 'string', description: 'day (default for a concrete date), month (月底/下个月), year (年初/年底), or unknown (relative wording that could not be resolved).' },
301
333
  track: { type: 'string', description: 'memory (default) or habit for an aggregated expression/sticker habit; do not write one habit per occurrence.' },
302
334
  attachments: { type: 'array', items: { type: 'object', properties: { sha256: { type: 'string', required: true } }, additionalProperties: true }, description: 'At most 8 sha256 references received in this conversation. Never supply paths or bytes. Ordinary image memories default to short_term if layer is omitted; choose long_term explicitly only when important.' },
303
335
  context: { type: 'object', properties: {
@@ -319,10 +351,20 @@ export function registerTools(ctx, { only = null } = {}) {
319
351
  sideEventId: args.side_event_id,
320
352
  tags: args.tags,
321
353
  openLoop: args.open_loop,
354
+ commitment: args.commitment,
355
+ factKey: args.fact_key ?? null,
356
+ conflictsWith: args.conflicts_with ?? null,
357
+ supersedes: args.supersedes ?? null,
322
358
  disclosure: args.disclosure,
323
359
  owner: args.owner,
324
360
  visibility: args.visibility,
325
361
  source: args.source,
362
+ sourceKind: args.source_kind,
363
+ speakerId: args.speaker_id ?? null,
364
+ quoteSpan: args.quote_span ?? null,
365
+ storylineId: args.storyline_id,
366
+ branchId: args.branch_id,
367
+ knownBy: args.known_by,
326
368
  confidence: args.confidence,
327
369
  moodValence: args.mood_valence ?? null,
328
370
  arousal: args.arousal ?? null,
@@ -333,6 +375,11 @@ export function registerTools(ctx, { only = null } = {}) {
333
375
  dominance: args.dominance ?? null,
334
376
  peak: args.peak === true,
335
377
  salientDate: args.salient_date ?? null,
378
+ observedAt: args.observed_at ?? null,
379
+ absoluteDate: args.absolute_date ?? null,
380
+ validFrom: args.valid_from,
381
+ validTo: args.valid_to,
382
+ datePrecision: args.date_precision,
336
383
  allowDuplicate: args.allow_duplicate === true,
337
384
  })
338
385
  // 事实级去重:几乎相同的重写被拒,返回的是
@@ -424,6 +471,19 @@ export function registerTools(ctx, { only = null } = {}) {
424
471
  status: { type: 'string', description: 'active, archived, fragment, suppressed, or expired.' },
425
472
  layer: { type: 'string', description: 'long_term to promote a short_term draft once it has proven worth keeping, or short_term to re-arm the deadline. must_remember needs a pin_reason and is only writable through memu_private_remember.' },
426
473
  open_loop: { type: 'boolean' },
474
+ commitment: {
475
+ type: 'object',
476
+ properties: {
477
+ counterparty: { type: 'string' },
478
+ action: { type: 'string' },
479
+ due_at: { type: 'string' },
480
+ status: { type: 'string' },
481
+ closed_by: { type: 'string' },
482
+ evidence_seq: { type: 'integer' },
483
+ },
484
+ additionalProperties: false,
485
+ description: 'Replace the commitment object. Set status=done/cancelled/expired to close it; open_loop follows status.',
486
+ },
427
487
  disclosure: { type: 'string', description: 'can_tell, only_if_asked, or never_say. Changing this changes how the memory is phrased when it is injected.' },
428
488
  owner: { type: 'string', description: 'me, us, about_user, or about_project.' },
429
489
  visibility: { type: 'string', description: 'shared or secret. secret keeps it out of the prompt and out of automatic recall; an explicit recall from the same folder can still read it.' },
@@ -431,7 +491,13 @@ export function registerTools(ctx, { only = null } = {}) {
431
491
  // Provenance and track are claims about what a memory *is*; both were writable
432
492
  // in memory.js and the panel while staying unreachable from the tool surface,
433
493
  // so the agent could file a quote as an inference and never correct it.
434
- source: { type: 'string', description: 'user_said, inferred, imagined, or told. Only user_said may be repeated as the user\'s own words, so correct this rather than living with a wrong provenance.' },
494
+ source: { type: 'string', description: 'user_said, assistant_said, told, imagined, inferred, or tool. Only user_said may be repeated as the user\'s own words, so correct this rather than living with a wrong provenance.' },
495
+ source_kind: { type: 'string', description: 'Same values as source; correcting the provenance must keep this in sync.' },
496
+ speaker_id: { type: 'string', description: 'Who said it: user, assistant, character:<id>, or group:<id>. Empty string clears it.' },
497
+ quote_span: { type: 'object', properties: { seq: { type: 'integer' }, turn: { type: 'integer' }, textHash: { type: 'string' } }, additionalProperties: false, description: 'Pointer back to the source turn; omit to keep, null to clear.' },
498
+ storyline_id: { type: 'string', description: 'Storyline / plot thread id; empty string clears it.' },
499
+ branch_id: { type: 'string', description: 'Branch id; empty string clears it.' },
500
+ known_by: { type: 'array', items: { type: 'string' }, description: 'Character identities that know this fact; empty array clears it.' },
435
501
  track: { type: 'string', description: 'memory or habit. habit folds repeat attachments of the same fact into one entry; a wrong track changes that aggregation and can now be corrected.' },
436
502
  peak: { type: 'boolean', description: 'Flashbulb flag: the moment was charged. Changing it recomputes accuracy.' },
437
503
  mood_valence: { type: 'number', description: 'How the moment felt, -1..1. Used as a retrieval lens; omitted keeps the stored value.' },
@@ -444,18 +510,29 @@ export function registerTools(ctx, { only = null } = {}) {
444
510
  },
445
511
  dominance: { type: 'number', description: '谁在掌控:-1 完全失控 … +1 完全掌控。省略=保留原值。' },
446
512
  salient_date: { type: 'string', description: 'Re-date the memory: MM-DD for an annual anniversary, YYYY-MM-DD for a one-off dated commitment, or an empty string to remove the date. Use this to repair a date that was stored without its year.' },
513
+ observed_at: { type: 'string', description: 'ISO scene time for this edit; relative dates in the new text resolve against it. Omit to use the conversation sceneTime.' },
514
+ absolute_date: { type: 'string', description: 'YYYY-MM-DD this memory is about. Omit to re-derive from the new title/content; pass an empty string to clear it.' },
515
+ valid_from: { type: 'string', description: 'YYYY-MM-DD the fact starts being true; empty string clears it.' },
516
+ valid_to: { type: 'string', description: 'YYYY-MM-DD the fact stops being true; empty string clears it.' },
447
517
  },
448
518
  async (args, exec) => {
449
519
  const result = await privateUpdate({
450
520
  exec, id: args.id, content: args.content, title: args.title, tags: args.tags,
451
- status: args.status, openLoop: args.open_loop, disclosure: args.disclosure, confidence: args.confidence,
521
+ status: args.status, openLoop: args.open_loop, commitment: args.commitment, disclosure: args.disclosure, confidence: args.confidence,
452
522
  layer: args.layer, owner: args.owner, visibility: args.visibility,
453
523
  source: args.source, track: args.track, peak: args.peak,
524
+ sourceKind: args.source_kind, speakerId: args.speaker_id,
525
+ quoteSpan: args.quote_span, storylineId: args.storyline_id,
526
+ branchId: args.branch_id, knownBy: args.known_by,
454
527
  moodValence: args.mood_valence, arousal: args.arousal,
455
528
  // undefined 就是"省略",必须原样传下去;换成 null 会把保留变成清除。
456
529
  emotion: args.emotion, dominance: args.dominance,
457
530
  // Sentinel: absent means "leave the date as it is", '' means "clear it".
458
531
  salientDate: args.salient_date,
532
+ observedAt: args.observed_at,
533
+ absoluteDate: args.absolute_date,
534
+ validFrom: args.valid_from,
535
+ validTo: args.valid_to,
459
536
  })
460
537
  return `已更新 ${result.id}: ${result.entry.title} (${result.entry.layer}, ${result.entry.status})`
461
538
  },
@@ -172,6 +172,11 @@ export function createVectorMigrator(options = {}) {
172
172
  listFiles: configured.listFiles ?? configured.list,
173
173
  retrieve: typeof configured.retrieve === 'function' ? configured.retrieve : null,
174
174
  smoke: typeof configured.smoke === 'function' ? configured.smoke : null,
175
+ // Optional: drop the index-side `vectorPending` marker for ids that this rebuild
176
+ // has just proven present in the shadow. Without it the marker was write-only —
177
+ // nothing ever cleared it after a successful migration, so a fully migrated
178
+ // library kept advertising itself as "not in the vector store yet".
179
+ clearVectorPending: typeof configured.clearVectorPending === 'function' ? configured.clearVectorPending : null,
175
180
  }
176
181
  for (const name of REQUIRED_DEPS) {
177
182
  if (typeof impl[name] !== 'function') throw new TypeError('createVectorMigrator requires a ' + name + '(… ) dependency')
@@ -527,6 +532,16 @@ export function createVectorMigrator(options = {}) {
527
532
  const verifiedPresent = await presentIds(scope, profile, generation)
528
533
  if (verifiedPresent.size !== known.size || [...known].some(id => !verifiedPresent.has(id))) {
529
534
  report.failed.push({ libraryId: scope.key, code: 'VECTOR_COVERAGE_FAILED', message: 'shadow membership differs from eligible index snapshot' })
535
+ } else if (impl.clearVectorPending) {
536
+ // Coverage passed: every admitted entry is provably in this generation's
537
+ // shadow, so "write me into the vector store later" is finished for all of
538
+ // them. Fail-open — a stale flag costs a little wasted work next rebuild, it
539
+ // must never turn a successful migration into a failed one.
540
+ try {
541
+ impl.clearVectorPending({ libraryId: scope.libraryId, ids: [...known], generation })
542
+ } catch (error) {
543
+ log('clear vectorPending failed for ' + scope.key + ': ' + (error?.message || error))
544
+ }
530
545
  }
531
546
  bucket.snapshot = { digest: before.scopes[index].digest, items: items.length, at: before.at }
532
547
  report.libraries[scope.key] = { items: items.length, present: present.size, digest: before.scopes[index].digest }
@@ -130,13 +130,6 @@ export function manifestDigestAccepted(stored, manifest) {
130
130
  /** 直接复用 embedding-catalog 的指纹协议(任何改变向量空间的字段都进指纹,§14.8)。 */
131
131
  export { profileFingerprint }
132
132
 
133
- export function profileShortFingerprint(profileOrEntry) {
134
- const fingerprint = typeof profileOrEntry === 'string'
135
- ? profileOrEntry
136
- : (profileOrEntry?.fingerprint || profileFingerprint(profileOrEntry))
137
- return String(fingerprint).slice(0, 8)
138
- }
139
-
140
133
  // ---------------------------------------------------------------- catalog 注入点
141
134
 
142
135
  // 默认只认 embedding-catalog.js 的目录。测试(以及将来多目录场景)可以换一个解析器:
@@ -989,4 +982,84 @@ export const activeVectorState = vectorState
989
982
  export const memuDbFor = dbPathFor
990
983
  export const memuGlobalDbFor = () => dbPathFor(null)
991
984
  export const captureVectorGeneration = captureGeneration
992
- export const assertVectorGeneration = assertGeneration
985
+ export const assertVectorGeneration = assertGeneration
986
+ // ---------------------------------------------------------------- P2-5 vector GC
987
+ //
988
+ // Generation files are safe to collect only when they are (a) not referenced by
989
+ // the active/pending manifest, (b) older than the active generation by the
990
+ // configured keep count, and (c) older than a retention window. The pure
991
+ // candidate filter is exported so the script and tests share exactly one rule.
992
+ const VECTOR_GC_DAY_MS = 86_400_000
993
+
994
+ export function vectorGcCandidates({
995
+ files = [], activeGeneration = 0, keepGenerations = 2, olderThanDays = 7,
996
+ now = Date.now(), keepPaths = [],
997
+ } = {}) {
998
+ const keepGenerationsCount = Math.max(1, Number(keepGenerations) || 2)
999
+ const minKeep = Math.max(0, (Number(activeGeneration) || 0) - (keepGenerationsCount - 1))
1000
+ const cutoff = Number(now) - Math.max(0, Number(olderThanDays) || 0) * VECTOR_GC_DAY_MS
1001
+ const keep = new Set((keepPaths || []).map((file) => path.resolve(String(file))))
1002
+ return (files || []).filter((item) => {
1003
+ const generation = Number(item?.generation)
1004
+ if (!Number.isSafeInteger(generation) || generation < 1) return false
1005
+ if (generation >= minKeep) return false
1006
+ if (keep.has(path.resolve(String(item.file)))) return false
1007
+ return Number(item.mtimeMs) < cutoff
1008
+ })
1009
+ }
1010
+
1011
+ export function listVectorArtifacts() {
1012
+ const state = readVectorState({ tolerateMissing: true }).state
1013
+ const keepPaths = []
1014
+ const collect = (manifest) => {
1015
+ if (!manifest?.databases) return
1016
+ const global = manifest.databases.global
1017
+ if (global?.path) keepPaths.push(resolveVectorPath(global.path))
1018
+ for (const entry of Object.values(manifest.databases.libraries || {})) {
1019
+ if (entry?.path) keepPaths.push(resolveVectorPath(entry.path))
1020
+ }
1021
+ }
1022
+ collect(state?.active)
1023
+ collect(state?.pending?.databases ? { databases: state.pending.databases } : null)
1024
+ const files = []
1025
+ for (const dir of [librariesDir(), indexDir()]) {
1026
+ let names = []
1027
+ try { names = fs.readdirSync(dir) } catch { continue }
1028
+ for (const name of names) {
1029
+ const match = /\.g(\d+)\.(?:sqlite3|json)$/.exec(name)
1030
+ if (!match) continue
1031
+ if (!name.endsWith('.sqlite3') && !name.startsWith('vector-ledger.')) continue
1032
+ const file = path.join(dir, name)
1033
+ let info
1034
+ try { info = fs.statSync(file) } catch { continue }
1035
+ files.push({ file, generation: Number(match[1]), bytes: info.size, mtimeMs: info.mtimeMs })
1036
+ }
1037
+ }
1038
+ return { activeGeneration: state?.active?.generation ?? 0, keepPaths, files }
1039
+ }
1040
+
1041
+ export function pruneVectorArtifacts({ apply = false, keepGenerations = 2, olderThanDays = 7, now = Date.now() } = {}) {
1042
+ const info = listVectorArtifacts()
1043
+ const candidates = vectorGcCandidates({
1044
+ files: info.files,
1045
+ activeGeneration: info.activeGeneration,
1046
+ keepGenerations,
1047
+ olderThanDays,
1048
+ now,
1049
+ keepPaths: info.keepPaths,
1050
+ })
1051
+ const removed = []
1052
+ if (apply) {
1053
+ for (const item of candidates) {
1054
+ try { fs.unlinkSync(item.file); removed.push(item.file) } catch {}
1055
+ }
1056
+ }
1057
+ return {
1058
+ dryRun: apply !== true,
1059
+ activeGeneration: info.activeGeneration,
1060
+ keepGenerations,
1061
+ olderThanDays,
1062
+ candidates: candidates.map((item) => ({ file: item.file, generation: item.generation, bytes: item.bytes })),
1063
+ removed,
1064
+ }
1065
+ }
package/lib/visibility.js CHANGED
@@ -16,10 +16,6 @@
16
16
  export const STORED_VISIBILITIES = ['shared', 'secret']
17
17
  export const LEGACY_SESSION = 'session'
18
18
 
19
- export function normalizeVisibility(value) {
20
- return value === LEGACY_SESSION ? 'shared' : value
21
- }
22
-
23
19
  export function isLegacySession(entry) {
24
20
  return entry?.visibility === LEGACY_SESSION
25
21
  }
@@ -455,9 +455,6 @@ body[data-scrolled="true"] .topbar {
455
455
  #root {
456
456
  min-height: 50vh;
457
457
  }
458
- .boot-failed #root::before {
459
- content: "";
460
- }
461
458
 
462
459
  /* ── footer ────────────────────────────────────────────────────────────── */
463
460
  .foot {
@@ -619,11 +616,9 @@ html[data-standalone] .dshm-root {
619
616
  padding: 0;
620
617
  min-height: 0;
621
618
  animation: none;
622
- /* The component uses container queries inside the host pane. On a full page
623
- `contain: layout` would also make it the containing block for the detail
624
- drawer's fixed overlay, pinning it under the topbar; the media queries above
625
- already cover the narrow layout. */
626
- container-type: normal;
619
+ /* Keep the query container alive in the standalone shell too, so UI_CSS's
620
+ @container rules drive the narrow layout in both shells (see UI_CSS). */
621
+ container-type: inline-size;
627
622
  --dshm-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
628
623
  }
629
624
  html[data-standalone] .dshm-shell {
@@ -651,7 +646,7 @@ html[data-standalone] .dshm-nav {
651
646
  z-index: 20;
652
647
  }
653
648
  html[data-standalone] .dshm-nav::before {
654
- content: "MEMORY STUDIO";
649
+ content: var(--dshm-studio-label, "MEMORY STUDIO");
655
650
  display: block;
656
651
  padding: 4px 12px 10px;
657
652
  font-size: 9px;
@@ -922,8 +917,8 @@ html[data-standalone] .dshm-error {
922
917
  margin: 2px 0;
923
918
  padding: 8px 12px;
924
919
  border-radius: 11px;
925
- border: 1px solid color-mix(in srgb, var(--dshm-error, #b43e45) 30%, transparent);
926
- background: color-mix(in srgb, var(--dshm-error, #b43e45) 10%, transparent);
920
+ border: 1px solid color-mix(in srgb, var(--dsw-alias-state-error-primary, #b43e45) 30%, transparent);
921
+ background: color-mix(in srgb, var(--dsw-alias-state-error-primary, #b43e45) 10%, transparent);
927
922
  font-size: 12.5px;
928
923
  }
929
924
 
@@ -960,15 +955,19 @@ html[data-standalone] .dshm-wall-grid {
960
955
  }
961
956
  html[data-standalone] .dshm-wall-item {
962
957
  min-height: 236px;
958
+ /* Skip layout/paint for rows outside the viewport: a fullscreen wall can hold
959
+ 300 cards, and rendering all of them is what starves the WebView2 compositor. */
960
+ content-visibility: auto;
961
+ contain-intrinsic-size: auto 236px;
963
962
  padding: 18px;
964
963
  border-radius: 18px;
965
964
  border: 1px solid var(--dshm-line);
965
+ /* No backdrop-filter here. A fullscreen wall puts dozens of blurred cards on
966
+ screen at once; the pointer spotlight repaints their backdrop every frame
967
+ and WebView2 starts dropping compositor tiles (cards flash, then vanish).
968
+ The gradients below already carry the depth. */
966
969
  background:
967
- linear-gradient(180deg,
968
- color-mix(in srgb, var(--dshm-panel-strong) 92%, transparent),
969
- color-mix(in srgb, var(--dshm-panel) 82%, transparent));
970
- -webkit-backdrop-filter: blur(14px);
971
- backdrop-filter: blur(14px);
970
+ linear-gradient(180deg, var(--dshm-panel-strong), var(--dshm-panel));
972
971
  box-shadow: 0 18px 36px -32px rgba(10, 28, 23, .5);
973
972
  transition: transform .28s cubic-bezier(.22, 1, .36, 1), box-shadow .28s ease,
974
973
  border-color .28s ease;
@@ -998,9 +997,7 @@ html[data-standalone] .dshm-wall-cover-count {
998
997
  bottom: 10px;
999
998
  font-size: 10.5px;
1000
999
  letter-spacing: .01em;
1001
- background: rgba(10, 16, 32, .62);
1002
- -webkit-backdrop-filter: blur(6px);
1003
- backdrop-filter: blur(6px);
1000
+ background: rgba(10, 16, 32, .72);
1004
1001
  }
1005
1002
  html[data-standalone] .dshm-wall-meta {
1006
1003
  font-size: 11px;
@@ -1036,7 +1033,6 @@ html[data-standalone] .dshm-drawer {
1036
1033
  border-left-color: var(--dshm-line);
1037
1034
  box-shadow: -30px 0 80px -40px rgba(0, 0, 0, .55);
1038
1035
  }
1039
- html[data-standalone] .dshm-drawer .dshm-input,
1040
1036
  html[data-standalone] .dshm-drawer input,
1041
1037
  html[data-standalone] .dshm-drawer textarea,
1042
1038
  html[data-standalone] .dshm-drawer select {
@@ -1104,7 +1100,6 @@ html[data-standalone] .dshm-wall-graph {
1104
1100
 
1105
1101
  /* ── responsive ────────────────────────────────────────────────────────── */
1106
1102
  @media (max-width: 760px) {
1107
- html[data-standalone] .dshm-shell { grid-template-columns: minmax(0, 1fr); gap: 16px; }
1108
1103
  html[data-standalone] .dshm-nav { position: static; }
1109
1104
  html[data-standalone] .dshm-nav-list { flex-direction: row; flex-wrap: wrap; }
1110
1105
  html[data-standalone] .dshm-nav-ind { display: none; }
@@ -1112,7 +1107,7 @@ html[data-standalone] .dshm-wall-graph {
1112
1107
  }
1113
1108
  @media (max-width: 1120px) {
1114
1109
  :root { --dshm-rail: 186px; --dshm-gap: 24px; }
1115
- .stage { padding: 22px 22px 48px; }
1110
+ .stage { padding: 22px 22px 48px calc(var(--dshm-rail) + 38px); }
1116
1111
  }
1117
1112
  @media (max-width: 900px) {
1118
1113
  .topbar { top: 8px; width: calc(100% - 16px); margin-top: 8px; padding: 10px 12px; }
@@ -10,6 +10,7 @@
10
10
  backToDsh: '返回 DSH', close: '关闭', back: '返回',
11
11
  footer: '与 DSH 共用同一份记忆 · 本地优先', opening: '正在打开记忆工作室…',
12
12
  bootFailed: '打不开记忆工作台', reload: '重新加载', unknown: '未知错误',
13
+ studioLabel: '记忆工作室',
13
14
  },
14
15
  en: {
15
16
  skip: 'Skip to content', brand: 'MemU Memory', memories: 'Memories', sync: 'Local memory',
@@ -17,18 +18,22 @@
17
18
  backToDsh: 'Back to DSH', close: 'Close', back: 'Back',
18
19
  footer: 'Shares the same memory as DSH · local-first', opening: 'Opening the memory studio…',
19
20
  bootFailed: 'The memory studio failed to open', reload: 'Reload', unknown: 'Unknown error',
21
+ studioLabel: 'MEMORY STUDIO',
20
22
  },
21
23
  }
24
+ // 页序只留这一份 slug 清单;PAGE_NAMES 的键由 check-i18n.mjs 与
25
+ // client.js 的 SETTINGS_PAGES 对齐校验,避免第三份清单漂移。
26
+ var SETTINGS_PAGES = ['engine', 'connection', 'settings', 'folders', 'libraries', 'browser', 'global', 'prompts', 'stats', 'memories', 'logs', 'lexicon', 'help']
22
27
  var PAGE_NAMES = {
23
28
  zh: {
24
- engine: '引擎与连接', settings: '记忆设置', folders: '文件夹', libraries: '记忆库',
29
+ engine: '引擎与连接', connection: '连接与向量', settings: '记忆设置', folders: '文件夹', libraries: '记忆库',
25
30
  browser: '记忆浏览', global: '全局记忆', prompts: '提示词', stats: '统计', memories: '记忆总览',
26
- lexicon: '词典', help: '帮助',
31
+ logs: '日志', lexicon: '词典', help: '帮助',
27
32
  },
28
33
  en: {
29
- engine: 'Engine & connection', settings: 'Memory settings', folders: 'Folders', libraries: 'Libraries',
34
+ engine: 'Engine & connection', connection: 'Connection & vectors', settings: 'Memory settings', folders: 'Folders', libraries: 'Libraries',
30
35
  browser: 'Memory browser', global: 'Global memory', prompts: 'Prompts', stats: 'Stats', memories: 'Memories',
31
- lexicon: 'Lexicon', help: 'Help',
36
+ logs: 'Logs', lexicon: 'Lexicon', help: 'Help',
32
37
  },
33
38
  }
34
39
  var copy = COPY[locale]
@@ -51,6 +56,8 @@
51
56
  }
52
57
  }
53
58
  applyCopy()
59
+ // 导航装饰文字改走 CSS 变量,随语言切换(见 standalone.css 的 --dshm-studio-label)。
60
+ try { document.documentElement.style.setProperty('--dshm-studio-label', JSON.stringify(copy.studioLabel || '')) } catch (e) {}
54
61
  var root = document.getElementById('root')
55
62
  var boot = document.getElementById('boot')
56
63
  var pageLabel = document.getElementById('pageLabel')
@@ -98,7 +105,7 @@
98
105
  /* ── chrome: page label, title, footer, return control ─────────────────── */
99
106
  function currentSlug() {
100
107
  var match = /^#\/settings\/([a-z]+)/.exec(String(window.location.hash || ''))
101
- return match && PAGE_NAMES[locale][match[1]] ? match[1] : 'memories'
108
+ return match && SETTINGS_PAGES.indexOf(match[1]) >= 0 ? match[1] : 'memories'
102
109
  }
103
110
  function paintLocation() {
104
111
  var slug = currentSlug()
@@ -137,20 +144,31 @@
137
144
  }
138
145
  if (window.opener && !window.opener.closed) {
139
146
  try { window.opener.focus() } catch (e) {}
140
- try { window.close(); return } catch (e) {}
141
147
  }
142
- if (window.history.length > 1) window.history.back()
148
+ // window.close() 对不允许关闭的窗口静默失败且不抛异常,用 window.closed 判定兜底。
149
+ window.close()
150
+ if (!window.closed) window.history.back()
143
151
  })
144
152
 
145
153
  /* ── ambience: pointer spotlight and a shadow once the page scrolls ────── */
146
- if (!reduceMotion && window.matchMedia('(pointer: fine)').matches) {
154
+ // The overlay host embeds this page in an iframe over the whole DSH app.
155
+ // Repainting a full-viewport gradient on every pointer frame forces the host's
156
+ // compositor to keep re-combining that surface, and a maximized window is where
157
+ // WebView2 starts dropping wall tiles. Keep the spotlight for the standalone
158
+ // tab only; the overlay keeps the static ambient layers.
159
+ if (!framed && !reduceMotion && window.matchMedia('(pointer: fine)').matches) {
147
160
  document.body.dataset.pointer = 'fine'
161
+ var spot = document.querySelector('.ambient-spot')
148
162
  var pending = 0
149
163
  window.addEventListener('pointermove', function (event) {
150
164
  if (pending) return
151
165
  pending = window.requestAnimationFrame(function () {
152
166
  pending = 0
153
- var style = document.documentElement.style
167
+ // Scope the variables to the one element that paints the gradient.
168
+ // Writing them on <html> invalidated style for the whole document on
169
+ // every pointer frame — with a long wall of backdrop-filter cards that
170
+ // is enough for WebView2 to drop or flicker compositor frames.
171
+ var style = (spot || document.documentElement).style
154
172
  style.setProperty('--spot-x', event.clientX + 'px')
155
173
  style.setProperty('--spot-y', event.clientY + 'px')
156
174
  })
package/lib/webui.js CHANGED
@@ -26,7 +26,7 @@ export function standaloneAsset(pathname) {
26
26
  }
27
27
 
28
28
  /** The studio stylesheet lives next to this file so it can be read and edited as CSS. */
29
- export function standaloneCss() {
29
+ function standaloneCss() {
30
30
  return fs.readFileSync(path.join(DIR, 'standalone.css'), 'utf8')
31
31
  }
32
32
 
@@ -43,10 +43,10 @@ export function standaloneHtml() {
43
43
  <title>MemU 记忆</title>
44
44
  <meta name="theme-color" content="#f4f5f9">
45
45
  <link rel="icon" href="/dsh-memu-memory/ui-assets/mark.svg" type="image/svg+xml"><link rel="alternate icon" href="/dsh-memu-memory/ui-assets/icon.png">
46
- <script>try{var t=localStorage.getItem('dshm-theme');document.documentElement.dataset.theme=t||(window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light')}catch(e){}</script>
46
+ <script>try{var q=new URLSearchParams(location.search).get('theme');q=(q==='dark'||q==='light')?q:null;var t=localStorage.getItem('dshm-theme');document.documentElement.dataset.theme=t||q||(window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light')}catch(e){}</script>
47
47
  <style>
48
- :root{--dsw-alias-bg-base:#f4f5f9;--dsw-alias-bg-layer-1:#ffffff;--dsw-alias-bg-layer-2:#eceef5;--dsw-alias-bg-layer-3:#e2e5ef;--dsw-alias-bg-layer-4:#d8dce9;--dsw-alias-label-primary:#1a1e2b;--dsw-alias-label-secondary:#5f6577;--dsw-alias-label-primary-inverted:#ffffff;--dsw-alias-border-l1:rgba(26,30,43,.10);--dsw-alias-border-l2:rgba(26,30,43,.18);--dsw-alias-brand-primary:#3b5bdb;--dsw-alias-brand-text:#ffffff;--dsw-alias-label-error:#b43e45;--dsw-alias-label-warning:#9a6b1f}
49
- :root[data-theme=dark]{--dsw-alias-bg-base:#0d0f15;--dsw-alias-bg-layer-1:#171a23;--dsw-alias-bg-layer-2:#1e222d;--dsw-alias-bg-layer-3:#272c39;--dsw-alias-bg-layer-4:#313747;--dsw-alias-label-primary:#e9ebf4;--dsw-alias-label-secondary:#9ba2b5;--dsw-alias-label-primary-inverted:#0b1030;--dsw-alias-border-l1:rgba(233,235,244,.10);--dsw-alias-border-l2:rgba(233,235,244,.18);--dsw-alias-brand-primary:#8ea2ff;--dsw-alias-brand-text:#0b1030;--dsw-alias-label-error:#f08a91;--dsw-alias-label-warning:#d6a45f}
48
+ :root{--dsw-alias-bg-base:#f4f5f9;--dsw-alias-bg-layer-1:#ffffff;--dsw-alias-bg-layer-2:#eceef5;--dsw-alias-bg-layer-3:#e2e5ef;--dsw-alias-bg-layer-4:#d8dce9;--dsw-alias-label-primary:#1a1e2b;--dsw-alias-label-secondary:#5f6577;--dsw-alias-label-primary-inverted:#ffffff;--dsw-alias-border-l1:rgba(26,30,43,.10);--dsw-alias-border-l2:rgba(26,30,43,.18);--dsw-alias-brand-primary:#3b5bdb;--dsw-alias-brand-text:#ffffff;--dsw-alias-label-error:#b43e45;--dsw-alias-label-warning:#9a6b1f;--dsw-alias-state-error-primary:#b43e45;--dsw-alias-state-warn-label:#9a6b1f;--dsw-alias-state-warn-primary:#9a6b1f}
49
+ :root[data-theme=dark]{--dsw-alias-bg-base:#0d0f15;--dsw-alias-bg-layer-1:#171a23;--dsw-alias-bg-layer-2:#1e222d;--dsw-alias-bg-layer-3:#272c39;--dsw-alias-bg-layer-4:#313747;--dsw-alias-label-primary:#e9ebf4;--dsw-alias-label-secondary:#9ba2b5;--dsw-alias-label-primary-inverted:#0b1030;--dsw-alias-border-l1:rgba(233,235,244,.10);--dsw-alias-border-l2:rgba(233,235,244,.18);--dsw-alias-brand-primary:#8ea2ff;--dsw-alias-brand-text:#0b1030;--dsw-alias-label-error:#f08a91;--dsw-alias-label-warning:#d6a45f;--dsw-alias-state-error-primary:#f08a91;--dsw-alias-state-warn-label:#d6a45f;--dsw-alias-state-warn-primary:#d6a45f}
50
50
  ${css}
51
51
  </style>
52
52
  </head>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-memu-memory",
3
3
  "icon": "./assets/icon.png",
4
- "version": "1.2.7",
4
+ "version": "1.2.9",
5
5
  "description": "面向长篇 RP 与陪伴对话的 DeepSeek Harness 记忆插件:三层记忆、逐轮召回、来源标注、关系图、图片附件与独立 WebUI。",
6
6
  "keywords": [
7
7
  "deepseek-harness",
@@ -49,10 +49,11 @@
49
49
  "cordis.patch.yml",
50
50
  "requirements.lock",
51
51
  "README.md",
52
+ "README.zh.md",
53
+ "CHANGELOG.md",
52
54
  "assets",
53
55
  "AGENTS.md",
54
56
  "docs",
55
- "README.zh.md",
56
57
  "LICENSE"
57
58
  ],
58
59
  "scripts": {
@@ -626,7 +626,7 @@ await auto('F-1', 'the engine can be listed, switched and pruned', async () => {
626
626
  await auto('F-2', 'a backup restore brings a deleted memory back', async () => {
627
627
  const lib = makeLibrary('f2')
628
628
  seed(lib.id, 'mem-f2keep', { title: 'written before the backup' })
629
- const made = state.backupDatabases()
629
+ const made = await state.backupDatabases()
630
630
  assert.ok(made, 'a backup was taken')
631
631
  const backups = (await dispatch({}, 'listBackups', {})).backups
632
632
  assert.ok(backups.length >= 1, 'it shows up in the list')
@@ -894,7 +894,7 @@ await auto('H-7', 'an archived memory can be deleted, and only an archived one',
894
894
  await memory.privateArchive({ libraryId: lib.id, id: live.id })
895
895
  const archivedRow = (await dispatch({}, 'browseLibrary', { libraryId: lib.id })).files.find((item) => item.id === live.id)
896
896
  assert.equal(archivedRow.status, 'archived', 'archiving keeps it, so the archived tab has something to show')
897
- const gone = await dispatch({}, 'deleteMemory', { id: live.id, libraryId: lib.id })
897
+ const gone = await dispatch({}, 'deleteMemory', { id: live.id, libraryId: lib.id, confirmed: true })
898
898
  assert.equal(gone.deleted, true)
899
899
  assert.ok(!(await dispatch({}, 'browseLibrary', { libraryId: lib.id })).files.some((item) => item.id === live.id), 'and then it is really gone')
900
900
  let needsLib = ""
@@ -1,4 +1,4 @@
1
- // 召回基准台(1.3.0 P1-3):对比 HEAD 基线与施工后 lib 的检索质量与延迟。
1
+ // 召回基准台(1.2.8 P1-3):对比 HEAD 基线与升级后 lib 的检索质量与延迟。
2
2
  //
3
3
  // 用法:
4
4
  // node scripts/bench-recall.mjs # 测当前仓库 lib
@@ -9,7 +9,7 @@
9
9
  // - 指标:rankPairCandidates 延迟(N=300 精确两两 / N=2000 blocking 两档)、
10
10
  // buildCandidateClusters 延迟、Recall@10 / MRR(查询 → 目标条目是否进前 10)。
11
11
  // - 不引入任何依赖;被测导出(buildCorpus/rankPairCandidates/buildCandidateClusters)
12
- // 是 curator.js/global-graph.js 的既有公共面,任何施工都不应改动其签名。
12
+ // 是 curator.js/global-graph.js 的既有公共面,任何改动都不应改动其签名。
13
13
 
14
14
  import { pathToFileURL, fileURLToPath } from 'node:url'
15
15
  import { performance } from 'node:perf_hooks'
@@ -43,7 +43,9 @@ const budget = (rel, limit) => {
43
43
  budget('AGENTS.md', 60000)
44
44
 
45
45
  check('i18n', process.execPath, ['scripts/check-i18n.mjs'])
46
- check('package.json', process.execPath, ['-e', 'JSON.parse(require("fs").readFileSync("package.json","utf8"))'])
46
+ // npm silently de-duplicates `files` on pack, so a repeated entry only rots in
47
+ // source without any failing check. Pin the whitelist shape here instead.
48
+ check('package.json', process.execPath, ['-e', 'const p=JSON.parse(require("fs").readFileSync("package.json","utf8"));if(!Array.isArray(p.files)||new Set(p.files).size!==p.files.length)throw new Error("package.json: files must be an array with no duplicates")'])
47
49
 
48
50
  // W2 防漂移闸门:RPC 方法数标记、tests 跟踪状态、loader/stub 完整性。
49
51
  // 这三项由 scripts/check-doc-drift.mjs 实现,返回 ok / skipped / fail 三态: