dsh-memu-memory 1.2.8 → 1.3.0

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 (90) hide show
  1. package/CHANGELOG.md +494 -0
  2. package/README.md +1 -1
  3. package/README.zh.md +1 -1
  4. package/docs/memory-semantics.md +3 -2
  5. package/lib/backup.js +154 -25
  6. package/lib/binding-diagnostics.js +2 -3
  7. package/lib/budget.js +0 -9
  8. package/lib/client.js +221 -128
  9. package/lib/commitment.js +3 -3
  10. package/lib/consolidation-ledger.js +46 -3
  11. package/lib/consolidation-receipt.js +41 -16
  12. package/lib/consolidation-worker.js +34 -10
  13. package/lib/curator-policy.js +23 -0
  14. package/lib/cycle.js +8 -4
  15. package/lib/embedding-download.js +168 -28
  16. package/lib/embedding-runtime.js +76 -17
  17. package/lib/engine.js +0 -6
  18. package/lib/freshness.js +2 -2
  19. package/lib/graph.js +139 -11
  20. package/lib/index.js +71 -20
  21. package/lib/inject.js +50 -7
  22. package/lib/lexicon.js +61 -16
  23. package/lib/local-vector-service.js +21 -1
  24. package/lib/media.js +49 -12
  25. package/lib/memory.js +662 -116
  26. package/lib/paths.js +0 -7
  27. package/lib/preset-scope.js +6 -1
  28. package/lib/private.js +281 -18
  29. package/lib/prompts/private-consolidation.md +2 -2
  30. package/lib/prompts/private-consolidation.rp.md +3 -2
  31. package/lib/prompts.js +0 -7
  32. package/lib/rpc.js +95 -17
  33. package/lib/snippet.js +18 -2
  34. package/lib/state.js +109 -30
  35. package/lib/stats.js +2 -2
  36. package/lib/temporal.js +19 -0
  37. package/lib/text-retrieval.js +120 -44
  38. package/lib/text-similarity.js +205 -24
  39. package/lib/tokenizer-v2.js +0 -24
  40. package/lib/tools.js +62 -62
  41. package/lib/vector-migration.js +15 -0
  42. package/lib/vector-profile.js +81 -8
  43. package/lib/visibility.js +0 -4
  44. package/lib/webui/standalone.css +17 -22
  45. package/lib/webui/standalone.js +27 -9
  46. package/lib/webui.js +4 -4
  47. package/package.json +3 -2
  48. package/scripts/acceptance-local.mjs +2 -2
  49. package/scripts/check-all.mjs +3 -1
  50. package/scripts/check-i18n.mjs +35 -1
  51. package/scripts/migrate-visibility.mjs +3 -3
  52. package/scripts/prune-sessions.mjs +34 -0
  53. package/scripts/prune-vectors.mjs +24 -0
  54. package/tests/appendix-b.test.mjs +5 -4
  55. package/tests/audit-batch3.test.mjs +247 -0
  56. package/tests/audit-regression.test.mjs +2 -2
  57. package/tests/backup.test.mjs +83 -83
  58. package/tests/browser.test.mjs +6 -1
  59. package/tests/client-render.test.mjs +2 -2
  60. package/tests/consolidation-fork.test.mjs +61 -15
  61. package/tests/consolidation-ledger.test.mjs +64 -3
  62. package/tests/consolidation-snapshot.test.mjs +25 -9
  63. package/tests/curator-clusters.test.mjs +18 -0
  64. package/tests/curator-pairing.test.mjs +59 -16
  65. package/tests/dynamic-rrf.test.mjs +22 -19
  66. package/tests/dynamic-threshold.test.mjs +52 -0
  67. package/tests/fact-version.test.mjs +18 -0
  68. package/tests/fixtures/tokenizer-cases.mjs +27 -0
  69. package/tests/graph-cascade.test.mjs +29 -0
  70. package/tests/graph.test.mjs +45 -0
  71. package/tests/inject-conflict.test.mjs +18 -0
  72. package/tests/injection-chain.test.mjs +2 -2
  73. package/tests/lexical-bm25.test.mjs +171 -0
  74. package/tests/lexicon-frequency.test.mjs +16 -0
  75. package/tests/lexicon-inject.test.mjs +21 -0
  76. package/tests/lexicon-perf.test.mjs +37 -9
  77. package/tests/lexicon-scope.test.mjs +2 -2
  78. package/tests/lexicon-ui.test.mjs +1 -1
  79. package/tests/managed-memory.test.mjs +19 -0
  80. package/tests/ops-hardening.test.mjs +209 -0
  81. package/tests/package-shipping.test.mjs +4 -0
  82. package/tests/prompt-semantics.test.mjs +1 -1
  83. package/tests/prompts.test.mjs +1 -1
  84. package/tests/recall-intent.test.mjs +23 -0
  85. package/tests/slot-similarity.test.mjs +153 -0
  86. package/tests/state-gc.test.mjs +34 -0
  87. package/tests/state.test.mjs +2 -2
  88. package/tests/tokenizer-v2.test.mjs +1 -1
  89. package/tests/vector-gc.test.mjs +37 -0
  90. package/tests/webui.test.mjs +27 -0
