@nxuss/lemma 1.37.0 → 1.39.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.
Files changed (284) hide show
  1. package/README.md +9 -6
  2. package/bin/brain-ingest.js +86 -27
  3. package/bin/doctor.js +31 -4
  4. package/bin/init.js +98 -60
  5. package/dashboard/dist/assets/index-DNTQXLER.css +1 -0
  6. package/dashboard/dist/assets/index-DzL_Zu3m.js +452 -0
  7. package/dashboard/dist/index.html +2 -2
  8. package/dist/cjs/cli/gitHooks.d.ts +9 -2
  9. package/dist/cjs/cli/gitHooks.d.ts.map +1 -1
  10. package/dist/cjs/cli/gitHooks.js +31 -4
  11. package/dist/cjs/cli/gitHooks.js.map +1 -1
  12. package/dist/cjs/cli/hostHooks.d.ts +13 -1
  13. package/dist/cjs/cli/hostHooks.d.ts.map +1 -1
  14. package/dist/cjs/cli/hostHooks.js +34 -4
  15. package/dist/cjs/cli/hostHooks.js.map +1 -1
  16. package/dist/cjs/cli/lemma-proxy.d.ts.map +1 -1
  17. package/dist/cjs/cli/lemma-proxy.js +42 -5
  18. package/dist/cjs/cli/lemma-proxy.js.map +1 -1
  19. package/dist/cjs/infra/analyzers/index.d.ts +0 -2
  20. package/dist/cjs/infra/analyzers/index.d.ts.map +1 -1
  21. package/dist/cjs/infra/analyzers/index.js +1 -6
  22. package/dist/cjs/infra/analyzers/index.js.map +1 -1
  23. package/dist/cjs/infra/cli.d.ts +4 -0
  24. package/dist/cjs/infra/cli.d.ts.map +1 -1
  25. package/dist/cjs/infra/cli.js +6 -199
  26. package/dist/cjs/infra/cli.js.map +1 -1
  27. package/dist/cjs/infra/index.d.ts +1 -3
  28. package/dist/cjs/infra/index.d.ts.map +1 -1
  29. package/dist/cjs/infra/index.js +1 -16
  30. package/dist/cjs/infra/index.js.map +1 -1
  31. package/dist/cjs/infra/mcp-tools.d.ts.map +1 -1
  32. package/dist/cjs/infra/mcp-tools.js +8 -453
  33. package/dist/cjs/infra/mcp-tools.js.map +1 -1
  34. package/dist/cjs/infra/types.d.ts +0 -101
  35. package/dist/cjs/infra/types.d.ts.map +1 -1
  36. package/dist/cjs/infra/types.js +2 -1
  37. package/dist/cjs/infra/types.js.map +1 -1
  38. package/dist/cjs/mcp/index.js +33 -10
  39. package/dist/cjs/mcp/index.js.map +1 -1
  40. package/dist/cjs/mcp/prompts.d.ts +1 -1
  41. package/dist/cjs/mcp/prompts.d.ts.map +1 -1
  42. package/dist/cjs/mcp/prompts.js +8 -21
  43. package/dist/cjs/mcp/prompts.js.map +1 -1
  44. package/dist/cjs/mcp/tool-profiles.d.ts +8 -3
  45. package/dist/cjs/mcp/tool-profiles.d.ts.map +1 -1
  46. package/dist/cjs/mcp/tool-profiles.js +25 -54
  47. package/dist/cjs/mcp/tool-profiles.js.map +1 -1
  48. package/dist/cjs/mcp/tools/memory.d.ts +8 -0
  49. package/dist/cjs/mcp/tools/memory.d.ts.map +1 -1
  50. package/dist/cjs/mcp/tools/memory.js +154 -125
  51. package/dist/cjs/mcp/tools/memory.js.map +1 -1
  52. package/dist/cjs/mcp/tools.d.ts.map +1 -1
  53. package/dist/cjs/mcp/tools.js +11 -6
  54. package/dist/cjs/mcp/tools.js.map +1 -1
  55. package/dist/cjs/mcp/workspaceShared.d.ts.map +1 -1
  56. package/dist/cjs/mcp/workspaceShared.js +13 -12
  57. package/dist/cjs/mcp/workspaceShared.js.map +1 -1
  58. package/dist/cjs/proxy/ProjectRegistry.d.ts +44 -0
  59. package/dist/cjs/proxy/ProjectRegistry.d.ts.map +1 -1
  60. package/dist/cjs/proxy/ProjectRegistry.js +92 -3
  61. package/dist/cjs/proxy/ProjectRegistry.js.map +1 -1
  62. package/dist/cjs/subconscious/HostRecall.d.ts +36 -3
  63. package/dist/cjs/subconscious/HostRecall.d.ts.map +1 -1
  64. package/dist/cjs/subconscious/HostRecall.js +164 -37
  65. package/dist/cjs/subconscious/HostRecall.js.map +1 -1
  66. package/dist/cjs/subconscious/NarrowEvidence.d.ts +47 -0
  67. package/dist/cjs/subconscious/NarrowEvidence.d.ts.map +1 -0
  68. package/dist/cjs/subconscious/NarrowEvidence.js +252 -0
  69. package/dist/cjs/subconscious/NarrowEvidence.js.map +1 -0
  70. package/dist/cjs/subconscious/TheBrainV2.d.ts +37 -0
  71. package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
  72. package/dist/cjs/subconscious/TheBrainV2.js +147 -15
  73. package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
  74. package/dist/cjs/subconscious/freshness/LocalFsResolver.d.ts.map +1 -1
  75. package/dist/cjs/subconscious/freshness/LocalFsResolver.js +17 -0
  76. package/dist/cjs/subconscious/freshness/LocalFsResolver.js.map +1 -1
  77. package/dist/cjs/subconscious/recallDigest.d.ts +42 -0
  78. package/dist/cjs/subconscious/recallDigest.d.ts.map +1 -0
  79. package/dist/cjs/subconscious/recallDigest.js +94 -0
  80. package/dist/cjs/subconscious/recallDigest.js.map +1 -0
  81. package/dist/cjs/utils/OtherLanguageSymbols.d.ts +31 -0
  82. package/dist/cjs/utils/OtherLanguageSymbols.d.ts.map +1 -0
  83. package/dist/cjs/utils/OtherLanguageSymbols.js +283 -0
  84. package/dist/cjs/utils/OtherLanguageSymbols.js.map +1 -0
  85. package/dist/cjs/utils/SavingsLedger.d.ts +27 -0
  86. package/dist/cjs/utils/SavingsLedger.d.ts.map +1 -1
  87. package/dist/cjs/utils/SavingsLedger.js +51 -0
  88. package/dist/cjs/utils/SavingsLedger.js.map +1 -1
  89. package/dist/cjs/utils/StoreDraft.d.ts +12 -0
  90. package/dist/cjs/utils/StoreDraft.d.ts.map +1 -1
  91. package/dist/cjs/utils/StoreDraft.js +53 -1
  92. package/dist/cjs/utils/StoreDraft.js.map +1 -1
  93. package/dist/cjs/utils/SymbolSurgicalContext.d.ts +2 -0
  94. package/dist/cjs/utils/SymbolSurgicalContext.d.ts.map +1 -1
  95. package/dist/cjs/utils/SymbolSurgicalContext.js +1 -0
  96. package/dist/cjs/utils/SymbolSurgicalContext.js.map +1 -1
  97. package/dist/cjs/utils/reportSavings.d.ts +17 -4
  98. package/dist/cjs/utils/reportSavings.d.ts.map +1 -1
  99. package/dist/cjs/utils/reportSavings.js +67 -22
  100. package/dist/cjs/utils/reportSavings.js.map +1 -1
  101. package/dist/esm/cli/gitHooks.d.ts +9 -2
  102. package/dist/esm/cli/gitHooks.d.ts.map +1 -1
  103. package/dist/esm/cli/gitHooks.js +31 -4
  104. package/dist/esm/cli/gitHooks.js.map +1 -1
  105. package/dist/esm/cli/hostHooks.d.ts +13 -1
  106. package/dist/esm/cli/hostHooks.d.ts.map +1 -1
  107. package/dist/esm/cli/hostHooks.js +32 -3
  108. package/dist/esm/cli/hostHooks.js.map +1 -1
  109. package/dist/esm/cli/lemma-proxy.d.ts.map +1 -1
  110. package/dist/esm/cli/lemma-proxy.js +42 -5
  111. package/dist/esm/cli/lemma-proxy.js.map +1 -1
  112. package/dist/esm/infra/analyzers/index.d.ts +0 -2
  113. package/dist/esm/infra/analyzers/index.d.ts.map +1 -1
  114. package/dist/esm/infra/analyzers/index.js +0 -2
  115. package/dist/esm/infra/analyzers/index.js.map +1 -1
  116. package/dist/esm/infra/cli.d.ts +4 -0
  117. package/dist/esm/infra/cli.d.ts.map +1 -1
  118. package/dist/esm/infra/cli.js +6 -199
  119. package/dist/esm/infra/cli.js.map +1 -1
  120. package/dist/esm/infra/index.d.ts +1 -3
  121. package/dist/esm/infra/index.d.ts.map +1 -1
  122. package/dist/esm/infra/index.js +1 -3
  123. package/dist/esm/infra/index.js.map +1 -1
  124. package/dist/esm/infra/mcp-tools.d.ts.map +1 -1
  125. package/dist/esm/infra/mcp-tools.js +9 -454
  126. package/dist/esm/infra/mcp-tools.js.map +1 -1
  127. package/dist/esm/infra/types.d.ts +0 -101
  128. package/dist/esm/infra/types.d.ts.map +1 -1
  129. package/dist/esm/infra/types.js +2 -1
  130. package/dist/esm/infra/types.js.map +1 -1
  131. package/dist/esm/mcp/index.js +33 -10
  132. package/dist/esm/mcp/index.js.map +1 -1
  133. package/dist/esm/mcp/prompts.d.ts +1 -1
  134. package/dist/esm/mcp/prompts.d.ts.map +1 -1
  135. package/dist/esm/mcp/prompts.js +8 -21
  136. package/dist/esm/mcp/prompts.js.map +1 -1
  137. package/dist/esm/mcp/tool-profiles.d.ts +8 -3
  138. package/dist/esm/mcp/tool-profiles.d.ts.map +1 -1
  139. package/dist/esm/mcp/tool-profiles.js +25 -54
  140. package/dist/esm/mcp/tool-profiles.js.map +1 -1
  141. package/dist/esm/mcp/tools/memory.d.ts +8 -0
  142. package/dist/esm/mcp/tools/memory.d.ts.map +1 -1
  143. package/dist/esm/mcp/tools/memory.js +156 -128
  144. package/dist/esm/mcp/tools/memory.js.map +1 -1
  145. package/dist/esm/mcp/tools.d.ts.map +1 -1
  146. package/dist/esm/mcp/tools.js +12 -7
  147. package/dist/esm/mcp/tools.js.map +1 -1
  148. package/dist/esm/mcp/workspaceShared.d.ts.map +1 -1
  149. package/dist/esm/mcp/workspaceShared.js +13 -12
  150. package/dist/esm/mcp/workspaceShared.js.map +1 -1
  151. package/dist/esm/proxy/ProjectRegistry.d.ts +44 -0
  152. package/dist/esm/proxy/ProjectRegistry.d.ts.map +1 -1
  153. package/dist/esm/proxy/ProjectRegistry.js +91 -2
  154. package/dist/esm/proxy/ProjectRegistry.js.map +1 -1
  155. package/dist/esm/subconscious/HostRecall.d.ts +36 -3
  156. package/dist/esm/subconscious/HostRecall.d.ts.map +1 -1
  157. package/dist/esm/subconscious/HostRecall.js +159 -36
  158. package/dist/esm/subconscious/HostRecall.js.map +1 -1
  159. package/dist/esm/subconscious/NarrowEvidence.d.ts +47 -0
  160. package/dist/esm/subconscious/NarrowEvidence.d.ts.map +1 -0
  161. package/dist/esm/subconscious/NarrowEvidence.js +211 -0
  162. package/dist/esm/subconscious/NarrowEvidence.js.map +1 -0
  163. package/dist/esm/subconscious/TheBrainV2.d.ts +37 -0
  164. package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
  165. package/dist/esm/subconscious/TheBrainV2.js +146 -14
  166. package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
  167. package/dist/esm/subconscious/freshness/LocalFsResolver.d.ts.map +1 -1
  168. package/dist/esm/subconscious/freshness/LocalFsResolver.js +17 -0
  169. package/dist/esm/subconscious/freshness/LocalFsResolver.js.map +1 -1
  170. package/dist/esm/subconscious/recallDigest.d.ts +42 -0
  171. package/dist/esm/subconscious/recallDigest.d.ts.map +1 -0
  172. package/dist/esm/subconscious/recallDigest.js +87 -0
  173. package/dist/esm/subconscious/recallDigest.js.map +1 -0
  174. package/dist/esm/utils/OtherLanguageSymbols.d.ts +31 -0
  175. package/dist/esm/utils/OtherLanguageSymbols.d.ts.map +1 -0
  176. package/dist/esm/utils/OtherLanguageSymbols.js +275 -0
  177. package/dist/esm/utils/OtherLanguageSymbols.js.map +1 -0
  178. package/dist/esm/utils/SavingsLedger.d.ts +27 -0
  179. package/dist/esm/utils/SavingsLedger.d.ts.map +1 -1
  180. package/dist/esm/utils/SavingsLedger.js +51 -0
  181. package/dist/esm/utils/SavingsLedger.js.map +1 -1
  182. package/dist/esm/utils/StoreDraft.d.ts +12 -0
  183. package/dist/esm/utils/StoreDraft.d.ts.map +1 -1
  184. package/dist/esm/utils/StoreDraft.js +52 -1
  185. package/dist/esm/utils/StoreDraft.js.map +1 -1
  186. package/dist/esm/utils/SymbolSurgicalContext.d.ts +2 -0
  187. package/dist/esm/utils/SymbolSurgicalContext.d.ts.map +1 -1
  188. package/dist/esm/utils/SymbolSurgicalContext.js +1 -1
  189. package/dist/esm/utils/SymbolSurgicalContext.js.map +1 -1
  190. package/dist/esm/utils/reportSavings.d.ts +17 -4
  191. package/dist/esm/utils/reportSavings.d.ts.map +1 -1
  192. package/dist/esm/utils/reportSavings.js +65 -22
  193. package/dist/esm/utils/reportSavings.js.map +1 -1
  194. package/package.json +2 -1
  195. package/dashboard/dist/assets/index-BoeQau6n.css +0 -1
  196. package/dashboard/dist/assets/index-Clf3qR64.js +0 -451
  197. package/dist/cjs/infra/analyzers/DriftDetector.d.ts +0 -4
  198. package/dist/cjs/infra/analyzers/DriftDetector.d.ts.map +0 -1
  199. package/dist/cjs/infra/analyzers/DriftDetector.js +0 -88
  200. package/dist/cjs/infra/analyzers/DriftDetector.js.map +0 -1
  201. package/dist/cjs/infra/analyzers/InfraAnalyzer.d.ts +0 -3
  202. package/dist/cjs/infra/analyzers/InfraAnalyzer.d.ts.map +0 -1
  203. package/dist/cjs/infra/analyzers/InfraAnalyzer.js +0 -73
  204. package/dist/cjs/infra/analyzers/InfraAnalyzer.js.map +0 -1
  205. package/dist/cjs/infra/config.d.ts +0 -17
  206. package/dist/cjs/infra/config.d.ts.map +0 -1
  207. package/dist/cjs/infra/config.js +0 -111
  208. package/dist/cjs/infra/config.js.map +0 -1
  209. package/dist/cjs/infra/errorCause.d.ts +0 -36
  210. package/dist/cjs/infra/errorCause.d.ts.map +0 -1
  211. package/dist/cjs/infra/errorCause.js +0 -143
  212. package/dist/cjs/infra/errorCause.js.map +0 -1
  213. package/dist/cjs/infra/providers/InfraProvider.d.ts +0 -9
  214. package/dist/cjs/infra/providers/InfraProvider.d.ts.map +0 -1
  215. package/dist/cjs/infra/providers/InfraProvider.js +0 -3
  216. package/dist/cjs/infra/providers/InfraProvider.js.map +0 -1
  217. package/dist/cjs/infra/providers/JenkinsProvider.d.ts +0 -16
  218. package/dist/cjs/infra/providers/JenkinsProvider.d.ts.map +0 -1
  219. package/dist/cjs/infra/providers/JenkinsProvider.js +0 -193
  220. package/dist/cjs/infra/providers/JenkinsProvider.js.map +0 -1
  221. package/dist/cjs/infra/providers/OKDProvider.d.ts +0 -24
  222. package/dist/cjs/infra/providers/OKDProvider.d.ts.map +0 -1
  223. package/dist/cjs/infra/providers/OKDProvider.js +0 -296
  224. package/dist/cjs/infra/providers/OKDProvider.js.map +0 -1
  225. package/dist/cjs/infra/providers/TerraformProvider.d.ts +0 -17
  226. package/dist/cjs/infra/providers/TerraformProvider.d.ts.map +0 -1
  227. package/dist/cjs/infra/providers/TerraformProvider.js +0 -111
  228. package/dist/cjs/infra/providers/TerraformProvider.js.map +0 -1
  229. package/dist/cjs/infra/providers/index.d.ts +0 -9
  230. package/dist/cjs/infra/providers/index.d.ts.map +0 -1
  231. package/dist/cjs/infra/providers/index.js +0 -34
  232. package/dist/cjs/infra/providers/index.js.map +0 -1
  233. package/dist/cjs/infra/templates/jenkins/index.d.ts +0 -15
  234. package/dist/cjs/infra/templates/jenkins/index.d.ts.map +0 -1
  235. package/dist/cjs/infra/templates/jenkins/index.js +0 -128
  236. package/dist/cjs/infra/templates/jenkins/index.js.map +0 -1
  237. package/dist/cjs/infra/templates/okd/index.d.ts +0 -31
  238. package/dist/cjs/infra/templates/okd/index.d.ts.map +0 -1
  239. package/dist/cjs/infra/templates/okd/index.js +0 -149
  240. package/dist/cjs/infra/templates/okd/index.js.map +0 -1
  241. package/dist/esm/infra/analyzers/DriftDetector.d.ts +0 -4
  242. package/dist/esm/infra/analyzers/DriftDetector.d.ts.map +0 -1
  243. package/dist/esm/infra/analyzers/DriftDetector.js +0 -84
  244. package/dist/esm/infra/analyzers/DriftDetector.js.map +0 -1
  245. package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts +0 -3
  246. package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts.map +0 -1
  247. package/dist/esm/infra/analyzers/InfraAnalyzer.js +0 -70
  248. package/dist/esm/infra/analyzers/InfraAnalyzer.js.map +0 -1
  249. package/dist/esm/infra/config.d.ts +0 -17
  250. package/dist/esm/infra/config.d.ts.map +0 -1
  251. package/dist/esm/infra/config.js +0 -101
  252. package/dist/esm/infra/config.js.map +0 -1
  253. package/dist/esm/infra/errorCause.d.ts +0 -36
  254. package/dist/esm/infra/errorCause.d.ts.map +0 -1
  255. package/dist/esm/infra/errorCause.js +0 -138
  256. package/dist/esm/infra/errorCause.js.map +0 -1
  257. package/dist/esm/infra/providers/InfraProvider.d.ts +0 -9
  258. package/dist/esm/infra/providers/InfraProvider.d.ts.map +0 -1
  259. package/dist/esm/infra/providers/InfraProvider.js +0 -2
  260. package/dist/esm/infra/providers/InfraProvider.js.map +0 -1
  261. package/dist/esm/infra/providers/JenkinsProvider.d.ts +0 -16
  262. package/dist/esm/infra/providers/JenkinsProvider.d.ts.map +0 -1
  263. package/dist/esm/infra/providers/JenkinsProvider.js +0 -186
  264. package/dist/esm/infra/providers/JenkinsProvider.js.map +0 -1
  265. package/dist/esm/infra/providers/OKDProvider.d.ts +0 -24
  266. package/dist/esm/infra/providers/OKDProvider.d.ts.map +0 -1
  267. package/dist/esm/infra/providers/OKDProvider.js +0 -292
  268. package/dist/esm/infra/providers/OKDProvider.js.map +0 -1
  269. package/dist/esm/infra/providers/TerraformProvider.d.ts +0 -17
  270. package/dist/esm/infra/providers/TerraformProvider.d.ts.map +0 -1
  271. package/dist/esm/infra/providers/TerraformProvider.js +0 -107
  272. package/dist/esm/infra/providers/TerraformProvider.js.map +0 -1
  273. package/dist/esm/infra/providers/index.d.ts +0 -9
  274. package/dist/esm/infra/providers/index.d.ts.map +0 -1
  275. package/dist/esm/infra/providers/index.js +0 -27
  276. package/dist/esm/infra/providers/index.js.map +0 -1
  277. package/dist/esm/infra/templates/jenkins/index.d.ts +0 -15
  278. package/dist/esm/infra/templates/jenkins/index.d.ts.map +0 -1
  279. package/dist/esm/infra/templates/jenkins/index.js +0 -124
  280. package/dist/esm/infra/templates/jenkins/index.js.map +0 -1
  281. package/dist/esm/infra/templates/okd/index.d.ts +0 -31
  282. package/dist/esm/infra/templates/okd/index.d.ts.map +0 -1
  283. package/dist/esm/infra/templates/okd/index.js +0 -142
  284. package/dist/esm/infra/templates/okd/index.js.map +0 -1
