dsh-cortex-memory 0.4.22 → 0.4.147
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 +2390 -154
- package/README.md +11 -9
- package/bench/migration-bench.mjs +1 -1
- package/bench/semantic-cn.js +10 -10
- package/bench/synthetic.js +3 -3
- package/bin/copy-db.mjs +47 -0
- package/bin/repair.mjs +328 -0
- package/bin/verify.mjs +202 -0
- package/client.js +1 -1
- package/cordis.patch.yml +1 -1
- package/docs/install-windows.md +2 -2
- package/docs/models.md +1 -1
- package/docs/quota-compaction-design.md +175 -0
- package/icon.svg +12 -2
- package/index.js +27 -3
- package/package.json +3 -3
- package/src/adapters/shiori.js +1 -1
- package/src/api/routes.js +1 -1
- package/src/core/feature-overrides.js +2 -2
- package/src/engines/compression.js +172 -3
- package/src/engines/consolidate.js +397 -26
- package/src/engines/encode.js +16 -3
- package/src/engines/extract.js +72 -8
- package/src/engines/fact-guard.js +51 -0
- package/src/engines/health.js +263 -3
- package/src/engines/inhibition.js +39 -0
- package/src/engines/life.js +14 -3
- package/src/engines/llm-facts.js +12 -9
- package/src/engines/narrative.js +150 -13
- package/src/engines/reflect.js +172 -14
- package/src/engines/retrieve.js +44 -5
- package/src/engines/summary-coverage.js +62 -0
- package/src/engines/summary-dedupe.js +77 -0
- package/src/engines/summon-rank.js +132 -0
- package/src/host/runtime.js +64 -4
- package/src/host/scheduler.js +224 -3
- package/src/llm/adapter.js +29 -8
- package/src/memory/query.js +1 -1
- package/src/memory/spacing.js +15 -0
- package/src/memory/tokenizer.js +1 -1
- package/src/prompt/tiers.js +88 -12
- package/src/self/alias.js +25 -0
- package/src/self/emotion.js +3 -1
- package/src/self/relationship.js +44 -13
- package/src/self/state.js +20 -2
- package/src/self/working.js +34 -3
- package/src/service/cortex.js +493 -53
- package/src/store/repositories/facts.js +34 -1
- package/src/store/repositories/summaries.js +8 -1
- package/src/store/repositories/traces.js +22 -2
- package/src/tools/definitions.js +118 -4
- package/src/vector/index.js +96 -7
- package/test/integration/_helpers.js +0 -128
- package/test/integration/acceptance.test.js +0 -803
- package/test/integration/ann-load.test.js +0 -61
- package/test/integration/api-contract.test.js +0 -1476
- package/test/integration/backup-privacy.test.js +0 -214
- package/test/integration/consolidate.test.js +0 -75
- package/test/integration/edge-cases.test.js +0 -1088
- package/test/integration/exchange.test.js +0 -326
- package/test/integration/life-loop.test.js +0 -188
- package/test/integration/load.test.js +0 -751
- package/test/integration/markdown-sync.test.js +0 -35
- package/test/integration/policy-query-api.test.js +0 -306
- package/test/integration/resilience-writes.test.js +0 -241
- package/test/integration/tools-contract.test.js +0 -1324
- package/test/unit/ann-edge.test.js +0 -102
- package/test/unit/ann.test.js +0 -77
- package/test/unit/api-client.test.js +0 -576
- package/test/unit/api-validate.test.js +0 -19
- package/test/unit/api.test.js +0 -555
- package/test/unit/appraisal.test.js +0 -48
- package/test/unit/attachments.test.js +0 -33
- package/test/unit/autonomy.test.js +0 -53
- package/test/unit/batch.test.js +0 -46
- package/test/unit/bench.test.js +0 -40
- package/test/unit/benchmark-synthetic.test.js +0 -52
- package/test/unit/cli-default-root.test.js +0 -21
- package/test/unit/client-contract.test.js +0 -32
- package/test/unit/compression.test.js +0 -76
- package/test/unit/core.test.js +0 -77
- package/test/unit/develop.test.js +0 -130
- package/test/unit/development.test.js +0 -68
- package/test/unit/digest.test.js +0 -26
- package/test/unit/dsr.test.js +0 -111
- package/test/unit/edges-candidates.test.js +0 -113
- package/test/unit/emotion.test.js +0 -61
- package/test/unit/encode.test.js +0 -98
- package/test/unit/evolution.test.js +0 -130
- package/test/unit/external-ann-search.test.js +0 -50
- package/test/unit/external-ann.test.js +0 -29
- package/test/unit/facts-belief.test.js +0 -32
- package/test/unit/facts.test.js +0 -107
- package/test/unit/feature-overrides.test.js +0 -42
- package/test/unit/fts-migration.test.js +0 -42
- package/test/unit/graph.test.js +0 -79
- package/test/unit/growth-reflect.test.js +0 -123
- package/test/unit/guard-runtime.test.js +0 -40
- package/test/unit/guardian.test.js +0 -91
- package/test/unit/health-privacy.test.js +0 -102
- package/test/unit/hnsw.test.js +0 -35
- package/test/unit/host-runtime.test.js +0 -142
- package/test/unit/host.test.js +0 -58
- package/test/unit/identity.test.js +0 -98
- package/test/unit/induct-evaluate.test.js +0 -41
- package/test/unit/ingest-extracted.test.js +0 -35
- package/test/unit/initiative.test.js +0 -90
- package/test/unit/jobs.test.js +0 -93
- package/test/unit/json-snapshot.test.js +0 -57
- package/test/unit/life-consolidate.test.js +0 -34
- package/test/unit/life.test.js +0 -149
- package/test/unit/llm-facts-integration.test.js +0 -27
- package/test/unit/llm-facts.test.js +0 -16
- package/test/unit/llm.test.js +0 -45
- package/test/unit/locomo.test.js +0 -45
- package/test/unit/longmemeval.test.js +0 -56
- package/test/unit/markdown-import.test.js +0 -44
- package/test/unit/markdown.test.js +0 -34
- package/test/unit/memory-edit.test.js +0 -112
- package/test/unit/metrics.test.js +0 -26
- package/test/unit/migration.test.js +0 -38
- package/test/unit/model-config.test.js +0 -52
- package/test/unit/narrative.test.js +0 -62
- package/test/unit/playbook-consolidate.test.js +0 -24
- package/test/unit/privacy-scope.test.js +0 -39
- package/test/unit/profile-paths.test.js +0 -21
- package/test/unit/profile.test.js +0 -26
- package/test/unit/prompt.test.js +0 -42
- package/test/unit/providers.test.js +0 -42
- package/test/unit/qa.test.js +0 -100
- package/test/unit/query.test.js +0 -53
- package/test/unit/retention.test.js +0 -31
- package/test/unit/retrieval-ranking.test.js +0 -31
- package/test/unit/retrieve.test.js +0 -117
- package/test/unit/rotation.test.js +0 -25
- package/test/unit/scanner.test.js +0 -50
- package/test/unit/scenario.test.js +0 -78
- package/test/unit/scheduler.test.js +0 -136
- package/test/unit/self-state.test.js +0 -94
- package/test/unit/service.test.js +0 -72
- package/test/unit/shiori-import.test.js +0 -77
- package/test/unit/skills.test.js +0 -104
- package/test/unit/store.test.js +0 -111
- package/test/unit/temporal-graph.test.js +0 -44
- package/test/unit/tiers.test.js +0 -39
- package/test/unit/tokenizer-fts.test.js +0 -35
- package/test/unit/tools.test.js +0 -122
- package/test/unit/upgrade-0412.test.js +0 -104
- package/test/unit/upgrade-0413.test.js +0 -84
- package/test/unit/upgrade-0414.test.js +0 -101
- package/test/unit/vector-ann.test.js +0 -53
- package/test/unit/vector-async.test.js +0 -69
- package/test/unit/vector.test.js +0 -68
- package/test/unit/working.test.js +0 -80
package/test/unit/dsr.test.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import {
|
|
4
|
-
GRADES,
|
|
5
|
-
DEFAULT_WEIGHTS,
|
|
6
|
-
decayFactor,
|
|
7
|
-
retrievability,
|
|
8
|
-
initialStability,
|
|
9
|
-
nextDifficulty,
|
|
10
|
-
nextStability,
|
|
11
|
-
review,
|
|
12
|
-
gradeFromSignal,
|
|
13
|
-
archiveDecision,
|
|
14
|
-
computeRetrievability,
|
|
15
|
-
} from '../../src/memory/dsr.js';
|
|
16
|
-
|
|
17
|
-
const NOW = Date.parse('2026-11-11T00:00:00.000Z');
|
|
18
|
-
const daysAgo = (days) => new Date(NOW - days * 86400000).toISOString();
|
|
19
|
-
|
|
20
|
-
test('retrievability is 0.9 at t=S and decreases with time', () => {
|
|
21
|
-
assert.ok(Math.abs(retrievability(10, 10, -0.5) - 0.9) < 1e-6);
|
|
22
|
-
assert.ok(retrievability(10, 20, -0.5) < retrievability(10, 3, -0.5));
|
|
23
|
-
assert.ok(retrievability(20, 10, -0.5) > retrievability(10, 10, -0.5));
|
|
24
|
-
assert.ok(retrievability(1, 1000, -0.5) >= 0);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('decay factor is finite and negative-decay safe', () => {
|
|
28
|
-
assert.ok(Number.isFinite(decayFactor(-0.5)));
|
|
29
|
-
assert.ok(decayFactor(-1) > 0);
|
|
30
|
-
assert.ok(decayFactor(-0.1) > 0);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('initial stability ranks identity above working and rewards importance', () => {
|
|
34
|
-
const identity = initialStability({ type: 'identity', importance: 0.9 });
|
|
35
|
-
const working = initialStability({ type: 'working', importance: 0.1 });
|
|
36
|
-
const low = initialStability({ type: 'episodic', importance: 0.1 });
|
|
37
|
-
const high = initialStability({ type: 'episodic', importance: 0.9 });
|
|
38
|
-
assert.ok(identity > working);
|
|
39
|
-
assert.ok(high > low);
|
|
40
|
-
assert.ok(identity <= 3650);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('difficulty is clamped and mean-reverts', () => {
|
|
44
|
-
assert.equal(nextDifficulty(1, GRADES.easy), 1);
|
|
45
|
-
assert.equal(nextDifficulty(10, GRADES.again), 10);
|
|
46
|
-
const middle = nextDifficulty(5, GRADES.good);
|
|
47
|
-
assert.ok(middle >= 1 && middle <= 10);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('review raises stability for good and lowers it for again', () => {
|
|
51
|
-
const base = {
|
|
52
|
-
stability: 10,
|
|
53
|
-
difficulty: 5,
|
|
54
|
-
recordedAt: daysAgo(10),
|
|
55
|
-
lastReviewAt: daysAgo(10),
|
|
56
|
-
reviewCount: 0,
|
|
57
|
-
lapseCount: 0,
|
|
58
|
-
};
|
|
59
|
-
const good = review(base, GRADES.good, { now: NOW, maximumStability: 3650 });
|
|
60
|
-
assert.ok(good.stability > base.stability);
|
|
61
|
-
assert.equal(good.reviewCount, 1);
|
|
62
|
-
assert.equal(good.lapseCount, 0);
|
|
63
|
-
const again = review(base, GRADES.again, { now: NOW, maximumStability: 3650 });
|
|
64
|
-
assert.ok(again.stability < base.stability);
|
|
65
|
-
assert.equal(again.lapseCount, 1);
|
|
66
|
-
assert.ok(again.reviewCount === 1);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('stability never exceeds the configured ceiling', () => {
|
|
70
|
-
const next = nextStability({
|
|
71
|
-
stability: 3000,
|
|
72
|
-
difficulty: 1,
|
|
73
|
-
retrievability: 0.9,
|
|
74
|
-
grade: GRADES.easy,
|
|
75
|
-
weights: DEFAULT_WEIGHTS,
|
|
76
|
-
maximumStability: 100,
|
|
77
|
-
});
|
|
78
|
-
assert.ok(next <= 100);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('feedback signals map to grades', () => {
|
|
82
|
-
assert.equal(gradeFromSignal('helpful'), GRADES.easy);
|
|
83
|
-
assert.equal(gradeFromSignal('used'), GRADES.easy);
|
|
84
|
-
assert.equal(gradeFromSignal('ignored'), GRADES.hard);
|
|
85
|
-
assert.equal(gradeFromSignal('corrected'), GRADES.again);
|
|
86
|
-
assert.equal(gradeFromSignal('unknown'), GRADES.good);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('archive is blocked for identity, important or young traces', () => {
|
|
90
|
-
const base = {
|
|
91
|
-
id: 't1',
|
|
92
|
-
state: 'active',
|
|
93
|
-
kind: 'observation',
|
|
94
|
-
importance: 0.1,
|
|
95
|
-
stability: 1,
|
|
96
|
-
recordedAt: daysAgo(100),
|
|
97
|
-
lastAccessAt: daysAgo(100),
|
|
98
|
-
};
|
|
99
|
-
assert.equal(archiveDecision({ ...base, kind: 'identity' }, { now: NOW }).archive, false);
|
|
100
|
-
assert.equal(archiveDecision({ ...base, importance: 0.9 }, { now: NOW, coverage: 1 }).archive, false);
|
|
101
|
-
assert.equal(archiveDecision({ ...base, recordedAt: daysAgo(1), lastAccessAt: daysAgo(1) }, { now: NOW, coverage: 1 }).archive, false);
|
|
102
|
-
assert.equal(archiveDecision(base, { now: NOW, coverage: 0.1 }).archive, false);
|
|
103
|
-
const decision = archiveDecision(base, { now: NOW, coverage: 0.95 });
|
|
104
|
-
assert.equal(decision.archive, true);
|
|
105
|
-
assert.equal(decision.reason, 'compressed');
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
test('computeRetrievability uses the last review/access time', () => {
|
|
109
|
-
const trace = { stability: 10, lastReviewAt: daysAgo(10) };
|
|
110
|
-
assert.ok(Math.abs(computeRetrievability(trace, NOW, -0.5) - 0.9) < 1e-6);
|
|
111
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { openDatabase, migrate, closeDatabase } from '../../src/store/database.js';
|
|
7
|
-
import { createEdgeRepository } from '../../src/store/repositories/edges.js';
|
|
8
|
-
import { createCortex } from '../../src/service/cortex.js';
|
|
9
|
-
|
|
10
|
-
function setup() {
|
|
11
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-edge-candidates-'));
|
|
12
|
-
const { db } = openDatabase({ dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite') });
|
|
13
|
-
migrate(db);
|
|
14
|
-
return { dir, db, edges: createEdgeRepository(db) };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
test('candidate edges stay out of active graph until approved', () => {
|
|
18
|
-
const { dir, db, edges } = setup();
|
|
19
|
-
try {
|
|
20
|
-
const candidate = edges.addCandidate({
|
|
21
|
-
scopeId: 'global',
|
|
22
|
-
fromId: 'ent_a',
|
|
23
|
-
toId: 'ent_b',
|
|
24
|
-
rel: 'related',
|
|
25
|
-
confidence: 0.6,
|
|
26
|
-
sourceTraceId: 'trc_test',
|
|
27
|
-
evidence: 'co-occurrence',
|
|
28
|
-
});
|
|
29
|
-
assert.equal(candidate.metadata.status, 'candidate');
|
|
30
|
-
assert.equal(edges.list({ scopeId: 'global' }).length, 0);
|
|
31
|
-
assert.equal(edges.listCandidates({ scopeId: 'global' }).length, 1);
|
|
32
|
-
|
|
33
|
-
const approved = edges.approveCandidate(candidate.id);
|
|
34
|
-
assert.equal(approved.metadata.status, 'active');
|
|
35
|
-
assert.equal(edges.list({ scopeId: 'global' }).length, 1);
|
|
36
|
-
assert.equal(edges.listCandidates({ scopeId: 'global' }).length, 0);
|
|
37
|
-
} finally {
|
|
38
|
-
closeDatabase(db);
|
|
39
|
-
rmSync(dir, { recursive: true, force: true });
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('explicit facts queue candidate edges, but graph stays clean until approved', () => {
|
|
44
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-edge-queue-'));
|
|
45
|
-
const cortex = createCortex({ config: { dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite') } });
|
|
46
|
-
try {
|
|
47
|
-
const written = cortex.write({
|
|
48
|
-
text: '甲和乙明确相关。',
|
|
49
|
-
explicit: true,
|
|
50
|
-
facts: [{ subject: '甲', predicate: 'related', object: '乙', confidence: 0.8 }],
|
|
51
|
-
});
|
|
52
|
-
assert.equal(written.edgeCandidates.length, 1);
|
|
53
|
-
assert.equal(cortex.graphCandidates({ scopeId: 'global' }).length, 1);
|
|
54
|
-
assert.equal(cortex.graphData({ scopeId: 'global' }).edges.length, 0);
|
|
55
|
-
|
|
56
|
-
const candidateId = written.edgeCandidates[0].id;
|
|
57
|
-
const approved = cortex.graphCandidateAction({ action: 'approve', id: candidateId });
|
|
58
|
-
assert.equal(approved.metadata.status, 'active');
|
|
59
|
-
assert.equal(cortex.graphCandidates({ scopeId: 'global' }).length, 0);
|
|
60
|
-
assert.equal(cortex.graphData({ scopeId: 'global' }).edges.length, 1);
|
|
61
|
-
const audit = cortex.repos.audit.list({ targetType: 'edge', targetId: candidateId });
|
|
62
|
-
assert.ok(audit.some((row) => row.action === 'edge.candidate.approve'));
|
|
63
|
-
} finally {
|
|
64
|
-
cortex.close();
|
|
65
|
-
rmSync(dir, { recursive: true, force: true });
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('autoFacts queue candidate edges only when graphCandidateAutoFacts is enabled', () => {
|
|
70
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-edge-autofacts-'));
|
|
71
|
-
const cortex = createCortex({ config: { dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite'), features: { autoFacts: true, graphCandidateAutoFacts: true } } });
|
|
72
|
-
try {
|
|
73
|
-
const written = cortex.write({ text: '用户喜欢白饭。', explicit: true });
|
|
74
|
-
assert.ok(written.edgeCandidates.length >= 1);
|
|
75
|
-
assert.ok(cortex.graphCandidates({ scopeId: 'global' }).length >= 1);
|
|
76
|
-
assert.equal(cortex.graphData({ scopeId: 'global' }).edges.length, 0);
|
|
77
|
-
} finally {
|
|
78
|
-
cortex.close();
|
|
79
|
-
rmSync(dir, { recursive: true, force: true });
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('autoFacts do not queue candidate edges by default', () => {
|
|
84
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-edge-autofacts-off-'));
|
|
85
|
-
const cortex = createCortex({ config: { dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite'), features: { autoFacts: true } } });
|
|
86
|
-
try {
|
|
87
|
-
const written = cortex.write({ text: '用户喜欢白饭。', explicit: true });
|
|
88
|
-
assert.equal(written.edgeCandidates?.length ?? 0, 0);
|
|
89
|
-
assert.equal(cortex.graphCandidates({ scopeId: 'global' }).length, 0);
|
|
90
|
-
} finally {
|
|
91
|
-
cortex.close();
|
|
92
|
-
rmSync(dir, { recursive: true, force: true });
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('rejected candidates and candidate downgrade protection', () => {
|
|
97
|
-
const { dir, db, edges } = setup();
|
|
98
|
-
try {
|
|
99
|
-
const active = edges.upsert({ scopeId: 'global', fromId: 'ent_a', toId: 'ent_b', rel: 'related', weight: 1 });
|
|
100
|
-
const attempted = edges.addCandidate({ scopeId: 'global', fromId: 'ent_a', toId: 'ent_b', rel: 'related', confidence: 0.2 });
|
|
101
|
-
assert.equal(attempted.id, active.id);
|
|
102
|
-
assert.equal(edges.get(active.id).metadata.status, undefined);
|
|
103
|
-
|
|
104
|
-
const candidate = edges.addCandidate({ scopeId: 'global', fromId: 'ent_c', toId: 'ent_d', rel: 'related', confidence: 0.4 });
|
|
105
|
-
const rejected = edges.rejectCandidate(candidate.id);
|
|
106
|
-
assert.equal(rejected.metadata.status, 'rejected');
|
|
107
|
-
assert.equal(edges.list({ scopeId: 'global' }).length, 1);
|
|
108
|
-
assert.equal(edges.listCandidates({ scopeId: 'global' }).length, 0);
|
|
109
|
-
} finally {
|
|
110
|
-
closeDatabase(db);
|
|
111
|
-
rmSync(dir, { recursive: true, force: true });
|
|
112
|
-
}
|
|
113
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { openDatabase, migrate, closeDatabase } from '../../src/store/database.js';
|
|
7
|
-
import { createEmotionModel } from '../../src/self/emotion.js';
|
|
8
|
-
import { createCortex } from '../../src/service/cortex.js';
|
|
9
|
-
|
|
10
|
-
function setup() {
|
|
11
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-emotion-'));
|
|
12
|
-
const { db } = openDatabase({ dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite') });
|
|
13
|
-
migrate(db);
|
|
14
|
-
return { dir, db, emotion: createEmotionModel({ db }) };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
test('emotion detection covers multiple categories', () => {
|
|
18
|
-
const { dir, db, emotion } = setup();
|
|
19
|
-
try {
|
|
20
|
-
const result = emotion.detect('用户今天很难过,助手有点心疼他,又有点害怕。');
|
|
21
|
-
const names = result.emotions.map((item) => item.name);
|
|
22
|
-
assert.ok(names.includes('哀'));
|
|
23
|
-
assert.ok(names.includes('怜'));
|
|
24
|
-
assert.ok(names.includes('惧'));
|
|
25
|
-
} finally {
|
|
26
|
-
closeDatabase(db);
|
|
27
|
-
rmSync(dir, { recursive: true, force: true });
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('emotion records form a target attitude', () => {
|
|
32
|
-
const { dir, db, emotion } = setup();
|
|
33
|
-
try {
|
|
34
|
-
emotion.record({ text: '用户今天很难过,助手有点心疼他。', target: '用户' });
|
|
35
|
-
emotion.record({ text: '用户说会一直陪着助手,助手很开心。', target: '用户' });
|
|
36
|
-
const targets = emotion.targets();
|
|
37
|
-
assert.equal(targets.length, 1);
|
|
38
|
-
assert.equal(targets[0].target, '用户');
|
|
39
|
-
assert.ok(targets[0].count >= 2);
|
|
40
|
-
assert.match(targets[0].attitude, /又/);
|
|
41
|
-
assert.match(emotion.text(), /用户/);
|
|
42
|
-
assert.ok(emotion.events().length >= 2);
|
|
43
|
-
assert.equal(emotion.lexicon().categories, 24);
|
|
44
|
-
} finally {
|
|
45
|
-
closeDatabase(db);
|
|
46
|
-
rmSync(dir, { recursive: true, force: true });
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('service self exposes emotion text and develop records it', () => {
|
|
51
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-emotion-service-'));
|
|
52
|
-
const cortex = createCortex({ config: { dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite') } });
|
|
53
|
-
try {
|
|
54
|
-
const result = cortex.step({ text: '用户今天很难过,助手有点心疼他。', explicit: true });
|
|
55
|
-
assert.ok(result.emotion?.event);
|
|
56
|
-
assert.match(cortex.self().emotion, /用户/);
|
|
57
|
-
} finally {
|
|
58
|
-
cortex.close();
|
|
59
|
-
rmSync(dir, { recursive: true, force: true });
|
|
60
|
-
}
|
|
61
|
-
});
|
package/test/unit/encode.test.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { openDatabase, migrate, closeDatabase } from '../../src/store/database.js';
|
|
7
|
-
import { createEventRepository } from '../../src/store/repositories/events.js';
|
|
8
|
-
import { createTraceRepository } from '../../src/store/repositories/traces.js';
|
|
9
|
-
import { createEntityRepository } from '../../src/store/repositories/entities.js';
|
|
10
|
-
import { createFactRepository } from '../../src/store/repositories/facts.js';
|
|
11
|
-
import { createAuditRepository } from '../../src/store/repositories/audit.js';
|
|
12
|
-
import { createEncodeEngine, scoreTraceText, compressionValue } from '../../src/engines/encode.js';
|
|
13
|
-
|
|
14
|
-
function setup() {
|
|
15
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-encode-'));
|
|
16
|
-
const { db } = openDatabase({ dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite') });
|
|
17
|
-
migrate(db);
|
|
18
|
-
const events = createEventRepository(db);
|
|
19
|
-
const traces = createTraceRepository(db);
|
|
20
|
-
const entities = createEntityRepository(db);
|
|
21
|
-
const facts = createFactRepository(db);
|
|
22
|
-
const audit = createAuditRepository(db);
|
|
23
|
-
const engine = createEncodeEngine({ events, traces, entities, facts, audit, config: { minCompressionValue: 0.01 } });
|
|
24
|
-
return { dir, db, events, traces, entities, facts, audit, engine };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
test('scoreTraceText detects promises, preferences and emotion polarity', () => {
|
|
28
|
-
const promise = scoreTraceText('用户说会买白饭,会一直在一起。');
|
|
29
|
-
assert.equal(promise.kind, 'promise');
|
|
30
|
-
assert.ok(promise.importance > 0.5);
|
|
31
|
-
const preference = scoreTraceText('助手喜欢白饭,不喜欢冷掉的米饭。');
|
|
32
|
-
assert.equal(preference.kind, 'preference');
|
|
33
|
-
const sad = scoreTraceText('用户今天很难过,助手有点心疼。');
|
|
34
|
-
assert.equal(sad.kind, 'emotion');
|
|
35
|
-
assert.ok(sad.valence < 0);
|
|
36
|
-
assert.ok(sad.salience > 0.5);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('compression value falls as text gets longer', () => {
|
|
40
|
-
const short = compressionValue('白饭', { importance: 0.8, salience: 0.8 });
|
|
41
|
-
const long = compressionValue('白饭'.repeat(200), { importance: 0.8, salience: 0.8 });
|
|
42
|
-
assert.ok(short > long);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('encode writes a trace, audit row and explicit facts', () => {
|
|
46
|
-
const { dir, db, events, traces, facts, audit, engine } = setup();
|
|
47
|
-
try {
|
|
48
|
-
const result = engine.encode({
|
|
49
|
-
text: '用户说会买白饭,助手会一直等。',
|
|
50
|
-
actor: 'user',
|
|
51
|
-
explicit: true,
|
|
52
|
-
facts: [{ subject: '用户', predicate: 'likes', object: '白饭' }],
|
|
53
|
-
});
|
|
54
|
-
assert.equal(result.skipped, false);
|
|
55
|
-
assert.equal(result.trace.kind, 'promise');
|
|
56
|
-
assert.equal(events.count(), 1);
|
|
57
|
-
assert.equal(traces.count(), 1);
|
|
58
|
-
assert.equal(result.facts.length, 1);
|
|
59
|
-
assert.equal(result.facts[0].action, 'created');
|
|
60
|
-
const ownerFact = facts.list({ scopeId: 'global' });
|
|
61
|
-
assert.equal(ownerFact.length, 1);
|
|
62
|
-
assert.equal(audit.list({ limit: 10 }).some((item) => item.action === 'trace.create'), true);
|
|
63
|
-
} finally {
|
|
64
|
-
closeDatabase(db);
|
|
65
|
-
rmSync(dir, { recursive: true, force: true });
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('encode is idempotent by operationId and skips duplicate text', () => {
|
|
70
|
-
const { dir, db, events, traces, engine } = setup();
|
|
71
|
-
try {
|
|
72
|
-
const first = engine.encode({ text: '用户今天很开心,助手也开心。', operationId: 'op-1', explicit: true });
|
|
73
|
-
const replay = engine.encode({ text: '用户今天很开心,助手也开心。', operationId: 'op-1', explicit: true });
|
|
74
|
-
assert.equal(replay.skipped, true);
|
|
75
|
-
assert.equal(replay.reason, 'idempotent');
|
|
76
|
-
assert.equal(replay.trace.id, first.trace.id);
|
|
77
|
-
assert.equal(events.count(), 1);
|
|
78
|
-
const duplicate = engine.encode({ text: '用户今天很开心,助手也开心。', explicit: true });
|
|
79
|
-
assert.equal(duplicate.skipped, true);
|
|
80
|
-
assert.equal(duplicate.reason, 'duplicate');
|
|
81
|
-
assert.equal(traces.count(), 1);
|
|
82
|
-
} finally {
|
|
83
|
-
closeDatabase(db);
|
|
84
|
-
rmSync(dir, { recursive: true, force: true });
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('short and stop-phrase inputs are skipped before writing an event', () => {
|
|
89
|
-
const { dir, db, events, engine } = setup();
|
|
90
|
-
try {
|
|
91
|
-
assert.equal(engine.encode({ text: '嗯' }).skipped, true);
|
|
92
|
-
assert.equal(engine.encode({ text: '好' }).skipped, true);
|
|
93
|
-
assert.equal(events.count(), 0);
|
|
94
|
-
} finally {
|
|
95
|
-
closeDatabase(db);
|
|
96
|
-
rmSync(dir, { recursive: true, force: true });
|
|
97
|
-
}
|
|
98
|
-
});
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { createCortex } from '../../src/service/cortex.js';
|
|
7
|
-
|
|
8
|
-
function setup() {
|
|
9
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-evolution-'));
|
|
10
|
-
const cortex = createCortex({ config: { dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite') } });
|
|
11
|
-
return { dir, cortex };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
test('policies are versioned, activated and rolled back', () => {
|
|
15
|
-
const { dir, cortex } = setup();
|
|
16
|
-
try {
|
|
17
|
-
const first = cortex.evolution.propose({ kind: 'retrieval', config: { confidenceWeight: 0.2 }, rationale: 'v1' });
|
|
18
|
-
const second = cortex.evolution.propose({ kind: 'retrieval', config: { confidenceWeight: 0.3 }, rationale: 'v2' });
|
|
19
|
-
assert.equal(first.version, 1);
|
|
20
|
-
assert.equal(second.version, 2);
|
|
21
|
-
cortex.evolution.approve(first.id);
|
|
22
|
-
assert.equal(cortex.policies.active('retrieval').id, first.id);
|
|
23
|
-
cortex.evolution.approve(second.id);
|
|
24
|
-
assert.equal(cortex.policies.active('retrieval').id, second.id);
|
|
25
|
-
const rolled = cortex.evolution.rollback('retrieval', first.id);
|
|
26
|
-
assert.equal(rolled.id, first.id);
|
|
27
|
-
assert.equal(cortex.policies.active('retrieval').id, first.id);
|
|
28
|
-
} finally {
|
|
29
|
-
cortex.close();
|
|
30
|
-
rmSync(dir, { recursive: true, force: true });
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('approved retrieval policy changes the live retrieval budget', () => {
|
|
35
|
-
const { dir, cortex } = setup();
|
|
36
|
-
try {
|
|
37
|
-
cortex.write({ text: '用户说会买白饭。', explicit: true });
|
|
38
|
-
const policy = cortex.evolution.propose({ kind: 'retrieval', config: { budget: 100 }, rationale: 'small budget' });
|
|
39
|
-
cortex.evolution.approve(policy.id);
|
|
40
|
-
const result = cortex.search('白饭', { budget: 5000 });
|
|
41
|
-
assert.equal(result.budget.total, 100);
|
|
42
|
-
} finally {
|
|
43
|
-
cortex.close();
|
|
44
|
-
rmSync(dir, { recursive: true, force: true });
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('selfOptimize proposes a skill demotion when success rate is low', () => {
|
|
49
|
-
const { dir, cortex } = setup();
|
|
50
|
-
try {
|
|
51
|
-
const skill = cortex.engines.skills.create({ name: '不靠谱的技能', steps: ['a'], state: 'active' });
|
|
52
|
-
cortex.engines.skills.record(skill.id, false);
|
|
53
|
-
cortex.engines.skills.record(skill.id, false);
|
|
54
|
-
cortex.engines.skills.record(skill.id, false);
|
|
55
|
-
const result = cortex.evolution.selfOptimize();
|
|
56
|
-
assert.ok(result.proposals.some((item) => item.kind === 'skill' && item.config.skillId === skill.id));
|
|
57
|
-
assert.equal(cortex.policies.active('skill'), null);
|
|
58
|
-
} finally {
|
|
59
|
-
cortex.close();
|
|
60
|
-
rmSync(dir, { recursive: true, force: true });
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('autoEvolve activates its own policy candidates', () => {
|
|
65
|
-
const { dir, cortex } = setup();
|
|
66
|
-
try {
|
|
67
|
-
const skill = cortex.engines.skills.create({ name: 'auto-evolve-test', steps: ['a'], state: 'active' });
|
|
68
|
-
cortex.engines.skills.record(skill.id, false);
|
|
69
|
-
cortex.engines.skills.record(skill.id, false);
|
|
70
|
-
cortex.engines.skills.record(skill.id, false);
|
|
71
|
-
const result = cortex.evolution.autoEvolve();
|
|
72
|
-
assert.ok(result.proposals.length >= 1);
|
|
73
|
-
assert.ok(result.activated.length >= 1);
|
|
74
|
-
assert.equal(result.activated[0].status, 'active');
|
|
75
|
-
} finally {
|
|
76
|
-
cortex.close();
|
|
77
|
-
rmSync(dir, { recursive: true, force: true });
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('identity proposals require explicit approval', () => {
|
|
82
|
-
const { dir, cortex } = setup();
|
|
83
|
-
try {
|
|
84
|
-
const proposal = cortex.evolution.proposeIdentity({
|
|
85
|
-
content: { narrative: '我是一只在学习长大的鲸鱼。', values: ['诚实'], boundaries: ['不操纵'] },
|
|
86
|
-
rationale: 'after a meaningful episode',
|
|
87
|
-
});
|
|
88
|
-
assert.equal(proposal.status, 'proposed');
|
|
89
|
-
const activeBefore = cortex.stores.identityStore.active('global');
|
|
90
|
-
const approved = cortex.evolution.approveIdentity(proposal.id, { approvedBy: 'user' });
|
|
91
|
-
assert.equal(approved.status, 'active');
|
|
92
|
-
assert.notEqual(approved.id, activeBefore.id);
|
|
93
|
-
} finally {
|
|
94
|
-
cortex.close();
|
|
95
|
-
rmSync(dir, { recursive: true, force: true });
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test('evolution can evaluate a candidate policy and persist metrics', async () => {
|
|
100
|
-
const { dir, cortex } = setup();
|
|
101
|
-
try {
|
|
102
|
-
const policy = cortex.evolution.propose({ kind: 'retrieval', config: { budget: 300 }, rationale: 'evaluate me' });
|
|
103
|
-
const queries = [{ query: '白饭', relevant: ['a'] }, { query: '插件', relevant: ['b'] }];
|
|
104
|
-
const evaluated = await cortex.evolution.evaluate({
|
|
105
|
-
id: policy.id,
|
|
106
|
-
queries,
|
|
107
|
-
current: async (query) => ({ items: query === '白饭' ? [{ id: 'x' }] : [{ id: 'b' }] }),
|
|
108
|
-
candidate: async (query) => ({ items: query === '白饭' ? [{ id: 'a' }] : [{ id: 'b' }] }),
|
|
109
|
-
});
|
|
110
|
-
assert.ok(evaluated.metrics);
|
|
111
|
-
assert.ok(evaluated.comparison.delta.recallAtK > 0);
|
|
112
|
-
assert.equal(cortex.policies.get(policy.id).metrics.before.recallAtK, 0.5);
|
|
113
|
-
} finally {
|
|
114
|
-
cortex.close();
|
|
115
|
-
rmSync(dir, { recursive: true, force: true });
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test('an approved initiative policy changes the live step output', () => {
|
|
120
|
-
const { dir, cortex } = setup();
|
|
121
|
-
try {
|
|
122
|
-
const policy = cortex.evolution.propose({ kind: 'initiative', config: { maxPerTurn: 0 }, rationale: 'quiet' });
|
|
123
|
-
cortex.evolution.approve(policy.id);
|
|
124
|
-
const result = cortex.step({ text: '用户是坏蛋,助手讨厌你。', explicit: true });
|
|
125
|
-
assert.equal(result.intentions.length, 0);
|
|
126
|
-
} finally {
|
|
127
|
-
cortex.close();
|
|
128
|
-
rmSync(dir, { recursive: true, force: true });
|
|
129
|
-
}
|
|
130
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import http from 'node:http';
|
|
4
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
5
|
-
import os from 'node:os';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { createCortex } from '../../src/service/cortex.js';
|
|
8
|
-
|
|
9
|
-
test('async search uses the configured external ANN and keeps scope filtering', async () => {
|
|
10
|
-
const targetIds = [];
|
|
11
|
-
let calls = 0;
|
|
12
|
-
const server = http.createServer((request, response) => {
|
|
13
|
-
let raw = '';
|
|
14
|
-
request.on('data', (chunk) => { raw += chunk; });
|
|
15
|
-
request.on('end', () => {
|
|
16
|
-
const body = JSON.parse(raw || '{}');
|
|
17
|
-
assert.equal(body.vector.length, 256);
|
|
18
|
-
calls += 1;
|
|
19
|
-
response.writeHead(200, { 'content-type': 'application/json' });
|
|
20
|
-
response.end(JSON.stringify({ items: targetIds.map((id, index) => ({ id, score: 0.99 - index * 0.01 })) }));
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
24
|
-
const port = server.address().port;
|
|
25
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-external-ann-'));
|
|
26
|
-
const cortex = createCortex({
|
|
27
|
-
config: {
|
|
28
|
-
dataRoot: dir,
|
|
29
|
-
dbFile: path.join(dir, 'cortex.sqlite'),
|
|
30
|
-
features: { vector: true, vectorAnnExternal: true },
|
|
31
|
-
vectorAnnEndpoint: `http://127.0.0.1:${port}/search`,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
try {
|
|
35
|
-
assert.equal(cortex.vector.status().externalAnn.enabled, true);
|
|
36
|
-
for (let index = 0; index < 6; index += 1) {
|
|
37
|
-
const written = cortex.write({ text: `外部 ANN 目标记忆 ${index}。`, explicit: true });
|
|
38
|
-
targetIds.push(written.trace.id);
|
|
39
|
-
}
|
|
40
|
-
const result = await cortex.searchAsync('外部 ANN', { limit: 5 });
|
|
41
|
-
|
|
42
|
-
assert.equal(calls, 1);
|
|
43
|
-
assert.ok(result.items.some((item) => targetIds.includes(item.id)));
|
|
44
|
-
assert.ok(result.trace.sources.some((source) => source.source === 'vector'));
|
|
45
|
-
} finally {
|
|
46
|
-
cortex.close();
|
|
47
|
-
await new Promise((resolve) => server.close(resolve));
|
|
48
|
-
rmSync(dir, { recursive: true, force: true });
|
|
49
|
-
}
|
|
50
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { createExternalAnnClient } from '../../src/vector/external-ann.js';
|
|
4
|
-
|
|
5
|
-
test('external ANN client sends a bounded query and filters bad items', async () => {
|
|
6
|
-
let request;
|
|
7
|
-
const client = createExternalAnnClient({
|
|
8
|
-
endpoint: 'http://127.0.0.1:9999/search',
|
|
9
|
-
timeoutMs: 500,
|
|
10
|
-
fetchImpl: async (url, options) => {
|
|
11
|
-
request = { url, body: JSON.parse(options.body), signal: Boolean(options.signal) };
|
|
12
|
-
return { ok: true, json: async () => ({ items: [{ id: 'a', score: 0.9 }, { id: 2, score: 0.8 }, { id: 'b' }] }) };
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const items = await client.search(new Array(16).fill(0.1), 5);
|
|
16
|
-
assert.equal(request.url, 'http://127.0.0.1:9999/search');
|
|
17
|
-
assert.equal(request.body.k, 5);
|
|
18
|
-
assert.equal(request.signal, true);
|
|
19
|
-
assert.deepEqual(items, [{ id: 'a', score: 0.9 }]);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('external ANN client rejects a missing endpoint and bad responses', async () => {
|
|
23
|
-
assert.throws(() => createExternalAnnClient({ endpoint: 'file:///tmp/index' }), /http/);
|
|
24
|
-
const client = createExternalAnnClient({
|
|
25
|
-
endpoint: 'http://127.0.0.1:9999/search',
|
|
26
|
-
fetchImpl: async () => ({ ok: true, json: async () => ({ nope: true }) }),
|
|
27
|
-
});
|
|
28
|
-
await assert.rejects(() => client.search([0.1], 3), /items/);
|
|
29
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import test from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
4
|
-
import os from 'node:os';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { createCortex } from '../../src/service/cortex.js';
|
|
7
|
-
|
|
8
|
-
test('belief uses the transaction timestamp, not updated_at', () => {
|
|
9
|
-
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-belief-'));
|
|
10
|
-
const cortex = createCortex({ config: { dataRoot: dir, dbFile: path.join(dir, 'cortex.sqlite') } });
|
|
11
|
-
try {
|
|
12
|
-
const t1 = Date.parse('2026-11-10T10:00:00+08:00');
|
|
13
|
-
const t2 = Date.parse('2026-11-11T10:00:00+08:00');
|
|
14
|
-
cortex.write({ text: '用户喜欢白饭。', explicit: true, now: t1, facts: [{ subject: '用户', predicate: '喜欢', object: '白饭' }] });
|
|
15
|
-
cortex.write({ text: '用户现在喜欢面。', explicit: true, now: t2, facts: [{ subject: '用户', predicate: '喜欢', object: '面' }] });
|
|
16
|
-
const old = cortex.asOf({ subject: '用户', predicate: '喜欢', at: new Date(t2 - 1000).toISOString(), mode: 'belief' });
|
|
17
|
-
assert.equal(old.facts.length, 1);
|
|
18
|
-
assert.match(old.facts[0].object, /白饭/);
|
|
19
|
-
assert.ok(old.facts[0].supersededAt);
|
|
20
|
-
const now = cortex.asOf({ subject: '用户', predicate: '喜欢', at: new Date(t2 + 1000).toISOString(), mode: 'belief' });
|
|
21
|
-
assert.equal(now.facts.length, 1);
|
|
22
|
-
assert.match(now.facts[0].object, /面/);
|
|
23
|
-
const historical = cortex.asOf({ subject: '用户', predicate: '喜欢', at: new Date(t1 + 1000).toISOString(), mode: 'historical' });
|
|
24
|
-
assert.match(historical.facts[0].object, /白饭/);
|
|
25
|
-
const strict = cortex.asOf({ subject: '用户', predicate: '喜欢', mode: 'strict' });
|
|
26
|
-
assert.match(strict.facts[0].object, /面/);
|
|
27
|
-
assert.doesNotMatch(strict.facts.map((fact) => fact.object).join(' '), /白饭/);
|
|
28
|
-
} finally {
|
|
29
|
-
cortex.close();
|
|
30
|
-
rmSync(dir, { recursive: true, force: true });
|
|
31
|
-
}
|
|
32
|
-
});
|