@fgv/ts-agent-memory 5.1.0-46 → 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 (336) hide show
  1. package/README.md +55 -0
  2. package/dist/packlets/ingest/orchestrator.js +115 -20
  3. package/dist/packlets/ingest/orchestrator.js.map +1 -1
  4. package/dist/packlets/observe/memoryObservationStore.js +6 -0
  5. package/dist/packlets/observe/memoryObservationStore.js.map +1 -1
  6. package/dist/packlets/observe/observer.js.map +1 -1
  7. package/dist/packlets/store/fileTreeMemoryStore.js +63 -135
  8. package/dist/packlets/store/fileTreeMemoryStore.js.map +1 -1
  9. package/dist/packlets/store/vectorMaintenance.js +251 -0
  10. package/dist/packlets/store/vectorMaintenance.js.map +1 -0
  11. package/dist/packlets/vector/inMemoryCosineIndex.js +81 -18
  12. package/dist/packlets/vector/inMemoryCosineIndex.js.map +1 -1
  13. package/dist/packlets/vector/inMemoryFragmentCosineIndex.js +7 -0
  14. package/dist/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
  15. package/dist/packlets/vector/vectorIndex.js.map +1 -1
  16. package/dist/ts-agent-memory.d.ts +389 -71
  17. package/lib/packlets/ingest/orchestrator.d.ts +62 -5
  18. package/lib/packlets/ingest/orchestrator.d.ts.map +1 -1
  19. package/lib/packlets/ingest/orchestrator.js +115 -20
  20. package/lib/packlets/ingest/orchestrator.js.map +1 -1
  21. package/lib/packlets/observe/memoryObservationStore.d.ts.map +1 -1
  22. package/lib/packlets/observe/memoryObservationStore.js +6 -0
  23. package/lib/packlets/observe/memoryObservationStore.js.map +1 -1
  24. package/lib/packlets/observe/observer.d.ts +61 -0
  25. package/lib/packlets/observe/observer.d.ts.map +1 -1
  26. package/lib/packlets/observe/observer.js.map +1 -1
  27. package/lib/packlets/store/fileTreeMemoryStore.d.ts +97 -60
  28. package/lib/packlets/store/fileTreeMemoryStore.d.ts.map +1 -1
  29. package/lib/packlets/store/fileTreeMemoryStore.js +63 -135
  30. package/lib/packlets/store/fileTreeMemoryStore.js.map +1 -1
  31. package/lib/packlets/store/vectorMaintenance.d.ts +149 -0
  32. package/lib/packlets/store/vectorMaintenance.d.ts.map +1 -0
  33. package/lib/packlets/store/vectorMaintenance.js +255 -0
  34. package/lib/packlets/store/vectorMaintenance.js.map +1 -0
  35. package/lib/packlets/vector/inMemoryCosineIndex.d.ts +30 -7
  36. package/lib/packlets/vector/inMemoryCosineIndex.d.ts.map +1 -1
  37. package/lib/packlets/vector/inMemoryCosineIndex.js +80 -17
  38. package/lib/packlets/vector/inMemoryCosineIndex.js.map +1 -1
  39. package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts +7 -0
  40. package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts.map +1 -1
  41. package/lib/packlets/vector/inMemoryFragmentCosineIndex.js +7 -0
  42. package/lib/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
  43. package/lib/packlets/vector/vectorIndex.d.ts +129 -1
  44. package/lib/packlets/vector/vectorIndex.d.ts.map +1 -1
  45. package/lib/packlets/vector/vectorIndex.js.map +1 -1
  46. package/package.json +17 -7
  47. package/.rush/temp/6e1299d1cebb080772163a532c221cd181b54f9f.tar.log +0 -462
  48. package/.rush/temp/chunked-rush-logs/ts-agent-memory.build.chunks.jsonl +0 -9
  49. package/.rush/temp/operation/build/all.log +0 -9
  50. package/.rush/temp/operation/build/log-chunks.jsonl +0 -9
  51. package/.rush/temp/operation/build/state.json +0 -3
  52. package/.rush/temp/shrinkwrap-deps.json +0 -689
  53. package/config/api-extractor.json +0 -343
  54. package/config/jest.config.json +0 -14
  55. package/config/rig.json +0 -4
  56. package/dist/test/unit/converters/antagonistRoundTrip.test.js +0 -95
  57. package/dist/test/unit/converters/antagonistRoundTrip.test.js.map +0 -1
  58. package/dist/test/unit/converters/bodyConverterRegistry.test.js +0 -72
  59. package/dist/test/unit/converters/bodyConverterRegistry.test.js.map +0 -1
  60. package/dist/test/unit/converters/envelopeConverter.test.js +0 -313
  61. package/dist/test/unit/converters/envelopeConverter.test.js.map +0 -1
  62. package/dist/test/unit/index/memoryIndex.test.js +0 -214
  63. package/dist/test/unit/index/memoryIndex.test.js.map +0 -1
  64. package/dist/test/unit/ingest/antagonistCycleAndParity.test.js +0 -277
  65. package/dist/test/unit/ingest/antagonistCycleAndParity.test.js.map +0 -1
  66. package/dist/test/unit/ingest/cycleGuard.test.js +0 -81
  67. package/dist/test/unit/ingest/cycleGuard.test.js.map +0 -1
  68. package/dist/test/unit/ingest/orchestrator.test.js +0 -1055
  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 -841
  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 -938
  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/orchestrator.test.d.ts +0 -2
  149. package/lib/test/unit/ingest/orchestrator.test.d.ts.map +0 -1
  150. package/lib/test/unit/ingest/orchestrator.test.js +0 -1057
  151. package/lib/test/unit/ingest/orchestrator.test.js.map +0 -1
  152. package/lib/test/unit/observe/memoryObservationStore.test.d.ts +0 -2
  153. package/lib/test/unit/observe/memoryObservationStore.test.d.ts.map +0 -1
  154. package/lib/test/unit/observe/memoryObservationStore.test.js +0 -120
  155. package/lib/test/unit/observe/memoryObservationStore.test.js.map +0 -1
  156. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.d.ts +0 -2
  157. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.d.ts.map +0 -1
  158. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.js +0 -118
  159. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.js.map +0 -1
  160. package/lib/test/unit/retrieve/linkTraversalRetriever.test.d.ts +0 -2
  161. package/lib/test/unit/retrieve/linkTraversalRetriever.test.d.ts.map +0 -1
  162. package/lib/test/unit/retrieve/linkTraversalRetriever.test.js +0 -259
  163. package/lib/test/unit/retrieve/linkTraversalRetriever.test.js.map +0 -1
  164. package/lib/test/unit/retrieve/retrievers.test.d.ts +0 -2
  165. package/lib/test/unit/retrieve/retrievers.test.d.ts.map +0 -1
  166. package/lib/test/unit/retrieve/retrievers.test.js +0 -770
  167. package/lib/test/unit/retrieve/retrievers.test.js.map +0 -1
  168. package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts +0 -2
  169. package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts.map +0 -1
  170. package/lib/test/unit/retrieve/temporalRetrievers.test.js +0 -184
  171. package/lib/test/unit/retrieve/temporalRetrievers.test.js.map +0 -1
  172. package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts +0 -9
  173. package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts.map +0 -1
  174. package/lib/test/unit/store/antagonistTemporalBoundary.test.js +0 -122
  175. package/lib/test/unit/store/antagonistTemporalBoundary.test.js.map +0 -1
  176. package/lib/test/unit/store/embedOnWrite.test.d.ts +0 -2
  177. package/lib/test/unit/store/embedOnWrite.test.d.ts.map +0 -1
  178. package/lib/test/unit/store/embedOnWrite.test.js +0 -319
  179. package/lib/test/unit/store/embedOnWrite.test.js.map +0 -1
  180. package/lib/test/unit/store/fileTreeMemoryStore.test.d.ts +0 -2
  181. package/lib/test/unit/store/fileTreeMemoryStore.test.d.ts.map +0 -1
  182. package/lib/test/unit/store/fileTreeMemoryStore.test.js +0 -780
  183. package/lib/test/unit/store/fileTreeMemoryStore.test.js.map +0 -1
  184. package/lib/test/unit/store/fragmentEmbedOnWrite.test.d.ts +0 -2
  185. package/lib/test/unit/store/fragmentEmbedOnWrite.test.d.ts.map +0 -1
  186. package/lib/test/unit/store/fragmentEmbedOnWrite.test.js +0 -257
  187. package/lib/test/unit/store/fragmentEmbedOnWrite.test.js.map +0 -1
  188. package/lib/test/unit/store/indexInjection.test.d.ts +0 -2
  189. package/lib/test/unit/store/indexInjection.test.d.ts.map +0 -1
  190. package/lib/test/unit/store/indexInjection.test.js +0 -434
  191. package/lib/test/unit/store/indexInjection.test.js.map +0 -1
  192. package/lib/test/unit/store/lenientOpen.test.d.ts +0 -2
  193. package/lib/test/unit/store/lenientOpen.test.d.ts.map +0 -1
  194. package/lib/test/unit/store/lenientOpen.test.js +0 -250
  195. package/lib/test/unit/store/lenientOpen.test.js.map +0 -1
  196. package/lib/test/unit/store/listScoped.test.d.ts +0 -2
  197. package/lib/test/unit/store/listScoped.test.d.ts.map +0 -1
  198. package/lib/test/unit/store/listScoped.test.js +0 -111
  199. package/lib/test/unit/store/listScoped.test.js.map +0 -1
  200. package/lib/test/unit/store/observations.test.d.ts +0 -2
  201. package/lib/test/unit/store/observations.test.d.ts.map +0 -1
  202. package/lib/test/unit/store/observations.test.js +0 -241
  203. package/lib/test/unit/store/observations.test.js.map +0 -1
  204. package/lib/test/unit/store/rankAxis.test.d.ts +0 -2
  205. package/lib/test/unit/store/rankAxis.test.d.ts.map +0 -1
  206. package/lib/test/unit/store/rankAxis.test.js +0 -256
  207. package/lib/test/unit/store/rankAxis.test.js.map +0 -1
  208. package/lib/test/unit/store/scopeEncoding.test.d.ts +0 -2
  209. package/lib/test/unit/store/scopeEncoding.test.d.ts.map +0 -1
  210. package/lib/test/unit/store/scopeEncoding.test.js +0 -26
  211. package/lib/test/unit/store/scopeEncoding.test.js.map +0 -1
  212. package/lib/test/unit/store/temporalStore.test.d.ts +0 -2
  213. package/lib/test/unit/store/temporalStore.test.d.ts.map +0 -1
  214. package/lib/test/unit/store/temporalStore.test.js +0 -400
  215. package/lib/test/unit/store/temporalStore.test.js.map +0 -1
  216. package/lib/test/unit/tools/memoryTools.test.d.ts +0 -2
  217. package/lib/test/unit/tools/memoryTools.test.d.ts.map +0 -1
  218. package/lib/test/unit/tools/memoryTools.test.js +0 -843
  219. package/lib/test/unit/tools/memoryTools.test.js.map +0 -1
  220. package/lib/test/unit/types/identityCodec.test.d.ts +0 -2
  221. package/lib/test/unit/types/identityCodec.test.d.ts.map +0 -1
  222. package/lib/test/unit/types/identityCodec.test.js +0 -189
  223. package/lib/test/unit/types/identityCodec.test.js.map +0 -1
  224. package/lib/test/unit/types/ids.test.d.ts +0 -2
  225. package/lib/test/unit/types/ids.test.d.ts.map +0 -1
  226. package/lib/test/unit/types/ids.test.js +0 -86
  227. package/lib/test/unit/types/ids.test.js.map +0 -1
  228. package/lib/test/unit/types/temporalCodec.test.d.ts +0 -2
  229. package/lib/test/unit/types/temporalCodec.test.d.ts.map +0 -1
  230. package/lib/test/unit/types/temporalCodec.test.js +0 -205
  231. package/lib/test/unit/types/temporalCodec.test.js.map +0 -1
  232. package/lib/test/unit/types/temporalPolicy.test.d.ts +0 -2
  233. package/lib/test/unit/types/temporalPolicy.test.d.ts.map +0 -1
  234. package/lib/test/unit/types/temporalPolicy.test.js +0 -85
  235. package/lib/test/unit/types/temporalPolicy.test.js.map +0 -1
  236. package/lib/test/unit/types/writePolicy.test.d.ts +0 -2
  237. package/lib/test/unit/types/writePolicy.test.d.ts.map +0 -1
  238. package/lib/test/unit/types/writePolicy.test.js +0 -333
  239. package/lib/test/unit/types/writePolicy.test.js.map +0 -1
  240. package/lib/test/unit/vector/fragmentConverters.test.d.ts +0 -2
  241. package/lib/test/unit/vector/fragmentConverters.test.d.ts.map +0 -1
  242. package/lib/test/unit/vector/fragmentConverters.test.js +0 -60
  243. package/lib/test/unit/vector/fragmentConverters.test.js.map +0 -1
  244. package/lib/test/unit/vector/inMemoryCosineIndex.test.d.ts +0 -2
  245. package/lib/test/unit/vector/inMemoryCosineIndex.test.d.ts.map +0 -1
  246. package/lib/test/unit/vector/inMemoryCosineIndex.test.js +0 -254
  247. package/lib/test/unit/vector/inMemoryCosineIndex.test.js.map +0 -1
  248. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.d.ts +0 -2
  249. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.d.ts.map +0 -1
  250. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js +0 -364
  251. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +0 -1
  252. package/lib/test/unit/vector/vectorIndex.test.d.ts +0 -2
  253. package/lib/test/unit/vector/vectorIndex.test.d.ts.map +0 -1
  254. package/lib/test/unit/vector/vectorIndex.test.js +0 -53
  255. package/lib/test/unit/vector/vectorIndex.test.js.map +0 -1
  256. package/rush-logs/ts-agent-memory.build.cache.log +0 -3
  257. package/rush-logs/ts-agent-memory.build.log +0 -9
  258. package/src/index.ts +0 -14
  259. package/src/packlets/converters/bodyConverterRegistry.ts +0 -105
  260. package/src/packlets/converters/envelopeConverter.ts +0 -233
  261. package/src/packlets/converters/index.ts +0 -7
  262. package/src/packlets/index/index.ts +0 -6
  263. package/src/packlets/index/memoryIndex.ts +0 -332
  264. package/src/packlets/ingest/cycleGuard.ts +0 -153
  265. package/src/packlets/ingest/hostStages.ts +0 -111
  266. package/src/packlets/ingest/index.ts +0 -9
  267. package/src/packlets/ingest/model.ts +0 -195
  268. package/src/packlets/ingest/orchestrator.ts +0 -873
  269. package/src/packlets/observe/index.ts +0 -7
  270. package/src/packlets/observe/memoryObservationStore.ts +0 -153
  271. package/src/packlets/observe/observer.ts +0 -119
  272. package/src/packlets/retrieve/fragmentSemanticRetriever.ts +0 -138
  273. package/src/packlets/retrieve/hybridRetriever.ts +0 -194
  274. package/src/packlets/retrieve/index.ts +0 -14
  275. package/src/packlets/retrieve/linkTraversalRetriever.ts +0 -158
  276. package/src/packlets/retrieve/recencyRetriever.ts +0 -54
  277. package/src/packlets/retrieve/retriever.ts +0 -291
  278. package/src/packlets/retrieve/semanticRetriever.ts +0 -152
  279. package/src/packlets/retrieve/structuredFilterRetriever.ts +0 -58
  280. package/src/packlets/retrieve/tagRetriever.ts +0 -58
  281. package/src/packlets/retrieve/temporalRetrievers.ts +0 -210
  282. package/src/packlets/store/fileTreeMemoryStore.ts +0 -1834
  283. package/src/packlets/store/index.ts +0 -7
  284. package/src/packlets/store/scopeEncoding.ts +0 -36
  285. package/src/packlets/tools/index.ts +0 -6
  286. package/src/packlets/tools/memoryTools.ts +0 -706
  287. package/src/packlets/types/envelope.ts +0 -196
  288. package/src/packlets/types/filenameSafety.ts +0 -57
  289. package/src/packlets/types/identityCodec.ts +0 -447
  290. package/src/packlets/types/ids.ts +0 -124
  291. package/src/packlets/types/index.ts +0 -11
  292. package/src/packlets/types/temporal.ts +0 -96
  293. package/src/packlets/types/writePolicy.ts +0 -612
  294. package/src/packlets/vector/fragmentConverters.ts +0 -55
  295. package/src/packlets/vector/inMemoryCosineIndex.ts +0 -196
  296. package/src/packlets/vector/inMemoryFragmentCosineIndex.ts +0 -289
  297. package/src/packlets/vector/index.ts +0 -9
  298. package/src/packlets/vector/vectorIndex.ts +0 -273
  299. package/src/test/unit/converters/antagonistRoundTrip.test.ts +0 -110
  300. package/src/test/unit/converters/bodyConverterRegistry.test.ts +0 -89
  301. package/src/test/unit/converters/envelopeConverter.test.ts +0 -418
  302. package/src/test/unit/index/memoryIndex.test.ts +0 -272
  303. package/src/test/unit/ingest/antagonistCycleAndParity.test.ts +0 -367
  304. package/src/test/unit/ingest/cycleGuard.test.ts +0 -110
  305. package/src/test/unit/ingest/orchestrator.test.ts +0 -1351
  306. package/src/test/unit/observe/memoryObservationStore.test.ts +0 -158
  307. package/src/test/unit/retrieve/fragmentSemanticRetriever.test.ts +0 -163
  308. package/src/test/unit/retrieve/linkTraversalRetriever.test.ts +0 -329
  309. package/src/test/unit/retrieve/retrievers.test.ts +0 -1018
  310. package/src/test/unit/retrieve/temporalRetrievers.test.ts +0 -226
  311. package/src/test/unit/store/antagonistTemporalBoundary.test.ts +0 -158
  312. package/src/test/unit/store/embedOnWrite.test.ts +0 -418
  313. package/src/test/unit/store/fileTreeMemoryStore.test.ts +0 -1041
  314. package/src/test/unit/store/fragmentEmbedOnWrite.test.ts +0 -349
  315. package/src/test/unit/store/indexInjection.test.ts +0 -550
  316. package/src/test/unit/store/lenientOpen.test.ts +0 -292
  317. package/src/test/unit/store/listScoped.test.ts +0 -138
  318. package/src/test/unit/store/observations.test.ts +0 -290
  319. package/src/test/unit/store/rankAxis.test.ts +0 -349
  320. package/src/test/unit/store/scopeEncoding.test.ts +0 -37
  321. package/src/test/unit/store/temporalStore.test.ts +0 -469
  322. package/src/test/unit/tools/memoryTools.test.ts +0 -1120
  323. package/src/test/unit/types/identityCodec.test.ts +0 -266
  324. package/src/test/unit/types/ids.test.ts +0 -94
  325. package/src/test/unit/types/temporalCodec.test.ts +0 -259
  326. package/src/test/unit/types/temporalPolicy.test.ts +0 -124
  327. package/src/test/unit/types/writePolicy.test.ts +0 -446
  328. package/src/test/unit/vector/fragmentConverters.test.ts +0 -80
  329. package/src/test/unit/vector/inMemoryCosineIndex.test.ts +0 -318
  330. package/src/test/unit/vector/inMemoryFragmentCosineIndex.test.ts +0 -477
  331. package/src/test/unit/vector/vectorIndex.test.ts +0 -64
  332. package/temp/build/lint/_eslint-5eVG3S6w.json +0 -302
  333. package/temp/build/typescript/ts_8nwakTlr.json +0 -1
  334. package/temp/ts-agent-memory.api.json +0 -20933
  335. package/temp/ts-agent-memory.api.md +0 -938
  336. package/tsconfig.json +0 -8
