comisai 1.0.10 → 1.0.12

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 (251) hide show
  1. package/README.md +3 -3
  2. package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +1 -4
  3. package/node_modules/@comis/agent/package.json +1 -1
  4. package/node_modules/@comis/channels/package.json +1 -1
  5. package/node_modules/@comis/cli/dist/wizard/steps/06-channels.js +88 -11
  6. package/node_modules/@comis/cli/dist/wizard/steps/10-write-config.js +4 -0
  7. package/node_modules/@comis/cli/dist/wizard/types.d.ts +1 -0
  8. package/node_modules/@comis/cli/package.json +1 -1
  9. package/node_modules/@comis/core/package.json +1 -1
  10. package/node_modules/@comis/daemon/package.json +1 -1
  11. package/node_modules/@comis/gateway/package.json +1 -1
  12. package/node_modules/@comis/infra/package.json +1 -1
  13. package/node_modules/@comis/memory/package.json +1 -1
  14. package/node_modules/@comis/scheduler/package.json +1 -1
  15. package/node_modules/@comis/shared/package.json +1 -1
  16. package/node_modules/@comis/skills/package.json +1 -1
  17. package/package.json +18 -18
  18. package/node_modules/@comis/core/dist/approval/approval-gate.test.d.ts +0 -1
  19. package/node_modules/@comis/core/dist/approval/approval-gate.test.js +0 -1003
  20. package/node_modules/@comis/core/dist/bootstrap.test.d.ts +0 -1
  21. package/node_modules/@comis/core/dist/bootstrap.test.js +0 -150
  22. package/node_modules/@comis/core/dist/config/backup.test.d.ts +0 -1
  23. package/node_modules/@comis/core/dist/config/backup.test.js +0 -160
  24. package/node_modules/@comis/core/dist/config/env-substitution.test.d.ts +0 -1
  25. package/node_modules/@comis/core/dist/config/env-substitution.test.js +0 -259
  26. package/node_modules/@comis/core/dist/config/field-metadata.test.d.ts +0 -1
  27. package/node_modules/@comis/core/dist/config/field-metadata.test.js +0 -72
  28. package/node_modules/@comis/core/dist/config/git-manager.test.d.ts +0 -1
  29. package/node_modules/@comis/core/dist/config/git-manager.test.js +0 -1042
  30. package/node_modules/@comis/core/dist/config/immutable-keys.test.d.ts +0 -1
  31. package/node_modules/@comis/core/dist/config/immutable-keys.test.js +0 -283
  32. package/node_modules/@comis/core/dist/config/include-resolver.test.d.ts +0 -1
  33. package/node_modules/@comis/core/dist/config/include-resolver.test.js +0 -292
  34. package/node_modules/@comis/core/dist/config/layered.test.d.ts +0 -1
  35. package/node_modules/@comis/core/dist/config/layered.test.js +0 -211
  36. package/node_modules/@comis/core/dist/config/loader.test.d.ts +0 -1
  37. package/node_modules/@comis/core/dist/config/loader.test.js +0 -300
  38. package/node_modules/@comis/core/dist/config/migrate.test.d.ts +0 -1
  39. package/node_modules/@comis/core/dist/config/migrate.test.js +0 -244
  40. package/node_modules/@comis/core/dist/config/partial-validator.test.d.ts +0 -1
  41. package/node_modules/@comis/core/dist/config/partial-validator.test.js +0 -98
  42. package/node_modules/@comis/core/dist/config/schema-agent-model.test.d.ts +0 -1
  43. package/node_modules/@comis/core/dist/config/schema-agent-model.test.js +0 -279
  44. package/node_modules/@comis/core/dist/config/schema-agent-session.test.d.ts +0 -1
  45. package/node_modules/@comis/core/dist/config/schema-agent-session.test.js +0 -242
  46. package/node_modules/@comis/core/dist/config/schema-agent.test.d.ts +0 -1
  47. package/node_modules/@comis/core/dist/config/schema-agent.test.js +0 -645
  48. package/node_modules/@comis/core/dist/config/schema-channel.test.d.ts +0 -1
  49. package/node_modules/@comis/core/dist/config/schema-channel.test.js +0 -341
  50. package/node_modules/@comis/core/dist/config/schema-coalescer.test.d.ts +0 -1
  51. package/node_modules/@comis/core/dist/config/schema-coalescer.test.js +0 -51
  52. package/node_modules/@comis/core/dist/config/schema-context-engine.test.d.ts +0 -1
  53. package/node_modules/@comis/core/dist/config/schema-context-engine.test.js +0 -797
  54. package/node_modules/@comis/core/dist/config/schema-context-guard.test.d.ts +0 -1
  55. package/node_modules/@comis/core/dist/config/schema-context-guard.test.js +0 -111
  56. package/node_modules/@comis/core/dist/config/schema-daemon.test.d.ts +0 -1
  57. package/node_modules/@comis/core/dist/config/schema-daemon.test.js +0 -107
  58. package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.d.ts +0 -1
  59. package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.js +0 -51
  60. package/node_modules/@comis/core/dist/config/schema-documentation.test.d.ts +0 -1
  61. package/node_modules/@comis/core/dist/config/schema-documentation.test.js +0 -63
  62. package/node_modules/@comis/core/dist/config/schema-gateway.test.d.ts +0 -1
  63. package/node_modules/@comis/core/dist/config/schema-gateway.test.js +0 -219
  64. package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.d.ts +0 -1
  65. package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.js +0 -41
  66. package/node_modules/@comis/core/dist/config/schema-integrations.test.d.ts +0 -1
  67. package/node_modules/@comis/core/dist/config/schema-integrations.test.js +0 -92
  68. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.d.ts +0 -1
  69. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.js +0 -61
  70. package/node_modules/@comis/core/dist/config/schema-misc.test.d.ts +0 -1
  71. package/node_modules/@comis/core/dist/config/schema-misc.test.js +0 -394
  72. package/node_modules/@comis/core/dist/config/schema-observability.test.d.ts +0 -1
  73. package/node_modules/@comis/core/dist/config/schema-observability.test.js +0 -76
  74. package/node_modules/@comis/core/dist/config/schema-providers.test.d.ts +0 -1
  75. package/node_modules/@comis/core/dist/config/schema-providers.test.js +0 -294
  76. package/node_modules/@comis/core/dist/config/schema-queue.test.d.ts +0 -1
  77. package/node_modules/@comis/core/dist/config/schema-queue.test.js +0 -234
  78. package/node_modules/@comis/core/dist/config/schema-response-prefix.test.d.ts +0 -1
  79. package/node_modules/@comis/core/dist/config/schema-response-prefix.test.js +0 -36
  80. package/node_modules/@comis/core/dist/config/schema-security.test.d.ts +0 -1
  81. package/node_modules/@comis/core/dist/config/schema-security.test.js +0 -54
  82. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.d.ts +0 -1
  83. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.js +0 -60
  84. package/node_modules/@comis/core/dist/config/schema-serializer.test.d.ts +0 -1
  85. package/node_modules/@comis/core/dist/config/schema-serializer.test.js +0 -73
  86. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.d.ts +0 -1
  87. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.js +0 -39
  88. package/node_modules/@comis/core/dist/context/context.test.d.ts +0 -1
  89. package/node_modules/@comis/core/dist/context/context.test.js +0 -276
  90. package/node_modules/@comis/core/dist/domain/agent-response.test.d.ts +0 -1
  91. package/node_modules/@comis/core/dist/domain/agent-response.test.js +0 -159
  92. package/node_modules/@comis/core/dist/domain/credential-mapping.test.d.ts +0 -1
  93. package/node_modules/@comis/core/dist/domain/credential-mapping.test.js +0 -135
  94. package/node_modules/@comis/core/dist/domain/delivery-origin.test.d.ts +0 -1
  95. package/node_modules/@comis/core/dist/domain/delivery-origin.test.js +0 -68
  96. package/node_modules/@comis/core/dist/domain/execution-graph.test.d.ts +0 -1
  97. package/node_modules/@comis/core/dist/domain/execution-graph.test.js +0 -441
  98. package/node_modules/@comis/core/dist/domain/memory-entry.test.d.ts +0 -1
  99. package/node_modules/@comis/core/dist/domain/memory-entry.test.js +0 -193
  100. package/node_modules/@comis/core/dist/domain/normalized-message.test.d.ts +0 -1
  101. package/node_modules/@comis/core/dist/domain/normalized-message.test.js +0 -255
  102. package/node_modules/@comis/core/dist/domain/session-key.test.d.ts +0 -1
  103. package/node_modules/@comis/core/dist/domain/session-key.test.js +0 -291
  104. package/node_modules/@comis/core/dist/domain/subagent-context-config.test.d.ts +0 -1
  105. package/node_modules/@comis/core/dist/domain/subagent-context-config.test.js +0 -131
  106. package/node_modules/@comis/core/dist/domain/subagent-context-types.test.d.ts +0 -1
  107. package/node_modules/@comis/core/dist/domain/subagent-context-types.test.js +0 -182
  108. package/node_modules/@comis/core/dist/event-bus/bus.test.d.ts +0 -1
  109. package/node_modules/@comis/core/dist/event-bus/bus.test.js +0 -152
  110. package/node_modules/@comis/core/dist/event-bus/events-agent.test.d.ts +0 -1
  111. package/node_modules/@comis/core/dist/event-bus/events-agent.test.js +0 -409
  112. package/node_modules/@comis/core/dist/event-bus/events-channel.test.d.ts +0 -1
  113. package/node_modules/@comis/core/dist/event-bus/events-channel.test.js +0 -240
  114. package/node_modules/@comis/core/dist/event-bus/events-infra.test.d.ts +0 -1
  115. package/node_modules/@comis/core/dist/event-bus/events-infra.test.js +0 -416
  116. package/node_modules/@comis/core/dist/event-bus/events-messaging.test.d.ts +0 -1
  117. package/node_modules/@comis/core/dist/event-bus/events-messaging.test.js +0 -433
  118. package/node_modules/@comis/core/dist/event-bus/events.test.d.ts +0 -1
  119. package/node_modules/@comis/core/dist/event-bus/events.test.js +0 -93
  120. package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.d.ts +0 -1
  121. package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.js +0 -29
  122. package/node_modules/@comis/core/dist/hooks/hook-runner.test.d.ts +0 -1
  123. package/node_modules/@comis/core/dist/hooks/hook-runner.test.js +0 -490
  124. package/node_modules/@comis/core/dist/hooks/hook-strategies.test.d.ts +0 -1
  125. package/node_modules/@comis/core/dist/hooks/hook-strategies.test.js +0 -209
  126. package/node_modules/@comis/core/dist/hooks/integration.test.d.ts +0 -1
  127. package/node_modules/@comis/core/dist/hooks/integration.test.js +0 -235
  128. package/node_modules/@comis/core/dist/hooks/plugin-registry.test.d.ts +0 -1
  129. package/node_modules/@comis/core/dist/hooks/plugin-registry.test.js +0 -470
  130. package/node_modules/@comis/core/dist/load-env.test.d.ts +0 -1
  131. package/node_modules/@comis/core/dist/load-env.test.js +0 -21
  132. package/node_modules/@comis/core/dist/security/action-classifier.test.d.ts +0 -1
  133. package/node_modules/@comis/core/dist/security/action-classifier.test.js +0 -298
  134. package/node_modules/@comis/core/dist/security/audit-aggregator.test.d.ts +0 -1
  135. package/node_modules/@comis/core/dist/security/audit-aggregator.test.js +0 -128
  136. package/node_modules/@comis/core/dist/security/audit.test.d.ts +0 -1
  137. package/node_modules/@comis/core/dist/security/audit.test.js +0 -154
  138. package/node_modules/@comis/core/dist/security/canary-token.test.d.ts +0 -1
  139. package/node_modules/@comis/core/dist/security/canary-token.test.js +0 -45
  140. package/node_modules/@comis/core/dist/security/config-redaction.test.d.ts +0 -1
  141. package/node_modules/@comis/core/dist/security/config-redaction.test.js +0 -107
  142. package/node_modules/@comis/core/dist/security/external-content.test.d.ts +0 -1
  143. package/node_modules/@comis/core/dist/security/external-content.test.js +0 -210
  144. package/node_modules/@comis/core/dist/security/injection-patterns.test.d.ts +0 -1
  145. package/node_modules/@comis/core/dist/security/injection-patterns.test.js +0 -213
  146. package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.d.ts +0 -1
  147. package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.js +0 -194
  148. package/node_modules/@comis/core/dist/security/input-guard.test.d.ts +0 -1
  149. package/node_modules/@comis/core/dist/security/input-guard.test.js +0 -215
  150. package/node_modules/@comis/core/dist/security/input-security-guard.test.d.ts +0 -1
  151. package/node_modules/@comis/core/dist/security/input-security-guard.test.js +0 -215
  152. package/node_modules/@comis/core/dist/security/input-validator.test.d.ts +0 -1
  153. package/node_modules/@comis/core/dist/security/input-validator.test.js +0 -133
  154. package/node_modules/@comis/core/dist/security/log-sanitizer.test.d.ts +0 -1
  155. package/node_modules/@comis/core/dist/security/log-sanitizer.test.js +0 -260
  156. package/node_modules/@comis/core/dist/security/memory-write-validator.test.d.ts +0 -1
  157. package/node_modules/@comis/core/dist/security/memory-write-validator.test.js +0 -62
  158. package/node_modules/@comis/core/dist/security/output-guard.test.d.ts +0 -1
  159. package/node_modules/@comis/core/dist/security/output-guard.test.js +0 -397
  160. package/node_modules/@comis/core/dist/security/safe-path.test.d.ts +0 -1
  161. package/node_modules/@comis/core/dist/security/safe-path.test.js +0 -95
  162. package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.d.ts +0 -1
  163. package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.js +0 -231
  164. package/node_modules/@comis/core/dist/security/secret-access.test.d.ts +0 -1
  165. package/node_modules/@comis/core/dist/security/secret-access.test.js +0 -41
  166. package/node_modules/@comis/core/dist/security/secret-crypto.test.d.ts +0 -1
  167. package/node_modules/@comis/core/dist/security/secret-crypto.test.js +0 -113
  168. package/node_modules/@comis/core/dist/security/secret-manager.test.d.ts +0 -1
  169. package/node_modules/@comis/core/dist/security/secret-manager.test.js +0 -394
  170. package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.d.ts +0 -1
  171. package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.js +0 -268
  172. package/node_modules/@comis/core/dist/security/secrets-audit.test.d.ts +0 -10
  173. package/node_modules/@comis/core/dist/security/secrets-audit.test.js +0 -295
  174. package/node_modules/@comis/core/dist/security/ssrf-guard.test.d.ts +0 -1
  175. package/node_modules/@comis/core/dist/security/ssrf-guard.test.js +0 -127
  176. package/node_modules/@comis/core/dist/security/token-generator.test.d.ts +0 -1
  177. package/node_modules/@comis/core/dist/security/token-generator.test.js +0 -35
  178. package/node_modules/@comis/core/dist/tool-metadata.test.d.ts +0 -1
  179. package/node_modules/@comis/core/dist/tool-metadata.test.js +0 -112
  180. package/node_modules/@comis/memory/dist/compaction.test.d.ts +0 -1
  181. package/node_modules/@comis/memory/dist/compaction.test.js +0 -298
  182. package/node_modules/@comis/memory/dist/context-schema.test.d.ts +0 -1
  183. package/node_modules/@comis/memory/dist/context-schema.test.js +0 -246
  184. package/node_modules/@comis/memory/dist/context-store.test.d.ts +0 -1
  185. package/node_modules/@comis/memory/dist/context-store.test.js +0 -708
  186. package/node_modules/@comis/memory/dist/credential-mapping-schema.test.d.ts +0 -7
  187. package/node_modules/@comis/memory/dist/credential-mapping-schema.test.js +0 -73
  188. package/node_modules/@comis/memory/dist/credential-mapping-store.test.d.ts +0 -8
  189. package/node_modules/@comis/memory/dist/credential-mapping-store.test.js +0 -340
  190. package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.d.ts +0 -1
  191. package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.js +0 -165
  192. package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.d.ts +0 -1
  193. package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.js +0 -263
  194. package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.d.ts +0 -1
  195. package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.js +0 -202
  196. package/node_modules/@comis/memory/dist/embedding-cache-lru.test.d.ts +0 -1
  197. package/node_modules/@comis/memory/dist/embedding-cache-lru.test.js +0 -241
  198. package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.d.ts +0 -8
  199. package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.js +0 -678
  200. package/node_modules/@comis/memory/dist/embedding-cache.test.d.ts +0 -1
  201. package/node_modules/@comis/memory/dist/embedding-cache.test.js +0 -213
  202. package/node_modules/@comis/memory/dist/embedding-fingerprint.test.d.ts +0 -1
  203. package/node_modules/@comis/memory/dist/embedding-fingerprint.test.js +0 -87
  204. package/node_modules/@comis/memory/dist/embedding-hash.test.d.ts +0 -1
  205. package/node_modules/@comis/memory/dist/embedding-hash.test.js +0 -31
  206. package/node_modules/@comis/memory/dist/embedding-integration.test.d.ts +0 -8
  207. package/node_modules/@comis/memory/dist/embedding-integration.test.js +0 -232
  208. package/node_modules/@comis/memory/dist/embedding-provider-factory.test.d.ts +0 -1
  209. package/node_modules/@comis/memory/dist/embedding-provider-factory.test.js +0 -176
  210. package/node_modules/@comis/memory/dist/embedding-provider-local.test.d.ts +0 -8
  211. package/node_modules/@comis/memory/dist/embedding-provider-local.test.js +0 -76
  212. package/node_modules/@comis/memory/dist/embedding-provider-openai.test.d.ts +0 -8
  213. package/node_modules/@comis/memory/dist/embedding-provider-openai.test.js +0 -100
  214. package/node_modules/@comis/memory/dist/embedding-queue.test.d.ts +0 -1
  215. package/node_modules/@comis/memory/dist/embedding-queue.test.js +0 -236
  216. package/node_modules/@comis/memory/dist/hybrid-search.test.d.ts +0 -1
  217. package/node_modules/@comis/memory/dist/hybrid-search.test.js +0 -476
  218. package/node_modules/@comis/memory/dist/identity-link-store.test.d.ts +0 -1
  219. package/node_modules/@comis/memory/dist/identity-link-store.test.js +0 -88
  220. package/node_modules/@comis/memory/dist/memory-api.test.d.ts +0 -1
  221. package/node_modules/@comis/memory/dist/memory-api.test.js +0 -495
  222. package/node_modules/@comis/memory/dist/memory-concurrency.test.d.ts +0 -20
  223. package/node_modules/@comis/memory/dist/memory-concurrency.test.js +0 -222
  224. package/node_modules/@comis/memory/dist/named-graph-store.test.d.ts +0 -1
  225. package/node_modules/@comis/memory/dist/named-graph-store.test.js +0 -227
  226. package/node_modules/@comis/memory/dist/observability-store.test.d.ts +0 -1
  227. package/node_modules/@comis/memory/dist/observability-store.test.js +0 -704
  228. package/node_modules/@comis/memory/dist/row-mapper.test.d.ts +0 -1
  229. package/node_modules/@comis/memory/dist/row-mapper.test.js +0 -409
  230. package/node_modules/@comis/memory/dist/schema.test.d.ts +0 -1
  231. package/node_modules/@comis/memory/dist/schema.test.js +0 -240
  232. package/node_modules/@comis/memory/dist/secret-store-schema.test.d.ts +0 -7
  233. package/node_modules/@comis/memory/dist/secret-store-schema.test.js +0 -90
  234. package/node_modules/@comis/memory/dist/session-store.test.d.ts +0 -1
  235. package/node_modules/@comis/memory/dist/session-store.test.js +0 -262
  236. package/node_modules/@comis/memory/dist/setup-secrets.test.d.ts +0 -1
  237. package/node_modules/@comis/memory/dist/setup-secrets.test.js +0 -140
  238. package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.d.ts +0 -1
  239. package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.js +0 -888
  240. package/node_modules/@comis/memory/dist/sqlite-secret-store.test.d.ts +0 -8
  241. package/node_modules/@comis/memory/dist/sqlite-secret-store.test.js +0 -245
  242. package/node_modules/@comis/shared/dist/abort.test.d.ts +0 -1
  243. package/node_modules/@comis/shared/dist/abort.test.js +0 -71
  244. package/node_modules/@comis/shared/dist/result.test.d.ts +0 -1
  245. package/node_modules/@comis/shared/dist/result.test.js +0 -178
  246. package/node_modules/@comis/shared/dist/suppress-error.test.d.ts +0 -1
  247. package/node_modules/@comis/shared/dist/suppress-error.test.js +0 -50
  248. package/node_modules/@comis/shared/dist/timeout.test.d.ts +0 -1
  249. package/node_modules/@comis/shared/dist/timeout.test.js +0 -75
  250. package/node_modules/@comis/shared/dist/ttl-cache.test.d.ts +0 -1
  251. package/node_modules/@comis/shared/dist/ttl-cache.test.js +0 -81
