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

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 (376) 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/retrieve/linkTraversalRetriever.js +1 -1
  7. package/dist/packlets/retrieve/linkTraversalRetriever.js.map +1 -1
  8. package/dist/packlets/retrieve/recencyRetriever.js +1 -1
  9. package/dist/packlets/retrieve/recencyRetriever.js.map +1 -1
  10. package/dist/packlets/retrieve/retriever.js +11 -5
  11. package/dist/packlets/retrieve/retriever.js.map +1 -1
  12. package/dist/packlets/retrieve/structuredFilterRetriever.js +27 -5
  13. package/dist/packlets/retrieve/structuredFilterRetriever.js.map +1 -1
  14. package/dist/packlets/retrieve/tagRetriever.js +1 -1
  15. package/dist/packlets/retrieve/tagRetriever.js.map +1 -1
  16. package/dist/packlets/retrieve/temporalRetrievers.js +1 -1
  17. package/dist/packlets/retrieve/temporalRetrievers.js.map +1 -1
  18. package/dist/packlets/store/fileTreeMemoryStore.js +152 -132
  19. package/dist/packlets/store/fileTreeMemoryStore.js.map +1 -1
  20. package/dist/packlets/store/vectorMaintenance.js +251 -0
  21. package/dist/packlets/store/vectorMaintenance.js.map +1 -0
  22. package/dist/packlets/types/envelope.js.map +1 -1
  23. package/dist/packlets/vector/inMemoryCosineIndex.js +81 -18
  24. package/dist/packlets/vector/inMemoryCosineIndex.js.map +1 -1
  25. package/dist/packlets/vector/inMemoryFragmentCosineIndex.js +7 -0
  26. package/dist/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
  27. package/dist/packlets/vector/vectorIndex.js.map +1 -1
  28. package/dist/ts-agent-memory.d.ts +431 -79
  29. package/lib/packlets/ingest/orchestrator.d.ts.map +1 -1
  30. package/lib/packlets/ingest/orchestrator.js +11 -1
  31. package/lib/packlets/ingest/orchestrator.js.map +1 -1
  32. package/lib/packlets/observe/memoryObservationStore.d.ts.map +1 -1
  33. package/lib/packlets/observe/memoryObservationStore.js +6 -0
  34. package/lib/packlets/observe/memoryObservationStore.js.map +1 -1
  35. package/lib/packlets/observe/observer.d.ts +61 -0
  36. package/lib/packlets/observe/observer.d.ts.map +1 -1
  37. package/lib/packlets/observe/observer.js.map +1 -1
  38. package/lib/packlets/retrieve/linkTraversalRetriever.d.ts +1 -1
  39. package/lib/packlets/retrieve/linkTraversalRetriever.js +1 -1
  40. package/lib/packlets/retrieve/linkTraversalRetriever.js.map +1 -1
  41. package/lib/packlets/retrieve/recencyRetriever.d.ts +1 -1
  42. package/lib/packlets/retrieve/recencyRetriever.js +1 -1
  43. package/lib/packlets/retrieve/recencyRetriever.js.map +1 -1
  44. package/lib/packlets/retrieve/retriever.d.ts +26 -7
  45. package/lib/packlets/retrieve/retriever.d.ts.map +1 -1
  46. package/lib/packlets/retrieve/retriever.js +11 -5
  47. package/lib/packlets/retrieve/retriever.js.map +1 -1
  48. package/lib/packlets/retrieve/structuredFilterRetriever.d.ts +26 -4
  49. package/lib/packlets/retrieve/structuredFilterRetriever.d.ts.map +1 -1
  50. package/lib/packlets/retrieve/structuredFilterRetriever.js +27 -5
  51. package/lib/packlets/retrieve/structuredFilterRetriever.js.map +1 -1
  52. package/lib/packlets/retrieve/tagRetriever.d.ts +1 -1
  53. package/lib/packlets/retrieve/tagRetriever.js +1 -1
  54. package/lib/packlets/retrieve/tagRetriever.js.map +1 -1
  55. package/lib/packlets/retrieve/temporalRetrievers.js +1 -1
  56. package/lib/packlets/retrieve/temporalRetrievers.js.map +1 -1
  57. package/lib/packlets/store/fileTreeMemoryStore.d.ts +135 -59
  58. package/lib/packlets/store/fileTreeMemoryStore.d.ts.map +1 -1
  59. package/lib/packlets/store/fileTreeMemoryStore.js +151 -131
  60. package/lib/packlets/store/fileTreeMemoryStore.js.map +1 -1
  61. package/lib/packlets/store/vectorMaintenance.d.ts +149 -0
  62. package/lib/packlets/store/vectorMaintenance.d.ts.map +1 -0
  63. package/lib/packlets/store/vectorMaintenance.js +255 -0
  64. package/lib/packlets/store/vectorMaintenance.js.map +1 -0
  65. package/lib/packlets/types/envelope.d.ts +11 -0
  66. package/lib/packlets/types/envelope.d.ts.map +1 -1
  67. package/lib/packlets/types/envelope.js.map +1 -1
  68. package/lib/packlets/vector/inMemoryCosineIndex.d.ts +30 -7
  69. package/lib/packlets/vector/inMemoryCosineIndex.d.ts.map +1 -1
  70. package/lib/packlets/vector/inMemoryCosineIndex.js +80 -17
  71. package/lib/packlets/vector/inMemoryCosineIndex.js.map +1 -1
  72. package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts +7 -0
  73. package/lib/packlets/vector/inMemoryFragmentCosineIndex.d.ts.map +1 -1
  74. package/lib/packlets/vector/inMemoryFragmentCosineIndex.js +7 -0
  75. package/lib/packlets/vector/inMemoryFragmentCosineIndex.js.map +1 -1
  76. package/lib/packlets/vector/vectorIndex.d.ts +129 -1
  77. package/lib/packlets/vector/vectorIndex.d.ts.map +1 -1
  78. package/lib/packlets/vector/vectorIndex.js.map +1 -1
  79. package/package.json +17 -7
  80. package/.rush/temp/5667e36f1c0cc503a5c20a3ebff76e7b9a702d41.tar.log +0 -468
  81. package/.rush/temp/chunked-rush-logs/ts-agent-memory.build.chunks.jsonl +0 -9
  82. package/.rush/temp/operation/build/all.log +0 -9
  83. package/.rush/temp/operation/build/log-chunks.jsonl +0 -9
  84. package/.rush/temp/operation/build/state.json +0 -3
  85. package/.rush/temp/shrinkwrap-deps.json +0 -689
  86. package/config/api-extractor.json +0 -343
  87. package/config/jest.config.json +0 -14
  88. package/config/rig.json +0 -4
  89. package/dist/test/unit/converters/antagonistRoundTrip.test.js +0 -95
  90. package/dist/test/unit/converters/antagonistRoundTrip.test.js.map +0 -1
  91. package/dist/test/unit/converters/bodyConverterRegistry.test.js +0 -72
  92. package/dist/test/unit/converters/bodyConverterRegistry.test.js.map +0 -1
  93. package/dist/test/unit/converters/envelopeConverter.test.js +0 -313
  94. package/dist/test/unit/converters/envelopeConverter.test.js.map +0 -1
  95. package/dist/test/unit/index/memoryIndex.test.js +0 -214
  96. package/dist/test/unit/index/memoryIndex.test.js.map +0 -1
  97. package/dist/test/unit/ingest/antagonistCycleAndParity.test.js +0 -277
  98. package/dist/test/unit/ingest/antagonistCycleAndParity.test.js.map +0 -1
  99. package/dist/test/unit/ingest/cycleGuard.test.js +0 -81
  100. package/dist/test/unit/ingest/cycleGuard.test.js.map +0 -1
  101. package/dist/test/unit/ingest/dedupScope.test.js +0 -434
  102. package/dist/test/unit/ingest/dedupScope.test.js.map +0 -1
  103. package/dist/test/unit/ingest/orchestrator.test.js +0 -1058
  104. package/dist/test/unit/ingest/orchestrator.test.js.map +0 -1
  105. package/dist/test/unit/observe/memoryObservationStore.test.js +0 -118
  106. package/dist/test/unit/observe/memoryObservationStore.test.js.map +0 -1
  107. package/dist/test/unit/retrieve/fragmentSemanticRetriever.test.js +0 -116
  108. package/dist/test/unit/retrieve/fragmentSemanticRetriever.test.js.map +0 -1
  109. package/dist/test/unit/retrieve/linkTraversalRetriever.test.js +0 -257
  110. package/dist/test/unit/retrieve/linkTraversalRetriever.test.js.map +0 -1
  111. package/dist/test/unit/retrieve/retrievers.test.js +0 -768
  112. package/dist/test/unit/retrieve/retrievers.test.js.map +0 -1
  113. package/dist/test/unit/retrieve/temporalRetrievers.test.js +0 -182
  114. package/dist/test/unit/retrieve/temporalRetrievers.test.js.map +0 -1
  115. package/dist/test/unit/store/antagonistTemporalBoundary.test.js +0 -120
  116. package/dist/test/unit/store/antagonistTemporalBoundary.test.js.map +0 -1
  117. package/dist/test/unit/store/embedOnWrite.test.js +0 -317
  118. package/dist/test/unit/store/embedOnWrite.test.js.map +0 -1
  119. package/dist/test/unit/store/fileTreeMemoryStore.test.js +0 -778
  120. package/dist/test/unit/store/fileTreeMemoryStore.test.js.map +0 -1
  121. package/dist/test/unit/store/fragmentEmbedOnWrite.test.js +0 -255
  122. package/dist/test/unit/store/fragmentEmbedOnWrite.test.js.map +0 -1
  123. package/dist/test/unit/store/indexInjection.test.js +0 -432
  124. package/dist/test/unit/store/indexInjection.test.js.map +0 -1
  125. package/dist/test/unit/store/lenientOpen.test.js +0 -248
  126. package/dist/test/unit/store/lenientOpen.test.js.map +0 -1
  127. package/dist/test/unit/store/listScoped.test.js +0 -109
  128. package/dist/test/unit/store/listScoped.test.js.map +0 -1
  129. package/dist/test/unit/store/observations.test.js +0 -239
  130. package/dist/test/unit/store/observations.test.js.map +0 -1
  131. package/dist/test/unit/store/rankAxis.test.js +0 -254
  132. package/dist/test/unit/store/rankAxis.test.js.map +0 -1
  133. package/dist/test/unit/store/scopeEncoding.test.js +0 -24
  134. package/dist/test/unit/store/scopeEncoding.test.js.map +0 -1
  135. package/dist/test/unit/store/temporalStore.test.js +0 -398
  136. package/dist/test/unit/store/temporalStore.test.js.map +0 -1
  137. package/dist/test/unit/tools/memoryTools.test.js +0 -842
  138. package/dist/test/unit/tools/memoryTools.test.js.map +0 -1
  139. package/dist/test/unit/types/identityCodec.test.js +0 -187
  140. package/dist/test/unit/types/identityCodec.test.js.map +0 -1
  141. package/dist/test/unit/types/ids.test.js +0 -84
  142. package/dist/test/unit/types/ids.test.js.map +0 -1
  143. package/dist/test/unit/types/temporalCodec.test.js +0 -203
  144. package/dist/test/unit/types/temporalCodec.test.js.map +0 -1
  145. package/dist/test/unit/types/temporalPolicy.test.js +0 -83
  146. package/dist/test/unit/types/temporalPolicy.test.js.map +0 -1
  147. package/dist/test/unit/types/writePolicy.test.js +0 -331
  148. package/dist/test/unit/types/writePolicy.test.js.map +0 -1
  149. package/dist/test/unit/vector/fragmentConverters.test.js +0 -58
  150. package/dist/test/unit/vector/fragmentConverters.test.js.map +0 -1
  151. package/dist/test/unit/vector/inMemoryCosineIndex.test.js +0 -252
  152. package/dist/test/unit/vector/inMemoryCosineIndex.test.js.map +0 -1
  153. package/dist/test/unit/vector/inMemoryFragmentCosineIndex.test.js +0 -362
  154. package/dist/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +0 -1
  155. package/dist/test/unit/vector/vectorIndex.test.js +0 -51
  156. package/dist/test/unit/vector/vectorIndex.test.js.map +0 -1
  157. package/eslint.config.js +0 -15
  158. package/etc/ts-agent-memory.api.md +0 -940
  159. package/lib/test/unit/converters/antagonistRoundTrip.test.d.ts +0 -10
  160. package/lib/test/unit/converters/antagonistRoundTrip.test.d.ts.map +0 -1
  161. package/lib/test/unit/converters/antagonistRoundTrip.test.js +0 -97
  162. package/lib/test/unit/converters/antagonistRoundTrip.test.js.map +0 -1
  163. package/lib/test/unit/converters/bodyConverterRegistry.test.d.ts +0 -2
  164. package/lib/test/unit/converters/bodyConverterRegistry.test.d.ts.map +0 -1
  165. package/lib/test/unit/converters/bodyConverterRegistry.test.js +0 -74
  166. package/lib/test/unit/converters/bodyConverterRegistry.test.js.map +0 -1
  167. package/lib/test/unit/converters/envelopeConverter.test.d.ts +0 -2
  168. package/lib/test/unit/converters/envelopeConverter.test.d.ts.map +0 -1
  169. package/lib/test/unit/converters/envelopeConverter.test.js +0 -315
  170. package/lib/test/unit/converters/envelopeConverter.test.js.map +0 -1
  171. package/lib/test/unit/index/memoryIndex.test.d.ts +0 -2
  172. package/lib/test/unit/index/memoryIndex.test.d.ts.map +0 -1
  173. package/lib/test/unit/index/memoryIndex.test.js +0 -216
  174. package/lib/test/unit/index/memoryIndex.test.js.map +0 -1
  175. package/lib/test/unit/ingest/antagonistCycleAndParity.test.d.ts +0 -9
  176. package/lib/test/unit/ingest/antagonistCycleAndParity.test.d.ts.map +0 -1
  177. package/lib/test/unit/ingest/antagonistCycleAndParity.test.js +0 -279
  178. package/lib/test/unit/ingest/antagonistCycleAndParity.test.js.map +0 -1
  179. package/lib/test/unit/ingest/cycleGuard.test.d.ts +0 -2
  180. package/lib/test/unit/ingest/cycleGuard.test.d.ts.map +0 -1
  181. package/lib/test/unit/ingest/cycleGuard.test.js +0 -83
  182. package/lib/test/unit/ingest/cycleGuard.test.js.map +0 -1
  183. package/lib/test/unit/ingest/dedupScope.test.d.ts +0 -2
  184. package/lib/test/unit/ingest/dedupScope.test.d.ts.map +0 -1
  185. package/lib/test/unit/ingest/dedupScope.test.js +0 -436
  186. package/lib/test/unit/ingest/dedupScope.test.js.map +0 -1
  187. package/lib/test/unit/ingest/orchestrator.test.d.ts +0 -2
  188. package/lib/test/unit/ingest/orchestrator.test.d.ts.map +0 -1
  189. package/lib/test/unit/ingest/orchestrator.test.js +0 -1060
  190. package/lib/test/unit/ingest/orchestrator.test.js.map +0 -1
  191. package/lib/test/unit/observe/memoryObservationStore.test.d.ts +0 -2
  192. package/lib/test/unit/observe/memoryObservationStore.test.d.ts.map +0 -1
  193. package/lib/test/unit/observe/memoryObservationStore.test.js +0 -120
  194. package/lib/test/unit/observe/memoryObservationStore.test.js.map +0 -1
  195. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.d.ts +0 -2
  196. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.d.ts.map +0 -1
  197. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.js +0 -118
  198. package/lib/test/unit/retrieve/fragmentSemanticRetriever.test.js.map +0 -1
  199. package/lib/test/unit/retrieve/linkTraversalRetriever.test.d.ts +0 -2
  200. package/lib/test/unit/retrieve/linkTraversalRetriever.test.d.ts.map +0 -1
  201. package/lib/test/unit/retrieve/linkTraversalRetriever.test.js +0 -259
  202. package/lib/test/unit/retrieve/linkTraversalRetriever.test.js.map +0 -1
  203. package/lib/test/unit/retrieve/retrievers.test.d.ts +0 -2
  204. package/lib/test/unit/retrieve/retrievers.test.d.ts.map +0 -1
  205. package/lib/test/unit/retrieve/retrievers.test.js +0 -770
  206. package/lib/test/unit/retrieve/retrievers.test.js.map +0 -1
  207. package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts +0 -2
  208. package/lib/test/unit/retrieve/temporalRetrievers.test.d.ts.map +0 -1
  209. package/lib/test/unit/retrieve/temporalRetrievers.test.js +0 -184
  210. package/lib/test/unit/retrieve/temporalRetrievers.test.js.map +0 -1
  211. package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts +0 -9
  212. package/lib/test/unit/store/antagonistTemporalBoundary.test.d.ts.map +0 -1
  213. package/lib/test/unit/store/antagonistTemporalBoundary.test.js +0 -122
  214. package/lib/test/unit/store/antagonistTemporalBoundary.test.js.map +0 -1
  215. package/lib/test/unit/store/embedOnWrite.test.d.ts +0 -2
  216. package/lib/test/unit/store/embedOnWrite.test.d.ts.map +0 -1
  217. package/lib/test/unit/store/embedOnWrite.test.js +0 -319
  218. package/lib/test/unit/store/embedOnWrite.test.js.map +0 -1
  219. package/lib/test/unit/store/fileTreeMemoryStore.test.d.ts +0 -2
  220. package/lib/test/unit/store/fileTreeMemoryStore.test.d.ts.map +0 -1
  221. package/lib/test/unit/store/fileTreeMemoryStore.test.js +0 -780
  222. package/lib/test/unit/store/fileTreeMemoryStore.test.js.map +0 -1
  223. package/lib/test/unit/store/fragmentEmbedOnWrite.test.d.ts +0 -2
  224. package/lib/test/unit/store/fragmentEmbedOnWrite.test.d.ts.map +0 -1
  225. package/lib/test/unit/store/fragmentEmbedOnWrite.test.js +0 -257
  226. package/lib/test/unit/store/fragmentEmbedOnWrite.test.js.map +0 -1
  227. package/lib/test/unit/store/indexInjection.test.d.ts +0 -2
  228. package/lib/test/unit/store/indexInjection.test.d.ts.map +0 -1
  229. package/lib/test/unit/store/indexInjection.test.js +0 -434
  230. package/lib/test/unit/store/indexInjection.test.js.map +0 -1
  231. package/lib/test/unit/store/lenientOpen.test.d.ts +0 -2
  232. package/lib/test/unit/store/lenientOpen.test.d.ts.map +0 -1
  233. package/lib/test/unit/store/lenientOpen.test.js +0 -250
  234. package/lib/test/unit/store/lenientOpen.test.js.map +0 -1
  235. package/lib/test/unit/store/listScoped.test.d.ts +0 -2
  236. package/lib/test/unit/store/listScoped.test.d.ts.map +0 -1
  237. package/lib/test/unit/store/listScoped.test.js +0 -111
  238. package/lib/test/unit/store/listScoped.test.js.map +0 -1
  239. package/lib/test/unit/store/observations.test.d.ts +0 -2
  240. package/lib/test/unit/store/observations.test.d.ts.map +0 -1
  241. package/lib/test/unit/store/observations.test.js +0 -241
  242. package/lib/test/unit/store/observations.test.js.map +0 -1
  243. package/lib/test/unit/store/rankAxis.test.d.ts +0 -2
  244. package/lib/test/unit/store/rankAxis.test.d.ts.map +0 -1
  245. package/lib/test/unit/store/rankAxis.test.js +0 -256
  246. package/lib/test/unit/store/rankAxis.test.js.map +0 -1
  247. package/lib/test/unit/store/scopeEncoding.test.d.ts +0 -2
  248. package/lib/test/unit/store/scopeEncoding.test.d.ts.map +0 -1
  249. package/lib/test/unit/store/scopeEncoding.test.js +0 -26
  250. package/lib/test/unit/store/scopeEncoding.test.js.map +0 -1
  251. package/lib/test/unit/store/temporalStore.test.d.ts +0 -2
  252. package/lib/test/unit/store/temporalStore.test.d.ts.map +0 -1
  253. package/lib/test/unit/store/temporalStore.test.js +0 -400
  254. package/lib/test/unit/store/temporalStore.test.js.map +0 -1
  255. package/lib/test/unit/tools/memoryTools.test.d.ts +0 -2
  256. package/lib/test/unit/tools/memoryTools.test.d.ts.map +0 -1
  257. package/lib/test/unit/tools/memoryTools.test.js +0 -844
  258. package/lib/test/unit/tools/memoryTools.test.js.map +0 -1
  259. package/lib/test/unit/types/identityCodec.test.d.ts +0 -2
  260. package/lib/test/unit/types/identityCodec.test.d.ts.map +0 -1
  261. package/lib/test/unit/types/identityCodec.test.js +0 -189
  262. package/lib/test/unit/types/identityCodec.test.js.map +0 -1
  263. package/lib/test/unit/types/ids.test.d.ts +0 -2
  264. package/lib/test/unit/types/ids.test.d.ts.map +0 -1
  265. package/lib/test/unit/types/ids.test.js +0 -86
  266. package/lib/test/unit/types/ids.test.js.map +0 -1
  267. package/lib/test/unit/types/temporalCodec.test.d.ts +0 -2
  268. package/lib/test/unit/types/temporalCodec.test.d.ts.map +0 -1
  269. package/lib/test/unit/types/temporalCodec.test.js +0 -205
  270. package/lib/test/unit/types/temporalCodec.test.js.map +0 -1
  271. package/lib/test/unit/types/temporalPolicy.test.d.ts +0 -2
  272. package/lib/test/unit/types/temporalPolicy.test.d.ts.map +0 -1
  273. package/lib/test/unit/types/temporalPolicy.test.js +0 -85
  274. package/lib/test/unit/types/temporalPolicy.test.js.map +0 -1
  275. package/lib/test/unit/types/writePolicy.test.d.ts +0 -2
  276. package/lib/test/unit/types/writePolicy.test.d.ts.map +0 -1
  277. package/lib/test/unit/types/writePolicy.test.js +0 -333
  278. package/lib/test/unit/types/writePolicy.test.js.map +0 -1
  279. package/lib/test/unit/vector/fragmentConverters.test.d.ts +0 -2
  280. package/lib/test/unit/vector/fragmentConverters.test.d.ts.map +0 -1
  281. package/lib/test/unit/vector/fragmentConverters.test.js +0 -60
  282. package/lib/test/unit/vector/fragmentConverters.test.js.map +0 -1
  283. package/lib/test/unit/vector/inMemoryCosineIndex.test.d.ts +0 -2
  284. package/lib/test/unit/vector/inMemoryCosineIndex.test.d.ts.map +0 -1
  285. package/lib/test/unit/vector/inMemoryCosineIndex.test.js +0 -254
  286. package/lib/test/unit/vector/inMemoryCosineIndex.test.js.map +0 -1
  287. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.d.ts +0 -2
  288. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.d.ts.map +0 -1
  289. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js +0 -364
  290. package/lib/test/unit/vector/inMemoryFragmentCosineIndex.test.js.map +0 -1
  291. package/lib/test/unit/vector/vectorIndex.test.d.ts +0 -2
  292. package/lib/test/unit/vector/vectorIndex.test.d.ts.map +0 -1
  293. package/lib/test/unit/vector/vectorIndex.test.js +0 -53
  294. package/lib/test/unit/vector/vectorIndex.test.js.map +0 -1
  295. package/rush-logs/ts-agent-memory.build.cache.log +0 -3
  296. package/rush-logs/ts-agent-memory.build.log +0 -9
  297. package/src/index.ts +0 -14
  298. package/src/packlets/converters/bodyConverterRegistry.ts +0 -105
  299. package/src/packlets/converters/envelopeConverter.ts +0 -233
  300. package/src/packlets/converters/index.ts +0 -7
  301. package/src/packlets/index/index.ts +0 -6
  302. package/src/packlets/index/memoryIndex.ts +0 -332
  303. package/src/packlets/ingest/cycleGuard.ts +0 -153
  304. package/src/packlets/ingest/hostStages.ts +0 -111
  305. package/src/packlets/ingest/index.ts +0 -9
  306. package/src/packlets/ingest/model.ts +0 -195
  307. package/src/packlets/ingest/orchestrator.ts +0 -968
  308. package/src/packlets/observe/index.ts +0 -7
  309. package/src/packlets/observe/memoryObservationStore.ts +0 -153
  310. package/src/packlets/observe/observer.ts +0 -119
  311. package/src/packlets/retrieve/fragmentSemanticRetriever.ts +0 -138
  312. package/src/packlets/retrieve/hybridRetriever.ts +0 -194
  313. package/src/packlets/retrieve/index.ts +0 -14
  314. package/src/packlets/retrieve/linkTraversalRetriever.ts +0 -158
  315. package/src/packlets/retrieve/recencyRetriever.ts +0 -54
  316. package/src/packlets/retrieve/retriever.ts +0 -291
  317. package/src/packlets/retrieve/semanticRetriever.ts +0 -152
  318. package/src/packlets/retrieve/structuredFilterRetriever.ts +0 -58
  319. package/src/packlets/retrieve/tagRetriever.ts +0 -58
  320. package/src/packlets/retrieve/temporalRetrievers.ts +0 -210
  321. package/src/packlets/store/fileTreeMemoryStore.ts +0 -1872
  322. package/src/packlets/store/index.ts +0 -7
  323. package/src/packlets/store/scopeEncoding.ts +0 -36
  324. package/src/packlets/tools/index.ts +0 -6
  325. package/src/packlets/tools/memoryTools.ts +0 -706
  326. package/src/packlets/types/envelope.ts +0 -196
  327. package/src/packlets/types/filenameSafety.ts +0 -57
  328. package/src/packlets/types/identityCodec.ts +0 -447
  329. package/src/packlets/types/ids.ts +0 -124
  330. package/src/packlets/types/index.ts +0 -11
  331. package/src/packlets/types/temporal.ts +0 -96
  332. package/src/packlets/types/writePolicy.ts +0 -612
  333. package/src/packlets/vector/fragmentConverters.ts +0 -55
  334. package/src/packlets/vector/inMemoryCosineIndex.ts +0 -196
  335. package/src/packlets/vector/inMemoryFragmentCosineIndex.ts +0 -289
  336. package/src/packlets/vector/index.ts +0 -9
  337. package/src/packlets/vector/vectorIndex.ts +0 -273
  338. package/src/test/unit/converters/antagonistRoundTrip.test.ts +0 -110
  339. package/src/test/unit/converters/bodyConverterRegistry.test.ts +0 -89
  340. package/src/test/unit/converters/envelopeConverter.test.ts +0 -418
  341. package/src/test/unit/index/memoryIndex.test.ts +0 -272
  342. package/src/test/unit/ingest/antagonistCycleAndParity.test.ts +0 -367
  343. package/src/test/unit/ingest/cycleGuard.test.ts +0 -110
  344. package/src/test/unit/ingest/dedupScope.test.ts +0 -542
  345. package/src/test/unit/ingest/orchestrator.test.ts +0 -1355
  346. package/src/test/unit/observe/memoryObservationStore.test.ts +0 -158
  347. package/src/test/unit/retrieve/fragmentSemanticRetriever.test.ts +0 -163
  348. package/src/test/unit/retrieve/linkTraversalRetriever.test.ts +0 -329
  349. package/src/test/unit/retrieve/retrievers.test.ts +0 -1018
  350. package/src/test/unit/retrieve/temporalRetrievers.test.ts +0 -226
  351. package/src/test/unit/store/antagonistTemporalBoundary.test.ts +0 -158
  352. package/src/test/unit/store/embedOnWrite.test.ts +0 -418
  353. package/src/test/unit/store/fileTreeMemoryStore.test.ts +0 -1041
  354. package/src/test/unit/store/fragmentEmbedOnWrite.test.ts +0 -349
  355. package/src/test/unit/store/indexInjection.test.ts +0 -550
  356. package/src/test/unit/store/lenientOpen.test.ts +0 -292
  357. package/src/test/unit/store/listScoped.test.ts +0 -138
  358. package/src/test/unit/store/observations.test.ts +0 -290
  359. package/src/test/unit/store/rankAxis.test.ts +0 -349
  360. package/src/test/unit/store/scopeEncoding.test.ts +0 -37
  361. package/src/test/unit/store/temporalStore.test.ts +0 -469
  362. package/src/test/unit/tools/memoryTools.test.ts +0 -1121
  363. package/src/test/unit/types/identityCodec.test.ts +0 -266
  364. package/src/test/unit/types/ids.test.ts +0 -94
  365. package/src/test/unit/types/temporalCodec.test.ts +0 -259
  366. package/src/test/unit/types/temporalPolicy.test.ts +0 -124
  367. package/src/test/unit/types/writePolicy.test.ts +0 -446
  368. package/src/test/unit/vector/fragmentConverters.test.ts +0 -80
  369. package/src/test/unit/vector/inMemoryCosineIndex.test.ts +0 -318
  370. package/src/test/unit/vector/inMemoryFragmentCosineIndex.test.ts +0 -477
  371. package/src/test/unit/vector/vectorIndex.test.ts +0 -64
  372. package/temp/build/lint/_eslint-5eVG3S6w.json +0 -306
  373. package/temp/build/typescript/ts_8nwakTlr.json +0 -1
  374. package/temp/ts-agent-memory.api.json +0 -21030
  375. package/temp/ts-agent-memory.api.md +0 -940
  376. package/tsconfig.json +0 -8
