dsh-cortex-memory 0.4.14 → 0.4.15
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/CHANGELOG.md +2 -1
- package/README.md +6 -5
- package/bench/README.md +29 -0
- package/bench/results/semantic-cn.json +24 -0
- package/bench/semantic-cn.js +116 -0
- package/docs/install-windows.md +1 -2
- package/examples/README.md +2 -3
- package/examples/uninstall-cortex.ps1 +0 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# DSH Cortex
|
|
2
2
|
|
|
3
3
|
A local-first, layered memory engine for DeepSeek Harness.
|
|
4
4
|
|
|
@@ -9,14 +9,14 @@ core engine.
|
|
|
9
9
|
|
|
10
10
|
## Status
|
|
11
11
|
|
|
12
|
-
- Package: `dsh-cortex-memory@0.4.
|
|
12
|
+
- Package: `dsh-cortex-memory@0.4.15`
|
|
13
13
|
- Optional extractor: `dsh-cortex-extractors@0.3.4`
|
|
14
14
|
- DSH: `>=0.2.1-rc.2 <0.4.0`
|
|
15
15
|
- Node: `>=24`
|
|
16
16
|
- Tests: 433/433 (main)
|
|
17
17
|
- CI: GitHub Actions on Windows, Node 24
|
|
18
18
|
|
|
19
|
-
### What 0.4.
|
|
19
|
+
### What 0.4.15 changes
|
|
20
20
|
|
|
21
21
|
- **Evolution guard is configurable**: `autoActivate`, `maxPerDay`,
|
|
22
22
|
`minIntervalMs`, `canaryTicks` and `rollbackOnError` are now in the Config
|
|
@@ -78,14 +78,14 @@ taken; the installed bundle is still the Cortex memory engine.
|
|
|
78
78
|
## Install
|
|
79
79
|
|
|
80
80
|
```powershell
|
|
81
|
-
npm i dsh-cortex-memory@0.4.
|
|
81
|
+
npm i dsh-cortex-memory@0.4.15
|
|
82
82
|
npm i dsh-cortex-extractors@0.3.4 # optional OCR/ASR
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
Or let DSH add the bundles:
|
|
86
86
|
|
|
87
87
|
```powershell
|
|
88
|
-
dsh plugin --profile desktop add dsh-cortex-memory@0.4.
|
|
88
|
+
dsh plugin --profile desktop add dsh-cortex-memory@0.4.15
|
|
89
89
|
dsh plugin --profile desktop add dsh-cortex-extractors@0.3.4
|
|
90
90
|
```
|
|
91
91
|
|
|
@@ -220,3 +220,4 @@ MIT.
|
|
|
220
220
|
|
|
221
221
|
|
|
222
222
|
|
|
223
|
+
|
package/bench/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Cortex benchmarks
|
|
2
|
+
|
|
3
|
+
## semantic-cn.js
|
|
4
|
+
|
|
5
|
+
Reproducible controlled Chinese retrieval probe.
|
|
6
|
+
|
|
7
|
+
```powershell
|
|
8
|
+
node bench/semantic-cn.js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
It creates a temporary Cortex database, writes 12 controlled memories, runs
|
|
12
|
+
12 queries through full search and injection-tiered recall, and reports
|
|
13
|
+
recall@3, MRR@3, nDCG@3, p50 and p95. Output is written to
|
|
14
|
+
`bench/results/semantic-cn.json`.
|
|
15
|
+
|
|
16
|
+
This is deliberately labeled **synthetic-controlled**. It is not LoCoMo,
|
|
17
|
+
LongMemEval, MemoryAgentBench or an official score.
|
|
18
|
+
|
|
19
|
+
## LoCoMo / LongMemEval
|
|
20
|
+
|
|
21
|
+
Adapters live in `bench/locomo.js` and `bench/longmemeval.js`. They evaluate
|
|
22
|
+
retrieval only; do not claim official end-to-end QA scores from them.
|
|
23
|
+
|
|
24
|
+
## OCR / ASR
|
|
25
|
+
|
|
26
|
+
OCR and ASR microbenchmarks belong to `dsh-cortex-extractors`, because the
|
|
27
|
+
engine and model choices are external. The extractor package includes its
|
|
28
|
+
layout/TSV/empty-text/link tests. Real Chinese screenshot/audio accuracy needs
|
|
29
|
+
explicit samples and environments; no numbers are fabricated here.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "semantic-cn",
|
|
3
|
+
"kind": "synthetic-controlled",
|
|
4
|
+
"note": "Not an official LoCoMo/LongMemEval score. Controlled Chinese memories and queries; no real user data.",
|
|
5
|
+
"at": "2026-11-13T03:53:09.106Z",
|
|
6
|
+
"memories": 12,
|
|
7
|
+
"queries": 12,
|
|
8
|
+
"full": {
|
|
9
|
+
"n": 12,
|
|
10
|
+
"recallAt3": 1,
|
|
11
|
+
"mrrAt3": 0.9166666666666666,
|
|
12
|
+
"ndcgAt3": 0.9384882922619097,
|
|
13
|
+
"p50Ms": 1.31,
|
|
14
|
+
"p95Ms": 4.07
|
|
15
|
+
},
|
|
16
|
+
"inject": {
|
|
17
|
+
"n": 12,
|
|
18
|
+
"recallAt3": 1,
|
|
19
|
+
"mrrAt3": 0.9166666666666666,
|
|
20
|
+
"ndcgAt3": 0.9384882922619097,
|
|
21
|
+
"p50Ms": 1.11,
|
|
22
|
+
"p95Ms": 3.34
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Reproducible synthetic Chinese semantic retrieval probe.
|
|
4
|
+
*
|
|
5
|
+
* This is not LoCoMo/LongMemEval and must not be reported as an official
|
|
6
|
+
* benchmark score. It checks whether the current hybrid retrieval can find a
|
|
7
|
+
* known target among controlled distractors before/after the injection gate.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { performance } from 'node:perf_hooks';
|
|
13
|
+
import { createCortex } from '../src/service/cortex.js';
|
|
14
|
+
|
|
15
|
+
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-semantic-cn-'));
|
|
16
|
+
const cortex = createCortex({
|
|
17
|
+
config: {
|
|
18
|
+
dataRoot: dir,
|
|
19
|
+
dbFile: path.join(dir, 'cortex.sqlite'),
|
|
20
|
+
features: { autoFacts: false, llmFacts: false, autoGraphCandidates: false },
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const data = [
|
|
25
|
+
['便宜订阅', '涵儿喜欢便宜的音乐订阅,不买贵的套餐。'],
|
|
26
|
+
['白饭承诺', '涵儿答应下班带白饭,汐儿记得这个承诺。'],
|
|
27
|
+
['颈椎', '久坐后颈椎会疼,汐儿提醒涵儿起身。'],
|
|
28
|
+
['猫粮', '家里的猫只吃鸡肉味猫粮。'],
|
|
29
|
+
['雨天', '下雨天要带伞,涵儿常忘记。'],
|
|
30
|
+
['周末', '周末计划去河边散步。'],
|
|
31
|
+
['白饭', '白饭要热的,不要隔夜。'],
|
|
32
|
+
['订阅', '订阅续费前先看价格。'],
|
|
33
|
+
['颈椎', '颈椎疼时不要继续低头。'],
|
|
34
|
+
['猫', '猫晚上会在门口等。'],
|
|
35
|
+
['伞', '伞放在玄关的右边。'],
|
|
36
|
+
['散步', '散步时不看手机。'],
|
|
37
|
+
];
|
|
38
|
+
const written = new Map();
|
|
39
|
+
for (const [title, text] of data) {
|
|
40
|
+
const row = cortex.write({ text, title, kind: 'observation', explicit: true, importance: 0.72 });
|
|
41
|
+
written.set(title, row.trace.id);
|
|
42
|
+
}
|
|
43
|
+
const queries = [
|
|
44
|
+
['白饭', '白饭承诺'],
|
|
45
|
+
['便宜 订阅', '便宜订阅'],
|
|
46
|
+
['颈椎 疼', '颈椎'],
|
|
47
|
+
['猫 吃 什么', '猫粮'],
|
|
48
|
+
['下雨 带伞', '雨天'],
|
|
49
|
+
['周末 散步', '周末'],
|
|
50
|
+
['白饭 热', '白饭'],
|
|
51
|
+
['订阅 价格', '订阅'],
|
|
52
|
+
['低头 颈椎', '颈椎'],
|
|
53
|
+
['猫 晚上', '猫'],
|
|
54
|
+
['玄关 伞', '伞'],
|
|
55
|
+
['散步 手机', '散步'],
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
function metrics(rows) {
|
|
59
|
+
let hits = 0;
|
|
60
|
+
let mrr = 0;
|
|
61
|
+
let ndcg = 0;
|
|
62
|
+
for (const row of rows) {
|
|
63
|
+
const index = row.ids.indexOf(row.expected);
|
|
64
|
+
if (index >= 0) {
|
|
65
|
+
hits += 1;
|
|
66
|
+
mrr += 1 / (index + 1);
|
|
67
|
+
ndcg += 1 / Math.log2(index + 2);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const n = rows.length;
|
|
71
|
+
return {
|
|
72
|
+
n,
|
|
73
|
+
recallAt3: hits / n,
|
|
74
|
+
mrrAt3: mrr / n,
|
|
75
|
+
ndcgAt3: ndcg / n,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function run(mode) {
|
|
80
|
+
const rows = [];
|
|
81
|
+
const latencies = [];
|
|
82
|
+
for (const [query, expectedTitle] of queries) {
|
|
83
|
+
const started = performance.now();
|
|
84
|
+
const result = mode === 'inject'
|
|
85
|
+
? cortex.recallTiered({ query, limit: 3 }).result
|
|
86
|
+
: cortex.search(query, { limit: 3 });
|
|
87
|
+
latencies.push(performance.now() - started);
|
|
88
|
+
rows.push({ query, expected: written.get(expectedTitle), ids: result.items.map((item) => item.id) });
|
|
89
|
+
}
|
|
90
|
+
latencies.sort((a, b) => a - b);
|
|
91
|
+
const p50 = latencies[Math.floor(latencies.length * 0.5)] ?? null;
|
|
92
|
+
const p95 = latencies[Math.max(0, Math.ceil(latencies.length * 0.95) - 1)] ?? null;
|
|
93
|
+
return { ...metrics(rows), p50Ms: Math.round(p50 * 100) / 100, p95Ms: Math.round(p95 * 100) / 100 };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const full = run('full');
|
|
98
|
+
const injected = run('inject');
|
|
99
|
+
const result = {
|
|
100
|
+
name: 'semantic-cn',
|
|
101
|
+
kind: 'synthetic-controlled',
|
|
102
|
+
note: 'Not an official LoCoMo/LongMemEval score. Controlled Chinese memories and queries; no real user data.',
|
|
103
|
+
at: new Date().toISOString(),
|
|
104
|
+
memories: data.length,
|
|
105
|
+
queries: queries.length,
|
|
106
|
+
full,
|
|
107
|
+
inject: injected,
|
|
108
|
+
};
|
|
109
|
+
const out = path.join(import.meta.dirname, 'results');
|
|
110
|
+
mkdirSync(out, { recursive: true });
|
|
111
|
+
writeFileSync(path.join(out, 'semantic-cn.json'), JSON.stringify(result, null, 2) + '\n', 'utf8');
|
|
112
|
+
console.log(JSON.stringify(result, null, 2));
|
|
113
|
+
} finally {
|
|
114
|
+
cortex.close();
|
|
115
|
+
rmSync(dir, { recursive: true, force: true });
|
|
116
|
+
}
|
package/docs/install-windows.md
CHANGED
|
@@ -92,7 +92,7 @@ dsh plugin --profile desktop remove dsh-cortex
|
|
|
92
92
|
|
|
93
93
|
```powershell
|
|
94
94
|
powershell -ExecutionPolicy Bypass -File .\examples\uninstall-cortex.ps1 `
|
|
95
|
-
-Dsh "
|
|
95
|
+
-Dsh "D:\path\to\dsh.cmd" -Profile <profile>
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
脚本只删 `- id: cortex` 段,保留其他 patch,并跑一次 `--dump-config`;不删 dataRoot。已手动移除时也会跳过 remove、继续清 patch。
|
|
@@ -142,4 +142,3 @@ dsh --profile <profile> --dump-config > $null
|
|
|
142
142
|
- 零运行时 npm 依赖;SQLite 用 Node 内置。
|
|
143
143
|
- Windows 路径手写 `C:\...` 即可;包内没有 shell 脚本。
|
|
144
144
|
- 不修改全局 patch,不覆盖系统提示,不碰 shiori。
|
|
145
|
-
|
package/examples/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
```powershell
|
|
13
13
|
powershell -ExecutionPolicy Bypass -File .\examples\setup-cortex-bge.ps1 `
|
|
14
|
-
-Dsh "
|
|
14
|
+
-Dsh "D:\path\to\dsh.cmd" `
|
|
15
15
|
-Profile cortex-bge `
|
|
16
16
|
-Package "C:\path\to\dsh-cortex-memory-0.1.0.tgz"
|
|
17
17
|
```
|
|
@@ -58,7 +58,7 @@ dim: 1024
|
|
|
58
58
|
|
|
59
59
|
```powershell
|
|
60
60
|
powershell -ExecutionPolicy Bypass -File .\examples\uninstall-cortex.ps1 `
|
|
61
|
-
-Dsh "
|
|
61
|
+
-Dsh "D:\path\to\dsh.cmd" `
|
|
62
62
|
-Profile cortex-bge
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -70,4 +70,3 @@ powershell -ExecutionPolicy Bypass -File .\examples\uninstall-cortex.ps1 `
|
|
|
70
70
|
4. **不删 dataRoot**
|
|
71
71
|
|
|
72
72
|
如果已经手动移除,脚本会跳过 remove,仍清理残留 patch。
|
|
73
|
-
|