agentic-qe 3.13.11 → 3.14.0

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 (438) hide show
  1. package/.claude/helpers/.helpers-version +1 -1
  2. package/.claude/helpers/helpers.manifest.json +2 -2
  3. package/.claude/helpers/statusline.cjs +89 -40
  4. package/.claude/skills/qe-court/SKILL.md +4 -4
  5. package/.claude/skills/qe-court/config-schema.json +38 -0
  6. package/.claude/skills/qe-court/evals/qe-court.yaml +8 -8
  7. package/.claude/skills/skills-manifest.json +1 -1
  8. package/CHANGELOG.md +93 -0
  9. package/assets/skills/qe-court/SKILL.md +4 -4
  10. package/assets/skills/qe-court/config-schema.json +38 -0
  11. package/assets/skills/qe-court/evals/qe-court.yaml +8 -8
  12. package/assets/skills/skills-manifest.json +1 -1
  13. package/dist/cli/brain-commands.d.ts +1 -0
  14. package/dist/cli/brain-commands.js +1 -0
  15. package/dist/cli/bundle.js +5 -5
  16. package/dist/cli/chunks/adapter-3VBXL7DO.js +2 -0
  17. package/dist/cli/chunks/{agent-booster-wasm-5ARDZYNO.js → agent-booster-wasm-JZO6VUW4.js} +2 -2
  18. package/dist/cli/chunks/{agent-handler-SVKEPF7B.js → agent-handler-534KFGEJ.js} +2 -2
  19. package/dist/cli/chunks/{agent-memory-branch-QDL7OVHC.js → agent-memory-branch-B7KWLWY4.js} +2 -2
  20. package/dist/cli/chunks/aqe-learning-engine-NXRNKJNA.js +2 -0
  21. package/dist/cli/chunks/{arena-7OCKBN6O.js → arena-7CCD3S3I.js} +2 -2
  22. package/dist/cli/chunks/{arena-HQLSNQZ3.js → arena-OW5MELJX.js} +4 -4
  23. package/dist/cli/chunks/{audit-2EQJW5UE.js → audit-BHVKN4E2.js} +3 -3
  24. package/dist/cli/chunks/base-F6GMOKU2.js +2 -0
  25. package/dist/cli/chunks/{better-sqlite3-OBFNNE4T.js → better-sqlite3-P5FA6WFK.js} +2 -2
  26. package/dist/cli/chunks/brain-handler-WNW5LOV7.js +90 -0
  27. package/dist/cli/chunks/{branch-enumerator-6B4L5O3D.js → branch-enumerator-TVZ2ODKH.js} +2 -2
  28. package/dist/cli/chunks/{browser-VDMGBWNK.js → browser-TCEB2W2F.js} +2 -2
  29. package/dist/cli/chunks/browser-workflow-QRDC46LR.js +2 -0
  30. package/dist/cli/chunks/{chunk-M3MRFZKD.js → chunk-2D7UBX5S.js} +1 -1
  31. package/dist/cli/chunks/{chunk-IZF3VLNW.js → chunk-2HYVOX6N.js} +1 -1
  32. package/dist/cli/chunks/{chunk-U6G6RUFI.js → chunk-2NO4H35K.js} +1 -1
  33. package/dist/cli/chunks/{chunk-4TJJU5Y2.js → chunk-2O4DDPEA.js} +19 -19
  34. package/dist/cli/chunks/{chunk-24XW7KUX.js → chunk-3EM2MK3Z.js} +2 -2
  35. package/dist/cli/chunks/chunk-3GUO4ERR.js +24 -0
  36. package/dist/cli/chunks/{chunk-YRCNWQBO.js → chunk-3JIJBR4V.js} +2 -2
  37. package/dist/cli/chunks/{chunk-2E2QCIGR.js → chunk-3QT6S3A3.js} +3 -3
  38. package/dist/cli/chunks/{chunk-W2T36CS5.js → chunk-3RYTAYR6.js} +1 -1
  39. package/dist/cli/chunks/chunk-43GPSYAL.js +14 -0
  40. package/dist/cli/chunks/{chunk-YYAJEPRD.js → chunk-4FEJEVG7.js} +1 -1
  41. package/dist/cli/chunks/{chunk-4DTBGQWA.js → chunk-4MK2G6TK.js} +2 -2
  42. package/dist/cli/chunks/{chunk-CK7ZLMD2.js → chunk-4XTHRAUV.js} +1 -1
  43. package/dist/cli/chunks/{chunk-LM727BVL.js → chunk-4ZVGSVHV.js} +4 -4
  44. package/dist/cli/chunks/{chunk-DPZ4AU6W.js → chunk-52DFCV57.js} +2 -2
  45. package/dist/cli/chunks/{chunk-PADCR4LY.js → chunk-5LEAGKX5.js} +2 -2
  46. package/dist/cli/chunks/{chunk-P736OKQN.js → chunk-5MZF4N4Q.js} +1 -1
  47. package/dist/cli/chunks/{chunk-XZI4QXJJ.js → chunk-5VDVYTO5.js} +2 -2
  48. package/dist/cli/chunks/chunk-5XGVSQS2.js +11 -0
  49. package/dist/cli/chunks/{chunk-AAPJG3WI.js → chunk-6AOZU3UN.js} +2 -2
  50. package/dist/cli/chunks/{chunk-NC7HTDH5.js → chunk-6AYO3IR2.js} +2 -2
  51. package/dist/cli/chunks/{chunk-TJ67B7S7.js → chunk-6DPAMYLU.js} +2 -2
  52. package/dist/cli/chunks/{chunk-PZHAPI47.js → chunk-6IJMD2ZL.js} +3 -3
  53. package/dist/cli/chunks/{chunk-RGUKQXKL.js → chunk-6IZQSLYZ.js} +2 -2
  54. package/dist/cli/chunks/{chunk-2E3PRDEX.js → chunk-6W42XWLL.js} +2 -2
  55. package/dist/cli/chunks/{chunk-ATRUE6CT.js → chunk-7BOPFN3Y.js} +2 -2
  56. package/dist/cli/chunks/{chunk-LIGDJP6H.js → chunk-7OUMJCJT.js} +1 -1
  57. package/dist/cli/chunks/{chunk-2Y3PW5EJ.js → chunk-7RAB2BZY.js} +160 -26
  58. package/dist/cli/chunks/{chunk-XEUUWOSS.js → chunk-7RVAHJQZ.js} +3 -3
  59. package/dist/cli/chunks/{chunk-HHEWINDL.js → chunk-A2WZEMWT.js} +1 -1
  60. package/dist/cli/chunks/{chunk-36ONUM43.js → chunk-A7SKM6JL.js} +1 -1
  61. package/dist/cli/chunks/chunk-AFGT26NR.js +2 -0
  62. package/dist/cli/chunks/{chunk-23E37MDA.js → chunk-AR6SATU3.js} +2 -2
  63. package/dist/cli/chunks/{chunk-IYMV4CU5.js → chunk-AVLA5PBJ.js} +2 -2
  64. package/dist/cli/chunks/{chunk-OLPJGYO5.js → chunk-B3H4K7CY.js} +2 -2
  65. package/dist/cli/chunks/{chunk-JWT675RM.js → chunk-BQCTO7UB.js} +2 -2
  66. package/dist/cli/chunks/{chunk-JKP2BUF5.js → chunk-BZ4QVFP2.js} +2 -2
  67. package/dist/cli/chunks/{chunk-WINYWMQP.js → chunk-CIUOC5F3.js} +1 -1
  68. package/dist/cli/chunks/{chunk-SJJFU7KK.js → chunk-CIZ6LSNV.js} +2 -2
  69. package/dist/cli/chunks/{chunk-2D7SBOZ4.js → chunk-DDPJUAXQ.js} +2 -2
  70. package/dist/cli/chunks/{chunk-H7QWOJF2.js → chunk-DJITEQYS.js} +2 -2
  71. package/dist/cli/chunks/{chunk-DMHQ4ZUZ.js → chunk-DOWCOZDO.js} +2 -2
  72. package/dist/cli/chunks/{chunk-PBJ5I2NS.js → chunk-E4NU4BJA.js} +2 -2
  73. package/dist/cli/chunks/{chunk-E54QUKAD.js → chunk-E722WNWC.js} +2 -2
  74. package/dist/cli/chunks/chunk-ECTPFCON.js +2 -0
  75. package/dist/cli/chunks/{chunk-MUAW4AJ6.js → chunk-EJ6IP7DE.js} +5 -5
  76. package/dist/cli/chunks/{chunk-NHL37QAZ.js → chunk-ENGKLFLY.js} +2 -2
  77. package/dist/cli/chunks/{chunk-VU3ARH4S.js → chunk-FF43SRP6.js} +1 -1
  78. package/dist/cli/chunks/{chunk-PJNIDDER.js → chunk-FOHYBR3O.js} +1 -1
  79. package/dist/cli/chunks/{chunk-LREIHR2A.js → chunk-FRL3X2QA.js} +2 -2
  80. package/dist/cli/chunks/{chunk-WYQM7GXW.js → chunk-GKNDP5VK.js} +2 -2
  81. package/dist/cli/chunks/{chunk-JK6ENS3J.js → chunk-GVEJP5T7.js} +2 -2
  82. package/dist/cli/chunks/{chunk-H3BHOIT6.js → chunk-H3YDDKBW.js} +3 -3
  83. package/dist/cli/chunks/{chunk-3SPYI7TS.js → chunk-H6NFDOMK.js} +1 -1
  84. package/dist/cli/chunks/{chunk-AZVV7POX.js → chunk-H76TV4UU.js} +3 -3
  85. package/dist/cli/chunks/{chunk-2HT5HRAA.js → chunk-HJIAVR6P.js} +2 -2
  86. package/dist/cli/chunks/{chunk-UZ7OWJ75.js → chunk-HLNQDRHA.js} +1 -1
  87. package/dist/cli/chunks/{chunk-IGW5L7YM.js → chunk-HNKPLVYS.js} +1 -1
  88. package/dist/cli/chunks/{chunk-Y2S6SS7M.js → chunk-HQ7243G3.js} +2 -2
  89. package/dist/cli/chunks/{chunk-TZA45FI7.js → chunk-HQHLHSJO.js} +2 -2
  90. package/dist/cli/chunks/{chunk-YEPJS4AM.js → chunk-I3VHXA2W.js} +2 -2
  91. package/dist/cli/chunks/{chunk-W2NQDAJZ.js → chunk-IE5LC7MB.js} +2 -2
  92. package/dist/cli/chunks/{chunk-TU4BYSXR.js → chunk-IL4AEB3J.js} +27 -25
  93. package/dist/cli/chunks/{chunk-JTQSXU6V.js → chunk-IL6QRXRP.js} +6 -6
  94. package/dist/cli/chunks/{chunk-UX5SM2PW.js → chunk-IQ3JFHZN.js} +1 -1
  95. package/dist/cli/chunks/{chunk-RAV2NJNX.js → chunk-IQLRA4FV.js} +1 -1
  96. package/dist/cli/chunks/{chunk-S3FNAHNC.js → chunk-J3XSHJGK.js} +2 -2
  97. package/dist/cli/chunks/{chunk-AHG2O5HT.js → chunk-JAK5UUWH.js} +2 -2
  98. package/dist/cli/chunks/{chunk-XDK2TPI5.js → chunk-JGROLJ33.js} +1 -1
  99. package/dist/cli/chunks/{chunk-MWTFFGU3.js → chunk-JMKMDSXG.js} +2 -2
  100. package/dist/cli/chunks/{chunk-BVKFBJX6.js → chunk-JRKEBESE.js} +2 -2
  101. package/dist/cli/chunks/{chunk-76NSSNB3.js → chunk-JTWJR2KY.js} +2 -2
  102. package/dist/cli/chunks/{chunk-QYHRDBKI.js → chunk-JY4VZ6BN.js} +2 -2
  103. package/dist/cli/chunks/{chunk-DLL3AJH7.js → chunk-K6CGQR5R.js} +1 -1
  104. package/dist/cli/chunks/{chunk-7HTYM6XY.js → chunk-KDIZQHG5.js} +2 -2
  105. package/dist/cli/chunks/{chunk-B646CE3C.js → chunk-KTSCZ7AW.js} +2 -2
  106. package/dist/cli/chunks/{chunk-LLP3UW62.js → chunk-L4C42WYI.js} +2 -2
  107. package/dist/cli/chunks/{chunk-H3AKF2HS.js → chunk-LCSVROU7.js} +10 -10
  108. package/dist/cli/chunks/{chunk-HZR4G6I3.js → chunk-LKR7T3OZ.js} +1 -1
  109. package/dist/cli/chunks/{chunk-Z5ARI4XT.js → chunk-LZHTCUCO.js} +2 -2
  110. package/dist/cli/chunks/{chunk-YDEYB6Z2.js → chunk-M3HUZD2I.js} +1 -1
  111. package/dist/cli/chunks/{chunk-GWTGBQ6X.js → chunk-MO7EITJK.js} +2 -2
  112. package/dist/cli/chunks/{chunk-5364DBZG.js → chunk-N2YAUDAV.js} +2 -2
  113. package/dist/cli/chunks/{chunk-XVFSZLRS.js → chunk-NDPQ2WPU.js} +1 -1
  114. package/dist/cli/chunks/{chunk-CTS545BF.js → chunk-NKWO2X3T.js} +1 -1
  115. package/dist/cli/chunks/{chunk-GPJDZFFV.js → chunk-NOPVFBQM.js} +2 -2
  116. package/dist/cli/chunks/{chunk-VNVGCJCS.js → chunk-NYARYONH.js} +1 -1
  117. package/dist/cli/chunks/{chunk-WRZ5WZG3.js → chunk-O2MZZL54.js} +2 -2
  118. package/dist/cli/chunks/{chunk-EKFKQGIT.js → chunk-OIYUSWHX.js} +1 -1
  119. package/dist/cli/chunks/{chunk-ZNGFSR5M.js → chunk-OONCRNFA.js} +2 -2
  120. package/dist/cli/chunks/{chunk-LUAXQB57.js → chunk-PEW6FZ47.js} +1 -1
  121. package/dist/cli/chunks/{chunk-W7BB4XLP.js → chunk-Q73RRTLE.js} +2 -2
  122. package/dist/cli/chunks/{chunk-JKPMV5VB.js → chunk-QKQZ4IJF.js} +5 -5
  123. package/dist/cli/chunks/{chunk-EHZQIXH6.js → chunk-QMMDN4WX.js} +3 -3
  124. package/dist/cli/chunks/chunk-QQCENKCX.js +2 -0
  125. package/dist/cli/chunks/{chunk-7YL7P5XG.js → chunk-QSPRQPEL.js} +2 -2
  126. package/dist/cli/chunks/{chunk-DXQMVATY.js → chunk-QZPFUFZG.js} +2 -2
  127. package/dist/cli/chunks/chunk-R2B6EE45.js +2 -0
  128. package/dist/cli/chunks/{chunk-VLW63UA2.js → chunk-R6WJF4D5.js} +2 -2
  129. package/dist/cli/chunks/{chunk-EWH7PFV6.js → chunk-RGVD6ZUX.js} +1 -1
  130. package/dist/cli/chunks/{chunk-UGFHEVG4.js → chunk-RKUYVVGJ.js} +2 -2
  131. package/dist/cli/chunks/{chunk-V7QZMOG3.js → chunk-S5YVLPXU.js} +2 -2
  132. package/dist/cli/chunks/{chunk-UDFTDQ6C.js → chunk-SROZXIMT.js} +37 -37
  133. package/dist/cli/chunks/{chunk-AFXMTSO3.js → chunk-SSV6KSFT.js} +1 -1
  134. package/dist/cli/chunks/{chunk-HGPMS6JL.js → chunk-SUSMHSXT.js} +2 -2
  135. package/dist/cli/chunks/{chunk-BL5BHBXR.js → chunk-T3BZAFLP.js} +1 -1
  136. package/dist/cli/chunks/{chunk-K652SCBA.js → chunk-TGOGCA74.js} +2 -2
  137. package/dist/cli/chunks/{chunk-VHNAN7E2.js → chunk-TKYEP7OR.js} +1 -1
  138. package/dist/cli/chunks/{chunk-OJUI65TR.js → chunk-TQJE7DNL.js} +2 -2
  139. package/dist/cli/chunks/{chunk-MS5CAEPA.js → chunk-TRDEULS7.js} +2 -2
  140. package/dist/cli/chunks/{chunk-YRV45WDT.js → chunk-U4GZWPKM.js} +2 -2
  141. package/dist/cli/chunks/{chunk-2BDTZYQN.js → chunk-UI6WSPEK.js} +3 -3
  142. package/dist/cli/chunks/{chunk-TMY2Y7SC.js → chunk-UUJ5VQJM.js} +1 -1
  143. package/dist/cli/chunks/{chunk-4CTKRLRX.js → chunk-VESOYP6A.js} +2 -2
  144. package/dist/cli/chunks/{chunk-UPMQHCC2.js → chunk-VOSISOFD.js} +1 -1
  145. package/dist/cli/chunks/{chunk-IZOWGVTU.js → chunk-VPVZHJSU.js} +2 -2
  146. package/dist/cli/chunks/{chunk-TBO64O56.js → chunk-VRRG66XB.js} +1 -1
  147. package/dist/cli/chunks/{chunk-WJB6YYMJ.js → chunk-VXU53F7Z.js} +2 -2
  148. package/dist/cli/chunks/{chunk-4TUGQESL.js → chunk-VYENTZ45.js} +2 -2
  149. package/dist/cli/chunks/chunk-WJXHE52V.js +65 -0
  150. package/dist/cli/chunks/{chunk-EN36AFRJ.js → chunk-WKNWRDA5.js} +1 -1
  151. package/dist/cli/chunks/{chunk-4X4GTEQY.js → chunk-WTHAVFIC.js} +1 -1
  152. package/dist/cli/chunks/{chunk-LPDT27EC.js → chunk-WWWX76QB.js} +2 -2
  153. package/dist/cli/chunks/{chunk-TCVEXQLL.js → chunk-XITTURP2.js} +2 -2
  154. package/dist/cli/chunks/{chunk-HV6LJ57R.js → chunk-XXFKN7LB.js} +1 -1
  155. package/dist/cli/chunks/{chunk-UJ2NRIAS.js → chunk-YEAC3DC6.js} +2 -2
  156. package/dist/cli/chunks/{chunk-FBASWZ7G.js → chunk-YKWMKRYB.js} +1 -1
  157. package/dist/cli/chunks/chunk-YKZV7O65.js +2 -0
  158. package/dist/cli/chunks/{chunk-PT6U3IIK.js → chunk-YW4RNZWT.js} +2 -2
  159. package/dist/cli/chunks/{chunk-H5DS7S4B.js → chunk-ZAAYOENS.js} +2 -2
  160. package/dist/cli/chunks/chunk-ZBKGX72B.js +13 -0
  161. package/dist/cli/chunks/{chunk-WVNLNXXI.js → chunk-ZBOWR4XT.js} +2 -2
  162. package/dist/cli/chunks/{chunk-FPX4JSFH.js → chunk-ZCVJCCQQ.js} +2 -2
  163. package/dist/cli/chunks/{chunk-OQWG7GOD.js → chunk-ZI3UO7QR.js} +8 -7
  164. package/dist/cli/chunks/{chunk-BPPEN7SS.js → chunk-ZNSMVQCG.js} +2 -2
  165. package/dist/cli/chunks/{chunk-EI4KYBNI.js → chunk-ZQSXG7FA.js} +2 -2
  166. package/dist/cli/chunks/{ci-M6WYL2XY.js → ci-B432UH6N.js} +2 -2
  167. package/dist/cli/chunks/{ci-output-JFC3WOHX.js → ci-output-GTHH7WYG.js} +2 -2
  168. package/dist/cli/chunks/{circuit-breaker-IMVBU6WP.js → circuit-breaker-VW75DLME.js} +2 -2
  169. package/dist/cli/chunks/{claude-flow-setup-M5T5ZUXX.js → claude-flow-setup-RE3IVT7U.js} +2 -2
  170. package/dist/cli/chunks/client-HNBZUEVV.js +2 -0
  171. package/dist/cli/chunks/{cline-installer-LSFAUHXC.js → cline-installer-NUBZZ55N.js} +2 -2
  172. package/dist/cli/chunks/{code-N3SWJ3XL.js → code-K6JCWKNW.js} +2 -2
  173. package/dist/cli/chunks/{code-index-extractor-WPGRG36B.js → code-index-extractor-I4ILB5JN.js} +2 -2
  174. package/dist/cli/chunks/{codex-installer-LKRCSDU5.js → codex-installer-AKQ5BCHU.js} +2 -2
  175. package/dist/cli/chunks/{completions-E5TBZ5AB.js → completions-V3KJVJF4.js} +2 -2
  176. package/dist/cli/chunks/{complexity-analyzer-3FOSOELK.js → complexity-analyzer-HRG7OOY3.js} +2 -2
  177. package/dist/cli/chunks/{continuedev-installer-ZSVFWMQB.js → continuedev-installer-CNTDONWG.js} +2 -2
  178. package/dist/cli/chunks/{copilot-installer-POSKHPZM.js → copilot-installer-XPWWIWYA.js} +2 -2
  179. package/dist/cli/chunks/core-handlers-TB7NLYXL.js +2 -0
  180. package/dist/cli/chunks/{cost-tracker-3UWDCNGC.js → cost-tracker-MFNLQ56K.js} +2 -2
  181. package/dist/cli/chunks/{coverage-HPBO67JF.js → coverage-KOIK654V.js} +3 -3
  182. package/dist/cli/chunks/cross-domain-router-MDSI553U.js +2 -0
  183. package/dist/cli/chunks/{cursor-installer-DSW3L62X.js → cursor-installer-S5MKLRQQ.js} +2 -2
  184. package/dist/cli/chunks/{daemon-2622ZCMJ.js → daemon-DUS6JYW6.js} +3 -3
  185. package/dist/cli/chunks/{daemon-33KTKDUM.js → daemon-Z7VPGWHY.js} +4 -4
  186. package/dist/cli/chunks/{dag-attention-scheduler-YFT5JMM6.js → dag-attention-scheduler-7CQ3ARNI.js} +2 -2
  187. package/dist/cli/chunks/{detect-COR3Q6BE.js → detect-WORBCAYF.js} +2 -2
  188. package/dist/cli/chunks/{dist-node-5TRNTNWI.js → dist-node-KRNI6OYW.js} +2 -2
  189. package/dist/cli/chunks/{domain-handler-TZC4GCF6.js → domain-handler-KRUR2VQG.js} +2 -2
  190. package/dist/cli/chunks/{domain-transfer-D2TENM3Y.js → domain-transfer-VEOVLV54.js} +2 -2
  191. package/dist/cli/chunks/dream-X7ISHFEE.js +2 -0
  192. package/dist/cli/chunks/embed-and-insert-pattern-QU3NQVA5.js +3 -0
  193. package/dist/cli/chunks/{eval-5ID5D77H.js → eval-AYQ7BSUP.js} +2 -2
  194. package/dist/cli/chunks/{experience-capture-middleware-MT4Z74TD.js → experience-capture-middleware-AWQBL6LT.js} +3 -3
  195. package/dist/cli/chunks/{fast-paths-MACRZGSE.js → fast-paths-V5EL4BYJ.js} +2 -2
  196. package/dist/cli/chunks/{feature-flags-LFNL6BHS.js → feature-flags-BXX7BP22.js} +2 -2
  197. package/dist/cli/chunks/{feature-flags-JZX6ZBUX.js → feature-flags-P34BPRWU.js} +2 -2
  198. package/dist/cli/chunks/{file-discovery-DA5BEAO2.js → file-discovery-MS6BKQ2U.js} +2 -2
  199. package/dist/cli/chunks/{fleet-35I4F7D2.js → fleet-7WVVPA4W.js} +3 -3
  200. package/dist/cli/chunks/{gnn-wrapper-2W3HM3ZI.js → gnn-wrapper-7WQ3LEPG.js} +2 -2
  201. package/dist/cli/chunks/{heartbeat-handler-6O2D2FU2.js → heartbeat-handler-P7QD3BZH.js} +4 -4
  202. package/dist/cli/chunks/heartbeat-scheduler-2C5XGFQT.js +2 -0
  203. package/dist/cli/chunks/hnsw-adapter-KCVMXLUL.js +2 -0
  204. package/dist/cli/chunks/hnsw-index-OGWZS6MP.js +2 -0
  205. package/dist/cli/chunks/{hnsw-legacy-bridge-GWBXEMQR.js → hnsw-legacy-bridge-Y3GAR3UP.js} +2 -2
  206. package/dist/cli/chunks/{hnswlib-node-TZ4VLARU.js → hnswlib-node-5QUXZQWQ.js} +2 -2
  207. package/dist/cli/chunks/{hooks-723GPTQ4.js → hooks-2D64KPRY.js} +10 -10
  208. package/dist/cli/chunks/{hypergraph-engine-ILRYFJM5.js → hypergraph-engine-5INXEZDP.js} +2 -2
  209. package/dist/cli/chunks/{hypergraph-handler-523TSK4P.js → hypergraph-handler-YJJJ3ESZ.js} +3 -3
  210. package/dist/cli/chunks/impact-analyzer-IBJ43GQL.js +2 -0
  211. package/dist/cli/chunks/{init-handler-RBDYIXNV.js → init-handler-QSFYJN5Q.js} +6 -6
  212. package/dist/cli/chunks/init-wizard-6XMFD5LP.js +2 -0
  213. package/dist/cli/chunks/kernel-UDUMUPB3.js +2 -0
  214. package/dist/cli/chunks/{kilocode-installer-E2QSX7Z7.js → kilocode-installer-3N3QGTJU.js} +2 -2
  215. package/dist/cli/chunks/{kiro-installer-EZZLT2R5.js → kiro-installer-GIWVTFZQ.js} +2 -2
  216. package/dist/cli/chunks/knowledge-graph-JRYTUG3W.js +2 -0
  217. package/dist/cli/chunks/learning-SGO2DQ5Q.js +122 -0
  218. package/dist/cli/chunks/llm-router-HBBULO65.js +37 -0
  219. package/dist/cli/chunks/llm-router-service-KF5ZALUQ.js +2 -0
  220. package/dist/cli/chunks/{load-QFQ3YOBQ.js → load-B5OFYB4H.js} +2 -2
  221. package/dist/cli/chunks/load-test-LHMBCNCH.js +2 -0
  222. package/dist/cli/chunks/{mcp-FPBBJJFY.js → mcp-FG3LNQR4.js} +2 -2
  223. package/dist/cli/chunks/{memory-RKN6KV75.js → memory-SPS7ZWLC.js} +5 -5
  224. package/dist/cli/chunks/memory-backend-WZHKHBZK.js +2 -0
  225. package/dist/cli/chunks/memory-handlers-P7FTPWP3.js +2 -0
  226. package/dist/cli/chunks/{multi-model-executor-OUNW3JM5.js → multi-model-executor-PUB7E6KH.js} +2 -2
  227. package/dist/cli/chunks/{opencode-installer-FXETYGGY.js → opencode-installer-TGCSGVG2.js} +2 -2
  228. package/dist/cli/chunks/{orchestrator-35UTVXSP.js → orchestrator-S5FTJFGB.js} +10 -13
  229. package/dist/cli/chunks/pattern-null-store-UZSHCRL2.js +2 -0
  230. package/dist/cli/chunks/{pattern-usage-recorder-YEQDS7DN.js → pattern-usage-recorder-LCXXGRAB.js} +2 -2
  231. package/dist/cli/chunks/{pipeline-YDJMWCAR.js → pipeline-ENOSRHKW.js} +2 -2
  232. package/dist/cli/chunks/{platform-L3LPNVKT.js → platform-WCRBO3Z7.js} +2 -2
  233. package/dist/cli/chunks/{plugin-55EYFJH5.js → plugin-JZ5ODJSU.js} +2 -2
  234. package/dist/cli/chunks/{prime-radiant-advanced-wasm-SUZT6RTM.js → prime-radiant-advanced-wasm-DPJUPNCG.js} +2 -2
  235. package/dist/cli/chunks/protocol-executor-42NLVDTC.js +2 -0
  236. package/dist/cli/chunks/{protocol-handler-QNBFRJNY.js → protocol-handler-IP4NLVY3.js} +2 -2
  237. package/dist/cli/chunks/{prove-3X5NQP4L.js → prove-P6FM4RU7.js} +2 -2
  238. package/dist/cli/chunks/qe-reasoning-bank-W74RSMMU.js +2 -0
  239. package/dist/cli/chunks/{quality-5ZONTNA6.js → quality-UHP4XO26.js} +2 -2
  240. package/dist/cli/chunks/{quality-gate-JPNREEVR.js → quality-gate-63DDBSGM.js} +3 -3
  241. package/dist/cli/chunks/queen-coordinator-XELKSRMS.js +2 -0
  242. package/dist/cli/chunks/real-embeddings-6SO5MFRQ.js +2 -0
  243. package/dist/cli/chunks/{roocode-installer-ZK73O2GD.js → roocode-installer-WTWUOFCH.js} +2 -2
  244. package/dist/cli/chunks/router-GTW2EQZV.js +2 -0
  245. package/dist/cli/chunks/routing-feedback-NVOBWEMK.js +2 -0
  246. package/dist/cli/chunks/{routing-handler-2UN5GRHJ.js → routing-handler-IK7HYERQ.js} +2 -2
  247. package/dist/cli/chunks/{ruvector-commands-EQQUEVWN.js → ruvector-commands-THLB4NIM.js} +2 -2
  248. package/dist/cli/chunks/rvf-dual-writer-5OPVMXNL.js +2 -0
  249. package/dist/cli/chunks/rvf-migration-adapter-5S4YFTX4.js +2 -0
  250. package/dist/cli/chunks/rvf-migration-coordinator-BUKCSHBD.js +2 -0
  251. package/dist/cli/chunks/rvf-native-adapter-LYSJHEVX.js +2 -0
  252. package/dist/cli/chunks/{rvf-store-integrity-66FEC3MD.js → rvf-store-integrity-ECTADZIN.js} +2 -2
  253. package/dist/cli/chunks/safe-db-AEB3JMLD.js +2 -0
  254. package/dist/cli/chunks/schedule-4QNPCQNT.js +2 -0
  255. package/dist/cli/chunks/scheduler-S3DFHX6A.js +2 -0
  256. package/dist/cli/chunks/{security-H7PEUUCV.js → security-HN4UXFXX.js} +3 -3
  257. package/dist/cli/chunks/{shared-rvf-adapter-XETNK4ID.js → shared-rvf-adapter-XJCPX5SN.js} +2 -2
  258. package/dist/cli/chunks/{shared-rvf-dual-writer-PXD54BWJ.js → shared-rvf-dual-writer-23X5PNY5.js} +2 -2
  259. package/dist/cli/chunks/sqlite-persistence-L2KISU2H.js +2 -0
  260. package/dist/cli/chunks/status-handler-ZXANTHKT.js +47 -0
  261. package/dist/cli/chunks/{structural-health-EIFBDCRI.js → structural-health-LR6WI3AH.js} +2 -2
  262. package/dist/cli/chunks/{sync-PECWQ64K.js → sync-4OEI3BC2.js} +2 -2
  263. package/dist/cli/chunks/{sync-3SU4H6R3.js → sync-I5IUJF33.js} +2 -2
  264. package/dist/cli/chunks/{task-handler-ZTUAT6YF.js → task-handler-R3ATJKU5.js} +2 -2
  265. package/dist/cli/chunks/{task-handlers-4RIO7LJJ.js → task-handlers-4X357AEW.js} +3 -3
  266. package/dist/cli/chunks/{test-EV7BSUTI.js → test-PR2B5H2F.js} +4 -4
  267. package/dist/cli/chunks/{test-scheduling-4WVI5DLE.js → test-scheduling-ZNOSQVLD.js} +3 -3
  268. package/dist/cli/chunks/token-bootstrap-LYXOI72S.js +2 -0
  269. package/dist/cli/chunks/{token-usage-FR3JOWYB.js → token-usage-R6EQZBX2.js} +2 -2
  270. package/dist/cli/chunks/{transformers-FENO33LA.js → transformers-COQWK27J.js} +2 -2
  271. package/dist/cli/chunks/{tree-sitter-wasm-parser-YFGJLSMB.js → tree-sitter-wasm-parser-LLIW2X3M.js} +2 -2
  272. package/dist/cli/chunks/{types-N3Y565RZ.js → types-MEYTZITK.js} +2 -2
  273. package/dist/cli/chunks/unified-memory-5KQMA7FV.js +2 -0
  274. package/dist/cli/chunks/unified-memory-hnsw-PQRPTYOD.js +2 -0
  275. package/dist/cli/chunks/unified-persistence-YDONVPJB.js +2 -0
  276. package/dist/cli/chunks/{upgrade-33ZVVZFW.js → upgrade-DVIJ456A.js} +2 -2
  277. package/dist/cli/chunks/{validate-CS5PXGDF.js → validate-UYTSMJ5X.js} +2 -2
  278. package/dist/cli/chunks/{validate-swarm-GRZPWYNM.js → validate-swarm-P32WCJR6.js} +2 -2
  279. package/dist/cli/chunks/{vibium-IO7N4VEE.js → vibium-JGVOLM6X.js} +2 -2
  280. package/dist/cli/chunks/visual-security-RJ7RTNGJ.js +2 -0
  281. package/dist/cli/chunks/{web-tree-sitter-UQXR5HHR.js → web-tree-sitter-5ZGNCTPN.js} +2 -2
  282. package/dist/cli/chunks/{windsurf-installer-BCKLSLZT.js → windsurf-installer-IILSSQAE.js} +2 -2
  283. package/dist/cli/chunks/{witness-chain-R3V26QWL.js → witness-chain-JZMXCG3B.js} +2 -2
  284. package/dist/cli/chunks/witness-chain-YXXXNGAM.js +2 -0
  285. package/dist/cli/chunks/{witness-key-manager-Y36HMPEM.js → witness-key-manager-UUTLNUIH.js} +2 -2
  286. package/dist/cli/chunks/{workflow-4TCIUUFQ.js → workflow-NS7HXVHZ.js} +4 -4
  287. package/dist/cli/chunks/workflow-orchestrator-5KUAVSTH.js +2 -0
  288. package/dist/cli/chunks/{wrappers-MD4JRHJH.js → wrappers-XKEDSV5W.js} +2 -2
  289. package/dist/cli/commands/learning.js +44 -0
  290. package/dist/cli/commands/llm-router.js +62 -27
  291. package/dist/cli/handlers/brain-handler.js +2 -0
  292. package/dist/cli/handlers/status-handler.js +18 -2
  293. package/dist/context/compaction/index.d.ts +1 -0
  294. package/dist/context/compaction/index.js +3 -0
  295. package/dist/context/compaction/instruction-provenance.d.ts +20 -0
  296. package/dist/context/compaction/instruction-provenance.js +18 -0
  297. package/dist/context/compaction/tier2-session-summary.d.ts +8 -0
  298. package/dist/context/compaction/tier2-session-summary.js +20 -0
  299. package/dist/context/compaction/tier3-llm-compact.d.ts +4 -0
  300. package/dist/context/compaction/tier3-llm-compact.js +32 -4
  301. package/dist/init/phases/07-hooks.js +0 -3
  302. package/dist/integrations/embeddings/base/EmbeddingGenerator.js +4 -2
  303. package/dist/integrations/ruvector/brain-exporter.d.ts +1 -1
  304. package/dist/integrations/ruvector/brain-exporter.js +15 -3
  305. package/dist/integrations/ruvector/brain-rvf-exporter.d.ts +4 -0
  306. package/dist/integrations/ruvector/brain-rvf-exporter.js +118 -37
  307. package/dist/integrations/ruvector/brain-search.d.ts +1 -1
  308. package/dist/integrations/ruvector/brain-search.js +1 -1
  309. package/dist/integrations/ruvector/brain-shared.d.ts +4 -2
  310. package/dist/integrations/ruvector/brain-shared.js +11 -4
  311. package/dist/integrations/ruvector/brain-table-ddl.d.ts +2 -2
  312. package/dist/integrations/ruvector/brain-table-ddl.js +20 -8
  313. package/dist/integrations/ruvector/cognitive-container.js +1 -1
  314. package/dist/integrations/ruvector/rvf-dual-writer.d.ts +4 -0
  315. package/dist/integrations/ruvector/rvf-dual-writer.js +57 -9
  316. package/dist/integrations/ruvector/rvf-store-integrity.js +1 -1
  317. package/dist/kernel/unified-memory-schemas.d.ts +4 -3
  318. package/dist/kernel/unified-memory-schemas.js +19 -9
  319. package/dist/kernel/unified-memory.d.ts +2 -0
  320. package/dist/kernel/unified-memory.js +19 -0
  321. package/dist/learning/embed-and-insert-pattern.js +6 -3
  322. package/dist/learning/embedding-space.d.ts +50 -0
  323. package/dist/learning/embedding-space.js +128 -0
  324. package/dist/learning/evidence-admission-store.d.ts +15 -0
  325. package/dist/learning/evidence-admission-store.js +68 -0
  326. package/dist/learning/index.d.ts +4 -0
  327. package/dist/learning/index.js +2 -0
  328. package/dist/learning/learning-evidence-admission.d.ts +44 -0
  329. package/dist/learning/learning-evidence-admission.js +97 -0
  330. package/dist/learning/pattern-store.d.ts +5 -0
  331. package/dist/learning/pattern-store.js +36 -7
  332. package/dist/learning/qe-flywheel/coupled-anchor.d.ts +8 -0
  333. package/dist/learning/qe-flywheel/coupled-anchor.js +46 -3
  334. package/dist/learning/qe-reasoning-bank.js +4 -0
  335. package/dist/learning/real-embeddings.d.ts +3 -0
  336. package/dist/learning/real-embeddings.js +40 -3
  337. package/dist/learning/real-qe-reasoning-bank.js +7 -3
  338. package/dist/learning/rvf-pattern-migration.d.ts +2 -0
  339. package/dist/learning/rvf-pattern-migration.js +5 -3
  340. package/dist/learning/rvf-pattern-store.d.ts +3 -0
  341. package/dist/learning/rvf-pattern-store.js +21 -1
  342. package/dist/learning/sqlite-persistence.d.ts +7 -2
  343. package/dist/learning/sqlite-persistence.js +58 -21
  344. package/dist/mcp/bundle.js +607 -443
  345. package/dist/mcp/handlers/memory-handlers.js +6 -2
  346. package/dist/migrations/20260830_add_learning_evidence_tables.d.ts +7 -0
  347. package/dist/migrations/20260830_add_learning_evidence_tables.js +173 -0
  348. package/dist/persistence/rvf-migration-adapter.d.ts +2 -0
  349. package/dist/persistence/rvf-migration-adapter.js +56 -12
  350. package/dist/shared/llm/billing-modes.d.ts +5 -0
  351. package/dist/shared/llm/billing-modes.js +42 -3
  352. package/dist/shared/llm/index.d.ts +4 -1
  353. package/dist/shared/llm/index.js +5 -1
  354. package/dist/shared/llm/interfaces.d.ts +34 -3
  355. package/dist/shared/llm/interfaces.js +17 -0
  356. package/dist/shared/llm/llm-router-service.d.ts +8 -0
  357. package/dist/shared/llm/llm-router-service.js +21 -3
  358. package/dist/shared/llm/provider-manager.js +8 -1
  359. package/dist/shared/llm/provider-registry.d.ts +135 -0
  360. package/dist/shared/llm/provider-registry.js +227 -0
  361. package/dist/shared/llm/providers/external-cli.d.ts +129 -0
  362. package/dist/shared/llm/providers/external-cli.js +385 -0
  363. package/dist/shared/llm/router/config-store.d.ts +14 -0
  364. package/dist/shared/llm/router/config-store.js +102 -14
  365. package/dist/shared/llm/router/external-provider-config.d.ts +47 -0
  366. package/dist/shared/llm/router/external-provider-config.js +105 -0
  367. package/dist/shared/llm/router/types.d.ts +50 -4
  368. package/dist/shared/llm/router/types.js +10 -0
  369. package/dist/shared/llm/translation/message-formatter.js +7 -1
  370. package/dist/shared/sql-safety.js +4 -0
  371. package/dist/skills/qe-court/cli.d.ts +3 -0
  372. package/dist/skills/qe-court/cli.js +54 -0
  373. package/dist/verification/adversarial-verify/calibrate.d.ts +46 -2
  374. package/dist/verification/adversarial-verify/calibrate.js +104 -2
  375. package/dist/verification/adversarial-verify/index.d.ts +1 -1
  376. package/dist/verification/adversarial-verify/index.js +1 -1
  377. package/package.json +12 -3
  378. package/dist/cli/chunks/adapter-YBSKQFQ4.js +0 -2
  379. package/dist/cli/chunks/aqe-learning-engine-3H7DRDD4.js +0 -2
  380. package/dist/cli/chunks/base-ZTD6PFD7.js +0 -2
  381. package/dist/cli/chunks/brain-handler-FV2AJZ4A.js +0 -89
  382. package/dist/cli/chunks/browser-workflow-GKWDM25H.js +0 -2
  383. package/dist/cli/chunks/chunk-2CBEQV6R.js +0 -2
  384. package/dist/cli/chunks/chunk-4ZQOJ7Q2.js +0 -2
  385. package/dist/cli/chunks/chunk-CYQRZ645.js +0 -2
  386. package/dist/cli/chunks/chunk-FXKOHZBN.js +0 -2
  387. package/dist/cli/chunks/chunk-GJTGHVAX.js +0 -65
  388. package/dist/cli/chunks/chunk-GP5QBJVO.js +0 -3
  389. package/dist/cli/chunks/chunk-JGXP67BP.js +0 -2
  390. package/dist/cli/chunks/chunk-SW56PB22.js +0 -2
  391. package/dist/cli/chunks/chunk-T5M4TZRB.js +0 -12
  392. package/dist/cli/chunks/chunk-UDSNWQQI.js +0 -2
  393. package/dist/cli/chunks/chunk-VC77SDNH.js +0 -9
  394. package/dist/cli/chunks/chunk-WRMJWQUI.js +0 -12
  395. package/dist/cli/chunks/chunk-YXUFGDGS.js +0 -2
  396. package/dist/cli/chunks/client-4Q5JE7RY.js +0 -2
  397. package/dist/cli/chunks/core-handlers-4GKEYGPS.js +0 -2
  398. package/dist/cli/chunks/cross-domain-router-PBJ2ZGPJ.js +0 -2
  399. package/dist/cli/chunks/dream-4EXVFHUJ.js +0 -2
  400. package/dist/cli/chunks/embed-and-insert-pattern-COAZZGS6.js +0 -3
  401. package/dist/cli/chunks/heartbeat-scheduler-UNEYR3WR.js +0 -2
  402. package/dist/cli/chunks/hnsw-adapter-JQG66H4L.js +0 -2
  403. package/dist/cli/chunks/hnsw-index-2NOROILM.js +0 -2
  404. package/dist/cli/chunks/hybrid-router-FXTAJATE.js +0 -2
  405. package/dist/cli/chunks/impact-analyzer-VHZSBWMT.js +0 -2
  406. package/dist/cli/chunks/init-wizard-EML4OET2.js +0 -2
  407. package/dist/cli/chunks/kernel-TMRJOEO2.js +0 -2
  408. package/dist/cli/chunks/knowledge-graph-FMKVCMJQ.js +0 -2
  409. package/dist/cli/chunks/learning-II2U3EV2.js +0 -119
  410. package/dist/cli/chunks/llm-router-WC66OXZH.js +0 -36
  411. package/dist/cli/chunks/llm-router-service-GOSVGMKM.js +0 -2
  412. package/dist/cli/chunks/load-test-WIRGDZIA.js +0 -2
  413. package/dist/cli/chunks/memory-backend-XBBIXDZU.js +0 -2
  414. package/dist/cli/chunks/memory-handlers-SQHNK3DK.js +0 -2
  415. package/dist/cli/chunks/pattern-null-store-PFLKHRVU.js +0 -2
  416. package/dist/cli/chunks/protocol-executor-GAMNY2JB.js +0 -2
  417. package/dist/cli/chunks/provider-manager-VTIG5AKU.js +0 -2
  418. package/dist/cli/chunks/qe-reasoning-bank-KAX63PXV.js +0 -2
  419. package/dist/cli/chunks/queen-coordinator-UYW2MDKI.js +0 -2
  420. package/dist/cli/chunks/real-embeddings-HHR75AR5.js +0 -2
  421. package/dist/cli/chunks/router-NVDU7IIA.js +0 -2
  422. package/dist/cli/chunks/routing-feedback-KHR3J2J3.js +0 -2
  423. package/dist/cli/chunks/rvf-dual-writer-43L75WLF.js +0 -2
  424. package/dist/cli/chunks/rvf-migration-adapter-Y5OVCYTO.js +0 -2
  425. package/dist/cli/chunks/rvf-migration-coordinator-NEPDFB3N.js +0 -2
  426. package/dist/cli/chunks/rvf-native-adapter-PQ4IOTZU.js +0 -2
  427. package/dist/cli/chunks/safe-db-QHSFV63M.js +0 -2
  428. package/dist/cli/chunks/schedule-JGZFHJGM.js +0 -2
  429. package/dist/cli/chunks/scheduler-NGCDQIW5.js +0 -2
  430. package/dist/cli/chunks/sqlite-persistence-3JSNWL6I.js +0 -2
  431. package/dist/cli/chunks/status-handler-CTXOH3FX.js +0 -47
  432. package/dist/cli/chunks/token-bootstrap-3P22AYZ4.js +0 -2
  433. package/dist/cli/chunks/unified-memory-4VO5KSHP.js +0 -2
  434. package/dist/cli/chunks/unified-memory-hnsw-ZR2FZXOB.js +0 -2
  435. package/dist/cli/chunks/unified-persistence-VFPW5MFM.js +0 -2
  436. package/dist/cli/chunks/visual-security-SNADRUPR.js +0 -2
  437. package/dist/cli/chunks/witness-chain-2TXUTEJE.js +0 -2
  438. package/dist/cli/chunks/workflow-orchestrator-ON6UYRVE.js +0 -2
