dsh-memu-memory 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/contributing.md +1 -1
- package/docs/host-adaptation.md +1 -1
- package/docs/memory-semantics.md +3 -1
- package/docs/troubleshooting.md +3 -1
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +276 -28
- package/lib/curator-policy.js +98 -0
- package/lib/fork-model.js +312 -0
- package/lib/memory.js +36 -12
- package/lib/private.js +44 -5
- package/lib/prompts/private-consolidation.mixed.md +1 -0
- package/lib/prompts/private-consolidation.rp.md +1 -0
- package/lib/prompts/private-policy.mixed.md +1 -0
- package/lib/prompts/private-policy.rp.md +1 -1
- package/lib/recall-cache.js +204 -0
- package/lib/rpc.js +35 -4
- package/lib/state.js +43 -1
- package/lib/text-retrieval.js +221 -28
- package/lib/tokenizer-v2.js +295 -0
- package/lib/webui/standalone.css +17 -1
- package/package.json +1 -1
- package/scripts/bench-recall.mjs +142 -0
- package/scripts/check-seed-compat.mjs +118 -0
- package/tests/consolidation-fork.test.mjs +119 -2
- package/tests/curator-clusters.test.mjs +7 -1
- package/tests/curator-pairing.test.mjs +52 -8
- package/tests/dynamic-rrf.test.mjs +179 -0
- package/tests/fork-model.test.mjs +345 -0
- package/tests/loader.mjs +3 -0
- package/tests/negation-polarity.test.mjs +135 -0
- package/tests/recall-cache.test.mjs +290 -0
- package/tests/stubs/dsh-llm-pi-ai.js +13 -0
- package/tests/tokenizer-v2.test.mjs +142 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import {
|
|
4
|
+
globalConflictCheck,
|
|
5
|
+
negationPolarity,
|
|
6
|
+
pairFeatures,
|
|
7
|
+
polarityAt,
|
|
8
|
+
} from '../lib/text-retrieval.js'
|
|
9
|
+
|
|
10
|
+
// —— §4.8 冲突预筛 P1-2:子句级否定作用域(polarityAt)——
|
|
11
|
+
//
|
|
12
|
+
// 整文本 negationPolarity 有两类误报:无关子句的否定污染、双重否定。
|
|
13
|
+
// polarityAt 只判锚点所在子句,标记计数 mod 2,对比词切片段。
|
|
14
|
+
|
|
15
|
+
test('polarityAt: negation in the same clause hits across 12 chars (existing true positive)', () => {
|
|
16
|
+
// 「不」在第 2 字,锚点「告警」在第 12 字附近——同一子句即算否定侧,
|
|
17
|
+
// 这条是既有真阳性(curator-pairing 的告警对),不能丢。
|
|
18
|
+
assert.equal(polarityAt('用户不希望每次部署失败都发告警通知', '告警'), true)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('polarityAt: negation in an unrelated clause does not pollute the anchor clause', () => {
|
|
22
|
+
// 「别」在第二个子句(别忘了),锚点「截止日期」在第一个子句——互不污染。
|
|
23
|
+
assert.equal(polarityAt('项目截止日期是5月1日,别忘了', '截止日期'), false)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('polarityAt: double negation flips back to positive (marker count mod 2)', () => {
|
|
27
|
+
assert.equal(polarityAt('不是不喜欢香菜', '香菜'), false)
|
|
28
|
+
// 多标记句:禁止 → 单个否定 → 否定侧
|
|
29
|
+
assert.equal(polarityAt('禁止在-production 环境跑迁移', 'production'), true)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('polarityAt: contrast structure frees the B side (不是A而是B)', () => {
|
|
33
|
+
// 「不是 A 而是 B」里 B(队列)是肯定侧——这是 P1-2 要修的误报方向。
|
|
34
|
+
assert.equal(polarityAt('不是缓存的问题而是队列的问题', '队列'), false)
|
|
35
|
+
// A 侧(缓存):按对比规则正文「不是 A 而是 B 里否定属于 A」,标记「不」与
|
|
36
|
+
// 「缓存」之间没有对比词,否定仍属于 A → true。任务示例写的是「缓存 → false」,
|
|
37
|
+
// 与规则正文矛盾;这里取规则正文,保住「问题是缓存」 vs 「不是缓存而是队列」
|
|
38
|
+
// 这类真阳性。若要两侧皆 false,把含对比词子句里片段 0 的标记也跳过即可。
|
|
39
|
+
assert.equal(polarityAt('不是缓存的问题而是队列的问题', '缓存'), true)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
test('polarityAt: 而不是 passes the negation forward to what follows', () => {
|
|
43
|
+
// 「而不是」引出的片段继承一个否定:队列是否定侧、缓存不是——
|
|
44
|
+
// 「用缓存而不是队列」与「统一用缓存」不再误报冲突。
|
|
45
|
+
assert.equal(polarityAt('用缓存而不是队列', '队列'), true)
|
|
46
|
+
assert.equal(polarityAt('用缓存而不是队列', '缓存'), false)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
test('polarityAt: English markers, word-bounded', () => {
|
|
50
|
+
assert.equal(polarityAt('I no longer play tennis', 'tennis'), true)
|
|
51
|
+
assert.equal(polarityAt('I play tennis every weekend', 'tennis'), false)
|
|
52
|
+
// \b 生效:not 不命中 another 这类词内片段
|
|
53
|
+
assert.equal(polarityAt('another deploy window', 'deploy'), false)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('polarityAt: anchor absent or empty is false; deterministic on repeat', () => {
|
|
57
|
+
assert.equal(polarityAt('用户不希望每次部署失败都发告警通知', '监控'), false, 'anchor not in text')
|
|
58
|
+
assert.equal(polarityAt('用户不希望每次部署失败都发告警通知', ''), false, 'empty anchor')
|
|
59
|
+
const once = polarityAt('项目截止日期是5月1日,别忘了', '截止日期')
|
|
60
|
+
assert.equal(polarityAt('项目截止日期是5月1日,别忘了', '截止日期'), once, 'same input, same output')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('polarityAt: multiple anchor occurrences — any negated clause wins (conservative)', () => {
|
|
64
|
+
// 第一处出现在干净子句、第二处出现在否定子句 → 否定侧。
|
|
65
|
+
assert.equal(polarityAt('部署窗口照旧,别改部署窗口', '部署窗口'), true)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// —— §4.8 negationPolarity(整文本口径,原样保留)——
|
|
69
|
+
|
|
70
|
+
test('negationPolarity: whole-text ruler unchanged', () => {
|
|
71
|
+
assert.equal(negationPolarity('不发告警'), true)
|
|
72
|
+
assert.equal(negationPolarity('每次都发告警'), false)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// —— §4.8 globalConflictCheck:锚点化 negation 分支 ——
|
|
76
|
+
|
|
77
|
+
// 误报修复对。实测 pairFeatures:charDice=0.625(≥0.55,走到 negation 分支)、
|
|
78
|
+
// containment=0(不触发豁免)、titleDice=0.333(<0.8,value 分支也不触发)。
|
|
79
|
+
// 旧口径下 a 侧整文本带「别」→ negationPolarity 为 true,b 侧 false → 误报
|
|
80
|
+
// 'negation';新口径锚点(共享 token 里最长的 3 字 trigram)落在干净子句 → null。
|
|
81
|
+
test('globalConflictCheck: negation in an unrelated clause is no longer a conflict', () => {
|
|
82
|
+
const a = { title: '备份日程', content: '项目截止日期是5月1日,别忘了' }
|
|
83
|
+
const b = { title: '备份周期', content: '项目截止日期是5月10日' }
|
|
84
|
+
const features = pairFeatures(a, b)
|
|
85
|
+
// 门槛自证:这条用例确实走进了被改造的 negation 分支,且旧口径会误报。
|
|
86
|
+
assert.ok(features.charDice >= 0.55 && features.charDice < 0.95, `charDice ${features.charDice}`)
|
|
87
|
+
assert.ok(features.containment < 0.92, `containment ${features.containment}`)
|
|
88
|
+
assert.notEqual(negationPolarity(a.content), negationPolarity(b.content), 'old ruler would flag this pair')
|
|
89
|
+
assert.equal(globalConflictCheck(a, b), null)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// 真阳性保持对(与 curator-pairing 既有断言同一对,独立再放一份)。实测
|
|
93
|
+
// charDice=0.7568(≥0.55)、titleDice=0.333;锚点落在唯一子句,b 侧「不」
|
|
94
|
+
// 单标记 → 否定侧,a 侧无标记 → 极性不同 → 仍报 'negation'。
|
|
95
|
+
test('globalConflictCheck: same-clause negation stays a conflict (true positive)', () => {
|
|
96
|
+
const a = { title: '告警偏好', content: '用户希望每次部署失败都发告警通知' }
|
|
97
|
+
const b = { title: '告警设置', content: '用户不希望每次部署失败都发告警通知' }
|
|
98
|
+
const features = pairFeatures(a, b)
|
|
99
|
+
assert.ok(features.charDice >= 0.55 && features.charDice < 0.95, `charDice ${features.charDice}`)
|
|
100
|
+
assert.equal(globalConflictCheck(a, b), 'negation')
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
// 双重否定对。实测 charDice=0.6875(≥0.55);共享 token 最长者落在「不是
|
|
104
|
+
// 不喜欢」子句(「我对香菜」trigram),标记计数 2 → 偶数翻回肯定 → 双侧同
|
|
105
|
+
// 极性 → 不再误报。旧口径 a 侧整文本带「不」→ 误报 'negation'。
|
|
106
|
+
test('globalConflictCheck: double negation is not a conflict', () => {
|
|
107
|
+
const a = { title: '饮食偏好', content: '我对香菜不是不喜欢,是能接受的' }
|
|
108
|
+
const b = { title: '口味偏好', content: '我对香菜是喜欢,是能接受的' }
|
|
109
|
+
const features = pairFeatures(a, b)
|
|
110
|
+
assert.ok(features.charDice >= 0.55 && features.charDice < 0.95, `charDice ${features.charDice}`)
|
|
111
|
+
assert.ok(features.containment < 0.92, `containment ${features.containment}`)
|
|
112
|
+
assert.notEqual(negationPolarity(a.content), negationPolarity(b.content), 'old ruler would flag this pair')
|
|
113
|
+
assert.equal(globalConflictCheck(a, b), null)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
// 无共享锚点回退。实测 charDice=0.8333(≥0.55),但 tokenize 无任何共享 token
|
|
117
|
+
// (ab-cd vs ab / cd、ef-gh vs ef / gh,latin 连接符只在整 token 时保留)→
|
|
118
|
+
// 锚点为空 → 回退整文本 negationPolarity 对比 → b 侧 'not' → 仍报 'negation'。
|
|
119
|
+
test('globalConflictCheck: no shared token falls back to the whole-text ruler', () => {
|
|
120
|
+
const a = { title: 'note', content: 'ab-cd ef gh' }
|
|
121
|
+
const b = { title: 'note2', content: 'ab cd ef-gh not' }
|
|
122
|
+
const features = pairFeatures(a, b)
|
|
123
|
+
assert.ok(features.charDice >= 0.55 && features.charDice < 0.95, `charDice ${features.charDice}`)
|
|
124
|
+
assert.notEqual(negationPolarity(a.content), negationPolarity(b.content), 'b side carries "not"')
|
|
125
|
+
assert.equal(globalConflictCheck(a, b), 'negation')
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
test('globalConflictCheck: deterministic — same pair, same verdict twice', () => {
|
|
129
|
+
const a = { title: '告警偏好', content: '用户希望每次部署失败都发告警通知' }
|
|
130
|
+
const b = { title: '告警设置', content: '用户不希望每次部署失败都发告警通知' }
|
|
131
|
+
assert.equal(globalConflictCheck(a, b), globalConflictCheck(a, b))
|
|
132
|
+
const c = { title: '备份日程', content: '项目截止日期是5月1日,别忘了' }
|
|
133
|
+
const d = { title: '备份周期', content: '项目截止日期是5月10日' }
|
|
134
|
+
assert.deepEqual([globalConflictCheck(c, d), globalConflictCheck(c, d)], [null, null])
|
|
135
|
+
})
|
|
@@ -0,0 +1,290 @@
|
|
|
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
|
+
import { registerHooks } from 'node:module'
|
|
7
|
+
|
|
8
|
+
// P1-1 召回缓存测试。两部分:
|
|
9
|
+
// 1) 纯单元:lib/recall-cache.js 的 LRU/TTL/代数/wrap 去重/fail-open/键规范化;
|
|
10
|
+
// 2) 接线:managedRecall 的缓存命中、写路径失效、local-fallback 不缓存。
|
|
11
|
+
// managedRecall 不是导出函数,接线行为从导出入口 privateRecall(purpose:
|
|
12
|
+
// 'automatic',不触发 touchAccess 写)覆盖,mock 手法仿 tests/managed-memory.test.mjs:
|
|
13
|
+
// 在导入任何生产模块前用 registerHooks 把 ./memu.js 换成内存桥。
|
|
14
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-memu-recall-cache-'))
|
|
15
|
+
process.env.DSH_MEMU_HOME = home
|
|
16
|
+
process.env.DSH_MEMU_MEMORY_HOME = home
|
|
17
|
+
|
|
18
|
+
const calls = []
|
|
19
|
+
const warnings = []
|
|
20
|
+
globalThis.__recallCacheTest = {
|
|
21
|
+
async commit(args) { calls.push({ op: 'commit', ...args }); return { ok: true } },
|
|
22
|
+
async retrieve(args) { calls.push({ op: 'retrieve', ...args }); return retrieveHook(args) },
|
|
23
|
+
async forget(args) { calls.push({ op: 'forget', ...args }); return { deleted: 1, segments: 1 } },
|
|
24
|
+
async listFiles() { return { recall_files: [], resources: [], raw: null } },
|
|
25
|
+
}
|
|
26
|
+
let retrieveHook = () => ({ files: [], segments: [], resources: [], raw: null })
|
|
27
|
+
const engineSource = 'const bridge = globalThis.__recallCacheTest; export const commit = bridge.commit, retrieve = bridge.retrieve, forget = bridge.forget, listFiles = bridge.listFiles, closeMemuResident = () => 0, prewarmMemuResident = async () => false;'
|
|
28
|
+
const hooks = registerHooks({
|
|
29
|
+
resolve(specifier, context, nextResolve) {
|
|
30
|
+
if (specifier === './memu.js') {
|
|
31
|
+
return { url: 'data:text/javascript,' + encodeURIComponent(engineSource), shortCircuit: true }
|
|
32
|
+
}
|
|
33
|
+
return nextResolve(specifier, context)
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const { createRecallCache, recallCache, recallCacheKey } = await import('../lib/recall-cache.js')
|
|
38
|
+
const state = await import('../lib/state.js')
|
|
39
|
+
const vp = await import('../lib/vector-profile.js')
|
|
40
|
+
const paths = await import('../lib/paths.js')
|
|
41
|
+
const memory = await import('../lib/memory.js')
|
|
42
|
+
|
|
43
|
+
// ---------------------------------------------------------------- 纯单元部分
|
|
44
|
+
|
|
45
|
+
test('LRU 容量驱逐:max=2 放 3 个,最旧(未刷新)的先被逐', () => {
|
|
46
|
+
const cache = createRecallCache({ max: 2 })
|
|
47
|
+
cache.set('a', { v: 'a' })
|
|
48
|
+
cache.set('b', { v: 'b' })
|
|
49
|
+
assert.deepEqual(cache.get('a'), { v: 'a' }, '命中把 a 刷成最新')
|
|
50
|
+
cache.set('c', { v: 'c' })
|
|
51
|
+
assert.equal(cache.get('b'), null, 'b 是最旧的,被驱逐')
|
|
52
|
+
assert.deepEqual(cache.get('c'), { v: 'c' })
|
|
53
|
+
assert.deepEqual(cache.get('a'), { v: 'a' })
|
|
54
|
+
const stats = cache.stats()
|
|
55
|
+
assert.equal(stats.size, 2)
|
|
56
|
+
assert.equal(stats.evictions, 1)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('TTL 过期:注入假时钟,到点即失效并计逐出', () => {
|
|
60
|
+
let now = 1_000
|
|
61
|
+
const cache = createRecallCache({ ttlMs: 100, now: () => now })
|
|
62
|
+
cache.set('k', { v: 1 })
|
|
63
|
+
now = 1_099
|
|
64
|
+
assert.deepEqual(cache.get('k'), { v: 1 }, '到期前一刻仍有效')
|
|
65
|
+
now = 1_100
|
|
66
|
+
assert.equal(cache.get('k'), null, 'now >= 存入时刻+ttl 即过期')
|
|
67
|
+
assert.equal(cache.stats().evictions, 1, '过期即逐出')
|
|
68
|
+
assert.equal(cache.stats().misses, 1)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('bumpGeneration:旧键立即失联;在途 producer 落回旧代,不污染新代', async () => {
|
|
72
|
+
const cache = createRecallCache()
|
|
73
|
+
cache.set('k', { v: 'old' })
|
|
74
|
+
cache.bumpGeneration()
|
|
75
|
+
assert.equal(cache.get('k'), null, 'bump 后旧键立即失联')
|
|
76
|
+
assert.equal(cache.stats().generations, 1)
|
|
77
|
+
|
|
78
|
+
let release
|
|
79
|
+
const gate = new Promise((resolve) => { release = resolve })
|
|
80
|
+
let runs = 0
|
|
81
|
+
const inflight = cache.wrap('k', async () => { runs += 1; await gate; return { v: 'in-flight' } })
|
|
82
|
+
cache.bumpGeneration()
|
|
83
|
+
release()
|
|
84
|
+
assert.deepEqual(await inflight, { v: 'in-flight' }, '在途请求照常拿到自己的结果')
|
|
85
|
+
assert.equal(cache.get('k'), null, '旧代落地的结果在新代不可见')
|
|
86
|
+
let secondRuns = 0
|
|
87
|
+
const fresh = await cache.wrap('k', async () => { secondRuns += 1; return { v: 'fresh' } })
|
|
88
|
+
assert.deepEqual(fresh, { v: 'fresh' }, '新代重新计算,绝不命中旧值')
|
|
89
|
+
assert.equal(runs + secondRuns, 2, '旧代结果没有回流成新代缓存')
|
|
90
|
+
cache.bumpGeneration()
|
|
91
|
+
assert.equal(cache.stats().size, 0, '下一次 bump 把旧代残留清掉')
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('wrap 的 promise 去重:并发两次同 key,producer 只执行一次', async () => {
|
|
95
|
+
const cache = createRecallCache()
|
|
96
|
+
let runs = 0
|
|
97
|
+
let release
|
|
98
|
+
const gate = new Promise((resolve) => { release = resolve })
|
|
99
|
+
const producer = async () => { runs += 1; await gate; return { n: runs } }
|
|
100
|
+
const first = cache.wrap('k', producer)
|
|
101
|
+
const joined = cache.wrap('k', producer)
|
|
102
|
+
assert.equal(first, joined, '同 key 在途合并复用同一个 promise')
|
|
103
|
+
assert.equal(cache.stats().inflight, 1)
|
|
104
|
+
release()
|
|
105
|
+
const [x, y] = await Promise.all([first, joined])
|
|
106
|
+
assert.equal(runs, 1)
|
|
107
|
+
assert.deepEqual(x, y)
|
|
108
|
+
assert.equal(cache.stats().inflight, 0)
|
|
109
|
+
const stats = cache.stats()
|
|
110
|
+
assert.equal(stats.misses, 1)
|
|
111
|
+
assert.equal(stats.hits, 1, '在途合并计为一次命中')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
test('producer 抛错:不缓存、原样透传,下次重新执行', async () => {
|
|
115
|
+
const cache = createRecallCache()
|
|
116
|
+
let runs = 0
|
|
117
|
+
await assert.rejects(
|
|
118
|
+
cache.wrap('k', async () => { runs += 1; throw new Error('producer boom') }),
|
|
119
|
+
/producer boom/,
|
|
120
|
+
)
|
|
121
|
+
assert.equal(runs, 1)
|
|
122
|
+
assert.equal(cache.stats().errors, 0, 'producer 的业务错误不是缓存自身故障')
|
|
123
|
+
assert.equal(cache.stats().size, 0, '错误结果不入缓存')
|
|
124
|
+
const value = await cache.wrap('k', async () => { runs += 1; return { ok: true } })
|
|
125
|
+
assert.deepEqual(value, { ok: true })
|
|
126
|
+
assert.equal(runs, 2, '上次失败没有留下缓存')
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test('缓存自身故障 fail-open:错误计数与 onError 留痕,绝不影响取值', () => {
|
|
130
|
+
const seen = []
|
|
131
|
+
const cache = createRecallCache({ onError: (info) => seen.push(info) })
|
|
132
|
+
// 值不可 structuredClone(含函数)→ set 失败开放,计数不抛出。
|
|
133
|
+
cache.set('bad', { fn: () => {} })
|
|
134
|
+
assert.equal(cache.get('bad'), null, '写失败的键按未命中处理')
|
|
135
|
+
assert.equal(cache.stats().size, 0)
|
|
136
|
+
// 假时钟爆炸 → get 失败开放,返回 null。
|
|
137
|
+
let boom = false
|
|
138
|
+
const clocky = createRecallCache({ now: () => { if (boom) throw new Error('clock broke'); return 1 } })
|
|
139
|
+
clocky.set('k', { v: 1 })
|
|
140
|
+
boom = true
|
|
141
|
+
assert.equal(clocky.get('k'), null)
|
|
142
|
+
assert.match(clocky.stats().lastError, /get: clock broke/)
|
|
143
|
+
assert.ok(seen.some((info) => info.op === 'set'), 'onError 把吞没的故障暴露给调用方')
|
|
144
|
+
assert.ok(cache.stats().errors >= 1)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
test('键规范化:NFKC+trim+lowercase 归一,结构字段参与键', () => {
|
|
148
|
+
const base = { query: 'ABC', topK: 5, libraryId: 'lib', byId: false, route: 'managed-local', generation: 'gen:1:ab', revision: 3 }
|
|
149
|
+
assert.equal(recallCacheKey(base), recallCacheKey({ ...base, query: ' abc ' }), '首尾空格与大小写归一')
|
|
150
|
+
assert.equal(recallCacheKey(base), recallCacheKey({ ...base, query: 'ABC' }), 'NFKC 折叠全角')
|
|
151
|
+
assert.equal(recallCacheKey(base), recallCacheKey({ ...base, topK: '5' }), 'topK 数值归一')
|
|
152
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, query: 'abcd' }), '不同 query 不同键')
|
|
153
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, topK: 6 }), '不同 topK 不同键')
|
|
154
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, libraryId: 'lib2' }), '不同 libraryId 不同键')
|
|
155
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, route: 'remote-api' }), '不同 route 不同键')
|
|
156
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, generation: 'gen:2:cd' }), '向量代数变化换键')
|
|
157
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, revision: 4 }), '写路径 revision 变化换键')
|
|
158
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, automatic: true }), 'automatic 语义不同换键')
|
|
159
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, sessionId: 's2' }), '会话可见性不同换键')
|
|
160
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, domain: 'rp' }), '域过滤不同换键')
|
|
161
|
+
assert.notEqual(recallCacheKey(base), recallCacheKey({ ...base, context: { characterId: 'hero' } }), '绑定上下文不同换键')
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
test('invalidate:按规范化 query 精确失效,其他 query 不受牵连', async () => {
|
|
165
|
+
const cache = createRecallCache()
|
|
166
|
+
const keyOf = (q) => recallCacheKey({ query: q, topK: 4, libraryId: 'lib', route: 'remote-api' })
|
|
167
|
+
await cache.wrap(keyOf('部署 窗口'), async () => ({ v: 1 }))
|
|
168
|
+
await cache.wrap(keyOf('咖啡偏好'), async () => ({ v: 2 }))
|
|
169
|
+
assert.equal(cache.invalidate('deploy-x'), 0)
|
|
170
|
+
assert.equal(cache.invalidate(' 部署 窗口 '), 1, 'trim + lowercase 归一后精确命中')
|
|
171
|
+
assert.equal(cache.get(keyOf('部署 窗口')), null)
|
|
172
|
+
assert.deepEqual(cache.get(keyOf('咖啡偏好')), { v: 2 }, '别的 query 不被牵连')
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
test('模块级单例存在且具备全部公开方法', () => {
|
|
176
|
+
for (const method of ['get', 'set', 'bumpGeneration', 'invalidate', 'clear', 'stats', 'wrap', 'setErrorHandler']) {
|
|
177
|
+
assert.equal(typeof recallCache[method], 'function', method)
|
|
178
|
+
}
|
|
179
|
+
assert.deepEqual(Object.keys(recallCache.stats()).sort(),
|
|
180
|
+
['errors', 'evictions', 'generations', 'hits', 'inflight', 'lastError', 'misses', 'size'])
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
// ---------------------------------------------------------------- 接线部分
|
|
184
|
+
|
|
185
|
+
let serial = 0
|
|
186
|
+
function entry(content, extra = {}) {
|
|
187
|
+
return { status: 'active', title: content, content, layer: 'long_term', strength: 1,
|
|
188
|
+
createdAt: '2026-10-01T00:00:00.000Z', updatedAt: '2026-10-01T00:00:00.000Z', ...extra }
|
|
189
|
+
}
|
|
190
|
+
function fixture(entries = {}) {
|
|
191
|
+
serial += 1
|
|
192
|
+
const sessionId = 'cache-' + serial
|
|
193
|
+
const cwd = path.join(home, 'project-' + serial)
|
|
194
|
+
const binding = state.ensureSession(sessionId, { cwd, agentPreset: 'coding' })
|
|
195
|
+
state.setSessionBinding(sessionId, { useLibrary: true, useGlobal: true, domainOverride: 'coding' })
|
|
196
|
+
state.savePrivateIndex(binding.libraryId, { entries })
|
|
197
|
+
return { sessionId, libraryId: binding.libraryId, exec: { agent: { session: { header: { id: sessionId, cwd, agentPreset: 'coding' } } } } }
|
|
198
|
+
}
|
|
199
|
+
function activate(libraryIds = []) {
|
|
200
|
+
const profile = vp.profileFromCatalog('bge-small-zh-v1.5-int8')
|
|
201
|
+
const databases = vp.buildDatabaseSet({ profile, generation: 1, libraryIds })
|
|
202
|
+
fs.mkdirSync(path.join(home, 'libraries'), { recursive: true })
|
|
203
|
+
for (const row of [databases.global, ...Object.values(databases.libraries)]) fs.writeFileSync(vp.resolveVectorPath(row.path), '')
|
|
204
|
+
vp.updateVectorStateSync(current => ({ ...current, generation: 1, requested: null, pending: null,
|
|
205
|
+
active: { status: 'active', generation: 1, fingerprint: profile.fingerprint, profile, databases } }))
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const retrieveCalls = () => calls.filter((call) => call.op === 'retrieve').length
|
|
209
|
+
|
|
210
|
+
test.beforeEach(() => {
|
|
211
|
+
state.updateSettings({ memoryBackend: 'api', vectorSource: 'local', relevanceThreshold: 0, privateTopK: 5 })
|
|
212
|
+
state.saveGlobalIndex({ entries: {} })
|
|
213
|
+
calls.length = 0
|
|
214
|
+
warnings.length = 0
|
|
215
|
+
retrieveHook = () => ({ files: [], segments: [], resources: [], raw: null })
|
|
216
|
+
paths.setWarnSink((message) => warnings.push(String(message)))
|
|
217
|
+
})
|
|
218
|
+
test.after(() => {
|
|
219
|
+
hooks.deregister()
|
|
220
|
+
delete globalThis.__recallCacheTest
|
|
221
|
+
paths.setWarnSink(null)
|
|
222
|
+
fs.rmSync(home, { recursive: true, force: true })
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
// purpose 用 'automatic'(每轮注入的真正热路径):显式召回会 touchAccess 写索引,
|
|
226
|
+
// 自己就会推进 revision——那是正确行为,但不适合演示命中。
|
|
227
|
+
test('接线:相同参数的两次召回,第二次命中缓存不再调 retrieveImpl', async () => {
|
|
228
|
+
const f = fixture({ 'mem-needle': entry('needle local match'), 'mem-orbit': entry('orbital mechanics') })
|
|
229
|
+
activate([f.libraryId])
|
|
230
|
+
retrieveHook = () => ({ files: [{ name: 'mem-orbit' }], segments: [], resources: [] })
|
|
231
|
+
const first = await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 8, purpose: 'automatic' })
|
|
232
|
+
assert.equal(first.recallRoute, 'managed-vector-rrf')
|
|
233
|
+
assert.equal(retrieveCalls(), 1)
|
|
234
|
+
const second = await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 8, purpose: 'automatic' })
|
|
235
|
+
assert.equal(second.recallRoute, 'managed-vector-rrf', '缓存值带着原 recallRoute 语义')
|
|
236
|
+
assert.equal(retrieveCalls(), 1, '第二次没有再进语义召回')
|
|
237
|
+
assert.deepEqual(second.files.map((file) => file.name), first.files.map((file) => file.name), '返回相同的 files')
|
|
238
|
+
assert.deepEqual(new Set(second.files.map((file) => file.name)), new Set(['mem-needle', 'mem-orbit']))
|
|
239
|
+
assert.equal(state.getSessionBinding(f.sessionId).lastRecallError, undefined, '命中路径照常清降级信号')
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
test('接线:写入索引后 revision 推进,第三次召回重新调 retrieveImpl 并拿到新记忆', async () => {
|
|
243
|
+
const f = fixture({ 'mem-needle': entry('needle local match'), 'mem-orbit': entry('orbital mechanics') })
|
|
244
|
+
activate([f.libraryId])
|
|
245
|
+
retrieveHook = () => ({ files: [{ name: 'mem-orbit' }], segments: [], resources: [] })
|
|
246
|
+
await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 8, purpose: 'automatic' })
|
|
247
|
+
await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 8, purpose: 'automatic' })
|
|
248
|
+
assert.equal(retrieveCalls(), 1)
|
|
249
|
+
// 写路径失效:真实写收敛点(savePrivateIndex → memoryRevision 自增)改动键。
|
|
250
|
+
const index = state.loadPrivateIndex(f.libraryId)
|
|
251
|
+
index.entries['mem-fresh'] = entry('needle written just now')
|
|
252
|
+
state.savePrivateIndex(f.libraryId, index)
|
|
253
|
+
retrieveHook = () => ({ files: [{ name: 'mem-fresh' }], segments: [], resources: [] })
|
|
254
|
+
const third = await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 8, purpose: 'automatic' })
|
|
255
|
+
assert.equal(retrieveCalls(), 2, '写入后缓存失效,语义召回真实重跑')
|
|
256
|
+
assert.ok(third.files.some((file) => file.name === 'mem-fresh'), '拿到的是写入后的新世界,不是 stale 缓存')
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
test('接线:local-fallback 不缓存——失败的召回不会把降级结果放进缓存', async () => {
|
|
260
|
+
const f = fixture({ 'mem-needle': entry('needle local match') })
|
|
261
|
+
activate([f.libraryId])
|
|
262
|
+
retrieveHook = () => { throw new Error('semantic leg down') }
|
|
263
|
+
const failed = await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 8, purpose: 'automatic' })
|
|
264
|
+
assert.equal(failed.recallRoute, 'local-fallback')
|
|
265
|
+
assert.equal(failed.errors.length, 1, 'fallback 带着 errors 信号')
|
|
266
|
+
assert.equal(retrieveCalls(), 1)
|
|
267
|
+
retrieveHook = () => ({ files: [{ name: 'mem-orbit' }], segments: [], resources: [] })
|
|
268
|
+
const healthy = await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 8, purpose: 'automatic' })
|
|
269
|
+
assert.equal(healthy.recallRoute, 'managed-vector-rrf', '健康结果真实重算(失败那次没有占住键)')
|
|
270
|
+
assert.equal(retrieveCalls(), 2, 'producer 抛错不缓存,第二次仍会执行')
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
test('接线:query 大小写/首尾空格不同命中同一键', async () => {
|
|
274
|
+
const f = fixture({ 'mem-needle': entry('needle local match'), 'mem-orbit': entry('orbital mechanics') })
|
|
275
|
+
activate([f.libraryId])
|
|
276
|
+
retrieveHook = () => ({ files: [{ name: 'mem-orbit' }], segments: [], resources: [] })
|
|
277
|
+
await memory.privateRecall({ exec: f.exec, query: 'Needle', topK: 8, purpose: 'automatic' })
|
|
278
|
+
const again = await memory.privateRecall({ exec: f.exec, query: ' needle ', topK: 8, purpose: 'automatic' })
|
|
279
|
+
assert.equal(retrieveCalls(), 1, '规范化后命中同一缓存键')
|
|
280
|
+
assert.equal(again.recallRoute, 'managed-vector-rrf')
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
test('接线:topK 不同不共享缓存(融合截断上限随 topK 变化)', async () => {
|
|
284
|
+
const f = fixture({ 'mem-needle': entry('needle local match'), 'mem-orbit': entry('orbital mechanics') })
|
|
285
|
+
activate([f.libraryId])
|
|
286
|
+
retrieveHook = () => ({ files: [{ name: 'mem-orbit' }], segments: [], resources: [] })
|
|
287
|
+
await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 8, purpose: 'automatic' })
|
|
288
|
+
await memory.privateRecall({ exec: f.exec, query: 'needle', topK: 3, purpose: 'automatic' })
|
|
289
|
+
assert.equal(retrieveCalls(), 2, 'topK 参与键,两种截断各算各的')
|
|
290
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// dsh-llm-pi-ai 的测试桩:整理 fork 自定义模型 route(lib/fork-model.js)在测试进程里
|
|
2
|
+
// 拉不到宿主包,loader(tests/loader.mjs)把该 peer 依赖映射到这里。只保证「PiAiAdapter
|
|
3
|
+
// 是可构造的类、构造 options 会被记录」——构造/探测/注册的真实逻辑由 fork-model.test.mjs
|
|
4
|
+
// 用注入的 loader stub(mock llm + 注入 PiAiAdapter)逐分支覆盖,这里只让 private.js 的
|
|
5
|
+
// 生产接线(默认 loader)在测试里走通成功路径。
|
|
6
|
+
export class PiAiAdapter {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
globalThis.__dshMemuLastPiAiAdapterOptions = options
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const name = 'llm-pi-ai'
|
|
13
|
+
export const inject = ['llm']
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import {
|
|
4
|
+
normalizeAndLower,
|
|
5
|
+
tokenize,
|
|
6
|
+
tokenizeStats,
|
|
7
|
+
tokenizeV2,
|
|
8
|
+
TEST_CASES,
|
|
9
|
+
tokenStreamV2,
|
|
10
|
+
} from '../lib/tokenizer-v2.js'
|
|
11
|
+
|
|
12
|
+
// —— 召回升级 P0-1:Tokenizer V2(CJK 三层 n-gram + 实体保护)——
|
|
13
|
+
// 开关在 lib/curator-policy.js(TOKENIZER_V2);这里测 V2 本身的行为契约。
|
|
14
|
+
|
|
15
|
+
test('normalizeAndLower: NFKC 折叠全角并小写化', () => {
|
|
16
|
+
assert.equal(normalizeAndLower('ABc DEF'), 'abc def')
|
|
17
|
+
assert.equal(normalizeAndLower('Cache-COHERENCE'), 'cache-coherence')
|
|
18
|
+
assert.equal(normalizeAndLower(null), '')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('纯中文短句:4 字 run 出 unigram+bigram+trigram+完整 run,插入序确定', () => {
|
|
22
|
+
// Level 1 unigram → Level 2 bigram → Level 3 trigram → 完整 run 收尾
|
|
23
|
+
assert.deepEqual(tokenize('部署窗口'), [
|
|
24
|
+
'部', '署', '窗', '口',
|
|
25
|
+
'部署', '署窗', '窗口',
|
|
26
|
+
'部署窗', '署窗口',
|
|
27
|
+
'部署窗口',
|
|
28
|
+
])
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('纯中文短句:2 字 run 不重复收 bigram(流里 tf 不虚高)', () => {
|
|
32
|
+
assert.deepEqual(tokenize('缓存 缓存'), ['缓', '存', '缓存'])
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('中英混合:日期实体完整保留、英文同 V1 口径、CJK 三层展开', () => {
|
|
36
|
+
const tokens = tokenize('2026-11-05 AI 技术在快速发展')
|
|
37
|
+
// 实体:完整日期,不被拆散(Set 插入序让实体排最前)
|
|
38
|
+
assert.ok(tokens.includes('2026-11-05'))
|
|
39
|
+
// 英文:≥2 字符的 latin 词
|
|
40
|
+
assert.ok(tokens.includes('ai'))
|
|
41
|
+
// CJK:unigram/bigram/trigram 三层都在
|
|
42
|
+
assert.ok(tokens.includes('技') && tokens.includes('技术') && tokens.includes('速发展'))
|
|
43
|
+
// 长句 run(7 字 > 4)不出完整 run token
|
|
44
|
+
assert.ok(!tokens.includes('技术在快速发展'))
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('日期/时间实体:周一 / 星期一 / 周日 都能成整 token(空格 bug 已修)', () => {
|
|
48
|
+
assert.equal(tokenize('周一开会')[0], '周一')
|
|
49
|
+
assert.ok(tokenize('星期一例会').includes('星期一'))
|
|
50
|
+
assert.ok(tokenize('周日 拖地').includes('周日'))
|
|
51
|
+
assert.ok(tokenize('星期天大扫除').includes('星期天'))
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('日期/时间实体:YYYY-MM-DD 整体保留;M月D日 成整 token', () => {
|
|
55
|
+
assert.deepEqual(tokenize('截止 2026-11-05 完成'), ['2026-11-05', '截', '止', '截止', '完', '成', '完成'])
|
|
56
|
+
assert.ok(tokenize('11月5日 提交').includes('11月5日'))
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('数字/百分比:独立数字与百分比都成 token;标识符内部的数字不拆出噪声', () => {
|
|
60
|
+
assert.deepEqual(tokenize('增长 85%').slice(0, 2), ['85', '85%'])
|
|
61
|
+
// 'v2.today' 不拆出 '2';'30-40' 由英文连接词口径整收
|
|
62
|
+
assert.deepEqual(tokenize('use dsh-memu-memory_v2.today ok'), ['use', 'dsh-memu-memory_v2.today', 'ok'])
|
|
63
|
+
assert.ok(!tokenize('Qwen3-Embedding 在 2026 年发布').includes('3'))
|
|
64
|
+
assert.ok(tokenize('Qwen3-Embedding 在 2026 年发布').includes('2026'))
|
|
65
|
+
// 完整日期的子串(2026/11/05)不再作为数字实体重复出现
|
|
66
|
+
assert.ok(!tokenize('2026-11-05 提交').includes('2026'))
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
test('邮箱与 URL:整体成 token;URL 句尾标点被剥掉', () => {
|
|
70
|
+
assert.ok(tokenize('发到 user@example.com 即可').includes('user@example.com'))
|
|
71
|
+
assert.ok(tokenize('看 https://example.com/docs。').includes('https://example.com/docs'))
|
|
72
|
+
assert.ok(!tokenize('看 https://example.com/docs。').includes('https://example.com/docs。'))
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('单字 run:只保留 unigram;跨标点的 run 各自独立', () => {
|
|
76
|
+
assert.deepEqual([...tokenizeV2('猫')], ['猫'])
|
|
77
|
+
assert.deepEqual(tokenize('猫。狗'), ['猫', '狗'])
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test('长 run 的 trigram 边界:>4 字不出完整 run,首尾 trigram 都在', () => {
|
|
81
|
+
const tokens = tokenize('人工智能技术') // 6 字
|
|
82
|
+
assert.ok(tokens.includes('人工智'), '首个 trigram')
|
|
83
|
+
assert.ok(tokens.includes('能技术'), '末尾 trigram')
|
|
84
|
+
assert.ok(!tokens.includes('人工智能技术'), '长 run 不收完整串')
|
|
85
|
+
// 4 字 run 是唯一补收完整串的长度
|
|
86
|
+
assert.ok(tokenize('部署窗口').includes('部署窗口'))
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
test('英文与 NFKC 口径与 V1 完全一致:连接词、全角折叠、单字符丢弃', () => {
|
|
90
|
+
assert.deepEqual(tokenize('use dsh-memu-memory_v2.today ok'), ['use', 'dsh-memu-memory_v2.today', 'ok'])
|
|
91
|
+
assert.deepEqual(tokenize('a b cd'), ['cd'])
|
|
92
|
+
assert.deepEqual(tokenize('per-turn retry'), ['per-turn', 'retry'])
|
|
93
|
+
assert.deepEqual(tokenize('RISCV CACHE CACHE'), ['riscv', 'cache'])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
test('去重确定性:同输入两次调用结果一致(含 TEST_CASES 全部场景)', () => {
|
|
97
|
+
for (const { input } of TEST_CASES) {
|
|
98
|
+
assert.deepEqual(tokenize(input), tokenize(input), input)
|
|
99
|
+
assert.deepEqual([...tokenizeV2(input)], [...tokenizeV2(input)], input)
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test('tokenize 兼容接口:返回数组,且与 tokenizeV2 的 Set 展开一致', () => {
|
|
104
|
+
assert.equal(Array.isArray(tokenize('部署窗口')), true)
|
|
105
|
+
assert.deepEqual(tokenize('部署窗口'), [...tokenizeV2('部署窗口')])
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('tokenStreamV2 与 tokenizeV2 一致:流的去重集合 ⊆/= V2 的 Set,且含重复语义', () => {
|
|
109
|
+
const stream = tokenStreamV2('缓存 2026-11-05 缓存过期')
|
|
110
|
+
const set = tokenizeV2('缓存 2026-11-05 缓存过期')
|
|
111
|
+
for (const token of stream) assert.equal(set.has(token), true, `流 token ${token} 必须在 Set 中`)
|
|
112
|
+
assert.ok(stream.length >= set.size, '流不去重,长度不小于集合')
|
|
113
|
+
// 同一生成器:流去重后与 Set 完全相等
|
|
114
|
+
assert.deepEqual(new Set(stream), set)
|
|
115
|
+
// 重复出现的词在流里保留频率(BM25 tf 的来源)
|
|
116
|
+
const repeated = tokenStreamV2('缓存缓存')
|
|
117
|
+
assert.ok(repeated.filter((t) => t === '缓存').length >= 2)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('tokenizeStats:total 正确计数(数组 length),byType 覆盖全部 token', () => {
|
|
121
|
+
const stats = tokenizeStats('猫 2026-11-05 user@example.com https://a.io 85% 部署窗')
|
|
122
|
+
assert.equal(stats.total, 16)
|
|
123
|
+
const sum = Object.values(stats.byType).reduce((a, b) => a + b, 0)
|
|
124
|
+
assert.equal(sum, stats.total, 'byType 各类之和必须等于 total')
|
|
125
|
+
assert.equal(stats.byType.date_iso, 1)
|
|
126
|
+
assert.equal(stats.byType.email, 1)
|
|
127
|
+
assert.equal(stats.byType.url, 1)
|
|
128
|
+
assert.equal(stats.byType.percent, 1)
|
|
129
|
+
assert.equal(stats.byType.number, 1) // 85(日期子串不再算数字)
|
|
130
|
+
assert.equal(stats.byType.cjk_unigram, 4) // 猫/部/署/窗
|
|
131
|
+
assert.equal(stats.byType.cjk_bigram, 2) // 部署/署窗
|
|
132
|
+
assert.equal(stats.byType.cjk_trigram, 1) // 部署窗
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('TEST_CASES 导出形状不变:input/description 字段齐全且可分词', () => {
|
|
136
|
+
assert.ok(Array.isArray(TEST_CASES) && TEST_CASES.length >= 4)
|
|
137
|
+
for (const item of TEST_CASES) {
|
|
138
|
+
assert.equal(typeof item.input, 'string')
|
|
139
|
+
assert.equal(typeof item.description, 'string')
|
|
140
|
+
assert.ok(tokenizeV2(item.input).size > 0)
|
|
141
|
+
}
|
|
142
|
+
})
|