recallnest 2.2.0 → 2.2.1
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/.env +4 -0
- package/config.json +55 -0
- package/logs/daily-recall.error.log +0 -0
- package/logs/daily-recall.log +30 -0
- package/logs/ingest-2026-04-11.log +110 -0
- package/logs/ingest-2026-04-12.log +90 -0
- package/logs/launchagent-stderr.log +0 -0
- package/logs/launchagent-stdout.log +0 -0
- package/package.json +1 -1
- package/.claude-plugin/CLAUDE.md +0 -29
- package/.claude-plugin/marketplace.json +0 -18
- package/.dockerignore +0 -11
- package/.github/workflows/ci.yml +0 -28
- package/.mcp.json +0 -9
- package/CHANGELOG.md +0 -51
- package/DEMO.md +0 -94
- package/Dockerfile +0 -20
- package/EVAL.md +0 -89
- package/FAILURES.md +0 -75
- package/OPERATIONS.md +0 -59
- package/ROADMAP.md +0 -245
- package/SKILL.md +0 -250
- package/assets/dashboard.png +0 -0
- package/assets/knowledge-graph.png +0 -0
- package/assets/recallnest-workbench.png +0 -0
- package/assets/screenshots/ui-full.png +0 -0
- package/assets/screenshots/ui-overview.png +0 -0
- package/assets/screenshots/ui-search.png +0 -0
- package/assets/ui/app.js +0 -1031
- package/assets/ui/index.html +0 -224
- package/assets/ui/styles.css +0 -781
- package/assets/wechat-qr.jpg +0 -0
- package/bun.lock +0 -337
- package/daily-reflections/2026-03-05.md +0 -15
- package/daily-reflections/2026-03-06.md +0 -15
- package/daily-reflections/2026-03-07.md +0 -7
- package/daily-reflections/2026-03-08.md +0 -34
- package/daily-reflections/2026-03-09.md +0 -35
- package/daily-reflections/2026-03-10.md +0 -36
- package/daily-reflections/2026-03-11.md +0 -35
- package/daily-reflections/2026-03-12.md +0 -36
- package/daily-reflections/2026-03-13.md +0 -35
- package/daily-reflections/2026-03-14.md +0 -35
- package/daily-reflections/2026-03-15.md +0 -35
- package/daily-reflections/2026-03-16.md +0 -41
- package/daily-reflections/2026-03-17.md +0 -10
- package/daily-reflections/2026-03-18.md +0 -10
- package/daily-reflections/2026-03-19.md +0 -10
- package/daily-reflections/2026-03-20.md +0 -10
- package/daily-reflections/2026-03-21.md +0 -10
- package/daily-reflections/2026-03-22.md +0 -10
- package/daily-reflections/2026-03-23.md +0 -10
- package/daily-reflections/2026-03-24.md +0 -10
- package/daily-reflections/2026-03-25.md +0 -32
- package/daily-reflections/2026-03-26.md +0 -37
- package/daily-reflections/2026-03-27.md +0 -35
- package/daily-reflections/2026-03-28.md +0 -35
- package/daily-reflections/2026-03-29.md +0 -35
- package/daily-reflections/2026-03-30.md +0 -36
- package/daily-reflections/2026-03-31.md +0 -35
- package/daily-reflections/2026-04-01.md +0 -35
- package/daily-reflections/2026-04-02.md +0 -35
- package/daily-reflections/2026-04-03.md +0 -37
- package/daily-reflections/2026-04-04.md +0 -37
- package/daily-reflections/2026-04-05.md +0 -35
- package/daily-reflections/2026-04-06.md +0 -36
- package/daily-reflections/2026-04-07.md +0 -35
- package/daily-reflections/2026-04-08.md +0 -35
- package/daily-reflections/2026-04-12.md +0 -35
- package/data/alias-map.example.json +0 -22
- package/docs/api-reference.md +0 -1291
- package/docs/architecture.md +0 -168
- package/docs/memory-boundary-contract.md +0 -226
- package/docs/memory-categories.md +0 -119
- package/docs/pipeline-audit-ultramemory.md +0 -177
- package/docs/plans/2026-03-08-query-expansion.md +0 -270
- package/docs/plans/2026-03-16-continuity-layer.md +0 -196
- package/docs/plans/2026-04-01-recall-boost.md +0 -100
- package/docs/plans/mcp-tiering-plan.md +0 -126
- package/docs/research/recall-quality-audit-2026-03-22.md +0 -153
- package/docs/self-evolution.md +0 -198
- package/docs/superpowers/plans/2026-03-19-ingest-pipeline-upgrade.md +0 -782
- package/docs/superpowers/plans/2026-04-11-constructive-retrieval-emotion.md +0 -1195
- package/docs/superpowers/specs/2026-03-19-ingest-pipeline-upgrade-design.md +0 -77
- package/docs/superpowers/specs/2026-03-23-pull-claude-desktop-design.md +0 -95
- package/docs/superpowers/specs/2026-04-11-constructive-retrieval-emotion-design.md +0 -398
- package/eval/continuity/results-2026-03-16.md +0 -117
- package/eval/continuity/results-2026-03-19.md +0 -453
- package/eval/continuity/runbook.md +0 -110
- package/eval/continuity/seed-cases.md +0 -54
- package/eval/reports/2026-03-06-abstract-query-baseline.md +0 -96
- package/eval/reports/2026-03-06-aws-ssh-baseline.md +0 -82
- package/eval/reports/2026-03-06-baseline.md +0 -82
- package/eval/reports/query-expansion.md +0 -138
- package/glama.json +0 -6
- package/lm +0 -19
- package/plan-philosophy-upgrades.md +0 -363
- package/plan-product-upgrades.md +0 -155
- package/plan-v1.2-distributable.md +0 -105
- package/plan.md +0 -140
- package/research-memory-evolution.md +0 -440
- package/research-rl-agent-memory.md +0 -330
- package/scripts/archive-distilled-junk.ts +0 -116
- package/scripts/backfill-anchors.ts +0 -130
- package/scripts/backfill-l0l1l2.ts +0 -98
- package/scripts/blind-scan.ts +0 -588
- package/scripts/cleanup-step1-exact-dups.ts +0 -117
- package/scripts/cleanup-step2-template-dups.ts +0 -113
- package/scripts/cleanup-step3-stale-content.ts +0 -149
- package/scripts/cleanup-step4-orphan-scopes.ts +0 -131
- package/scripts/delete-distilled-junk.ts +0 -88
- package/scripts/diagnose-vector-search.ts +0 -132
- package/scripts/distill-facts.ts +0 -305
- package/scripts/health-check.ts +0 -343
- package/scripts/incremental-ingest.sh +0 -71
- package/scripts/migrate-language.ts +0 -75
- package/scripts/mlp-health-check.ts +0 -382
- package/scripts/pull-claude-desktop.ts +0 -515
- package/scripts/re-ingest-cc.sh +0 -66
- package/scripts/rebalance-memory-health.ts +0 -181
- package/scripts/run-desktop-ingest.sh +0 -11
- package/scripts/start-server.sh +0 -12
- package/scripts/verify-emotion-decay.ts +0 -148
- package/scripts/viz-dashboard.html +0 -423
- package/scripts/viz-export.ts +0 -703
- package/src/__tests__/access-tracker-novelty.test.ts +0 -228
- package/src/__tests__/activity-counter.test.ts +0 -96
- package/src/__tests__/admission-control.test.ts +0 -206
- package/src/__tests__/anchor-generator.test.ts +0 -67
- 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 -139
- package/src/__tests__/batch-dedup.test.ts +0 -65
- package/src/__tests__/capture-engine.test.ts +0 -1144
- 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 -33
- 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 -712
- package/src/__tests__/confidence-metadata.test.ts +0 -125
- package/src/__tests__/confidence-tracker.test.ts +0 -249
- 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 -374
- package/src/__tests__/consolidation-engine.test.ts +0 -181
- 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__/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 -225
- package/src/__tests__/decay-exemption.test.ts +0 -84
- 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 -176
- package/src/__tests__/doctor.test.ts +0 -303
- package/src/__tests__/dream-pipeline.test.ts +0 -232
- 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__/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__/graph-export.test.ts +0 -489
- package/src/__tests__/hotness-blend.test.ts +0 -76
- 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 -184
- package/src/__tests__/kg-store.test.ts +0 -198
- package/src/__tests__/llm-consolidation.test.ts +0 -226
- package/src/__tests__/mcp-efficiency.test.ts +0 -288
- package/src/__tests__/memory-boundaries.test.ts +0 -237
- package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +0 -243
- 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 -271
- package/src/__tests__/memory-output.test.ts +0 -215
- package/src/__tests__/multi-vector.test.ts +0 -242
- package/src/__tests__/narrative-architecture.test.ts +0 -456
- package/src/__tests__/pending-review.test.ts +0 -77
- 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 -230
- package/src/__tests__/preference-slots.test.ts +0 -205
- package/src/__tests__/prospective-memory.test.ts +0 -283
- package/src/__tests__/query-entity-detector.test.ts +0 -171
- package/src/__tests__/query-expander-alias.test.ts +0 -89
- package/src/__tests__/query-expander.test.ts +0 -34
- package/src/__tests__/recall-governor.test.ts +0 -227
- package/src/__tests__/recall-mode.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-trace.test.ts +0 -213
- package/src/__tests__/retriever-boundary-weight.test.ts +0 -136
- 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__/session-checkpoint.test.ts +0 -259
- package/src/__tests__/session-distiller.test.ts +0 -611
- package/src/__tests__/session-gc.test.ts +0 -215
- package/src/__tests__/skill-engine.test.ts +0 -546
- package/src/__tests__/skill-promotion.test.ts +0 -349
- package/src/__tests__/store-scope-audit.test.ts +0 -81
- package/src/__tests__/supersede-chain.test.ts +0 -154
- package/src/__tests__/temporal-parser.test.ts +0 -241
- package/src/__tests__/temporal-validity.test.ts +0 -160
- package/src/__tests__/term-registry.test.ts +0 -121
- package/src/__tests__/tool-output-compressor.test.ts +0 -133
- package/src/__tests__/topic-tag.test.ts +0 -113
- package/src/__tests__/trusted-memory.test.ts +0 -828
- package/src/__tests__/version-manager.test.ts +0 -213
- package/src/__tests__/workflow-observation.test.ts +0 -400
- package/src/__tests__/write-verifier.test.ts +0 -122
|
@@ -1,271 +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"> {
|
|
38
|
-
return {
|
|
39
|
-
async list() { return entries; },
|
|
40
|
-
} as Pick<MemoryStore, "list">;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
// runMemoryLint
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
|
|
47
|
-
describe("runMemoryLint", () => {
|
|
48
|
-
it("returns all-clear for healthy data", async () => {
|
|
49
|
-
const entries = [
|
|
50
|
-
makeEntry({ id: "a1", text: "User prefers dark mode", category: "preferences", vector: [1, 0, 0, 0, 0] }),
|
|
51
|
-
makeEntry({ id: "a2", text: "Project uses Bun runtime", category: "entities", vector: [0, 1, 0, 0, 0] }),
|
|
52
|
-
];
|
|
53
|
-
const store = createMockStore(entries);
|
|
54
|
-
const report = await runMemoryLint({ store });
|
|
55
|
-
|
|
56
|
-
expect(report.healthScore).toBe(100);
|
|
57
|
-
expect(report.findings).toHaveLength(0);
|
|
58
|
-
expect(report.summary.contradictions).toBe(0);
|
|
59
|
-
expect(report.summary.duplicates).toBe(0);
|
|
60
|
-
expect(report.totalScanned).toBe(2);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("detects contradictions in same scope+category", async () => {
|
|
64
|
-
const entries = [
|
|
65
|
-
makeEntry({ id: "c1", text: "Always use Bun for scripts", scope: "project:x", category: "patterns" }),
|
|
66
|
-
makeEntry({ id: "c2", text: "Never use Bun for scripts", scope: "project:x", category: "patterns" }),
|
|
67
|
-
];
|
|
68
|
-
const store = createMockStore(entries);
|
|
69
|
-
const report = await runMemoryLint({ store });
|
|
70
|
-
|
|
71
|
-
expect(report.summary.contradictions).toBeGreaterThanOrEqual(1);
|
|
72
|
-
const finding = report.findings.find(f => f.check === "contradiction");
|
|
73
|
-
expect(finding).toBeDefined();
|
|
74
|
-
expect(finding!.memoryIds).toContain("c1");
|
|
75
|
-
expect(finding!.memoryIds).toContain("c2");
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("detects duplicates by vector similarity", async () => {
|
|
79
|
-
const vec = [0.5, 0.5, 0.5, 0.5, 0.5];
|
|
80
|
-
const entries = [
|
|
81
|
-
makeEntry({ id: "d1", text: "Docker port is 4318", vector: vec, scope: "project:x", category: "entities" }),
|
|
82
|
-
makeEntry({ id: "d2", text: "Docker port is 4318 config", vector: vec, scope: "project:x", category: "entities" }),
|
|
83
|
-
];
|
|
84
|
-
const store = createMockStore(entries);
|
|
85
|
-
const report = await runMemoryLint({ store });
|
|
86
|
-
|
|
87
|
-
expect(report.summary.duplicates).toBeGreaterThanOrEqual(1);
|
|
88
|
-
const finding = report.findings.find(f => f.check === "duplicate");
|
|
89
|
-
expect(finding).toBeDefined();
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("detects stale memories (old, never accessed)", async () => {
|
|
93
|
-
const oldTimestamp = Date.now() - 120 * 24 * 60 * 60 * 1000; // 120 days ago
|
|
94
|
-
const entries = [
|
|
95
|
-
makeEntry({
|
|
96
|
-
id: "s1",
|
|
97
|
-
text: "Some old fact",
|
|
98
|
-
timestamp: oldTimestamp,
|
|
99
|
-
metadata: JSON.stringify({
|
|
100
|
-
evolution: {
|
|
101
|
-
status: "active",
|
|
102
|
-
version: 1,
|
|
103
|
-
accessCount: 0,
|
|
104
|
-
lastAccessedAt: null,
|
|
105
|
-
supersededBy: null,
|
|
106
|
-
supersedes: null,
|
|
107
|
-
evolutionNote: null,
|
|
108
|
-
consolidatedInto: null,
|
|
109
|
-
contributedToPattern: null,
|
|
110
|
-
sourceMemories: [],
|
|
111
|
-
validFrom: oldTimestamp,
|
|
112
|
-
validUntil: null,
|
|
113
|
-
},
|
|
114
|
-
}),
|
|
115
|
-
}),
|
|
116
|
-
];
|
|
117
|
-
const store = createMockStore(entries);
|
|
118
|
-
const report = await runMemoryLint({ store });
|
|
119
|
-
|
|
120
|
-
expect(report.summary.staleMemories).toBe(1);
|
|
121
|
-
const finding = report.findings.find(f => f.check === "stale");
|
|
122
|
-
expect(finding).toBeDefined();
|
|
123
|
-
expect(finding!.severity).toBe("info");
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("detects orphans with missing scope", async () => {
|
|
127
|
-
const entries = [
|
|
128
|
-
makeEntry({ id: "o1", text: "Orphan memory", scope: "" }),
|
|
129
|
-
makeEntry({ id: "o2", text: "Schema entry", scope: "__schema__" }),
|
|
130
|
-
];
|
|
131
|
-
const store = createMockStore(entries);
|
|
132
|
-
const report = await runMemoryLint({ store });
|
|
133
|
-
|
|
134
|
-
expect(report.summary.orphans).toBe(2);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("detects broken consolidation links", async () => {
|
|
138
|
-
const entries = [
|
|
139
|
-
makeEntry({
|
|
140
|
-
id: "b1",
|
|
141
|
-
text: "Points to deleted",
|
|
142
|
-
metadata: JSON.stringify({
|
|
143
|
-
evolution: {
|
|
144
|
-
status: "active",
|
|
145
|
-
version: 1,
|
|
146
|
-
accessCount: 5,
|
|
147
|
-
lastAccessedAt: Date.now(),
|
|
148
|
-
supersededBy: null,
|
|
149
|
-
supersedes: null,
|
|
150
|
-
evolutionNote: null,
|
|
151
|
-
consolidatedInto: "nonexistent-id-12345",
|
|
152
|
-
contributedToPattern: null,
|
|
153
|
-
sourceMemories: [],
|
|
154
|
-
validFrom: Date.now(),
|
|
155
|
-
validUntil: null,
|
|
156
|
-
},
|
|
157
|
-
}),
|
|
158
|
-
}),
|
|
159
|
-
];
|
|
160
|
-
const store = createMockStore(entries);
|
|
161
|
-
const report = await runMemoryLint({ store });
|
|
162
|
-
|
|
163
|
-
expect(report.summary.orphans).toBe(1);
|
|
164
|
-
const finding = report.findings.find(f => f.check === "orphan" && f.severity === "warning");
|
|
165
|
-
expect(finding).toBeDefined();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("skips non-active entries", async () => {
|
|
169
|
-
const entries = [
|
|
170
|
-
makeEntry({
|
|
171
|
-
id: "arc1",
|
|
172
|
-
text: "Archived memory",
|
|
173
|
-
scope: "",
|
|
174
|
-
metadata: JSON.stringify({
|
|
175
|
-
evolution: {
|
|
176
|
-
status: "archived",
|
|
177
|
-
version: 1,
|
|
178
|
-
accessCount: 0,
|
|
179
|
-
lastAccessedAt: null,
|
|
180
|
-
supersededBy: null,
|
|
181
|
-
supersedes: null,
|
|
182
|
-
evolutionNote: null,
|
|
183
|
-
consolidatedInto: null,
|
|
184
|
-
contributedToPattern: null,
|
|
185
|
-
sourceMemories: [],
|
|
186
|
-
validFrom: Date.now(),
|
|
187
|
-
validUntil: null,
|
|
188
|
-
},
|
|
189
|
-
}),
|
|
190
|
-
}),
|
|
191
|
-
];
|
|
192
|
-
const store = createMockStore(entries);
|
|
193
|
-
const report = await runMemoryLint({ store });
|
|
194
|
-
|
|
195
|
-
// Archived entry should be skipped, so no orphan finding
|
|
196
|
-
expect(report.totalScanned).toBe(0);
|
|
197
|
-
expect(report.findings).toHaveLength(0);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
// ---------------------------------------------------------------------------
|
|
202
|
-
// computeHealthScore
|
|
203
|
-
// ---------------------------------------------------------------------------
|
|
204
|
-
|
|
205
|
-
describe("computeHealthScore", () => {
|
|
206
|
-
it("returns 100 when no issues", () => {
|
|
207
|
-
expect(computeHealthScore({ contradictions: 0, duplicates: 0, staleMemories: 0, orphans: 0 }, 100)).toBe(100);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it("deducts correctly for mixed findings", () => {
|
|
211
|
-
// 1 contradiction (-10) + 2 duplicates (-10) + 4 stale (-2) + 1 orphan (-3) = -25 → 75
|
|
212
|
-
expect(computeHealthScore({ contradictions: 1, duplicates: 2, staleMemories: 4, orphans: 1 }, 100)).toBe(75);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it("clamps to 0", () => {
|
|
216
|
-
expect(computeHealthScore({ contradictions: 20, duplicates: 0, staleMemories: 0, orphans: 0 }, 10)).toBe(0);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
// ---------------------------------------------------------------------------
|
|
221
|
-
// formatMemoryLintReport
|
|
222
|
-
// ---------------------------------------------------------------------------
|
|
223
|
-
|
|
224
|
-
describe("formatMemoryLintReport", () => {
|
|
225
|
-
it("shows all-clear when no findings", () => {
|
|
226
|
-
const report: MemoryLintReport = {
|
|
227
|
-
findings: [],
|
|
228
|
-
healthScore: 100,
|
|
229
|
-
totalScanned: 50,
|
|
230
|
-
timestamp: "2026-04-08T12:00:00Z",
|
|
231
|
-
summary: { contradictions: 0, duplicates: 0, staleMemories: 0, orphans: 0 },
|
|
232
|
-
};
|
|
233
|
-
const output = formatMemoryLintReport(report);
|
|
234
|
-
expect(output).toContain("All Clear");
|
|
235
|
-
expect(output).toContain("100/100");
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("includes findings when present", () => {
|
|
239
|
-
const report: MemoryLintReport = {
|
|
240
|
-
findings: [
|
|
241
|
-
{ check: "contradiction", severity: "warning", detail: '"A" vs "B"', memoryIds: ["id1", "id2"] },
|
|
242
|
-
],
|
|
243
|
-
healthScore: 90,
|
|
244
|
-
totalScanned: 100,
|
|
245
|
-
timestamp: "2026-04-08T12:00:00Z",
|
|
246
|
-
summary: { contradictions: 1, duplicates: 0, staleMemories: 0, orphans: 0 },
|
|
247
|
-
};
|
|
248
|
-
const output = formatMemoryLintReport(report);
|
|
249
|
-
expect(output).toContain("Contradictions (1)");
|
|
250
|
-
expect(output).toContain("90/100");
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it("summarizes stale when count > 5", () => {
|
|
254
|
-
const staleFindings = Array.from({ length: 10 }, (_, i) => ({
|
|
255
|
-
check: "stale" as const,
|
|
256
|
-
severity: "info" as const,
|
|
257
|
-
detail: `${100 + i}d old`,
|
|
258
|
-
memoryIds: [`stale${i}`],
|
|
259
|
-
}));
|
|
260
|
-
const report: MemoryLintReport = {
|
|
261
|
-
findings: staleFindings,
|
|
262
|
-
healthScore: 95,
|
|
263
|
-
totalScanned: 200,
|
|
264
|
-
timestamp: "2026-04-08T12:00:00Z",
|
|
265
|
-
summary: { contradictions: 0, duplicates: 0, staleMemories: 10, orphans: 0 },
|
|
266
|
-
};
|
|
267
|
-
const output = formatMemoryLintReport(report);
|
|
268
|
-
expect(output).toContain("Stale (10)");
|
|
269
|
-
expect(output).toContain("10 memories not accessed");
|
|
270
|
-
});
|
|
271
|
-
});
|
|
@@ -1,215 +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("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
|
-
});
|