@@ -1,213 +0,0 @@
1
- import { ok, err } from "@comis/shared";
2
- import { describe, it, expect, vi } from "vitest";
3
- import { createCachedEmbeddingPort } from "./embedding-cache.js";
4
- const DIMS = 4;
5
- /** Create a mock EmbeddingPort with vi.fn() methods for call tracking. */
6
- function createMockPort() {
7
- const embedFn = vi.fn(async (text) => {
8
- const vec = new Array(DIMS).fill(0);
9
- for (let i = 0; i < text.length && i < DIMS; i++) {
10
- vec[i] = text.charCodeAt(i) / 256;
11
- }
12
- return ok(vec);
13
- });
14
- const embedBatchFn = vi.fn(async (texts) => {
15
- const vecs = [];
16
- for (const t of texts) {
17
- const vec = new Array(DIMS).fill(0);
18
- for (let i = 0; i < t.length && i < DIMS; i++) {
19
- vec[i] = t.charCodeAt(i) / 256;
20
- }
21
- vecs.push(vec);
22
- }
23
- return ok(vecs);
24
- });
25
- return {
26
- provider: "test",
27
- dimensions: DIMS,
28
- modelId: "test-model",
29
- embed: embedFn,
30
- embedBatch: embedBatchFn,
31
- embedFn,
32
- embedBatchFn,
33
- };
34
- }
35
- describe("createCachedEmbeddingPort", () => {
36
- it("first embed call hits inner, second returns from cache", async () => {
37
- const mock = createMockPort();
38
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
39
- const r1 = await cached.embed("hello");
40
- expect(r1.ok).toBe(true);
41
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
42
- const r2 = await cached.embed("hello");
43
- expect(r2.ok).toBe(true);
44
- // Inner should NOT be called again
45
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
46
- // Both results should be identical
47
- if (r1.ok && r2.ok) {
48
- expect(r1.value).toEqual(r2.value);
49
- }
50
- });
51
- it("embedBatch with mix of cached and uncached only sends misses to inner", async () => {
52
- const mock = createMockPort();
53
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
54
- // Pre-cache "alpha" via single embed
55
- await cached.embed("alpha");
56
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
57
- // Now embedBatch with alpha (cached) + beta (uncached) + gamma (uncached)
58
- const result = await cached.embedBatch(["alpha", "beta", "gamma"]);
59
- expect(result.ok).toBe(true);
60
- // Inner embedBatch should only receive the uncached texts
61
- expect(mock.embedBatchFn).toHaveBeenCalledTimes(1);
62
- expect(mock.embedBatchFn).toHaveBeenCalledWith(["beta", "gamma"]);
63
- // Result should have 3 vectors
64
- if (result.ok) {
65
- expect(result.value).toHaveLength(3);
66
- }
67
- });
68
- it("embedBatch with all cached returns immediately without calling inner", async () => {
69
- const mock = createMockPort();
70
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
71
- // Pre-cache all texts via single embeds
72
- await cached.embed("one");
73
- await cached.embed("two");
74
- mock.embedFn.mockClear();
75
- mock.embedBatchFn.mockClear();
76
- const result = await cached.embedBatch(["one", "two"]);
77
- expect(result.ok).toBe(true);
78
- // Neither embed nor embedBatch should be called
79
- expect(mock.embedFn).not.toHaveBeenCalled();
80
- expect(mock.embedBatchFn).not.toHaveBeenCalled();
81
- if (result.ok) {
82
- expect(result.value).toHaveLength(2);
83
- }
84
- });
85
- it("cache respects maxEntries (oldest evicted)", async () => {
86
- const mock = createMockPort();
87
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 2 });
88
- // Fill cache to max
89
- await cached.embed("first");
90
- await cached.embed("second");
91
- expect(mock.embedFn).toHaveBeenCalledTimes(2);
92
- // Add a third entry, which should evict "first"
93
- await cached.embed("third");
94
- expect(mock.embedFn).toHaveBeenCalledTimes(3);
95
- // "second" and "third" should be cached
96
- mock.embedFn.mockClear();
97
- await cached.embed("second");
98
- await cached.embed("third");
99
- expect(mock.embedFn).not.toHaveBeenCalled();
100
- // "first" should have been evicted -- must call inner again
101
- await cached.embed("first");
102
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
103
- });
104
- it("embed error is not cached", async () => {
105
- const mock = createMockPort();
106
- // Make first call fail
107
- mock.embedFn.mockResolvedValueOnce(err(new Error("provider down")));
108
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
109
- const r1 = await cached.embed("failing");
110
- expect(r1.ok).toBe(false);
111
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
112
- // Now make inner succeed
113
- mock.embedFn.mockResolvedValueOnce(ok([1, 2, 3, 4]));
114
- const r2 = await cached.embed("failing");
115
- expect(r2.ok).toBe(true);
116
- // Inner should be called again since error was not cached
117
- expect(mock.embedFn).toHaveBeenCalledTimes(2);
118
- });
119
- it("preserves dimensions and modelId from inner port", () => {
120
- const mock = createMockPort();
121
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
122
- expect(cached.dimensions).toBe(DIMS);
123
- expect(cached.modelId).toBe("test-model");
124
- });
125
- it("embedBatch propagates inner error", async () => {
126
- const mock = createMockPort();
127
- mock.embedBatchFn.mockResolvedValueOnce(err(new Error("batch failure")));
128
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
129
- const result = await cached.embedBatch(["a", "b"]);
130
- expect(result.ok).toBe(false);
131
- if (!result.ok) {
132
- expect(result.error.message).toBe("batch failure");
133
- }
134
- });
135
- describe("getCacheStats", () => {
136
- it("returns zeroed stats on fresh cache", () => {
137
- const mock = createMockPort();
138
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
139
- const stats = cached.getCacheStats();
140
- expect(stats).toEqual({
141
- entries: 0,
142
- maxEntries: 100,
143
- hitRate: 0,
144
- hits: 0,
145
- misses: 0,
146
- provider: "test",
147
- });
148
- });
149
- it("tracks miss on first embed and hit on second", async () => {
150
- const mock = createMockPort();
151
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
152
- await cached.embed("hello");
153
- let stats = cached.getCacheStats();
154
- expect(stats.misses).toBe(1);
155
- expect(stats.hits).toBe(0);
156
- expect(stats.entries).toBe(1);
157
- await cached.embed("hello");
158
- stats = cached.getCacheStats();
159
- expect(stats.hits).toBe(1);
160
- expect(stats.misses).toBe(1);
161
- expect(stats.hitRate).toBe(0.5);
162
- expect(stats.entries).toBe(1);
163
- });
164
- it("tracks hits and misses in embedBatch", async () => {
165
- const mock = createMockPort();
166
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
167
- // Pre-cache "alpha"
168
- await cached.embed("alpha");
169
- // stats: 1 miss, 0 hits
170
- // embedBatch with alpha (hit) + beta (miss) + gamma (miss)
171
- await cached.embedBatch(["alpha", "beta", "gamma"]);
172
- const stats = cached.getCacheStats();
173
- // embed: 1 miss
174
- // embedBatch: 1 hit + 2 misses
175
- expect(stats.hits).toBe(1);
176
- expect(stats.misses).toBe(3);
177
- expect(stats.entries).toBe(3);
178
- expect(stats.hitRate).toBe(1 / 4);
179
- });
180
- });
181
- describe("TTL support", () => {
182
- it("expires entries after ttlMs", async () => {
183
- const mock = createMockPort();
184
- const cached = createCachedEmbeddingPort(mock, {
185
- maxEntries: 100,
186
- ttlMs: 100,
187
- });
188
- // First call -- inner called
189
- await cached.embed("hello");
190
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
191
- // Immediate second call -- cache hit, inner NOT called
192
- await cached.embed("hello");
193
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
194
- // Wait for TTL to expire
195
- await new Promise((r) => setTimeout(r, 150));
196
- // After TTL -- inner called again
197
- await cached.embed("hello");
198
- expect(mock.embedFn).toHaveBeenCalledTimes(2);
199
- });
200
- it("entries persist without TTL (LRU only)", async () => {
201
- const mock = createMockPort();
202
- const cached = createCachedEmbeddingPort(mock, { maxEntries: 100 });
203
- // First call -- inner called
204
- await cached.embed("hello");
205
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
206
- // Wait longer than the TTL test above
207
- await new Promise((r) => setTimeout(r, 200));
208
- // Still cached -- inner NOT called (no TTL, pure LRU)
209
- await cached.embed("hello");
210
- expect(mock.embedFn).toHaveBeenCalledTimes(1);
211
- });
212
- });
213
- });
@@ -1,87 +0,0 @@
1
- import { ok } from "@comis/shared";
2
- import Database from "better-sqlite3";
3
- import { describe, it, expect, beforeEach, vi } from "vitest";
4
- import { createFingerprintManager } from "./embedding-fingerprint.js";
5
- /** Create a minimal mock EmbeddingPort with given modelId and dimensions. */
6
- function stubProvider(modelId, dimensions) {
7
- return {
8
- provider: "test",
9
- modelId,
10
- dimensions,
11
- embed: vi.fn().mockResolvedValue(ok(new Array(dimensions).fill(0))),
12
- embedBatch: vi.fn().mockResolvedValue(ok([])),
13
- };
14
- }
15
- describe("createFingerprintManager", () => {
16
- let db;
17
- beforeEach(() => {
18
- db = new Database(":memory:");
19
- const mgr = createFingerprintManager(db);
20
- mgr.ensureTable();
21
- });
22
- it("getCurrent returns null before any save", () => {
23
- const mgr = createFingerprintManager(db);
24
- expect(mgr.getCurrent()).toBeNull();
25
- });
26
- it("getCurrent returns saved fingerprint after save", () => {
27
- const mgr = createFingerprintManager(db);
28
- const provider = stubProvider("text-embedding-3-small", 1536);
29
- const fp = mgr.computeFingerprint(provider);
30
- mgr.save(fp);
31
- const stored = mgr.getCurrent();
32
- expect(stored).not.toBeNull();
33
- expect(stored.modelId).toBe("text-embedding-3-small");
34
- expect(stored.dimensions).toBe(1536);
35
- expect(stored.hash).toBe(fp.hash);
36
- });
37
- it("first run: hasChanged returns false (no stored fingerprint)", () => {
38
- const mgr = createFingerprintManager(db);
39
- const provider = stubProvider("text-embedding-3-small", 1536);
40
- // No fingerprint saved yet
41
- expect(mgr.hasChanged(provider)).toBe(false);
42
- });
43
- it("same provider: hasChanged returns false after save", () => {
44
- const mgr = createFingerprintManager(db);
45
- const provider = stubProvider("text-embedding-3-small", 1536);
46
- mgr.save(mgr.computeFingerprint(provider));
47
- expect(mgr.hasChanged(provider)).toBe(false);
48
- });
49
- it("changed model: hasChanged returns true", () => {
50
- const mgr = createFingerprintManager(db);
51
- const providerA = stubProvider("model-a", 768);
52
- const providerB = stubProvider("model-b", 768);
53
- mgr.save(mgr.computeFingerprint(providerA));
54
- expect(mgr.hasChanged(providerB)).toBe(true);
55
- });
56
- it("changed dimensions: hasChanged returns true", () => {
57
- const mgr = createFingerprintManager(db);
58
- const provider768 = stubProvider("text-embedding-3-small", 768);
59
- const provider1536 = stubProvider("text-embedding-3-small", 1536);
60
- mgr.save(mgr.computeFingerprint(provider768));
61
- expect(mgr.hasChanged(provider1536)).toBe(true);
62
- });
63
- it("computeFingerprint produces deterministic hash", () => {
64
- const mgr = createFingerprintManager(db);
65
- const provider = stubProvider("nomic-embed-text", 384);
66
- const fp1 = mgr.computeFingerprint(provider);
67
- const fp2 = mgr.computeFingerprint(provider);
68
- expect(fp1.hash).toBe(fp2.hash);
69
- expect(fp1.modelId).toBe("nomic-embed-text");
70
- expect(fp1.dimensions).toBe(384);
71
- });
72
- it("save overwrites previous fingerprint", () => {
73
- const mgr = createFingerprintManager(db);
74
- const providerA = stubProvider("model-a", 768);
75
- const providerB = stubProvider("model-b", 1536);
76
- mgr.save(mgr.computeFingerprint(providerA));
77
- expect(mgr.getCurrent().modelId).toBe("model-a");
78
- mgr.save(mgr.computeFingerprint(providerB));
79
- expect(mgr.getCurrent().modelId).toBe("model-b");
80
- expect(mgr.getCurrent().dimensions).toBe(1536);
81
- });
82
- it("ensureTable is idempotent (safe to call multiple times)", () => {
83
- const mgr = createFingerprintManager(db);
84
- // Already called once in beforeEach; calling again should not throw
85
- expect(() => mgr.ensureTable()).not.toThrow();
86
- });
87
- });
@@ -1,31 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { describe, it, expect } from "vitest";
3
- import { computeEmbeddingIdentityHash } from "./embedding-hash.js";
4
- describe("computeEmbeddingIdentityHash", () => {
5
- it("produces SHA-256 of modelId:dimensions", () => {
6
- const expected = createHash("sha256")
7
- .update("text-embedding-3-small:1536")
8
- .digest("hex");
9
- expect(computeEmbeddingIdentityHash("text-embedding-3-small", 1536)).toBe(expected);
10
- });
11
- it("returns full 64-char hex (no truncation)", () => {
12
- const hash = computeEmbeddingIdentityHash("any-model", 768);
13
- expect(hash).toHaveLength(64);
14
- expect(hash).toMatch(/^[0-9a-f]{64}$/);
15
- });
16
- it("is deterministic (same input = same output)", () => {
17
- const a = computeEmbeddingIdentityHash("nomic-embed-text", 384);
18
- const b = computeEmbeddingIdentityHash("nomic-embed-text", 384);
19
- expect(a).toBe(b);
20
- });
21
- it("differs when modelId differs", () => {
22
- const a = computeEmbeddingIdentityHash("model-a", 768);
23
- const b = computeEmbeddingIdentityHash("model-b", 768);
24
- expect(a).not.toBe(b);
25
- });
26
- it("differs when dimensions differ", () => {
27
- const a = computeEmbeddingIdentityHash("text-embedding-3-small", 768);
28
- const b = computeEmbeddingIdentityHash("text-embedding-3-small", 1536);
29
- expect(a).not.toBe(b);
30
- });
31
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * Integration tests for the full embedding pipeline.
3
- *
4
- * Exercises the end-to-end flow: config -> provider creation -> cache wrapping ->
5
- * fingerprint check -> batch indexing -> queue wiring -> memory adapter with vector
6
- * search. Uses mock EmbeddingPort (no actual node-llama-cpp or OpenAI calls).
7
- */
8
- export {};
@@ -1,232 +0,0 @@
1
- /**
2
- * Integration tests for the full embedding pipeline.
3
- *
4
- * Exercises the end-to-end flow: config -> provider creation -> cache wrapping ->
5
- * fingerprint check -> batch indexing -> queue wiring -> memory adapter with vector
6
- * search. Uses mock EmbeddingPort (no actual node-llama-cpp or OpenAI calls).
7
- */
8
- import { ok, err } from "@comis/shared";
9
- import Database from "better-sqlite3";
10
- import { describe, it, expect, vi, beforeEach } from "vitest";
11
- import { initSchema, isVecAvailable } from "./schema.js";
12
- import { SqliteMemoryAdapter } from "./sqlite-memory-adapter.js";
13
- import { createCachedEmbeddingPort } from "./embedding-cache-lru.js";
14
- import { createFingerprintManager } from "./embedding-fingerprint.js";
15
- import { createBatchIndexer } from "./embedding-batch-indexer.js";
16
- import { createEmbeddingQueue } from "./embedding-queue.js";
17
- const DIMS = 4;
18
- // ---------------------------------------------------------------------------
19
- // Helpers
20
- // ---------------------------------------------------------------------------
21
- /**
22
- * Create a mock EmbeddingPort with deterministic fake vectors.
23
- * Vectors are based on character codes for uniqueness per input text.
24
- */
25
- function createMockEmbeddingPort(dimensions = DIMS, modelId = "test-model") {
26
- const embedFn = vi.fn(async (text) => {
27
- const vec = new Array(dimensions).fill(0.1);
28
- for (let i = 0; i < text.length && i < dimensions; i++) {
29
- vec[i] = text.charCodeAt(i) / 256;
30
- }
31
- return ok(vec);
32
- });
33
- const embedBatchFn = vi.fn(async (texts) => {
34
- const vecs = texts.map((t) => {
35
- const vec = new Array(dimensions).fill(0.1);
36
- for (let i = 0; i < t.length && i < dimensions; i++) {
37
- vec[i] = t.charCodeAt(i) / 256;
38
- }
39
- return vec;
40
- });
41
- return ok(vecs);
42
- });
43
- return {
44
- provider: "test",
45
- dimensions,
46
- modelId,
47
- embed: embedFn,
48
- embedBatch: embedBatchFn,
49
- embedFn,
50
- embedBatchFn,
51
- };
52
- }
53
- /** Insert a minimal memory row directly into the DB. */
54
- function insertMemory(db, id, content, hasEmbedding = 0) {
55
- db.prepare(`INSERT INTO memories (id, tenant_id, agent_id, user_id, content, trust_level, memory_type, source_who, tags, created_at, has_embedding)
56
- VALUES (?, 'default', 'default', 'u1', ?, 'learned', 'semantic', 'agent', '[]', ?, ?)`).run(id, content, Date.now(), hasEmbedding);
57
- }
58
- // ---------------------------------------------------------------------------
59
- // Integration Tests
60
- // ---------------------------------------------------------------------------
61
- describe("Embedding pipeline integration", () => {
62
- let db;
63
- beforeEach(() => {
64
- db = new Database(":memory:");
65
- initSchema(db, DIMS);
66
- });
67
- it("full pipeline: store -> batch index -> search returns results", async () => {
68
- const mockPort = createMockEmbeddingPort(DIMS, "test-embed-v1");
69
- // Create adapter with embedding port
70
- const adapter = new SqliteMemoryAdapter({ dbPath: ":memory:", walMode: false, embeddingDimensions: DIMS }, mockPort);
71
- // Use the adapter's internal DB (which has the schema already initialized)
72
- const adapterDb = adapter.getDb();
73
- // Store 3 memories via adapter
74
- const now = Date.now();
75
- for (let i = 1; i <= 3; i++) {
76
- await adapter.store({
77
- id: `mem-${i}`,
78
- tenantId: "default",
79
- agentId: "default",
80
- userId: "u1",
81
- content: `Test memory content number ${i}`,
82
- trustLevel: "learned",
83
- source: { who: "agent" },
84
- tags: ["test"],
85
- createdAt: now + i,
86
- });
87
- }
88
- // Create batch indexer and embed all unembedded memories
89
- const batchIndexer = createBatchIndexer(adapterDb, mockPort, { batchSize: 10 });
90
- const indexResult = await batchIndexer.indexUnembedded();
91
- expect(indexResult.indexed).toBe(3);
92
- expect(indexResult.failed).toBe(0);
93
- // Search via adapter (uses embeddingPort.embed for query vector)
94
- const sessionKey = { tenantId: "default", userId: "u1", channelId: "test" };
95
- const searchResult = await adapter.search(sessionKey, "Test memory content", { limit: 10 });
96
- expect(searchResult.ok).toBe(true);
97
- if (searchResult.ok) {
98
- // Should return results (FTS5 at minimum, possibly hybrid if vec is available)
99
- expect(searchResult.value.length).toBeGreaterThan(0);
100
- }
101
- });
102
- it("cache prevents redundant embedding calls", async () => {
103
- const mockPort = createMockEmbeddingPort(DIMS, "cached-model");
104
- // Wrap with cache
105
- const cached = createCachedEmbeddingPort(mockPort, { maxEntries: 100 });
106
- // Call embed with same text twice
107
- const result1 = await cached.embed("same text for caching");
108
- const result2 = await cached.embed("same text for caching");
109
- expect(result1.ok).toBe(true);
110
- expect(result2.ok).toBe(true);
111
- // Inner embed should only be called once (second was cache hit)
112
- expect(mockPort.embedFn).toHaveBeenCalledTimes(1);
113
- // Both results should be identical
114
- if (result1.ok && result2.ok) {
115
- expect(result1.value).toEqual(result2.value);
116
- }
117
- });
118
- it("fingerprint detects model change and triggers reindex", async () => {
119
- const fingerprintMgr = createFingerprintManager(db);
120
- fingerprintMgr.ensureTable();
121
- // Create mock port A (4 dims, model-a)
122
- const portA = createMockEmbeddingPort(4, "model-a");
123
- // Save fingerprint for port A
124
- fingerprintMgr.save(fingerprintMgr.computeFingerprint(portA));
125
- // Verify no change detected for same port
126
- expect(fingerprintMgr.hasChanged(portA)).toBe(false);
127
- // Create mock port B (different model and dimensions)
128
- const portB = createMockEmbeddingPort(4, "model-b");
129
- // Should detect change since model changed
130
- expect(fingerprintMgr.hasChanged(portB)).toBe(true);
131
- // Insert some memories to reindex
132
- insertMemory(db, "m1", "hello world", 1);
133
- insertMemory(db, "m2", "test data", 1);
134
- insertMemory(db, "m3", "embedding test", 1);
135
- // Create batch indexer with port B and reindex all
136
- const batchIndexer = createBatchIndexer(db, portB, { batchSize: 10 });
137
- const result = await batchIndexer.reindexAll();
138
- // All 3 should be re-embedded with port B
139
- expect(result.indexed).toBe(3);
140
- expect(result.failed).toBe(0);
141
- expect(portB.embedBatchFn).toHaveBeenCalled();
142
- // Update fingerprint to port B
143
- fingerprintMgr.save(fingerprintMgr.computeFingerprint(portB));
144
- // No change detected for port B now
145
- expect(fingerprintMgr.hasChanged(portB)).toBe(false);
146
- });
147
- it("embedding queue processes new entries asynchronously", async () => {
148
- const mockPort = createMockEmbeddingPort(DIMS, "queue-model");
149
- // Insert entries first so the queue can update their has_embedding flag
150
- insertMemory(db, "q1", "queue entry one");
151
- insertMemory(db, "q2", "queue entry two");
152
- insertMemory(db, "q3", "queue entry three");
153
- // Create embedding queue
154
- const queue = createEmbeddingQueue(db, mockPort);
155
- // Enqueue 3 entries
156
- queue.enqueue("q1", "queue entry one");
157
- queue.enqueue("q2", "queue entry two");
158
- queue.enqueue("q3", "queue entry three");
159
- // Wait for queue to process all entries
160
- await queue.onIdle();
161
- // Verify has_embedding = 1 for all 3 entries
162
- const rows = db
163
- .prepare("SELECT id, has_embedding FROM memories WHERE id IN ('q1', 'q2', 'q3')")
164
- .all();
165
- for (const row of rows) {
166
- expect(row.has_embedding).toBe(1);
167
- }
168
- // Verify vec_memories has rows (if vec is available)
169
- if (isVecAvailable()) {
170
- const vecCount = db
171
- .prepare("SELECT COUNT(*) as cnt FROM vec_memories")
172
- .get();
173
- expect(vecCount.cnt).toBe(3);
174
- }
175
- });
176
- it("graceful degradation: no embedding port uses FTS5 only", async () => {
177
- // Create SqliteMemoryAdapter WITHOUT embedding port
178
- const adapter = new SqliteMemoryAdapter({ dbPath: ":memory:", walMode: false, embeddingDimensions: DIMS });
179
- const adapterDb = adapter.getDb();
180
- // Store memories
181
- const now = Date.now();
182
- for (let i = 1; i <= 3; i++) {
183
- await adapter.store({
184
- id: `fts-${i}`,
185
- tenantId: "default",
186
- agentId: "default",
187
- userId: "u1",
188
- content: `Searchable memory about topic ${i}`,
189
- trustLevel: "learned",
190
- source: { who: "agent" },
191
- tags: [],
192
- createdAt: now + i,
193
- });
194
- }
195
- // Search by text -- should return results via FTS5
196
- const sessionKey = { tenantId: "default", userId: "u1", channelId: "test" };
197
- const searchResult = await adapter.search(sessionKey, "Searchable memory topic", { limit: 10 });
198
- expect(searchResult.ok).toBe(true);
199
- if (searchResult.ok) {
200
- expect(searchResult.value.length).toBeGreaterThan(0);
201
- }
202
- // Verify no embeddings were generated
203
- const embeddedCount = adapterDb
204
- .prepare("SELECT COUNT(*) as cnt FROM memories WHERE has_embedding = 1")
205
- .get();
206
- expect(embeddedCount.cnt).toBe(0);
207
- });
208
- it("batch indexer handles embedBatch failure gracefully", async () => {
209
- // Create mock port that always fails embedBatch
210
- const failPort = {
211
- provider: "test",
212
- dimensions: DIMS,
213
- modelId: "fail-model",
214
- embed: vi.fn().mockResolvedValue(err(new Error("embed failed"))),
215
- embedBatch: vi.fn().mockResolvedValue(err(new Error("batch failed"))),
216
- };
217
- // Insert memories to index
218
- insertMemory(db, "f1", "should fail embedding");
219
- insertMemory(db, "f2", "also should fail");
220
- insertMemory(db, "f3", "failing too");
221
- const indexer = createBatchIndexer(db, failPort, { batchSize: 10 });
222
- const result = await indexer.indexUnembedded();
223
- // All should fail
224
- expect(result.indexed).toBe(0);
225
- expect(result.failed).toBe(3);
226
- // Memories still have has_embedding = 0
227
- const unembedded = indexer.unembeddedCount();
228
- expect(unembedded).toBe(3);
229
- // embedBatch was called once (then stopped due to failure-stop behavior)
230
- expect(failPort.embedBatch).toHaveBeenCalledTimes(1);
231
- });
232
- });