@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
@@ -1 +0,0 @@
1
- {"version":3,"file":"memoryIndex.test.d.ts","sourceRoot":"","sources":["../../../../src/test/unit/index/memoryIndex.test.ts"],"names":[],"mappings":"AAKA,OAAO,oBAAoB,CAAC"}
@@ -1,216 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2026 Erik Fortune
4
- * SPDX-License-Identifier: MIT
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- require("@fgv/ts-utils-jest");
8
- const index_1 = require("../../../index");
9
- /**
10
- * The scope every link target in this fixture lives under. Links are authored as
11
- * bare id strings and resolved to `{ scope: LINK_TARGET_SCOPE, id }`, so the
12
- * cross-scope source tests can share one target while their sources differ.
13
- */
14
- const LINK_TARGET_SCOPE = 'knowledge';
15
- /** A scope-qualified backlink-target query for the fixed link-target scope. */
16
- function bt(id) {
17
- return { scope: LINK_TARGET_SCOPE, id: id };
18
- }
19
- /** Extract the bare ids from a set of scope-qualified targets (backlink results). */
20
- function targetIds(targets) {
21
- return targets.map((t) => t.id);
22
- }
23
- function makeEntry(spec) {
24
- var _a, _b, _c, _d, _e, _f;
25
- const record = {
26
- envelope: index_1.envelopeConverter
27
- .convert(Object.assign(Object.assign({ id: spec.id, entityId: spec.id, kind: (_a = spec.kind) !== null && _a !== void 0 ? _a : 'knowledge', tags: (_b = spec.tags) !== null && _b !== void 0 ? _b : [], links: ((_c = spec.links) !== null && _c !== void 0 ? _c : []).map((target) => ({
28
- type: 'rel',
29
- target: { scope: LINK_TARGET_SCOPE, id: target }
30
- })), created: 0, updated: (_d = spec.updated) !== null && _d !== void 0 ? _d : 0, seq: (_e = spec.seq) !== null && _e !== void 0 ? _e : 0, contentHash: 'h' }, (spec.rank !== undefined ? { rank: spec.rank } : {})), { provenance: { source: 'agent' } }))
31
- .orThrow(),
32
- body: `body-${spec.id}`
33
- };
34
- return { scope: ((_f = spec.scope) !== null && _f !== void 0 ? _f : 'knowledge'), record };
35
- }
36
- function ids(records) {
37
- return records.map((r) => r.envelope.id);
38
- }
39
- describe('MemoryIndex', () => {
40
- let index;
41
- beforeEach(() => {
42
- index = index_1.MemoryIndex.create().orThrow();
43
- });
44
- describe('create', () => {
45
- test('starts empty', () => {
46
- expect(index.entries()).toHaveLength(0);
47
- expect(index.byKind('knowledge')).toHaveLength(0);
48
- expect(index.byTag('any')).toHaveLength(0);
49
- expect(index.byRecency()).toHaveLength(0);
50
- expect(index.backlinks(bt('none'))).toHaveLength(0);
51
- });
52
- });
53
- describe('rebuild', () => {
54
- test('indexes every entry and reports the count', () => {
55
- const entries = [
56
- makeEntry({ id: 'a', tags: ['x'], links: ['b'] }),
57
- makeEntry({ id: 'b', tags: ['x', 'y'] })
58
- ];
59
- expect(index.rebuild(entries)).toSucceedWith(2);
60
- expect(index.entries()).toHaveLength(2);
61
- expect([...ids(index.byKind('knowledge'))].sort()).toEqual(['a', 'b']);
62
- expect([...ids(index.byTag('x'))].sort()).toEqual(['a', 'b']);
63
- expect(ids(index.byTag('y'))).toEqual(['b']);
64
- expect(targetIds(index.backlinks(bt('b')))).toEqual(['a']);
65
- });
66
- test('clears prior state', () => {
67
- index.rebuild([makeEntry({ id: 'a', tags: ['x'] })]).orThrow();
68
- expect(index.rebuild([makeEntry({ id: 'c', tags: ['z'] })])).toSucceedWith(1);
69
- expect(ids(index.entries().map((e) => e.record))).toEqual(['c']);
70
- expect(index.byTag('x')).toHaveLength(0);
71
- });
72
- });
73
- describe('patch', () => {
74
- test('put inserts a new entry and returns it', () => {
75
- const entry = makeEntry({ id: 'a', tags: ['x'], links: ['b'] });
76
- expect(index.patch('put', entry)).toSucceedWith(entry);
77
- expect(ids(index.byKind('knowledge'))).toEqual(['a']);
78
- expect(targetIds(index.backlinks(bt('b')))).toEqual(['a']);
79
- });
80
- test('put on an existing key replaces stale associations', () => {
81
- index.patch('put', makeEntry({ id: 'a', kind: 'knowledge', tags: ['old'], links: ['b'] })).orThrow();
82
- index.patch('put', makeEntry({ id: 'a', kind: 'note', tags: ['new'], links: ['c'] })).orThrow();
83
- expect(index.entries()).toHaveLength(1);
84
- expect(index.byTag('old')).toHaveLength(0);
85
- expect(ids(index.byTag('new'))).toEqual(['a']);
86
- expect(index.byKind('knowledge')).toHaveLength(0);
87
- expect(ids(index.byKind('note'))).toEqual(['a']);
88
- expect(index.backlinks(bt('b'))).toHaveLength(0);
89
- expect(targetIds(index.backlinks(bt('c')))).toEqual(['a']);
90
- });
91
- test('delete removes the entry and its associations', () => {
92
- const entry = makeEntry({ id: 'a', tags: ['x'], links: ['b'] });
93
- index.patch('put', entry).orThrow();
94
- expect(index.patch('delete', entry)).toSucceedWith(entry);
95
- expect(index.entries()).toHaveLength(0);
96
- expect(index.byTag('x')).toHaveLength(0);
97
- expect(index.backlinks(bt('b'))).toHaveLength(0);
98
- });
99
- test('delete of an absent key is a no-op that still succeeds', () => {
100
- const entry = makeEntry({ id: 'ghost' });
101
- expect(index.patch('delete', entry)).toSucceedWith(entry);
102
- expect(index.entries()).toHaveLength(0);
103
- });
104
- test('distinguishes entries with the same id across scopes', () => {
105
- index.patch('put', makeEntry({ id: 'turn-0', scope: 'conversations/c1' })).orThrow();
106
- index.patch('put', makeEntry({ id: 'turn-0', scope: 'conversations/c2' })).orThrow();
107
- expect(index.entries()).toHaveLength(2);
108
- });
109
- });
110
- describe('byRecency', () => {
111
- test('orders most-recently-updated first, breaking ties by seq', () => {
112
- index
113
- .rebuild([
114
- makeEntry({ id: 'old', updated: 100, seq: 1 }),
115
- makeEntry({ id: 'newest', updated: 300, seq: 3 }),
116
- makeEntry({ id: 'tie-lo', updated: 200, seq: 4 }),
117
- makeEntry({ id: 'tie-hi', updated: 200, seq: 9 })
118
- ])
119
- .orThrow();
120
- expect(ids(index.byRecency())).toEqual(['newest', 'tie-hi', 'tie-lo', 'old']);
121
- });
122
- });
123
- describe('byRank', () => {
124
- test('orders by rank descending, absent-rank records last, recency tiebreak', () => {
125
- index
126
- .rebuild([
127
- makeEntry({ id: 'mid', rank: 5, updated: 100, seq: 1 }),
128
- makeEntry({ id: 'top', rank: 9, updated: 100, seq: 2 }),
129
- makeEntry({ id: 'tie-lo', rank: 3, updated: 200, seq: 4 }),
130
- makeEntry({ id: 'tie-hi', rank: 3, updated: 200, seq: 9 }),
131
- makeEntry({ id: 'unranked-old', updated: 100, seq: 5 }),
132
- makeEntry({ id: 'unranked-new', updated: 400, seq: 6 })
133
- ])
134
- .orThrow();
135
- // ranked (desc): top(9), mid(5), tie-hi(3,seq9), tie-lo(3,seq4);
136
- // then unranked by recency: unranked-new(updated400), unranked-old(updated100).
137
- expect(ids(index.byRank())).toEqual(['top', 'mid', 'tie-hi', 'tie-lo', 'unranked-new', 'unranked-old']);
138
- });
139
- test('is empty on an empty index', () => {
140
- expect(index.byRank()).toHaveLength(0);
141
- });
142
- test('sorts a ranked record ahead of an earlier-listed absent-rank record', () => {
143
- // Input lists the absent-rank record first so the sort compares (ranked, absent),
144
- // exercising the ranked-before-absent direction of the comparator.
145
- index
146
- .rebuild([
147
- makeEntry({ id: 'unranked', updated: 100, seq: 1 }),
148
- makeEntry({ id: 'ranked', rank: 5, updated: 100, seq: 2 })
149
- ])
150
- .orThrow();
151
- expect(ids(index.byRank())).toEqual(['ranked', 'unranked']);
152
- });
153
- test('orders two absent-rank records by recency alone', () => {
154
- index
155
- .rebuild([makeEntry({ id: 'a', updated: 100, seq: 1 }), makeEntry({ id: 'b', updated: 300, seq: 2 })])
156
- .orThrow();
157
- expect(ids(index.byRank())).toEqual(['b', 'a']);
158
- });
159
- test("index byRank agrees pairwise with the retrieve packlet's rankCompare", () => {
160
- // Guard against the two hand-duplicated comparators (index `_compareByRank`
161
- // and retrieve `rankCompare`) drifting: a future tie-break edit to one that
162
- // diverges from the other is caught here on a shared mixed fixture.
163
- const fixture = [
164
- makeEntry({ id: 'r-top', rank: 9, updated: 100, seq: 1 }),
165
- makeEntry({ id: 'r-mid', rank: 5, updated: 400, seq: 2 }),
166
- makeEntry({ id: 'r-tie-a', rank: 3, updated: 200, seq: 3 }),
167
- makeEntry({ id: 'r-tie-b', rank: 3, updated: 200, seq: 8 }),
168
- makeEntry({ id: 'absent-old', updated: 100, seq: 4 }),
169
- makeEntry({ id: 'absent-new', updated: 500, seq: 5 })
170
- ];
171
- index.rebuild(fixture).orThrow();
172
- const viaIndex = ids(index.byRank());
173
- const viaRankCompare = ids(fixture.map((e) => e.record).sort(index_1.rankCompare));
174
- expect(viaIndex).toEqual(viaRankCompare);
175
- // And the shared expected ordering is what both must produce.
176
- expect(viaIndex).toEqual(['r-top', 'r-mid', 'r-tie-b', 'r-tie-a', 'absent-new', 'absent-old']);
177
- });
178
- });
179
- describe('backlinks', () => {
180
- test('aggregates multiple sources pointing at one target', () => {
181
- index
182
- .rebuild([makeEntry({ id: 'a', links: ['target'] }), makeEntry({ id: 'b', links: ['target'] })])
183
- .orThrow();
184
- expect(targetIds(index.backlinks(bt('target'))).sort()).toEqual(['a', 'b']);
185
- });
186
- test('drops the target set once the last source is removed', () => {
187
- const a = makeEntry({ id: 'a', links: ['target'] });
188
- index.patch('put', a).orThrow();
189
- index.patch('delete', a).orThrow();
190
- expect(index.backlinks(bt('target'))).toHaveLength(0);
191
- });
192
- test('tracks same-id sources across scopes independently', () => {
193
- // Two distinct records that share the id 'a' under different scopes, both
194
- // linking 'target'. Removing one must NOT drop the other's inbound edge.
195
- const a1 = makeEntry({ id: 'a', scope: 'conversations/c1', links: ['target'] });
196
- const a2 = makeEntry({ id: 'a', scope: 'conversations/c2', links: ['target'] });
197
- index.patch('put', a1).orThrow();
198
- index.patch('put', a2).orThrow();
199
- expect(targetIds(index.backlinks(bt('target')))).toEqual(['a', 'a']);
200
- index.patch('delete', a1).orThrow();
201
- expect(targetIds(index.backlinks(bt('target')))).toEqual(['a']);
202
- });
203
- });
204
- describe('duplicate associations', () => {
205
- test('a record with duplicate tags and links is cleaned up exactly once on delete', () => {
206
- const entry = makeEntry({ id: 'a', tags: ['dup', 'dup'], links: ['t', 't'] });
207
- index.patch('put', entry).orThrow();
208
- expect(ids(index.byTag('dup'))).toEqual(['a']);
209
- expect(targetIds(index.backlinks(bt('t')))).toEqual(['a']);
210
- index.patch('delete', entry).orThrow();
211
- expect(index.byTag('dup')).toHaveLength(0);
212
- expect(index.backlinks(bt('t'))).toHaveLength(0);
213
- });
214
- });
215
- });
216
- //# sourceMappingURL=memoryIndex.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memoryIndex.test.js","sourceRoot":"","sources":["../../../../src/test/unit/index/memoryIndex.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,8BAA4B;AAC5B,0CAWwB;AAExB;;;;GAIG;AACH,MAAM,iBAAiB,GAAW,WAAW,CAAC;AAE9C,+EAA+E;AAC/E,SAAS,EAAE,CAAC,EAAU;IACpB,OAAO,EAAE,KAAK,EAAE,iBAAmC,EAAE,EAAE,EAAE,EAAc,EAAE,CAAC;AAC5E,CAAC;AAED,qFAAqF;AACrF,SAAS,SAAS,CAAC,OAAmC;IACpD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAY,CAAC,CAAC;AAC5C,CAAC;AAaD,SAAS,SAAS,CAAC,IAAiB;;IAClC,MAAM,MAAM,GAA2B;QACrC,QAAQ,EAAE,yBAAiB;aACxB,OAAO,+BACN,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,QAAQ,EAAE,IAAI,CAAC,EAAE,EACjB,IAAI,EAA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AAC,CAAC;IAEH,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,IAAI,CAAC,6EAA6E,EAAE,GAAG,EAAE;YACvF,MAAM,KAAK,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9E,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACtD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3D,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;YACvC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,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 MemoryId,\n MemoryIndex,\n MemoryScopeKey,\n Tag,\n envelopeConverter,\n rankCompare\n} from '../../../index';\n\n/**\n * The scope every link target in this fixture lives under. Links are authored as\n * bare id strings and resolved to `{ scope: LINK_TARGET_SCOPE, id }`, so the\n * cross-scope source tests can share one target while their sources differ.\n */\nconst LINK_TARGET_SCOPE: string = 'knowledge';\n\n/** A scope-qualified backlink-target query for the fixed link-target scope. */\nfunction bt(id: string): IEdgeTarget {\n return { scope: LINK_TARGET_SCOPE as MemoryScopeKey, id: id as MemoryId };\n}\n\n/** Extract the bare ids from a set of scope-qualified targets (backlink results). */\nfunction targetIds(targets: ReadonlyArray<IEdgeTarget>): string[] {\n return targets.map((t) => t.id as string);\n}\n\ninterface IRecordSpec {\n readonly id: string;\n readonly scope?: string;\n readonly kind?: string;\n readonly tags?: ReadonlyArray<string>;\n readonly links?: ReadonlyArray<string>;\n readonly updated?: number;\n readonly seq?: number;\n readonly rank?: number;\n}\n\nfunction makeEntry(spec: IRecordSpec): IIndexedMemoryRecord {\n const record: IMemoryRecord<unknown> = {\n envelope: envelopeConverter\n .convert({\n id: spec.id,\n entityId: spec.id,\n kind: spec.kind ?? 'knowledge',\n tags: spec.tags ?? [],\n links: (spec.links ?? []).map((target) => ({\n type: 'rel',\n target: { scope: LINK_TARGET_SCOPE, id: target }\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: (spec.scope ?? 'knowledge') as MemoryScopeKey, record };\n}\n\nfunction ids(records: ReadonlyArray<IMemoryRecord<unknown>>): ReadonlyArray<string> {\n return records.map((r) => r.envelope.id as string);\n}\n\ndescribe('MemoryIndex', () => {\n let index: MemoryIndex;\n\n beforeEach(() => {\n index = MemoryIndex.create().orThrow();\n });\n\n describe('create', () => {\n test('starts empty', () => {\n expect(index.entries()).toHaveLength(0);\n expect(index.byKind('knowledge' as Kind)).toHaveLength(0);\n expect(index.byTag('any' as Tag)).toHaveLength(0);\n expect(index.byRecency()).toHaveLength(0);\n expect(index.backlinks(bt('none'))).toHaveLength(0);\n });\n });\n\n describe('rebuild', () => {\n test('indexes every entry and reports the count', () => {\n const entries = [\n makeEntry({ id: 'a', tags: ['x'], links: ['b'] }),\n makeEntry({ id: 'b', tags: ['x', 'y'] })\n ];\n expect(index.rebuild(entries)).toSucceedWith(2);\n expect(index.entries()).toHaveLength(2);\n expect([...ids(index.byKind('knowledge' as Kind))].sort()).toEqual(['a', 'b']);\n expect([...ids(index.byTag('x' as Tag))].sort()).toEqual(['a', 'b']);\n expect(ids(index.byTag('y' as Tag))).toEqual(['b']);\n expect(targetIds(index.backlinks(bt('b')))).toEqual(['a']);\n });\n\n test('clears prior state', () => {\n index.rebuild([makeEntry({ id: 'a', tags: ['x'] })]).orThrow();\n expect(index.rebuild([makeEntry({ id: 'c', tags: ['z'] })])).toSucceedWith(1);\n expect(ids(index.entries().map((e) => e.record))).toEqual(['c']);\n expect(index.byTag('x' as Tag)).toHaveLength(0);\n });\n });\n\n describe('patch', () => {\n test('put inserts a new entry and returns it', () => {\n const entry = makeEntry({ id: 'a', tags: ['x'], links: ['b'] });\n expect(index.patch('put', entry)).toSucceedWith(entry);\n expect(ids(index.byKind('knowledge' as Kind))).toEqual(['a']);\n expect(targetIds(index.backlinks(bt('b')))).toEqual(['a']);\n });\n\n test('put on an existing key replaces stale associations', () => {\n index.patch('put', makeEntry({ id: 'a', kind: 'knowledge', tags: ['old'], links: ['b'] })).orThrow();\n index.patch('put', makeEntry({ id: 'a', kind: 'note', tags: ['new'], links: ['c'] })).orThrow();\n expect(index.entries()).toHaveLength(1);\n expect(index.byTag('old' as Tag)).toHaveLength(0);\n expect(ids(index.byTag('new' as Tag))).toEqual(['a']);\n expect(index.byKind('knowledge' as Kind)).toHaveLength(0);\n expect(ids(index.byKind('note' as Kind))).toEqual(['a']);\n expect(index.backlinks(bt('b'))).toHaveLength(0);\n expect(targetIds(index.backlinks(bt('c')))).toEqual(['a']);\n });\n\n test('delete removes the entry and its associations', () => {\n const entry = makeEntry({ id: 'a', tags: ['x'], links: ['b'] });\n index.patch('put', entry).orThrow();\n expect(index.patch('delete', entry)).toSucceedWith(entry);\n expect(index.entries()).toHaveLength(0);\n expect(index.byTag('x' as Tag)).toHaveLength(0);\n expect(index.backlinks(bt('b'))).toHaveLength(0);\n });\n\n test('delete of an absent key is a no-op that still succeeds', () => {\n const entry = makeEntry({ id: 'ghost' });\n expect(index.patch('delete', entry)).toSucceedWith(entry);\n expect(index.entries()).toHaveLength(0);\n });\n\n test('distinguishes entries with the same id across scopes', () => {\n index.patch('put', makeEntry({ id: 'turn-0', scope: 'conversations/c1' })).orThrow();\n index.patch('put', makeEntry({ id: 'turn-0', scope: 'conversations/c2' })).orThrow();\n expect(index.entries()).toHaveLength(2);\n });\n });\n\n describe('byRecency', () => {\n test('orders most-recently-updated first, breaking ties by seq', () => {\n index\n .rebuild([\n makeEntry({ id: 'old', updated: 100, seq: 1 }),\n makeEntry({ id: 'newest', updated: 300, seq: 3 }),\n makeEntry({ id: 'tie-lo', updated: 200, seq: 4 }),\n makeEntry({ id: 'tie-hi', updated: 200, seq: 9 })\n ])\n .orThrow();\n expect(ids(index.byRecency())).toEqual(['newest', 'tie-hi', 'tie-lo', 'old']);\n });\n });\n\n describe('byRank', () => {\n test('orders by rank descending, absent-rank records last, recency tiebreak', () => {\n index\n .rebuild([\n makeEntry({ id: 'mid', rank: 5, updated: 100, seq: 1 }),\n makeEntry({ id: 'top', rank: 9, updated: 100, seq: 2 }),\n makeEntry({ id: 'tie-lo', rank: 3, updated: 200, seq: 4 }),\n makeEntry({ id: 'tie-hi', rank: 3, updated: 200, seq: 9 }),\n makeEntry({ id: 'unranked-old', updated: 100, seq: 5 }),\n makeEntry({ id: 'unranked-new', updated: 400, seq: 6 })\n ])\n .orThrow();\n // ranked (desc): top(9), mid(5), tie-hi(3,seq9), tie-lo(3,seq4);\n // then unranked by recency: unranked-new(updated400), unranked-old(updated100).\n expect(ids(index.byRank())).toEqual(['top', 'mid', 'tie-hi', 'tie-lo', 'unranked-new', 'unranked-old']);\n });\n\n test('is empty on an empty index', () => {\n expect(index.byRank()).toHaveLength(0);\n });\n\n test('sorts a ranked record ahead of an earlier-listed absent-rank record', () => {\n // Input lists the absent-rank record first so the sort compares (ranked, absent),\n // exercising the ranked-before-absent direction of the comparator.\n index\n .rebuild([\n makeEntry({ id: 'unranked', updated: 100, seq: 1 }),\n makeEntry({ id: 'ranked', rank: 5, updated: 100, seq: 2 })\n ])\n .orThrow();\n expect(ids(index.byRank())).toEqual(['ranked', 'unranked']);\n });\n\n test('orders two absent-rank records by recency alone', () => {\n index\n .rebuild([makeEntry({ id: 'a', updated: 100, seq: 1 }), makeEntry({ id: 'b', updated: 300, seq: 2 })])\n .orThrow();\n expect(ids(index.byRank())).toEqual(['b', 'a']);\n });\n\n test(\"index byRank agrees pairwise with the retrieve packlet's rankCompare\", () => {\n // Guard against the two hand-duplicated comparators (index `_compareByRank`\n // and retrieve `rankCompare`) drifting: a future tie-break edit to one that\n // diverges from the other is caught here on a shared mixed fixture.\n const fixture = [\n makeEntry({ id: 'r-top', rank: 9, updated: 100, seq: 1 }),\n makeEntry({ id: 'r-mid', rank: 5, updated: 400, seq: 2 }),\n makeEntry({ id: 'r-tie-a', rank: 3, updated: 200, seq: 3 }),\n makeEntry({ id: 'r-tie-b', rank: 3, updated: 200, seq: 8 }),\n makeEntry({ id: 'absent-old', updated: 100, seq: 4 }),\n makeEntry({ id: 'absent-new', updated: 500, seq: 5 })\n ];\n index.rebuild(fixture).orThrow();\n const viaIndex = ids(index.byRank());\n const viaRankCompare = ids(fixture.map((e) => e.record).sort(rankCompare));\n expect(viaIndex).toEqual(viaRankCompare);\n // And the shared expected ordering is what both must produce.\n expect(viaIndex).toEqual(['r-top', 'r-mid', 'r-tie-b', 'r-tie-a', 'absent-new', 'absent-old']);\n });\n });\n\n describe('backlinks', () => {\n test('aggregates multiple sources pointing at one target', () => {\n index\n .rebuild([makeEntry({ id: 'a', links: ['target'] }), makeEntry({ id: 'b', links: ['target'] })])\n .orThrow();\n expect(targetIds(index.backlinks(bt('target'))).sort()).toEqual(['a', 'b']);\n });\n\n test('drops the target set once the last source is removed', () => {\n const a = makeEntry({ id: 'a', links: ['target'] });\n index.patch('put', a).orThrow();\n index.patch('delete', a).orThrow();\n expect(index.backlinks(bt('target'))).toHaveLength(0);\n });\n\n test('tracks same-id sources across scopes independently', () => {\n // Two distinct records that share the id 'a' under different scopes, both\n // linking 'target'. Removing one must NOT drop the other's inbound edge.\n const a1 = makeEntry({ id: 'a', scope: 'conversations/c1', links: ['target'] });\n const a2 = makeEntry({ id: 'a', scope: 'conversations/c2', links: ['target'] });\n index.patch('put', a1).orThrow();\n index.patch('put', a2).orThrow();\n expect(targetIds(index.backlinks(bt('target')))).toEqual(['a', 'a']);\n index.patch('delete', a1).orThrow();\n expect(targetIds(index.backlinks(bt('target')))).toEqual(['a']);\n });\n });\n\n describe('duplicate associations', () => {\n test('a record with duplicate tags and links is cleaned up exactly once on delete', () => {\n const entry = makeEntry({ id: 'a', tags: ['dup', 'dup'], links: ['t', 't'] });\n index.patch('put', entry).orThrow();\n expect(ids(index.byTag('dup' as Tag))).toEqual(['a']);\n expect(targetIds(index.backlinks(bt('t')))).toEqual(['a']);\n index.patch('delete', entry).orThrow();\n expect(index.byTag('dup' as Tag)).toHaveLength(0);\n expect(index.backlinks(bt('t'))).toHaveLength(0);\n });\n });\n});\n"]}
@@ -1,9 +0,0 @@
1
- /**
2
- * Antagonist torture tests — cycle guard adversarial graphs (target class 6) and
3
- * enum-branch parity (target class 7), exercised at the ORCHESTRATOR/integration
4
- * level over a real {@link FileTreeMemoryStore}, complementing the pure-function
5
- * unit tests in `cycleGuard.test.ts` and the per-verdict tests in
6
- * `orchestrator.test.ts`.
7
- */
8
- import '@fgv/ts-utils-jest';
9
- //# sourceMappingURL=antagonistCycleAndParity.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"antagonistCycleAndParity.test.d.ts","sourceRoot":"","sources":["../../../../src/test/unit/ingest/antagonistCycleAndParity.test.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH,OAAO,oBAAoB,CAAC"}
@@ -1,279 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2026 Erik Fortune
4
- * SPDX-License-Identifier: MIT
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- /**
8
- * Antagonist torture tests — cycle guard adversarial graphs (target class 6) and
9
- * enum-branch parity (target class 7), exercised at the ORCHESTRATOR/integration
10
- * level over a real {@link FileTreeMemoryStore}, complementing the pure-function
11
- * unit tests in `cycleGuard.test.ts` and the per-verdict tests in
12
- * `orchestrator.test.ts`.
13
- */
14
- require("@fgv/ts-utils-jest");
15
- const ts_utils_1 = require("@fgv/ts-utils");
16
- const ts_json_base_1 = require("@fgv/ts-json-base");
17
- const index_1 = require("../../../index");
18
- const noteKind = 'note';
19
- /** A scope-qualified target for the note fixtures (all under the knowledge scope). */
20
- function kt(id) {
21
- return { scope: 'knowledge', id: id };
22
- }
23
- function mutableRoot() {
24
- const tree = ts_json_base_1.FileTree.inMemory([], { mutable: true }).orThrow();
25
- const root = tree.getDirectory('/').orThrow();
26
- if (!ts_json_base_1.FileTree.isMutableDirectoryItem(root)) {
27
- throw new Error('expected a mutable root directory');
28
- }
29
- return root;
30
- }
31
- function registry() {
32
- const reg = index_1.BodyConverterRegistry.create().orThrow();
33
- reg.register(noteKind, ts_utils_1.Converters.string);
34
- return reg;
35
- }
36
- const codecs = new Map([
37
- [noteKind, new index_1.KnowledgeIdentityCodec()]
38
- ]);
39
- function buildStore() {
40
- return index_1.FileTreeMemoryStore.create({ root: mutableRoot(), registry: registry(), codecs }).orThrow();
41
- }
42
- async function putFull(store, entityId, body, links = []) {
43
- const rec = {
44
- envelope: {
45
- id: entityId,
46
- entityId: entityId,
47
- kind: noteKind,
48
- tags: [],
49
- links,
50
- created: 0,
51
- updated: 0,
52
- seq: 0,
53
- contentHash: '',
54
- provenance: { source: 'agent' }
55
- },
56
- body
57
- };
58
- (await store.put(rec)).orThrow();
59
- }
60
- function classifier(fn) {
61
- return { classify: (item) => Promise.resolve(fn(item)) };
62
- }
63
- function extractor(fn) {
64
- return { extract: (item, c) => Promise.resolve(fn(item, c)) };
65
- }
66
- function relater(fn) {
67
- return { relate: (ctx) => Promise.resolve(fn(ctx)) };
68
- }
69
- function resolver(fn) {
70
- return { resolve: (candidate, similar) => Promise.resolve(fn(candidate, similar)) };
71
- }
72
- const classifyNote = classifier(() => (0, ts_utils_1.succeed)({ kind: noteKind }));
73
- function candidate(entityId, body, links = []) {
74
- return {
75
- envelope: {
76
- entityId: entityId,
77
- kind: noteKind,
78
- tags: [],
79
- links,
80
- provenance: { source: 'agent' }
81
- },
82
- body
83
- };
84
- }
85
- function candEdge(source, type, target) {
86
- return { source: kt(source), edge: { type: type, target: kt(target) } };
87
- }
88
- function buildOrchestrator(params) {
89
- return index_1.MemoryIngestOrchestrator.create({
90
- store: params.store,
91
- registry: registry(),
92
- codecs,
93
- classifier: classifyNote,
94
- extractor: params.extractor,
95
- relationExtractor: params.relationExtractor,
96
- entityResolver: params.entityResolver
97
- }).orThrow();
98
- }
99
- describe('antagonist — cycle guard through EXISTING store edges (integration)', () => {
100
- // Wrong impl this catches: an orchestrator that only feeds the cycle guard the
101
- // proposed-edge batch (as its own pure-function unit tests do) and forgets to
102
- // fold in the store snapshot's existing edges, so a cycle that closes THROUGH
103
- // an already-persisted edge is silently admitted.
104
- test('a proposed edge that closes a cycle through a pre-existing on-disk edge is rejected', async () => {
105
- const store = buildStore();
106
- // Existing on-disk edge: doc-a -> doc-b (persisted before this ingest runs).
107
- await putFull(store, 'doc-a', 'anchor-a', [{ type: 'rel', target: kt('doc-b') }]);
108
- await putFull(store, 'doc-b', 'anchor-b');
109
- // This ingest re-writes doc-b (a 'new'-verdict same-id update, since no
110
- // resolver is wired) and proposes doc-b -> doc-a, which — unioned with the
111
- // EXISTING doc-a -> doc-b edge — closes a 2-cycle that exists ONLY because of
112
- // the on-disk edge, not anything proposed in this batch.
113
- const orch = buildOrchestrator({
114
- store,
115
- extractor: extractor(() => (0, ts_utils_1.succeed)([candidate('doc-b', 'anchor-b-v2')])),
116
- relationExtractor: relater(() => (0, ts_utils_1.succeed)([candEdge('doc-b', 'rel', 'doc-a')]))
117
- });
118
- expect(await orch.ingestItem({ id: 'i', content: 'x' })).toFailWith(/would create a cycle/);
119
- // Confirm the guard fired BEFORE any write — doc-b's content must be unchanged.
120
- expect(await store.get(noteKind, 'doc-b')).toSucceedAndSatisfy((rec) => expect(rec === null || rec === void 0 ? void 0 : rec.body).toBe('anchor-b'));
121
- });
122
- test('a long existing chain plus one proposed edge closing the loop is rejected', async () => {
123
- const store = buildStore();
124
- // Existing chain: a -> b -> c -> d (four pre-existing on-disk edges spanning
125
- // three hops), persisted before this ingest.
126
- await putFull(store, 'chain-a', 'a', [{ type: 'rel', target: kt('chain-b') }]);
127
- await putFull(store, 'chain-b', 'b', [{ type: 'rel', target: kt('chain-c') }]);
128
- await putFull(store, 'chain-c', 'c', [{ type: 'rel', target: kt('chain-d') }]);
129
- await putFull(store, 'chain-d', 'd');
130
- // Proposed: chain-d -> chain-a, closing the whole loop through the existing chain.
131
- const orch = buildOrchestrator({
132
- store,
133
- extractor: extractor(() => (0, ts_utils_1.succeed)([candidate('chain-d', 'd-v2')])),
134
- relationExtractor: relater(() => (0, ts_utils_1.succeed)([candEdge('chain-d', 'rel', 'chain-a')]))
135
- });
136
- expect(await orch.ingestItem({ id: 'i', content: 'x' })).toFailWith(/would create a cycle/);
137
- });
138
- test('cycleGuard "off" admits a cycle that closes through an existing edge', async () => {
139
- const store = buildStore();
140
- await putFull(store, 'doc-a', 'anchor-a', [{ type: 'rel', target: kt('doc-b') }]);
141
- await putFull(store, 'doc-b', 'anchor-b');
142
- const orch = index_1.MemoryIngestOrchestrator.create({
143
- store,
144
- registry: registry(),
145
- codecs,
146
- classifier: classifyNote,
147
- extractor: extractor(() => (0, ts_utils_1.succeed)([candidate('doc-b', 'anchor-b-v2')])),
148
- relationExtractor: relater(() => (0, ts_utils_1.succeed)([candEdge('doc-b', 'rel', 'doc-a')])),
149
- cycleGuard: 'off'
150
- }).orThrow();
151
- expect(await orch.ingestItem({ id: 'i', content: 'x' })).toSucceedAndSatisfy((r) => {
152
- var _a;
153
- expect((_a = r.records[0].record) === null || _a === void 0 ? void 0 : _a.envelope.links).toEqual([{ type: 'rel', target: kt('doc-a') }]);
154
- });
155
- });
156
- });
157
- describe('antagonist — resolver target need not be a surfaced `similar` candidate (structural-only gate)', () => {
158
- // Documents (and locks in) the actual contract: fgv validates a target-bearing
159
- // verdict STRUCTURALLY (exists in the store + matching kind), uniformly across
160
- // all three target-bearing verdicts, regardless of whether the resolver's
161
- // choice was among the `similar` candidates it was shown. Wrong impl this
162
- // guards against: fgv silently restricting itself to `similar` membership
163
- // (which would incorrectly reject a host resolver with external knowledge), OR
164
- // fgv skipping the structural check for one of the three verdicts.
165
- test.each(['duplicate-of', 'supersede', 'merge-into'])("verdict '%s' targeting a valid existing record OUTSIDE the surfaced similar set is accepted", async (verdict) => {
166
- const store = buildStore();
167
- await putFull(store, 'doc-a', 'apple pie'); // will be surfaced as `similar`
168
- await putFull(store, 'doc-q', 'unrelated target'); // exists, but never surfaced
169
- const vectorIndex = index_1.InMemoryCosineIndex.create().orThrow();
170
- const embed = () => Promise.resolve((0, ts_utils_1.succeed)(Float32Array.from([1, 0, 0])));
171
- // Only doc-a is embedded/indexed; doc-q is never surfaced by similarity —
172
- // it can only be reached by the resolver's own out-of-band choice.
173
- (await vectorIndex.add(kt('doc-a'), Float32Array.from([1, 0, 0]))).orThrow();
174
- const orch = index_1.MemoryIngestOrchestrator.create({
175
- store,
176
- registry: registry(),
177
- codecs,
178
- classifier: classifyNote,
179
- extractor: extractor(() => (0, ts_utils_1.succeed)([candidate('doc-b', 'apple tart')])),
180
- relationExtractor: relater(() => (0, ts_utils_1.succeed)([])),
181
- vectorIndex,
182
- embed,
183
- entityResolver: resolver(() => (0, ts_utils_1.succeed)({ verdict, target: kt('doc-q') }))
184
- }).orThrow();
185
- const result = await orch.ingestItem({ id: 'i', content: 'x' });
186
- if (verdict === 'duplicate-of') {
187
- expect(result).toSucceedAndSatisfy((r) => {
188
- expect(r.records[0].disposition).toBe('deduped');
189
- expect(r.records[0].id).toBe('doc-q');
190
- });
191
- }
192
- else if (verdict === 'supersede') {
193
- expect(result).toSucceedAndSatisfy((r) => {
194
- expect(r.records[0].disposition).toBe('written');
195
- expect(r.records[0].resolution).toEqual({ verdict: 'supersede', target: kt('doc-q') });
196
- });
197
- }
198
- else {
199
- expect(result).toSucceedAndSatisfy((r) => {
200
- expect(r.records[0].disposition).toBe('merged');
201
- expect(r.records[0].id).toBe('doc-q');
202
- });
203
- }
204
- });
205
- });
206
- describe('antagonist — enum-branch parity: uniform structural rejection across target-bearing verdicts', () => {
207
- // A single table-driven test locking in that EVERY target-bearing verdict arm
208
- // shares the SAME two structural checks (existence, then kind match) in the
209
- // SAME order — the exact class of hole ("only merge-into checked") that a
210
- // prior review caught. Wrong impl this guards against: a future edit that adds
211
- // a fourth verdict or refactors validation per-branch and re-introduces an
212
- // asymmetric gap.
213
- const verdicts = ['duplicate-of', 'supersede', 'merge-into'];
214
- test.each(verdicts)("verdict '%s' rejects a nonexistent target with the SAME message shape", async (verdict) => {
215
- const store = buildStore();
216
- await putFull(store, 'doc-a', 'apple pie');
217
- const vectorIndex = index_1.InMemoryCosineIndex.create().orThrow();
218
- const embed = () => Promise.resolve((0, ts_utils_1.succeed)(Float32Array.from([1, 0, 0])));
219
- const orch = index_1.MemoryIngestOrchestrator.create({
220
- store,
221
- registry: registry(),
222
- codecs,
223
- classifier: classifyNote,
224
- extractor: extractor(() => (0, ts_utils_1.succeed)([candidate('doc-b', 'apple tart')])),
225
- relationExtractor: relater(() => (0, ts_utils_1.succeed)([])),
226
- vectorIndex,
227
- embed,
228
- entityResolver: resolver(() => (0, ts_utils_1.succeed)({ verdict, target: kt('ghost') }))
229
- }).orThrow();
230
- (await vectorIndex.add(kt('doc-a'), Float32Array.from([1, 0, 0]))).orThrow();
231
- expect(await orch.ingestItem({ id: 'i', content: 'x' })).toFailWith(`ingest 'i': ${verdict} target 'knowledge/ghost' does not exist in the store`);
232
- });
233
- test.each(verdicts)("verdict '%s' rejects a foreign-kind target with the SAME message shape", async (verdict) => {
234
- const otherKind = 'other';
235
- const reg = registry();
236
- reg.register(otherKind, ts_utils_1.Converters.string);
237
- const otherCodecs = new Map([
238
- ...codecs,
239
- [otherKind, new index_1.KnowledgeIdentityCodec()]
240
- ]);
241
- const store = index_1.FileTreeMemoryStore.create({
242
- root: mutableRoot(),
243
- registry: reg,
244
- codecs: otherCodecs
245
- }).orThrow();
246
- const foreignRec = {
247
- envelope: {
248
- id: 'foreign-1',
249
- entityId: 'foreign-1',
250
- kind: otherKind,
251
- tags: [],
252
- links: [],
253
- created: 0,
254
- updated: 0,
255
- seq: 0,
256
- contentHash: '',
257
- provenance: { source: 'agent' }
258
- },
259
- body: 'apple pie'
260
- };
261
- (await store.put(foreignRec)).orThrow();
262
- const vectorIndex = index_1.InMemoryCosineIndex.create().orThrow();
263
- const embed = () => Promise.resolve((0, ts_utils_1.succeed)(Float32Array.from([1, 0, 0])));
264
- const orch = index_1.MemoryIngestOrchestrator.create({
265
- store,
266
- registry: reg,
267
- codecs: otherCodecs,
268
- classifier: classifyNote,
269
- extractor: extractor(() => (0, ts_utils_1.succeed)([candidate('doc-b', 'apple tart')])),
270
- relationExtractor: relater(() => (0, ts_utils_1.succeed)([])),
271
- vectorIndex,
272
- embed,
273
- entityResolver: resolver(() => (0, ts_utils_1.succeed)({ verdict, target: kt('foreign-1') }))
274
- }).orThrow();
275
- (await vectorIndex.add(kt('foreign-1'), Float32Array.from([1, 0, 0]))).orThrow();
276
- expect(await orch.ingestItem({ id: 'i', content: 'x' })).toFailWith(`ingest 'i': ${verdict} target 'knowledge/foreign-1' is kind 'other' but the candidate is kind 'note'`);
277
- });
278
- });
279
- //# sourceMappingURL=antagonistCycleAndParity.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"antagonistCycleAndParity.test.js","sourceRoot":"","sources":["../../../../src/test/unit/ingest/antagonistCycleAndParity.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH;;;;;;GAMG;AAEH,8BAA4B;AAC5B,4CAA4D;AAC5D,oDAA6C;AAC7C,0CA4BwB;AAExB,MAAM,QAAQ,GAAS,MAAc,CAAC;AAEtC,sFAAsF;AACtF,SAAS,EAAE,CAAC,EAAU;IACpB,OAAO,EAAE,KAAK,EAAE,WAA6B,EAAE,EAAE,EAAE,EAAc,EAAE,CAAC;AACtE,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,IAAI,GAAG,uBAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IAChE,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9C,IAAI,CAAC,uBAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ;IACf,MAAM,GAAG,GAAG,6BAAqB,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACrD,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,qBAAU,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,MAAM,GAAsC,IAAI,GAAG,CAAuB;IAC9E,CAAC,QAAQ,EAAE,IAAI,8BAAsB,EAAE,CAAC;CACzC,CAAC,CAAC;AAEH,SAAS,UAAU;IACjB,OAAO,2BAAmB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,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C,CAAC,OAAO,EAAE,CAAC;QACjF,MAAM,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,UAAU,CACjE,eAAe,OAAO,gFAAgF,CACvG,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n * SPDX-License-Identifier: MIT\n */\n\n/**\n * Antagonist torture tests — cycle guard adversarial graphs (target class 6) and\n * enum-branch parity (target class 7), exercised at the ORCHESTRATOR/integration\n * level over a real {@link FileTreeMemoryStore}, complementing the pure-function\n * unit tests in `cycleGuard.test.ts` and the per-verdict tests in\n * `orchestrator.test.ts`.\n */\n\nimport '@fgv/ts-utils-jest';\nimport { Converters, Result, succeed } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport {\n BodyConverterRegistry,\n EntityId,\n FileTreeMemoryStore,\n IBodyConverterRegistry,\n ICandidateEdge,\n ICandidateRecord,\n IEdgeTarget,\n IEntityResolutionCandidate,\n IEntityResolver,\n IFactExtractor,\n IIdentityCodec,\n IIngestItem,\n IIngestItemResult,\n IMemoryClassification,\n IMemoryClassifier,\n IMemoryEnvelope,\n IMemoryRecord,\n IRelationContext,\n IRelationExtractor,\n InMemoryCosineIndex,\n Kind,\n KnowledgeIdentityCodec,\n MemoryId,\n MemoryIngestOrchestrator,\n MemoryScopeKey,\n ResolutionVerdict,\n Tag\n} from '../../../index';\n\nconst noteKind: Kind = 'note' as Kind;\n\n/** A scope-qualified target for the note fixtures (all under the knowledge scope). */\nfunction kt(id: string): IEdgeTarget {\n return { scope: 'knowledge' as MemoryScopeKey, id: id as MemoryId };\n}\n\nfunction mutableRoot(): FileTree.IMutableFileTreeDirectoryItem {\n const tree = FileTree.inMemory([], { mutable: true }).orThrow();\n const root = tree.getDirectory('/').orThrow();\n if (!FileTree.isMutableDirectoryItem(root)) {\n throw new Error('expected a mutable root directory');\n }\n return root;\n}\n\nfunction registry(): IBodyConverterRegistry {\n const reg = BodyConverterRegistry.create().orThrow();\n reg.register(noteKind, Converters.string);\n return reg;\n}\n\nconst codecs: ReadonlyMap<Kind, IIdentityCodec> = new Map<Kind, IIdentityCodec>([\n [noteKind, new KnowledgeIdentityCodec()]\n]);\n\nfunction buildStore(): FileTreeMemoryStore {\n return FileTreeMemoryStore.create({ root: mutableRoot(), registry: registry(), codecs }).orThrow();\n}\n\nasync function putFull(\n store: FileTreeMemoryStore,\n entityId: string,\n body: string,\n links: IMemoryEnvelope['links'] = []\n): Promise<void> {\n const rec: IMemoryRecord<unknown> = {\n envelope: {\n id: entityId as MemoryId,\n entityId: entityId as EntityId,\n kind: noteKind,\n tags: [],\n links,\n created: 0,\n updated: 0,\n seq: 0,\n contentHash: '',\n provenance: { source: 'agent' }\n },\n body\n };\n (await store.put(rec)).orThrow();\n}\n\nfunction classifier(fn: (item: IIngestItem) => Result<IMemoryClassification>): IMemoryClassifier {\n return { classify: (item) => Promise.resolve(fn(item)) };\n}\nfunction extractor(\n fn: (item: IIngestItem, c: IMemoryClassification) => Result<ReadonlyArray<ICandidateRecord>>\n): IFactExtractor {\n return { extract: (item, c) => Promise.resolve(fn(item, c)) };\n}\nfunction relater(fn: (ctx: IRelationContext) => Result<ReadonlyArray<ICandidateEdge>>): IRelationExtractor {\n return { relate: (ctx) => Promise.resolve(fn(ctx)) };\n}\nfunction resolver(\n fn: (\n candidate: ICandidateRecord,\n similar: ReadonlyArray<IEntityResolutionCandidate>\n ) => Result<ResolutionVerdict>\n): IEntityResolver {\n return { resolve: (candidate, similar) => Promise.resolve(fn(candidate, similar)) };\n}\n\nconst classifyNote: IMemoryClassifier = classifier(() => succeed({ kind: noteKind }));\n\nfunction candidate(\n entityId: string,\n body: unknown,\n links: ICandidateRecord['envelope']['links'] = []\n): ICandidateRecord {\n return {\n envelope: {\n entityId: entityId as EntityId,\n kind: noteKind,\n tags: [],\n links,\n provenance: { source: 'agent' }\n },\n body\n };\n}\n\nfunction candEdge(source: string, type: string, target: string): ICandidateEdge {\n return { source: kt(source), edge: { type: type as never, target: kt(target) } };\n}\n\nfunction buildOrchestrator(params: {\n store: FileTreeMemoryStore;\n extractor: IFactExtractor;\n relationExtractor: IRelationExtractor;\n entityResolver?: IEntityResolver;\n}): MemoryIngestOrchestrator {\n return MemoryIngestOrchestrator.create({\n store: params.store,\n registry: registry(),\n codecs,\n classifier: classifyNote,\n extractor: params.extractor,\n relationExtractor: params.relationExtractor,\n entityResolver: params.entityResolver\n }).orThrow();\n}\n\ndescribe('antagonist — cycle guard through EXISTING store edges (integration)', () => {\n // Wrong impl this catches: an orchestrator that only feeds the cycle guard the\n // proposed-edge batch (as its own pure-function unit tests do) and forgets to\n // fold in the store snapshot's existing edges, so a cycle that closes THROUGH\n // an already-persisted edge is silently admitted.\n test('a proposed edge that closes a cycle through a pre-existing on-disk edge is rejected', async () => {\n const store = buildStore();\n // Existing on-disk edge: doc-a -> doc-b (persisted before this ingest runs).\n await putFull(store, 'doc-a', 'anchor-a', [{ type: 'rel' as never, target: kt('doc-b') }]);\n await putFull(store, 'doc-b', 'anchor-b');\n\n // This ingest re-writes doc-b (a 'new'-verdict same-id update, since no\n // resolver is wired) and proposes doc-b -> doc-a, which — unioned with the\n // EXISTING doc-a -> doc-b edge — closes a 2-cycle that exists ONLY because of\n // the on-disk edge, not anything proposed in this batch.\n const orch = buildOrchestrator({\n store,\n extractor: extractor(() => succeed([candidate('doc-b', 'anchor-b-v2')])),\n relationExtractor: relater(() => succeed([candEdge('doc-b', 'rel', 'doc-a')]))\n });\n expect(await orch.ingestItem({ id: 'i', content: 'x' })).toFailWith(/would create a cycle/);\n\n // Confirm the guard fired BEFORE any write — doc-b's content must be unchanged.\n expect(await store.get(noteKind, 'doc-b' as EntityId)).toSucceedAndSatisfy(\n (rec: IMemoryRecord<unknown> | undefined) => expect(rec?.body).toBe('anchor-b')\n );\n });\n\n test('a long existing chain plus one proposed edge closing the loop is rejected', async () => {\n const store = buildStore();\n // Existing chain: a -> b -> c -> d (four pre-existing on-disk edges spanning\n // three hops), persisted before this ingest.\n await putFull(store, 'chain-a', 'a', [{ type: 'rel' as never, target: kt('chain-b') }]);\n await putFull(store, 'chain-b', 'b', [{ type: 'rel' as never, target: kt('chain-c') }]);\n await putFull(store, 'chain-c', 'c', [{ type: 'rel' as never, target: kt('chain-d') }]);\n await putFull(store, 'chain-d', 'd');\n\n // Proposed: chain-d -> chain-a, closing the whole loop through the existing chain.\n const orch = buildOrchestrator({\n store,\n extractor: extractor(() => succeed([candidate('chain-d', 'd-v2')])),\n relationExtractor: relater(() => succeed([candEdge('chain-d', 'rel', 'chain-a')]))\n });\n expect(await orch.ingestItem({ id: 'i', content: 'x' })).toFailWith(/would create a cycle/);\n });\n\n test('cycleGuard \"off\" admits a cycle that closes through an existing edge', async () => {\n const store = buildStore();\n await putFull(store, 'doc-a', 'anchor-a', [{ type: 'rel' as never, target: kt('doc-b') }]);\n await putFull(store, 'doc-b', 'anchor-b');\n const orch = MemoryIngestOrchestrator.create({\n store,\n registry: registry(),\n codecs,\n classifier: classifyNote,\n extractor: extractor(() => succeed([candidate('doc-b', 'anchor-b-v2')])),\n relationExtractor: relater(() => succeed([candEdge('doc-b', 'rel', 'doc-a')])),\n cycleGuard: 'off'\n }).orThrow();\n expect(await orch.ingestItem({ id: 'i', content: 'x' })).toSucceedAndSatisfy((r: IIngestItemResult) => {\n expect(r.records[0].record?.envelope.links).toEqual([{ type: 'rel', target: kt('doc-a') }]);\n });\n });\n});\n\ndescribe('antagonist — resolver target need not be a surfaced `similar` candidate (structural-only gate)', () => {\n // Documents (and locks in) the actual contract: fgv validates a target-bearing\n // verdict STRUCTURALLY (exists in the store + matching kind), uniformly across\n // all three target-bearing verdicts, regardless of whether the resolver's\n // choice was among the `similar` candidates it was shown. Wrong impl this\n // guards against: fgv silently restricting itself to `similar` membership\n // (which would incorrectly reject a host resolver with external knowledge), OR\n // fgv skipping the structural check for one of the three verdicts.\n test.each(['duplicate-of', 'supersede', 'merge-into'] as const)(\n \"verdict '%s' targeting a valid existing record OUTSIDE the surfaced similar set is accepted\",\n async (verdict) => {\n const store = buildStore();\n await putFull(store, 'doc-a', 'apple pie'); // will be surfaced as `similar`\n await putFull(store, 'doc-q', 'unrelated target'); // exists, but never surfaced\n\n const vectorIndex = InMemoryCosineIndex.create().orThrow();\n const embed = (): Promise<Result<Float32Array>> =>\n Promise.resolve(succeed(Float32Array.from([1, 0, 0])));\n // Only doc-a is embedded/indexed; doc-q is never surfaced by similarity —\n // it can only be reached by the resolver's own out-of-band choice.\n (await vectorIndex.add(kt('doc-a'), Float32Array.from([1, 0, 0]))).orThrow();\n\n const orch = MemoryIngestOrchestrator.create({\n store,\n registry: registry(),\n codecs,\n classifier: classifyNote,\n extractor: extractor(() => succeed([candidate('doc-b', 'apple tart')])),\n relationExtractor: relater(() => succeed([])),\n vectorIndex,\n embed,\n entityResolver: resolver(() => succeed({ verdict, target: kt('doc-q') } as ResolutionVerdict))\n }).orThrow();\n\n const result = await orch.ingestItem({ id: 'i', content: 'x' });\n if (verdict === 'duplicate-of') {\n expect(result).toSucceedAndSatisfy((r: IIngestItemResult) => {\n expect(r.records[0].disposition).toBe('deduped');\n expect(r.records[0].id).toBe('doc-q');\n });\n } else if (verdict === 'supersede') {\n expect(result).toSucceedAndSatisfy((r: IIngestItemResult) => {\n expect(r.records[0].disposition).toBe('written');\n expect(r.records[0].resolution).toEqual({ verdict: 'supersede', target: kt('doc-q') });\n });\n } else {\n expect(result).toSucceedAndSatisfy((r: IIngestItemResult) => {\n expect(r.records[0].disposition).toBe('merged');\n expect(r.records[0].id).toBe('doc-q');\n });\n }\n }\n );\n});\n\ndescribe('antagonist — enum-branch parity: uniform structural rejection across target-bearing verdicts', () => {\n // A single table-driven test locking in that EVERY target-bearing verdict arm\n // shares the SAME two structural checks (existence, then kind match) in the\n // SAME order — the exact class of hole (\"only merge-into checked\") that a\n // prior review caught. Wrong impl this guards against: a future edit that adds\n // a fourth verdict or refactors validation per-branch and re-introduces an\n // asymmetric gap.\n const verdicts = ['duplicate-of', 'supersede', 'merge-into'] as const;\n\n test.each(verdicts)(\n \"verdict '%s' rejects a nonexistent target with the SAME message shape\",\n async (verdict) => {\n const store = buildStore();\n await putFull(store, 'doc-a', 'apple pie');\n const vectorIndex = InMemoryCosineIndex.create().orThrow();\n const embed = (): Promise<Result<Float32Array>> =>\n Promise.resolve(succeed(Float32Array.from([1, 0, 0])));\n const orch = MemoryIngestOrchestrator.create({\n store,\n registry: registry(),\n codecs,\n classifier: classifyNote,\n extractor: extractor(() => succeed([candidate('doc-b', 'apple tart')])),\n relationExtractor: relater(() => succeed([])),\n vectorIndex,\n embed,\n entityResolver: resolver(() => succeed({ verdict, target: kt('ghost') } as ResolutionVerdict))\n }).orThrow();\n (await vectorIndex.add(kt('doc-a'), Float32Array.from([1, 0, 0]))).orThrow();\n expect(await orch.ingestItem({ id: 'i', content: 'x' })).toFailWith(\n `ingest 'i': ${verdict} target 'knowledge/ghost' does not exist in the store`\n );\n }\n );\n\n test.each(verdicts)(\n \"verdict '%s' rejects a foreign-kind target with the SAME message shape\",\n async (verdict) => {\n const otherKind: Kind = 'other' as Kind;\n const reg = registry();\n reg.register(otherKind, Converters.string);\n const otherCodecs: ReadonlyMap<Kind, IIdentityCodec> = new Map<Kind, IIdentityCodec>([\n ...codecs,\n [otherKind, new KnowledgeIdentityCodec()]\n ]);\n const store = FileTreeMemoryStore.create({\n root: mutableRoot(),\n registry: reg,\n codecs: otherCodecs\n }).orThrow();\n const foreignRec: IMemoryRecord<unknown> = {\n envelope: {\n id: 'foreign-1' as MemoryId,\n entityId: 'foreign-1' as EntityId,\n kind: otherKind,\n tags: [] as ReadonlyArray<Tag>,\n links: [],\n created: 0,\n updated: 0,\n seq: 0,\n contentHash: '',\n provenance: { source: 'agent' }\n },\n body: 'apple pie'\n };\n (await store.put(foreignRec)).orThrow();\n const vectorIndex = InMemoryCosineIndex.create().orThrow();\n const embed = (): Promise<Result<Float32Array>> =>\n Promise.resolve(succeed(Float32Array.from([1, 0, 0])));\n const orch = MemoryIngestOrchestrator.create({\n store,\n registry: reg,\n codecs: otherCodecs,\n classifier: classifyNote,\n extractor: extractor(() => succeed([candidate('doc-b', 'apple tart')])),\n relationExtractor: relater(() => succeed([])),\n vectorIndex,\n embed,\n entityResolver: resolver(() => succeed({ verdict, target: kt('foreign-1') } as ResolutionVerdict))\n }).orThrow();\n (await vectorIndex.add(kt('foreign-1'), Float32Array.from([1, 0, 0]))).orThrow();\n expect(await orch.ingestItem({ id: 'i', content: 'x' })).toFailWith(\n `ingest 'i': ${verdict} target 'knowledge/foreign-1' is kind 'other' but the candidate is kind 'note'`\n );\n }\n );\n});\n"]}
@@ -1,2 +0,0 @@
1
- import '@fgv/ts-utils-jest';
2
- //# sourceMappingURL=cycleGuard.test.d.ts.map