recallnest 3.0.0 → 3.0.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.
Files changed (184) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +222 -254
  3. package/README_CN.md +206 -243
  4. package/package.json +3 -2
  5. package/src/capture-engine.ts +26 -4
  6. package/src/context-composer-stable.ts +5 -1
  7. package/src/embedder.ts +24 -0
  8. package/src/env-config.ts +18 -0
  9. package/src/ingest.ts +225 -17
  10. package/src/kg-extractor.ts +17 -0
  11. package/src/memory-output.ts +35 -0
  12. package/src/pivot-apply.ts +52 -1
  13. package/src/pivot-evidence.ts +128 -0
  14. package/src/ppr-traversal.ts +25 -1
  15. package/src/runtime-config.ts +9 -0
  16. package/src/session-engine.ts +11 -4
  17. package/src/session-output.ts +9 -1
  18. package/src/session-store.ts +2 -3
  19. package/src/skill-promotion.ts +67 -1
  20. package/src/__tests__/access-tracker-novelty.test.ts +0 -324
  21. package/src/__tests__/activity-counter.test.ts +0 -125
  22. package/src/__tests__/adaptive-fidelity.test.ts +0 -102
  23. package/src/__tests__/admission-control.test.ts +0 -206
  24. package/src/__tests__/age-label.test.ts +0 -33
  25. package/src/__tests__/anchor-generator.test.ts +0 -67
  26. package/src/__tests__/api-server-security.test.ts +0 -102
  27. package/src/__tests__/auto-consolidation.test.ts +0 -168
  28. package/src/__tests__/auto-recall.test.ts +0 -131
  29. package/src/__tests__/babel-integration.test.ts +0 -144
  30. package/src/__tests__/batch-dedup.test.ts +0 -65
  31. package/src/__tests__/belief-history.test.ts +0 -220
  32. package/src/__tests__/canary-eval.test.ts +0 -114
  33. package/src/__tests__/capture-engine.test.ts +0 -1328
  34. package/src/__tests__/capture-heuristic.test.ts +0 -171
  35. package/src/__tests__/cascade-forget.test.ts +0 -210
  36. package/src/__tests__/category-min-scores.test.ts +0 -116
  37. package/src/__tests__/cc8-cc1-essential-context.test.ts +0 -298
  38. package/src/__tests__/circuit-breaker.test.ts +0 -99
  39. package/src/__tests__/cluster-consolidation.test.ts +0 -1236
  40. package/src/__tests__/confidence-metadata.test.ts +0 -125
  41. package/src/__tests__/confidence-tracker.test.ts +0 -261
  42. package/src/__tests__/conflict-advisor.test.ts +0 -206
  43. package/src/__tests__/conflict-escalation.test.ts +0 -149
  44. package/src/__tests__/conflict-lifecycle.test.ts +0 -83
  45. package/src/__tests__/conflict-output.test.ts +0 -85
  46. package/src/__tests__/conflict-store.test.ts +0 -418
  47. package/src/__tests__/connector-v1.test.ts +0 -181
  48. package/src/__tests__/consolidation-engine.test.ts +0 -520
  49. package/src/__tests__/constructive-retrieval.test.ts +0 -509
  50. package/src/__tests__/context-collapse-renderer.test.ts +0 -214
  51. package/src/__tests__/context-composer-pins.test.ts +0 -64
  52. package/src/__tests__/context-composer-task-selection.test.ts +0 -24
  53. package/src/__tests__/context-reconstructor.test.ts +0 -65
  54. package/src/__tests__/context-renderer.test.ts +0 -91
  55. package/src/__tests__/continuity-eval.test.ts +0 -275
  56. package/src/__tests__/continuity-schema.test.ts +0 -97
  57. package/src/__tests__/contracts.test.ts +0 -262
  58. package/src/__tests__/conversation-importer.test.ts +0 -692
  59. package/src/__tests__/core-recall-eval.test.ts +0 -235
  60. package/src/__tests__/core-summary.test.ts +0 -109
  61. package/src/__tests__/data-checkup.test.ts +0 -304
  62. package/src/__tests__/decay-exemption.test.ts +0 -129
  63. package/src/__tests__/dedup-actions.test.ts +0 -58
  64. package/src/__tests__/dedup-guard.test.ts +0 -39
  65. package/src/__tests__/deterministic-id.test.ts +0 -39
  66. package/src/__tests__/distill-lock.test.ts +0 -305
  67. package/src/__tests__/distill-session-argshape.test.ts +0 -79
  68. package/src/__tests__/doctor.test.ts +0 -319
  69. package/src/__tests__/dream-pipeline.test.ts +0 -820
  70. package/src/__tests__/dream-scope-isolation.test.ts +0 -386
  71. package/src/__tests__/dream-write-batching.test.ts +0 -211
  72. package/src/__tests__/drill-down.test.ts +0 -108
  73. package/src/__tests__/embedder.test.ts +0 -122
  74. package/src/__tests__/emotion-decay.test.ts +0 -46
  75. package/src/__tests__/emotion-detector.test.ts +0 -56
  76. package/src/__tests__/emotion-phase1-integration.test.ts +0 -153
  77. package/src/__tests__/emotion-retrieval.test.ts +0 -56
  78. package/src/__tests__/entity-resolver.test.ts +0 -58
  79. package/src/__tests__/env-config-invariant.test.ts +0 -80
  80. package/src/__tests__/env-config.test.ts +0 -211
  81. package/src/__tests__/error-signature-boost.test.ts +0 -87
  82. package/src/__tests__/error-signature.test.ts +0 -95
  83. package/src/__tests__/error-taxonomy.test.ts +0 -129
  84. package/src/__tests__/ethics-layer.test.ts +0 -476
  85. package/src/__tests__/event-segmenter.test.ts +0 -153
  86. package/src/__tests__/feature-flags-integration.test.ts +0 -54
  87. package/src/__tests__/frequency-tracker.test.ts +0 -113
  88. package/src/__tests__/freshness.test.ts +0 -186
  89. package/src/__tests__/graph-export.test.ts +0 -489
  90. package/src/__tests__/hotness-blend.test.ts +0 -283
  91. package/src/__tests__/ingest-chunking.test.ts +0 -44
  92. package/src/__tests__/ingest-scope-prefix.test.ts +0 -69
  93. package/src/__tests__/ingest.test.ts +0 -360
  94. package/src/__tests__/interference-detector.test.ts +0 -203
  95. package/src/__tests__/kg-extractor.test.ts +0 -192
  96. package/src/__tests__/kg-store.test.ts +0 -300
  97. package/src/__tests__/llm-client-pivot.test.ts +0 -628
  98. package/src/__tests__/llm-consolidation.test.ts +0 -226
  99. package/src/__tests__/maintenance-locks.test.ts +0 -197
  100. package/src/__tests__/mcp-efficiency.test.ts +0 -288
  101. package/src/__tests__/mcp-related-scopes.test.ts +0 -151
  102. package/src/__tests__/memory-boundaries.test.ts +0 -282
  103. package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +0 -362
  104. package/src/__tests__/memory-evolution.test.ts +0 -271
  105. package/src/__tests__/memory-health-rebalance.test.ts +0 -144
  106. package/src/__tests__/memory-lint.test.ts +0 -421
  107. package/src/__tests__/memory-output.test.ts +0 -224
  108. package/src/__tests__/memory-promotion.test.ts +0 -315
  109. package/src/__tests__/memory-utility.test.ts +0 -256
  110. package/src/__tests__/migrate-dedup-ids.test.ts +0 -65
  111. package/src/__tests__/multi-vector.test.ts +0 -242
  112. package/src/__tests__/narrative-architecture.test.ts +0 -456
  113. package/src/__tests__/noise-filter.test.ts +0 -205
  114. package/src/__tests__/noise-prototype-bank.test.ts +0 -280
  115. package/src/__tests__/obsidian-connector.test.ts +0 -363
  116. package/src/__tests__/omitted-reporting.test.ts +0 -98
  117. package/src/__tests__/openai-contract.test.ts +0 -513
  118. package/src/__tests__/pending-review.test.ts +0 -77
  119. package/src/__tests__/pii-redact.test.ts +0 -333
  120. package/src/__tests__/pivot-apply.test.ts +0 -373
  121. package/src/__tests__/pivot-distill-supervisor.test.ts +0 -457
  122. package/src/__tests__/pivot-distill.test.ts +0 -1178
  123. package/src/__tests__/post-retrieval-filter.test.ts +0 -178
  124. package/src/__tests__/ppr-traversal.test.ts +0 -256
  125. package/src/__tests__/prediction-engine.test.ts +0 -349
  126. package/src/__tests__/predictive-prospective-memory.test.ts +0 -416
  127. package/src/__tests__/preference-guard-smoke.test.ts +0 -211
  128. package/src/__tests__/preference-matcher.test.ts +0 -282
  129. package/src/__tests__/preference-slots.test.ts +0 -205
  130. package/src/__tests__/promotion-distinct-sources.test.ts +0 -162
  131. package/src/__tests__/prospective-memory.test.ts +0 -283
  132. package/src/__tests__/pull-from-macbook-sync-only.test.ts +0 -679
  133. package/src/__tests__/query-entity-detector.test.ts +0 -171
  134. package/src/__tests__/query-expander-alias.test.ts +0 -146
  135. package/src/__tests__/query-expander.test.ts +0 -34
  136. package/src/__tests__/recall-gate.test.ts +0 -266
  137. package/src/__tests__/recall-governor.test.ts +0 -227
  138. package/src/__tests__/recall-mode.test.ts +0 -64
  139. package/src/__tests__/resolve-db-path.test.ts +0 -130
  140. package/src/__tests__/resolve-tier.test.ts +0 -64
  141. package/src/__tests__/result-synthesizer.test.ts +0 -198
  142. package/src/__tests__/resume-context.test.ts +0 -4898
  143. package/src/__tests__/retrieval-eval.test.ts +0 -163
  144. package/src/__tests__/retrieval-trace.test.ts +0 -213
  145. package/src/__tests__/retrieve-audit-revision.test.ts +0 -255
  146. package/src/__tests__/retriever-boundary-weight.test.ts +0 -136
  147. package/src/__tests__/retriever-lazy-init-dispatch.test.ts +0 -123
  148. package/src/__tests__/retroactive-boost.test.ts +0 -223
  149. package/src/__tests__/salience-scoring.test.ts +0 -106
  150. package/src/__tests__/scope-inventory.test.ts +0 -200
  151. package/src/__tests__/scope-policy.test.ts +0 -69
  152. package/src/__tests__/scope-suggester.test.ts +0 -80
  153. package/src/__tests__/session-checkpoint.test.ts +0 -291
  154. package/src/__tests__/session-distiller.test.ts +0 -640
  155. package/src/__tests__/session-gc.test.ts +0 -215
  156. package/src/__tests__/skill-engine.test.ts +0 -552
  157. package/src/__tests__/skill-promotion.test.ts +0 -654
  158. package/src/__tests__/skill-verifier.test.ts +0 -122
  159. package/src/__tests__/source-heartbeat.test.ts +0 -254
  160. package/src/__tests__/stable-context-length-contract.test.ts +0 -62
  161. package/src/__tests__/store-patch-metadata.test.ts +0 -235
  162. package/src/__tests__/store-read-consistency.test.ts +0 -122
  163. package/src/__tests__/store-schema-migration.test.ts +0 -87
  164. package/src/__tests__/store-scope-audit.test.ts +0 -81
  165. package/src/__tests__/store-upsert.test.ts +0 -201
  166. package/src/__tests__/supersede-chain.test.ts +0 -154
  167. package/src/__tests__/synthesis-contract.test.ts +0 -252
  168. package/src/__tests__/synthesis-promotion.test.ts +0 -369
  169. package/src/__tests__/temporal-parser.test.ts +0 -241
  170. package/src/__tests__/temporal-validity.test.ts +0 -160
  171. package/src/__tests__/term-registry-terminal-roster.test.ts +0 -127
  172. package/src/__tests__/term-registry.test.ts +0 -121
  173. package/src/__tests__/tool-error-surfacing.test.ts +0 -98
  174. package/src/__tests__/tool-output-compressor.test.ts +0 -160
  175. package/src/__tests__/topic-tag.test.ts +0 -113
  176. package/src/__tests__/trusted-memory.test.ts +0 -867
  177. package/src/__tests__/ui-server-security.test.ts +0 -93
  178. package/src/__tests__/usage-tracker.test.ts +0 -287
  179. package/src/__tests__/utility-weight.test.ts +0 -57
  180. package/src/__tests__/verbatim-self-recall.test.ts +0 -279
  181. package/src/__tests__/version-manager.test.ts +0 -248
  182. package/src/__tests__/workflow-observation-skill-outcome.test.ts +0 -352
  183. package/src/__tests__/workflow-observation.test.ts +0 -433
  184. package/src/__tests__/write-verifier.test.ts +0 -122