@@ -1,10 +0,0 @@
1
- /**
2
- * Antagonist torture test — convert/validate round-trip symmetry (target class
3
- * 7): every OPTIONAL field the envelope/edge/provenance shapes carry must
4
- * survive a full on-disk round-trip (serialize → YAML text → parse), not just a
5
- * single `Converter.convert` pass in memory. This exercises the exact path a
6
- * corrupted or field-dropping serializer/parser pair would break, mirroring the
7
- * `aiClientToolConfig`/`annotations` field-drop class named in the brief.
8
- */
9
- import '@fgv/ts-utils-jest';
10
- //# sourceMappingURL=antagonistRoundTrip.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"antagonistRoundTrip.test.d.ts","sourceRoot":"","sources":["../../../../src/test/unit/converters/antagonistRoundTrip.test.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AAEH,OAAO,oBAAoB,CAAC"}
@@ -1,97 +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 test — convert/validate round-trip symmetry (target class
9
- * 7): every OPTIONAL field the envelope/edge/provenance shapes carry must
10
- * survive a full on-disk round-trip (serialize → YAML text → parse), not just a
11
- * single `Converter.convert` pass in memory. This exercises the exact path a
12
- * corrupted or field-dropping serializer/parser pair would break, mirroring the
13
- * `aiClientToolConfig`/`annotations` field-drop class named in the brief.
14
- */
15
- require("@fgv/ts-utils-jest");
16
- const ts_utils_1 = require("@fgv/ts-utils");
17
- const index_1 = require("../../../index");
18
- const kind = 'note';
19
- function registry() {
20
- const reg = index_1.BodyConverterRegistry.create().orThrow();
21
- reg.register(kind, ts_utils_1.Converters.string);
22
- return reg;
23
- }
24
- describe('antagonist — full on-disk round-trip preserves every optional field', () => {
25
- // Wrong impl this catches: a serializer/parser pair where one side silently
26
- // drops an optional field (the exact class of bug the brief calls out for
27
- // `aiClientToolConfig`/`annotations`-shaped converters) — e.g. omitting
28
- // `temporal.invalid_at: null`, an edge's `valid_at`/`invalid_at`/`provenance`,
29
- // a `null` `embeddingRef`, or a provenance extension key, because the author
30
- // forgot to thread it through both the YAML emit AND the envelope Converter.
31
- test('every optional envelope/edge/provenance field set simultaneously survives a full YAML round-trip', () => {
32
- const envelope = {
33
- id: 'doc-1',
34
- entityId: 'doc-1',
35
- kind,
36
- tags: ['t1', 't2'],
37
- links: [
38
- {
39
- type: 'rel',
40
- target: { scope: 'knowledge', id: 'doc-2' },
41
- confidence: 0.42,
42
- provenance: { source: 'agent', by: 'curator', extra: { nested: true } },
43
- valid_at: 111,
44
- invalid_at: null
45
- }
46
- ],
47
- created: 1000,
48
- updated: 2000,
49
- seq: 7,
50
- contentHash: 'abc123',
51
- provenance: {
52
- source: 'host-ingest',
53
- by: 'erik',
54
- model: 'gpt-5',
55
- confidence: 0.87,
56
- derivedFrom: { scope: 'conversations/c1', id: 'turn-3' },
57
- // Opaque extension keys (per IProvenance's `[key: string]: unknown` arm).
58
- sentiment: { score: 0.5 },
59
- epistemic: 'belief'
60
- },
61
- temporal: { valid_at: 500, invalid_at: null },
62
- embeddingRef: null
63
- };
64
- const raw = (0, index_1.serializeMemoryFile)(envelope, 'the body text').orThrow();
65
- expect((0, index_1.parseMemoryFile)(raw, registry())).toSucceedAndSatisfy((record) => {
66
- // Deep-equal the ENTIRE envelope, not field-by-field — a partial assertion
67
- // list is exactly how a single dropped field slips through review.
68
- expect(record.envelope).toEqual(envelope);
69
- expect(record.body).toBe('the body text');
70
- });
71
- });
72
- test('an absent temporal/embeddingRef/edge-optionals round-trips to fully absent (no null-vs-undefined drift)', () => {
73
- const envelope = {
74
- id: 'doc-2',
75
- entityId: 'doc-2',
76
- kind,
77
- tags: [],
78
- links: [{ type: 'rel', target: { scope: 'knowledge', id: 'doc-3' } }],
79
- created: 0,
80
- updated: 0,
81
- seq: 0,
82
- contentHash: '',
83
- provenance: { source: 'agent' }
84
- };
85
- const raw = (0, index_1.serializeMemoryFile)(envelope, 'body').orThrow();
86
- expect((0, index_1.parseMemoryFile)(raw, registry())).toSucceedAndSatisfy((record) => {
87
- expect(record.envelope.temporal).toBeUndefined();
88
- expect(record.envelope.embeddingRef).toBeUndefined();
89
- expect(record.envelope.links[0].confidence).toBeUndefined();
90
- expect(record.envelope.links[0].provenance).toBeUndefined();
91
- expect(record.envelope.links[0].valid_at).toBeUndefined();
92
- expect(record.envelope.links[0].invalid_at).toBeUndefined();
93
- expect(record.envelope).toEqual(envelope);
94
- });
95
- });
96
- });
97
- //# sourceMappingURL=antagonistRoundTrip.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"antagonistRoundTrip.test.js","sourceRoot":"","sources":["../../../../src/test/unit/converters/antagonistRoundTrip.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH;;;;;;;GAOG;AAEH,8BAA4B;AAC5B,4CAA2C;AAC3C,0CAMwB;AAExB,MAAM,IAAI,GAAG,MAAiC,CAAC;AAE/C,SAAS,QAAQ;IACf,MAAM,GAAG,GAAG,6BAAqB,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACrD,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,qBAAU,CAAC,MAAM,CAAC,C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M,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;YAC5D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;YAC5D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAC;YAC1D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;YAC5D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5C,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\n/**\n * Antagonist torture test — convert/validate round-trip symmetry (target class\n * 7): every OPTIONAL field the envelope/edge/provenance shapes carry must\n * survive a full on-disk round-trip (serialize → YAML text → parse), not just a\n * single `Converter.convert` pass in memory. This exercises the exact path a\n * corrupted or field-dropping serializer/parser pair would break, mirroring the\n * `aiClientToolConfig`/`annotations` field-drop class named in the brief.\n */\n\nimport '@fgv/ts-utils-jest';\nimport { Converters } from '@fgv/ts-utils';\nimport {\n BodyConverterRegistry,\n IBodyConverterRegistry,\n IMemoryEnvelope,\n parseMemoryFile,\n serializeMemoryFile\n} from '../../../index';\n\nconst kind = 'note' as IMemoryEnvelope['kind'];\n\nfunction registry(): IBodyConverterRegistry {\n const reg = BodyConverterRegistry.create().orThrow();\n reg.register(kind, Converters.string);\n return reg;\n}\n\ndescribe('antagonist — full on-disk round-trip preserves every optional field', () => {\n // Wrong impl this catches: a serializer/parser pair where one side silently\n // drops an optional field (the exact class of bug the brief calls out for\n // `aiClientToolConfig`/`annotations`-shaped converters) — e.g. omitting\n // `temporal.invalid_at: null`, an edge's `valid_at`/`invalid_at`/`provenance`,\n // a `null` `embeddingRef`, or a provenance extension key, because the author\n // forgot to thread it through both the YAML emit AND the envelope Converter.\n test('every optional envelope/edge/provenance field set simultaneously survives a full YAML round-trip', () => {\n const envelope: IMemoryEnvelope = {\n id: 'doc-1' as IMemoryEnvelope['id'],\n entityId: 'doc-1' as IMemoryEnvelope['entityId'],\n kind,\n tags: ['t1', 't2'] as unknown as IMemoryEnvelope['tags'],\n links: [\n {\n type: 'rel' as never,\n target: { scope: 'knowledge', id: 'doc-2' } as never,\n confidence: 0.42,\n provenance: { source: 'agent', by: 'curator', extra: { nested: true } },\n valid_at: 111,\n\n invalid_at: null\n }\n ],\n created: 1000,\n updated: 2000,\n seq: 7,\n contentHash: 'abc123',\n provenance: {\n source: 'host-ingest',\n by: 'erik',\n model: 'gpt-5',\n confidence: 0.87,\n derivedFrom: { scope: 'conversations/c1', id: 'turn-3' } as never,\n // Opaque extension keys (per IProvenance's `[key: string]: unknown` arm).\n sentiment: { score: 0.5 },\n epistemic: 'belief'\n },\n\n temporal: { valid_at: 500, invalid_at: null },\n\n embeddingRef: null\n };\n\n const raw = serializeMemoryFile(envelope, 'the body text').orThrow();\n expect(parseMemoryFile(raw, registry())).toSucceedAndSatisfy((record) => {\n // Deep-equal the ENTIRE envelope, not field-by-field — a partial assertion\n // list is exactly how a single dropped field slips through review.\n expect(record.envelope).toEqual(envelope);\n expect(record.body).toBe('the body text');\n });\n });\n\n test('an absent temporal/embeddingRef/edge-optionals round-trips to fully absent (no null-vs-undefined drift)', () => {\n const envelope: IMemoryEnvelope = {\n id: 'doc-2' as IMemoryEnvelope['id'],\n entityId: 'doc-2' as IMemoryEnvelope['entityId'],\n kind,\n tags: [],\n links: [{ type: 'rel' as never, target: { scope: 'knowledge', id: 'doc-3' } as never }],\n created: 0,\n updated: 0,\n seq: 0,\n contentHash: '',\n provenance: { source: 'agent' }\n };\n const raw = serializeMemoryFile(envelope, 'body').orThrow();\n expect(parseMemoryFile(raw, registry())).toSucceedAndSatisfy((record) => {\n expect(record.envelope.temporal).toBeUndefined();\n expect(record.envelope.embeddingRef).toBeUndefined();\n expect(record.envelope.links[0].confidence).toBeUndefined();\n expect(record.envelope.links[0].provenance).toBeUndefined();\n expect(record.envelope.links[0].valid_at).toBeUndefined();\n expect(record.envelope.links[0].invalid_at).toBeUndefined();\n expect(record.envelope).toEqual(envelope);\n });\n });\n});\n"]}
@@ -1,2 +0,0 @@
1
- import '@fgv/ts-utils-jest';
2
- //# sourceMappingURL=bodyConverterRegistry.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bodyConverterRegistry.test.d.ts","sourceRoot":"","sources":["../../../../src/test/unit/converters/bodyConverterRegistry.test.ts"],"names":[],"mappings":"AAKA,OAAO,oBAAoB,CAAC"}
@@ -1,74 +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 ts_utils_1 = require("@fgv/ts-utils");
9
- const ts_json_base_1 = require("@fgv/ts-json-base");
10
- const converters_1 = require("../../../packlets/converters");
11
- const knowledgeKind = 'knowledge';
12
- const profileKind = 'profile';
13
- describe('BodyConverterRegistry', () => {
14
- let registry;
15
- beforeEach(() => {
16
- registry = converters_1.BodyConverterRegistry.create().orThrow();
17
- });
18
- test('create succeeds', () => {
19
- expect(converters_1.BodyConverterRegistry.create()).toSucceed();
20
- });
21
- describe('register / has / convert', () => {
22
- test('registers a Converter and converts a matching body', () => {
23
- registry.register(knowledgeKind, ts_utils_1.Converters.string);
24
- expect(registry.has(knowledgeKind)).toBe(true);
25
- expect(registry.convert(knowledgeKind, 'a knowledge doc')).toSucceedWith('a knowledge doc');
26
- });
27
- test('a registered Converter rejects an invalid body', () => {
28
- registry.register(knowledgeKind, ts_utils_1.Converters.string);
29
- expect(registry.convert(knowledgeKind, 42)).toFail();
30
- });
31
- test('has returns false for an unregistered kind', () => {
32
- expect(registry.has(knowledgeKind)).toBe(false);
33
- });
34
- test('convert fails for an unregistered kind', () => {
35
- expect(registry.convert(knowledgeKind, 'x')).toFailWith(/no converter registered for kind 'knowledge'/i);
36
- });
37
- test('register replaces a prior registration for the same kind', () => {
38
- registry.register(knowledgeKind, ts_utils_1.Converters.string);
39
- registry.register(knowledgeKind, ts_utils_1.Converters.number);
40
- expect(registry.convert(knowledgeKind, 7)).toSucceedWith(7);
41
- expect(registry.convert(knowledgeKind, 'x')).toFail();
42
- });
43
- });
44
- describe('getConverter', () => {
45
- test('returns the registered converter', () => {
46
- registry.register(knowledgeKind, ts_utils_1.Converters.string);
47
- expect(registry.getConverter(knowledgeKind)).toSucceedAndSatisfy((converter) => {
48
- expect(converter.convert('hello')).toSucceedWith('hello');
49
- });
50
- });
51
- test('fails for an unregistered kind', () => {
52
- expect(registry.getConverter(knowledgeKind)).toFailWith(/no converter registered for kind/i);
53
- });
54
- });
55
- describe('registerSchema', () => {
56
- const profileSchema = ts_json_base_1.JsonSchema.object({
57
- name: ts_json_base_1.JsonSchema.string(),
58
- age: ts_json_base_1.JsonSchema.integer()
59
- });
60
- test('registers a JsonSchema validator and validates a matching body', () => {
61
- registry.registerSchema(profileKind, profileSchema);
62
- expect(registry.has(profileKind)).toBe(true);
63
- expect(registry.convert(profileKind, { name: 'Ada', age: 36 })).toSucceedWith({
64
- name: 'Ada',
65
- age: 36
66
- });
67
- });
68
- test('a registered schema rejects an invalid body', () => {
69
- registry.registerSchema(profileKind, profileSchema);
70
- expect(registry.convert(profileKind, { name: 'Ada' })).toFail();
71
- });
72
- });
73
- });
74
- //# sourceMappingURL=bodyConverterRegistry.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bodyConverterRegistry.test.js","sourceRoot":"","sources":["../../../../src/test/unit/converters/bodyConverterRegistry.test.ts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AAa,CAAC,CAAC,CAAC,UAAU,CAAC,mCAAmC,CAAC,CAAC;QAC/F,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;QAC9B,MAAM,aAAa,GAAG,yBAAU,CAAC,MAAM,CAAC;YACtC,IAAI,EAAE,yBAAU,CAAC,MAAM,EAAE;YACzB,GAAG,EAAE,yBAAU,CAAC,OAAO,EAAE;SAC1B,CAAC,CAAC;QAEH,IAAI,CAAC,gEAAgE,EAAE,GAAG,EAAE;YAC1E,QAAQ,CAAC,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;YACpD,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;gBAC5E,IAAI,EAAE,KAAK;gBACX,GAAG,EAAE,EAAE;aACR,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;YACvD,QAAQ,CAAC,cAAc,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;YACpD,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAClE,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 { Converters } from '@fgv/ts-utils';\nimport { JsonSchema } from '@fgv/ts-json-base';\nimport { BodyConverterRegistry } from '../../../packlets/converters';\nimport { Kind } from '../../../packlets/types';\n\nconst knowledgeKind: Kind = 'knowledge' as Kind;\nconst profileKind: Kind = 'profile' as Kind;\n\ndescribe('BodyConverterRegistry', () => {\n let registry: BodyConverterRegistry;\n\n beforeEach(() => {\n registry = BodyConverterRegistry.create().orThrow();\n });\n\n test('create succeeds', () => {\n expect(BodyConverterRegistry.create()).toSucceed();\n });\n\n describe('register / has / convert', () => {\n test('registers a Converter and converts a matching body', () => {\n registry.register(knowledgeKind, Converters.string);\n expect(registry.has(knowledgeKind)).toBe(true);\n expect(registry.convert(knowledgeKind, 'a knowledge doc')).toSucceedWith('a knowledge doc');\n });\n\n test('a registered Converter rejects an invalid body', () => {\n registry.register(knowledgeKind, Converters.string);\n expect(registry.convert(knowledgeKind, 42)).toFail();\n });\n\n test('has returns false for an unregistered kind', () => {\n expect(registry.has(knowledgeKind)).toBe(false);\n });\n\n test('convert fails for an unregistered kind', () => {\n expect(registry.convert(knowledgeKind, 'x')).toFailWith(\n /no converter registered for kind 'knowledge'/i\n );\n });\n\n test('register replaces a prior registration for the same kind', () => {\n registry.register(knowledgeKind, Converters.string);\n registry.register(knowledgeKind, Converters.number);\n expect(registry.convert(knowledgeKind, 7)).toSucceedWith(7);\n expect(registry.convert(knowledgeKind, 'x')).toFail();\n });\n });\n\n describe('getConverter', () => {\n test('returns the registered converter', () => {\n registry.register(knowledgeKind, Converters.string);\n expect(registry.getConverter(knowledgeKind)).toSucceedAndSatisfy((converter) => {\n expect(converter.convert('hello')).toSucceedWith('hello');\n });\n });\n\n test('fails for an unregistered kind', () => {\n expect(registry.getConverter(knowledgeKind)).toFailWith(/no converter registered for kind/i);\n });\n });\n\n describe('registerSchema', () => {\n const profileSchema = JsonSchema.object({\n name: JsonSchema.string(),\n age: JsonSchema.integer()\n });\n\n test('registers a JsonSchema validator and validates a matching body', () => {\n registry.registerSchema(profileKind, profileSchema);\n expect(registry.has(profileKind)).toBe(true);\n expect(registry.convert(profileKind, { name: 'Ada', age: 36 })).toSucceedWith({\n name: 'Ada',\n age: 36\n });\n });\n\n test('a registered schema rejects an invalid body', () => {\n registry.registerSchema(profileKind, profileSchema);\n expect(registry.convert(profileKind, { name: 'Ada' })).toFail();\n });\n });\n});\n"]}
@@ -1,2 +0,0 @@
1
- import '@fgv/ts-utils-jest';
2
- //# sourceMappingURL=envelopeConverter.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"envelopeConverter.test.d.ts","sourceRoot":"","sources":["../../../../src/test/unit/converters/envelopeConverter.test.ts"],"names":[],"mappings":"AAKA,OAAO,oBAAoB,CAAC"}
@@ -1,315 +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 ts_utils_1 = require("@fgv/ts-utils");
9
- const converters_1 = require("../../../packlets/converters");
10
- const validEnvelopeObject = {
11
- id: 'intro-to-rust',
12
- entityId: 'intro-to-rust',
13
- kind: 'knowledge',
14
- tags: ['rust', 'systems'],
15
- links: [{ type: 'related', target: { scope: 'knowledge', id: 'ownership' } }],
16
- created: 1000,
17
- updated: 2000,
18
- seq: 5,
19
- contentHash: 'crc-abc',
20
- provenance: { source: 'agent', by: 'curator' }
21
- };
22
- describe('provenanceConverter', () => {
23
- test('validates the known fields', () => {
24
- expect(converters_1.provenanceConverter.convert({ source: 'human', by: 'erik', model: 'gpt', confidence: 0.9 })).toSucceedWith({ source: 'human', by: 'erik', model: 'gpt', confidence: 0.9 });
25
- });
26
- test('preserves opaque extension keys verbatim', () => {
27
- expect(converters_1.provenanceConverter.convert({ source: 'agent', sentiment: { score: 0.5 }, epistemic: 'belief' })).toSucceedAndSatisfy((p) => {
28
- expect(p.source).toBe('agent');
29
- expect(p.sentiment).toEqual({ score: 0.5 });
30
- expect(p.epistemic).toBe('belief');
31
- });
32
- });
33
- test('accepts an arbitrary source string (open vocabulary)', () => {
34
- expect(converters_1.provenanceConverter.convert({ source: 'host-ingest' })).toSucceedWith({ source: 'host-ingest' });
35
- });
36
- test('validates a scope-qualified derivedFrom (nested { scope, id })', () => {
37
- expect(converters_1.provenanceConverter.convert({
38
- source: 'host-ingest',
39
- derivedFrom: { scope: 'conversations/conv-a', id: 'turn-3' }
40
- })).toSucceedAndSatisfy((p) => {
41
- expect(p.derivedFrom).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });
42
- });
43
- });
44
- test('rejects a bare-string derivedFrom (the pre-scoped format)', () => {
45
- expect(converters_1.provenanceConverter.convert({ source: 'host-ingest', derivedFrom: 'turn-3' })).toFail();
46
- });
47
- test('rejects a derivedFrom missing scope', () => {
48
- expect(converters_1.provenanceConverter.convert({ source: 'host-ingest', derivedFrom: { id: 'turn-3' } })).toFailWith(/scope/i);
49
- });
50
- test('rejects a derivedFrom missing id', () => {
51
- expect(converters_1.provenanceConverter.convert({ source: 'host-ingest', derivedFrom: { scope: 'conversations/conv-a' } })).toFailWith(/id/i);
52
- });
53
- test('fails when source is missing', () => {
54
- expect(converters_1.provenanceConverter.convert({ by: 'erik' })).toFail();
55
- });
56
- test('fails on a non-object', () => {
57
- expect(converters_1.provenanceConverter.convert('nope')).toFail();
58
- });
59
- });
60
- describe('edgeTargetConverter', () => {
61
- test('validates a scope-qualified target', () => {
62
- expect(converters_1.edgeTargetConverter.convert({ scope: 'conversations/conv-a', id: 'turn-3' })).toSucceedAndSatisfy((t) => {
63
- expect(t).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });
64
- });
65
- });
66
- test('rejects a target missing scope', () => {
67
- expect(converters_1.edgeTargetConverter.convert({ id: 'turn-3' })).toFailWith(/scope/i);
68
- });
69
- test('rejects a target missing id', () => {
70
- expect(converters_1.edgeTargetConverter.convert({ scope: 'conversations/conv-a' })).toFailWith(/id/i);
71
- });
72
- test('rejects a bare-string target (the pre-scoped format)', () => {
73
- expect(converters_1.edgeTargetConverter.convert('turn-3')).toFail();
74
- });
75
- });
76
- describe('edgeConverter', () => {
77
- test('validates a full attributed edge', () => {
78
- expect(converters_1.edgeConverter.convert({
79
- type: 'mtm-ref',
80
- target: { scope: 'conversations/conv-a', id: 'turn-3' },
81
- confidence: 0.8,
82
- provenance: { source: 'agent' },
83
- valid_at: 100,
84
- invalid_at: 200
85
- })).toSucceedAndSatisfy((edge) => {
86
- expect(edge.type).toBe('mtm-ref');
87
- expect(edge.target).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });
88
- expect(edge.confidence).toBe(0.8);
89
- expect(edge.provenance).toEqual({ source: 'agent' });
90
- expect(edge.valid_at).toBe(100);
91
- expect(edge.invalid_at).toBe(200);
92
- });
93
- });
94
- test('validates a minimal edge', () => {
95
- expect(converters_1.edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'ownership' } })).toSucceedAndSatisfy((edge) => {
96
- expect(edge.type).toBe('related');
97
- expect(edge.target).toEqual({ scope: 'knowledge', id: 'ownership' });
98
- expect(edge.confidence).toBeUndefined();
99
- });
100
- });
101
- test('accepts a null invalid_at (still valid)', () => {
102
- expect(converters_1.edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'x' }, invalid_at: null })).toSucceedAndSatisfy((edge) => {
103
- expect(edge.invalid_at).toBeNull();
104
- });
105
- });
106
- test('fails when invalid_at is neither a number nor null', () => {
107
- expect(converters_1.edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'x' }, invalid_at: 'soon' })).toFail();
108
- });
109
- test('fails when target is missing', () => {
110
- expect(converters_1.edgeConverter.convert({ type: 'related' })).toFail();
111
- });
112
- test('fails when target is a bare string (rejects the pre-scoped format)', () => {
113
- expect(converters_1.edgeConverter.convert({ type: 'related', target: 'ownership' })).toFail();
114
- });
115
- });
116
- describe('temporalConverter', () => {
117
- test('validates a temporal block', () => {
118
- expect(converters_1.temporalConverter.convert({ valid_at: 1, invalid_at: null })).toSucceedWith({
119
- valid_at: 1,
120
- invalid_at: null
121
- });
122
- });
123
- test('validates an empty temporal block', () => {
124
- expect(converters_1.temporalConverter.convert({})).toSucceedWith({});
125
- });
126
- });
127
- describe('envelopeConverter', () => {
128
- test('validates a full envelope without optional blocks', () => {
129
- expect(converters_1.envelopeConverter.convert(validEnvelopeObject)).toSucceedAndSatisfy((envelope) => {
130
- expect(envelope.id).toBe('intro-to-rust');
131
- expect(envelope.tags).toEqual(['rust', 'systems']);
132
- expect(envelope.links).toHaveLength(1);
133
- expect(envelope.temporal).toBeUndefined();
134
- expect(envelope.embeddingRef).toBeUndefined();
135
- });
136
- });
137
- test('validates a temporal envelope with a string embeddingRef', () => {
138
- expect(converters_1.envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { temporal: { valid_at: 10 }, embeddingRef: 'vec-1' }))).toSucceedAndSatisfy((envelope) => {
139
- expect(envelope.temporal).toEqual({ valid_at: 10 });
140
- expect(envelope.embeddingRef).toBe('vec-1');
141
- });
142
- });
143
- test('accepts a null embeddingRef (not embedded)', () => {
144
- expect(converters_1.envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { embeddingRef: null }))).toSucceedAndSatisfy((envelope) => {
145
- expect(envelope.embeddingRef).toBeNull();
146
- });
147
- });
148
- test('fails when embeddingRef is neither a string nor null', () => {
149
- expect(converters_1.envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { embeddingRef: 42 }))).toFail();
150
- });
151
- test('rank is absent when not present', () => {
152
- expect(converters_1.envelopeConverter.convert(validEnvelopeObject)).toSucceedAndSatisfy((envelope) => {
153
- expect(envelope.rank).toBeUndefined();
154
- });
155
- });
156
- test('validates and preserves a numeric rank', () => {
157
- expect(converters_1.envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { rank: 42 }))).toSucceedAndSatisfy((envelope) => {
158
- expect(envelope.rank).toBe(42);
159
- });
160
- });
161
- test('serialize/parse round-trips rank through frontmatter', () => {
162
- const registry = converters_1.BodyConverterRegistry.create().orThrow();
163
- registry.register('knowledge', ts_utils_1.Converters.string);
164
- const envelope = converters_1.envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { rank: 7 })).orThrow();
165
- const file = (0, converters_1.serializeMemoryFile)(envelope, 'body').orThrow();
166
- expect((0, converters_1.parseMemoryFile)(file, registry)).toSucceedAndSatisfy((record) => {
167
- expect(record.envelope.rank).toBe(7);
168
- });
169
- });
170
- test('fails when rank is not a number', () => {
171
- expect(converters_1.envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { rank: 'high' }))).toFail();
172
- });
173
- test('fails when a required field is missing', () => {
174
- const missing = Object.assign({}, validEnvelopeObject);
175
- delete missing.contentHash;
176
- expect(converters_1.envelopeConverter.convert(missing)).toFail();
177
- });
178
- });
179
- describe('envelopeYamlConverter', () => {
180
- test('parses an envelope from a YAML string', () => {
181
- const yaml = (0, converters_1.serializeMemoryFile)(converters_1.envelopeConverter.convert(validEnvelopeObject).orThrow(), 'body text').orThrow();
182
- const frontmatter = (0, converters_1.splitFrontmatter)(yaml).orThrow().frontmatter;
183
- expect(converters_1.envelopeYamlConverter.convert(frontmatter)).toSucceedAndSatisfy((envelope) => {
184
- expect(envelope.id).toBe('intro-to-rust');
185
- });
186
- });
187
- test('fails on a YAML string that is not an object', () => {
188
- expect(converters_1.envelopeYamlConverter.convert('just a scalar')).toFail();
189
- });
190
- });
191
- describe('splitFrontmatter / joinFrontmatter', () => {
192
- test('splits a well-formed memory file', () => {
193
- const raw = '---\nid: x\nkind: knowledge\n---\nThe body.\nSecond line.';
194
- expect((0, converters_1.splitFrontmatter)(raw)).toSucceedWith({
195
- frontmatter: 'id: x\nkind: knowledge',
196
- body: 'The body.\nSecond line.'
197
- });
198
- });
199
- test('strips trailing CR so CRLF-authored files parse identically to LF', () => {
200
- const raw = '---\r\nid: x\r\nkind: knowledge\r\n---\r\nThe body.\r\nSecond line.';
201
- expect((0, converters_1.splitFrontmatter)(raw)).toSucceedWith({
202
- frontmatter: 'id: x\nkind: knowledge',
203
- body: 'The body.\nSecond line.'
204
- });
205
- });
206
- test('fails when the opening delimiter is missing', () => {
207
- expect((0, converters_1.splitFrontmatter)('no frontmatter here')).toFailWith(/missing opening frontmatter delimiter/i);
208
- });
209
- test('fails when the closing delimiter is missing', () => {
210
- expect((0, converters_1.splitFrontmatter)('---\nid: x\nstill going')).toFailWith(/missing closing frontmatter delimiter/i);
211
- });
212
- test('join adds a trailing newline to the frontmatter when absent', () => {
213
- expect((0, converters_1.joinFrontmatter)('id: x', 'body')).toBe('---\nid: x\n---\nbody');
214
- });
215
- test('join does not double the trailing newline when present', () => {
216
- expect((0, converters_1.joinFrontmatter)('id: x\n', 'body')).toBe('---\nid: x\n---\nbody');
217
- });
218
- test('split and join round-trip', () => {
219
- const raw = '---\nid: x\n---\nbody content';
220
- const parts = (0, converters_1.splitFrontmatter)(raw).orThrow();
221
- expect((0, converters_1.joinFrontmatter)(parts.frontmatter, parts.body)).toBe(raw);
222
- });
223
- });
224
- describe('parseMemoryFile / serializeMemoryFile', () => {
225
- let registry;
226
- const knowledgeKind = 'knowledge';
227
- beforeEach(() => {
228
- registry = converters_1.BodyConverterRegistry.create().orThrow();
229
- registry.register(knowledgeKind, ts_utils_1.Converters.string);
230
- });
231
- test('serializes then parses a record round-trip', () => {
232
- const envelope = converters_1.envelopeConverter.convert(validEnvelopeObject).orThrow();
233
- const file = (0, converters_1.serializeMemoryFile)(envelope, 'The knowledge body.').orThrow();
234
- expect((0, converters_1.parseMemoryFile)(file, registry)).toSucceedAndSatisfy((record) => {
235
- expect(record.envelope.id).toBe('intro-to-rust');
236
- expect(record.body).toBe('The knowledge body.');
237
- });
238
- });
239
- test('round-trips a scope-qualified edge target through the frontmatter intact', () => {
240
- const envelope = converters_1.envelopeConverter
241
- .convert(Object.assign(Object.assign({}, validEnvelopeObject), { links: [{ type: 'mtm-ref', target: { scope: 'conversations/conv-a', id: 'turn-3' } }] }))
242
- .orThrow();
243
- const file = (0, converters_1.serializeMemoryFile)(envelope, 'body').orThrow();
244
- // On-wire the target is a nested object, NOT a bare scalar.
245
- expect(file).toMatch(/scope: conversations\/conv-a/);
246
- expect(file).toMatch(/id: turn-3/);
247
- expect((0, converters_1.parseMemoryFile)(file, registry)).toSucceedAndSatisfy((record) => {
248
- expect(record.envelope.links).toEqual([
249
- { type: 'mtm-ref', target: { scope: 'conversations/conv-a', id: 'turn-3' } }
250
- ]);
251
- // Serializing the reparsed record reproduces byte-identical output.
252
- expect((0, converters_1.serializeMemoryFile)(record.envelope, record.body)).toSucceedWith(file);
253
- });
254
- });
255
- test('round-trips a scope-qualified provenance.derivedFrom through the frontmatter intact', () => {
256
- const envelope = converters_1.envelopeConverter
257
- .convert(Object.assign(Object.assign({}, validEnvelopeObject), { provenance: {
258
- source: 'host-ingest',
259
- derivedFrom: { scope: 'conversations/conv-a', id: 'turn-3' }
260
- } }))
261
- .orThrow();
262
- const file = (0, converters_1.serializeMemoryFile)(envelope, 'body').orThrow();
263
- // On-wire the back-reference is a nested object, NOT a bare scalar.
264
- expect(file).toMatch(/scope: conversations\/conv-a/);
265
- expect((0, converters_1.parseMemoryFile)(file, registry)).toSucceedAndSatisfy((record) => {
266
- expect(record.envelope.provenance.derivedFrom).toEqual({
267
- scope: 'conversations/conv-a',
268
- id: 'turn-3'
269
- });
270
- expect((0, converters_1.serializeMemoryFile)(record.envelope, record.body)).toSucceedWith(file);
271
- });
272
- });
273
- test('two records whose derivedFrom share a stem across scopes round-trip as distinct scoped refs', () => {
274
- // Same idStem ('turn-3'), different scopes — exactly the ambiguity a bare
275
- // MemoryId could not disambiguate. Each must round-trip to ITS OWN scope.
276
- const makeFile = (scope) => {
277
- const envelope = converters_1.envelopeConverter
278
- .convert(Object.assign(Object.assign({}, validEnvelopeObject), { provenance: { source: 'host-ingest', derivedFrom: { scope, id: 'turn-3' } } }))
279
- .orThrow();
280
- return (0, converters_1.serializeMemoryFile)(envelope, 'body').orThrow();
281
- };
282
- const fileA = makeFile('conversations/conv-a');
283
- const fileB = makeFile('conversations/conv-b');
284
- expect(fileA).not.toBe(fileB);
285
- expect((0, converters_1.parseMemoryFile)(fileA, registry)).toSucceedAndSatisfy((record) => {
286
- expect(record.envelope.provenance.derivedFrom).toEqual({
287
- scope: 'conversations/conv-a',
288
- id: 'turn-3'
289
- });
290
- });
291
- expect((0, converters_1.parseMemoryFile)(fileB, registry)).toSucceedAndSatisfy((record) => {
292
- expect(record.envelope.provenance.derivedFrom).toEqual({
293
- scope: 'conversations/conv-b',
294
- id: 'turn-3'
295
- });
296
- });
297
- });
298
- test('fails when the frontmatter cannot be split', () => {
299
- expect((0, converters_1.parseMemoryFile)('no delimiters', registry)).toFailWith(/missing opening frontmatter delimiter/i);
300
- });
301
- test('fails with envelope context when the envelope is invalid', () => {
302
- const file = '---\nid: x\n---\nbody';
303
- expect((0, converters_1.parseMemoryFile)(file, registry)).toFailWith(/invalid envelope/i);
304
- });
305
- test('fails with body context when the body fails the registered converter', () => {
306
- const envelope = converters_1.envelopeConverter.convert(Object.assign(Object.assign({}, validEnvelopeObject), { kind: 'unregistered' })).orThrow();
307
- const file = (0, converters_1.serializeMemoryFile)(envelope, 'body').orThrow();
308
- expect((0, converters_1.parseMemoryFile)(file, registry)).toFailWith(/invalid body.*no converter registered/i);
309
- });
310
- test('serialize fails (with id context) when the envelope cannot be dumped to YAML', () => {
311
- const unserializable = Object.assign(Object.assign({}, validEnvelopeObject), { weird: BigInt(10) });
312
- expect((0, converters_1.serializeMemoryFile)(unserializable, 'body')).toFailWith(/failed to serialize envelope/i);
313
- });
314
- });
315
- //# sourceMappingURL=envelopeConverter.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"envelopeConverter.test.js","sourceRoot":"","sources":["../../../../src/test/unit/converters/envelopeConverter.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,8BAA4B;AAC5B,4CAA2C;AAC3C,6DAYsC;AAGtC,MAAM,mBAAmB,GAA4B;IACnD,EAAE,EAAE,eAAe;IACnB,QAAQ,EAAE,eAAe;IACzB,IAAI,EAAE,WAAW;I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O,iCAAM,mBAAmB,KAAE,IAAI,EAAE,cAAc,IAAG,CAAC,OAAO,EAAE,CAAC;QACvG,MAAM,IAAI,GAAG,IAAA,gCAAmB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7D,MAAM,CAAC,IAAA,4BAAe,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,wCAAwC,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACxF,MAAM,cAAc,GAAG,gCAAK,mBAAmB,KAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,GAAgC,CAAC;QACnG,MAAM,CAAC,IAAA,gCAAmB,EAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,+BAA+B,CAAC,CAAC;IAClG,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 { Converters } from '@fgv/ts-utils';\nimport {\n BodyConverterRegistry,\n edgeConverter,\n edgeTargetConverter,\n envelopeConverter,\n envelopeYamlConverter,\n joinFrontmatter,\n parseMemoryFile,\n provenanceConverter,\n serializeMemoryFile,\n splitFrontmatter,\n temporalConverter\n} from '../../../packlets/converters';\nimport { IMemoryEnvelope, Kind } from '../../../packlets/types';\n\nconst validEnvelopeObject: Record<string, unknown> = {\n id: 'intro-to-rust',\n entityId: 'intro-to-rust',\n kind: 'knowledge',\n tags: ['rust', 'systems'],\n links: [{ type: 'related', target: { scope: 'knowledge', id: 'ownership' } }],\n created: 1000,\n updated: 2000,\n seq: 5,\n contentHash: 'crc-abc',\n provenance: { source: 'agent', by: 'curator' }\n};\n\ndescribe('provenanceConverter', () => {\n test('validates the known fields', () => {\n expect(\n provenanceConverter.convert({ source: 'human', by: 'erik', model: 'gpt', confidence: 0.9 })\n ).toSucceedWith({ source: 'human', by: 'erik', model: 'gpt', confidence: 0.9 });\n });\n\n test('preserves opaque extension keys verbatim', () => {\n expect(\n provenanceConverter.convert({ source: 'agent', sentiment: { score: 0.5 }, epistemic: 'belief' })\n ).toSucceedAndSatisfy((p) => {\n expect(p.source).toBe('agent');\n expect(p.sentiment).toEqual({ score: 0.5 });\n expect(p.epistemic).toBe('belief');\n });\n });\n\n test('accepts an arbitrary source string (open vocabulary)', () => {\n expect(provenanceConverter.convert({ source: 'host-ingest' })).toSucceedWith({ source: 'host-ingest' });\n });\n\n test('validates a scope-qualified derivedFrom (nested { scope, id })', () => {\n expect(\n provenanceConverter.convert({\n source: 'host-ingest',\n derivedFrom: { scope: 'conversations/conv-a', id: 'turn-3' }\n })\n ).toSucceedAndSatisfy((p) => {\n expect(p.derivedFrom).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });\n });\n });\n\n test('rejects a bare-string derivedFrom (the pre-scoped format)', () => {\n expect(provenanceConverter.convert({ source: 'host-ingest', derivedFrom: 'turn-3' })).toFail();\n });\n\n test('rejects a derivedFrom missing scope', () => {\n expect(provenanceConverter.convert({ source: 'host-ingest', derivedFrom: { id: 'turn-3' } })).toFailWith(\n /scope/i\n );\n });\n\n test('rejects a derivedFrom missing id', () => {\n expect(\n provenanceConverter.convert({ source: 'host-ingest', derivedFrom: { scope: 'conversations/conv-a' } })\n ).toFailWith(/id/i);\n });\n\n test('fails when source is missing', () => {\n expect(provenanceConverter.convert({ by: 'erik' })).toFail();\n });\n\n test('fails on a non-object', () => {\n expect(provenanceConverter.convert('nope')).toFail();\n });\n});\n\ndescribe('edgeTargetConverter', () => {\n test('validates a scope-qualified target', () => {\n expect(edgeTargetConverter.convert({ scope: 'conversations/conv-a', id: 'turn-3' })).toSucceedAndSatisfy(\n (t) => {\n expect(t).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });\n }\n );\n });\n\n test('rejects a target missing scope', () => {\n expect(edgeTargetConverter.convert({ id: 'turn-3' })).toFailWith(/scope/i);\n });\n\n test('rejects a target missing id', () => {\n expect(edgeTargetConverter.convert({ scope: 'conversations/conv-a' })).toFailWith(/id/i);\n });\n\n test('rejects a bare-string target (the pre-scoped format)', () => {\n expect(edgeTargetConverter.convert('turn-3')).toFail();\n });\n});\n\ndescribe('edgeConverter', () => {\n test('validates a full attributed edge', () => {\n expect(\n edgeConverter.convert({\n type: 'mtm-ref',\n target: { scope: 'conversations/conv-a', id: 'turn-3' },\n confidence: 0.8,\n provenance: { source: 'agent' },\n valid_at: 100,\n invalid_at: 200\n })\n ).toSucceedAndSatisfy((edge) => {\n expect(edge.type).toBe('mtm-ref');\n expect(edge.target).toEqual({ scope: 'conversations/conv-a', id: 'turn-3' });\n expect(edge.confidence).toBe(0.8);\n expect(edge.provenance).toEqual({ source: 'agent' });\n expect(edge.valid_at).toBe(100);\n expect(edge.invalid_at).toBe(200);\n });\n });\n\n test('validates a minimal edge', () => {\n expect(\n edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'ownership' } })\n ).toSucceedAndSatisfy((edge) => {\n expect(edge.type).toBe('related');\n expect(edge.target).toEqual({ scope: 'knowledge', id: 'ownership' });\n expect(edge.confidence).toBeUndefined();\n });\n });\n\n test('accepts a null invalid_at (still valid)', () => {\n expect(\n edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'x' }, invalid_at: null })\n ).toSucceedAndSatisfy((edge) => {\n expect(edge.invalid_at).toBeNull();\n });\n });\n\n test('fails when invalid_at is neither a number nor null', () => {\n expect(\n edgeConverter.convert({ type: 'related', target: { scope: 'knowledge', id: 'x' }, invalid_at: 'soon' })\n ).toFail();\n });\n\n test('fails when target is missing', () => {\n expect(edgeConverter.convert({ type: 'related' })).toFail();\n });\n\n test('fails when target is a bare string (rejects the pre-scoped format)', () => {\n expect(edgeConverter.convert({ type: 'related', target: 'ownership' })).toFail();\n });\n});\n\ndescribe('temporalConverter', () => {\n test('validates a temporal block', () => {\n expect(temporalConverter.convert({ valid_at: 1, invalid_at: null })).toSucceedWith({\n valid_at: 1,\n invalid_at: null\n });\n });\n\n test('validates an empty temporal block', () => {\n expect(temporalConverter.convert({})).toSucceedWith({});\n });\n});\n\ndescribe('envelopeConverter', () => {\n test('validates a full envelope without optional blocks', () => {\n expect(envelopeConverter.convert(validEnvelopeObject)).toSucceedAndSatisfy((envelope) => {\n expect(envelope.id).toBe('intro-to-rust');\n expect(envelope.tags).toEqual(['rust', 'systems']);\n expect(envelope.links).toHaveLength(1);\n expect(envelope.temporal).toBeUndefined();\n expect(envelope.embeddingRef).toBeUndefined();\n });\n });\n\n test('validates a temporal envelope with a string embeddingRef', () => {\n expect(\n envelopeConverter.convert({\n ...validEnvelopeObject,\n temporal: { valid_at: 10 },\n embeddingRef: 'vec-1'\n })\n ).toSucceedAndSatisfy((envelope) => {\n expect(envelope.temporal).toEqual({ valid_at: 10 });\n expect(envelope.embeddingRef).toBe('vec-1');\n });\n });\n\n test('accepts a null embeddingRef (not embedded)', () => {\n expect(envelopeConverter.convert({ ...validEnvelopeObject, embeddingRef: null })).toSucceedAndSatisfy(\n (envelope) => {\n expect(envelope.embeddingRef).toBeNull();\n }\n );\n });\n\n test('fails when embeddingRef is neither a string nor null', () => {\n expect(envelopeConverter.convert({ ...validEnvelopeObject, embeddingRef: 42 })).toFail();\n });\n\n test('rank is absent when not present', () => {\n expect(envelopeConverter.convert(validEnvelopeObject)).toSucceedAndSatisfy((envelope) => {\n expect(envelope.rank).toBeUndefined();\n });\n });\n\n test('validates and preserves a numeric rank', () => {\n expect(envelopeConverter.convert({ ...validEnvelopeObject, rank: 42 })).toSucceedAndSatisfy(\n (envelope) => {\n expect(envelope.rank).toBe(42);\n }\n );\n });\n\n test('serialize/parse round-trips rank through frontmatter', () => {\n const registry = BodyConverterRegistry.create().orThrow();\n registry.register('knowledge' as Kind, Converters.string);\n const envelope = envelopeConverter.convert({ ...validEnvelopeObject, rank: 7 }).orThrow();\n const file = serializeMemoryFile(envelope, 'body').orThrow();\n expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.rank).toBe(7);\n });\n });\n\n test('fails when rank is not a number', () => {\n expect(envelopeConverter.convert({ ...validEnvelopeObject, rank: 'high' })).toFail();\n });\n\n test('fails when a required field is missing', () => {\n const missing: Record<string, unknown> = { ...validEnvelopeObject };\n delete missing.contentHash;\n expect(envelopeConverter.convert(missing)).toFail();\n });\n});\n\ndescribe('envelopeYamlConverter', () => {\n test('parses an envelope from a YAML string', () => {\n const yaml = serializeMemoryFile(\n envelopeConverter.convert(validEnvelopeObject).orThrow(),\n 'body text'\n ).orThrow();\n const frontmatter = splitFrontmatter(yaml).orThrow().frontmatter;\n expect(envelopeYamlConverter.convert(frontmatter)).toSucceedAndSatisfy((envelope) => {\n expect(envelope.id).toBe('intro-to-rust');\n });\n });\n\n test('fails on a YAML string that is not an object', () => {\n expect(envelopeYamlConverter.convert('just a scalar')).toFail();\n });\n});\n\ndescribe('splitFrontmatter / joinFrontmatter', () => {\n test('splits a well-formed memory file', () => {\n const raw = '---\\nid: x\\nkind: knowledge\\n---\\nThe body.\\nSecond line.';\n expect(splitFrontmatter(raw)).toSucceedWith({\n frontmatter: 'id: x\\nkind: knowledge',\n body: 'The body.\\nSecond line.'\n });\n });\n\n test('strips trailing CR so CRLF-authored files parse identically to LF', () => {\n const raw = '---\\r\\nid: x\\r\\nkind: knowledge\\r\\n---\\r\\nThe body.\\r\\nSecond line.';\n expect(splitFrontmatter(raw)).toSucceedWith({\n frontmatter: 'id: x\\nkind: knowledge',\n body: 'The body.\\nSecond line.'\n });\n });\n\n test('fails when the opening delimiter is missing', () => {\n expect(splitFrontmatter('no frontmatter here')).toFailWith(/missing opening frontmatter delimiter/i);\n });\n\n test('fails when the closing delimiter is missing', () => {\n expect(splitFrontmatter('---\\nid: x\\nstill going')).toFailWith(/missing closing frontmatter delimiter/i);\n });\n\n test('join adds a trailing newline to the frontmatter when absent', () => {\n expect(joinFrontmatter('id: x', 'body')).toBe('---\\nid: x\\n---\\nbody');\n });\n\n test('join does not double the trailing newline when present', () => {\n expect(joinFrontmatter('id: x\\n', 'body')).toBe('---\\nid: x\\n---\\nbody');\n });\n\n test('split and join round-trip', () => {\n const raw = '---\\nid: x\\n---\\nbody content';\n const parts = splitFrontmatter(raw).orThrow();\n expect(joinFrontmatter(parts.frontmatter, parts.body)).toBe(raw);\n });\n});\n\ndescribe('parseMemoryFile / serializeMemoryFile', () => {\n let registry: BodyConverterRegistry;\n const knowledgeKind: Kind = 'knowledge' as Kind;\n\n beforeEach(() => {\n registry = BodyConverterRegistry.create().orThrow();\n registry.register(knowledgeKind, Converters.string);\n });\n\n test('serializes then parses a record round-trip', () => {\n const envelope = envelopeConverter.convert(validEnvelopeObject).orThrow();\n const file = serializeMemoryFile(envelope, 'The knowledge body.').orThrow();\n expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.id).toBe('intro-to-rust');\n expect(record.body).toBe('The knowledge body.');\n });\n });\n\n test('round-trips a scope-qualified edge target through the frontmatter intact', () => {\n const envelope = envelopeConverter\n .convert({\n ...validEnvelopeObject,\n links: [{ type: 'mtm-ref', target: { scope: 'conversations/conv-a', id: 'turn-3' } }]\n })\n .orThrow();\n const file = serializeMemoryFile(envelope, 'body').orThrow();\n // On-wire the target is a nested object, NOT a bare scalar.\n expect(file).toMatch(/scope: conversations\\/conv-a/);\n expect(file).toMatch(/id: turn-3/);\n expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.links).toEqual([\n { type: 'mtm-ref', target: { scope: 'conversations/conv-a', id: 'turn-3' } }\n ]);\n // Serializing the reparsed record reproduces byte-identical output.\n expect(serializeMemoryFile(record.envelope, record.body as string)).toSucceedWith(file);\n });\n });\n\n test('round-trips a scope-qualified provenance.derivedFrom through the frontmatter intact', () => {\n const envelope = envelopeConverter\n .convert({\n ...validEnvelopeObject,\n provenance: {\n source: 'host-ingest',\n derivedFrom: { scope: 'conversations/conv-a', id: 'turn-3' }\n }\n })\n .orThrow();\n const file = serializeMemoryFile(envelope, 'body').orThrow();\n // On-wire the back-reference is a nested object, NOT a bare scalar.\n expect(file).toMatch(/scope: conversations\\/conv-a/);\n expect(parseMemoryFile(file, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.provenance.derivedFrom).toEqual({\n scope: 'conversations/conv-a',\n id: 'turn-3'\n });\n expect(serializeMemoryFile(record.envelope, record.body as string)).toSucceedWith(file);\n });\n });\n\n test('two records whose derivedFrom share a stem across scopes round-trip as distinct scoped refs', () => {\n // Same idStem ('turn-3'), different scopes — exactly the ambiguity a bare\n // MemoryId could not disambiguate. Each must round-trip to ITS OWN scope.\n const makeFile = (scope: string): string => {\n const envelope = envelopeConverter\n .convert({\n ...validEnvelopeObject,\n provenance: { source: 'host-ingest', derivedFrom: { scope, id: 'turn-3' } }\n })\n .orThrow();\n return serializeMemoryFile(envelope, 'body').orThrow();\n };\n const fileA = makeFile('conversations/conv-a');\n const fileB = makeFile('conversations/conv-b');\n expect(fileA).not.toBe(fileB);\n expect(parseMemoryFile(fileA, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.provenance.derivedFrom).toEqual({\n scope: 'conversations/conv-a',\n id: 'turn-3'\n });\n });\n expect(parseMemoryFile(fileB, registry)).toSucceedAndSatisfy((record) => {\n expect(record.envelope.provenance.derivedFrom).toEqual({\n scope: 'conversations/conv-b',\n id: 'turn-3'\n });\n });\n });\n\n test('fails when the frontmatter cannot be split', () => {\n expect(parseMemoryFile('no delimiters', registry)).toFailWith(/missing opening frontmatter delimiter/i);\n });\n\n test('fails with envelope context when the envelope is invalid', () => {\n const file = '---\\nid: x\\n---\\nbody';\n expect(parseMemoryFile(file, registry)).toFailWith(/invalid envelope/i);\n });\n\n test('fails with body context when the body fails the registered converter', () => {\n const envelope = envelopeConverter.convert({ ...validEnvelopeObject, kind: 'unregistered' }).orThrow();\n const file = serializeMemoryFile(envelope, 'body').orThrow();\n expect(parseMemoryFile(file, registry)).toFailWith(/invalid body.*no converter registered/i);\n });\n\n test('serialize fails (with id context) when the envelope cannot be dumped to YAML', () => {\n const unserializable = { ...validEnvelopeObject, weird: BigInt(10) } as unknown as IMemoryEnvelope;\n expect(serializeMemoryFile(unserializable, 'body')).toFailWith(/failed to serialize envelope/i);\n });\n});\n"]}
@@ -1,2 +0,0 @@
1
- import '@fgv/ts-utils-jest';
2
- //# sourceMappingURL=memoryIndex.test.d.ts.map