@@ -43,6 +43,10 @@ function runCheckAll(root) {
43
43
  test('package.json ships tests/ so the packaged suite is not silently empty', () => {
44
44
  assert.ok(Array.isArray(pkg.files), 'package.json needs a files whitelist')
45
45
  assert.ok(pkg.files.includes('tests'), 'files must include "tests" or npm test finds 0 test files')
46
+ // G-1 in the packaged acceptance suite reads CHANGELOG.md. If it does not ship,
47
+ // the installed package reports a 49/50 acceptance run while the repo is 50/50.
48
+ assert.ok(pkg.files.includes('CHANGELOG.md'), 'files must include "CHANGELOG.md" for packaged acceptance G-1')
49
+ assert.equal(new Set(pkg.files).size, pkg.files.length, 'files must not contain duplicate entries')
46
50
  // The suite is only runnable if its harness (loader + stubs) travels with it.
47
51
  for (const rel of ['loader-register.mjs', 'loader.mjs', 'stubs/dsh-llm.js']) {
48
52
  assert.ok(fs.existsSync(path.join(REPO, 'tests', rel)), 'tests/' + rel + ' must ship with the package')
@@ -45,7 +45,7 @@ test('the consolidation page and worker brief carry the same field contract', ()
45
45
  snapshot: { fromSeq: 1, throughSeq: 2, eventCount: 2, hash: 'prompt-128' },
46
46
  probe: { tools: ['memu_private_remember', 'memu_private_update'] },
47
47
  })
48
- for (const needle of ['speaker_id', 'source_kind', 'absolute_date', 'conflicts_with', 'supersedes', 'commitment', 'assistant_said', '每窗最多新增 10 条']) {
48
+ for (const needle of ['speaker_id', 'source_kind', 'absolute_date', 'conflicts_with', 'supersedes', 'commitment', 'assistant_said', '每窗最多新增 8 条']) {
49
49
  assert.ok(brief.includes(needle), `worker brief is missing ${needle}`)
50
50
  }
51
51
  })
@@ -222,7 +222,7 @@ test('title guidance ships in every consolidation page; tool workflow lives in t
222
222
 
223
223
  const { buildWorkerBrief } = await import('../lib/consolidation-worker.js')
224
224
  const brief = buildWorkerBrief({ snapshot: { fromSeq: 1, throughSeq: 2, eventCount: 2, hash: 'prompt-test' }, probe: null, contract: '' })
225
- for (const rule of [/memu_lexicon_search/, /memu_lexicon_propose/, /term 是索引键/, /sensitive trigger/, /memu_private_link_suggest/, /noop/, /conflict/, /最多确认 5 条/]) {
225
+ for (const rule of [/memu_private_remember/, /memu_private_update/, /memu_private_link_suggest/, /每窗最多新增 8 条/]) {
226
226
  assert.match(brief, rule, 'the local worker brief owns the tool workflow')
227
227
  }
228
228
  assert.match(prompts.CONSOLIDATION_CONTRACTS.remote, /8-40字/, 'the remote JSON contract uses the same title length')
@@ -67,6 +67,29 @@ test('one-hop expansion follows an explicit link to a memory the query never mat
67
67
  assert.ok(recalled.files.find((file) => file.name === b.id).relatedTo === a.id)
68
68
  })
69
69
 
70
+ test('graph expansion only fills empty topK seats, never adds injected entries', async () => {
71
+ const { exec, sessionId } = session('intent-multihop-budget')
72
+ const a = await memory.privateRemember({
73
+ exec, title: '码头灯塔记录', content: '林眠傍晚去了码头看灯塔。',
74
+ })
75
+ const b = await memory.privateRemember({
76
+ exec, title: '灯塔亮起时间', content: '码头边的灯塔亮了三次。',
77
+ })
78
+ const linked = await memory.privateRemember({
79
+ exec, title: '她带了一把旧伞', content: '那天她带着一把旧伞。',
80
+ })
81
+ const binding = state.getSessionBinding(sessionId)
82
+ state.updatePrivateIndex(binding.libraryId, (index) => {
83
+ index.entries[a.id].links = [{ to: linked.id, kind: 'event', note: 'same evening', confidence: 0.9 }]
84
+ })
85
+ const recalled = await memory.privateRecall({ exec, query: '码头 灯塔', topK: 2, relevanceThreshold: 0 })
86
+ const ids = recalled.files.map((file) => file.name)
87
+ assert.equal(recalled.files.length, 2, 'topK seats stay full; expansion cannot add a third')
88
+ assert.ok(ids.includes(a.id) && ids.includes(b.id))
89
+ assert.ok(!ids.includes(linked.id), 'the linked memory must wait until a seat is free')
90
+ assert.equal(recalled.expanded, undefined)
91
+ })
92
+
70
93
  test('automatic recall hides never_say and only_if_asked; boundary questions release only_if_asked', async () => {
71
94
  const { exec } = session('intent-disclosure')
72
95
  const open = await memory.privateRemember({
@@ -0,0 +1,153 @@
1
+ import test from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import fs from 'node:fs'
4
+ import os from 'node:os'
5
+ import path from 'node:path'
6
+
7
+ const home = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-memu-memory-slots-'))
8
+ process.env.DSH_MEMU_HOME = home
9
+
10
+ const state = await import('../lib/state.js')
11
+ const memory = await import('../lib/memory.js')
12
+ const similarity = await import('../lib/text-similarity.js')
13
+
14
+ test.after(() => {
15
+ try { fs.rmSync(home, { recursive: true, force: true }) } catch {}
16
+ })
17
+
18
+ let seq = 0
19
+ function session(name) {
20
+ seq += 1
21
+ const cwd = path.join(home, 'ws', `${name}-${seq}`)
22
+ const sessionId = `${name}-${seq}`
23
+ state.ensureSession(sessionId, { cwd, agentPreset: 'coding' })
24
+ return {
25
+ sessionId,
26
+ libraryId: state.getSessionBinding(sessionId).libraryId,
27
+ exec: { agent: { session: { header: { id: sessionId, cwd, agentPreset: 'coding' } } } },
28
+ }
29
+ }
30
+
31
+ const LOAN_A = '图书馆借阅规则:每人每次最多借五本书,借期十四天,可以续借一次,逾期按天收取滞纳金,闭馆日不办理。'
32
+ const LOAN_B = '图书馆借阅规则:每人每次最多借七本书,借期十四天,可以续借一次,逾期按天收取滞纳金,闭馆日不办理。'
33
+
34
+ test('numbers, dates, times, weekdays and quoted names are slot conflicts', () => {
35
+ const cases = [
36
+ [LOAN_A, LOAN_B],
37
+ ['复诊安排在2026-11-08上午十点。', '复诊安排在2026-11-15上午十点。'],
38
+ ['每周一上午九点开会。', '每周二上午九点开会。'],
39
+ ['他说“林眠”明天会来,而且会带伞。', '他说“Yuike”明天会来,而且会带伞。'],
40
+ ]
41
+ for (const [a, b] of cases) {
42
+ const detail = similarity.similarityDetail(a, b)
43
+ assert.equal(detail.slotConflict, true, a.slice(0, 18))
44
+ assert.ok(detail.dice >= similarity.TOPIC_DICE, 'fixture must be similar enough to inspect slots')
45
+ assert.ok(similarity.similarTexts(a, b) < similarity.TOPIC_DICE, 'slot conflict must fall below the topic band')
46
+ }
47
+ assert.deepEqual(similarity.slotSignature('借五本书,等十五天').numbers.sort(), ['15', '5'])
48
+ })
49
+
50
+ test('same slots and added numbers are not capped', () => {
51
+ assert.equal(similarity.similarityDetail(LOAN_A, LOAN_A).slotConflict, false)
52
+ const same = '图书馆借阅规则:每人每次最多借五本书,借期十四天。'
53
+ const added = '图书馆借阅规则:每人每次最多借五本书,借期十四天,押金二十元,每人限办一张卡。'
54
+ const detail = similarity.similarityDetail(same, added)
55
+ assert.equal(detail.slotConflict, false, 'an added number is an enrichment, not a contradiction')
56
+ assert.equal(similarity.similarTexts(same, added), Math.max(detail.dice, detail.containment))
57
+ // Totally unrelated text never pays for slot extraction and is not a conflict.
58
+ assert.equal(similarity.similarityDetail('窗外的雨停了。', '图书馆周三闭馆。').slotConflict, false)
59
+ })
60
+
61
+ test('different-title facts that only change a number both stay active', async () => {
62
+ const { exec, libraryId } = session('slot-write')
63
+ const first = await memory.privateRemember({ exec, title: '借阅上限', content: LOAN_A })
64
+ const raw = similarity.similarityDetail(LOAN_A, LOAN_B)
65
+ assert.ok(raw.dice >= similarity.DUP_REJECT_DICE, 'fixture must sit in the old reject band, got ' + raw.dice)
66
+ assert.equal(raw.slotConflict, true)
67
+ const second = await memory.privateRemember({ exec, title: '借阅额度', content: LOAN_B })
68
+ assert.equal(second.deduped, undefined)
69
+ assert.equal(second.entry.status, 'active')
70
+ assert.equal(second.entry.duplicateOf, undefined)
71
+ const index = state.loadPrivateIndex(libraryId)
72
+ assert.equal(Object.keys(index.entries).length, 2)
73
+ assert.equal(index.entries[first.id].status, 'active')
74
+ assert.equal(index.entries[second.id].content, LOAN_B)
75
+ })
76
+
77
+ test('same title + changed number is held as a conflict, not swallowed as duplicate', async () => {
78
+ const { exec, libraryId } = session('slot-same-title')
79
+ const first = await memory.privateRemember({ exec, title: '借阅上限', content: LOAN_A })
80
+ const second = await memory.privateRemember({ exec, title: '借阅上限', content: LOAN_B })
81
+ assert.equal(second.conflict, first.id, 'same-title slot correction must be a conflict')
82
+ const index = state.loadPrivateIndex(libraryId)
83
+ assert.equal(index.entries[second.id].status, 'pending_review')
84
+ assert.match(index.entries[second.id].reviewReason, /slot|说法|同题/)
85
+ assert.equal(index.entries[second.id].content, LOAN_B, 'the corrected text is preserved')
86
+ })
87
+
88
+ test('an update that only changes a number is not refused as a duplicate', async () => {
89
+ const { exec, libraryId } = session('slot-update')
90
+ const index = state.loadPrivateIndex(libraryId)
91
+ const now = new Date().toISOString()
92
+ index.entries['mem-host'] = {
93
+ title: '借阅上限', content: LOAN_A,
94
+ status: 'active', layer: 'long_term', createdAt: now, updatedAt: now,
95
+ }
96
+ index.entries['mem-target'] = {
97
+ title: '借阅额度备注', content: '这条先占位,稍后改成正式规则。',
98
+ status: 'active', layer: 'long_term', createdAt: now, updatedAt: now,
99
+ }
100
+ state.savePrivateIndex(libraryId, index)
101
+ const updated = await memory.privateUpdate({ exec, id: 'mem-target', content: LOAN_B })
102
+ assert.equal(updated.entry.content, LOAN_B)
103
+ assert.equal(updated.entry.status, 'active')
104
+ assert.equal(updated.entry.duplicateOf, undefined, 'a slot change is a different fact, not a duplicate')
105
+ })
106
+
107
+ test('recall keeps same-template different-number facts in separate seats', async () => {
108
+ const { exec, libraryId } = session('slot-recall')
109
+ const index = state.loadPrivateIndex(libraryId)
110
+ const now = new Date().toISOString()
111
+ index.entries['mem-five'] = {
112
+ title: '借阅上限五本', content: LOAN_A,
113
+ status: 'active', layer: 'long_term', createdAt: now, updatedAt: now,
114
+ }
115
+ index.entries['mem-seven'] = {
116
+ title: '借阅上限七本', content: LOAN_B,
117
+ status: 'active', layer: 'long_term', createdAt: now, updatedAt: now,
118
+ }
119
+ state.savePrivateIndex(libraryId, index)
120
+ const raw = similarity.similarityDetail(LOAN_A, LOAN_B)
121
+ assert.ok(raw.dice >= similarity.DUP_DICE, 'fixture must be in the old folding band')
122
+ const recalled = await memory.privateRecall({ exec, query: '图书馆借阅规则', topK: 10, relevanceThreshold: 0 })
123
+ const ids = recalled.files.map((file) => file.name)
124
+ assert.ok(ids.includes('mem-five') && ids.includes('mem-seven'), 'distinct facts must keep two seats')
125
+ assert.deepEqual(recalled.dedup?.collapsed || [], [], 'the pair must not be folded')
126
+ })
127
+
128
+ test('A-10: similarity thresholds have a single source; compat exports keep their values', () => {
129
+ assert.deepEqual(similarity.SIMILARITY_THRESHOLDS, {
130
+ duplicateDice: 0.82,
131
+ rejectDice: 0.90,
132
+ topicDice: 0.55,
133
+ lengthPruneRatio: 0.5,
134
+ containmentFloor: 0.92,
135
+ probeMinChars: 6,
136
+ probeMaxChars: 240,
137
+ })
138
+ assert.equal(similarity.DUP_DICE, similarity.SIMILARITY_THRESHOLDS.duplicateDice)
139
+ assert.equal(similarity.DUP_REJECT_DICE, similarity.SIMILARITY_THRESHOLDS.rejectDice)
140
+ assert.equal(similarity.TOPIC_DICE, similarity.SIMILARITY_THRESHOLDS.topicDice)
141
+ assert.equal(similarity.LENGTH_PRUNE_RATIO, similarity.SIMILARITY_THRESHOLDS.lengthPruneRatio)
142
+ assert.equal(similarity.CONTAINMENT_FLOOR, similarity.SIMILARITY_THRESHOLDS.containmentFloor)
143
+ assert.equal(similarity.CORE_COVER_FLOOR, similarity.SIMILARITY_THRESHOLDS.rejectDice)
144
+ for (const value of [similarity.DUP_DICE, similarity.DUP_REJECT_DICE, similarity.TOPIC_DICE, similarity.CONTAINMENT_FLOOR]) {
145
+ assert.equal(typeof value, 'number', 'compat exports stay plain numbers')
146
+ }
147
+ })
148
+
149
+ test('D-21: jaccard is exported from the shared ruler with the old formula', () => {
150
+ assert.equal(similarity.jaccard(new Set(), new Set(['a'])), 0)
151
+ assert.equal(similarity.jaccard(new Set(['a', 'b']), new Set(['b', 'c'])), 1 / 3)
152
+ assert.equal(similarity.jaccard(new Set(['a', 'b']), new Set(['a', 'b'])), 1)
153
+ })
@@ -0,0 +1,34 @@
1
+ import test from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import fs from 'node:fs'
4
+ import os from 'node:os'
5
+ import path from 'node:path'
6
+
7
+ const home = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-memu-memory-gc-'))
8
+ process.env.DSH_MEMU_HOME = home
9
+
10
+ const state = await import('../lib/state.js')
11
+
12
+ test.after(() => {
13
+ state.flushState()
14
+ try { fs.rmSync(home, { recursive: true, force: true }) } catch {}
15
+ })
16
+
17
+ test('session-binding GC is dry-run first and skips bindings without a clock', async () => {
18
+ state.ensureSession('gc-old', { cwd: path.join(home, 'old') })
19
+ state.setSessionBinding('gc-old', { lastTurnAt: '2020-01-01T00:00:00.000Z' })
20
+ state.ensureSession('gc-new', { cwd: path.join(home, 'new') })
21
+ state.setSessionBinding('gc-new', { lastTurnAt: new Date().toISOString() })
22
+ state.ensureSession('gc-noclock', { cwd: path.join(home, 'noclock') })
23
+
24
+ const dry = state.pruneSessionBindings({ olderThanDays: 30 })
25
+ assert.equal(dry.dryRun, true)
26
+ assert.deepEqual(dry.candidates.map((item) => item.sessionId), ['gc-old'])
27
+ assert.ok(state.getSessionBinding('gc-old'), 'dry-run must not remove')
28
+
29
+ const applied = state.pruneSessionBindings({ olderThanDays: 30, dryRun: false })
30
+ assert.deepEqual(applied.removed, ['gc-old'])
31
+ assert.equal(state.getSessionBinding('gc-old'), null)
32
+ assert.ok(state.getSessionBinding('gc-new'), 'a recent binding survives')
33
+ assert.ok(state.getSessionBinding('gc-noclock'), 'a binding without lastTurnAt is never guessed away')
34
+ })
@@ -56,8 +56,8 @@ test('the unpin marker is gone from session bindings', () => {
56
56
  assert.equal(typeof state.consumeTrauma, 'undefined')
57
57
  })
58
58
 
59
- test('backup creates a timestamped directory', () => {
60
- const dest = state.backupDatabases()
59
+ test('backup creates a timestamped directory', async () => {
60
+ const dest = await state.backupDatabases()
61
61
  assert.ok(fs.existsSync(dest))
62
62
  assert.ok(fs.existsSync(path.join(dest, 'index')))
63
63
  })
@@ -5,9 +5,9 @@ import {
5
5
  tokenize,
6
6
  tokenizeStats,
7
7
  tokenizeV2,
8
- TEST_CASES,
9
8
  tokenStreamV2,
10
9
  } from '../lib/tokenizer-v2.js'
10
+ import { TEST_CASES } from './fixtures/tokenizer-cases.mjs'
11
11
 
12
12
  // —— 召回升级 P0-1:Tokenizer V2(CJK 三层 n-gram + 实体保护)——
13
13
  // 开关在 lib/curator-policy.js(TOKENIZER_V2);这里测 V2 本身的行为契约。
@@ -0,0 +1,37 @@
1
+ import test from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+
4
+ import { vectorGcCandidates } from '../lib/vector-profile.js'
5
+
6
+ const DAY = 86_400_000
7
+ const NOW = 1_800_000_000_000
8
+
9
+ test('vector GC keeps active/pending paths and the last N generations', () => {
10
+ const old = NOW - 40 * DAY
11
+ const files = [
12
+ { file: 'global.aaaa.g1.sqlite3', generation: 1, bytes: 10, mtimeMs: old },
13
+ { file: 'global.aaaa.g2.sqlite3', generation: 2, bytes: 10, mtimeMs: old },
14
+ { file: 'global.aaaa.g3.sqlite3', generation: 3, bytes: 10, mtimeMs: old },
15
+ { file: 'vector-ledger.aaaa.g1.json', generation: 1, bytes: 10, mtimeMs: old },
16
+ { file: 'legacy.sqlite3', generation: null, bytes: 10, mtimeMs: old },
17
+ ]
18
+ const candidates = vectorGcCandidates({
19
+ files, activeGeneration: 3, keepGenerations: 2, olderThanDays: 7, now: NOW,
20
+ })
21
+ assert.deepEqual(candidates.map((item) => item.file).sort(), [
22
+ 'global.aaaa.g1.sqlite3',
23
+ 'vector-ledger.aaaa.g1.json',
24
+ ])
25
+
26
+ const kept = vectorGcCandidates({
27
+ files, activeGeneration: 3, keepGenerations: 2, olderThanDays: 7, now: NOW,
28
+ keepPaths: ['global.aaaa.g1.sqlite3'],
29
+ })
30
+ assert.deepEqual(kept.map((item) => item.file), ['vector-ledger.aaaa.g1.json'])
31
+
32
+ const recent = vectorGcCandidates({
33
+ files: [{ file: 'global.aaaa.g1.sqlite3', generation: 1, bytes: 10, mtimeMs: NOW - DAY }],
34
+ activeGeneration: 3, keepGenerations: 2, olderThanDays: 7, now: NOW,
35
+ })
36
+ assert.deepEqual(recent, [], 'a recent old generation is left for the retention window')
37
+ })
@@ -135,6 +135,33 @@ test('wall heartbeat retries failed paints, pauses hidden and shares the metadat
135
135
  assert.match(source, /data\.type === "memory-write"/)
136
136
  })
137
137
 
138
+ test('fullscreen wall avoids the WebView2 compositor traps that dropped cards', () => {
139
+ const client = fs.readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
140
+ // The overlay is a full-viewport iframe over the host app. A backdrop-filter on
141
+ // that wrapper (and a transparent iframe background) made WebView2 re-blur the
142
+ // whole host on every repaint; at fullscreen it started dropping wall tiles.
143
+ const overlay = client.slice(client.indexOf('function toggleWebUiOverlay'), client.indexOf('function glyph'))
144
+ assert.ok(!/backdrop-filter\s*:/.test(overlay), 'the overlay wrapper must not blur the host behind the iframe')
145
+ assert.match(overlay, /background:var\(--dsw-alias-bg-base, #f4f5f9\)/, 'the iframe stays opaque while its page paints')
146
+ // Late replies must not repaint the wall/browser after a newer library was picked.
147
+ assert.match(client, /const requestId = \+\+browseRequest\.current/)
148
+ assert.match(client, /const requestId = \+\+browseLibraryRequest\.current/)
149
+ assert.match(client, /const requestId = \+\+statsRequest\.current/)
150
+ assert.match(client, /const requestId = \+\+reviewsRequest\.current/)
151
+ assert.match(client, /if \(!current\(\)\) return/, 'stale browseWall replies are dropped')
152
+
153
+ const css = fs.readFileSync(new URL('../lib/webui/standalone.css', import.meta.url), 'utf8')
154
+ const start = css.indexOf('html[data-standalone] .dshm-wall-item {')
155
+ const wall = css.slice(start, css.indexOf('html[data-standalone] .dshm-wall-item:hover'))
156
+ assert.ok(!/backdrop-filter\s*:/.test(wall), 'wall cards must not stack dozens of blur layers on screen')
157
+ assert.match(wall, /content-visibility: auto/, 'off-screen wall rows stay out of the paint path')
158
+
159
+ const standalone = fs.readFileSync(new URL('../lib/webui/standalone.js', import.meta.url), 'utf8')
160
+ assert.match(standalone, /var spot = document\.querySelector\('\.ambient-spot'\)/)
161
+ assert.match(standalone, /\(spot \|\| document\.documentElement\)\.style/, 'pointer moves only invalidate the spotlight element')
162
+ assert.match(standalone, /if \(!framed && !reduceMotion/, 'the iframe overlay does not repaint a full-screen spotlight')
163
+ })
164
+
138
165
  test('single-library browseWall still carries global rows and F1/F2 metadata', async () => {
139
166
  const library = state.createLibrary({ name: 'wall-global-merge', cwd: path.join(home, 'wall-global-merge') })
140
167
  state.updatePrivateIndex(library.id, (index) => {