@@ -1,257 +0,0 @@
1
- /*
2
- * Copyright (c) 2026 Erik Fortune
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import '@fgv/ts-utils-jest';
6
- import { LinkTraversalRetriever, LINK_TRAVERSAL_NO_SEED_MESSAGE, LINK_TRAVERSAL_UNWIRED_MESSAGE, MemoryIndex, envelopeConverter } from '../../../index';
7
- const DEFAULT_SCOPE = 'experience';
8
- /** A scope-qualified traversal seed (defaults to the fixture's default scope). */
9
- function seed(id, scope = DEFAULT_SCOPE) {
10
- return { scope: scope, id: id };
11
- }
12
- function makeEntry(spec) {
13
- var _a, _b, _c, _d, _e, _f;
14
- const scope = (_a = spec.scope) !== null && _a !== void 0 ? _a : DEFAULT_SCOPE;
15
- const record = {
16
- envelope: envelopeConverter
17
- .convert(Object.assign(Object.assign({ id: spec.id, entityId: spec.id, kind: (_b = spec.kind) !== null && _b !== void 0 ? _b : 'experience', tags: (_c = spec.tags) !== null && _c !== void 0 ? _c : [],
18
- // A bare link id defaults its target scope to the source record's own
19
- // scope (the same-conversation case); an object carries an explicit scope.
20
- links: ((_d = spec.links) !== null && _d !== void 0 ? _d : []).map((l) => typeof l === 'string'
21
- ? { type: 'rel', target: { scope, id: l } }
22
- : { type: 'rel', target: { scope: l.scope, id: l.id } }), created: 0, updated: (_e = spec.updated) !== null && _e !== void 0 ? _e : 0, seq: (_f = spec.seq) !== null && _f !== void 0 ? _f : 0, contentHash: 'h' }, (spec.rank !== undefined ? { rank: spec.rank } : {})), { provenance: { source: 'agent' } }))
23
- .orThrow(),
24
- body: `body-${spec.id}`
25
- };
26
- return { scope: scope, record };
27
- }
28
- function buildIndex(specs) {
29
- const index = MemoryIndex.create().orThrow();
30
- index.rebuild(specs.map(makeEntry)).orThrow();
31
- return index;
32
- }
33
- function ids(records) {
34
- return records.map((r) => r.envelope.id);
35
- }
36
- describe('LinkTraversalRetriever', () => {
37
- test('reports the link-traversal capability', () => {
38
- const index = buildIndex([]);
39
- const retriever = LinkTraversalRetriever.create(index).orThrow();
40
- expect(retriever.capabilities).toEqual({
41
- supportsSemanticRecall: false,
42
- supportsTemporalQuery: false,
43
- supportsLinkTraversal: true
44
- });
45
- });
46
- describe('outbound traversal (linkedFrom)', () => {
47
- test('returns the direct outbound neighbors at the default single hop', async () => {
48
- const index = buildIndex([
49
- { id: 'a', links: ['b', 'c'] },
50
- { id: 'b', updated: 20 },
51
- { id: 'c', updated: 10 }
52
- ]);
53
- const retriever = LinkTraversalRetriever.create(index).orThrow();
54
- expect(await retriever.retrieve({ linkedFrom: seed('a') })).toSucceedAndSatisfy((records) => {
55
- // Recency-ordered: b (updated 20) before c (updated 10). 'a' (the seed) excluded.
56
- expect(ids(records)).toEqual(['b', 'c']);
57
- });
58
- });
59
- test('stops at the default single hop (does not reach 2-hop neighbors)', async () => {
60
- const index = buildIndex([{ id: 'a', links: ['b'] }, { id: 'b', links: ['c'] }, { id: 'c' }]);
61
- const retriever = LinkTraversalRetriever.create(index).orThrow();
62
- expect(await retriever.retrieve({ linkedFrom: seed('a') })).toSucceedAndSatisfy((records) => {
63
- expect(ids(records)).toEqual(['b']);
64
- });
65
- });
66
- test('follows multiple hops when hops is raised', async () => {
67
- const index = buildIndex([{ id: 'a', links: ['b'] }, { id: 'b', links: ['c'] }, { id: 'c' }]);
68
- const retriever = LinkTraversalRetriever.create(index).orThrow();
69
- expect(await retriever.retrieve({ linkedFrom: seed('a'), hops: 2 })).toSucceedAndSatisfy((records) => {
70
- expect(ids(records).sort()).toEqual(['b', 'c']);
71
- });
72
- });
73
- });
74
- describe('orderBy axis', () => {
75
- function seedIndex() {
76
- // Seed 'a' links to three ranked neighbors. `rank` and `updated` are
77
- // deliberately INVERTED so the rank order (n3,n2,n1) is the exact reverse of
78
- // the recency order (n1,n2,n3) — proving orderBy actually re-sorts.
79
- return buildIndex([
80
- { id: 'a', links: ['n1', 'n3', 'n2'] },
81
- { id: 'n1', rank: 1, updated: 300, seq: 1 },
82
- { id: 'n3', rank: 3, updated: 100, seq: 3 },
83
- { id: 'n2', rank: 2, updated: 200, seq: 2 }
84
- ]);
85
- }
86
- test("orderBy 'rank' orders reached records by rank descending", async () => {
87
- const retriever = LinkTraversalRetriever.create(seedIndex()).orThrow();
88
- expect(await retriever.retrieve({ linkedFrom: seed('a'), orderBy: 'rank' })).toSucceedAndSatisfy((records) => {
89
- expect(ids(records)).toEqual(['n3', 'n2', 'n1']);
90
- });
91
- });
92
- test('orderBy absent is unchanged recency order', async () => {
93
- const retriever = LinkTraversalRetriever.create(seedIndex()).orThrow();
94
- expect(await retriever.retrieve({ linkedFrom: seed('a') })).toSucceedAndSatisfy((records) => {
95
- // Recency: most-recently-updated first → n1(300), n2(200), n3(100).
96
- expect(ids(records)).toEqual(['n1', 'n2', 'n3']);
97
- });
98
- });
99
- test("orderBy 'rank' composes with { limit, offset }", async () => {
100
- const retriever = LinkTraversalRetriever.create(seedIndex()).orThrow();
101
- expect(await retriever.retrieve({ linkedFrom: seed('a'), orderBy: 'rank', limit: 1, offset: 1 })).toSucceedAndSatisfy((records) => {
102
- expect(ids(records)).toEqual(['n2']);
103
- });
104
- });
105
- });
106
- describe('inbound traversal (linkedTo)', () => {
107
- test('returns the records whose edges point at the seed (backlinks)', async () => {
108
- const index = buildIndex([
109
- { id: 'a', links: ['target'], updated: 30 },
110
- { id: 'b', links: ['target'], updated: 10 },
111
- { id: 'target' }
112
- ]);
113
- const retriever = LinkTraversalRetriever.create(index).orThrow();
114
- expect(await retriever.retrieve({ linkedTo: seed('target') })).toSucceedAndSatisfy((records) => {
115
- expect(ids(records)).toEqual(['a', 'b']);
116
- });
117
- });
118
- test('reaches ONLY the same-scope inbound source when a TARGET stem is reused across scopes', async () => {
119
- // 'shared' exists in scope a and scope b; src-a@a links {a, shared} and
120
- // src-b@b links {b, shared}. Seeding linkedTo {a, shared} must reach ONLY
121
- // src-a — backlinks disambiguate on the target's (scope, id), not a bare id.
122
- const index = buildIndex([
123
- { id: 'src-a', scope: 'a', links: ['shared'], tags: ['src-a'] },
124
- { id: 'src-b', scope: 'b', links: ['shared'], tags: ['src-b'] },
125
- { id: 'shared', scope: 'a' },
126
- { id: 'shared', scope: 'b' }
127
- ]);
128
- const retriever = LinkTraversalRetriever.create(index).orThrow();
129
- expect(await retriever.retrieve({ linkedTo: seed('shared', 'a') })).toSucceedAndSatisfy((records) => {
130
- expect(records).toHaveLength(1);
131
- expect(records[0].envelope.tags).toEqual(['src-a']);
132
- });
133
- // Symmetric: seeding the b-scope target reaches only src-b.
134
- expect(await retriever.retrieve({ linkedTo: seed('shared', 'b') })).toSucceedAndSatisfy((records) => {
135
- expect(records).toHaveLength(1);
136
- expect(records[0].envelope.tags).toEqual(['src-b']);
137
- });
138
- });
139
- });
140
- describe('cycle safety', () => {
141
- test('terminates on a self-loop and excludes the seed', async () => {
142
- const index = buildIndex([{ id: 'a', links: ['a'] }]);
143
- const retriever = LinkTraversalRetriever.create(index).orThrow();
144
- expect(await retriever.retrieve({ linkedFrom: seed('a'), hops: 5 })).toSucceedAndSatisfy((records) => {
145
- expect(records).toHaveLength(0);
146
- });
147
- });
148
- test('terminates on a multi-hop cycle without revisiting', async () => {
149
- const index = buildIndex([
150
- { id: 'a', links: ['b'] },
151
- { id: 'b', links: ['c'] },
152
- { id: 'c', links: ['a'] }
153
- ]);
154
- const retriever = LinkTraversalRetriever.create(index).orThrow();
155
- expect(await retriever.retrieve({ linkedFrom: seed('a'), hops: 10 })).toSucceedAndSatisfy((records) => {
156
- // a→b→c→a: reaches b and c, then the edge back to the seed is pruned.
157
- expect(ids(records).sort()).toEqual(['b', 'c']);
158
- });
159
- });
160
- });
161
- test('traverses a cross-kind edge (experience derivedFrom a knowledge doc)', async () => {
162
- const index = buildIndex([
163
- {
164
- id: 'turn-5',
165
- scope: 'conversations/conv-1',
166
- kind: 'summarized-turn',
167
- links: [{ id: 'doc-1', scope: 'knowledge' }]
168
- },
169
- { id: 'doc-1', scope: 'knowledge', kind: 'knowledge' }
170
- ]);
171
- const retriever = LinkTraversalRetriever.create(index).orThrow();
172
- expect(await retriever.retrieve({ linkedFrom: seed('turn-5', 'conversations/conv-1') })).toSucceedAndSatisfy((records) => {
173
- expect(ids(records)).toEqual(['doc-1']);
174
- expect(records[0].envelope.kind).toBe('knowledge');
175
- });
176
- });
177
- describe('post-filtering and bounds', () => {
178
- test('applies the kind pre-filter to the reached records', async () => {
179
- const index = buildIndex([
180
- { id: 'a', links: ['b', 'c'] },
181
- { id: 'b', kind: 'keep' },
182
- { id: 'c', kind: 'drop' }
183
- ]);
184
- const retriever = LinkTraversalRetriever.create(index).orThrow();
185
- expect(await retriever.retrieve({ linkedFrom: seed('a'), kind: 'keep' })).toSucceedAndSatisfy((records) => {
186
- expect(ids(records)).toEqual(['b']);
187
- });
188
- });
189
- test('applies the limit after ordering', async () => {
190
- const index = buildIndex([
191
- { id: 'a', links: ['b', 'c', 'd'] },
192
- { id: 'b', updated: 30 },
193
- { id: 'c', updated: 20 },
194
- { id: 'd', updated: 10 }
195
- ]);
196
- const retriever = LinkTraversalRetriever.create(index).orThrow();
197
- expect(await retriever.retrieve({ linkedFrom: seed('a'), limit: 2 })).toSucceedAndSatisfy((records) => {
198
- expect(ids(records)).toEqual(['b', 'c']);
199
- });
200
- });
201
- test('returns empty when the seed is not in the index', async () => {
202
- const index = buildIndex([{ id: 'a', links: ['b'] }, { id: 'b' }]);
203
- const retriever = LinkTraversalRetriever.create(index).orThrow();
204
- expect(await retriever.retrieve({ linkedFrom: seed('missing') })).toSucceedWith([]);
205
- });
206
- test('reaches ONLY the same-scope target when an id is reused across scopes', async () => {
207
- // 'seed' (scope a) links a bare 'dup' → the edge target is {scope a, id dup}.
208
- // Two records share the stem 'dup' (scopes a and b); the scoped edge must
209
- // reach ONLY dup@a, never dup@b — the whole point of scope-qualified targets.
210
- const index = buildIndex([
211
- { id: 'seed', scope: 'a', links: ['dup'] },
212
- { id: 'dup', scope: 'a', tags: ['in-a'] },
213
- { id: 'dup', scope: 'b', tags: ['in-b'] }
214
- ]);
215
- const retriever = LinkTraversalRetriever.create(index).orThrow();
216
- expect(await retriever.retrieve({ linkedFrom: seed('seed', 'a') })).toSucceedAndSatisfy((records) => {
217
- expect(records).toHaveLength(1);
218
- expect(records[0].envelope.tags).toEqual(['in-a']);
219
- });
220
- });
221
- test('an explicit cross-scope edge reaches the other scope', async () => {
222
- // The same fixture, but the edge names dup@b explicitly → traversal follows
223
- // it to the b-scope record, proving explicit scope is honored verbatim.
224
- const index = buildIndex([
225
- { id: 'seed', scope: 'a', links: [{ id: 'dup', scope: 'b' }] },
226
- { id: 'dup', scope: 'a', tags: ['in-a'] },
227
- { id: 'dup', scope: 'b', tags: ['in-b'] }
228
- ]);
229
- const retriever = LinkTraversalRetriever.create(index).orThrow();
230
- expect(await retriever.retrieve({ linkedFrom: seed('seed', 'a') })).toSucceedAndSatisfy((records) => {
231
- expect(records).toHaveLength(1);
232
- expect(records[0].envelope.tags).toEqual(['in-b']);
233
- });
234
- });
235
- });
236
- describe('loud degradation', () => {
237
- test('fails when no seed (linkedFrom / linkedTo) is supplied', async () => {
238
- const index = buildIndex([{ id: 'a' }]);
239
- const retriever = LinkTraversalRetriever.create(index).orThrow();
240
- expect(await retriever.retrieve({ hops: 2 })).toFailWith(LINK_TRAVERSAL_NO_SEED_MESSAGE);
241
- });
242
- });
243
- });
244
- describe('LINK_TRAVERSAL_UNWIRED_MESSAGE constant', () => {
245
- test('has the stable public message non-link retrievers use to degrade loudly', () => {
246
- // The link-traversal retriever supports the axis, so it never emits this
247
- // message; the constant is the shared one the non-link v1 retrievers raise
248
- // (asserted here to keep the public string stable).
249
- expect(LINK_TRAVERSAL_UNWIRED_MESSAGE).toMatch(/link traversal requires a backlink index/i);
250
- });
251
- test('a link query against the link-capable retriever still succeeds', async () => {
252
- const index = buildIndex([{ id: 'a', links: ['b'] }, { id: 'b' }]);
253
- const retriever = LinkTraversalRetriever.create(index).orThrow();
254
- expect(await retriever.retrieve({ linkedFrom: seed('a') })).toSucceed();
255
- });
256
- });
257
- //# sourceMappingURL=linkTraversalRetriever.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"linkTraversalRetriever.test.js","sourceRoot":"","sources":["../../../../src/test/unit/retrieve/linkTraversalRetriever.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAKL,sBAAsB,EACtB,8BAA8B,EAC9B,8BAA8B,EAE9B,WAAW,EAEX,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAExB,MAAM,aAAa,GAAW,YAAY,CAAC;AAgB3C,kFAAkF;AAClF,SAAS,IAAI,CAAC,EAAU,EAAE,QAAgB,aAAa;IACrD,OAAO,EAAE,KAAK,EAAE,KAAuB,EAAE,EAAE,EAAE,EAAc,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,SAAS,CAAC,IAAgB;;IACjC,MAAM,KAAK,GAAW,MAAA,IAAI,CAAC,KAAK,mCAAI,aAAa,CAAC;IAClD,MAAM,MAAM,GAA2B;QACrC,QAAQ,EAAE,iBAAiB;aACxB,OAAO,+BACN,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,QAAQ,EAAE,IAAI,CAAC,EAAE,EACjB,IAAI,EAAE,MAAA,IAAI,CAAC,IAAI,mCAAI,YAAY,EAC/B,IAAI,EAAE,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE;YACrB,sEAAsE;YACtE,2EAA2E;YAC3E,KAAK,EAAE,CAAC,MAAA,IAAI,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAClC,OAAO,CAAC,KAAK,QAAQ;gBACnB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;gBAC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EAAyE,EAAE,GAAG,EAAE;QACnF,yEAAyE;QACzE,2EAA2E;QAC3E,oDAAoD;QACpD,MAAM,CAAC,8BAA8B,CAAC,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAChF,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QACnE,MAAM,SAAS,GAAG,sBAAsB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QACjE,MAAM,CAAC,MAAM,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n * SPDX-License-Identifier: MIT\n */\n\nimport '@fgv/ts-utils-jest';\nimport {\n IEdgeTarget,\n IIndexedMemoryRecord,\n IMemoryRecord,\n Kind,\n LinkTraversalRetriever,\n LINK_TRAVERSAL_NO_SEED_MESSAGE,\n LINK_TRAVERSAL_UNWIRED_MESSAGE,\n MemoryId,\n MemoryIndex,\n MemoryScopeKey,\n envelopeConverter\n} from '../../../index';\n\nconst DEFAULT_SCOPE: string = 'experience';\n\n/** A link target authored either as a bare id (same-scope) or an explicit `(scope, id)`. */\ntype LinkSpec = string | { readonly id: string; readonly scope: string };\n\ninterface IEntrySpec {\n readonly id: string;\n readonly scope?: string;\n readonly kind?: string;\n readonly tags?: ReadonlyArray<string>;\n readonly updated?: number;\n readonly seq?: number;\n readonly links?: ReadonlyArray<LinkSpec>;\n readonly rank?: number;\n}\n\n/** A scope-qualified traversal seed (defaults to the fixture's default scope). */\nfunction seed(id: string, scope: string = DEFAULT_SCOPE): IEdgeTarget {\n return { scope: scope as MemoryScopeKey, id: id as MemoryId };\n}\n\nfunction makeEntry(spec: IEntrySpec): IIndexedMemoryRecord {\n const scope: string = spec.scope ?? DEFAULT_SCOPE;\n const record: IMemoryRecord<unknown> = {\n envelope: envelopeConverter\n .convert({\n id: spec.id,\n entityId: spec.id,\n kind: spec.kind ?? 'experience',\n tags: spec.tags ?? [],\n // A bare link id defaults its target scope to the source record's own\n // scope (the same-conversation case); an object carries an explicit scope.\n links: (spec.links ?? []).map((l) =>\n typeof l === 'string'\n ? { type: 'rel', target: { scope, id: l } }\n : { type: 'rel', target: { scope: l.scope, id: l.id } }\n ),\n created: 0,\n updated: spec.updated ?? 0,\n seq: spec.seq ?? 0,\n contentHash: 'h',\n ...(spec.rank !== undefined ? { rank: spec.rank } : {}),\n provenance: { source: 'agent' }\n })\n .orThrow(),\n body: `body-${spec.id}`\n };\n return { scope: scope as MemoryScopeKey, record };\n}\n\nfunction buildIndex(specs: ReadonlyArray<IEntrySpec>): MemoryIndex {\n const index = MemoryIndex.create().orThrow();\n index.rebuild(specs.map(makeEntry)).orThrow();\n return index;\n}\n\nfunction ids(records: ReadonlyArray<IMemoryRecord<unknown>>): string[] {\n return records.map((r) => r.envelope.id as string);\n}\n\ndescribe('LinkTraversalRetriever', () => {\n test('reports the link-traversal capability', () => {\n const index = buildIndex([]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(retriever.capabilities).toEqual({\n supportsSemanticRecall: false,\n supportsTemporalQuery: false,\n supportsLinkTraversal: true\n });\n });\n\n describe('outbound traversal (linkedFrom)', () => {\n test('returns the direct outbound neighbors at the default single hop', async () => {\n const index = buildIndex([\n { id: 'a', links: ['b', 'c'] },\n { id: 'b', updated: 20 },\n { id: 'c', updated: 10 }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a') })).toSucceedAndSatisfy((records) => {\n // Recency-ordered: b (updated 20) before c (updated 10). 'a' (the seed) excluded.\n expect(ids(records)).toEqual(['b', 'c']);\n });\n });\n\n test('stops at the default single hop (does not reach 2-hop neighbors)', async () => {\n const index = buildIndex([{ id: 'a', links: ['b'] }, { id: 'b', links: ['c'] }, { id: 'c' }]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a') })).toSucceedAndSatisfy((records) => {\n expect(ids(records)).toEqual(['b']);\n });\n });\n\n test('follows multiple hops when hops is raised', async () => {\n const index = buildIndex([{ id: 'a', links: ['b'] }, { id: 'b', links: ['c'] }, { id: 'c' }]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a'), hops: 2 })).toSucceedAndSatisfy((records) => {\n expect(ids(records).sort()).toEqual(['b', 'c']);\n });\n });\n });\n\n describe('orderBy axis', () => {\n function seedIndex(): MemoryIndex {\n // Seed 'a' links to three ranked neighbors. `rank` and `updated` are\n // deliberately INVERTED so the rank order (n3,n2,n1) is the exact reverse of\n // the recency order (n1,n2,n3) — proving orderBy actually re-sorts.\n return buildIndex([\n { id: 'a', links: ['n1', 'n3', 'n2'] },\n { id: 'n1', rank: 1, updated: 300, seq: 1 },\n { id: 'n3', rank: 3, updated: 100, seq: 3 },\n { id: 'n2', rank: 2, updated: 200, seq: 2 }\n ]);\n }\n\n test(\"orderBy 'rank' orders reached records by rank descending\", async () => {\n const retriever = LinkTraversalRetriever.create(seedIndex()).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a'), orderBy: 'rank' })).toSucceedAndSatisfy(\n (records) => {\n expect(ids(records)).toEqual(['n3', 'n2', 'n1']);\n }\n );\n });\n\n test('orderBy absent is unchanged recency order', async () => {\n const retriever = LinkTraversalRetriever.create(seedIndex()).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a') })).toSucceedAndSatisfy((records) => {\n // Recency: most-recently-updated first → n1(300), n2(200), n3(100).\n expect(ids(records)).toEqual(['n1', 'n2', 'n3']);\n });\n });\n\n test(\"orderBy 'rank' composes with { limit, offset }\", async () => {\n const retriever = LinkTraversalRetriever.create(seedIndex()).orThrow();\n expect(\n await retriever.retrieve({ linkedFrom: seed('a'), orderBy: 'rank', limit: 1, offset: 1 })\n ).toSucceedAndSatisfy((records) => {\n expect(ids(records)).toEqual(['n2']);\n });\n });\n });\n\n describe('inbound traversal (linkedTo)', () => {\n test('returns the records whose edges point at the seed (backlinks)', async () => {\n const index = buildIndex([\n { id: 'a', links: ['target'], updated: 30 },\n { id: 'b', links: ['target'], updated: 10 },\n { id: 'target' }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedTo: seed('target') })).toSucceedAndSatisfy((records) => {\n expect(ids(records)).toEqual(['a', 'b']);\n });\n });\n\n test('reaches ONLY the same-scope inbound source when a TARGET stem is reused across scopes', async () => {\n // 'shared' exists in scope a and scope b; src-a@a links {a, shared} and\n // src-b@b links {b, shared}. Seeding linkedTo {a, shared} must reach ONLY\n // src-a — backlinks disambiguate on the target's (scope, id), not a bare id.\n const index = buildIndex([\n { id: 'src-a', scope: 'a', links: ['shared'], tags: ['src-a'] },\n { id: 'src-b', scope: 'b', links: ['shared'], tags: ['src-b'] },\n { id: 'shared', scope: 'a' },\n { id: 'shared', scope: 'b' }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedTo: seed('shared', 'a') })).toSucceedAndSatisfy((records) => {\n expect(records).toHaveLength(1);\n expect(records[0].envelope.tags).toEqual(['src-a']);\n });\n // Symmetric: seeding the b-scope target reaches only src-b.\n expect(await retriever.retrieve({ linkedTo: seed('shared', 'b') })).toSucceedAndSatisfy((records) => {\n expect(records).toHaveLength(1);\n expect(records[0].envelope.tags).toEqual(['src-b']);\n });\n });\n });\n\n describe('cycle safety', () => {\n test('terminates on a self-loop and excludes the seed', async () => {\n const index = buildIndex([{ id: 'a', links: ['a'] }]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a'), hops: 5 })).toSucceedAndSatisfy((records) => {\n expect(records).toHaveLength(0);\n });\n });\n\n test('terminates on a multi-hop cycle without revisiting', async () => {\n const index = buildIndex([\n { id: 'a', links: ['b'] },\n { id: 'b', links: ['c'] },\n { id: 'c', links: ['a'] }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a'), hops: 10 })).toSucceedAndSatisfy((records) => {\n // a→b→c→a: reaches b and c, then the edge back to the seed is pruned.\n expect(ids(records).sort()).toEqual(['b', 'c']);\n });\n });\n });\n\n test('traverses a cross-kind edge (experience derivedFrom a knowledge doc)', async () => {\n const index = buildIndex([\n {\n id: 'turn-5',\n scope: 'conversations/conv-1',\n kind: 'summarized-turn',\n links: [{ id: 'doc-1', scope: 'knowledge' }]\n },\n { id: 'doc-1', scope: 'knowledge', kind: 'knowledge' }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(\n await retriever.retrieve({ linkedFrom: seed('turn-5', 'conversations/conv-1') })\n ).toSucceedAndSatisfy((records) => {\n expect(ids(records)).toEqual(['doc-1']);\n expect(records[0].envelope.kind).toBe('knowledge');\n });\n });\n\n describe('post-filtering and bounds', () => {\n test('applies the kind pre-filter to the reached records', async () => {\n const index = buildIndex([\n { id: 'a', links: ['b', 'c'] },\n { id: 'b', kind: 'keep' },\n { id: 'c', kind: 'drop' }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(\n await retriever.retrieve({ linkedFrom: seed('a'), kind: 'keep' as unknown as Kind })\n ).toSucceedAndSatisfy((records) => {\n expect(ids(records)).toEqual(['b']);\n });\n });\n\n test('applies the limit after ordering', async () => {\n const index = buildIndex([\n { id: 'a', links: ['b', 'c', 'd'] },\n { id: 'b', updated: 30 },\n { id: 'c', updated: 20 },\n { id: 'd', updated: 10 }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a'), limit: 2 })).toSucceedAndSatisfy((records) => {\n expect(ids(records)).toEqual(['b', 'c']);\n });\n });\n\n test('returns empty when the seed is not in the index', async () => {\n const index = buildIndex([{ id: 'a', links: ['b'] }, { id: 'b' }]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('missing') })).toSucceedWith([]);\n });\n\n test('reaches ONLY the same-scope target when an id is reused across scopes', async () => {\n // 'seed' (scope a) links a bare 'dup' → the edge target is {scope a, id dup}.\n // Two records share the stem 'dup' (scopes a and b); the scoped edge must\n // reach ONLY dup@a, never dup@b — the whole point of scope-qualified targets.\n const index = buildIndex([\n { id: 'seed', scope: 'a', links: ['dup'] },\n { id: 'dup', scope: 'a', tags: ['in-a'] },\n { id: 'dup', scope: 'b', tags: ['in-b'] }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('seed', 'a') })).toSucceedAndSatisfy((records) => {\n expect(records).toHaveLength(1);\n expect(records[0].envelope.tags).toEqual(['in-a']);\n });\n });\n\n test('an explicit cross-scope edge reaches the other scope', async () => {\n // The same fixture, but the edge names dup@b explicitly → traversal follows\n // it to the b-scope record, proving explicit scope is honored verbatim.\n const index = buildIndex([\n { id: 'seed', scope: 'a', links: [{ id: 'dup', scope: 'b' }] },\n { id: 'dup', scope: 'a', tags: ['in-a'] },\n { id: 'dup', scope: 'b', tags: ['in-b'] }\n ]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('seed', 'a') })).toSucceedAndSatisfy((records) => {\n expect(records).toHaveLength(1);\n expect(records[0].envelope.tags).toEqual(['in-b']);\n });\n });\n });\n\n describe('loud degradation', () => {\n test('fails when no seed (linkedFrom / linkedTo) is supplied', async () => {\n const index = buildIndex([{ id: 'a' }]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ hops: 2 })).toFailWith(LINK_TRAVERSAL_NO_SEED_MESSAGE);\n });\n });\n});\n\ndescribe('LINK_TRAVERSAL_UNWIRED_MESSAGE constant', () => {\n test('has the stable public message non-link retrievers use to degrade loudly', () => {\n // The link-traversal retriever supports the axis, so it never emits this\n // message; the constant is the shared one the non-link v1 retrievers raise\n // (asserted here to keep the public string stable).\n expect(LINK_TRAVERSAL_UNWIRED_MESSAGE).toMatch(/link traversal requires a backlink index/i);\n });\n\n test('a link query against the link-capable retriever still succeeds', async () => {\n const index = buildIndex([{ id: 'a', links: ['b'] }, { id: 'b' }]);\n const retriever = LinkTraversalRetriever.create(index).orThrow();\n expect(await retriever.retrieve({ linkedFrom: seed('a') })).toSucceed();\n });\n});\n"]}