@@ -46,6 +46,8 @@ export interface PatternStoreConfig {
46
46
  namespace: string;
47
47
  /** Dimension of embedding vectors */
48
48
  embeddingDimension: number;
49
+ /** Runtime-provided provenance override (primarily for injected embedders/tests). */
50
+ embeddingSpaceId?: string;
49
51
  /** HNSW configuration */
50
52
  hnsw: {
51
53
  M: number;
@@ -124,6 +126,8 @@ export interface PatternSearchOptions {
124
126
  context?: Partial<QEPatternContext>;
125
127
  /** Include vector similarity search */
126
128
  useVectorSearch?: boolean;
129
+ /** Provenance of a pre-computed query vector. Required for semantic ranking. */
130
+ embeddingSpaceId?: string;
127
131
  /**
128
132
  * Composable metadata filter expression (Task 1.2: ruvector-filter).
129
133
  * Applied post-search to refine results by domain, severity,
@@ -212,6 +216,7 @@ export declare class PatternStore implements IPatternStore {
212
216
  private typeIndex;
213
217
  private tierIndex;
214
218
  private hnswIndex;
219
+ private hnswSpaceId;
215
220
  private hnswAvailable;
216
221
  private hnswInitPromise;
217
222
  private hdcCache;
@@ -6,6 +6,8 @@
6
6
  * O(log n) approximate nearest neighbor search.
7
7
  */
8
8
  import { v4 as uuidv4 } from 'uuid';
9
+ import { existsSync } from 'node:fs';
10
+ import { join as joinPath } from 'node:path';
9
11
  // Issue #516: lightweight, sqlite-free project-root resolver (static import so it
10
12
  // resolves under the test runner; avoids pulling unified-memory's sqlite graph).
11
13
  import { findProjectRoot } from '../kernel/project-root.js';
@@ -28,6 +30,7 @@ import { createVectorDeltaTracker, } from '../integrations/ruvector/vector-delta
28
30
  import { createHopfieldMemory } from '../integrations/ruvector/hopfield-memory.js';
29
31
  import { createHyperbolicPatternIndex, } from './hyperbolic-pattern-index.js';
30
32
  import { PatternNullStore } from './pattern-null-store.js';
33
+ import { getActiveEmbeddingSpaceIdentity } from './real-embeddings.js';
31
34
  // ============================================================================
32
35
  // R1: HDC Fingerprint Singleton (lazy-initialized)
33
36
  // ============================================================================
@@ -120,6 +123,7 @@ export class PatternStore {
120
123
  // HNSW index for vector search (lazy loaded - ADR-048)
121
124
  // Using dynamic import type since HNSWIndex is lazily loaded
122
125
  hnswIndex = null;
126
+ hnswSpaceId = null;
123
127
  hnswAvailable = false;
124
128
  hnswInitPromise = null;
125
129
  // R1: HDC fingerprint cache (pattern ID -> fingerprint vector)
@@ -206,6 +210,11 @@ export class PatternStore {
206
210
  async ensureHNSW() {
207
211
  // Already initialized
208
212
  if (this.hnswIndex !== null) {
213
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? this.config.embeddingSpaceId ?? null;
214
+ if (this.hnswSpaceId !== activeSpaceId) {
215
+ console.warn('[PatternStore] VECTOR_SPACE_MISMATCH: active embedder changed; semantic index disabled');
216
+ return null;
217
+ }
209
218
  return this.hnswIndex;
210
219
  }
211
220
  // Already marked as unavailable
@@ -234,6 +243,10 @@ export class PatternStore {
234
243
  */
235
244
  async initializeHNSWInternal() {
236
245
  try {
246
+ this.hnswSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? this.config.embeddingSpaceId ?? null;
247
+ if (!this.hnswSpaceId) {
248
+ throw new Error('VECTOR_SPACE_UNVERIFIED: cannot initialize HNSW without runtime provenance');
249
+ }
237
250
  // ADR-071: Use unified HNSW via bridge when flag is enabled
238
251
  const unifiedFlags = getRuVectorFeatureFlags();
239
252
  if (unifiedFlags.useUnifiedHnsw) {
@@ -302,10 +315,11 @@ export class PatternStore {
302
315
  const maxBootstrap = this.config.hnsw.maxElements;
303
316
  let loaded = 0;
304
317
  let skipped = 0;
305
- for (const { patternId, embedding } of embeddings) {
318
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? this.config.embeddingSpaceId;
319
+ for (const { patternId, embedding, spaceId } of embeddings) {
306
320
  if (loaded >= maxBootstrap)
307
321
  break;
308
- if (!embedding || embedding.length !== this.config.embeddingDimension) {
322
+ if (!activeSpaceId || spaceId !== activeSpaceId || !embedding || embedding.length !== this.config.embeddingDimension) {
309
323
  skipped++;
310
324
  continue;
311
325
  }
@@ -429,6 +443,10 @@ export class PatternStore {
429
443
  if (pattern.confidence < this.config.minConfidence) {
430
444
  return err(new Error(`Pattern confidence ${pattern.confidence} below threshold ${this.config.minConfidence}`));
431
445
  }
446
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? this.config.embeddingSpaceId;
447
+ if (pattern.embedding && !activeSpaceId) {
448
+ return err(new Error('VECTOR_SPACE_UNVERIFIED: refusing to persist or index an embedding without runtime provenance'));
449
+ }
432
450
  // Check domain limit
433
451
  const domainCount = this.domainIndex.get(pattern.qeDomain)?.size || 0;
434
452
  if (domainCount >= this.config.maxPatternsPerDomain) {
@@ -442,7 +460,7 @@ export class PatternStore {
442
460
  // Persist to SQLite (pattern + embedding atomically)
443
461
  if (this.sqliteStore) {
444
462
  try {
445
- const actualId = this.sqliteStore.storePattern(pattern, pattern.embedding);
463
+ const actualId = this.sqliteStore.storePattern(pattern, pattern.embedding, activeSpaceId);
446
464
  // #447: ON CONFLICT(name, qe_domain, pattern_type) may preserve an
447
465
  // existing row's id instead of the one we generated — realign the
448
466
  // in-memory indices (and pattern.id itself) or every later
@@ -703,6 +721,10 @@ export class PatternStore {
703
721
  }
704
722
  // Vector search if query is embedding and HNSW available (lazy-load)
705
723
  if (Array.isArray(query) && options.useVectorSearch !== false) {
724
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? this.config.embeddingSpaceId;
725
+ if (!activeSpaceId || options.embeddingSpaceId !== activeSpaceId) {
726
+ throw new Error('VECTOR_SPACE_UNVERIFIED: pre-computed query vectors require the active embeddingSpaceId');
727
+ }
706
728
  const hnsw = await this.ensureHNSW();
707
729
  if (hnsw) {
708
730
  const hnswResults = await hnsw.search(query, limit * 2);
@@ -1410,8 +1432,6 @@ export function createPatternStore(memory, config) {
1410
1432
  // Only use RVF if the data directory exists (created by kernel init).
1411
1433
  // Issue #516: anchor to the project root so a subfolder cwd reads/writes
1412
1434
  // the project's own .agentic-qe/ rather than a cwd-relative stray store.
1413
- const { existsSync } = require('fs');
1414
- const { join: joinPath } = require('path');
1415
1435
  const projectRoot = process.env.AQE_PROJECT_ROOT ?? findProjectRoot();
1416
1436
  const rvfDir = joinPath(projectRoot, '.agentic-qe');
1417
1437
  const rvfPath = joinPath(rvfDir, 'patterns.rvf');
@@ -1431,7 +1451,12 @@ export function createPatternStore(memory, config) {
1431
1451
  const shared = getSharedRvfAdapter(rvfDir, mergedConfig.embeddingDimension);
1432
1452
  if (shared) {
1433
1453
  useSharedAdapter = true;
1434
- const store = new RvfPatternStore(() => shared, { rvfPath, base: mergedConfig, skipCloseOnDispose: true });
1454
+ const store = new RvfPatternStore(() => shared, {
1455
+ rvfPath,
1456
+ base: mergedConfig,
1457
+ skipCloseOnDispose: true,
1458
+ embeddingSpaceId: mergedConfig.embeddingSpaceId,
1459
+ });
1435
1460
  console.log('[PatternStore] Using RVF-backed store (ADR-066)');
1436
1461
  return store;
1437
1462
  }
@@ -1487,7 +1512,11 @@ export function createPatternStore(memory, config) {
1487
1512
  }
1488
1513
  throw createErr;
1489
1514
  }
1490
- }, { rvfPath, base: mergedConfig });
1515
+ }, {
1516
+ rvfPath,
1517
+ base: mergedConfig,
1518
+ embeddingSpaceId: mergedConfig.embeddingSpaceId,
1519
+ });
1491
1520
  console.log('[PatternStore] Using RVF-backed store (ADR-066)');
1492
1521
  return store;
1493
1522
  }
@@ -21,6 +21,7 @@
21
21
  * (the LLM step is the metered part — bind it deliberately).
22
22
  */
23
23
  import type { Database as DatabaseType } from 'better-sqlite3';
24
+ import { type EmbeddingSpaceIdentity } from '../embedding-space.js';
24
25
  import type { RetrievalPolicy } from './policy.js';
25
26
  import type { PolicyScorer } from './generation.js';
26
27
  /** A pattern retrieved as a few-shot example for test generation. */
@@ -73,6 +74,13 @@ export interface SemanticRetrieverOptions {
73
74
  db: DatabaseType;
74
75
  /** Embed a query into the pattern-embedding space. Default: all-MiniLM-L6-v2. */
75
76
  embed?: (text: string) => Promise<number[]>;
77
+ /** Storage-side embedding path used by the executable round-trip canary. */
78
+ writeEmbed?: (text: string) => Promise<number[]>;
79
+ /** Runtime identities for injected embedders. Defaults to the active AQE embedder. */
80
+ embeddingSpace?: EmbeddingSpaceIdentity;
81
+ writeEmbeddingSpace?: EmbeddingSpaceIdentity;
82
+ /** Explicit non-semantic fallback used when provenance cannot be verified. */
83
+ fallback?: RetrieveFn;
76
84
  topK?: number;
77
85
  }
78
86
  /**
@@ -20,7 +20,8 @@
20
20
  * a real policy-weighted DB retriever + an LLM test generator in production
21
21
  * (the LLM step is the metered part — bind it deliberately).
22
22
  */
23
- import { computeRealEmbedding } from '../real-embeddings.js';
23
+ import { computeRealEmbedding, getActiveEmbeddingSpaceIdentity } from '../real-embeddings.js';
24
+ import { EmbeddingSpaceError, inspectEmbeddingSpaceRows, verifyEmbeddingRoundTrip, } from '../embedding-space.js';
24
25
  import { evaluateOracle } from '../../validation/oracle-eval.js';
25
26
  import { loadAnchorSet, anchorMean as meanOf } from '../../validation/anchor-set.js';
26
27
  import { createCorpusScorer } from './corpus-scorer.js';
@@ -124,20 +125,62 @@ function cosine(a, b) {
124
125
  export function createSemanticRetriever(opts) {
125
126
  const embed = opts.embed ?? ((t) => computeRealEmbedding(t));
126
127
  const topK = opts.topK ?? 3;
128
+ const hasSpaceId = opts.db.prepare("PRAGMA table_info('qe_pattern_embeddings')").all()
129
+ .some((column) => column.name === 'space_id');
127
130
  const rows = opts.db.prepare(`SELECT p.id AS id, p.name AS name, COALESCE(p.description,'') AS body,
128
- e.embedding AS embedding, e.dimension AS dimension
131
+ e.embedding AS embedding, e.dimension AS dimension, ${hasSpaceId ? 'e.space_id' : 'NULL'} AS space_id
129
132
  FROM qe_patterns p JOIN qe_pattern_embeddings e ON e.pattern_id = p.id
130
133
  WHERE p.deprecated_at IS NULL`).all();
131
134
  const toks = (s) => new Set(s.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean));
132
135
  const docs = rows.map((r) => ({
133
- id: r.id, name: r.name, body: r.body,
136
+ id: r.id, name: r.name, body: r.body, spaceId: r.space_id,
134
137
  vec: new Float32Array(r.embedding.buffer, r.embedding.byteOffset, r.dimension),
135
138
  nameToks: toks(r.name), bodyToks: toks(r.body),
136
139
  }));
137
140
  const queryCache = new Map();
141
+ let compatibilityCheck = null;
138
142
  return async (query, policy) => {
139
143
  if (docs.length === 0)
140
144
  return [];
145
+ try {
146
+ if (!opts.writeEmbed) {
147
+ throw new EmbeddingSpaceError('VECTOR_SPACE_UNVERIFIED', 'an independent storage-side embedder is required for the write/read canary');
148
+ }
149
+ if (!compatibilityCheck) {
150
+ compatibilityCheck = verifyEmbeddingRoundTrip(opts.writeEmbed, embed);
151
+ }
152
+ try {
153
+ await compatibilityCheck;
154
+ }
155
+ catch (error) {
156
+ compatibilityCheck = null;
157
+ throw error;
158
+ }
159
+ const activeIdentity = opts.embeddingSpace ?? getActiveEmbeddingSpaceIdentity();
160
+ const writeIdentity = opts.writeEmbeddingSpace ?? activeIdentity;
161
+ if (!activeIdentity || !writeIdentity) {
162
+ throw new EmbeddingSpaceError('VECTOR_SPACE_UNVERIFIED', 'runtime embedding-space identity is unavailable');
163
+ }
164
+ if (writeIdentity.spaceId !== activeIdentity.spaceId) {
165
+ throw new EmbeddingSpaceError('VECTOR_SPACE_MISMATCH', `write space ${writeIdentity.spaceId} != query space ${activeIdentity.spaceId}`);
166
+ }
167
+ const invalidDimensions = docs.filter((doc) => doc.vec.length !== activeIdentity.dimensions);
168
+ if (invalidDimensions.length > 0) {
169
+ throw new EmbeddingSpaceError('VECTOR_SPACE_MISMATCH', `${invalidDimensions.length} stored vectors have dimensions incompatible with ${activeIdentity.dimensions}`);
170
+ }
171
+ const diagnostics = inspectEmbeddingSpaceRows(docs.map((doc) => ({ spaceId: doc.spaceId })), activeIdentity.spaceId);
172
+ if (diagnostics.unverifiedVectors > 0) {
173
+ throw new EmbeddingSpaceError('VECTOR_SPACE_UNVERIFIED', `${diagnostics.unverifiedVectors} stored vectors have no provenance`);
174
+ }
175
+ if (diagnostics.status === 'vector_space_mismatch') {
176
+ throw new EmbeddingSpaceError('VECTOR_SPACE_MISMATCH', `stored spaces [${diagnostics.storedSpaceIds.join(', ')}] do not match ${activeIdentity.spaceId}`);
177
+ }
178
+ }
179
+ catch (error) {
180
+ if (opts.fallback)
181
+ return opts.fallback(query, policy);
182
+ throw error;
183
+ }
141
184
  let qv = queryCache.get(query);
142
185
  if (!qv) {
143
186
  qv = new Float32Array(await embed(query));
@@ -22,6 +22,7 @@ import { getGuidance, getCombinedGuidance, generateGuidanceContext, checkAntiPat
22
22
  import { createPatternStore, } from './pattern-store.js';
23
23
  import { createSQLitePatternStore, } from './sqlite-persistence.js';
24
24
  import { getWitnessChain } from '../audit/witness-chain.js';
25
+ import { getActiveEmbeddingSpaceIdentity } from './real-embeddings.js';
25
26
  // Import extracted modules
26
27
  import { DEFAULT_QE_REASONING_BANK_CONFIG } from './qe-reasoning-bank-types.js';
27
28
  import { PRETRAINED_PATTERNS } from './pretrained-patterns.js';
@@ -323,6 +324,9 @@ export class QEReasoningBank {
323
324
  return this.patternStore.search(searchQuery, {
324
325
  ...options,
325
326
  useVectorSearch,
327
+ embeddingSpaceId: typeof query === 'string'
328
+ ? getActiveEmbeddingSpaceIdentity()?.spaceId
329
+ : options?.embeddingSpaceId,
326
330
  });
327
331
  }
328
332
  /**
@@ -7,6 +7,7 @@
7
7
  */
8
8
  export { cosineSimilarity } from '../shared/utils/vector-math.js';
9
9
  import { type EndpointIdentity } from './embedder-endpoint-client.js';
10
+ import { type EmbeddingSpaceIdentity } from './embedding-space.js';
10
11
  /**
11
12
  * Embedding model configuration
12
13
  */
@@ -83,4 +84,6 @@ export declare function isUsingEndpoint(): boolean;
83
84
  * ADR-097: Returns the endpoint identity fingerprint, or null when not using an endpoint.
84
85
  */
85
86
  export declare function getEndpointIdentity(): EndpointIdentity | null;
87
+ /** Runtime-backed identity of the initialized embedding space. */
88
+ export declare function getActiveEmbeddingSpaceIdentity(): EmbeddingSpaceIdentity | null;
86
89
  //# sourceMappingURL=real-embeddings.d.ts.map
@@ -10,6 +10,7 @@ export { cosineSimilarity } from '../shared/utils/vector-math.js';
10
10
  import { toErrorMessage } from '../shared/error-utils.js';
11
11
  import { EmbedderEndpointClient, redactEndpoint, } from './embedder-endpoint-client.js';
12
12
  import { loadEmbedderIdentity, resetEmbedderIdentityStore, saveEmbedderIdentity, } from './embedder-identity-store.js';
13
+ import { EMBEDDING_SPACE_CANARY, deriveEmbeddingSpaceIdentity, fingerprintEmbeddingRuntime, } from './embedding-space.js';
13
14
  // Lazy-loaded transformer pipeline
14
15
  let pipeline = null;
15
16
  let embeddingModel = null;
@@ -22,6 +23,7 @@ let failureReason = '';
22
23
  */
23
24
  let endpointClient = null;
24
25
  let endpointIdentity = null;
26
+ let activeEmbeddingSpaceIdentity = null;
25
27
  export const DEFAULT_EMBEDDING_CONFIG = {
26
28
  modelName: 'Xenova/all-MiniLM-L6-v2',
27
29
  quantized: true,
@@ -100,6 +102,16 @@ async function initializeModel(config = {}) {
100
102
  });
101
103
  // Probe + identity fingerprint. Fails loud on dim mismatch.
102
104
  endpointIdentity = await endpointClient.probe();
105
+ activeEmbeddingSpaceIdentity = deriveEmbeddingSpaceIdentity({
106
+ provider: 'openai-compatible-endpoint',
107
+ model: fullConfig.modelName,
108
+ dimensions: endpointIdentity.dim,
109
+ pooling: 'mean',
110
+ normalized: true,
111
+ preprocessingVersion: 'aqe-text-v1',
112
+ implementation: endpointIdentity.endpoint,
113
+ runtimeFingerprint: endpointIdentity.fingerprint,
114
+ });
103
115
  console.log(`[RealEmbeddings] Endpoint identity: dim=${endpointIdentity.dim} fingerprint=${endpointIdentity.fingerprint}`);
104
116
  // Cross-run drift detection: compare against the last-known identity
105
117
  // for this endpoint (memory.db kv_store, namespace _system). If the
@@ -136,9 +148,11 @@ async function initializeModel(config = {}) {
136
148
  }
137
149
  catch {
138
150
  throw new Error('In-process embeddings require the optional package "@huggingface/transformers", ' +
139
- 'which is not installed. Either run `npm install @huggingface/transformers`, or ' +
140
- 'configure an embedding endpoint (EmbeddingConfig.endpoint / AQE_EMBEDDER_ENDPOINT) ' +
141
- 'so no local model is loaded.');
151
+ 'which is not installed. Configure an embedding endpoint ' +
152
+ '(EmbeddingConfig.endpoint / AQE_EMBEDDER_ENDPOINT) so no local model is loaded. ' +
153
+ 'Installing @huggingface/transformers@4.2.0 is an explicit security opt-in: ' +
154
+ 'its compatible dependency chain currently has unresolved HIGH advisories ' +
155
+ 'GHSA-xcpc-8h2w-3j85 and GHSA-f88m-g3jw-g9cj.');
142
156
  }
143
157
  pipeline = transformers.pipeline;
144
158
  console.log(`[RealEmbeddings] Loading model: ${fullConfig.modelName}`);
@@ -147,6 +161,24 @@ async function initializeModel(config = {}) {
147
161
  embeddingModel = await pipeline('feature-extraction', fullConfig.modelName, {
148
162
  quantized: fullConfig.quantized,
149
163
  });
164
+ const initializedModel = embeddingModel;
165
+ if (!initializedModel)
166
+ throw new Error('Transformer pipeline returned no embedding model');
167
+ const canary = await initializedModel(EMBEDDING_SPACE_CANARY, {
168
+ pooling: 'mean',
169
+ normalize: true,
170
+ });
171
+ const canaryVector = Array.from(canary.data);
172
+ activeEmbeddingSpaceIdentity = deriveEmbeddingSpaceIdentity({
173
+ provider: 'huggingface-transformers',
174
+ model: fullConfig.modelName,
175
+ dimensions: canaryVector.length,
176
+ pooling: 'mean',
177
+ normalized: true,
178
+ preprocessingVersion: 'aqe-text-v1',
179
+ implementation: `transformers:${fullConfig.quantized ? 'quantized' : 'full'}`,
180
+ runtimeFingerprint: fingerprintEmbeddingRuntime(canaryVector),
181
+ });
150
182
  const loadTime = performance.now() - startTime;
151
183
  console.log(`[RealEmbeddings] Model loaded in ${loadTime.toFixed(0)}ms`);
152
184
  }
@@ -356,6 +388,7 @@ export function resetInitialization() {
356
388
  }
357
389
  endpointClient = null;
358
390
  endpointIdentity = null;
391
+ activeEmbeddingSpaceIdentity = null;
359
392
  // Drop the identity-store's cached DB connection so tests that flip cwd or
360
393
  // AQE_MEMORY_PATH between runs don't write into a stale handle.
361
394
  resetEmbedderIdentityStore();
@@ -373,4 +406,8 @@ export function isUsingEndpoint() {
373
406
  export function getEndpointIdentity() {
374
407
  return endpointIdentity;
375
408
  }
409
+ /** Runtime-backed identity of the initialized embedding space. */
410
+ export function getActiveEmbeddingSpaceIdentity() {
411
+ return activeEmbeddingSpaceIdentity;
412
+ }
376
413
  //# sourceMappingURL=real-embeddings.js.map
@@ -19,8 +19,9 @@ import { v4 as uuidv4 } from 'uuid';
19
19
  import { LoggerFactory } from '../logging/index.js';
20
20
  import { toError, toErrorMessage } from '../shared/error-utils.js';
21
21
  import { maybeEnhanceRoutingWithPatterns } from './pattern-routing-guidance.js';
22
+ import { EMBEDDING_SPACE_CANARY } from './embedding-space.js';
22
23
  const logger = LoggerFactory.create('RealQEReasoningBank');
23
- import { computeRealEmbedding, isTransformerAvailable, getEmbeddingDimension, clearEmbeddingCache, } from './real-embeddings.js';
24
+ import { computeRealEmbedding, isTransformerAvailable, getEmbeddingDimension, clearEmbeddingCache, getActiveEmbeddingSpaceIdentity, } from './real-embeddings.js';
24
25
  import { createSQLitePatternStore, } from './sqlite-persistence.js';
25
26
  import { detectQEDomain, detectQEDomains, mapQEDomainToAQE, QE_DOMAIN_LIST, shouldPromotePattern, } from './qe-patterns.js';
26
27
  import { getGuidance, getCombinedGuidance, generateGuidanceContext, checkAntiPatterns, } from './qe-guidance.js';
@@ -164,6 +165,8 @@ export class RealQEReasoningBank {
164
165
  // Initialize SQLite persistence
165
166
  await this.sqliteStore.initialize();
166
167
  logger.info('SQLite persistence initialized');
168
+ // Establish executable provenance before any persisted vectors enter ANN.
169
+ await computeRealEmbedding(EMBEDDING_SPACE_CANARY, this.qeConfig.embeddings);
167
170
  // Initialize HNSW index
168
171
  await this.initializeHNSW();
169
172
  logger.info('HNSW index initialized');
@@ -228,9 +231,10 @@ export class RealQEReasoningBank {
228
231
  const expectedDim = getEmbeddingDimension();
229
232
  let loaded = 0;
230
233
  let skipped = 0;
231
- for (const { patternId, embedding } of embeddings) {
234
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId;
235
+ for (const { patternId, embedding, spaceId } of embeddings) {
232
236
  // Skip invalid or corrupted embeddings
233
- if (!embedding || !Array.isArray(embedding) || embedding.length !== expectedDim) {
237
+ if (!activeSpaceId || spaceId !== activeSpaceId || !embedding || !Array.isArray(embedding) || embedding.length !== expectedDim) {
234
238
  skipped++;
235
239
  continue;
236
240
  }
@@ -33,6 +33,8 @@ export interface MigrationOptions {
33
33
  dimension?: number;
34
34
  /** Log progress every N patterns (default: 1000) */
35
35
  progressInterval?: number;
36
+ /** Runtime embedding space that the destination RVF index is bound to. */
37
+ embeddingSpaceId?: string;
36
38
  }
37
39
  /**
38
40
  * Migrate pattern embeddings from SQLite to an RVF file.
@@ -12,6 +12,7 @@
12
12
  *
13
13
  * @module learning/rvf-pattern-migration
14
14
  */
15
+ import { getActiveEmbeddingSpaceIdentity } from './real-embeddings.js';
15
16
  // ============================================================================
16
17
  // Migration Function
17
18
  // ============================================================================
@@ -52,10 +53,11 @@ export function migratePatterns(sqliteStore, rvfAdapter, options = {}) {
52
53
  console.log(`[RVF Migration] Found ${allEmbeddings.length} embeddings to migrate (dim=${dimension})`);
53
54
  // Process in batches
54
55
  let batch = [];
56
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? options.embeddingSpaceId;
55
57
  for (let i = 0; i < allEmbeddings.length; i++) {
56
- const { patternId, embedding } = allEmbeddings[i];
57
- // Skip if dimension doesn't match
58
- if (embedding.length !== dimension) {
58
+ const { patternId, embedding, spaceId } = allEmbeddings[i];
59
+ // Never mix unknown or incompatible spaces in an ANN file.
60
+ if (!activeSpaceId || spaceId !== activeSpaceId || embedding.length !== dimension) {
59
61
  result.totalSkipped++;
60
62
  continue;
61
63
  }
@@ -22,6 +22,8 @@ export interface RvfPatternStoreConfig {
22
22
  base: PatternStoreConfig;
23
23
  /** When true, dispose() will not close the adapter (shared singleton) */
24
24
  skipCloseOnDispose?: boolean;
25
+ /** Runtime provenance for an injected embedder. */
26
+ embeddingSpaceId?: string;
25
27
  }
26
28
  /**
27
29
  * Pattern store backed by @ruvector/rvf-node for persistent HNSW.
@@ -34,6 +36,7 @@ export declare class RvfPatternStore implements IPatternStore {
34
36
  private readonly config;
35
37
  private readonly rvfPath;
36
38
  private readonly skipCloseOnDispose;
39
+ private readonly embeddingSpaceId?;
37
40
  private adapter;
38
41
  private sqliteStore;
39
42
  private initialized;
@@ -16,6 +16,8 @@ import { ok, err } from '../shared/types/index.js';
16
16
  import { toErrorMessage } from '../shared/error-utils.js';
17
17
  import { calculateQualityScore, validateQEPattern, mapQEDomainToAQE, PROMOTION_THRESHOLD, } from './qe-patterns.js';
18
18
  import { DEFAULT_PATTERN_STORE_CONFIG } from './pattern-store.js';
19
+ import { getActiveEmbeddingSpaceIdentity } from './real-embeddings.js';
20
+ import { verifyOrCreateEmbeddingSpaceManifest } from './embedding-space.js';
19
21
  // ============================================================================
20
22
  // RVF Pattern Store Implementation
21
23
  // ============================================================================
@@ -30,6 +32,7 @@ export class RvfPatternStore {
30
32
  config;
31
33
  rvfPath;
32
34
  skipCloseOnDispose;
35
+ embeddingSpaceId;
33
36
  adapter = null;
34
37
  sqliteStore = null;
35
38
  initialized = false;
@@ -41,6 +44,7 @@ export class RvfPatternStore {
41
44
  this.config = config?.base ?? DEFAULT_PATTERN_STORE_CONFIG;
42
45
  this.rvfPath = config?.rvfPath ?? '.agentic-qe/patterns.rvf';
43
46
  this.skipCloseOnDispose = config?.skipCloseOnDispose ?? false;
47
+ this.embeddingSpaceId = config?.embeddingSpaceId;
44
48
  }
45
49
  /**
46
50
  * Attach SQLite persistence for metadata (pattern fields, FTS5).
@@ -69,6 +73,8 @@ export class RvfPatternStore {
69
73
  }
70
74
  try {
71
75
  this.adapter = this.createAdapter(this.rvfPath, this.config.embeddingDimension);
76
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? this.embeddingSpaceId ?? null;
77
+ verifyOrCreateEmbeddingSpaceManifest(this.rvfPath, activeSpaceId, this.adapter.status()?.totalVectors ?? 0);
72
78
  this.initialized = true;
73
79
  console.log(`[RvfPatternStore] Initialized: ${this.rvfPath} (dim=${this.config.embeddingDimension})`);
74
80
  }
@@ -77,6 +83,10 @@ export class RvfPatternStore {
77
83
  // so they need to know RVF is not working. Log a clear error, set
78
84
  // adapter to null, and mark nativeAvailable=false in stats.
79
85
  this.rvfInitError = toErrorMessage(error);
86
+ try {
87
+ this.adapter?.close();
88
+ }
89
+ catch { /* best effort */ }
80
90
  console.error(`[RvfPatternStore] ERROR: RVF native init failed — vector search is DISABLED. ` +
81
91
  `Cause: ${this.rvfInitError}. ` +
82
92
  `Fix: install @ruvector/rvf-node native bindings, or set useRVFPatternStore=false to use SQLite HNSW.`);
@@ -162,6 +172,10 @@ export class RvfPatternStore {
162
172
  if (pattern.confidence < this.config.minConfidence) {
163
173
  return err(new Error(`Pattern confidence ${pattern.confidence} below threshold ${this.config.minConfidence}`));
164
174
  }
175
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? this.embeddingSpaceId;
176
+ if (pattern.embedding && !activeSpaceId) {
177
+ return err(new Error('VECTOR_SPACE_UNVERIFIED: refusing to persist or index an embedding without runtime provenance'));
178
+ }
165
179
  // Persist metadata to SQLite. #447: capture the returned id — ON CONFLICT
166
180
  // on (name, qe_domain, pattern_type) preserves the existing row's id, so
167
181
  // we must align pattern.id with what's actually stored before ingesting
@@ -169,7 +183,7 @@ export class RvfPatternStore {
169
183
  // with "Pattern not found" and qe_pattern_usage stays empty).
170
184
  if (this.sqliteStore) {
171
185
  try {
172
- const actualId = this.sqliteStore.storePattern(pattern, pattern.embedding);
186
+ const actualId = this.sqliteStore.storePattern(pattern, pattern.embedding, activeSpaceId);
173
187
  if (actualId && actualId !== pattern.id) {
174
188
  // QEPattern.id is `readonly` for callers, but inside the store
175
189
  // we own the lifecycle and must align it with the persisted row
@@ -245,6 +259,12 @@ export class RvfPatternStore {
245
259
  const startTime = performance.now();
246
260
  const limit = options.limit ?? 10;
247
261
  const results = [];
262
+ if (Array.isArray(query)) {
263
+ const activeSpaceId = getActiveEmbeddingSpaceIdentity()?.spaceId ?? this.embeddingSpaceId;
264
+ if (!activeSpaceId || options.embeddingSpaceId !== activeSpaceId) {
265
+ return err(new Error('VECTOR_SPACE_UNVERIFIED: pre-computed query vectors require the active embeddingSpaceId'));
266
+ }
267
+ }
248
268
  // Vector search via RVF native HNSW
249
269
  if (Array.isArray(query) && this.adapter) {
250
270
  try {
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { type Database as DatabaseType } from 'better-sqlite3';
15
15
  import type { QEPattern, QEDomain } from './qe-patterns.js';
16
+ import { type EmbeddingSpaceDiagnostics } from './embedding-space.js';
16
17
  /**
17
18
  * SQLite persistence configuration
18
19
  */
@@ -71,11 +72,12 @@ export declare class SQLitePatternStore {
71
72
  /**
72
73
  * Prepare commonly used statements
73
74
  */
75
+ private ensureEmbeddingSpaceSchema;
74
76
  private prepareStatements;
75
77
  /**
76
78
  * Store a pattern
77
79
  */
78
- storePattern(pattern: QEPattern, embedding?: number[]): string;
80
+ storePattern(pattern: QEPattern, embedding?: number[], embeddingSpaceId?: string): string;
79
81
  /**
80
82
  * Get a pattern by ID
81
83
  */
@@ -113,6 +115,7 @@ export declare class SQLitePatternStore {
113
115
  getAllEmbeddings(): Array<{
114
116
  patternId: string;
115
117
  embedding: number[];
118
+ spaceId: string | null;
116
119
  }>;
117
120
  /**
118
121
  * Get up to `limit` embeddings, most-recently-used first.
@@ -124,7 +127,9 @@ export declare class SQLitePatternStore {
124
127
  getRecentEmbeddings(limit: number): Array<{
125
128
  patternId: string;
126
129
  embedding: number[];
130
+ spaceId: string | null;
127
131
  }>;
132
+ getEmbeddingSpaceDiagnostics(activeSpaceId?: string | null): EmbeddingSpaceDiagnostics;
128
133
  /**
129
134
  * Record pattern usage.
130
135
  *
@@ -191,7 +196,7 @@ export declare class SQLitePatternStore {
191
196
  /**
192
197
  * Store embedding for an existing pattern
193
198
  */
194
- storePatternEmbedding(patternId: string, embedding: number[]): void;
199
+ storePatternEmbedding(patternId: string, embedding: number[], embeddingSpaceId?: string): void;
195
200
  /**
196
201
  * Record pattern reuse for metrics tracking (Phase 5.4)
197
202
  *