@@ -1,319 +0,0 @@
1
- import { describe, expect, it } from "bun:test";
2
-
3
- import {
4
- assessContinuityBaseline,
5
- assessScopeInventoryReport,
6
- describeSecretPresence,
7
- formatDoctorResults,
8
- loadContinuityBaselineEntries,
9
- } from "../doctor.js";
10
- import type { MemoryEntry } from "../store.js";
11
-
12
- function buildEntry(
13
- id: string,
14
- category: MemoryEntry["category"],
15
- text: string,
16
- scope: string,
17
- metadata: Record<string, unknown> = {},
18
- ): MemoryEntry {
19
- return {
20
- id,
21
- text,
22
- vector: [],
23
- category,
24
- scope,
25
- importance: 0.8,
26
- timestamp: Date.parse("2026-03-17T00:00:00.000Z"),
27
- metadata: JSON.stringify(metadata),
28
- };
29
- }
30
-
31
- describe("assessContinuityBaseline", () => {
32
- it("reports full coverage when all canonical continuity seeds are present", () => {
33
- const seeds = {
34
- patterns: [
35
- {
36
- title: "Cross-window continuity handoff",
37
- trigger: "When opening a fresh terminal window",
38
- steps: ["Call resume_context before coding."],
39
- outcome: "Fresh windows recover stable context.",
40
- tools: ["resume_context"],
41
- importance: 0.9,
42
- source: "agent",
43
- },
44
- ],
45
- cases: [
46
- {
47
- title: "Continuity eval checkpoint isolation",
48
- problem: "Eval reads live checkpoints.",
49
- solutionSteps: ["Use fixture checkpoints instead."],
50
- outcome: "Continuity eval becomes deterministic.",
51
- tools: ["eval:continuity"],
52
- source: "agent",
53
- scope: "recallnest",
54
- importance: 0.85,
55
- },
56
- ],
57
- memories: [
58
- {
59
- text: "RecallNest is the shared memory layer for Claude Code, Codex, and Gemini CLI.",
60
- category: "entities",
61
- scope: "recallnest",
62
- source: "agent",
63
- importance: 0.9,
64
- canonicalKey: "entities:recallnest:shared-memory-layer",
65
- },
66
- ],
67
- };
68
-
69
- const entries: MemoryEntry[] = [
70
- buildEntry(
71
- "pattern-1",
72
- "patterns",
73
- "Workflow pattern: Cross-window continuity handoff",
74
- "memory:agent",
75
- { workflowPattern: { title: "Cross-window continuity handoff" } },
76
- ),
77
- buildEntry(
78
- "case-1",
79
- "cases",
80
- "Case: Continuity eval checkpoint isolation",
81
- "recallnest",
82
- { caseMemory: { title: "Continuity eval checkpoint isolation" } },
83
- ),
84
- buildEntry(
85
- "memory-1",
86
- "entities",
87
- "RecallNest is the shared memory layer for Claude Code, Codex, and Gemini CLI.",
88
- "recallnest",
89
- { canonicalKey: "entities:recallnest:shared-memory-layer" },
90
- ),
91
- ];
92
-
93
- const assessment = assessContinuityBaseline(entries, seeds as any);
94
-
95
- expect(assessment.found).toEqual({ patterns: 1, cases: 1, memories: 1 });
96
- expect(assessment.missing).toEqual({ patterns: [], cases: [], memories: [] });
97
- });
98
-
99
- it("reports missing canonical seeds by category", () => {
100
- const seeds = {
101
- patterns: [
102
- {
103
- title: "Recall before repo exploration",
104
- trigger: "When startup context is sparse",
105
- steps: ["Run search_memory before local repo exploration."],
106
- outcome: "Fresh windows recover task-specific continuity.",
107
- tools: ["resume_context", "search_memory"],
108
- importance: 0.9,
109
- source: "agent",
110
- },
111
- ],
112
- cases: [
113
- {
114
- title: "RecallNest scope fallback cleanup",
115
- problem: "Project continuity prefers raw transcript notes.",
116
- solutionSteps: ["Prefer durable cases and patterns."],
117
- outcome: "Stable project continuity becomes cleaner.",
118
- tools: ["resume_context"],
119
- source: "agent",
120
- scope: "recallnest",
121
- importance: 0.85,
122
- },
123
- ],
124
- memories: [
125
- {
126
- text: "RecallNest continuity revolves around three primitives.",
127
- category: "entities",
128
- scope: "recallnest",
129
- source: "agent",
130
- importance: 0.9,
131
- canonicalKey: "entities:recallnest:continuity-primitives",
132
- },
133
- ],
134
- };
135
-
136
- const entries: MemoryEntry[] = [
137
- buildEntry(
138
- "pattern-1",
139
- "patterns",
140
- "Workflow pattern: Cross-window continuity handoff",
141
- "memory:agent",
142
- { workflowPattern: { title: "Cross-window continuity handoff" } },
143
- ),
144
- ];
145
-
146
- const assessment = assessContinuityBaseline(entries, seeds as any);
147
-
148
- expect(assessment.found).toEqual({ patterns: 0, cases: 0, memories: 0 });
149
- expect(assessment.missing.patterns).toEqual(["Recall before repo exploration"]);
150
- expect(assessment.missing.cases).toEqual(["RecallNest scope fallback cleanup"]);
151
- expect(assessment.missing.memories).toEqual(["entities:recallnest:continuity-primitives"]);
152
- });
153
-
154
- it("loads enough entries for baseline checks when the index is larger than the legacy 5000-entry window", async () => {
155
- const targetEntry = buildEntry(
156
- "pattern-target",
157
- "patterns",
158
- "Workflow pattern: RecallNest MCP transport rollout",
159
- "project:recallnest",
160
- { workflowPattern: { title: "RecallNest MCP transport rollout" } },
161
- );
162
- const entries: MemoryEntry[] = [
163
- ...Array.from({ length: 5000 }, (_, index) => buildEntry(
164
- `noise-${index}`,
165
- "patterns",
166
- `Workflow pattern: Noise ${index}`,
167
- "memory:agent",
168
- { workflowPattern: { title: `Noise ${index}` } },
169
- )),
170
- targetEntry,
171
- ];
172
- const listCalls: Array<[string[] | undefined, string | undefined, number | undefined, number | undefined]> = [];
173
- const store = {
174
- async list(scopeFilter?: string[], category?: string, limit = 20, offset = 0): Promise<MemoryEntry[]> {
175
- listCalls.push([scopeFilter, category, limit, offset]);
176
- return entries.slice(offset, offset + limit);
177
- },
178
- };
179
-
180
- const loaded = await loadContinuityBaselineEntries(store as any, entries.length);
181
- const assessment = assessContinuityBaseline(loaded, {
182
- patterns: [
183
- {
184
- title: "RecallNest MCP transport rollout",
185
- trigger: "When RecallNest continuity work touches MCP transport wiring under project scope",
186
- steps: ["Call resume_context with project:recallnest before transport changes."],
187
- outcome: "RecallNest transport changes stay project-scoped.",
188
- tools: ["resume_context", "search_memory", "eval:continuity"],
189
- source: "agent",
190
- scope: "project:recallnest",
191
- importance: 0.87,
192
- },
193
- ],
194
- cases: [],
195
- memories: [],
196
- } as any);
197
-
198
- expect(listCalls).toEqual([[undefined, undefined, 5001, 0]]);
199
- expect(assessment.found.patterns).toBe(1);
200
- expect(assessment.missing.patterns).toEqual([]);
201
- });
202
- });
203
-
204
- describe("assessScopeInventoryReport", () => {
205
- it("reports a clean scope inventory when no unresolved anomalies remain", () => {
206
- const result = assessScopeInventoryReport({
207
- generatedAt: "2026-03-19T08:20:00.000Z",
208
- sampleLimit: 5,
209
- totalScannedCount: 42,
210
- totalAnomalyCount: 0,
211
- totalInvalidCount: 0,
212
- totalReviewedCount: 1,
213
- layers: [
214
- {
215
- layer: "memories",
216
- scannedCount: 40,
217
- anomalyCount: 0,
218
- invalidCount: 0,
219
- reviewedCount: 0,
220
- counts: { missing: 0, empty: 0, global: 0 },
221
- samples: [],
222
- recommendation: "ok",
223
- },
224
- {
225
- layer: "workflow-observations",
226
- scannedCount: 2,
227
- anomalyCount: 0,
228
- invalidCount: 0,
229
- reviewedCount: 1,
230
- counts: { missing: 0, empty: 0, global: 0 },
231
- samples: [],
232
- recommendation: "ok",
233
- },
234
- ],
235
- });
236
-
237
- expect(result).toEqual({
238
- name: "Scope inventory",
239
- status: "pass",
240
- message: "0 unresolved anomalies across 42 records; reviewed keeps 1",
241
- });
242
- });
243
-
244
- it("warns when scope inventory still has unresolved anomalies or invalid files", () => {
245
- const result = assessScopeInventoryReport({
246
- generatedAt: "2026-03-19T08:20:00.000Z",
247
- sampleLimit: 5,
248
- totalScannedCount: 12,
249
- totalAnomalyCount: 2,
250
- totalInvalidCount: 1,
251
- totalReviewedCount: 0,
252
- layers: [
253
- {
254
- layer: "pins",
255
- scannedCount: 4,
256
- anomalyCount: 1,
257
- invalidCount: 0,
258
- reviewedCount: 0,
259
- counts: { missing: 0, empty: 0, global: 1 },
260
- samples: [{
261
- layer: "pins",
262
- id: "pin-legacy-1234",
263
- kind: "global",
264
- scope: "global",
265
- context: "pin",
266
- preview: "Legacy pin",
267
- recordedAt: "2026-03-19T08:00:00.000Z",
268
- }],
269
- recommendation: "re-pin",
270
- },
271
- {
272
- layer: "workflow-observations",
273
- scannedCount: 8,
274
- anomalyCount: 1,
275
- invalidCount: 1,
276
- reviewedCount: 0,
277
- counts: { missing: 1, empty: 0, global: 0 },
278
- samples: [],
279
- recommendation: "review",
280
- },
281
- ],
282
- });
283
-
284
- expect(result.status).toBe("warn");
285
- expect(result.name).toBe("Scope inventory");
286
- expect(result.message).toContain("2 unresolved anomalies, 1 invalid file(s) across 12 records");
287
- expect(result.message).toContain("pins:1");
288
- expect(result.message).toContain("workflow-observations:1 invalid 1");
289
- expect(result.message).toContain("sample pins:global:pin-lega");
290
- expect(result.fix).toBe("bun run scope-inventory");
291
- });
292
- });
293
-
294
- describe("formatDoctorResults", () => {
295
- it("does not claim all clear when warnings are present", () => {
296
- const output = formatDoctorResults([
297
- { name: "Bun runtime", status: "pass", message: "ok" },
298
- { name: "Scope inventory", status: "warn", message: "1 unresolved anomaly", fix: "bun run scope-inventory" },
299
- ]);
300
-
301
- expect(output).toContain("Review the ⚠️ items above before relying on this environment as a clean baseline.");
302
- expect(output).not.toContain("All clear.");
303
- });
304
- });
305
-
306
- describe("describeSecretPresence", () => {
307
- it("reports only presence and never includes the configured value", () => {
308
- const secret = "sensitive-value-that-must-not-appear";
309
- const message = describeSecretPresence(secret, "placeholder");
310
-
311
- expect(message).toBe("set");
312
- expect(message).not.toContain(secret);
313
- });
314
-
315
- it("does not treat an absent or placeholder value as configured", () => {
316
- expect(describeSecretPresence(undefined, "placeholder")).toBeNull();
317
- expect(describeSecretPresence("placeholder", "placeholder")).toBeNull();
318
- });
319
- });