@@ -6,14 +6,14 @@
6
6
  */
7
7
  import fs from "fs";
8
8
  import path from "path";
9
- import { getBrain, deriveProjectId, currentGitContext } from "../../subconscious/TheBrainV2.js";
10
- import { reportSavings } from "../../utils/reportSavings.js";
9
+ import { getBrain, deriveProjectId, currentGitContext, tokenize } from "../../subconscious/TheBrainV2.js";
10
+ import { reportSavings, reportRecall } from "../../utils/reportSavings.js";
11
11
  import { netTokensSaved } from "./squeeze-cache.js";
12
12
  import { recordReceiptEvent } from "../../utils/TokenReceipt.js";
13
- import { logError, safeResolvePath, DEFAULT_MEMORY_SIMILARITY_FLOOR, tryElicitConfirmation } from "../utils.js";
13
+ import { logError, safeResolvePath, tryElicitConfirmation } from "../utils.js";
14
14
  import { deriveDomainForFile } from "../cognitiveMap.js";
15
15
  import { getRecentEvidence } from "../../utils/SessionEvidence.js";
16
- import { bucketNearMiss } from "../../subconscious/NearMiss.js";
16
+ import { narrowEvidence } from "../../subconscious/NarrowEvidence.js";
17
17
  import { ageLabel } from "../../utils/ageLabel.js";
