recallnest 2.3.0 → 2.6.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.
- package/CHANGELOG.md +187 -0
- package/README.md +49 -38
- package/README_CN.md +46 -31
- package/assets/ui/app.js +1031 -0
- package/assets/ui/index.html +224 -0
- package/assets/ui/styles.css +781 -0
- package/config.json.example +4 -1
- package/docs/api-reference.md +1291 -0
- package/docs/architecture.md +168 -0
- package/docs/connector-spec.md +126 -0
- package/eval/cases-canary.json +58 -0
- package/eval/cases-scope-robustness.json +278 -0
- package/eval/cases.json +117 -20
- package/package.json +25 -4
- package/src/__tests__/access-tracker-novelty.test.ts +304 -0
- package/src/__tests__/activity-counter.test.ts +125 -0
- package/src/__tests__/adaptive-fidelity.test.ts +102 -0
- package/src/__tests__/admission-control.test.ts +206 -0
- package/src/__tests__/anchor-generator.test.ts +67 -0
- package/src/__tests__/api-server-security.test.ts +102 -0
- package/src/__tests__/auto-consolidation.test.ts +168 -0
- package/src/__tests__/auto-recall.test.ts +131 -0
- package/src/__tests__/babel-integration.test.ts +144 -0
- package/src/__tests__/batch-dedup.test.ts +65 -0
- package/src/__tests__/belief-history.test.ts +220 -0
- package/src/__tests__/canary-eval.test.ts +114 -0
- package/src/__tests__/capture-engine.test.ts +1328 -0
- package/src/__tests__/capture-heuristic.test.ts +171 -0
- package/src/__tests__/cascade-forget.test.ts +210 -0
- package/src/__tests__/category-min-scores.test.ts +116 -0
- package/src/__tests__/cc8-cc1-essential-context.test.ts +298 -0
- package/src/__tests__/circuit-breaker.test.ts +99 -0
- package/src/__tests__/cluster-consolidation.test.ts +945 -0
- package/src/__tests__/confidence-metadata.test.ts +125 -0
- package/src/__tests__/confidence-tracker.test.ts +261 -0
- package/src/__tests__/conflict-advisor.test.ts +206 -0
- package/src/__tests__/conflict-escalation.test.ts +149 -0
- package/src/__tests__/conflict-lifecycle.test.ts +83 -0
- package/src/__tests__/conflict-output.test.ts +85 -0
- package/src/__tests__/conflict-store.test.ts +418 -0
- package/src/__tests__/connector-v1.test.ts +181 -0
- package/src/__tests__/consolidation-engine.test.ts +430 -0
- package/src/__tests__/constructive-retrieval.test.ts +509 -0
- package/src/__tests__/context-collapse-renderer.test.ts +214 -0
- package/src/__tests__/context-composer-pins.test.ts +64 -0
- package/src/__tests__/context-composer-task-selection.test.ts +24 -0
- package/src/__tests__/context-reconstructor.test.ts +65 -0
- package/src/__tests__/context-renderer.test.ts +91 -0
- package/src/__tests__/continuity-eval.test.ts +275 -0
- package/src/__tests__/continuity-schema.test.ts +97 -0
- package/src/__tests__/contracts.test.ts +262 -0
- package/src/__tests__/conversation-importer.test.ts +692 -0
- package/src/__tests__/core-recall-eval.test.ts +235 -0
- package/src/__tests__/core-summary.test.ts +109 -0
- package/src/__tests__/data-checkup.test.ts +276 -0
- package/src/__tests__/decay-exemption.test.ts +129 -0
- package/src/__tests__/dedup-actions.test.ts +58 -0
- package/src/__tests__/dedup-guard.test.ts +39 -0
- package/src/__tests__/deterministic-id.test.ts +39 -0
- package/src/__tests__/distill-lock.test.ts +305 -0
- package/src/__tests__/distill-session-argshape.test.ts +79 -0
- package/src/__tests__/doctor.test.ts +319 -0
- package/src/__tests__/dream-pipeline.test.ts +780 -0
- package/src/__tests__/drill-down.test.ts +108 -0
- package/src/__tests__/embedder.test.ts +122 -0
- package/src/__tests__/emotion-decay.test.ts +46 -0
- package/src/__tests__/emotion-detector.test.ts +56 -0
- package/src/__tests__/emotion-phase1-integration.test.ts +153 -0
- package/src/__tests__/emotion-retrieval.test.ts +56 -0
- package/src/__tests__/entity-resolver.test.ts +58 -0
- package/src/__tests__/env-config.test.ts +151 -0
- package/src/__tests__/error-signature-boost.test.ts +87 -0
- package/src/__tests__/error-signature.test.ts +95 -0
- package/src/__tests__/error-taxonomy.test.ts +129 -0
- package/src/__tests__/ethics-layer.test.ts +476 -0
- package/src/__tests__/event-segmenter.test.ts +153 -0
- package/src/__tests__/feature-flags-integration.test.ts +54 -0
- package/src/__tests__/frequency-tracker.test.ts +113 -0
- package/src/__tests__/freshness.test.ts +186 -0
- package/src/__tests__/graph-export.test.ts +489 -0
- package/src/__tests__/hotness-blend.test.ts +283 -0
- package/src/__tests__/ingest-chunking.test.ts +44 -0
- package/src/__tests__/ingest.test.ts +360 -0
- package/src/__tests__/interference-detector.test.ts +203 -0
- package/src/__tests__/kg-extractor.test.ts +192 -0
- package/src/__tests__/kg-store.test.ts +300 -0
- package/src/__tests__/llm-client-pivot.test.ts +628 -0
- package/src/__tests__/llm-consolidation.test.ts +226 -0
- package/src/__tests__/maintenance-locks.test.ts +189 -0
- package/src/__tests__/mcp-efficiency.test.ts +288 -0
- package/src/__tests__/mcp-related-scopes.test.ts +151 -0
- package/src/__tests__/memory-boundaries.test.ts +282 -0
- package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +345 -0
- package/src/__tests__/memory-evolution.test.ts +271 -0
- package/src/__tests__/memory-health-rebalance.test.ts +144 -0
- package/src/__tests__/memory-lint.test.ts +421 -0
- package/src/__tests__/memory-output.test.ts +215 -0
- package/src/__tests__/memory-promotion.test.ts +315 -0
- package/src/__tests__/migrate-dedup-ids.test.ts +65 -0
- package/src/__tests__/multi-vector.test.ts +242 -0
- package/src/__tests__/narrative-architecture.test.ts +456 -0
- package/src/__tests__/noise-filter.test.ts +205 -0
- package/src/__tests__/noise-prototype-bank.test.ts +280 -0
- package/src/__tests__/obsidian-connector.test.ts +363 -0
- package/src/__tests__/omitted-reporting.test.ts +98 -0
- package/src/__tests__/pending-review.test.ts +77 -0
- package/src/__tests__/pii-redact.test.ts +333 -0
- package/src/__tests__/pivot-apply.test.ts +373 -0
- package/src/__tests__/pivot-distill-supervisor.test.ts +457 -0
- package/src/__tests__/pivot-distill.test.ts +1178 -0
- package/src/__tests__/post-retrieval-filter.test.ts +178 -0
- package/src/__tests__/ppr-traversal.test.ts +256 -0
- package/src/__tests__/prediction-engine.test.ts +349 -0
- package/src/__tests__/predictive-prospective-memory.test.ts +416 -0
- package/src/__tests__/preference-guard-smoke.test.ts +211 -0
- package/src/__tests__/preference-matcher.test.ts +282 -0
- package/src/__tests__/preference-slots.test.ts +205 -0
- package/src/__tests__/prospective-memory.test.ts +283 -0
- package/src/__tests__/pull-from-macbook-sync-only.test.ts +679 -0
- package/src/__tests__/query-entity-detector.test.ts +171 -0
- package/src/__tests__/query-expander-alias.test.ts +146 -0
- package/src/__tests__/query-expander.test.ts +34 -0
- package/src/__tests__/recall-gate.test.ts +266 -0
- package/src/__tests__/recall-governor.test.ts +227 -0
- package/src/__tests__/recall-mode.test.ts +64 -0
- package/src/__tests__/resolve-db-path.test.ts +130 -0
- package/src/__tests__/resolve-tier.test.ts +64 -0
- package/src/__tests__/result-synthesizer.test.ts +198 -0
- package/src/__tests__/resume-context.test.ts +4898 -0
- package/src/__tests__/retrieval-eval.test.ts +163 -0
- package/src/__tests__/retrieval-trace.test.ts +213 -0
- package/src/__tests__/retriever-boundary-weight.test.ts +136 -0
- package/src/__tests__/retriever-lazy-init-dispatch.test.ts +123 -0
- package/src/__tests__/retroactive-boost.test.ts +223 -0
- package/src/__tests__/salience-scoring.test.ts +106 -0
- package/src/__tests__/scope-inventory.test.ts +200 -0
- package/src/__tests__/scope-policy.test.ts +69 -0
- package/src/__tests__/scope-suggester.test.ts +80 -0
- package/src/__tests__/session-checkpoint.test.ts +291 -0
- package/src/__tests__/session-distiller.test.ts +640 -0
- package/src/__tests__/session-gc.test.ts +215 -0
- package/src/__tests__/skill-engine.test.ts +552 -0
- package/src/__tests__/skill-promotion.test.ts +654 -0
- package/src/__tests__/skill-verifier.test.ts +122 -0
- package/src/__tests__/source-heartbeat.test.ts +250 -0
- package/src/__tests__/stable-context-length-contract.test.ts +62 -0
- package/src/__tests__/store-patch-metadata.test.ts +205 -0
- package/src/__tests__/store-read-consistency.test.ts +122 -0
- package/src/__tests__/store-schema-migration.test.ts +87 -0
- package/src/__tests__/store-scope-audit.test.ts +81 -0
- package/src/__tests__/store-upsert.test.ts +201 -0
- package/src/__tests__/supersede-chain.test.ts +154 -0
- package/src/__tests__/temporal-parser.test.ts +241 -0
- package/src/__tests__/temporal-validity.test.ts +160 -0
- package/src/__tests__/term-registry-terminal-roster.test.ts +127 -0
- package/src/__tests__/term-registry.test.ts +121 -0
- package/src/__tests__/tool-error-surfacing.test.ts +98 -0
- package/src/__tests__/tool-output-compressor.test.ts +160 -0
- package/src/__tests__/topic-tag.test.ts +113 -0
- package/src/__tests__/trusted-memory.test.ts +839 -0
- package/src/__tests__/ui-server-security.test.ts +93 -0
- package/src/__tests__/usage-tracker.test.ts +287 -0
- package/src/__tests__/version-manager.test.ts +213 -0
- package/src/__tests__/workflow-observation-skill-outcome.test.ts +352 -0
- package/src/__tests__/workflow-observation.test.ts +433 -0
- package/src/__tests__/write-verifier.test.ts +122 -0
- package/src/access-tracker.ts +90 -34
- package/src/activity-counter.ts +46 -18
- package/src/adaptive-retrieval.ts +11 -0
- package/src/aliases.ts +133 -0
- package/src/api-server.ts +36 -9
- package/src/audit-log.ts +4 -2
- package/src/auto-consolidation.ts +8 -3
- package/src/auto-gc.ts +85 -21
- package/src/auto-recall.ts +61 -1
- package/src/belief-history.ts +164 -0
- package/src/capture-engine.ts +142 -32
- package/src/cli.ts +268 -41
- package/src/confidence-tracker.ts +36 -18
- package/src/conflict-engine.ts +24 -3
- package/src/consolidation-engine.ts +255 -23
- package/src/context-composer-stable-selection.ts +7 -1
- package/src/context-composer.ts +8 -1
- package/src/data-checkup.ts +96 -7
- package/src/decay-engine.ts +59 -7
- package/src/distill-lock.ts +194 -15
- package/src/doctor.ts +13 -4
- package/src/dream-pipeline.ts +473 -41
- package/src/env-config.ts +118 -0
- package/src/error-signature.ts +153 -0
- package/src/error-taxonomy.ts +115 -0
- package/src/eval.ts +402 -14
- package/src/freshness.ts +192 -0
- package/src/http-request-policy.ts +148 -0
- package/src/idempotency.ts +8 -0
- package/src/ingest.ts +308 -12
- package/src/kg-extractor.ts +13 -3
- package/src/kg-store.ts +236 -44
- package/src/llm-client.ts +106 -11
- package/src/llm-consolidation.ts +2 -1
- package/src/mcp-server.ts +87 -1800
- package/src/mcp-tool-deps.ts +48 -0
- package/src/mcp-tools-advanced.ts +954 -0
- package/src/mcp-tools-core.ts +637 -0
- package/src/mcp-tools-governance.ts +475 -0
- package/src/memory-boundaries.ts +26 -3
- package/src/memory-evolution.ts +73 -1
- package/src/memory-health-rebalance.ts +4 -0
- package/src/memory-lint.ts +183 -10
- package/src/memory-output.ts +129 -4
- package/src/memory-promotion.ts +246 -0
- package/src/memory-schema.ts +25 -2
- package/src/memory-store-port.ts +46 -0
- package/src/multi-vector.ts +2 -1
- package/src/narrative-schema.ts +2 -1
- package/src/noise-filter.ts +57 -6
- package/src/noise-prototype-bank.ts +408 -0
- package/src/pii-detector.ts +207 -5
- package/src/pivot-apply.ts +399 -0
- package/src/preference-matcher.ts +37 -3
- package/src/query-expander.ts +90 -9
- package/src/recall-gate.ts +305 -0
- package/src/result-synthesizer.ts +2 -1
- package/src/retention-policy.ts +2 -1
- package/src/retrieval-profiles.ts +46 -4
- package/src/retriever.ts +354 -157
- package/src/retroactive-boost.ts +6 -2
- package/src/runtime-config.ts +78 -6
- package/src/scope-suggester.ts +113 -0
- package/src/session-distiller.ts +23 -2
- package/src/session-engine.ts +2 -1
- package/src/session-schema.ts +1 -0
- package/src/session-store.ts +5 -0
- package/src/skill-engine.ts +78 -0
- package/src/skill-promotion.ts +304 -48
- package/src/skill-schema.ts +16 -3
- package/src/skill-verifier.ts +152 -0
- package/src/store.ts +321 -57
- package/src/term-registry.ts +35 -0
- package/src/tool-output-compressor.ts +3 -1
- package/src/ui-server.ts +9 -1
- package/src/usage-tracker.ts +242 -0
- package/src/version-manager.ts +3 -2
- package/src/version.ts +19 -0
- package/src/workflow-observation-engine.ts +2 -1
- package/src/workflow-observation-schema.ts +2 -1
- package/src/workflow-observation-store.ts +6 -2
- package/.env +0 -4
- package/CLAUDE.md +0 -46
- package/config.json +0 -55
- package/daily-recall.sh +0 -110
- package/logs/daily-recall.error.log +0 -0
- package/logs/daily-recall.log +0 -60
- package/logs/ingest-2026-04-11.log +0 -110
- package/logs/ingest-2026-04-12.log +0 -90
- package/logs/ingest-2026-04-13.log +0 -87
- package/logs/launchagent-stderr.log +0 -0
- package/logs/launchagent-stdout.log +0 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import { runMemoryLint, formatMemoryLintReport, computeHealthScore, type MemoryLintReport } from "../memory-lint.js";
|
|
3
|
+
import type { MemoryEntry, MemoryStore } from "../store.js";
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Helpers
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
function makeEntry(overrides: Partial<MemoryEntry> & { id: string }): MemoryEntry {
|
|
10
|
+
return {
|
|
11
|
+
text: "test memory",
|
|
12
|
+
vector: [1, 0, 0, 0, 0],
|
|
13
|
+
category: "events",
|
|
14
|
+
scope: "project:test",
|
|
15
|
+
importance: 0.7,
|
|
16
|
+
timestamp: Date.now(),
|
|
17
|
+
metadata: JSON.stringify({
|
|
18
|
+
evolution: {
|
|
19
|
+
status: "active",
|
|
20
|
+
version: 1,
|
|
21
|
+
accessCount: 0,
|
|
22
|
+
lastAccessedAt: null,
|
|
23
|
+
supersededBy: null,
|
|
24
|
+
supersedes: null,
|
|
25
|
+
evolutionNote: null,
|
|
26
|
+
consolidatedInto: null,
|
|
27
|
+
contributedToPattern: null,
|
|
28
|
+
sourceMemories: [],
|
|
29
|
+
validFrom: Date.now(),
|
|
30
|
+
validUntil: null,
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
...overrides,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function createMockStore(entries: MemoryEntry[]): Pick<MemoryStore, "list" | "getVectors"> {
|
|
38
|
+
return {
|
|
39
|
+
// 复刻真实 store:list() 为性能不返回向量(vector: []),lint 需经 getVectors 补回。
|
|
40
|
+
// 旧 mock 直接返回带向量的 entry,与生产行为不符,曾掩盖矛盾/去重在生产哑火的 bug。
|
|
41
|
+
async list() { return entries.map(e => ({ ...e, vector: [] })); },
|
|
42
|
+
async getVectors(ids: string[]) {
|
|
43
|
+
const map = new Map<string, number[]>();
|
|
44
|
+
for (const e of entries) {
|
|
45
|
+
if (ids.includes(e.id) && e.vector.length > 0) map.set(e.id, e.vector);
|
|
46
|
+
}
|
|
47
|
+
return map;
|
|
48
|
+
},
|
|
49
|
+
} as Pick<MemoryStore, "list" | "getVectors">;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// Cold memories (P0 B-1 observation)
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
describe("cold memory lint (P0 B-1)", () => {
|
|
57
|
+
it("aggregates cold memories into a single info finding with top ids (flag on)", async () => {
|
|
58
|
+
process.env.RECALLNEST_CONSTRUCTIVE_RETRIEVAL = "true";
|
|
59
|
+
try {
|
|
60
|
+
const coldMeta = (n: number) => JSON.stringify({
|
|
61
|
+
accessCount: n,
|
|
62
|
+
evolution: { status: "active", version: 1 },
|
|
63
|
+
});
|
|
64
|
+
// 向量彼此正交、文本不同,避免触发 duplicate/contradiction 干扰
|
|
65
|
+
const entries = [
|
|
66
|
+
makeEntry({ id: "cold-a", text: "alpha topic", vector: [1, 0, 0, 0, 0], metadata: coldMeta(12) }),
|
|
67
|
+
makeEntry({ id: "cold-b", text: "beta topic", vector: [0, 1, 0, 0, 0], metadata: coldMeta(7) }),
|
|
68
|
+
makeEntry({ id: "warm-c", text: "gamma topic", vector: [0, 0, 1, 0, 0], metadata: JSON.stringify({ accessCount: 9, usage: { useCount: 2 }, evolution: { status: "active", version: 1 } }) }),
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const report = await runMemoryLint({ store: createMockStore(entries) as MemoryStore });
|
|
72
|
+
|
|
73
|
+
expect(report.summary.coldMemories).toBe(2);
|
|
74
|
+
const finding = report.findings.find(f => f.check === "coldMemory");
|
|
75
|
+
expect(finding).toBeTruthy();
|
|
76
|
+
expect(finding!.severity).toBe("info");
|
|
77
|
+
// top ids sorted by injection desc
|
|
78
|
+
expect(finding!.memoryIds[0]).toBe("cold-a");
|
|
79
|
+
expect(finding!.memoryIds).toContain("cold-b");
|
|
80
|
+
expect(formatMemoryLintReport(report)).toContain("Cold Memories (2)");
|
|
81
|
+
} finally {
|
|
82
|
+
delete process.env.RECALLNEST_CONSTRUCTIVE_RETRIEVAL;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("skips cold detection entirely when use signal is inactive (flag off)", async () => {
|
|
87
|
+
delete process.env.RECALLNEST_CONSTRUCTIVE_RETRIEVAL;
|
|
88
|
+
const coldishMeta = JSON.stringify({ accessCount: 12, evolution: { status: "active", version: 1 } });
|
|
89
|
+
const report = await runMemoryLint({
|
|
90
|
+
store: createMockStore([makeEntry({ id: "a", text: "alpha", metadata: coldishMeta })]) as MemoryStore,
|
|
91
|
+
});
|
|
92
|
+
expect(report.summary.coldMemories).toBe(0);
|
|
93
|
+
expect(report.findings.find(f => f.check === "coldMemory")).toBeUndefined();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("health score dents only when cold share exceeds 10%, capped at 10", () => {
|
|
97
|
+
const base = { contradictions: 0, duplicates: 0, staleMemories: 0, orphans: 0, weakLessons: 0 };
|
|
98
|
+
// 5% cold -> no penalty
|
|
99
|
+
expect(computeHealthScore({ ...base, coldMemories: 5 }, 100)).toBe(100);
|
|
100
|
+
// 15% cold -> floor(15-10)=5 penalty
|
|
101
|
+
expect(computeHealthScore({ ...base, coldMemories: 15 }, 100)).toBe(95);
|
|
102
|
+
// 60% cold -> capped at 10
|
|
103
|
+
expect(computeHealthScore({ ...base, coldMemories: 60 }, 100)).toBe(90);
|
|
104
|
+
// backward compat: summary without coldMemories
|
|
105
|
+
expect(computeHealthScore(base, 100)).toBe(100);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// runMemoryLint
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
describe("runMemoryLint", () => {
|
|
114
|
+
it("returns all-clear for healthy data", async () => {
|
|
115
|
+
const entries = [
|
|
116
|
+
makeEntry({ id: "a1", text: "User prefers dark mode", category: "preferences", vector: [1, 0, 0, 0, 0] }),
|
|
117
|
+
makeEntry({ id: "a2", text: "Project uses Bun runtime", category: "entities", vector: [0, 1, 0, 0, 0] }),
|
|
118
|
+
];
|
|
119
|
+
const store = createMockStore(entries);
|
|
120
|
+
const report = await runMemoryLint({ store });
|
|
121
|
+
|
|
122
|
+
expect(report.healthScore).toBe(100);
|
|
123
|
+
expect(report.findings).toHaveLength(0);
|
|
124
|
+
expect(report.summary.contradictions).toBe(0);
|
|
125
|
+
expect(report.summary.duplicates).toBe(0);
|
|
126
|
+
expect(report.totalScanned).toBe(2);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("detects contradictions in same scope+category", async () => {
|
|
130
|
+
const entries = [
|
|
131
|
+
makeEntry({ id: "c1", text: "Always use Bun for scripts", scope: "project:x", category: "patterns" }),
|
|
132
|
+
makeEntry({ id: "c2", text: "Never use Bun for scripts", scope: "project:x", category: "patterns" }),
|
|
133
|
+
];
|
|
134
|
+
const store = createMockStore(entries);
|
|
135
|
+
const report = await runMemoryLint({ store });
|
|
136
|
+
|
|
137
|
+
expect(report.summary.contradictions).toBeGreaterThanOrEqual(1);
|
|
138
|
+
const finding = report.findings.find(f => f.check === "contradiction");
|
|
139
|
+
expect(finding).toBeDefined();
|
|
140
|
+
expect(finding!.memoryIds).toContain("c1");
|
|
141
|
+
expect(finding!.memoryIds).toContain("c2");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("detects duplicates by vector similarity", async () => {
|
|
145
|
+
const vec = [0.5, 0.5, 0.5, 0.5, 0.5];
|
|
146
|
+
const entries = [
|
|
147
|
+
makeEntry({ id: "d1", text: "Docker port is 4318", vector: vec, scope: "project:x", category: "entities" }),
|
|
148
|
+
makeEntry({ id: "d2", text: "Docker port is 4318 config", vector: vec, scope: "project:x", category: "entities" }),
|
|
149
|
+
];
|
|
150
|
+
const store = createMockStore(entries);
|
|
151
|
+
const report = await runMemoryLint({ store });
|
|
152
|
+
|
|
153
|
+
expect(report.summary.duplicates).toBeGreaterThanOrEqual(1);
|
|
154
|
+
const finding = report.findings.find(f => f.check === "duplicate");
|
|
155
|
+
expect(finding).toBeDefined();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("detects stale memories (old, never accessed)", async () => {
|
|
159
|
+
const oldTimestamp = Date.now() - 120 * 24 * 60 * 60 * 1000; // 120 days ago
|
|
160
|
+
const entries = [
|
|
161
|
+
makeEntry({
|
|
162
|
+
id: "s1",
|
|
163
|
+
text: "Some old fact",
|
|
164
|
+
timestamp: oldTimestamp,
|
|
165
|
+
metadata: JSON.stringify({
|
|
166
|
+
evolution: {
|
|
167
|
+
status: "active",
|
|
168
|
+
version: 1,
|
|
169
|
+
accessCount: 0,
|
|
170
|
+
lastAccessedAt: null,
|
|
171
|
+
supersededBy: null,
|
|
172
|
+
supersedes: null,
|
|
173
|
+
evolutionNote: null,
|
|
174
|
+
consolidatedInto: null,
|
|
175
|
+
contributedToPattern: null,
|
|
176
|
+
sourceMemories: [],
|
|
177
|
+
validFrom: oldTimestamp,
|
|
178
|
+
validUntil: null,
|
|
179
|
+
},
|
|
180
|
+
}),
|
|
181
|
+
}),
|
|
182
|
+
];
|
|
183
|
+
const store = createMockStore(entries);
|
|
184
|
+
const report = await runMemoryLint({ store });
|
|
185
|
+
|
|
186
|
+
expect(report.summary.staleMemories).toBe(1);
|
|
187
|
+
const finding = report.findings.find(f => f.check === "stale");
|
|
188
|
+
expect(finding).toBeDefined();
|
|
189
|
+
expect(finding!.severity).toBe("info");
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("detects orphans with missing scope", async () => {
|
|
193
|
+
const entries = [
|
|
194
|
+
makeEntry({ id: "o1", text: "Orphan memory", scope: "" }),
|
|
195
|
+
makeEntry({ id: "o2", text: "Schema entry", scope: "__schema__" }),
|
|
196
|
+
];
|
|
197
|
+
const store = createMockStore(entries);
|
|
198
|
+
const report = await runMemoryLint({ store });
|
|
199
|
+
|
|
200
|
+
expect(report.summary.orphans).toBe(2);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("detects broken consolidation links", async () => {
|
|
204
|
+
const entries = [
|
|
205
|
+
makeEntry({
|
|
206
|
+
id: "b1",
|
|
207
|
+
text: "Points to deleted",
|
|
208
|
+
metadata: JSON.stringify({
|
|
209
|
+
evolution: {
|
|
210
|
+
status: "active",
|
|
211
|
+
version: 1,
|
|
212
|
+
accessCount: 5,
|
|
213
|
+
lastAccessedAt: Date.now(),
|
|
214
|
+
supersededBy: null,
|
|
215
|
+
supersedes: null,
|
|
216
|
+
evolutionNote: null,
|
|
217
|
+
consolidatedInto: "nonexistent-id-12345",
|
|
218
|
+
contributedToPattern: null,
|
|
219
|
+
sourceMemories: [],
|
|
220
|
+
validFrom: Date.now(),
|
|
221
|
+
validUntil: null,
|
|
222
|
+
},
|
|
223
|
+
}),
|
|
224
|
+
}),
|
|
225
|
+
];
|
|
226
|
+
const store = createMockStore(entries);
|
|
227
|
+
const report = await runMemoryLint({ store });
|
|
228
|
+
|
|
229
|
+
expect(report.summary.orphans).toBe(1);
|
|
230
|
+
const finding = report.findings.find(f => f.check === "orphan" && f.severity === "warning");
|
|
231
|
+
expect(finding).toBeDefined();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it("skips non-active entries", async () => {
|
|
235
|
+
const entries = [
|
|
236
|
+
makeEntry({
|
|
237
|
+
id: "arc1",
|
|
238
|
+
text: "Archived memory",
|
|
239
|
+
scope: "",
|
|
240
|
+
metadata: JSON.stringify({
|
|
241
|
+
evolution: {
|
|
242
|
+
status: "archived",
|
|
243
|
+
version: 1,
|
|
244
|
+
accessCount: 0,
|
|
245
|
+
lastAccessedAt: null,
|
|
246
|
+
supersededBy: null,
|
|
247
|
+
supersedes: null,
|
|
248
|
+
evolutionNote: null,
|
|
249
|
+
consolidatedInto: null,
|
|
250
|
+
contributedToPattern: null,
|
|
251
|
+
sourceMemories: [],
|
|
252
|
+
validFrom: Date.now(),
|
|
253
|
+
validUntil: null,
|
|
254
|
+
},
|
|
255
|
+
}),
|
|
256
|
+
}),
|
|
257
|
+
];
|
|
258
|
+
const store = createMockStore(entries);
|
|
259
|
+
const report = await runMemoryLint({ store });
|
|
260
|
+
|
|
261
|
+
// Archived entry should be skipped, so no orphan finding
|
|
262
|
+
expect(report.totalScanned).toBe(0);
|
|
263
|
+
expect(report.findings).toHaveLength(0);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// ---- Weak lessons (action-verb heuristic, inspired by Orb) ----------------
|
|
267
|
+
|
|
268
|
+
it("flags patterns without any action verb as weak lessons", async () => {
|
|
269
|
+
const entries = [
|
|
270
|
+
makeEntry({
|
|
271
|
+
id: "wl1",
|
|
272
|
+
text: "This phenomenon is very interesting and noteworthy",
|
|
273
|
+
category: "patterns",
|
|
274
|
+
scope: "project:x",
|
|
275
|
+
vector: [1, 0, 0, 0, 0],
|
|
276
|
+
}),
|
|
277
|
+
];
|
|
278
|
+
const store = createMockStore(entries);
|
|
279
|
+
const report = await runMemoryLint({ store });
|
|
280
|
+
|
|
281
|
+
expect(report.summary.weakLessons).toBe(1);
|
|
282
|
+
const finding = report.findings.find(f => f.check === "weakLesson");
|
|
283
|
+
expect(finding).toBeDefined();
|
|
284
|
+
expect(finding!.severity).toBe("info");
|
|
285
|
+
expect(finding!.memoryIds).toContain("wl1");
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("does not flag patterns that contain action verbs (English or Chinese)", async () => {
|
|
289
|
+
const entries = [
|
|
290
|
+
makeEntry({
|
|
291
|
+
id: "wl2",
|
|
292
|
+
text: "Use Bun to run scripts; verify output before committing",
|
|
293
|
+
category: "patterns",
|
|
294
|
+
scope: "project:x",
|
|
295
|
+
vector: [1, 0, 0, 0, 0],
|
|
296
|
+
}),
|
|
297
|
+
makeEntry({
|
|
298
|
+
id: "wl3",
|
|
299
|
+
text: "使用 playwright 验证网页交互,失败时重试最多三次",
|
|
300
|
+
category: "patterns",
|
|
301
|
+
scope: "project:x",
|
|
302
|
+
vector: [0, 1, 0, 0, 0],
|
|
303
|
+
}),
|
|
304
|
+
];
|
|
305
|
+
const store = createMockStore(entries);
|
|
306
|
+
const report = await runMemoryLint({ store });
|
|
307
|
+
|
|
308
|
+
expect(report.summary.weakLessons).toBe(0);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it("does not flag non-pattern categories for weak lessons (events/profile exempt)", async () => {
|
|
312
|
+
const entries = [
|
|
313
|
+
makeEntry({
|
|
314
|
+
id: "wl4",
|
|
315
|
+
text: "This phenomenon is interesting", // no verb, but not a pattern
|
|
316
|
+
category: "events",
|
|
317
|
+
scope: "project:x",
|
|
318
|
+
vector: [1, 0, 0, 0, 0],
|
|
319
|
+
}),
|
|
320
|
+
makeEntry({
|
|
321
|
+
id: "wl5",
|
|
322
|
+
text: "User background info without verbs",
|
|
323
|
+
category: "profile",
|
|
324
|
+
scope: "project:x",
|
|
325
|
+
vector: [0, 1, 0, 0, 0],
|
|
326
|
+
}),
|
|
327
|
+
];
|
|
328
|
+
const store = createMockStore(entries);
|
|
329
|
+
const report = await runMemoryLint({ store });
|
|
330
|
+
|
|
331
|
+
expect(report.summary.weakLessons).toBe(0);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// ---------------------------------------------------------------------------
|
|
336
|
+
// computeHealthScore
|
|
337
|
+
// ---------------------------------------------------------------------------
|
|
338
|
+
|
|
339
|
+
describe("computeHealthScore", () => {
|
|
340
|
+
it("returns 100 when no issues", () => {
|
|
341
|
+
expect(computeHealthScore({ contradictions: 0, duplicates: 0, staleMemories: 0, orphans: 0 }, 100)).toBe(100);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it("deducts correctly for mixed findings", () => {
|
|
345
|
+
// 1 contradiction (-10) + 2 duplicates (-10) + 4 stale (-2) + 1 orphan (-3) = -25 → 75
|
|
346
|
+
expect(computeHealthScore({ contradictions: 1, duplicates: 2, staleMemories: 4, orphans: 1 }, 100)).toBe(75);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it("clamps to 0", () => {
|
|
350
|
+
expect(computeHealthScore({ contradictions: 20, duplicates: 0, staleMemories: 0, orphans: 0 }, 10)).toBe(0);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
// ---------------------------------------------------------------------------
|
|
355
|
+
// formatMemoryLintReport
|
|
356
|
+
// ---------------------------------------------------------------------------
|
|
357
|
+
|
|
358
|
+
describe("formatMemoryLintReport", () => {
|
|
359
|
+
it("shows all-clear when no findings", () => {
|
|
360
|
+
const report: MemoryLintReport = {
|
|
361
|
+
findings: [],
|
|
362
|
+
healthScore: 100,
|
|
363
|
+
totalScanned: 50,
|
|
364
|
+
timestamp: "2026-04-08T12:00:00Z",
|
|
365
|
+
summary: { contradictions: 0, duplicates: 0, staleMemories: 0, orphans: 0, weakLessons: 0 },
|
|
366
|
+
};
|
|
367
|
+
const output = formatMemoryLintReport(report);
|
|
368
|
+
expect(output).toContain("All Clear");
|
|
369
|
+
expect(output).toContain("100/100");
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it("includes findings when present", () => {
|
|
373
|
+
const report: MemoryLintReport = {
|
|
374
|
+
findings: [
|
|
375
|
+
{ check: "contradiction", severity: "warning", detail: '"A" vs "B"', memoryIds: ["id1", "id2"] },
|
|
376
|
+
],
|
|
377
|
+
healthScore: 90,
|
|
378
|
+
totalScanned: 100,
|
|
379
|
+
timestamp: "2026-04-08T12:00:00Z",
|
|
380
|
+
summary: { contradictions: 1, duplicates: 0, staleMemories: 0, orphans: 0, weakLessons: 0 },
|
|
381
|
+
};
|
|
382
|
+
const output = formatMemoryLintReport(report);
|
|
383
|
+
expect(output).toContain("Contradictions (1)");
|
|
384
|
+
expect(output).toContain("90/100");
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it("summarizes stale when count > 5", () => {
|
|
388
|
+
const staleFindings = Array.from({ length: 10 }, (_, i) => ({
|
|
389
|
+
check: "stale" as const,
|
|
390
|
+
severity: "info" as const,
|
|
391
|
+
detail: `${100 + i}d old`,
|
|
392
|
+
memoryIds: [`stale${i}`],
|
|
393
|
+
}));
|
|
394
|
+
const report: MemoryLintReport = {
|
|
395
|
+
findings: staleFindings,
|
|
396
|
+
healthScore: 95,
|
|
397
|
+
totalScanned: 200,
|
|
398
|
+
timestamp: "2026-04-08T12:00:00Z",
|
|
399
|
+
summary: { contradictions: 0, duplicates: 0, staleMemories: 10, orphans: 0, weakLessons: 0 },
|
|
400
|
+
};
|
|
401
|
+
const output = formatMemoryLintReport(report);
|
|
402
|
+
expect(output).toContain("Stale (10)");
|
|
403
|
+
expect(output).toContain("10 memories not accessed");
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it("renders weak lessons section when present", () => {
|
|
407
|
+
const report: MemoryLintReport = {
|
|
408
|
+
findings: [
|
|
409
|
+
{ check: "weakLesson", severity: "info", detail: 'Pattern without action verbs: "X is Y"', memoryIds: ["wl1"] },
|
|
410
|
+
{ check: "weakLesson", severity: "info", detail: 'Pattern without action verbs: "abstract note"', memoryIds: ["wl2"] },
|
|
411
|
+
],
|
|
412
|
+
healthScore: 96,
|
|
413
|
+
totalScanned: 10,
|
|
414
|
+
timestamp: "2026-04-16T12:00:00Z",
|
|
415
|
+
summary: { contradictions: 0, duplicates: 0, staleMemories: 0, orphans: 0, weakLessons: 2 },
|
|
416
|
+
};
|
|
417
|
+
const output = formatMemoryLintReport(report);
|
|
418
|
+
expect(output).toContain("Weak Lessons (2)");
|
|
419
|
+
expect(output).toContain("96/100");
|
|
420
|
+
});
|
|
421
|
+
});
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import { formatExplainResults, formatSearchResults } from "../memory-output.js";
|
|
4
|
+
import type { RetrievalResult } from "../retriever.js";
|
|
5
|
+
|
|
6
|
+
function buildResult(id: string, metadata: Record<string, unknown>): RetrievalResult {
|
|
7
|
+
return {
|
|
8
|
+
entry: {
|
|
9
|
+
id,
|
|
10
|
+
text: "User prefers concise, direct replies.",
|
|
11
|
+
vector: [],
|
|
12
|
+
category: "preferences",
|
|
13
|
+
scope: "memory:agent",
|
|
14
|
+
importance: 0.8,
|
|
15
|
+
timestamp: Date.parse("2026-03-16T00:00:00.000Z"),
|
|
16
|
+
metadata: JSON.stringify(metadata),
|
|
17
|
+
},
|
|
18
|
+
score: 0.91,
|
|
19
|
+
sources: {
|
|
20
|
+
vector: { score: 0.9, rank: 1 },
|
|
21
|
+
bm25: { score: 0.8, rank: 2 },
|
|
22
|
+
fused: { score: 0.91 },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe("memory output", () => {
|
|
28
|
+
it("includes provenance in search results", () => {
|
|
29
|
+
const output = formatSearchResults([
|
|
30
|
+
buildResult("abcd1234-0000-0000-0000-000000000001", {
|
|
31
|
+
source: "agent",
|
|
32
|
+
canonicalKey: "user-reply-style",
|
|
33
|
+
boundary: {
|
|
34
|
+
layer: "durable",
|
|
35
|
+
authority: "structured-memory",
|
|
36
|
+
conflictPolicy: "latest-wins",
|
|
37
|
+
originalCategory: "preferences",
|
|
38
|
+
},
|
|
39
|
+
promotedFrom: {
|
|
40
|
+
memoryId: "feedface-0000-0000-0000-000000000001",
|
|
41
|
+
scope: "cc:session1",
|
|
42
|
+
category: "events",
|
|
43
|
+
boundary: {
|
|
44
|
+
layer: "evidence",
|
|
45
|
+
authority: "transcript-ingest",
|
|
46
|
+
conflictPolicy: "append-only",
|
|
47
|
+
originalCategory: "preferences",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
provenanceHistory: [
|
|
51
|
+
{
|
|
52
|
+
memoryId: "feedface-0000-0000-0000-000000000001",
|
|
53
|
+
scope: "cc:session1",
|
|
54
|
+
category: "events",
|
|
55
|
+
source: "cc",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
memoryId: "deadbeef-0000-0000-0000-000000000002",
|
|
59
|
+
scope: "cc:session2",
|
|
60
|
+
category: "events",
|
|
61
|
+
source: "cc",
|
|
62
|
+
observedAt: "2026-03-17T04:30:00.000Z",
|
|
63
|
+
boundary: {
|
|
64
|
+
layer: "evidence",
|
|
65
|
+
authority: "transcript-ingest",
|
|
66
|
+
conflictPolicy: "append-only",
|
|
67
|
+
originalCategory: "preferences",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
provenanceHistoryCount: 2,
|
|
72
|
+
preferenceSlot: {
|
|
73
|
+
type: "brand-item",
|
|
74
|
+
brand: "麦当劳",
|
|
75
|
+
item: "麦辣鸡翅",
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
], {
|
|
79
|
+
query: "reply style",
|
|
80
|
+
profile: "default",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(output).toContain("prov : durable/structured-memory");
|
|
84
|
+
expect(output).toContain("key:user-reply-style");
|
|
85
|
+
expect(output).toContain("promoted:feedface<-evidence/transcript-ingest");
|
|
86
|
+
expect(output).toContain("history:2");
|
|
87
|
+
expect(output).toContain("observed:deadbeef@2026-03-17");
|
|
88
|
+
expect(output).toContain("slot:brand-item:麦当劳:麦辣鸡翅");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("includes provenance in explain results", () => {
|
|
92
|
+
const output = formatExplainResults([
|
|
93
|
+
buildResult("abcd1234-0000-0000-0000-000000000001", {
|
|
94
|
+
source: "cc",
|
|
95
|
+
boundary: {
|
|
96
|
+
layer: "evidence",
|
|
97
|
+
authority: "transcript-ingest",
|
|
98
|
+
conflictPolicy: "append-only",
|
|
99
|
+
originalCategory: "preferences",
|
|
100
|
+
downgradedFrom: "preferences",
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
103
|
+
], {
|
|
104
|
+
query: "reply style",
|
|
105
|
+
profile: "writing",
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(output).toContain("prov : evidence/transcript-ingest");
|
|
109
|
+
expect(output).toContain("downgraded:preferences");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("renders reply-style slots in provenance summaries", () => {
|
|
113
|
+
const output = formatSearchResults([
|
|
114
|
+
buildResult("abcd1234-0000-0000-0000-000000000002", {
|
|
115
|
+
source: "agent",
|
|
116
|
+
canonicalKey: "preferences:reply-style:concise:direct",
|
|
117
|
+
boundary: {
|
|
118
|
+
layer: "durable",
|
|
119
|
+
authority: "structured-memory",
|
|
120
|
+
conflictPolicy: "latest-wins",
|
|
121
|
+
originalCategory: "preferences",
|
|
122
|
+
},
|
|
123
|
+
preferenceSlot: {
|
|
124
|
+
type: "reply-style",
|
|
125
|
+
traits: ["concise", "direct"],
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
], {
|
|
129
|
+
query: "reply style",
|
|
130
|
+
profile: "default",
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
expect(output).toContain("slot:reply-style:concise:direct");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("renders tool-choice slots in provenance summaries", () => {
|
|
137
|
+
const output = formatSearchResults([
|
|
138
|
+
buildResult("abcd1234-0000-0000-0000-000000000003", {
|
|
139
|
+
source: "agent",
|
|
140
|
+
canonicalKey: "preferences:tool-choice:bun:over:node",
|
|
141
|
+
boundary: {
|
|
142
|
+
layer: "durable",
|
|
143
|
+
authority: "structured-memory",
|
|
144
|
+
conflictPolicy: "latest-wins",
|
|
145
|
+
originalCategory: "preferences",
|
|
146
|
+
},
|
|
147
|
+
preferenceSlot: {
|
|
148
|
+
type: "tool-choice",
|
|
149
|
+
preferredTool: "bun",
|
|
150
|
+
avoidedTool: "node",
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
153
|
+
], {
|
|
154
|
+
query: "tool choice",
|
|
155
|
+
profile: "default",
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
expect(output).toContain("slot:tool-choice:bun:over:node");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("does not render slot provenance for plain preferences canonical keys", () => {
|
|
162
|
+
const output = formatSearchResults([
|
|
163
|
+
buildResult("abcd1234-0000-0000-0000-000000000004", {
|
|
164
|
+
source: "agent",
|
|
165
|
+
canonicalKey: "preferences:这段文案简洁直接-先别改",
|
|
166
|
+
boundary: {
|
|
167
|
+
layer: "durable",
|
|
168
|
+
authority: "structured-memory",
|
|
169
|
+
conflictPolicy: "latest-wins",
|
|
170
|
+
originalCategory: "preferences",
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
buildResult("abcd1234-0000-0000-0000-000000000005", {
|
|
174
|
+
source: "agent",
|
|
175
|
+
canonicalKey: "preferences:文档里写了-uses-bun-over-node-的迁移说明",
|
|
176
|
+
boundary: {
|
|
177
|
+
layer: "durable",
|
|
178
|
+
authority: "structured-memory",
|
|
179
|
+
conflictPolicy: "latest-wins",
|
|
180
|
+
originalCategory: "preferences",
|
|
181
|
+
},
|
|
182
|
+
}),
|
|
183
|
+
], {
|
|
184
|
+
query: "preferences",
|
|
185
|
+
profile: "default",
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
expect(output).toContain("key:preferences:这段文案简洁直接-先别改");
|
|
189
|
+
expect(output).toContain("key:preferences:文档里写了-uses-bun-over-node-的迁移说明");
|
|
190
|
+
expect(output).not.toContain("slot:reply-style:");
|
|
191
|
+
expect(output).not.toContain("slot:tool-choice:");
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("does not render slot provenance in explain output for plain preferences canonical keys", () => {
|
|
195
|
+
const output = formatExplainResults([
|
|
196
|
+
buildResult("abcd1234-0000-0000-0000-000000000006", {
|
|
197
|
+
source: "agent",
|
|
198
|
+
canonicalKey: "preferences:这段文案简洁直接-先别改",
|
|
199
|
+
boundary: {
|
|
200
|
+
layer: "durable",
|
|
201
|
+
authority: "structured-memory",
|
|
202
|
+
conflictPolicy: "latest-wins",
|
|
203
|
+
originalCategory: "preferences",
|
|
204
|
+
},
|
|
205
|
+
}),
|
|
206
|
+
], {
|
|
207
|
+
query: "draft note",
|
|
208
|
+
profile: "default",
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(output).toContain("key:preferences:这段文案简洁直接-先别改");
|
|
212
|
+
expect(output).not.toContain("slot:reply-style:");
|
|
213
|
+
expect(output).not.toContain("slot:tool-choice:");
|
|
214
|
+
});
|
|
215
|
+
});
|