recallnest 3.0.0 → 4.0.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 +304 -0
- package/README.md +251 -258
- package/README_CN.md +226 -247
- package/assets/ui/app.js +6 -1
- package/bin/recallnest.mjs +20 -37
- package/docs/api-reference.md +8 -0
- package/docs/architecture.md +18 -13
- package/eval/cases-canary.json +107 -9
- package/integrations/examples/claude-agent-sdk/memory-agent.ts +2 -0
- package/integrations/examples/langchain/memory-chain.py +4 -0
- package/integrations/examples/openai-agents-sdk/memory-agent.py +4 -0
- package/package.json +12 -3
- package/src/activity-counter.ts +1 -0
- package/src/adaptive-retrieval.ts +23 -0
- package/src/api-server.ts +13 -11
- package/src/asset-sync.ts +26 -2
- package/src/audit-log.ts +2 -0
- package/src/auto-gc.ts +4 -3
- package/src/belief-history.ts +137 -31
- package/src/capture-engine.ts +459 -71
- package/src/cascade-forget.ts +7 -3
- package/src/checkpoint-mirror.ts +417 -0
- package/src/cli.ts +574 -54
- package/src/conflict-engine.ts +43 -15
- package/src/consolidation-engine.ts +24 -3
- package/src/context-collapse-renderer.ts +8 -1
- package/src/context-composer-stable.ts +5 -1
- package/src/context-composer.ts +11 -2
- package/src/distill-lock.ts +246 -74
- package/src/dream-pipeline.ts +3 -1
- package/src/embedder.ts +24 -0
- package/src/env-config.ts +136 -0
- package/src/flock.ts +97 -0
- package/src/forget-engine.ts +342 -58
- package/src/gateway-server.ts +4 -0
- package/src/ingest-plan.ts +56 -0
- package/src/ingest.ts +294 -121
- package/src/kg-contradiction.ts +753 -0
- package/src/kg-extractor.ts +17 -0
- package/src/kg-store.ts +1 -1
- package/src/known-item-eval.ts +455 -0
- package/src/llm-client.ts +13 -26
- package/src/llm-consolidation.ts +2 -2
- package/src/mcp-tool-deps.ts +6 -0
- package/src/mcp-tools-advanced.ts +80 -45
- package/src/mcp-tools-core.ts +23 -17
- package/src/mcp-tools-governance.ts +13 -7
- package/src/memory-assets.ts +144 -8
- package/src/memory-boundaries.ts +19 -0
- package/src/memory-evolution.ts +9 -0
- package/src/memory-lint.ts +1 -1
- package/src/memory-output.ts +311 -14
- package/src/memory-reconcile.ts +1437 -0
- package/src/memory-schema.ts +11 -0
- package/src/memory-store-port.ts +1 -0
- package/src/minis-archive.ts +151 -0
- package/src/noise-filter.ts +15 -2
- package/src/pii-detector.ts +31 -1
- package/src/pivot-apply.ts +55 -5
- package/src/pivot-evidence.ts +128 -0
- package/src/ppr-traversal.ts +25 -1
- package/src/preference-matcher.ts +40 -28
- package/src/prospective-memory.ts +7 -4
- package/src/retriever.ts +297 -57
- package/src/retroactive-boost.ts +3 -2
- package/src/runtime-config.ts +15 -1
- package/src/scope-policy.ts +1 -0
- package/src/session-distiller.ts +6 -2
- package/src/session-engine.ts +11 -4
- package/src/session-output.ts +20 -1
- package/src/session-schema.ts +5 -2
- package/src/session-store.ts +59 -12
- package/src/skill-promotion.ts +67 -1
- package/src/store-receipts.ts +109 -0
- package/src/store-write-budget.ts +37 -0
- package/src/store.ts +298 -57
- package/src/text-fingerprint.ts +25 -0
- package/src/trigger-store.ts +443 -0
- package/src/ui-server.ts +22 -21
- package/src/version-manager.ts +19 -5
- package/src/write-verifier.ts +16 -11
- package/src/__tests__/access-tracker-novelty.test.ts +0 -324
- package/src/__tests__/activity-counter.test.ts +0 -125
- package/src/__tests__/adaptive-fidelity.test.ts +0 -102
- package/src/__tests__/admission-control.test.ts +0 -206
- package/src/__tests__/age-label.test.ts +0 -33
- package/src/__tests__/anchor-generator.test.ts +0 -67
- package/src/__tests__/api-server-security.test.ts +0 -102
- package/src/__tests__/auto-consolidation.test.ts +0 -168
- package/src/__tests__/auto-recall.test.ts +0 -131
- package/src/__tests__/babel-integration.test.ts +0 -144
- package/src/__tests__/batch-dedup.test.ts +0 -65
- package/src/__tests__/belief-history.test.ts +0 -220
- package/src/__tests__/canary-eval.test.ts +0 -114
- package/src/__tests__/capture-engine.test.ts +0 -1328
- package/src/__tests__/capture-heuristic.test.ts +0 -171
- package/src/__tests__/cascade-forget.test.ts +0 -210
- package/src/__tests__/category-min-scores.test.ts +0 -116
- package/src/__tests__/cc8-cc1-essential-context.test.ts +0 -298
- package/src/__tests__/circuit-breaker.test.ts +0 -99
- package/src/__tests__/cluster-consolidation.test.ts +0 -1236
- package/src/__tests__/confidence-metadata.test.ts +0 -125
- package/src/__tests__/confidence-tracker.test.ts +0 -261
- package/src/__tests__/conflict-advisor.test.ts +0 -206
- package/src/__tests__/conflict-escalation.test.ts +0 -149
- package/src/__tests__/conflict-lifecycle.test.ts +0 -83
- package/src/__tests__/conflict-output.test.ts +0 -85
- package/src/__tests__/conflict-store.test.ts +0 -418
- package/src/__tests__/connector-v1.test.ts +0 -181
- package/src/__tests__/consolidation-engine.test.ts +0 -520
- package/src/__tests__/constructive-retrieval.test.ts +0 -509
- package/src/__tests__/context-collapse-renderer.test.ts +0 -214
- package/src/__tests__/context-composer-pins.test.ts +0 -64
- package/src/__tests__/context-composer-task-selection.test.ts +0 -24
- package/src/__tests__/context-reconstructor.test.ts +0 -65
- package/src/__tests__/context-renderer.test.ts +0 -91
- package/src/__tests__/continuity-eval.test.ts +0 -275
- package/src/__tests__/continuity-schema.test.ts +0 -97
- package/src/__tests__/contracts.test.ts +0 -262
- package/src/__tests__/conversation-importer.test.ts +0 -692
- package/src/__tests__/core-recall-eval.test.ts +0 -235
- package/src/__tests__/core-summary.test.ts +0 -109
- package/src/__tests__/data-checkup.test.ts +0 -304
- package/src/__tests__/decay-exemption.test.ts +0 -129
- package/src/__tests__/dedup-actions.test.ts +0 -58
- package/src/__tests__/dedup-guard.test.ts +0 -39
- package/src/__tests__/deterministic-id.test.ts +0 -39
- package/src/__tests__/distill-lock.test.ts +0 -305
- package/src/__tests__/distill-session-argshape.test.ts +0 -79
- package/src/__tests__/doctor.test.ts +0 -319
- package/src/__tests__/dream-pipeline.test.ts +0 -820
- package/src/__tests__/dream-scope-isolation.test.ts +0 -386
- package/src/__tests__/dream-write-batching.test.ts +0 -211
- package/src/__tests__/drill-down.test.ts +0 -108
- package/src/__tests__/embedder.test.ts +0 -122
- package/src/__tests__/emotion-decay.test.ts +0 -46
- package/src/__tests__/emotion-detector.test.ts +0 -56
- package/src/__tests__/emotion-phase1-integration.test.ts +0 -153
- package/src/__tests__/emotion-retrieval.test.ts +0 -56
- package/src/__tests__/entity-resolver.test.ts +0 -58
- package/src/__tests__/env-config-invariant.test.ts +0 -80
- package/src/__tests__/env-config.test.ts +0 -211
- package/src/__tests__/error-signature-boost.test.ts +0 -87
- package/src/__tests__/error-signature.test.ts +0 -95
- package/src/__tests__/error-taxonomy.test.ts +0 -129
- package/src/__tests__/ethics-layer.test.ts +0 -476
- package/src/__tests__/event-segmenter.test.ts +0 -153
- package/src/__tests__/feature-flags-integration.test.ts +0 -54
- package/src/__tests__/frequency-tracker.test.ts +0 -113
- package/src/__tests__/freshness.test.ts +0 -186
- package/src/__tests__/graph-export.test.ts +0 -489
- package/src/__tests__/hotness-blend.test.ts +0 -283
- package/src/__tests__/ingest-chunking.test.ts +0 -44
- package/src/__tests__/ingest-scope-prefix.test.ts +0 -69
- package/src/__tests__/ingest.test.ts +0 -360
- package/src/__tests__/interference-detector.test.ts +0 -203
- package/src/__tests__/kg-extractor.test.ts +0 -192
- package/src/__tests__/kg-store.test.ts +0 -300
- package/src/__tests__/llm-client-pivot.test.ts +0 -628
- package/src/__tests__/llm-consolidation.test.ts +0 -226
- package/src/__tests__/maintenance-locks.test.ts +0 -197
- package/src/__tests__/mcp-efficiency.test.ts +0 -288
- package/src/__tests__/mcp-related-scopes.test.ts +0 -151
- package/src/__tests__/memory-boundaries.test.ts +0 -282
- package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +0 -362
- package/src/__tests__/memory-evolution.test.ts +0 -271
- package/src/__tests__/memory-health-rebalance.test.ts +0 -144
- package/src/__tests__/memory-lint.test.ts +0 -421
- package/src/__tests__/memory-output.test.ts +0 -224
- package/src/__tests__/memory-promotion.test.ts +0 -315
- package/src/__tests__/memory-utility.test.ts +0 -256
- package/src/__tests__/migrate-dedup-ids.test.ts +0 -65
- package/src/__tests__/multi-vector.test.ts +0 -242
- package/src/__tests__/narrative-architecture.test.ts +0 -456
- package/src/__tests__/noise-filter.test.ts +0 -205
- package/src/__tests__/noise-prototype-bank.test.ts +0 -280
- package/src/__tests__/obsidian-connector.test.ts +0 -363
- package/src/__tests__/omitted-reporting.test.ts +0 -98
- package/src/__tests__/openai-contract.test.ts +0 -513
- package/src/__tests__/pending-review.test.ts +0 -77
- package/src/__tests__/pii-redact.test.ts +0 -333
- package/src/__tests__/pivot-apply.test.ts +0 -373
- package/src/__tests__/pivot-distill-supervisor.test.ts +0 -457
- package/src/__tests__/pivot-distill.test.ts +0 -1178
- package/src/__tests__/post-retrieval-filter.test.ts +0 -178
- package/src/__tests__/ppr-traversal.test.ts +0 -256
- package/src/__tests__/prediction-engine.test.ts +0 -349
- package/src/__tests__/predictive-prospective-memory.test.ts +0 -416
- package/src/__tests__/preference-guard-smoke.test.ts +0 -211
- package/src/__tests__/preference-matcher.test.ts +0 -282
- package/src/__tests__/preference-slots.test.ts +0 -205
- package/src/__tests__/promotion-distinct-sources.test.ts +0 -162
- package/src/__tests__/prospective-memory.test.ts +0 -283
- package/src/__tests__/pull-from-macbook-sync-only.test.ts +0 -679
- package/src/__tests__/query-entity-detector.test.ts +0 -171
- package/src/__tests__/query-expander-alias.test.ts +0 -146
- package/src/__tests__/query-expander.test.ts +0 -34
- package/src/__tests__/recall-gate.test.ts +0 -266
- package/src/__tests__/recall-governor.test.ts +0 -227
- package/src/__tests__/recall-mode.test.ts +0 -64
- package/src/__tests__/resolve-db-path.test.ts +0 -130
- package/src/__tests__/resolve-tier.test.ts +0 -64
- package/src/__tests__/result-synthesizer.test.ts +0 -198
- package/src/__tests__/resume-context.test.ts +0 -4898
- package/src/__tests__/retrieval-eval.test.ts +0 -163
- package/src/__tests__/retrieval-trace.test.ts +0 -213
- package/src/__tests__/retrieve-audit-revision.test.ts +0 -255
- package/src/__tests__/retriever-boundary-weight.test.ts +0 -136
- package/src/__tests__/retriever-lazy-init-dispatch.test.ts +0 -123
- package/src/__tests__/retroactive-boost.test.ts +0 -223
- package/src/__tests__/salience-scoring.test.ts +0 -106
- package/src/__tests__/scope-inventory.test.ts +0 -200
- package/src/__tests__/scope-policy.test.ts +0 -69
- package/src/__tests__/scope-suggester.test.ts +0 -80
- package/src/__tests__/session-checkpoint.test.ts +0 -291
- package/src/__tests__/session-distiller.test.ts +0 -640
- package/src/__tests__/session-gc.test.ts +0 -215
- package/src/__tests__/skill-engine.test.ts +0 -552
- package/src/__tests__/skill-promotion.test.ts +0 -654
- package/src/__tests__/skill-verifier.test.ts +0 -122
- package/src/__tests__/source-heartbeat.test.ts +0 -254
- package/src/__tests__/stable-context-length-contract.test.ts +0 -62
- package/src/__tests__/store-patch-metadata.test.ts +0 -235
- package/src/__tests__/store-read-consistency.test.ts +0 -122
- package/src/__tests__/store-schema-migration.test.ts +0 -87
- package/src/__tests__/store-scope-audit.test.ts +0 -81
- package/src/__tests__/store-upsert.test.ts +0 -201
- package/src/__tests__/supersede-chain.test.ts +0 -154
- package/src/__tests__/synthesis-contract.test.ts +0 -252
- package/src/__tests__/synthesis-promotion.test.ts +0 -369
- package/src/__tests__/temporal-parser.test.ts +0 -241
- package/src/__tests__/temporal-validity.test.ts +0 -160
- package/src/__tests__/term-registry-terminal-roster.test.ts +0 -127
- package/src/__tests__/term-registry.test.ts +0 -121
- package/src/__tests__/tool-error-surfacing.test.ts +0 -98
- package/src/__tests__/tool-output-compressor.test.ts +0 -160
- package/src/__tests__/topic-tag.test.ts +0 -113
- package/src/__tests__/trusted-memory.test.ts +0 -867
- package/src/__tests__/ui-server-security.test.ts +0 -93
- package/src/__tests__/usage-tracker.test.ts +0 -287
- package/src/__tests__/utility-weight.test.ts +0 -57
- package/src/__tests__/verbatim-self-recall.test.ts +0 -279
- package/src/__tests__/version-manager.test.ts +0 -248
- package/src/__tests__/workflow-observation-skill-outcome.test.ts +0 -352
- package/src/__tests__/workflow-observation.test.ts +0 -433
- package/src/__tests__/write-verifier.test.ts +0 -122
|
@@ -1,421 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,224 +0,0 @@
|
|
|
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("renders a whole-day age next to every date so nobody has to subtract", () => {
|
|
29
|
-
const result = buildResult("abcd1234-0000-0000-0000-000000000009", { source: "agent" });
|
|
30
|
-
const search = formatSearchResults([result], { query: "concise", profile: "default" } as any);
|
|
31
|
-
expect(search).toContain("Date Age Retrieval Path");
|
|
32
|
-
expect(search).toMatch(/2026-03-16 \d+d\s+vector/);
|
|
33
|
-
const explain = formatExplainResults([result], { query: "concise", profile: "default" } as any);
|
|
34
|
-
expect(explain).toMatch(/2026-03-16 \(\d+d\)/);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("includes provenance in search results", () => {
|
|
38
|
-
const output = formatSearchResults([
|
|
39
|
-
buildResult("abcd1234-0000-0000-0000-000000000001", {
|
|
40
|
-
source: "agent",
|
|
41
|
-
canonicalKey: "user-reply-style",
|
|
42
|
-
boundary: {
|
|
43
|
-
layer: "durable",
|
|
44
|
-
authority: "structured-memory",
|
|
45
|
-
conflictPolicy: "latest-wins",
|
|
46
|
-
originalCategory: "preferences",
|
|
47
|
-
},
|
|
48
|
-
promotedFrom: {
|
|
49
|
-
memoryId: "feedface-0000-0000-0000-000000000001",
|
|
50
|
-
scope: "cc:session1",
|
|
51
|
-
category: "events",
|
|
52
|
-
boundary: {
|
|
53
|
-
layer: "evidence",
|
|
54
|
-
authority: "transcript-ingest",
|
|
55
|
-
conflictPolicy: "append-only",
|
|
56
|
-
originalCategory: "preferences",
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
provenanceHistory: [
|
|
60
|
-
{
|
|
61
|
-
memoryId: "feedface-0000-0000-0000-000000000001",
|
|
62
|
-
scope: "cc:session1",
|
|
63
|
-
category: "events",
|
|
64
|
-
source: "cc",
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
memoryId: "deadbeef-0000-0000-0000-000000000002",
|
|
68
|
-
scope: "cc:session2",
|
|
69
|
-
category: "events",
|
|
70
|
-
source: "cc",
|
|
71
|
-
observedAt: "2026-03-17T04:30:00.000Z",
|
|
72
|
-
boundary: {
|
|
73
|
-
layer: "evidence",
|
|
74
|
-
authority: "transcript-ingest",
|
|
75
|
-
conflictPolicy: "append-only",
|
|
76
|
-
originalCategory: "preferences",
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
provenanceHistoryCount: 2,
|
|
81
|
-
preferenceSlot: {
|
|
82
|
-
type: "brand-item",
|
|
83
|
-
brand: "麦当劳",
|
|
84
|
-
item: "麦辣鸡翅",
|
|
85
|
-
},
|
|
86
|
-
}),
|
|
87
|
-
], {
|
|
88
|
-
query: "reply style",
|
|
89
|
-
profile: "default",
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
expect(output).toContain("prov : durable/structured-memory");
|
|
93
|
-
expect(output).toContain("key:user-reply-style");
|
|
94
|
-
expect(output).toContain("promoted:feedface<-evidence/transcript-ingest");
|
|
95
|
-
expect(output).toContain("history:2");
|
|
96
|
-
expect(output).toContain("observed:deadbeef@2026-03-17");
|
|
97
|
-
expect(output).toContain("slot:brand-item:麦当劳:麦辣鸡翅");
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it("includes provenance in explain results", () => {
|
|
101
|
-
const output = formatExplainResults([
|
|
102
|
-
buildResult("abcd1234-0000-0000-0000-000000000001", {
|
|
103
|
-
source: "cc",
|
|
104
|
-
boundary: {
|
|
105
|
-
layer: "evidence",
|
|
106
|
-
authority: "transcript-ingest",
|
|
107
|
-
conflictPolicy: "append-only",
|
|
108
|
-
originalCategory: "preferences",
|
|
109
|
-
downgradedFrom: "preferences",
|
|
110
|
-
},
|
|
111
|
-
}),
|
|
112
|
-
], {
|
|
113
|
-
query: "reply style",
|
|
114
|
-
profile: "writing",
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
expect(output).toContain("prov : evidence/transcript-ingest");
|
|
118
|
-
expect(output).toContain("downgraded:preferences");
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("renders reply-style slots in provenance summaries", () => {
|
|
122
|
-
const output = formatSearchResults([
|
|
123
|
-
buildResult("abcd1234-0000-0000-0000-000000000002", {
|
|
124
|
-
source: "agent",
|
|
125
|
-
canonicalKey: "preferences:reply-style:concise:direct",
|
|
126
|
-
boundary: {
|
|
127
|
-
layer: "durable",
|
|
128
|
-
authority: "structured-memory",
|
|
129
|
-
conflictPolicy: "latest-wins",
|
|
130
|
-
originalCategory: "preferences",
|
|
131
|
-
},
|
|
132
|
-
preferenceSlot: {
|
|
133
|
-
type: "reply-style",
|
|
134
|
-
traits: ["concise", "direct"],
|
|
135
|
-
},
|
|
136
|
-
}),
|
|
137
|
-
], {
|
|
138
|
-
query: "reply style",
|
|
139
|
-
profile: "default",
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
expect(output).toContain("slot:reply-style:concise:direct");
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("renders tool-choice slots in provenance summaries", () => {
|
|
146
|
-
const output = formatSearchResults([
|
|
147
|
-
buildResult("abcd1234-0000-0000-0000-000000000003", {
|
|
148
|
-
source: "agent",
|
|
149
|
-
canonicalKey: "preferences:tool-choice:bun:over:node",
|
|
150
|
-
boundary: {
|
|
151
|
-
layer: "durable",
|
|
152
|
-
authority: "structured-memory",
|
|
153
|
-
conflictPolicy: "latest-wins",
|
|
154
|
-
originalCategory: "preferences",
|
|
155
|
-
},
|
|
156
|
-
preferenceSlot: {
|
|
157
|
-
type: "tool-choice",
|
|
158
|
-
preferredTool: "bun",
|
|
159
|
-
avoidedTool: "node",
|
|
160
|
-
},
|
|
161
|
-
}),
|
|
162
|
-
], {
|
|
163
|
-
query: "tool choice",
|
|
164
|
-
profile: "default",
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
expect(output).toContain("slot:tool-choice:bun:over:node");
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it("does not render slot provenance for plain preferences canonical keys", () => {
|
|
171
|
-
const output = formatSearchResults([
|
|
172
|
-
buildResult("abcd1234-0000-0000-0000-000000000004", {
|
|
173
|
-
source: "agent",
|
|
174
|
-
canonicalKey: "preferences:这段文案简洁直接-先别改",
|
|
175
|
-
boundary: {
|
|
176
|
-
layer: "durable",
|
|
177
|
-
authority: "structured-memory",
|
|
178
|
-
conflictPolicy: "latest-wins",
|
|
179
|
-
originalCategory: "preferences",
|
|
180
|
-
},
|
|
181
|
-
}),
|
|
182
|
-
buildResult("abcd1234-0000-0000-0000-000000000005", {
|
|
183
|
-
source: "agent",
|
|
184
|
-
canonicalKey: "preferences:文档里写了-uses-bun-over-node-的迁移说明",
|
|
185
|
-
boundary: {
|
|
186
|
-
layer: "durable",
|
|
187
|
-
authority: "structured-memory",
|
|
188
|
-
conflictPolicy: "latest-wins",
|
|
189
|
-
originalCategory: "preferences",
|
|
190
|
-
},
|
|
191
|
-
}),
|
|
192
|
-
], {
|
|
193
|
-
query: "preferences",
|
|
194
|
-
profile: "default",
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
expect(output).toContain("key:preferences:这段文案简洁直接-先别改");
|
|
198
|
-
expect(output).toContain("key:preferences:文档里写了-uses-bun-over-node-的迁移说明");
|
|
199
|
-
expect(output).not.toContain("slot:reply-style:");
|
|
200
|
-
expect(output).not.toContain("slot:tool-choice:");
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it("does not render slot provenance in explain output for plain preferences canonical keys", () => {
|
|
204
|
-
const output = formatExplainResults([
|
|
205
|
-
buildResult("abcd1234-0000-0000-0000-000000000006", {
|
|
206
|
-
source: "agent",
|
|
207
|
-
canonicalKey: "preferences:这段文案简洁直接-先别改",
|
|
208
|
-
boundary: {
|
|
209
|
-
layer: "durable",
|
|
210
|
-
authority: "structured-memory",
|
|
211
|
-
conflictPolicy: "latest-wins",
|
|
212
|
-
originalCategory: "preferences",
|
|
213
|
-
},
|
|
214
|
-
}),
|
|
215
|
-
], {
|
|
216
|
-
query: "draft note",
|
|
217
|
-
profile: "default",
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
expect(output).toContain("key:preferences:这段文案简洁直接-先别改");
|
|
221
|
-
expect(output).not.toContain("slot:reply-style:");
|
|
222
|
-
expect(output).not.toContain("slot:tool-choice:");
|
|
223
|
-
});
|
|
224
|
-
});
|