18
18
  import { sanitizeRefs, describeRef, checkExternalRefs } from "../../subconscious/ExternalRefs.js";
19
19
  import { pushTeamBrain, pullTeamBrain, teamBrainStatus } from "../../subconscious/TeamBrain.js";
@@ -41,7 +41,7 @@ export const MEMORY_TOOL_DEFINITIONS = [
41
41
  {
42
42
  name: "search_memory",
43
43
  annotations: { readOnlyHint: true, openWorldHint: false },
44
- description: "Search Lemma's semantic memory (The Brain) before investigating something from scratch — retrieves past solutions, fixes, and context from ALL your projects globally. Results split into 'fresh' (safe to reuse) and 'stale' (a tracked file changed since — re-verify before reusing). Never treat a stale result as current. If a returned memory turns out wrong once acted on, call downvote_memory with its id.",
44
+ description: "Search the Brain before investigating something from scratch: past fixes, traps, failed approaches and decisions from earlier sessions. Returns a ranked shortlist (headline, excerpt, fresh/STALE) — pick the one that answers your question and get_memory it for the body. Never treat a STALE result as current.",
45
45
  inputSchema: {
46
46
  type: "object",
47
47
  properties: {
@@ -49,8 +49,8 @@ export const MEMORY_TOOL_DEFINITIONS = [
49
49
  limit: { type: "number", description: "Maximum results to return", default: 5 },
50
50
  minSimilarity: {
51
51
  type: "number",
52
- description: "Similarity floor (0.0-1.0) a memory must clear to be returned. Lowering this surfaces loosely related memories that are usually noise — leave it alone unless a known-relevant memory is being filtered out.",
53
- default: 0.75,
52
+ description: "Optional floor (0-1) on the ranking score. Off by default: the score ranks well but does not separate relevant from unrelated.",
53
+ default: 0,
54
54
  },
55
55
  domain: {
56
56
  type: "string",
@@ -58,7 +58,12 @@ export const MEMORY_TOOL_DEFINITIONS = [
58
58
  },
59
59
  semanticDiff: {
60
60
  type: "boolean",
61
- description: "Don't count a comment/whitespace-only change as stale.",
61
+ description: "Don't count a comment/whitespace-only change as stale (default). Pass false to treat any edit to the tracked code as a change.",
62
+ default: true,
63
+ },
64
+ allProjects: {
65
+ type: "boolean",
66
+ description: "Also search memories from your other projects (labelled as such). Off by default: they may be confidential and rarely apply here.",
62
67
  default: false,
63
68
  },
64
69
  },
@@ -85,7 +90,7 @@ export const MEMORY_TOOL_DEFINITIONS = [
85
90
  {
86
91
  name: "store_memory",
87
92
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
88
- description: "Save a verified solution, fix, decision or fact to the Brain so it needn't be re-investigated. Pass filePaths (or `symbols` for one function/class) so it goes stale when that code changes; if both are omitted, Lemma guesses from the files this session touched and flags it as a guess. outcome='failed' records a dead end. To correct or extend an existing memory use update_memory — storing a revision here creates a second entry and searches return a mix of both.",
93
+ description: "Save a verified fix, decision or fact so it needn't be re-investigated: what code and git can't tell the next session (root cause, trap, failed approach, how-to), not a log of what shipped. Pass filePaths (or `symbols`) so it goes stale when that code changes; omitted, Lemma guesses from files this session touched. outcome='failed' records a dead end. To correct a memory use update_memory — a re-store here leaves both versions.",
89
94
  inputSchema: {
90
95
  type: "object",
91
96
  properties: {
@@ -206,8 +211,8 @@ export const MEMORY_TOOL_DEFINITIONS = [
206
211
  ids: { type: "array", items: { type: "string" }, description: "Entry and/or claim ids to revalidate, from a prior search_memory/store_memory result." },
207
212
  semanticDiff: {
208
213
  type: "boolean",
209
- description: "Don't count a comment/whitespace-only change as stale.",
210
- default: false,
214
+ description: "Don't count a comment/whitespace-only change as stale (default). Pass false to treat any edit to the tracked code as a change.",
215
+ default: true,
211
216
  },
212
217
  },
213
218
  required: ["ids"],
@@ -363,142 +368,113 @@ export const MEMORY_TOOL_DEFINITIONS = [
363
368
  },
364
369
  },
365
370
  ];
371
+ /**
372
+ * Ids the last search_memory calls put on a shortlist. A get_memory of one of them is the
373
+ * moment a memory was actually reused, so that is where its hit and its saving are booked —
374
+ * listing a headline saves nothing by itself.
375
+ */
376
+ const _shortlisted = new Set();
377
+ const SHORTLIST_MEMORY = 200;
378
+ const EXCERPT_CHARS = 180;
379
+ function excerpt(text) {
380
+ const flat = String(typeof text === "string" ? text : JSON.stringify(text)).replace(/\s+/g, " ").trim();
381
+ return flat.length > EXCERPT_CHARS ? `${flat.slice(0, EXCERPT_CHARS - 1)}…` : flat;
382
+ }
383
+ /**
384
+ * search_memory answers with a ranked shortlist, not a verdict.
385
+ *
386
+ * It used to return a memory only above a 0.75 similarity floor and otherwise said
387
+ * "Investigate from scratch — there is nothing safe to reuse". Measured on Lemma's own Brain
388
+ * (18 questions a later session would really ask), the right memory ranked first 15 times and
389
+ * in the top three every time — and cleared the floor zero times. The score can't carry a
390
+ * floor: BM25 is normalized against the best candidate *of the same search*, so the top result
391
+ * of an unrelated question scores 0.54–0.66, the same band as a correct one (0.56–0.73). The
392
+ * ranking is good; deciding relevance from headlines is something the agent does well. So the
393
+ * Brain shortlists and the agent picks, then reads the one that answers with get_memory.
394
+ */
366
395
  async function handleSearchMemory(args) {
367
- const query = args?.query;
368
- const limit = args?.limit || 5;
369
- // A floor of 0 returns the nearest neighbour no matter how unrelated it is, and the
370
- // formatting below then presents it as a reusable memory. Match smarter_cache's
371
- // threshold so both paths agree on what counts as a hit.
372
- const minSimilarity = typeof args?.minSimilarity === "number" ? args.minSimilarity : DEFAULT_MEMORY_SIMILARITY_FLOOR;
396
+ const query = typeof args?.query === "string" ? args.query : "";
397
+ const limit = Math.min(Math.max(Math.floor(args?.limit || 5), 1), 10);
398
+ // Explicit floors are still honoured; by default nothing is cut, for the reason above.
399
+ const minSimilarity = typeof args?.minSimilarity === "number" ? args.minSimilarity : 0;
373
400
  const domain = typeof args?.domain === "string" && args.domain.trim() ? args.domain.trim() : undefined;
374
- const semanticDiff = args?.semanticDiff === true;
401
+ const semanticDiff = args?.semanticDiff !== false;
375
402
  if (!query)
376
403
  throw new Error("Query is required");
377
404
  try {
378
405
  const brain = getBrain();
379
- // searchHybrid is search() plus one boolean check unless LEMMA_BRAIN_EMBEDDINGS is set,
380
- // so this costs nothing by default and picks up the semantic re-rank when it is enabled.
381
- const results = await brain.searchHybrid(query, limit, minSimilarity, { projectId: deriveProjectId(), domain, semanticDiff });
382
- if (results.length === 0) {
383
- recordReceiptEvent("reasoning", query.substring(0, 100), {
384
- tool: "search_memory",
385
- reason: `no memory above the ${minSimilarity} similarity floor`,
386
- });
387
- // searchHybrid already filtered anything below minSimilarity out of `results`, so the
388
- // near-miss check needs its own uncapped lookup — countStats:false, this must not
389
- // register as a second miss on top of the one searchHybrid just counted.
390
- const uncapped = brain.search(query, ORIENTATION_LIMIT, 0, { projectId: deriveProjectId(), domain, countStats: false });
391
- const nearMiss = bucketNearMiss(uncapped[0] ? { id: uncapped[0].id, query: uncapped[0].query, similarity: uncapped[0].similarity } : undefined, minSimilarity);
392
- // A miss that says nothing cannot tell "nothing related" from "something related at 60%".
393
- // These are for orientation only: below the floor, never reusable, never credited.
394
- const related = uncapped
395
- .filter((r) => r.similarity >= ORIENTATION_MIN)
396
- .map((r) => ` - ${r.id} (${(r.similarity * 100).toFixed(0)}%, stored ${ageLabel(r.timestamp)}): ${r.query.substring(0, 100)}`);
397
- const orientation = related.length > 0
398
- ? `\n\nBelow the reuse floor, for orientation only (not cache hits — get_memory to read, then verify against current state before relying on any):\n${related.join("\n")}`
399
- : "";
406
+ // countStats:false — appearing on a shortlist is not a reuse; get_memory books that.
407
+ const projectId = deriveProjectId();
408
+ adoptOnce(brain, projectId);
409
+ const results = await brain.searchHybrid(query, limit, minSimilarity, {
410
+ projectId,
411
+ allProjects: args?.allProjects === true,
412
+ domain,
413
+ semanticDiff,
414
+ countStats: false,
415
+ });
416
+ if (results.length === 0 && tokenize(query).length === 0) {
400
417
  return {
401
- content: [{
402
- type: "text",
403
- text: `No memory in Lemma's Brain scored at or above the ${(minSimilarity * 100).toFixed(0)}% similarity floor for this query. Investigate from scratch — there is nothing safe to reuse.${nearMiss.hint ? ` ${nearMiss.hint}` : ""}${orientation}`,
404
- }],
418
+ content: [{ type: "text", text: "This query has no searchable words (only stop words or symbols). Search with the error text, a symbol or file name, or the words of the question." }],
405
419
  };
406
420
  }
407
- // An entry that tracks nothing reports `fresh: true` vacuously (checkEntryFreshness has
408
- // nothing to compare) — it must NOT land in the verified-fresh bucket, be credited as a
409
- // cache hit, or be told "from cache". It gets its own UNTRACKED bucket instead.
410
- const fresh = results.filter((r) => r.fresh && !r.untracked);
411
- const stale = results.filter((r) => !r.fresh);
412
- const untracked = results.filter((r) => r.fresh && r.untracked);
413
- const formatClaims = (r) => {
414
- if (!Array.isArray(r.claims) || r.claims.length === 0)
415
- return "";
416
- const lines = r.claims.map((c) => c.fresh
417
- ? ` ✓ fresh: ${c.text}`
418
- : ` ✗ STALE (${(c.staleFiles || []).join(", ")}): ${c.text}`);
419
- const staleCount = r.claims.filter((c) => !c.fresh).length;
420
- return `\nClaims (${r.claims.length - staleCount}/${r.claims.length} still fresh — trust only the ✓ ones):\n${lines.join("\n")}`;
421
- };
422
- const formatResult = (r, i) => `Result ${i + 1} (id: ${r.id}, Similarity: ${(r.similarity * 100).toFixed(1)}%, stored ${ageLabel(r.timestamp)})${r.outcome === "failed" ? "\n⚠️ TAGGED AS A FAILED ATTEMPT — this was tried before and did NOT work. Do not repeat it; treat this as a warning, not a suggestion." : ""}${typeof r.tokensSaved === "number" && r.tokensSaved > 0
423
- ? `\n💰 This memory has saved ${r.tokensSaved} tokens across ${r.hits || "?"} reuse(s) — prefer it over re-deriving.`
424
- : ""}\nPrompt: ${r.query.substring(0, 300)}...\nResponse: ${typeof r.response === "string" ? r.response : JSON.stringify(r.response, null, 2)}${formatClaims(r)}${Array.isArray(r.evidence) && r.evidence.length > 0
425
- ? `\nEvidence: ${r.evidence.map((e) => {
426
- const sep = e.lastIndexOf("::");
427
- return sep > 0 ? `${relLabel(e.substring(0, sep))}::${e.substring(sep + 2)}` : relLabel(e);
428
- }).join(", ")}`
429
- : ""}${Array.isArray(r.whyShown) && r.whyShown.length > 0
430
- ? `\nWhy shown: ${r.whyShown.join(" · ")}`
431
- : ""}${Array.isArray(r.cosmeticChanges) && r.cosmeticChanges.length > 0
432
- ? `\n(comment/whitespace-only change, ignored under semanticDiff: ${r.cosmeticChanges.join(", ")})`
433
- : ""}`;
434
- if (fresh.length > 0) {
435
- // Only a fresh hit (or an untracked, purely conceptual entry) counts as a real
436
- // avoided re-investigation — this is the only case worth crediting as savings.
437
- const bestFresh = fresh[0];
438
- const { net: tokensSaved } = netTokensSaved(Math.max(400, String(bestFresh.response).length), query);
439
- reportSavings({ source: "cache", tokens: tokensSaved, toolName: "search_memory", query: query.substring(0, 100) });
440
- // Attribute the saving to the memory itself: the per-entry ROI ledger lives on the
441
- // entry (persisted, merged, imported), booked on the same event as the ledger above
442
- // so the two can never disagree about whether a reuse happened.
443
- brain.creditSavings(bestFresh.id, tokensSaved);
444
- recordReceiptEvent("semantic_cache_hit", query.substring(0, 100), {
445
- tool: "search_memory",
446
- similarity: bestFresh.similarity,
447
- tokensSaved,
448
- memoryId: bestFresh.id,
449
- });
450
- }
451
- else if (untracked.length > 0) {
452
- recordReceiptEvent("reasoning", query.substring(0, 100), {
453
- tool: "search_memory",
454
- reason: `${untracked.length} similar but UNTRACKED — no evidence to verify, not credited as a cache hit`,
455
- });
456
- }
457
- else {
458
- recordReceiptEvent("reasoning", query.substring(0, 100), {
459
- tool: "search_memory",
460
- reason: `${stale.length} similar memory/memories found but all stale — must re-verify`,
461
- });
462
- }
463
- const parts = [];
464
- if (fresh.length > 0) {
465
- parts.push(`Lemma found ${fresh.length} fresh ${fresh.length === 1 ? "memory" : "memories"} (from cache — say so if you use this):\n\n${fresh.map(formatResult).join("\n\n---\n\n")}`);
466
- }
467
- if (untracked.length > 0) {
468
- const untrackedText = untracked
469
- .map((r, i) => formatResult(r, i))
470
- .join("\n\n---\n\n");
471
- parts.push(`⚠️ ${untracked.length} ${untracked.length === 1 ? "memory is" : "memories are"} similar but UNTRACKED — ${untracked.length === 1 ? "it tracks" : "they track"} no files or symbols, so nothing was verified against current code (${untracked.length === 1 ? "it is" : "they are"} vacuously "fresh": there was nothing to check). ${untracked.length === 1 ? "It may" : "They may"} describe state that no longer exists — treat as a hint, re-verify against the repo before acting on it, and use update_memory/refresh_memory with filePaths/symbols so it becomes verifiable next time:\n\n${untrackedText}`);
421
+ if (results.length === 0) {
422
+ const why = minSimilarity > 0
423
+ ? `scored at or above the ${minSimilarity} floor you set`
424
+ : "shares a term with this query — nothing was learned about it in an earlier session";
425
+ recordReceiptEvent("reasoning", query.substring(0, 100), { tool: "search_memory", reason: `no memory ${why}` });
426
+ return { content: [{ type: "text", text: `No memory in Lemma's Brain ${why}. Investigate from scratch.` }] };
472
427
  }
473
- if (stale.length > 0) {
474
- const staleText = stale
475
- .map((r, i) => {
476
- // "You are on a different branch" and "someone rewrote this function" are the same
477
- // hash mismatch and completely different situations for the reader: the first is
478
- // usually not a reason to distrust the memory at all.
479
- const cause = r.staleCause === "branch-changed"
480
- ? `\nNOTE: stored on branch \`${r.storedOnBranch}\`, you are on \`${currentGitContext().branch || "an unknown branch"}\`. The difference may be the branch switch rather than an edit — check before discarding this.`
428
+ for (const r of results)
429
+ _shortlisted.add(r.id);
430
+ while (_shortlisted.size > SHORTLIST_MEMORY)
431
+ _shortlisted.delete(_shortlisted.values().next().value);
432
+ void reportRecall({ projectPath: process.cwd(), trigger: "search", memoryIds: results.map((r) => r.id) });
433
+ recordReceiptEvent("reasoning", query.substring(0, 100), { tool: "search_memory", reason: `shortlisted ${results.length} memories` });
434
+ const line = (r, i) => {
435
+ const verdict = !r.fresh
436
+ ? r.staleCause === "branch-changed"
437
+ ? `STALE — stored on branch ${r.storedOnBranch}, you are on ${currentGitContext().branch || "another branch"}`
438
+ : `STALE — changed since: ${(r.staleFiles || []).map(relLabel).join(", ")}`
439
+ : r.untracked
440
+ ? "untracked — tracks no files, nothing to check it against"
441
+ : "fresh";
442
+ const failed = r.outcome === "failed" ? " ⚠️ FAILED APPROACH — tried before and did not work" : "";
443
+ const origin = r.scope === "other-project"
444
+ ? ` ⚠️ FROM ANOTHER PROJECT (${r.ownerProject}) — do not assume it applies here`
445
+ : r.scope === "unscoped"
446
+ ? " [stored before memories were scoped to a project — may not be from this one]"
481
447
  : "";
482
- return `${formatResult(r, i)}\nSTALE — changed since stored: ${r.staleFiles.join(", ")}${cause}`;
483
- })
484
- .join("\n\n---\n\n");
485
- parts.push(`${stale.length} more ${stale.length === 1 ? "memory is" : "memories are"} similar but STALE (underlying file(s) changed) — do not reuse verbatim, re-verify against current file state:\n\n${staleText}`);
486
- }
487
- return { content: [{ type: "text", text: parts.join("\n\n===\n\n") }] };
448
+ return `${i + 1}. ${r.id} (${ageLabel(r.timestamp)}, ${verdict})${failed}${origin}\n ${r.query.replace(/\s+/g, " ").slice(0, 160)}\n ${excerpt(r.response)}`;
449
+ };
450
+ const text = `Closest memories in Lemma's Brain, best match first. Ranking is lexical: the right memory is usually here, but so are unrelated ones that share words — judge each by its headline.\n\n` +
451
+ `${results.map(line).join("\n\n")}\n\n` +
452
+ `If one answers your question, get_memory <id> for the full body before relying on it (a STALE one must be re-checked against the current code; a FAILED one is a warning, not a suggestion). If none does, investigate from scratch. A memory that turns out wrong: downvote_memory or forget_memory it.`;
453
+ return { content: [{ type: "text", text }] };
488
454
  }
489
455
  catch (e) {
490
456
  logError("search_memory", e);
491
457
  return { content: [{ type: "text", text: `Local Search failed: ${e.message}` }] };
492
458
  }
493
459
  }
460
+ /** Memories from before projects existed are adopted once per process, from the repo root. */
461
+ let _adopted = false;
462
+ function adoptOnce(brain, projectId) {
463
+ if (_adopted)
464
+ return;
465
+ _adopted = true;
466
+ try {
467
+ brain.adoptUnscopedByEvidence(projectId, process.cwd());
468
+ }
469
+ catch (e) {
470
+ logError("adoptUnscopedByEvidence", e);
471
+ }
472
+ }
494
473
  /** Relative-to-cwd label for a tracked absolute path, matching how the Brain reports them. */
495
474
  function relLabel(abs) {
496
475
  const rel = path.relative(process.cwd(), abs);
497
476
  return rel.startsWith("..") ? abs : rel;
498
477
  }
499
- /** How many below-floor candidates a miss lists, and the weakest one still worth naming. */
500
- const ORIENTATION_LIMIT = 3;
501
- const ORIENTATION_MIN = 0.3;
502
478
  /** External refs (commit / MR / issue) an entry carries, as one readable line; "" if none. */
503
479
  function refsLine(entry) {
504
480
  const refs = Array.isArray(entry.refs) ? entry.refs : [];
@@ -548,6 +524,18 @@ async function handleGetMemory(args) {
548
524
  return { content: [{ type: "text", text: `No memory with id "${id}" in the Brain. It may have been deleted with forget_memory, or evicted at capacity — search_memory can find it by content if it is still there under another id.` }] };
549
525
  }
550
526
  const [status] = brain.verifyByIds([id]);
527
+ // Opened from a search_memory shortlist: this is the reuse. Booked once per shortlisting,
528
+ // and only for a memory that was checked against code and still holds — the same rule the
529
+ // old above-the-floor hit followed.
530
+ if (_shortlisted.delete(id) && includeResponse) {
531
+ brain.recordReuse(id);
532
+ if (status?.status === "fresh") {
533
+ const { net: tokensSaved } = netTokensSaved(Math.max(400, entry.response.length), entry.query);
534
+ reportSavings({ source: "cache", tokens: tokensSaved, toolName: "search_memory", query: entry.query.substring(0, 100) });
535
+ brain.creditSavings(id, tokensSaved);
536
+ recordReceiptEvent("semantic_cache_hit", entry.query.substring(0, 100), { tool: "get_memory", tokensSaved, memoryId: id });
537
+ }
538
+ }
551
539
  const facts = [
552
540
  `stored ${entry.timestamp}`,
553
541
  ...(entry.refreshedAt ? [`re-anchored ${entry.refreshedAt}`] : []),
@@ -620,7 +608,19 @@ async function handleUpdateMemory(args) {
620
608
  const ok = getBrain().setRefs(id, refs);
621
609
  return { content: [{ type: "text", text: ok ? `External refs on "${id}" ${refs.length > 0 ? `set to: ${refs.map(describeRef).join(", ")}` : "cleared"}. Nothing else was changed.` : `No entry with id "${id}" in the Brain.` }] };
622
610
  }
623
- const result = getBrain().update(id, { query, response, filePaths, symbols, claims, outcome, domain, derivedFrom, supersededBy, refs });
611
+ // New files without symbols: track the symbols the memory names in them instead (see
612
+ // NarrowEvidence) — the text it is judged by is the new one when given, else the stored one.
613
+ let trackFiles = filePaths;
614
+ let trackSymbols = symbols;
615
+ if (filePaths && filePaths.length > 0 && !symbols) {
616
+ const current = getBrain().getEntry(id);
617
+ const narrowed = narrowEvidence(filePaths, `${query ?? current?.query ?? ""}\n${response ?? current?.response ?? ""}`);
618
+ if (narrowed.symbols.length > 0) {
619
+ trackFiles = narrowed.filePaths;
620
+ trackSymbols = narrowed.symbols;
621
+ }
622
+ }
623
+ const result = getBrain().update(id, { query, response, filePaths: trackFiles, symbols: trackSymbols, claims, outcome, domain, derivedFrom, supersededBy, refs });
624
624
  if (!result.ok)
625
625
  return { content: [{ type: "text", text: result.message }] };
626
626
  recordReceiptEvent("tool_call", `update_memory: ${id}`, {
@@ -646,6 +646,20 @@ async function handleUpdateMemory(args) {
646
646
  return { content: [{ type: "text", text: `Failed to update memory: ${e.message}` }], isError: true };
647
647
  }
648
648
  }
649
+ /**
650
+ * A memory that reads as a log of what was done — "release v1.31.0: what shipped", "commit abc123:
651
+ * …", "hito v1.26.0". On Lemma's own repo these were most of the memories written on purpose and
652
+ * none was ever recalled: the next session asks why something breaks or how to do it, never what
653
+ * shipped on a date, and git log / the CHANGELOG answer that anyway. A how/why question is
654
+ * knowledge even when it mentions a release ("how to publish a release"), so it is let through.
655
+ */
656
+ export function looksLikeLogbook(query) {
657
+ const q = query.toLowerCase();
658
+ if (/^(how|why|cómo|como|por qué|porque)\s/.test(q))
659
+ return false;
660
+ return (/^commit [0-9a-f]{7,}/.test(q) ||
661
+ /(?<![a-z])(what shipped|shipped|released?|milestone|hito|changelog|qué trae|qué se publicó|publicad[oa])(?![a-z])/.test(q));
662
+ }
649
663
  async function handleStoreMemory(args) {
650
664
  const query = args?.query;
651
665
  const responseText = args?.response;
@@ -668,6 +682,17 @@ async function handleStoreMemory(args) {
668
682
  autoEvidence = true;
669
683
  }
670
684
  }
685
+ // A whole file goes stale on any edit anywhere in it; the symbols the memory names in it go
686
+ // stale only when what it talks about changes (see NarrowEvidence).
687
+ let narrowedNote = "";
688
+ if (filePaths && filePaths.length > 0 && (!symbols || symbols.length === 0) && query && responseText) {
689
+ const narrowed = narrowEvidence(filePaths, `${query}\n${responseText}`);
690
+ if (narrowed.symbols.length > 0) {
691
+ filePaths = narrowed.filePaths.length > 0 ? narrowed.filePaths : undefined;
692
+ symbols = narrowed.symbols;
693
+ narrowedNote = ` Tracking the symbols it names instead of their whole file (${narrowed.narrowed.join("; ")}) — an edit elsewhere in those files won't stale it; pass symbols explicitly to choose others.`;
694
+ }
695
+ }
671
696
  const claims = Array.isArray(args?.claims)
672
697
  ? args.claims.filter((c) => c?.text)
673
698
  : undefined;
@@ -720,10 +745,13 @@ async function handleStoreMemory(args) {
720
745
  // later store, verify_memory, refresh_memory, forget_memory. Without it the caller had
721
746
  // to search for the memory it had just written to do anything with it.
722
747
  const idNote = storeRes.id ? ` (id: ${storeRes.id})` : "";
748
+ const logbookNote = looksLikeLogbook(query)
749
+ ? "\n\n📓 This reads like a log of what was done or shipped. git log and the CHANGELOG already hold that, and log-style memories are the ones that never get recalled. If it contains what they don't — the root cause, the trap, the approach that failed, the non-obvious step — update_memory it so the key and body lead with that; otherwise forget_memory it."
750
+ : "";
723
751
  const scrubNote = storeRes.redactions > 0
724
752
  ? ` 🛡 ${storeRes.redactions} secret(s) redacted before storage — credentials are never persisted, only their placeholders.`
725
753
  : "";
726
- return { content: [{ type: "text", text: `Success: Memory stored${idNote}. ${storeRes.reason}${trackingNote}${symbolNote}${autoEvidenceNote}${outcomeNote}${claimsNote}${domainNote}${refsNote}${derivedFromNote}${conflictsNote}${textConflictsNote}${scrubNote}` }] };
754
+ return { content: [{ type: "text", text: `Success: Memory stored${idNote}. ${storeRes.reason}${trackingNote}${symbolNote}${autoEvidenceNote}${outcomeNote}${claimsNote}${domainNote}${refsNote}${derivedFromNote}${conflictsNote}${narrowedNote}${textConflictsNote}${scrubNote}${logbookNote}` }] };
727
755
  }
728
756
  catch (e) {
729
757
  logError("store_memory", e);
@@ -1143,7 +1171,7 @@ async function handleBrainTeam(args) {
1143
1171
  }
1144
1172
  async function handleVerifyMemory(args) {
1145
1173
  const ids = Array.isArray(args?.ids) ? args.ids.filter((id) => typeof id === "string" && id) : [];
1146
- const semanticDiff = args?.semanticDiff === true;
1174
+ const semanticDiff = args?.semanticDiff !== false;
1147
1175
  if (ids.length === 0)
1148
1176
  throw new Error("ids is required and must be a non-empty array");
1149
1177
  try {