agentic-qe 3.2.3 → 3.3.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 (340) hide show
  1. package/.claude/agents/v3/qe-accessibility-auditor.md +90 -0
  2. package/README.md +43 -5
  3. package/package.json +3 -2
  4. package/scripts/cloud-db-config.json +37 -0
  5. package/scripts/cloud-db-connect.sh +37 -0
  6. package/scripts/cloud-db-tunnel.sh +23 -0
  7. package/v3/CHANGELOG.md +165 -0
  8. package/v3/README.md +59 -1
  9. package/v3/assets/agents/v3/qe-accessibility-auditor.md +90 -0
  10. package/v3/dist/adapters/claude-flow/index.d.ts +54 -0
  11. package/v3/dist/adapters/claude-flow/index.d.ts.map +1 -0
  12. package/v3/dist/adapters/claude-flow/index.js +79 -0
  13. package/v3/dist/adapters/claude-flow/index.js.map +1 -0
  14. package/v3/dist/adapters/claude-flow/model-router-bridge.d.ts +70 -0
  15. package/v3/dist/adapters/claude-flow/model-router-bridge.d.ts.map +1 -0
  16. package/v3/dist/adapters/claude-flow/model-router-bridge.js +203 -0
  17. package/v3/dist/adapters/claude-flow/model-router-bridge.js.map +1 -0
  18. package/v3/dist/adapters/claude-flow/pretrain-bridge.d.ts +73 -0
  19. package/v3/dist/adapters/claude-flow/pretrain-bridge.d.ts.map +1 -0
  20. package/v3/dist/adapters/claude-flow/pretrain-bridge.js +276 -0
  21. package/v3/dist/adapters/claude-flow/pretrain-bridge.js.map +1 -0
  22. package/v3/dist/adapters/claude-flow/trajectory-bridge.d.ts +70 -0
  23. package/v3/dist/adapters/claude-flow/trajectory-bridge.d.ts.map +1 -0
  24. package/v3/dist/adapters/claude-flow/trajectory-bridge.js +205 -0
  25. package/v3/dist/adapters/claude-flow/trajectory-bridge.js.map +1 -0
  26. package/v3/dist/adapters/claude-flow/types.d.ts +99 -0
  27. package/v3/dist/adapters/claude-flow/types.d.ts.map +1 -0
  28. package/v3/dist/adapters/claude-flow/types.js +6 -0
  29. package/v3/dist/adapters/claude-flow/types.js.map +1 -0
  30. package/v3/dist/causal-discovery/causal-graph.d.ts +80 -1
  31. package/v3/dist/causal-discovery/causal-graph.d.ts.map +1 -1
  32. package/v3/dist/causal-discovery/causal-graph.js +111 -1
  33. package/v3/dist/causal-discovery/causal-graph.js.map +1 -1
  34. package/v3/dist/cli/bundle.js +11612 -4929
  35. package/v3/dist/cli/commands/claude-flow-setup.d.ts +82 -0
  36. package/v3/dist/cli/commands/claude-flow-setup.d.ts.map +1 -0
  37. package/v3/dist/cli/commands/claude-flow-setup.js +334 -0
  38. package/v3/dist/cli/commands/claude-flow-setup.js.map +1 -0
  39. package/v3/dist/cli/commands/hooks.d.ts +2 -0
  40. package/v3/dist/cli/commands/hooks.d.ts.map +1 -1
  41. package/v3/dist/cli/commands/hooks.js +13 -2
  42. package/v3/dist/cli/commands/hooks.js.map +1 -1
  43. package/v3/dist/cli/commands/init.d.ts +19 -0
  44. package/v3/dist/cli/commands/init.d.ts.map +1 -0
  45. package/v3/dist/cli/commands/init.js +345 -0
  46. package/v3/dist/cli/commands/init.js.map +1 -0
  47. package/v3/dist/cli/index.js +110 -2
  48. package/v3/dist/cli/index.js.map +1 -1
  49. package/v3/dist/coordination/mincut/interfaces.d.ts +8 -2
  50. package/v3/dist/coordination/mincut/interfaces.d.ts.map +1 -1
  51. package/v3/dist/coordination/mincut/interfaces.js.map +1 -1
  52. package/v3/dist/coordination/mincut/mincut-health-monitor.d.ts +5 -0
  53. package/v3/dist/coordination/mincut/mincut-health-monitor.d.ts.map +1 -1
  54. package/v3/dist/coordination/mincut/mincut-health-monitor.js +22 -4
  55. package/v3/dist/coordination/mincut/mincut-health-monitor.js.map +1 -1
  56. package/v3/dist/coordination/mincut/queen-integration.d.ts +4 -0
  57. package/v3/dist/coordination/mincut/queen-integration.d.ts.map +1 -1
  58. package/v3/dist/coordination/mincut/queen-integration.js +14 -1
  59. package/v3/dist/coordination/mincut/queen-integration.js.map +1 -1
  60. package/v3/dist/coordination/queen-coordinator.d.ts +5 -0
  61. package/v3/dist/coordination/queen-coordinator.d.ts.map +1 -1
  62. package/v3/dist/coordination/queen-coordinator.js +45 -7
  63. package/v3/dist/coordination/queen-coordinator.js.map +1 -1
  64. package/v3/dist/domains/learning-optimization/coordinator.d.ts +5 -0
  65. package/v3/dist/domains/learning-optimization/coordinator.d.ts.map +1 -1
  66. package/v3/dist/domains/learning-optimization/coordinator.js +79 -0
  67. package/v3/dist/domains/learning-optimization/coordinator.js.map +1 -1
  68. package/v3/dist/domains/test-generation/coherence-gate.d.ts +245 -0
  69. package/v3/dist/domains/test-generation/coherence-gate.d.ts.map +1 -0
  70. package/v3/dist/domains/test-generation/coherence-gate.js +454 -0
  71. package/v3/dist/domains/test-generation/coherence-gate.js.map +1 -0
  72. package/v3/dist/domains/test-generation/coordinator.d.ts +32 -1
  73. package/v3/dist/domains/test-generation/coordinator.d.ts.map +1 -1
  74. package/v3/dist/domains/test-generation/coordinator.js +70 -1
  75. package/v3/dist/domains/test-generation/coordinator.js.map +1 -1
  76. package/v3/dist/domains/test-generation/index.d.ts +1 -0
  77. package/v3/dist/domains/test-generation/index.d.ts.map +1 -1
  78. package/v3/dist/domains/test-generation/index.js +4 -0
  79. package/v3/dist/domains/test-generation/index.js.map +1 -1
  80. package/v3/dist/domains/test-generation/services/index.d.ts +1 -0
  81. package/v3/dist/domains/test-generation/services/index.d.ts.map +1 -1
  82. package/v3/dist/domains/test-generation/services/index.js +2 -0
  83. package/v3/dist/domains/test-generation/services/index.js.map +1 -1
  84. package/v3/dist/domains/visual-accessibility/index.d.ts +2 -1
  85. package/v3/dist/domains/visual-accessibility/index.d.ts.map +1 -1
  86. package/v3/dist/domains/visual-accessibility/index.js +1 -0
  87. package/v3/dist/domains/visual-accessibility/index.js.map +1 -1
  88. package/v3/dist/domains/visual-accessibility/interfaces.d.ts +131 -0
  89. package/v3/dist/domains/visual-accessibility/interfaces.d.ts.map +1 -1
  90. package/v3/dist/domains/visual-accessibility/plugin.d.ts +26 -0
  91. package/v3/dist/domains/visual-accessibility/plugin.d.ts.map +1 -1
  92. package/v3/dist/domains/visual-accessibility/plugin.js +151 -0
  93. package/v3/dist/domains/visual-accessibility/plugin.js.map +1 -1
  94. package/v3/dist/domains/visual-accessibility/services/accessibility-tester.d.ts +42 -1
  95. package/v3/dist/domains/visual-accessibility/services/accessibility-tester.d.ts.map +1 -1
  96. package/v3/dist/domains/visual-accessibility/services/accessibility-tester.js +69 -0
  97. package/v3/dist/domains/visual-accessibility/services/accessibility-tester.js.map +1 -1
  98. package/v3/dist/domains/visual-accessibility/services/eu-compliance.d.ts +138 -0
  99. package/v3/dist/domains/visual-accessibility/services/eu-compliance.d.ts.map +1 -0
  100. package/v3/dist/domains/visual-accessibility/services/eu-compliance.js +830 -0
  101. package/v3/dist/domains/visual-accessibility/services/eu-compliance.js.map +1 -0
  102. package/v3/dist/domains/visual-accessibility/services/index.d.ts +1 -0
  103. package/v3/dist/domains/visual-accessibility/services/index.d.ts.map +1 -1
  104. package/v3/dist/domains/visual-accessibility/services/index.js +1 -0
  105. package/v3/dist/domains/visual-accessibility/services/index.js.map +1 -1
  106. package/v3/dist/init/enhancements/claude-flow-adapter.d.ts +84 -0
  107. package/v3/dist/init/enhancements/claude-flow-adapter.d.ts.map +1 -0
  108. package/v3/dist/init/enhancements/claude-flow-adapter.js +250 -0
  109. package/v3/dist/init/enhancements/claude-flow-adapter.js.map +1 -0
  110. package/v3/dist/init/enhancements/detector.d.ts +10 -0
  111. package/v3/dist/init/enhancements/detector.d.ts.map +1 -0
  112. package/v3/dist/init/enhancements/detector.js +87 -0
  113. package/v3/dist/init/enhancements/detector.js.map +1 -0
  114. package/v3/dist/init/enhancements/index.d.ts +13 -0
  115. package/v3/dist/init/enhancements/index.d.ts.map +1 -0
  116. package/v3/dist/init/enhancements/index.js +25 -0
  117. package/v3/dist/init/enhancements/index.js.map +1 -0
  118. package/v3/dist/init/enhancements/types.d.ts +93 -0
  119. package/v3/dist/init/enhancements/types.d.ts.map +1 -0
  120. package/v3/dist/init/enhancements/types.js +6 -0
  121. package/v3/dist/init/enhancements/types.js.map +1 -0
  122. package/v3/dist/init/index.d.ts +8 -0
  123. package/v3/dist/init/index.d.ts.map +1 -1
  124. package/v3/dist/init/index.js +4 -0
  125. package/v3/dist/init/index.js.map +1 -1
  126. package/v3/dist/init/migration/config-migrator.d.ts +31 -0
  127. package/v3/dist/init/migration/config-migrator.d.ts.map +1 -0
  128. package/v3/dist/init/migration/config-migrator.js +133 -0
  129. package/v3/dist/init/migration/config-migrator.js.map +1 -0
  130. package/v3/dist/init/migration/data-migrator.d.ts +72 -0
  131. package/v3/dist/init/migration/data-migrator.d.ts.map +1 -0
  132. package/v3/dist/init/migration/data-migrator.js +233 -0
  133. package/v3/dist/init/migration/data-migrator.js.map +1 -0
  134. package/v3/dist/init/migration/detector.d.ts +44 -0
  135. package/v3/dist/init/migration/detector.d.ts.map +1 -0
  136. package/v3/dist/init/migration/detector.js +106 -0
  137. package/v3/dist/init/migration/detector.js.map +1 -0
  138. package/v3/dist/init/migration/index.d.ts +8 -0
  139. package/v3/dist/init/migration/index.d.ts.map +1 -0
  140. package/v3/dist/init/migration/index.js +8 -0
  141. package/v3/dist/init/migration/index.js.map +1 -0
  142. package/v3/dist/init/orchestrator.d.ts +68 -0
  143. package/v3/dist/init/orchestrator.d.ts.map +1 -0
  144. package/v3/dist/init/orchestrator.js +239 -0
  145. package/v3/dist/init/orchestrator.js.map +1 -0
  146. package/v3/dist/init/phases/01-detection.d.ts +30 -0
  147. package/v3/dist/init/phases/01-detection.d.ts.map +1 -0
  148. package/v3/dist/init/phases/01-detection.js +143 -0
  149. package/v3/dist/init/phases/01-detection.js.map +1 -0
  150. package/v3/dist/init/phases/02-analysis.d.ts +18 -0
  151. package/v3/dist/init/phases/02-analysis.d.ts.map +1 -0
  152. package/v3/dist/init/phases/02-analysis.js +28 -0
  153. package/v3/dist/init/phases/02-analysis.js.map +1 -0
  154. package/v3/dist/init/phases/03-configuration.d.ts +26 -0
  155. package/v3/dist/init/phases/03-configuration.d.ts.map +1 -0
  156. package/v3/dist/init/phases/03-configuration.js +98 -0
  157. package/v3/dist/init/phases/03-configuration.js.map +1 -0
  158. package/v3/dist/init/phases/04-database.d.ts +22 -0
  159. package/v3/dist/init/phases/04-database.d.ts.map +1 -0
  160. package/v3/dist/init/phases/04-database.js +88 -0
  161. package/v3/dist/init/phases/04-database.js.map +1 -0
  162. package/v3/dist/init/phases/05-learning.d.ts +28 -0
  163. package/v3/dist/init/phases/05-learning.d.ts.map +1 -0
  164. package/v3/dist/init/phases/05-learning.js +98 -0
  165. package/v3/dist/init/phases/05-learning.js.map +1 -0
  166. package/v3/dist/init/phases/06-code-intelligence.d.ts +33 -0
  167. package/v3/dist/init/phases/06-code-intelligence.d.ts.map +1 -0
  168. package/v3/dist/init/phases/06-code-intelligence.js +115 -0
  169. package/v3/dist/init/phases/06-code-intelligence.js.map +1 -0
  170. package/v3/dist/init/phases/07-hooks.d.ts +27 -0
  171. package/v3/dist/init/phases/07-hooks.d.ts.map +1 -0
  172. package/v3/dist/init/phases/07-hooks.js +209 -0
  173. package/v3/dist/init/phases/07-hooks.js.map +1 -0
  174. package/v3/dist/init/phases/08-mcp.d.ts +22 -0
  175. package/v3/dist/init/phases/08-mcp.d.ts.map +1 -0
  176. package/v3/dist/init/phases/08-mcp.js +62 -0
  177. package/v3/dist/init/phases/08-mcp.js.map +1 -0
  178. package/v3/dist/init/phases/09-assets.d.ts +23 -0
  179. package/v3/dist/init/phases/09-assets.d.ts.map +1 -0
  180. package/v3/dist/init/phases/09-assets.js +82 -0
  181. package/v3/dist/init/phases/09-assets.js.map +1 -0
  182. package/v3/dist/init/phases/10-workers.d.ts +23 -0
  183. package/v3/dist/init/phases/10-workers.d.ts.map +1 -0
  184. package/v3/dist/init/phases/10-workers.js +111 -0
  185. package/v3/dist/init/phases/10-workers.js.map +1 -0
  186. package/v3/dist/init/phases/11-claude-md.d.ts +26 -0
  187. package/v3/dist/init/phases/11-claude-md.d.ts.map +1 -0
  188. package/v3/dist/init/phases/11-claude-md.js +121 -0
  189. package/v3/dist/init/phases/11-claude-md.js.map +1 -0
  190. package/v3/dist/init/phases/12-verification.d.ts +38 -0
  191. package/v3/dist/init/phases/12-verification.d.ts.map +1 -0
  192. package/v3/dist/init/phases/12-verification.js +187 -0
  193. package/v3/dist/init/phases/12-verification.js.map +1 -0
  194. package/v3/dist/init/phases/index.d.ts +46 -0
  195. package/v3/dist/init/phases/index.d.ts.map +1 -0
  196. package/v3/dist/init/phases/index.js +64 -0
  197. package/v3/dist/init/phases/index.js.map +1 -0
  198. package/v3/dist/init/phases/phase-interface.d.ts +193 -0
  199. package/v3/dist/init/phases/phase-interface.d.ts.map +1 -0
  200. package/v3/dist/init/phases/phase-interface.js +119 -0
  201. package/v3/dist/init/phases/phase-interface.js.map +1 -0
  202. package/v3/dist/integrations/coherence/coherence-service.d.ts +323 -0
  203. package/v3/dist/integrations/coherence/coherence-service.d.ts.map +1 -0
  204. package/v3/dist/integrations/coherence/coherence-service.js +799 -0
  205. package/v3/dist/integrations/coherence/coherence-service.js.map +1 -0
  206. package/v3/dist/integrations/coherence/engines/category-adapter.d.ts +170 -0
  207. package/v3/dist/integrations/coherence/engines/category-adapter.d.ts.map +1 -0
  208. package/v3/dist/integrations/coherence/engines/category-adapter.js +403 -0
  209. package/v3/dist/integrations/coherence/engines/category-adapter.js.map +1 -0
  210. package/v3/dist/integrations/coherence/engines/causal-adapter.d.ts +159 -0
  211. package/v3/dist/integrations/coherence/engines/causal-adapter.d.ts.map +1 -0
  212. package/v3/dist/integrations/coherence/engines/causal-adapter.js +348 -0
  213. package/v3/dist/integrations/coherence/engines/causal-adapter.js.map +1 -0
  214. package/v3/dist/integrations/coherence/engines/cohomology-adapter.d.ts +174 -0
  215. package/v3/dist/integrations/coherence/engines/cohomology-adapter.d.ts.map +1 -0
  216. package/v3/dist/integrations/coherence/engines/cohomology-adapter.js +401 -0
  217. package/v3/dist/integrations/coherence/engines/cohomology-adapter.js.map +1 -0
  218. package/v3/dist/integrations/coherence/engines/homotopy-adapter.d.ts +201 -0
  219. package/v3/dist/integrations/coherence/engines/homotopy-adapter.d.ts.map +1 -0
  220. package/v3/dist/integrations/coherence/engines/homotopy-adapter.js +324 -0
  221. package/v3/dist/integrations/coherence/engines/homotopy-adapter.js.map +1 -0
  222. package/v3/dist/integrations/coherence/engines/index.d.ts +20 -0
  223. package/v3/dist/integrations/coherence/engines/index.d.ts.map +1 -0
  224. package/v3/dist/integrations/coherence/engines/index.js +26 -0
  225. package/v3/dist/integrations/coherence/engines/index.js.map +1 -0
  226. package/v3/dist/integrations/coherence/engines/spectral-adapter.d.ts +193 -0
  227. package/v3/dist/integrations/coherence/engines/spectral-adapter.d.ts.map +1 -0
  228. package/v3/dist/integrations/coherence/engines/spectral-adapter.js +476 -0
  229. package/v3/dist/integrations/coherence/engines/spectral-adapter.js.map +1 -0
  230. package/v3/dist/integrations/coherence/engines/witness-adapter.d.ts +175 -0
  231. package/v3/dist/integrations/coherence/engines/witness-adapter.d.ts.map +1 -0
  232. package/v3/dist/integrations/coherence/engines/witness-adapter.js +377 -0
  233. package/v3/dist/integrations/coherence/engines/witness-adapter.js.map +1 -0
  234. package/v3/dist/integrations/coherence/index.d.ts +84 -0
  235. package/v3/dist/integrations/coherence/index.d.ts.map +1 -0
  236. package/v3/dist/integrations/coherence/index.js +114 -0
  237. package/v3/dist/integrations/coherence/index.js.map +1 -0
  238. package/v3/dist/integrations/coherence/threshold-tuner.d.ts +396 -0
  239. package/v3/dist/integrations/coherence/threshold-tuner.d.ts.map +1 -0
  240. package/v3/dist/integrations/coherence/threshold-tuner.js +538 -0
  241. package/v3/dist/integrations/coherence/threshold-tuner.js.map +1 -0
  242. package/v3/dist/integrations/coherence/types.d.ts +879 -0
  243. package/v3/dist/integrations/coherence/types.d.ts.map +1 -0
  244. package/v3/dist/integrations/coherence/types.js +134 -0
  245. package/v3/dist/integrations/coherence/types.js.map +1 -0
  246. package/v3/dist/integrations/coherence/wasm-loader.d.ts +351 -0
  247. package/v3/dist/integrations/coherence/wasm-loader.d.ts.map +1 -0
  248. package/v3/dist/integrations/coherence/wasm-loader.js +842 -0
  249. package/v3/dist/integrations/coherence/wasm-loader.js.map +1 -0
  250. package/v3/dist/integrations/embeddings/index/HNSWIndex.d.ts.map +1 -1
  251. package/v3/dist/integrations/embeddings/index/HNSWIndex.js +4 -1
  252. package/v3/dist/integrations/embeddings/index/HNSWIndex.js.map +1 -1
  253. package/v3/dist/kernel/interfaces.d.ts +8 -1
  254. package/v3/dist/kernel/interfaces.d.ts.map +1 -1
  255. package/v3/dist/learning/aqe-learning-engine.d.ts +272 -0
  256. package/v3/dist/learning/aqe-learning-engine.d.ts.map +1 -0
  257. package/v3/dist/learning/aqe-learning-engine.js +708 -0
  258. package/v3/dist/learning/aqe-learning-engine.js.map +1 -0
  259. package/v3/dist/learning/causal-verifier.d.ts +244 -0
  260. package/v3/dist/learning/causal-verifier.d.ts.map +1 -0
  261. package/v3/dist/learning/causal-verifier.js +300 -0
  262. package/v3/dist/learning/causal-verifier.js.map +1 -0
  263. package/v3/dist/learning/experience-capture.d.ts +266 -0
  264. package/v3/dist/learning/experience-capture.d.ts.map +1 -0
  265. package/v3/dist/learning/experience-capture.js +647 -0
  266. package/v3/dist/learning/experience-capture.js.map +1 -0
  267. package/v3/dist/learning/index.d.ts +8 -0
  268. package/v3/dist/learning/index.d.ts.map +1 -1
  269. package/v3/dist/learning/index.js +16 -0
  270. package/v3/dist/learning/index.js.map +1 -1
  271. package/v3/dist/learning/memory-auditor.d.ts +235 -0
  272. package/v3/dist/learning/memory-auditor.d.ts.map +1 -0
  273. package/v3/dist/learning/memory-auditor.js +478 -0
  274. package/v3/dist/learning/memory-auditor.js.map +1 -0
  275. package/v3/dist/learning/pattern-store.d.ts.map +1 -1
  276. package/v3/dist/learning/pattern-store.js +27 -6
  277. package/v3/dist/learning/pattern-store.js.map +1 -1
  278. package/v3/dist/learning/qe-patterns.d.ts +15 -1
  279. package/v3/dist/learning/qe-patterns.d.ts.map +1 -1
  280. package/v3/dist/learning/qe-patterns.js +26 -5
  281. package/v3/dist/learning/qe-patterns.js.map +1 -1
  282. package/v3/dist/learning/qe-reasoning-bank.d.ts +38 -2
  283. package/v3/dist/learning/qe-reasoning-bank.d.ts.map +1 -1
  284. package/v3/dist/learning/qe-reasoning-bank.js +86 -4
  285. package/v3/dist/learning/qe-reasoning-bank.js.map +1 -1
  286. package/v3/dist/learning/real-qe-reasoning-bank.d.ts +32 -2
  287. package/v3/dist/learning/real-qe-reasoning-bank.d.ts.map +1 -1
  288. package/v3/dist/learning/real-qe-reasoning-bank.js +61 -6
  289. package/v3/dist/learning/real-qe-reasoning-bank.js.map +1 -1
  290. package/v3/dist/mcp/bundle.js +6303 -266
  291. package/v3/dist/mcp/tools/coherence/audit.d.ts +107 -0
  292. package/v3/dist/mcp/tools/coherence/audit.d.ts.map +1 -0
  293. package/v3/dist/mcp/tools/coherence/audit.js +236 -0
  294. package/v3/dist/mcp/tools/coherence/audit.js.map +1 -0
  295. package/v3/dist/mcp/tools/coherence/check.d.ts +106 -0
  296. package/v3/dist/mcp/tools/coherence/check.d.ts.map +1 -0
  297. package/v3/dist/mcp/tools/coherence/check.js +205 -0
  298. package/v3/dist/mcp/tools/coherence/check.js.map +1 -0
  299. package/v3/dist/mcp/tools/coherence/collapse.d.ts +123 -0
  300. package/v3/dist/mcp/tools/coherence/collapse.d.ts.map +1 -0
  301. package/v3/dist/mcp/tools/coherence/collapse.js +279 -0
  302. package/v3/dist/mcp/tools/coherence/collapse.js.map +1 -0
  303. package/v3/dist/mcp/tools/coherence/consensus.d.ts +100 -0
  304. package/v3/dist/mcp/tools/coherence/consensus.d.ts.map +1 -0
  305. package/v3/dist/mcp/tools/coherence/consensus.js +201 -0
  306. package/v3/dist/mcp/tools/coherence/consensus.js.map +1 -0
  307. package/v3/dist/mcp/tools/coherence/index.d.ts +31 -0
  308. package/v3/dist/mcp/tools/coherence/index.d.ts.map +1 -0
  309. package/v3/dist/mcp/tools/coherence/index.js +42 -0
  310. package/v3/dist/mcp/tools/coherence/index.js.map +1 -0
  311. package/v3/dist/mcp/tools/index.d.ts +6 -1
  312. package/v3/dist/mcp/tools/index.d.ts.map +1 -1
  313. package/v3/dist/mcp/tools/index.js +9 -1
  314. package/v3/dist/mcp/tools/index.js.map +1 -1
  315. package/v3/dist/mcp/tools/mincut/index.d.ts +1 -1
  316. package/v3/dist/mcp/tools/mincut/index.d.ts.map +1 -1
  317. package/v3/dist/mcp/tools/mincut/index.js.map +1 -1
  318. package/v3/dist/mcp/tools/registry.d.ts +4 -0
  319. package/v3/dist/mcp/tools/registry.d.ts.map +1 -1
  320. package/v3/dist/mcp/tools/registry.js +5 -0
  321. package/v3/dist/mcp/tools/registry.js.map +1 -1
  322. package/v3/dist/mcp/types.d.ts +1 -1
  323. package/v3/dist/mcp/types.d.ts.map +1 -1
  324. package/v3/dist/strange-loop/belief-reconciler.d.ts +357 -0
  325. package/v3/dist/strange-loop/belief-reconciler.d.ts.map +1 -0
  326. package/v3/dist/strange-loop/belief-reconciler.js +696 -0
  327. package/v3/dist/strange-loop/belief-reconciler.js.map +1 -0
  328. package/v3/dist/strange-loop/index.d.ts +1 -0
  329. package/v3/dist/strange-loop/index.d.ts.map +1 -1
  330. package/v3/dist/strange-loop/index.js +2 -0
  331. package/v3/dist/strange-loop/index.js.map +1 -1
  332. package/v3/dist/strange-loop/strange-loop.d.ts +177 -5
  333. package/v3/dist/strange-loop/strange-loop.d.ts.map +1 -1
  334. package/v3/dist/strange-loop/strange-loop.js +452 -9
  335. package/v3/dist/strange-loop/strange-loop.js.map +1 -1
  336. package/v3/dist/strange-loop/types.d.ts +205 -1
  337. package/v3/dist/strange-loop/types.d.ts.map +1 -1
  338. package/v3/dist/strange-loop/types.js +5 -0
  339. package/v3/dist/strange-loop/types.js.map +1 -1
  340. package/v3/package.json +5 -1
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Agentic QE v3 - Coherence Audit Memory MCP Tool
3
+ * ADR-052: Phase 4 Action A4.1
4
+ *
5
+ * qe/coherence/audit - Audit QE memory for contradictions
6
+ *
7
+ * Uses the MemoryCoherenceAuditor to scan QE patterns for coherence issues,
8
+ * detecting contradictions and generating remediation recommendations.
9
+ */
10
+ import { MCPToolBase, MCPToolConfig, MCPToolContext } from '../base.js';
11
+ import { ToolResult } from '../../types.js';
12
+ /**
13
+ * Parameters for memory audit
14
+ */
15
+ export interface CoherenceAuditParams {
16
+ /** Namespace to audit (default: 'qe-patterns') */
17
+ namespace?: string;
18
+ /** Maximum patterns to scan (default: 1000) */
19
+ maxPatterns?: number;
20
+ /** Energy threshold for flagging issues (default: 0.4) */
21
+ energyThreshold?: number;
22
+ /** Include detailed pattern information in results */
23
+ includeDetails?: boolean;
24
+ /** Index signature for Record<string, unknown> compatibility */
25
+ [key: string]: unknown;
26
+ }
27
+ /**
28
+ * Result of memory audit
29
+ */
30
+ export interface CoherenceAuditResult {
31
+ /** Total number of patterns in the database */
32
+ totalPatterns: number;
33
+ /** Number of patterns scanned in this audit */
34
+ scannedPatterns: number;
35
+ /** Number of contradictions found */
36
+ contradictionCount: number;
37
+ /** Overall coherence energy (lower = more coherent) */
38
+ globalEnergy: number;
39
+ /** High-energy domains requiring attention */
40
+ hotspots: Array<{
41
+ domain: string;
42
+ patternIds: string[];
43
+ energy: number;
44
+ description: string;
45
+ }>;
46
+ /** Actionable recommendations */
47
+ recommendations: Array<{
48
+ type: 'merge' | 'remove' | 'review' | 'split';
49
+ patternIds: string[];
50
+ reason: string;
51
+ priority: 'low' | 'medium' | 'high';
52
+ }>;
53
+ /** Audit duration in milliseconds */
54
+ durationMs: number;
55
+ /** Audit timestamp */
56
+ timestamp: string;
57
+ /** Memory health score (0-100, higher = healthier) */
58
+ healthScore: number;
59
+ }
60
+ /**
61
+ * Coherence Audit Memory Tool
62
+ *
63
+ * Scans QE patterns for coherence issues using Prime Radiant:
64
+ * - Detects contradictory patterns
65
+ * - Identifies duplicate/overlapping patterns
66
+ * - Flags outdated patterns with low usage
67
+ * - Generates remediation recommendations
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const result = await tool.invoke({
72
+ * namespace: 'qe-patterns',
73
+ * maxPatterns: 500,
74
+ * energyThreshold: 0.5,
75
+ * });
76
+ *
77
+ * console.log(`Health Score: ${result.data.healthScore}/100`);
78
+ * console.log('Hotspots:', result.data.hotspots);
79
+ * console.log('Recommendations:', result.data.recommendations);
80
+ * ```
81
+ */
82
+ export declare class CoherenceAuditTool extends MCPToolBase<CoherenceAuditParams, CoherenceAuditResult> {
83
+ readonly config: MCPToolConfig;
84
+ private coherenceService;
85
+ private auditor;
86
+ /**
87
+ * Get or create the CoherenceService instance
88
+ */
89
+ private getService;
90
+ /**
91
+ * Reset instance cache (called when fleet is disposed)
92
+ */
93
+ resetInstanceCache(): void;
94
+ /**
95
+ * Execute the memory audit
96
+ */
97
+ execute(params: CoherenceAuditParams, context: MCPToolContext): Promise<ToolResult<CoherenceAuditResult>>;
98
+ /**
99
+ * Calculate memory health score (0-100)
100
+ */
101
+ private calculateHealthScore;
102
+ }
103
+ /**
104
+ * Create a CoherenceAuditTool instance
105
+ */
106
+ export declare function createCoherenceAuditTool(): CoherenceAuditTool;
107
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/coherence/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,EAGf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAsB5C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,eAAe,CAAC,EAAE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,OAAO,CACX,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IA+H5C;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAoB7B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,kBAAkB,CAE7D"}
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Agentic QE v3 - Coherence Audit Memory MCP Tool
3
+ * ADR-052: Phase 4 Action A4.1
4
+ *
5
+ * qe/coherence/audit - Audit QE memory for contradictions
6
+ *
7
+ * Uses the MemoryCoherenceAuditor to scan QE patterns for coherence issues,
8
+ * detecting contradictions and generating remediation recommendations.
9
+ */
10
+ import { MCPToolBase, getSharedMemoryBackend, } from '../base.js';
11
+ import { createCoherenceService, wasmLoader, } from '../../../integrations/coherence/index.js';
12
+ import { createMemoryAuditor, } from '../../../learning/index.js';
13
+ import { createPatternStore, } from '../../../learning/index.js';
14
+ // ============================================================================
15
+ // Schema
16
+ // ============================================================================
17
+ const COHERENCE_AUDIT_SCHEMA = {
18
+ type: 'object',
19
+ properties: {
20
+ namespace: {
21
+ type: 'string',
22
+ description: 'Namespace to audit (default: qe-patterns)',
23
+ default: 'qe-patterns',
24
+ },
25
+ maxPatterns: {
26
+ type: 'number',
27
+ description: 'Maximum patterns to scan (default: 1000)',
28
+ default: 1000,
29
+ minimum: 1,
30
+ maximum: 10000,
31
+ },
32
+ energyThreshold: {
33
+ type: 'number',
34
+ description: 'Energy threshold for flagging issues (default: 0.4)',
35
+ default: 0.4,
36
+ minimum: 0,
37
+ maximum: 1,
38
+ },
39
+ includeDetails: {
40
+ type: 'boolean',
41
+ description: 'Include detailed pattern information in results',
42
+ default: false,
43
+ },
44
+ },
45
+ required: [],
46
+ };
47
+ // ============================================================================
48
+ // Tool Implementation
49
+ // ============================================================================
50
+ /**
51
+ * Coherence Audit Memory Tool
52
+ *
53
+ * Scans QE patterns for coherence issues using Prime Radiant:
54
+ * - Detects contradictory patterns
55
+ * - Identifies duplicate/overlapping patterns
56
+ * - Flags outdated patterns with low usage
57
+ * - Generates remediation recommendations
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const result = await tool.invoke({
62
+ * namespace: 'qe-patterns',
63
+ * maxPatterns: 500,
64
+ * energyThreshold: 0.5,
65
+ * });
66
+ *
67
+ * console.log(`Health Score: ${result.data.healthScore}/100`);
68
+ * console.log('Hotspots:', result.data.hotspots);
69
+ * console.log('Recommendations:', result.data.recommendations);
70
+ * ```
71
+ */
72
+ export class CoherenceAuditTool extends MCPToolBase {
73
+ config = {
74
+ name: 'qe/coherence/audit',
75
+ description: 'Audit QE memory for contradictions and coherence issues. ' +
76
+ 'Scans patterns, detects hotspots, and generates remediation recommendations.',
77
+ domain: 'learning-optimization',
78
+ schema: COHERENCE_AUDIT_SCHEMA,
79
+ streaming: false,
80
+ timeout: 60000,
81
+ };
82
+ coherenceService = null;
83
+ auditor = null;
84
+ /**
85
+ * Get or create the CoherenceService instance
86
+ */
87
+ async getService() {
88
+ if (!this.coherenceService) {
89
+ this.coherenceService = await createCoherenceService(wasmLoader);
90
+ }
91
+ return this.coherenceService;
92
+ }
93
+ /**
94
+ * Reset instance cache (called when fleet is disposed)
95
+ */
96
+ resetInstanceCache() {
97
+ if (this.coherenceService) {
98
+ this.coherenceService.dispose();
99
+ this.coherenceService = null;
100
+ }
101
+ this.auditor = null;
102
+ }
103
+ /**
104
+ * Execute the memory audit
105
+ */
106
+ async execute(params, context) {
107
+ const { namespace = 'qe-patterns', maxPatterns = 1000, energyThreshold = 0.4, } = params;
108
+ try {
109
+ // Get coherence service
110
+ const service = await this.getService();
111
+ // Create auditor if not exists
112
+ if (!this.auditor) {
113
+ this.auditor = createMemoryAuditor(service, undefined, {
114
+ energyThreshold,
115
+ hotspotThreshold: energyThreshold + 0.2,
116
+ maxRecommendations: 10,
117
+ });
118
+ }
119
+ // Get memory backend and fetch patterns
120
+ const memory = await getSharedMemoryBackend();
121
+ const patternStore = createPatternStore(memory, {
122
+ namespace,
123
+ embeddingDimension: 128,
124
+ });
125
+ await patternStore.initialize();
126
+ // Search for all patterns (empty query returns all)
127
+ const searchResult = await patternStore.search('', {
128
+ limit: maxPatterns,
129
+ useVectorSearch: false,
130
+ });
131
+ const patterns = searchResult.success
132
+ ? searchResult.value.map((r) => r.pattern)
133
+ : [];
134
+ // Run audit if we have patterns
135
+ let auditResult;
136
+ if (patterns.length > 0) {
137
+ auditResult = await this.auditor.auditPatterns(patterns);
138
+ }
139
+ else {
140
+ // No patterns - return empty audit
141
+ auditResult = {
142
+ totalPatterns: 0,
143
+ scannedPatterns: 0,
144
+ contradictionCount: 0,
145
+ globalEnergy: 0,
146
+ hotspots: [],
147
+ recommendations: [],
148
+ duration: 0,
149
+ timestamp: new Date(),
150
+ };
151
+ }
152
+ // Calculate health score (0-100)
153
+ const healthScore = this.calculateHealthScore(auditResult);
154
+ this.markAsRealData();
155
+ return {
156
+ success: true,
157
+ data: {
158
+ totalPatterns: auditResult.totalPatterns,
159
+ scannedPatterns: auditResult.scannedPatterns,
160
+ contradictionCount: auditResult.contradictionCount,
161
+ globalEnergy: auditResult.globalEnergy,
162
+ hotspots: auditResult.hotspots.map((h) => ({
163
+ domain: h.domain,
164
+ patternIds: h.patternIds,
165
+ energy: h.energy,
166
+ description: h.description,
167
+ })),
168
+ recommendations: auditResult.recommendations.map((r) => ({
169
+ type: r.type,
170
+ patternIds: r.patternIds,
171
+ reason: r.reason,
172
+ priority: r.priority,
173
+ })),
174
+ durationMs: auditResult.duration,
175
+ timestamp: auditResult.timestamp.toISOString(),
176
+ healthScore,
177
+ },
178
+ };
179
+ }
180
+ catch (error) {
181
+ // Check if WASM is unavailable - provide graceful fallback
182
+ if (error instanceof Error &&
183
+ error.message.includes('WASM')) {
184
+ this.markAsDemoData(context, 'WASM module unavailable');
185
+ return {
186
+ success: true,
187
+ data: {
188
+ totalPatterns: 0,
189
+ scannedPatterns: 0,
190
+ contradictionCount: 0,
191
+ globalEnergy: 0,
192
+ hotspots: [],
193
+ recommendations: [
194
+ {
195
+ type: 'review',
196
+ patternIds: [],
197
+ reason: 'WASM module unavailable - install prime-radiant-advanced-wasm for full audit',
198
+ priority: 'medium',
199
+ },
200
+ ],
201
+ durationMs: 0,
202
+ timestamp: new Date().toISOString(),
203
+ healthScore: 100,
204
+ },
205
+ };
206
+ }
207
+ return {
208
+ success: false,
209
+ error: error instanceof Error ? error.message : String(error),
210
+ };
211
+ }
212
+ }
213
+ /**
214
+ * Calculate memory health score (0-100)
215
+ */
216
+ calculateHealthScore(result) {
217
+ let score = 100;
218
+ // Deduct for contradictions
219
+ score -= Math.min(30, result.contradictionCount * 5);
220
+ // Deduct for high energy
221
+ score -= Math.min(30, result.globalEnergy * 50);
222
+ // Deduct for hotspots
223
+ score -= Math.min(20, result.hotspots.length * 5);
224
+ // Deduct for critical recommendations
225
+ const criticalCount = result.recommendations.filter((r) => r.priority === 'high').length;
226
+ score -= Math.min(20, criticalCount * 5);
227
+ return Math.max(0, Math.round(score));
228
+ }
229
+ }
230
+ /**
231
+ * Create a CoherenceAuditTool instance
232
+ */
233
+ export function createCoherenceAuditTool() {
234
+ return new CoherenceAuditTool();
235
+ }
236
+ //# sourceMappingURL=audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../../src/mcp/tools/coherence/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,WAAW,EAIX,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,sBAAsB,EACtB,UAAU,GACX,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAEL,mBAAmB,GAIpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AAwDpC,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,MAAM,sBAAsB,GAAkB;IAC5C,IAAI,EAAE,QAAQ;IACd,UA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,CAAC,CAAC;QAErD,yBAAyB;QACzB,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,YAAY,GAAG,EAAE,CAAC,CAAC;QAEhD,sBAAsB;QACtB,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAElD,sCAAsC;QACtC,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,MAAM,CACjD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAC7B,CAAC,MAAM,CAAC;QACT,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,GAAG,CAAC,CAAC,CAAC;QAEzC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,IAAI,kBAAkB,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Agentic QE v3 - Coherence Check MCP Tool
3
+ * ADR-052: Phase 4 Action A4.1
4
+ *
5
+ * qe/coherence/check - Check coherence of beliefs/facts using Prime Radiant
6
+ *
7
+ * Uses the CoherenceService to verify mathematical coherence of a set of nodes,
8
+ * detecting contradictions and computing the overall coherence energy.
9
+ */
10
+ import { MCPToolBase, MCPToolConfig, MCPToolContext } from '../base.js';
11
+ import { ToolResult } from '../../types.js';
12
+ import { type ComputeLane } from '../../../integrations/coherence/index.js';
13
+ /**
14
+ * Parameters for coherence check
15
+ */
16
+ export interface CoherenceCheckParams {
17
+ /** Nodes to check for coherence - each node has id, embedding, and optional weight/metadata */
18
+ nodes: Array<{
19
+ /** Unique identifier for the node */
20
+ id: string;
21
+ /** Embedding vector (array of numbers) */
22
+ embedding: number[];
23
+ /** Optional weight (0-1, defaults to 1.0) */
24
+ weight?: number;
25
+ /** Optional metadata */
26
+ metadata?: Record<string, unknown>;
27
+ }>;
28
+ /** Optional custom energy threshold for contradiction detection (default: 0.4) */
29
+ energyThreshold?: number;
30
+ /** Index signature for Record<string, unknown> compatibility */
31
+ [key: string]: unknown;
32
+ }
33
+ /**
34
+ * Result of coherence check
35
+ */
36
+ export interface CoherenceCheckResult {
37
+ /** Whether the nodes are coherent */
38
+ isCoherent: boolean;
39
+ /** Computed coherence energy (lower = more coherent) */
40
+ energy: number;
41
+ /** Compute lane based on energy threshold */
42
+ lane: ComputeLane;
43
+ /** Detected contradictions */
44
+ contradictions: Array<{
45
+ /** IDs of the contradicting nodes */
46
+ nodeIds: [string, string];
47
+ /** Severity of the contradiction */
48
+ severity: string;
49
+ /** Human-readable description */
50
+ description: string;
51
+ }>;
52
+ /** Recommendations for resolving incoherence */
53
+ recommendations: string[];
54
+ /** Number of nodes analyzed */
55
+ nodeCount: number;
56
+ /** Execution time in milliseconds */
57
+ executionTimeMs: number;
58
+ /** Whether fallback logic was used */
59
+ usedFallback: boolean;
60
+ }
61
+ /**
62
+ * Coherence Check Tool
63
+ *
64
+ * Uses Prime Radiant's sheaf cohomology engine to verify mathematical
65
+ * coherence of a set of nodes/beliefs.
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const result = await tool.invoke({
70
+ * nodes: [
71
+ * { id: 'belief-1', embedding: [0.1, 0.2, ...], weight: 0.9 },
72
+ * { id: 'belief-2', embedding: [0.3, 0.1, ...], weight: 0.8 },
73
+ * ],
74
+ * energyThreshold: 0.4,
75
+ * });
76
+ *
77
+ * if (!result.data.isCoherent) {
78
+ * console.log('Contradictions found:', result.data.contradictions);
79
+ * }
80
+ * ```
81
+ */
82
+ export declare class CoherenceCheckTool extends MCPToolBase<CoherenceCheckParams, CoherenceCheckResult> {
83
+ readonly config: MCPToolConfig;
84
+ private coherenceService;
85
+ /**
86
+ * Get or create the CoherenceService instance
87
+ */
88
+ private getService;
89
+ /**
90
+ * Reset instance cache (called when fleet is disposed)
91
+ */
92
+ resetInstanceCache(): void;
93
+ /**
94
+ * Execute the coherence check
95
+ */
96
+ execute(params: CoherenceCheckParams, context: MCPToolContext): Promise<ToolResult<CoherenceCheckResult>>;
97
+ /**
98
+ * Generate additional recommendations based on coherence results
99
+ */
100
+ private generateAdditionalRecommendations;
101
+ }
102
+ /**
103
+ * Create a CoherenceCheckTool instance
104
+ */
105
+ export declare function createCoherenceCheckTool(): CoherenceCheckTool;
106
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/coherence/check.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,EAEf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,0CAA0C,CAAC;AAMlD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,+FAA+F;IAC/F,KAAK,EAAE,KAAK,CAAC;QACX,qCAAqC;QACrC,EAAE,EAAE,MAAM,CAAC;QACX,0CAA0C;QAC1C,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,6CAA6C;QAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,wBAAwB;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,CAAC,CAAC;IACH,kFAAkF;IAClF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,EAAE,WAAW,CAAC;IAClB,8BAA8B;IAC9B,cAAc,EAAE,KAAK,CAAC;QACpB,qCAAqC;QACrC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1B,oCAAoC;QACpC,QAAQ,EAAE,MAAM,CAAC;QACjB,iCAAiC;QACjC,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,gDAAgD;IAChD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,YAAY,EAAE,OAAO,CAAC;CACvB;AA6BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,kBAAmB,SAAQ,WAAW,CACjD,oBAAoB,EACpB,oBAAoB,CACrB;IACC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAS5B;IAEF,OAAO,CAAC,gBAAgB,CAAiC;IAEzD;;OAEG;YACW,UAAU;IAOxB;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAO1B;;OAEG;IACG,OAAO,CACX,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAuG5C;;OAEG;IACH,OAAO,CAAC,iCAAiC;CAiC1C;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,kBAAkB,CAE7D"}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Agentic QE v3 - Coherence Check MCP Tool
3
+ * ADR-052: Phase 4 Action A4.1
4
+ *
5
+ * qe/coherence/check - Check coherence of beliefs/facts using Prime Radiant
6
+ *
7
+ * Uses the CoherenceService to verify mathematical coherence of a set of nodes,
8
+ * detecting contradictions and computing the overall coherence energy.
9
+ */
10
+ import { MCPToolBase, } from '../base.js';
11
+ import { createCoherenceService, wasmLoader, } from '../../../integrations/coherence/index.js';
12
+ // ============================================================================
13
+ // Schema
14
+ // ============================================================================
15
+ const COHERENCE_CHECK_SCHEMA = {
16
+ type: 'object',
17
+ properties: {
18
+ nodes: {
19
+ type: 'array',
20
+ description: 'Array of nodes to check for coherence. Each node must have an id and embedding vector.',
21
+ },
22
+ energyThreshold: {
23
+ type: 'number',
24
+ description: 'Custom energy threshold for contradiction detection (default: 0.4)',
25
+ minimum: 0,
26
+ maximum: 1,
27
+ },
28
+ },
29
+ required: ['nodes'],
30
+ };
31
+ // ============================================================================
32
+ // Tool Implementation
33
+ // ============================================================================
34
+ /**
35
+ * Coherence Check Tool
36
+ *
37
+ * Uses Prime Radiant's sheaf cohomology engine to verify mathematical
38
+ * coherence of a set of nodes/beliefs.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const result = await tool.invoke({
43
+ * nodes: [
44
+ * { id: 'belief-1', embedding: [0.1, 0.2, ...], weight: 0.9 },
45
+ * { id: 'belief-2', embedding: [0.3, 0.1, ...], weight: 0.8 },
46
+ * ],
47
+ * energyThreshold: 0.4,
48
+ * });
49
+ *
50
+ * if (!result.data.isCoherent) {
51
+ * console.log('Contradictions found:', result.data.contradictions);
52
+ * }
53
+ * ```
54
+ */
55
+ export class CoherenceCheckTool extends MCPToolBase {
56
+ config = {
57
+ name: 'qe/coherence/check',
58
+ description: 'Check mathematical coherence of beliefs/facts using Prime Radiant sheaf cohomology. ' +
59
+ 'Detects contradictions and computes coherence energy for multi-agent coordination.',
60
+ domain: 'learning-optimization',
61
+ schema: COHERENCE_CHECK_SCHEMA,
62
+ streaming: false,
63
+ timeout: 30000,
64
+ };
65
+ coherenceService = null;
66
+ /**
67
+ * Get or create the CoherenceService instance
68
+ */
69
+ async getService() {
70
+ if (!this.coherenceService) {
71
+ this.coherenceService = await createCoherenceService(wasmLoader);
72
+ }
73
+ return this.coherenceService;
74
+ }
75
+ /**
76
+ * Reset instance cache (called when fleet is disposed)
77
+ */
78
+ resetInstanceCache() {
79
+ if (this.coherenceService) {
80
+ this.coherenceService.dispose();
81
+ this.coherenceService = null;
82
+ }
83
+ }
84
+ /**
85
+ * Execute the coherence check
86
+ */
87
+ async execute(params, context) {
88
+ const startTime = Date.now();
89
+ const { nodes, energyThreshold = 0.4 } = params;
90
+ // Validate nodes
91
+ if (!nodes || nodes.length === 0) {
92
+ return {
93
+ success: false,
94
+ error: 'At least one node is required for coherence check',
95
+ };
96
+ }
97
+ // Validate embeddings
98
+ for (const node of nodes) {
99
+ if (!node.embedding || !Array.isArray(node.embedding)) {
100
+ return {
101
+ success: false,
102
+ error: `Node ${node.id} has invalid embedding - must be an array of numbers`,
103
+ };
104
+ }
105
+ }
106
+ try {
107
+ // Get service (initializes WASM if needed)
108
+ const service = await this.getService();
109
+ // Convert to CoherenceNode format
110
+ const coherenceNodes = nodes.map((node) => ({
111
+ id: node.id,
112
+ embedding: node.embedding,
113
+ weight: node.weight ?? 1.0,
114
+ metadata: node.metadata,
115
+ }));
116
+ // Perform coherence check
117
+ const result = await service.checkCoherence(coherenceNodes);
118
+ // Generate recommendations based on results
119
+ const recommendations = [
120
+ ...result.recommendations,
121
+ ...this.generateAdditionalRecommendations(result, energyThreshold),
122
+ ];
123
+ // Format contradictions for output (convert Severity enum to string)
124
+ const contradictions = result.contradictions.map((c) => ({
125
+ nodeIds: c.nodeIds,
126
+ severity: String(c.severity),
127
+ description: c.description ||
128
+ `Contradiction between nodes ${c.nodeIds[0]} and ${c.nodeIds[1]}`,
129
+ }));
130
+ const executionTimeMs = Date.now() - startTime;
131
+ this.markAsRealData();
132
+ return {
133
+ success: true,
134
+ data: {
135
+ isCoherent: result.isCoherent,
136
+ energy: result.energy,
137
+ lane: result.lane,
138
+ contradictions,
139
+ recommendations,
140
+ nodeCount: nodes.length,
141
+ executionTimeMs,
142
+ usedFallback: result.usedFallback,
143
+ },
144
+ };
145
+ }
146
+ catch (error) {
147
+ // Check if WASM is unavailable - provide graceful fallback
148
+ if (error instanceof Error &&
149
+ error.message.includes('WASM')) {
150
+ this.markAsDemoData(context, 'WASM module unavailable');
151
+ return {
152
+ success: true,
153
+ data: {
154
+ isCoherent: true,
155
+ energy: 0.1,
156
+ lane: 'reflex',
157
+ contradictions: [],
158
+ recommendations: [
159
+ 'WASM module unavailable - coherence check running in fallback mode',
160
+ 'Install prime-radiant-advanced-wasm for full coherence verification',
161
+ ],
162
+ nodeCount: nodes.length,
163
+ executionTimeMs: Date.now() - startTime,
164
+ usedFallback: true,
165
+ },
166
+ };
167
+ }
168
+ return {
169
+ success: false,
170
+ error: error instanceof Error ? error.message : String(error),
171
+ };
172
+ }
173
+ }
174
+ /**
175
+ * Generate additional recommendations based on coherence results
176
+ */
177
+ generateAdditionalRecommendations(result, threshold) {
178
+ const recommendations = [];
179
+ if (result.energy > threshold) {
180
+ recommendations.push(`High coherence energy (${result.energy.toFixed(3)}) detected - review contradicting beliefs`);
181
+ }
182
+ switch (result.lane) {
183
+ case 'reflex':
184
+ recommendations.push('Low energy - safe for immediate execution');
185
+ break;
186
+ case 'retrieval':
187
+ recommendations.push('Moderate energy - consider fetching additional context');
188
+ break;
189
+ case 'heavy':
190
+ recommendations.push('High energy - deep analysis recommended');
191
+ break;
192
+ case 'human':
193
+ recommendations.push('Critical energy - escalate to Queen coordinator');
194
+ break;
195
+ }
196
+ return recommendations;
197
+ }
198
+ }
199
+ /**
200
+ * Create a CoherenceCheckTool instance
201
+ */
202
+ export function createCoherenceCheckTool() {
203
+ return new CoherenceCheckTool();
204
+ }
205
+ //# sourceMappingURL=check.js.map