@fgv/ts-agent-memory 5.1.0-47 → 5.1.0-48

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 (341) hide show
  1. package/dist/packlets/ingest/orchestrator.js +11 -1
  2. package/dist/packlets/ingest/orchestrator.js.map +1 -1
  3. package/dist/packlets/observe/memoryObservationStore.js +6 -0
  4. package/dist/packlets/observe/memoryObservationStore.js.map +1 -1
  5. package/dist/packlets/observe/observer.js.map +1 -1
  6. package/dist/packlets/store/fileTreeMemoryStore.js +52 -131
  7. package/dist/packlets/store/fileTreeMemoryStore.js.map +1 -1
  8. package/dist/packlets/store/vectorMaintenance.js +251 -0
  9. package/dist/packlets/store/vectorMaintenance.js.map +1 -0
  10. package/dist/packlets/vector/inMemoryCosineIndex.js +81 -18
  11. package/dist/packlets/vector/inMemoryCosineIndex.js.map +1 -1
  12. package/dist/packlets/vector/inMemoryFragmentCosineIndex.js +7 -0
  13. package/dist/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
  14. package/dist/packlets/vector/vectorIndex.js.map +1 -1
  15. package/dist/ts-agent-memory.d.ts +297 -66
  16. package/lib/packlets/ingest/orchestrator.d.ts.map +1 -1
  17. package/lib/packlets/ingest/orchestrator.js +11 -1
  18. package/lib/packlets/ingest/orchestrator.js.map +1 -1
  19. package/lib/packlets/observe/memoryObservationStore.d.ts.map +1 -1
  20. package/lib/packlets/observe/memoryObservationStore.js +6 -0
  21. package/lib/packlets/observe/memoryObservationStore.js.map +1 -1
  22. package/lib/packlets/observe/observer.d.ts +61 -0
  23. package/lib/packlets/observe/observer.d.ts.map +1 -1
  24. package/lib/packlets/observe/observer.js.map +1 -1
  25. package/lib/packlets/store/fileTreeMemoryStore.d.ts +66 -59
  26. package/lib/packlets/store/fileTreeMemoryStore.d.ts.map +1 -1
  27. package/lib/packlets/store/fileTreeMemoryStore.js +52 -131
  28. package/lib/packlets/store/fileTreeMemoryStore.js.map +1 -1
  29. package/lib/packlets/store/vectorMaintenance.d.ts +149 -0
  30. package/lib/packlets/store/vectorMaintenance.d.ts.map +1 -0
  31. package/lib/packlets/store/vectorMaintenance.js +255 -0
  32. package/lib/packlets/store/vectorMaintenance.js.map +1 -0
  33. package/lib/packlets/vector/inMemoryCosineIndex.d.ts +30 -7
  34. package/lib/packlets/vector/inMemoryCosineIndex.d.ts.map +1 -1
  35. package/lib/packlets/vector/inMemoryCosineIndex.js +80 -17
  36. package/lib/packlets/vector/inMemoryCosineIndex.js.map +1 -1
  37. package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts +7 -0
  38. package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts.map +1 -1
  39. package/lib/packlets/vector/inMemoryFragmentCosineIndex.js +7 -0
  40. package/lib/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
  41. package/lib/packlets/vector/vectorIndex.d.ts +129 -1
  42. package/lib/packlets/vector/vectorIndex.d.ts.map +1 -1
  43. package/lib/packlets/vector/vectorIndex.js.map +1 -1
  44. package/package.json +17 -7
  45. package/.rush/temp/5667e36f1c0cc503a5c20a3ebff76e7b9a702d41.tar.log +0 -468
  46. package/.rush/temp/chunked-rush-logs/ts-agent-memory.build.chunks.jsonl +0 -9
  47. package/.rush/temp/operation/build/all.log +0 -9
  48. package/.rush/temp/operation/build/log-chunks.jsonl +0 -9
  49. package/.rush/temp/operation/build/state.json +0 -3
  50. package/.rush/temp/shrinkwrap-deps.json +0 -689
  51. package/config/api-extractor.json +0 -343
  52. package/config/jest.config.json +0 -14
  53. package/config/rig.json +0 -4
  54. package/dist/test/unit/converters/antagonistRoundTrip.test.js +0 -95
  55. package/dist/test/unit/converters/antagonistRoundTrip.test.js.map +0 -1
  56. package/dist/test/unit/converters/bodyConverterRegistry.test.js +0 -72
  57. package/dist/test/unit/converters/bodyConverterRegistry.test.js.map +0 -1
  58. package/dist/test/unit/converters/envelopeConverter.test.js +0 -313
  59. package/dist/test/unit/converters/envelopeConverter.test.js.map +0 -1
  60. package/dist/test/unit/index/memoryIndex.test.js +0 -214
  61. package/dist/test/unit/index/memoryIndex.test.js.map +0 -1
  62. package/dist/test/unit/ingest/antagonistCycleAndParity.test.js +0 -277
  63. package/dist/test/unit/ingest/antagonistCycleAndParity.test.js.map +0 -1
  64. package/dist/test/unit/ingest/cycleGuard.test.js +0 -81
  65. package/dist/test/unit/ingest/cycleGuard.test.js.map +0 -1
  66. package/dist/test/unit/ingest/dedupScope.test.js +0 -434
  67. package/dist/test/unit/ingest/dedupScope.test.js.map +0 -1
  68. package/dist/test/unit/ingest/orchestrator.test.js +0 -1058
  69. package/dist/test/unit/ingest/orchestrator.test.js.map +0 -1
  70. package/dist/test/unit/observe/memoryObservationStore.test.js +0 -118
  71. package/dist/test/unit/observe/memoryObservationStore.test.js.map +0 -1
  72. package/dist/test/unit/retrieve/fragmentSemanticRetriever.test.js +0 -116
  73. package/dist/test/unit/retrieve/fragmentSemanticRetriever.test.js.map +0 -1
  74. package/dist/test/unit/retrieve/linkTraversalRetriever.test.js +0 -257
  75. package/dist/test/unit/retrieve/linkTraversalRetriever.test.js.map +0 -1
  76. package/dist/test/unit/retrieve/retrievers.test.js +0 -768
  77. package/dist/test/unit/retrieve/retrievers.test.js.map +0 -1
  78. package/dist/test/unit/retrieve/temporalRetrievers.test.js +0 -182
  79. package/dist/test/unit/retrieve/temporalRetrievers.test.js.map +0 -1
  80. package/dist/test/unit/store/antagonistTemporalBoundary.test.js +0 -120
  81. package/dist/test/unit/store/antagonistTemporalBoundary.test.js.map +0 -1
  82. package/dist/test/unit/store/embedOnWrite.test.js +0 -317
  83. package/dist/test/unit/store/embedOnWrite.test.js.map +0 -1
  84. package/dist/test/unit/store/fileTreeMemoryStore.test.js +0 -778
  85. package/dist/test/unit/store/fileTreeMemoryStore.test.js.map +0 -1
  86. package/dist/test/unit/store/fragmentEmbedOnWrite.test.js +0 -255
  87. package/dist/test/unit/store/fragmentEmbedOnWrite.test.js.map +0 -1
  88. package/dist/test/unit/store/indexInjection.test.js +0 -432
  89. package/dist/test/unit/store/indexInjection.test.js.map +0 -1
  90. package/dist/test/unit/store/lenientOpen.test.js +0 -248
  91. package/dist/test/unit/store/lenientOpen.test.js.map +0 -1
  92. package/dist/test/unit/store/listScoped.test.js +0 -109
  93. package/dist/test/unit/store/listScoped.test.js.map +0 -1
  94. package/dist/test/unit/store/observations.test.js +0 -239
  95. package/dist/test/unit/store/observations.test.js.map +0 -1
  96. package/dist/test/unit/store/rankAxis.test.js +0 -254
  97. package/dist/test/unit/store/rankAxis.test.js.map +0 -1
  98. package/dist/test/unit/store/scopeEncoding.test.js +0 -24
  99. package/dist/test/unit/store/scopeEncoding.test.js.map +0 -1
  100. package/dist/test/unit/store/temporalStore.test.js +0 -398
  101. package/dist/test/unit/store/temporalStore.test.js.map +0 -1
  102. package/dist/test/unit/tools/memoryTools.test.js +0 -842
  103. package/dist/test/unit/tools/memoryTools.test.js.map +0 -1
  104. package/dist/test/unit/types/identityCodec.test.js +0 -187
  105. package/dist/test/unit/types/identityCodec.test.js.map +0 -1
  106. package/dist/test/unit/types/ids.test.js +0 -84
  107. package/dist/test/unit/types/ids.test.js.map +0 -1
  108. package/dist/test/unit/types/temporalCodec.test.js +0 -203
  109. package/dist/test/unit/types/temporalCodec.test.js.map +0 -1
  110. package/dist/test/unit/types/temporalPolicy.test.js +0 -83
  111. package/dist/test/unit/types/temporalPolicy.test.js.map +0 -1
  112. package/dist/test/unit/types/writePolicy.test.js +0 -331
  113. package/dist/test/unit/types/writePolicy.test.js.map +0 -1
  114. package/dist/test/unit/vector/fragmentConverters.test.js +0 -58
  115. package/dist/test/unit/vector/fragmentConverters.test.js.map +0 -1
  116. package/dist/test/unit/vector/inMemoryCosineIndex.test.js +0 -252
  117. package/dist/test/unit/vector/inMemoryCosineIndex.test.js.map +0 -1
  118. package/dist/test/unit/vector/inMemoryFragmentCosineIndex.test.js +0 -362
  119. package/dist/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +0 -1
  120. package/dist/test/unit/vector/vectorIndex.test.js +0 -51
  121. package/dist/test/unit/vector/vectorIndex.test.js.map +0 -1
  122. package/eslint.config.js +0 -15
  123. package/etc/ts-agent-memory.api.md +0 -940
  124. package/lib/test/unit/converters/antagonistRoundTrip.test.d.ts +0 -10
  125. package/lib/test/unit/converters/antagonistRoundTrip.test.d.ts.map +0 -1
  126. package/lib/test/unit/converters/antagonistRoundTrip.test.js +0 -97
  127. package/lib/test/unit/converters/antagonistRoundTrip.test.js.map +0 -1
  128. package/lib/test/unit/converters/bodyConverterRegistry.test.d.ts +0 -2
  129. package/lib/test/unit/converters/bodyConverterRegistry.test.d.ts.map +0 -1
  130. package/lib/test/unit/converters/bodyConverterRegistry.test.js +0 -74
  131. package/lib/test/unit/converters/bodyConverterRegistry.test.js.map +0 -1
  132. package/lib/test/unit/converters/envelopeConverter.test.d.ts +0 -2
  133. package/lib/test/unit/converters/envelopeConverter.test.d.ts.map +0 -1
  134. package/lib/test/unit/converters/envelopeConverter.test.js +0 -315
  135. package/lib/test/unit/converters/envelopeConverter.test.js.map +0 -1
  136. package/lib/test/unit/index/memoryIndex.test.d.ts +0 -2
  137. package/lib/test/unit/index/memoryIndex.test.d.ts.map +0 -1
  138. package/lib/test/unit/index/memoryIndex.test.js +0 -216
  139. package/lib/test/unit/index/memoryIndex.test.js.map +0 -1
  140. package/lib/test/unit/ingest/antagonistCycleAndParity.test.d.ts +0 -9
  141. package/lib/test/unit/ingest/antagonistCycleAndParity.test.d.ts.map +0 -1
  142. package/lib/test/unit/ingest/antagonistCycleAndParity.test.js +0 -279
  143. package/lib/test/unit/ingest/antagonistCycleAndParity.test.js.map +0 -1
  144. package/lib/test/unit/ingest/cycleGuard.test.d.ts +0 -2
  145. package/lib/test/unit/ingest/cycleGuard.test.d.ts.map +0 -1
  146. package/lib/test/unit/ingest/cycleGuard.test.js +0 -83
  147. package/lib/test/unit/ingest/cycleGuard.test.js.map +0 -1
  148. package/lib/test/unit/ingest/dedupScope.test.d.ts +0 -2
  149. package/lib/test/unit/ingest/dedupScope.test.d.ts.map +0 -1
  150. package/lib/test/unit/ingest/dedupScope.test.js +0 -436
  151. package/lib/test/unit/ingest/dedupScope.test.js.map +0 -1
  152. package/lib/test/unit/ingest/orchestrator.test.d.ts +0 -2
  153. package/lib/test/unit/ingest/orchestrator.test.d.ts.map +0 -1
  154. package/lib/test/unit/ingest/orchestrator.test.js +0 -1060
  155. package/lib/test/unit/ingest/orchestrator.test.js.map +0 -1
  156. package/lib/test/unit/observe/memoryObservationStore.test.d.ts +0 -2
  157. package/lib/test/unit/observe/memoryObservationStore.test.d.ts.map +0 -1
  158. package/lib/test/unit/observe/memoryObservationStore.test.js +0 -120
  159. package/lib/test/unit/observe/memoryObservationStore.test.js.map +0 -1
  160. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.d.ts +0 -2
  161. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.d.ts.map +0 -1
  162. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.js +0 -118
  163. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.js.map +0 -1
  164. package/lib/test/unit/retrieve/linkTraversalRetriever.test.d.ts +0 -2
  165. package/lib/test/unit/retrieve/linkTraversalRetriever.test.d.ts.map +0 -1
  166. package/lib/test/unit/retrieve/linkTraversalRetriever.test.js +0 -259
  167. package/lib/test/unit/retrieve/linkTraversalRetriever.test.js.map +0 -1
  168. package/lib/test/unit/retrieve/retrievers.test.d.ts +0 -2
  169. package/lib/test/unit/retrieve/retrievers.test.d.ts.map +0 -1
  170. package/lib/test/unit/retrieve/retrievers.test.js +0 -770
  171. package/lib/test/unit/retrieve/retrievers.test.js.map +0 -1
  172. package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts +0 -2
  173. package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts.map +0 -1
  174. package/lib/test/unit/retrieve/temporalRetrievers.test.js +0 -184
  175. package/lib/test/unit/retrieve/temporalRetrievers.test.js.map +0 -1
  176. package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts +0 -9
  177. package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts.map +0 -1
  178. package/lib/test/unit/store/antagonistTemporalBoundary.test.js +0 -122
  179. package/lib/test/unit/store/antagonistTemporalBoundary.test.js.map +0 -1
  180. package/lib/test/unit/store/embedOnWrite.test.d.ts +0 -2
  181. package/lib/test/unit/store/embedOnWrite.test.d.ts.map +0 -1
  182. package/lib/test/unit/store/embedOnWrite.test.js +0 -319
  183. package/lib/test/unit/store/embedOnWrite.test.js.map +0 -1
  184. package/lib/test/unit/store/fileTreeMemoryStore.test.d.ts +0 -2
  185. package/lib/test/unit/store/fileTreeMemoryStore.test.d.ts.map +0 -1
  186. package/lib/test/unit/store/fileTreeMemoryStore.test.js +0 -780
  187. package/lib/test/unit/store/fileTreeMemoryStore.test.js.map +0 -1
  188. package/lib/test/unit/store/fragmentEmbedOnWrite.test.d.ts +0 -2
  189. package/lib/test/unit/store/fragmentEmbedOnWrite.test.d.ts.map +0 -1
  190. package/lib/test/unit/store/fragmentEmbedOnWrite.test.js +0 -257
  191. package/lib/test/unit/store/fragmentEmbedOnWrite.test.js.map +0 -1
  192. package/lib/test/unit/store/indexInjection.test.d.ts +0 -2
  193. package/lib/test/unit/store/indexInjection.test.d.ts.map +0 -1
  194. package/lib/test/unit/store/indexInjection.test.js +0 -434
  195. package/lib/test/unit/store/indexInjection.test.js.map +0 -1
  196. package/lib/test/unit/store/lenientOpen.test.d.ts +0 -2
  197. package/lib/test/unit/store/lenientOpen.test.d.ts.map +0 -1
  198. package/lib/test/unit/store/lenientOpen.test.js +0 -250
  199. package/lib/test/unit/store/lenientOpen.test.js.map +0 -1
  200. package/lib/test/unit/store/listScoped.test.d.ts +0 -2
  201. package/lib/test/unit/store/listScoped.test.d.ts.map +0 -1
  202. package/lib/test/unit/store/listScoped.test.js +0 -111
  203. package/lib/test/unit/store/listScoped.test.js.map +0 -1
  204. package/lib/test/unit/store/observations.test.d.ts +0 -2
  205. package/lib/test/unit/store/observations.test.d.ts.map +0 -1
  206. package/lib/test/unit/store/observations.test.js +0 -241
  207. package/lib/test/unit/store/observations.test.js.map +0 -1
  208. package/lib/test/unit/store/rankAxis.test.d.ts +0 -2
  209. package/lib/test/unit/store/rankAxis.test.d.ts.map +0 -1
  210. package/lib/test/unit/store/rankAxis.test.js +0 -256
  211. package/lib/test/unit/store/rankAxis.test.js.map +0 -1
  212. package/lib/test/unit/store/scopeEncoding.test.d.ts +0 -2
  213. package/lib/test/unit/store/scopeEncoding.test.d.ts.map +0 -1
  214. package/lib/test/unit/store/scopeEncoding.test.js +0 -26
  215. package/lib/test/unit/store/scopeEncoding.test.js.map +0 -1
  216. package/lib/test/unit/store/temporalStore.test.d.ts +0 -2
  217. package/lib/test/unit/store/temporalStore.test.d.ts.map +0 -1
  218. package/lib/test/unit/store/temporalStore.test.js +0 -400
  219. package/lib/test/unit/store/temporalStore.test.js.map +0 -1
  220. package/lib/test/unit/tools/memoryTools.test.d.ts +0 -2
  221. package/lib/test/unit/tools/memoryTools.test.d.ts.map +0 -1
  222. package/lib/test/unit/tools/memoryTools.test.js +0 -844
  223. package/lib/test/unit/tools/memoryTools.test.js.map +0 -1
  224. package/lib/test/unit/types/identityCodec.test.d.ts +0 -2
  225. package/lib/test/unit/types/identityCodec.test.d.ts.map +0 -1
  226. package/lib/test/unit/types/identityCodec.test.js +0 -189
  227. package/lib/test/unit/types/identityCodec.test.js.map +0 -1
  228. package/lib/test/unit/types/ids.test.d.ts +0 -2
  229. package/lib/test/unit/types/ids.test.d.ts.map +0 -1
  230. package/lib/test/unit/types/ids.test.js +0 -86
  231. package/lib/test/unit/types/ids.test.js.map +0 -1
  232. package/lib/test/unit/types/temporalCodec.test.d.ts +0 -2
  233. package/lib/test/unit/types/temporalCodec.test.d.ts.map +0 -1
  234. package/lib/test/unit/types/temporalCodec.test.js +0 -205
  235. package/lib/test/unit/types/temporalCodec.test.js.map +0 -1
  236. package/lib/test/unit/types/temporalPolicy.test.d.ts +0 -2
  237. package/lib/test/unit/types/temporalPolicy.test.d.ts.map +0 -1
  238. package/lib/test/unit/types/temporalPolicy.test.js +0 -85
  239. package/lib/test/unit/types/temporalPolicy.test.js.map +0 -1
  240. package/lib/test/unit/types/writePolicy.test.d.ts +0 -2
  241. package/lib/test/unit/types/writePolicy.test.d.ts.map +0 -1
  242. package/lib/test/unit/types/writePolicy.test.js +0 -333
  243. package/lib/test/unit/types/writePolicy.test.js.map +0 -1
  244. package/lib/test/unit/vector/fragmentConverters.test.d.ts +0 -2
  245. package/lib/test/unit/vector/fragmentConverters.test.d.ts.map +0 -1
  246. package/lib/test/unit/vector/fragmentConverters.test.js +0 -60
  247. package/lib/test/unit/vector/fragmentConverters.test.js.map +0 -1
  248. package/lib/test/unit/vector/inMemoryCosineIndex.test.d.ts +0 -2
  249. package/lib/test/unit/vector/inMemoryCosineIndex.test.d.ts.map +0 -1
  250. package/lib/test/unit/vector/inMemoryCosineIndex.test.js +0 -254
  251. package/lib/test/unit/vector/inMemoryCosineIndex.test.js.map +0 -1
  252. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.d.ts +0 -2
  253. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.d.ts.map +0 -1
  254. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js +0 -364
  255. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +0 -1
  256. package/lib/test/unit/vector/vectorIndex.test.d.ts +0 -2
  257. package/lib/test/unit/vector/vectorIndex.test.d.ts.map +0 -1
  258. package/lib/test/unit/vector/vectorIndex.test.js +0 -53
  259. package/lib/test/unit/vector/vectorIndex.test.js.map +0 -1
  260. package/rush-logs/ts-agent-memory.build.cache.log +0 -3
  261. package/rush-logs/ts-agent-memory.build.log +0 -9
  262. package/src/index.ts +0 -14
  263. package/src/packlets/converters/bodyConverterRegistry.ts +0 -105
  264. package/src/packlets/converters/envelopeConverter.ts +0 -233
  265. package/src/packlets/converters/index.ts +0 -7
  266. package/src/packlets/index/index.ts +0 -6
  267. package/src/packlets/index/memoryIndex.ts +0 -332
  268. package/src/packlets/ingest/cycleGuard.ts +0 -153
  269. package/src/packlets/ingest/hostStages.ts +0 -111
  270. package/src/packlets/ingest/index.ts +0 -9
  271. package/src/packlets/ingest/model.ts +0 -195
  272. package/src/packlets/ingest/orchestrator.ts +0 -968
  273. package/src/packlets/observe/index.ts +0 -7
  274. package/src/packlets/observe/memoryObservationStore.ts +0 -153
  275. package/src/packlets/observe/observer.ts +0 -119
  276. package/src/packlets/retrieve/fragmentSemanticRetriever.ts +0 -138
  277. package/src/packlets/retrieve/hybridRetriever.ts +0 -194
  278. package/src/packlets/retrieve/index.ts +0 -14
  279. package/src/packlets/retrieve/linkTraversalRetriever.ts +0 -158
  280. package/src/packlets/retrieve/recencyRetriever.ts +0 -54
  281. package/src/packlets/retrieve/retriever.ts +0 -291
  282. package/src/packlets/retrieve/semanticRetriever.ts +0 -152
  283. package/src/packlets/retrieve/structuredFilterRetriever.ts +0 -58
  284. package/src/packlets/retrieve/tagRetriever.ts +0 -58
  285. package/src/packlets/retrieve/temporalRetrievers.ts +0 -210
  286. package/src/packlets/store/fileTreeMemoryStore.ts +0 -1872
  287. package/src/packlets/store/index.ts +0 -7
  288. package/src/packlets/store/scopeEncoding.ts +0 -36
  289. package/src/packlets/tools/index.ts +0 -6
  290. package/src/packlets/tools/memoryTools.ts +0 -706
  291. package/src/packlets/types/envelope.ts +0 -196
  292. package/src/packlets/types/filenameSafety.ts +0 -57
  293. package/src/packlets/types/identityCodec.ts +0 -447
  294. package/src/packlets/types/ids.ts +0 -124
  295. package/src/packlets/types/index.ts +0 -11
  296. package/src/packlets/types/temporal.ts +0 -96
  297. package/src/packlets/types/writePolicy.ts +0 -612
  298. package/src/packlets/vector/fragmentConverters.ts +0 -55
  299. package/src/packlets/vector/inMemoryCosineIndex.ts +0 -196
  300. package/src/packlets/vector/inMemoryFragmentCosineIndex.ts +0 -289
  301. package/src/packlets/vector/index.ts +0 -9
  302. package/src/packlets/vector/vectorIndex.ts +0 -273
  303. package/src/test/unit/converters/antagonistRoundTrip.test.ts +0 -110
  304. package/src/test/unit/converters/bodyConverterRegistry.test.ts +0 -89
  305. package/src/test/unit/converters/envelopeConverter.test.ts +0 -418
  306. package/src/test/unit/index/memoryIndex.test.ts +0 -272
  307. package/src/test/unit/ingest/antagonistCycleAndParity.test.ts +0 -367
  308. package/src/test/unit/ingest/cycleGuard.test.ts +0 -110
  309. package/src/test/unit/ingest/dedupScope.test.ts +0 -542
  310. package/src/test/unit/ingest/orchestrator.test.ts +0 -1355
  311. package/src/test/unit/observe/memoryObservationStore.test.ts +0 -158
  312. package/src/test/unit/retrieve/fragmentSemanticRetriever.test.ts +0 -163
  313. package/src/test/unit/retrieve/linkTraversalRetriever.test.ts +0 -329
  314. package/src/test/unit/retrieve/retrievers.test.ts +0 -1018
  315. package/src/test/unit/retrieve/temporalRetrievers.test.ts +0 -226
  316. package/src/test/unit/store/antagonistTemporalBoundary.test.ts +0 -158
  317. package/src/test/unit/store/embedOnWrite.test.ts +0 -418
  318. package/src/test/unit/store/fileTreeMemoryStore.test.ts +0 -1041
  319. package/src/test/unit/store/fragmentEmbedOnWrite.test.ts +0 -349
  320. package/src/test/unit/store/indexInjection.test.ts +0 -550
  321. package/src/test/unit/store/lenientOpen.test.ts +0 -292
  322. package/src/test/unit/store/listScoped.test.ts +0 -138
  323. package/src/test/unit/store/observations.test.ts +0 -290
  324. package/src/test/unit/store/rankAxis.test.ts +0 -349
  325. package/src/test/unit/store/scopeEncoding.test.ts +0 -37
  326. package/src/test/unit/store/temporalStore.test.ts +0 -469
  327. package/src/test/unit/tools/memoryTools.test.ts +0 -1121
  328. package/src/test/unit/types/identityCodec.test.ts +0 -266
  329. package/src/test/unit/types/ids.test.ts +0 -94
  330. package/src/test/unit/types/temporalCodec.test.ts +0 -259
  331. package/src/test/unit/types/temporalPolicy.test.ts +0 -124
  332. package/src/test/unit/types/writePolicy.test.ts +0 -446
  333. package/src/test/unit/vector/fragmentConverters.test.ts +0 -80
  334. package/src/test/unit/vector/inMemoryCosineIndex.test.ts +0 -318
  335. package/src/test/unit/vector/inMemoryFragmentCosineIndex.test.ts +0 -477
  336. package/src/test/unit/vector/vectorIndex.test.ts +0 -64
  337. package/temp/build/lint/_eslint-5eVG3S6w.json +0 -306
  338. package/temp/build/typescript/ts_8nwakTlr.json +0 -1
  339. package/temp/ts-agent-memory.api.json +0 -21030
  340. package/temp/ts-agent-memory.api.md +0 -940
  341. package/tsconfig.json +0 -8
@@ -87,8 +87,16 @@ export interface IMemoryStore {
87
87
  /**
88
88
  * Adapt this store to the {@link IMemoryRecordSource} seam so it can drive
89
89
  * {@link IVectorIndex} rebuilds (e.g. `InMemoryCosineIndex.rebuild`). The
90
- * returned source's `list()` delegates to {@link IMemoryStore.listScoped}. The
91
- * store cannot implement {@link IMemoryRecordSource} directly because its
90
+ * returned source's `list()` delegates to {@link IMemoryStore.listScoped},
91
+ * **filtered to the kinds {@link IMemoryStore.embedsKind | embedsKind} reports**
92
+ * this source exists to feed the record vector index, so a kind excluded from
93
+ * that index is excluded here too, and a reopen does not re-embed records the
94
+ * index will never return. With no
95
+ * {@link IFileTreeMemoryStoreCreateParams.embedKinds | embedKinds} declaration
96
+ * every kind participates and the filter is the identity. `listScoped` itself is
97
+ * **not** filtered and remains the whole-vault surface.
98
+ *
99
+ * The store cannot implement {@link IMemoryRecordSource} directly because its
92
100
  * `list(filter?)` returns bare records (the ergonomic query surface) while the
93
101
  * seam's `list()` returns scope-qualified records.
94
102
  */
@@ -121,6 +129,25 @@ export interface IMemoryStore {
121
129
  * invoking admission or merge logic out of band.
122
130
  */
123
131
  dedupScopeFor(kind: Kind): DedupScope;
132
+ /**
133
+ * Whether records of `kind` participate in the **record-granular** vector index.
134
+ *
135
+ * @remarks
136
+ * A read accessor over the store's injected {@link IFileTreeMemoryStoreCreateParams.embedKinds | embedKinds}
137
+ * declaration, in the same spirit as {@link IMemoryStore.dedupScopeFor} — one
138
+ * place to ask, so the store's write path and any caller reasoning about index
139
+ * coverage cannot disagree. `true` for every kind when no declaration was made.
140
+ *
141
+ * **This is distinct from a {@link MemoryEmbedder} decline, and the difference is
142
+ * cost.** An embedder that returns `undefined` has already been called: the
143
+ * round trip is paid, and on a locally-hosted model that round trip is the
144
+ * expense. A kind excluded here is never handed to the embedder at all. The
145
+ * decline makes the intent *expressible*; this makes it *free*.
146
+ *
147
+ * Deliberately synchronous, total, and NOT `Result`-returning: it reads
148
+ * constructor-injected configuration, touches no I/O, and cannot fail.
149
+ */
150
+ embedsKind(kind: Kind): boolean;
124
151
  /**
125
152
  * Write a record. Validates the body, computes a content hash, deduplicates
126
153
  * (scope-wide, before policy), applies the kind's {@link IWritePolicy}, stamps
@@ -164,6 +191,37 @@ export interface IFileTreeMemoryStoreCreateParams {
164
191
  * guard-host-callbacks conventions).
165
192
  */
166
193
  readonly rankProjectors?: ReadonlyMap<Kind, RankProjector>;
194
+ /**
195
+ * The kinds whose records participate in the **record-granular** vector index.
196
+ *
197
+ * @remarks
198
+ * **Absent means every kind participates**, which is the pre-existing behavior —
199
+ * so omitting this is byte-identical to before it existed. Supplying it makes the
200
+ * set an allowlist: a kind outside it is never handed to the {@link MemoryEmbedder}
201
+ * on write, and is omitted from {@link IMemoryStore.asRecordSource | asRecordSource},
202
+ * so a rebuild driven from this store does not pay for it either.
203
+ *
204
+ * Two costs motivate it, and the second is the one that is easy to miss:
205
+ *
206
+ * - **Embedder work on the critical path.** Embed-on-write is synchronous with
207
+ * the write. A bookkeeping row — a status, a counter, a lease — that no query
208
+ * will ever return still pays a full embedding round trip, and on a
209
+ * locally-hosted model the first call after a restart pays a cold model load
210
+ * on top.
211
+ * - **Un-queried kinds crowd the `topK` window.** `IVectorIndex.query` applies
212
+ * `topK` *before* any kind filter the retriever adds, so vectors that can never
213
+ * be returned still occupy candidate slots. Over-fetching to compensate hides
214
+ * this until the un-queried kinds start scoring well — at which point recall is
215
+ * silently lost. Restricting what is indexed fixes the recall problem, not just
216
+ * the cost.
217
+ *
218
+ * Applies to the record-granular path only. The fragment path
219
+ * ({@link IFileTreeMemoryStoreCreateParams.fragmentIndex | fragmentIndex} /
220
+ * `fragmentEmbedder`) is independent and unaffected — a kind may legitimately be
221
+ * fragment-embedded and not record-embedded, which is the right shape for a long
222
+ * document whose whole body exceeds the model's context.
223
+ */
224
+ readonly embedKinds?: ReadonlySet<Kind>;
167
225
  /** Default codec for kinds without an explicit entry. */
168
226
  readonly defaultCodec?: IIdentityCodec;
169
227
  /**
@@ -318,6 +376,8 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
318
376
  private readonly _writePolicies;
319
377
  private readonly _codecs;
320
378
  private readonly _rankProjectors;
379
+ /** `undefined` = no declaration = every kind participates. */
380
+ private readonly _embedKinds;
321
381
  private readonly _defaultCodec;
322
382
  private readonly _defaultPolicy;
323
383
  private readonly _scopeEncoding;
@@ -325,11 +385,9 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
325
385
  private readonly _index;
326
386
  private readonly _hasher;
327
387
  private readonly _observers;
388
+ /** Record- and fragment-vector maintenance; every operation is best-effort. */
389
+ private readonly _vectors;
328
390
  private readonly _logger;
329
- private readonly _vectorIndex;
330
- private readonly _embed;
331
- private readonly _fragmentIndex;
332
- private readonly _fragmentEmbedder;
333
391
  /**
334
392
  * Records the initial walk could not load. Populated during `create()` in
335
393
  * {@link MemoryRecordErrorMode | `'skip'` mode}; empty otherwise.
@@ -446,39 +504,6 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
446
504
  * later eviction failure never loses data with nothing written in its place.
447
505
  */
448
506
  private _admitWrite;
449
- /**
450
- * Best-effort embed-on-write. When a vector index AND an embedder are wired,
451
- * embeds the built record, `add`s the vector (replace semantics handle a same-id
452
- * re-embed — no explicit remove), and stamps the returned `embeddingRef`. A
453
- * failure (returned `fail` OR a thrown/rejected hook) is logged and the
454
- * unembedded record is returned unchanged — the put still persists, and the
455
- * derived index is reconciled by a later `rebuild`. A pass-through no-op when
456
- * unwired (byte-identical record).
457
- *
458
- * Always succeeds (`Result` is the chain's shape, never a vector-induced
459
- * failure).
460
- */
461
- private _embedOnWrite;
462
- /**
463
- * Best-effort fragment-embed-on-write. When a fragment index AND a fragment
464
- * embedder are wired, chunks + embeds the built record and replaces its
465
- * fragments in the index (`addFragments` is whole-record-replace, so a re-authored
466
- * document never leaves stale fragments behind — no explicit remove needed). A
467
- * failure (returned `fail` OR a thrown/rejected hook) is logged and the record is
468
- * returned unchanged — the put still persists, and the fragment index is a derived
469
- * view a later `rebuild` reconciles. Unlike {@link FileTreeMemoryStore._embedOnWrite}
470
- * it stamps nothing on the record (fragments have no per-record `embeddingRef`
471
- * analog). A pass-through no-op when unwired (byte-identical record).
472
- */
473
- private _embedFragmentsOnWrite;
474
- /**
475
- * Best-effort fragment removal. A no-op unless the full fragment lifecycle is
476
- * wired (both an index AND an embedder), so an unwired store does no fragment
477
- * work and behaves byte-identically. Failures are logged, never surfaced — a
478
- * committed delete/eviction must not fail because a derived fragment index could
479
- * not be pruned.
480
- */
481
- private _removeFragmentsBestEffort;
482
507
  /**
483
508
  * Evict the records named by a `cull-oldest` decision, best-effort. Runs only
484
509
  * after the authoritative `_persist`, so a failed eviction is logged (never
@@ -487,26 +512,6 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
487
512
  * `accept` / `reject` decisions evict nothing.
488
513
  */
489
514
  private _applyEvictions;
490
- /**
491
- * Best-effort vector removal for each evicted record (never fails the put).
492
- * Every evicted record is in the same `scope` as the incoming write (the
493
- * cull-oldest cohort is the incoming record's `(scope, kind)` cohort), so that
494
- * scope qualifies each removal target.
495
- */
496
- private _removeEvictedVectors;
497
- /**
498
- * Run a consumer-supplied vector hook, normalizing a thrown/rejected hook into a
499
- * `Failure` and logging any failure at `warn`. Best-effort: the caller proceeds
500
- * regardless, since the index is rebuildable.
501
- */
502
- private _tryVectorOp;
503
- /**
504
- * Best-effort vector removal. A no-op unless the full vector lifecycle is wired
505
- * (both an index AND an embedder), so an unwired store does no vector work and
506
- * behaves byte-identically. Failures are logged, never surfaced — a committed
507
- * delete/eviction must not fail because a derived index could not be pruned.
508
- */
509
- private _removeVectorBestEffort;
510
515
  /**
511
516
  * Build the record to persist. On a first write the incoming envelope is the
512
517
  * base (final content equals the incoming content, so the dedup `hash` is
@@ -640,6 +645,8 @@ export declare class FileTreeMemoryStore implements IMemoryStore {
640
645
  private _policyFor;
641
646
  /** {@inheritDoc IMemoryStore.dedupScopeFor} */
642
647
  dedupScopeFor(kind: Kind): DedupScope;
648
+ /** {@inheritDoc IMemoryStore.embedsKind} */
649
+ embedsKind(kind: Kind): boolean;
643
650
  /**
644
651
  * Read and validate the record at `<scope>/<idStem>.md`, returning `undefined`
645
652
  * when the scope directory or file is absent. Verifies the on-disk id ↔
@@ -1 +1 @@
1
- {"version":3,"file":"fileTreeMemoryStore.d.ts","sourceRoot":"","sources":["../../../src/packlets/store/fileTreeMemoryStore.ts"],"names":[],"mappings":"AAKA,OAAO,EAAQ,OAAO,EAAE,MAAM,EAAyC,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAGL,UAAU,EACV,QAAQ,EAER,cAAc,EAEd,aAAa,EAGb,YAAY,EACZ,IAAI,EAEJ,QAAQ,EACR,cAAc,EACd,aAAa,EACb,GAAG,EAMJ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,sBAAsB,IAAI,SAAS,EAAwC,MAAM,eAAe,CAAC;AAC1G,OAAO,EAAwB,YAAY,EAAe,MAAM,UAAU,CAAC;AAC3E,OAAO,EAEL,eAAe,EAGhB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAEhB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACf,MAAM,WAAW,CAAC;AAMnB;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,QAAQ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B;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAe3B;;;;;;;;OAQG;IACH,OAAO,CAAC,qBAAqB;IA0D7B;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAwB1B;;;;;;;;OAQG;YACW,gBAAgB;IAe9B,gFAAgF;IAChF,OAAO,CAAC,MAAM;IAWd,uEAAuE;IACvE,OAAO,CAAC,oBAAoB;IAkB5B;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,2BAA2B;IAYnC,OAAO,CAAC,YAAY;IAIpB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,UAAU;IAIlB,+CAA+C;IACxC,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU;IAI5C,4CAA4C;IACrC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAMtC;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAqBnB;;;;;;;;OAQG;IACH,OAAO,CAAC,aAAa;IAyBrB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAwBxB,sEAAsE;IACtE,OAAO,CAAC,eAAe;IAyBvB,oEAAoE;IACpE,OAAO,CAAC,UAAU;IAmBlB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAwBnB;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;IAarB,kFAAkF;IAClF,OAAO,CAAC,eAAe;IAiCvB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;CAoBxB"}
@@ -9,6 +9,7 @@ const ts_utils_1 = require("@fgv/ts-utils");
9
9
  const ts_json_base_1 = require("@fgv/ts-json-base");
10
10
  const types_1 = require("../types");
11
11
  const converters_1 = require("../converters");
12
+ const vectorMaintenance_1 = require("./vectorMaintenance");
12
13
  const index_1 = require("../index");
13
14
  const scopeEncoding_1 = require("./scopeEncoding");
14
15
  /** The on-disk extension for a memory record file. */
@@ -29,11 +30,13 @@ const MEMORY_FILE_EXTENSION = '.md';
29
30
  */
30
31
  class FileTreeMemoryStore {
31
32
  constructor(params) {
33
+ var _a;
32
34
  this._root = params.root;
33
35
  this._registry = params.registry;
34
36
  this._writePolicies = params.writePolicies;
35
37
  this._codecs = params.codecs;
36
38
  this._rankProjectors = params.rankProjectors;
39
+ this._embedKinds = (_a = params.embedKinds) !== null && _a !== void 0 ? _a : undefined;
37
40
  this._defaultCodec = params.defaultCodec;
38
41
  this._defaultPolicy = params.defaultPolicy;
39
42
  this._scopeEncoding = params.scopeEncoding;
@@ -42,10 +45,14 @@ class FileTreeMemoryStore {
42
45
  this._hasher = new ts_utils_1.Hash.Crc32Normalizer();
43
46
  this._observers = params.observers;
44
47
  this._logger = params.logger;
45
- this._vectorIndex = params.vectorIndex;
46
- this._embed = params.embed;
47
- this._fragmentIndex = params.fragmentIndex;
48
- this._fragmentEmbedder = params.fragmentEmbedder;
48
+ this._vectors = new vectorMaintenance_1.VectorMaintenance({
49
+ vectorIndex: params.vectorIndex,
50
+ embed: params.embed,
51
+ fragmentIndex: params.fragmentIndex,
52
+ fragmentEmbedder: params.fragmentEmbedder,
53
+ warn: (message) => this._warnSwallowed(message),
54
+ embedsKind: (kind) => this.embedsKind(kind)
55
+ });
49
56
  this._skippedRecords = [];
50
57
  this._seq = 0;
51
58
  this._observationSeq = 0;
@@ -78,6 +85,7 @@ class FileTreeMemoryStore {
78
85
  writePolicies: (_a = params.writePolicies) !== null && _a !== void 0 ? _a : new Map(),
79
86
  codecs: (_b = params.codecs) !== null && _b !== void 0 ? _b : new Map(),
80
87
  rankProjectors: (_c = params.rankProjectors) !== null && _c !== void 0 ? _c : new Map(),
88
+ embedKinds: params.embedKinds,
81
89
  defaultCodec: params.defaultCodec,
82
90
  defaultPolicy,
83
91
  scopeEncoding: (_d = params.scopeEncoding) !== null && _d !== void 0 ? _d : scopeEncoding_1.defaultMemoryScopeEncoding,
@@ -171,7 +179,14 @@ class FileTreeMemoryStore {
171
179
  }
172
180
  /** {@inheritDoc IMemoryStore.asRecordSource} */
173
181
  asRecordSource() {
174
- return { list: () => this.listScoped() };
182
+ return {
183
+ // Filtered to the kinds that participate in the record vector index. This
184
+ // source exists to drive `IVectorIndex` rebuilds, so a kind excluded from the
185
+ // index has no business being re-embedded on open — which is where the cost
186
+ // is worst, since a rebuild embeds the whole vault serially. With no
187
+ // `embedKinds` declaration every kind passes and this is the identity filter.
188
+ list: async () => (await this.listScoped()).onSuccess((scoped) => (0, ts_utils_1.succeed)(scoped.filter((s) => this.embedsKind(s.record.envelope.kind))))
189
+ };
175
190
  }
176
191
  /**
177
192
  * Collapse temporal records to the single version valid at `asOf` per entity;
@@ -213,7 +228,8 @@ class FileTreeMemoryStore {
213
228
  outcome: result.isSuccess() ? 'success' : 'failure',
214
229
  id: result.isSuccess() ? result.value.record.envelope.id : record.envelope.id,
215
230
  provenance: record.envelope.provenance,
216
- error: result.isFailure() ? result.message : undefined
231
+ error: result.isFailure() ? result.message : undefined,
232
+ embed: result.isSuccess() ? result.value.embed : undefined
217
233
  });
218
234
  // Fire one `'delete'` observation per record evicted by cap-cull. The
219
235
  // evicted records are always in the same `(scope, kind)` cohort as the
@@ -269,7 +285,8 @@ class FileTreeMemoryStore {
269
285
  kind,
270
286
  outcome: details.outcome,
271
287
  error: details.error,
272
- provenance: details.provenance
288
+ provenance: details.provenance,
289
+ embed: details.embed
273
290
  };
274
291
  const awaited = [];
275
292
  for (const observer of this._observers) {
@@ -422,89 +439,27 @@ class FileTreeMemoryStore {
422
439
  }
423
440
  return this._buildRecord(record, body, existing, policy, hash)
424
441
  .onSuccess((built) => (0, ts_utils_1.succeed)(this._stampRank(built)))
425
- .thenOnSuccess((built) => this._embedOnWrite(built, scope))
426
- .thenOnSuccess((built) => this._embedFragmentsOnWrite(built, scope))
427
- .onSuccess((embeddedBuilt) => this._persist(embeddedBuilt, scope, idStem))
428
- .thenOnSuccess(async (persisted) => {
442
+ .thenOnSuccess((built) => this._vectors.embedOnWrite(built, scope))
443
+ .thenOnSuccess(async (embedded) => (await this._vectors.embedFragmentsOnWrite(embedded.record, scope)).onSuccess((withFragments) => (0, ts_utils_1.succeed)(Object.assign(Object.assign({}, embedded), { record: withFragments }))))
444
+ .onSuccess((embedded) => this._persist(embedded.record, scope, idStem).onSuccess((persisted) => (0, ts_utils_1.succeed)({ persisted, stale: embedded.stale, embed: embedded.embed })))
445
+ .thenOnSuccess(async ({ persisted, stale, embed }) => {
429
446
  // Everything after the authoritative `_persist` commit is best-effort and
430
447
  // never turns a committed write into a `Failure`:
448
+ // - a stale vector superseded by a decline is pruned here rather than at
449
+ // the point of the decline, because a `_persist` that fails leaves the
450
+ // PREVIOUS content on disk — content that vector is still an accurate
451
+ // embedding of. Pruning early would delete a correct vector on behalf
452
+ // of a write that never landed;
431
453
  // - a cull-oldest eviction that fails is logged (the per-(scope,kind)
432
454
  // cap may be transiently exceeded; the next write's admission restores
433
455
  // it), and only the successfully-evicted ids flow onward;
434
456
  // - vector pruning of the evicted cohort is likewise best-effort.
457
+ await this._vectors.pruneStaleVector(stale);
435
458
  const evicted = this._applyEvictions(decision, scope);
436
- await this._removeEvictedVectors(evicted, scope);
437
- return (0, ts_utils_1.succeed)({ record: persisted, evicted });
459
+ await this._vectors.removeEvictedVectors(evicted, scope);
460
+ return (0, ts_utils_1.succeed)({ record: persisted, evicted, embed });
438
461
  });
439
462
  }
440
- /**
441
- * Best-effort embed-on-write. When a vector index AND an embedder are wired,
442
- * embeds the built record, `add`s the vector (replace semantics handle a same-id
443
- * re-embed — no explicit remove), and stamps the returned `embeddingRef`. A
444
- * failure (returned `fail` OR a thrown/rejected hook) is logged and the
445
- * unembedded record is returned unchanged — the put still persists, and the
446
- * derived index is reconciled by a later `rebuild`. A pass-through no-op when
447
- * unwired (byte-identical record).
448
- *
449
- * Always succeeds (`Result` is the chain's shape, never a vector-induced
450
- * failure).
451
- */
452
- async _embedOnWrite(built, scope) {
453
- if (this._vectorIndex === undefined || this._embed === undefined) {
454
- return (0, ts_utils_1.succeed)(built);
455
- }
456
- const vectorIndex = this._vectorIndex;
457
- const embed = this._embed;
458
- const target = { scope, id: built.envelope.id };
459
- const embedded = await this._tryVectorOp(() => embed(built), `embedding '${built.envelope.id}'`);
460
- if (embedded.isFailure()) {
461
- return (0, ts_utils_1.succeed)(built);
462
- }
463
- const added = await this._tryVectorOp(() => vectorIndex.add(target, embedded.value), `vector add for '${built.envelope.id}'`);
464
- if (added.isFailure()) {
465
- return (0, ts_utils_1.succeed)(built);
466
- }
467
- return (0, ts_utils_1.succeed)({ envelope: Object.assign(Object.assign({}, built.envelope), { embeddingRef: added.value }), body: built.body });
468
- }
469
- /**
470
- * Best-effort fragment-embed-on-write. When a fragment index AND a fragment
471
- * embedder are wired, chunks + embeds the built record and replaces its
472
- * fragments in the index (`addFragments` is whole-record-replace, so a re-authored
473
- * document never leaves stale fragments behind — no explicit remove needed). A
474
- * failure (returned `fail` OR a thrown/rejected hook) is logged and the record is
475
- * returned unchanged — the put still persists, and the fragment index is a derived
476
- * view a later `rebuild` reconciles. Unlike {@link FileTreeMemoryStore._embedOnWrite}
477
- * it stamps nothing on the record (fragments have no per-record `embeddingRef`
478
- * analog). A pass-through no-op when unwired (byte-identical record).
479
- */
480
- async _embedFragmentsOnWrite(built, scope) {
481
- if (this._fragmentIndex === undefined || this._fragmentEmbedder === undefined) {
482
- return (0, ts_utils_1.succeed)(built);
483
- }
484
- const fragmentIndex = this._fragmentIndex;
485
- const fragmentEmbedder = this._fragmentEmbedder;
486
- const target = { scope, id: built.envelope.id };
487
- const embedded = await this._tryVectorOp(() => fragmentEmbedder(built), `fragment embedding '${built.envelope.id}'`);
488
- if (embedded.isFailure()) {
489
- return (0, ts_utils_1.succeed)(built);
490
- }
491
- await this._tryVectorOp(() => fragmentIndex.addFragments(target, embedded.value), `fragment add for '${built.envelope.id}'`);
492
- return (0, ts_utils_1.succeed)(built);
493
- }
494
- /**
495
- * Best-effort fragment removal. A no-op unless the full fragment lifecycle is
496
- * wired (both an index AND an embedder), so an unwired store does no fragment
497
- * work and behaves byte-identically. Failures are logged, never surfaced — a
498
- * committed delete/eviction must not fail because a derived fragment index could
499
- * not be pruned.
500
- */
501
- async _removeFragmentsBestEffort(target) {
502
- if (this._fragmentIndex === undefined || this._fragmentEmbedder === undefined) {
503
- return;
504
- }
505
- const fragmentIndex = this._fragmentIndex;
506
- await this._tryVectorOp(() => fragmentIndex.remove(target), `fragment removal for '${target.id}'`);
507
- }
508
463
  /**
509
464
  * Evict the records named by a `cull-oldest` decision, best-effort. Runs only
510
465
  * after the authoritative `_persist`, so a failed eviction is logged (never
@@ -528,49 +483,6 @@ class FileTreeMemoryStore {
528
483
  }
529
484
  return evicted;
530
485
  }
531
- /**
532
- * Best-effort vector removal for each evicted record (never fails the put).
533
- * Every evicted record is in the same `scope` as the incoming write (the
534
- * cull-oldest cohort is the incoming record's `(scope, kind)` cohort), so that
535
- * scope qualifies each removal target.
536
- */
537
- async _removeEvictedVectors(evicted, scope) {
538
- for (const id of evicted) {
539
- await this._removeVectorBestEffort({ scope, id });
540
- await this._removeFragmentsBestEffort({ scope, id });
541
- }
542
- }
543
- /**
544
- * Run a consumer-supplied vector hook, normalizing a thrown/rejected hook into a
545
- * `Failure` and logging any failure at `warn`. Best-effort: the caller proceeds
546
- * regardless, since the index is rebuildable.
547
- */
548
- async _tryVectorOp(op, label) {
549
- let result;
550
- try {
551
- result = await op();
552
- }
553
- catch (err) {
554
- result = (0, ts_utils_1.fail)(`${label} threw: ${String(err)}`);
555
- }
556
- if (result.isFailure()) {
557
- this._warnSwallowed(`memory: ${label} failed (best-effort; derived index left for rebuild): ${result.message}`);
558
- }
559
- return result;
560
- }
561
- /**
562
- * Best-effort vector removal. A no-op unless the full vector lifecycle is wired
563
- * (both an index AND an embedder), so an unwired store does no vector work and
564
- * behaves byte-identically. Failures are logged, never surfaced — a committed
565
- * delete/eviction must not fail because a derived index could not be pruned.
566
- */
567
- async _removeVectorBestEffort(target) {
568
- if (this._vectorIndex === undefined || this._embed === undefined) {
569
- return;
570
- }
571
- const vectorIndex = this._vectorIndex;
572
- await this._tryVectorOp(() => vectorIndex.remove(target), `vector removal for '${target.id}'`);
573
- }
574
486
  /**
575
487
  * Build the record to persist. On a first write the incoming envelope is the
576
488
  * base (final content equals the incoming content, so the dedup `hash` is
@@ -640,8 +552,7 @@ class FileTreeMemoryStore {
640
552
  return this._deleteFile(scope, idStem)
641
553
  .onSuccess(() => this._index.patch('delete', { scope, record: existing }))
642
554
  .thenOnSuccess(async () => {
643
- await this._removeVectorBestEffort({ scope, id: existing.envelope.id });
644
- await this._removeFragmentsBestEffort({ scope, id: existing.envelope.id });
555
+ await this._vectors.removeAll({ scope, id: existing.envelope.id });
645
556
  return (0, ts_utils_1.succeed)(existing.envelope.id);
646
557
  });
647
558
  });
@@ -727,11 +638,15 @@ class FileTreeMemoryStore {
727
638
  .withErrorFormat((msg) => `memory put '${entityId}': ${msg}`)
728
639
  .thenOnSuccess((versionStem) => this._buildVersionedRecord(record, body, current, policy, hash, versionStem, validAt, now, seq)
729
640
  .onSuccess((built) => (0, ts_utils_1.succeed)(this._stampRank(built)))
730
- .thenOnSuccess((built) => this._embedOnWrite(built, scope))
731
- .thenOnSuccess((built) => this._embedFragmentsOnWrite(built, scope))
732
- .onSuccess((embeddedBuilt) => this._persist(embeddedBuilt, scope, versionStem))
733
- .onSuccess((persisted) => this._invalidateCurrents(scope, priorCurrents, validAt, now).onSuccess(() => (0, ts_utils_1.succeed)(persisted)))
734
- .onSuccess((persisted) => (0, ts_utils_1.succeed)({ record: persisted, evicted: [] })));
641
+ .thenOnSuccess((built) => this._vectors.embedOnWrite(built, scope))
642
+ .thenOnSuccess(async (embedded) => (await this._vectors.embedFragmentsOnWrite(embedded.record, scope)).onSuccess((withFragments) => (0, ts_utils_1.succeed)(Object.assign(Object.assign({}, embedded), { record: withFragments }))))
643
+ .onSuccess((embedded) => this._persist(embedded.record, scope, versionStem).onSuccess((persisted) => (0, ts_utils_1.succeed)({ persisted, stale: embedded.stale, embed: embedded.embed })))
644
+ .onSuccess(({ persisted, stale, embed }) => this._invalidateCurrents(scope, priorCurrents, validAt, now).onSuccess(() => (0, ts_utils_1.succeed)({ persisted, stale, embed })))
645
+ // Post-commit and best-effort, exactly as on the flat path.
646
+ .thenOnSuccess(async ({ persisted, stale, embed }) => {
647
+ await this._vectors.pruneStaleVector(stale);
648
+ return (0, ts_utils_1.succeed)({ record: persisted, evicted: [], embed });
649
+ }));
735
650
  });
736
651
  });
737
652
  }
@@ -944,6 +859,12 @@ class FileTreeMemoryStore {
944
859
  var _a;
945
860
  return (_a = this._policyFor(kind).dedupScope) !== null && _a !== void 0 ? _a : types_1.DEFAULT_DEDUP_SCOPE;
946
861
  }
862
+ /** {@inheritDoc IMemoryStore.embedsKind} */
863
+ embedsKind(kind) {
864
+ // No declaration means every kind participates — the behavior that predates
865
+ // this param, so an existing consumer is unaffected.
866
+ return this._embedKinds === undefined || this._embedKinds.has(kind);
867
+ }
947
868
  /**
948
869
  * Read and validate the record at `<scope>/<idStem>.md`, returning `undefined`
949
870
  * when the scope directory or file is absent. Verifies the on-disk id ↔