agentic-qe 3.11.3 → 3.11.5

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 (426) hide show
  1. package/.claude/hooks/aqe-hook.cjs +44 -10
  2. package/.claude/skills/skills-manifest.json +1 -1
  3. package/CHANGELOG.md +106 -0
  4. package/assets/skills/skills-manifest.json +1 -1
  5. package/dist/audit/witness-chain.d.ts +25 -0
  6. package/dist/audit/witness-chain.js +69 -22
  7. package/dist/audit/witness-key-manager.d.ts +11 -0
  8. package/dist/audit/witness-key-manager.js +24 -0
  9. package/dist/cli/brain-commands.js +2 -1
  10. package/dist/cli/bundle.js +5 -5
  11. package/dist/cli/chunks/adapter-KNM5R47J.js +2 -0
  12. package/dist/cli/chunks/{agent-booster-wasm-BFRW7HEU.js → agent-booster-wasm-CSTBLNYZ.js} +2 -2
  13. package/dist/cli/chunks/{agent-handler-ZVC3VFPC.js → agent-handler-M4W4GTXN.js} +2 -2
  14. package/dist/cli/chunks/{agent-memory-branch-3WU3CVSX.js → agent-memory-branch-VGXFYLSQ.js} +2 -2
  15. package/dist/cli/chunks/aqe-learning-engine-MXPJLVR3.js +2 -0
  16. package/dist/cli/chunks/{arena-QMRLNQUC.js → arena-FKSD3LLM.js} +4 -4
  17. package/dist/cli/chunks/{arena-JMVTWWG5.js → arena-IQBRGWAG.js} +2 -2
  18. package/dist/cli/chunks/audit-7NSGRR4Z.js +3 -0
  19. package/dist/cli/chunks/base-X4EXQ2AS.js +2 -0
  20. package/dist/cli/chunks/{hnswlib-node-EBRXKEX5.js → better-sqlite3-2KR4LQRU.js} +2 -2
  21. package/dist/cli/chunks/brain-handler-M6A3UB66.js +89 -0
  22. package/dist/cli/chunks/{branch-enumerator-CJJG6X3I.js → branch-enumerator-2JGKY4BB.js} +2 -2
  23. package/dist/cli/chunks/{browser-LI2CDWVR.js → browser-J43WQPJL.js} +2 -2
  24. package/dist/cli/chunks/browser-workflow-4HX6RP5F.js +2 -0
  25. package/dist/cli/chunks/{chunk-DS7AZD26.js → chunk-26WEI3P4.js} +2 -2
  26. package/dist/cli/chunks/{chunk-OVEG5MEL.js → chunk-2XPMATEK.js} +2 -2
  27. package/dist/cli/chunks/{chunk-36HTS4EP.js → chunk-2XQHG56O.js} +2 -2
  28. package/dist/cli/chunks/{chunk-CGKHG46K.js → chunk-354367AP.js} +2 -2
  29. package/dist/cli/chunks/{chunk-FPKKKUWF.js → chunk-37ZUF5NX.js} +1 -1
  30. package/dist/cli/chunks/{chunk-H7Y43HBQ.js → chunk-3I4TCMOJ.js} +1 -1
  31. package/dist/cli/chunks/{chunk-WV66MXJI.js → chunk-3JF5A72M.js} +2 -2
  32. package/dist/cli/chunks/{chunk-MX5FMAY5.js → chunk-3LY7OCSO.js} +1 -1
  33. package/dist/cli/chunks/{chunk-KHUN65Q3.js → chunk-3V36WMIO.js} +1 -1
  34. package/dist/cli/chunks/{chunk-VFEU4JM4.js → chunk-3WR35GFF.js} +2 -2
  35. package/dist/cli/chunks/{chunk-A43MKBSX.js → chunk-4LODYRNV.js} +2 -2
  36. package/dist/cli/chunks/{chunk-3E3PSEC5.js → chunk-4MHN7JWC.js} +3 -3
  37. package/dist/cli/chunks/chunk-4QOI5JS7.js +14 -0
  38. package/dist/cli/chunks/{chunk-LKLWIP4Z.js → chunk-4RTWPR3X.js} +1 -1
  39. package/dist/cli/chunks/chunk-4XJ2A3HY.js +65 -0
  40. package/dist/cli/chunks/{chunk-PMHSTMHV.js → chunk-4Y3LGBKJ.js} +3 -3
  41. package/dist/cli/chunks/{chunk-SFDBIO64.js → chunk-52U5BFZP.js} +2 -2
  42. package/dist/cli/chunks/{chunk-YPRM6ZFL.js → chunk-53YOYZW5.js} +2 -2
  43. package/dist/cli/chunks/{chunk-REZ2GZQ3.js → chunk-5WMU7XCF.js} +1 -1
  44. package/dist/cli/chunks/{chunk-VUEYLW5P.js → chunk-62OTU2AP.js} +2 -2
  45. package/dist/cli/chunks/{chunk-3XLGXCSX.js → chunk-62UM7Q5N.js} +1 -1
  46. package/dist/cli/chunks/{chunk-DZZ4AJQI.js → chunk-6Q57K4YD.js} +2 -2
  47. package/dist/cli/chunks/chunk-6R3YOAKO.js +2 -0
  48. package/dist/cli/chunks/chunk-6T65OKUM.js +2 -0
  49. package/dist/cli/chunks/{chunk-VTDWQ7WI.js → chunk-7BCRULCP.js} +2 -2
  50. package/dist/cli/chunks/{chunk-XCSEJQXR.js → chunk-7DTMENY6.js} +2 -2
  51. package/dist/cli/chunks/{chunk-N2K2EQFH.js → chunk-7KXPNNMR.js} +2 -2
  52. package/dist/cli/chunks/{chunk-XKUN5PDH.js → chunk-7P6X4BFO.js} +3 -3
  53. package/dist/cli/chunks/{chunk-3CBYKKRW.js → chunk-7YSBATSN.js} +2 -2
  54. package/dist/cli/chunks/{chunk-ZDPQB67L.js → chunk-ABU64UWB.js} +1 -1
  55. package/dist/cli/chunks/{chunk-IJHPZMEQ.js → chunk-AF6P5RWY.js} +2 -2
  56. package/dist/cli/chunks/{chunk-7S7QF4HJ.js → chunk-AGJOGUP5.js} +1 -1
  57. package/dist/cli/chunks/{chunk-EHEFI6LR.js → chunk-AL5VJJN4.js} +1 -1
  58. package/dist/cli/chunks/{chunk-Q2A2XQGF.js → chunk-AOQYORVA.js} +2 -2
  59. package/dist/cli/chunks/{chunk-6WWNK67C.js → chunk-AOXJFDH5.js} +180 -176
  60. package/dist/cli/chunks/{chunk-SWRGPCZ2.js → chunk-AXKWV5NF.js} +4 -4
  61. package/dist/cli/chunks/{chunk-3BREKEL5.js → chunk-B2VBDMDI.js} +2 -2
  62. package/dist/cli/chunks/{chunk-RXN5DWVM.js → chunk-BJLA2IX7.js} +2 -2
  63. package/dist/cli/chunks/{chunk-DPYNXEBC.js → chunk-BLPWJQTY.js} +2 -2
  64. package/dist/cli/chunks/{chunk-SMHYPPO6.js → chunk-BTLUWH4R.js} +2 -2
  65. package/dist/cli/chunks/{chunk-PUK5NE47.js → chunk-C4EZNOWK.js} +1 -1
  66. package/dist/cli/chunks/{chunk-ATFADWGD.js → chunk-C5C4W572.js} +2 -2
  67. package/dist/cli/chunks/{chunk-WTKT2AD3.js → chunk-CDJP6COA.js} +2 -2
  68. package/dist/cli/chunks/{chunk-G6MPXBCD.js → chunk-CKOF27L7.js} +2 -2
  69. package/dist/cli/chunks/{chunk-BQ5EJPK3.js → chunk-D45QLJEL.js} +1 -1
  70. package/dist/cli/chunks/{chunk-WCVZHXWL.js → chunk-DFRRWOEX.js} +2 -2
  71. package/dist/cli/chunks/{chunk-PSL53AQ4.js → chunk-DLBVADWQ.js} +92 -92
  72. package/dist/cli/chunks/{chunk-HRD5I7ES.js → chunk-DPL762HU.js} +1 -1
  73. package/dist/cli/chunks/{chunk-7QIYYYUE.js → chunk-DVW66FPU.js} +1 -1
  74. package/dist/cli/chunks/{chunk-ABD6JBNO.js → chunk-EDOGRFAG.js} +1 -1
  75. package/dist/cli/chunks/{chunk-7SBMTSGY.js → chunk-EEKG35K5.js} +5 -5
  76. package/dist/cli/chunks/{chunk-PW4GGJMP.js → chunk-EK3HPH6A.js} +1 -1
  77. package/dist/cli/chunks/{chunk-QPMISAWB.js → chunk-FGD6HINU.js} +1 -1
  78. package/dist/cli/chunks/{chunk-SLU35IDJ.js → chunk-FGSIID5C.js} +2 -2
  79. package/dist/cli/chunks/{chunk-DNOBN3IR.js → chunk-FHTYEAQ3.js} +2 -2
  80. package/dist/cli/chunks/{chunk-S2T2BXUL.js → chunk-FII3WCCY.js} +2 -2
  81. package/dist/cli/chunks/{chunk-77QJQRL2.js → chunk-FIPKIIMS.js} +2 -2
  82. package/dist/cli/chunks/{chunk-WYJFVSEB.js → chunk-FMNXHVIN.js} +2 -2
  83. package/dist/cli/chunks/{chunk-FZLCKIPP.js → chunk-G2ZIJZJ7.js} +2 -2
  84. package/dist/cli/chunks/{chunk-L6PH7JIE.js → chunk-GODAWJMZ.js} +2 -2
  85. package/dist/cli/chunks/{chunk-KTYESESI.js → chunk-GW6XWMX2.js} +2 -2
  86. package/dist/cli/chunks/{chunk-AC6OZTY4.js → chunk-HC6KTVFR.js} +2 -2
  87. package/dist/cli/chunks/{chunk-EXCU4J7T.js → chunk-HJWT4KME.js} +1 -1
  88. package/dist/cli/chunks/{chunk-GBCDJJWH.js → chunk-I3ANRYQ6.js} +2 -2
  89. package/dist/cli/chunks/{chunk-KXRI4MR3.js → chunk-I3NWKPXJ.js} +2 -2
  90. package/dist/cli/chunks/chunk-IBDQWKI3.js +2 -0
  91. package/dist/cli/chunks/{chunk-7FVWETN4.js → chunk-IU5RSN6M.js} +2 -2
  92. package/dist/cli/chunks/{chunk-L44XXD3X.js → chunk-J5XDKVI7.js} +2 -2
  93. package/dist/cli/chunks/{chunk-NJ2RY4OL.js → chunk-J6PFPY7V.js} +2 -2
  94. package/dist/cli/chunks/{chunk-27MMZQ7X.js → chunk-JATLFS6A.js} +1 -1
  95. package/dist/cli/chunks/{chunk-SIAJP3YA.js → chunk-JBKZ5TUM.js} +2 -2
  96. package/dist/cli/chunks/{chunk-PLQADRA6.js → chunk-JDSHUECG.js} +2 -2
  97. package/dist/cli/chunks/chunk-K4C25BWV.js +24 -0
  98. package/dist/cli/chunks/{chunk-UFZCHVLH.js → chunk-K4I7UIU5.js} +1 -1
  99. package/dist/cli/chunks/{chunk-6F43POT6.js → chunk-KP3R2M2G.js} +1 -1
  100. package/dist/cli/chunks/chunk-KQVIWE3W.js +2 -0
  101. package/dist/cli/chunks/{chunk-JWTMVC6E.js → chunk-KVVJVMDM.js} +2 -2
  102. package/dist/cli/chunks/{chunk-EZ4GKHSI.js → chunk-LOE2JETO.js} +2 -2
  103. package/dist/cli/chunks/{chunk-O7ZDQ5FF.js → chunk-LPR2R3AN.js} +3 -3
  104. package/dist/cli/chunks/{chunk-AKOGQT3A.js → chunk-M6FW56MV.js} +2 -2
  105. package/dist/cli/chunks/{chunk-NBOEXSV2.js → chunk-MCHEUSY4.js} +1 -1
  106. package/dist/cli/chunks/{chunk-B7XPSXK6.js → chunk-MEIU7457.js} +2 -2
  107. package/dist/cli/chunks/{chunk-3FOFPGHH.js → chunk-MHMQ6MCT.js} +2 -2
  108. package/dist/cli/chunks/{chunk-6JR2RSY2.js → chunk-MIU5RUBJ.js} +2 -2
  109. package/dist/cli/chunks/{chunk-QCCXH5DK.js → chunk-MMEXHZUC.js} +37 -12
  110. package/dist/cli/chunks/{chunk-LW5TUN5F.js → chunk-MTBGOWJA.js} +2 -2
  111. package/dist/cli/chunks/{chunk-JVXPKHND.js → chunk-NCSXLMDL.js} +77 -27
  112. package/dist/cli/chunks/{chunk-WLLGPGQY.js → chunk-O7J54OHN.js} +1 -1
  113. package/dist/cli/chunks/{chunk-ZM7WOA3K.js → chunk-OGNTCZKK.js} +1 -1
  114. package/dist/cli/chunks/{chunk-CYJ6O5VZ.js → chunk-OS2HHJTM.js} +2 -2
  115. package/dist/cli/chunks/{chunk-242B625Q.js → chunk-OS62Y77J.js} +2 -2
  116. package/dist/cli/chunks/{chunk-CLZ5RQVA.js → chunk-PVDXNQPL.js} +2 -2
  117. package/dist/cli/chunks/{chunk-PUUGIBFF.js → chunk-PW72M2FE.js} +2 -2
  118. package/dist/cli/chunks/{chunk-RWUGXU2K.js → chunk-Q5TR6ETB.js} +22 -22
  119. package/dist/cli/chunks/{chunk-CCDGNJZX.js → chunk-QKK7VBVB.js} +2 -2
  120. package/dist/cli/chunks/{chunk-BHZI6PDR.js → chunk-RFLHPLET.js} +1 -1
  121. package/dist/cli/chunks/{chunk-KULBMV6K.js → chunk-RJN2RM76.js} +2 -2
  122. package/dist/cli/chunks/{chunk-LGEZ3ZJX.js → chunk-RKXZLTWR.js} +2 -2
  123. package/dist/cli/chunks/{chunk-OFMVC6P3.js → chunk-SE3JFUKP.js} +1 -1
  124. package/dist/cli/chunks/{chunk-S7KDHA6P.js → chunk-SK754ZSH.js} +4 -4
  125. package/dist/cli/chunks/{chunk-OQGELUM2.js → chunk-SO6G4IX3.js} +2 -2
  126. package/dist/cli/chunks/{chunk-5746QYRF.js → chunk-SUL3I6QZ.js} +2 -2
  127. package/dist/cli/chunks/{chunk-22CUJA33.js → chunk-TBT3OFRW.js} +2 -2
  128. package/dist/cli/chunks/{chunk-26KHL4VO.js → chunk-TEIWJ3GJ.js} +1 -1
  129. package/dist/cli/chunks/{chunk-SFGBC5RP.js → chunk-TRNBQFFG.js} +8 -20
  130. package/dist/cli/chunks/{chunk-UTGW75AZ.js → chunk-TTJJ4DQE.js} +2 -2
  131. package/dist/cli/chunks/{chunk-H6YFMUFG.js → chunk-UBI2EOS3.js} +1 -1
  132. package/dist/cli/chunks/{chunk-GCIL7PK7.js → chunk-UBY322ED.js} +2 -2
  133. package/dist/cli/chunks/{chunk-P4UGVVVX.js → chunk-UORTQXJ2.js} +1 -1
  134. package/dist/cli/chunks/{chunk-BFBZFUBP.js → chunk-URP75DL4.js} +1 -1
  135. package/dist/cli/chunks/chunk-V6NAB5UZ.js +2 -0
  136. package/dist/cli/chunks/{chunk-DZ7PWB6E.js → chunk-VMFAANWX.js} +2 -2
  137. package/dist/cli/chunks/{chunk-6KKKPVOF.js → chunk-VMWRMINE.js} +1 -1
  138. package/dist/cli/chunks/{chunk-ECGASTG7.js → chunk-VN2HHBZN.js} +2 -2
  139. package/dist/cli/chunks/{chunk-6GVRP64A.js → chunk-W72FJA2H.js} +2 -2
  140. package/dist/cli/chunks/chunk-W7TYKPLY.js +27 -0
  141. package/dist/cli/chunks/{chunk-2OUXYSQV.js → chunk-WHHQIL4F.js} +2 -2
  142. package/dist/cli/chunks/{chunk-RRSUW2TK.js → chunk-WMZ2QGGS.js} +2 -2
  143. package/dist/cli/chunks/{chunk-54TDOQAH.js → chunk-WPSK237F.js} +3 -3
  144. package/dist/cli/chunks/{chunk-LMA6KEZH.js → chunk-XKQY2Z3Q.js} +1 -1
  145. package/dist/cli/chunks/{chunk-UMWYL37S.js → chunk-XLT3FYS7.js} +2 -2
  146. package/dist/cli/chunks/{chunk-5EW36WTI.js → chunk-XT4TDLOB.js} +2 -2
  147. package/dist/cli/chunks/{chunk-7UOH55UT.js → chunk-Y25PO65W.js} +2 -2
  148. package/dist/cli/chunks/{chunk-ED7MD6OI.js → chunk-Y6DWJKHU.js} +3 -3
  149. package/dist/cli/chunks/{chunk-A4NYOH7P.js → chunk-YBPLJRVT.js} +2 -2
  150. package/dist/cli/chunks/{chunk-BA7PJS3Y.js → chunk-YFCULQBP.js} +2 -2
  151. package/dist/cli/chunks/{chunk-B65CRJN6.js → chunk-YGVDP6X7.js} +1 -1
  152. package/dist/cli/chunks/chunk-YR2JKBZO.js +2 -0
  153. package/dist/cli/chunks/{chunk-FJRRXCIS.js → chunk-YZSTZUGJ.js} +1 -1
  154. package/dist/cli/chunks/{chunk-H2YOWAEB.js → chunk-ZG5UAEEO.js} +2 -2
  155. package/dist/cli/chunks/{chunk-MU36VPXV.js → chunk-ZLBY25MB.js} +1 -1
  156. package/dist/cli/chunks/chunk-ZMPAM4DY.js +2 -0
  157. package/dist/cli/chunks/{chunk-4ITHKHR5.js → chunk-ZPP57WQU.js} +2 -2
  158. package/dist/cli/chunks/{chunk-B6USJW5E.js → chunk-ZXEWTZFR.js} +1 -1
  159. package/dist/cli/chunks/{ci-JW4O2J3W.js → ci-CBNVLOOQ.js} +2 -2
  160. package/dist/cli/chunks/{ci-output-JNXJV4B2.js → ci-output-I4HY2FYJ.js} +2 -2
  161. package/dist/cli/chunks/{circuit-breaker-XDD4KUGR.js → circuit-breaker-5VRBKGWL.js} +2 -2
  162. package/dist/cli/chunks/{claude-flow-setup-L6IZOGYZ.js → claude-flow-setup-XPJPKHIO.js} +2 -2
  163. package/dist/cli/chunks/client-AHXNCOHK.js +2 -0
  164. package/dist/cli/chunks/{cline-installer-PK5SMN2B.js → cline-installer-OFRDUUWZ.js} +2 -2
  165. package/dist/cli/chunks/{code-ZDVX3SQH.js → code-QIZQVB3E.js} +2 -2
  166. package/dist/cli/chunks/{code-index-extractor-VXZNKEU5.js → code-index-extractor-LMUUWEX4.js} +2 -2
  167. package/dist/cli/chunks/{codex-installer-OXKSIX7H.js → codex-installer-N2MKIZ2S.js} +2 -2
  168. package/dist/cli/chunks/{completions-VRFFK223.js → completions-Y36S3C5J.js} +2 -2
  169. package/dist/cli/chunks/{complexity-analyzer-FTIMV74J.js → complexity-analyzer-73YS3WUD.js} +2 -2
  170. package/dist/cli/chunks/{continuedev-installer-KTYBBPN4.js → continuedev-installer-SAOTP6J3.js} +2 -2
  171. package/dist/cli/chunks/{copilot-installer-WDC3YNUR.js → copilot-installer-A4HXF6HE.js} +2 -2
  172. package/dist/cli/chunks/core-handlers-EEFLLMAZ.js +2 -0
  173. package/dist/cli/chunks/{cost-tracker-6MH4H33B.js → cost-tracker-P26XUVZS.js} +2 -2
  174. package/dist/cli/chunks/{coverage-NHATLNS4.js → coverage-HVNHSMVJ.js} +3 -3
  175. package/dist/cli/chunks/cross-domain-router-LT3H4SNJ.js +2 -0
  176. package/dist/cli/chunks/{cursor-installer-VQSUJDFB.js → cursor-installer-46BQFTYZ.js} +2 -2
  177. package/dist/cli/chunks/{daemon-3VAOEKQW.js → daemon-Y54O3FLT.js} +3 -3
  178. package/dist/cli/chunks/daemon-YE7K2AZF.js +10 -0
  179. package/dist/cli/chunks/{dag-attention-scheduler-HZ6OGYIH.js → dag-attention-scheduler-ETA7YY52.js} +2 -2
  180. package/dist/cli/chunks/{detect-CGU3SC63.js → detect-5WLQ2J3E.js} +2 -2
  181. package/dist/cli/chunks/{dist-node-DIBQ7PTA.js → dist-node-45WW6I7J.js} +2 -2
  182. package/dist/cli/chunks/{domain-handler-DCMGAYXS.js → domain-handler-J7DQV74M.js} +2 -2
  183. package/dist/cli/chunks/domain-transfer-GD2EGQVR.js +2 -0
  184. package/dist/cli/chunks/dream-4K3BK4IG.js +2 -0
  185. package/dist/cli/chunks/{embed-and-insert-pattern-7247LAU3.js → embed-and-insert-pattern-JELNEA2D.js} +2 -2
  186. package/dist/cli/chunks/{eval-6KR7TFOK.js → eval-A4PA5G2U.js} +2 -2
  187. package/dist/cli/chunks/{experience-capture-middleware-IIOR6RVV.js → experience-capture-middleware-MLHTYWTA.js} +3 -3
  188. package/dist/cli/chunks/{fast-paths-M7OGD4ZI.js → fast-paths-QYDTITRV.js} +2 -2
  189. package/dist/cli/chunks/{feature-flags-U75KFIGH.js → feature-flags-H4MSY26Z.js} +2 -2
  190. package/dist/cli/chunks/{feature-flags-GGUXHRJI.js → feature-flags-MQYYRHIK.js} +2 -2
  191. package/dist/cli/chunks/{file-discovery-V52AYEB7.js → file-discovery-RMFVJNGL.js} +2 -2
  192. package/dist/cli/chunks/{fleet-2UH72CK4.js → fleet-7KZQOTAC.js} +4 -4
  193. package/dist/cli/chunks/{gnn-wrapper-J2GDLT3P.js → gnn-wrapper-NMZFTGVH.js} +2 -2
  194. package/dist/cli/chunks/{heartbeat-handler-QIDQHRXT.js → heartbeat-handler-7BQDK7MG.js} +4 -4
  195. package/dist/cli/chunks/heartbeat-scheduler-IMPPGQUK.js +2 -0
  196. package/dist/cli/chunks/hnsw-adapter-EIAA6R2L.js +2 -0
  197. package/dist/cli/chunks/hnsw-index-ZXXP6AXZ.js +2 -0
  198. package/dist/cli/chunks/{hnsw-legacy-bridge-IU62PIY5.js → hnsw-legacy-bridge-TPPGBPKF.js} +2 -2
  199. package/dist/cli/chunks/{better-sqlite3-QNZJOJAB.js → hnswlib-node-E6NSZPP2.js} +2 -2
  200. package/dist/cli/chunks/{hooks-ZI4D3ATS.js → hooks-CYZIUYSH.js} +48 -52
  201. package/dist/cli/chunks/hybrid-router-LXWG4MLH.js +2 -0
  202. package/dist/cli/chunks/{hypergraph-engine-6JEERAGA.js → hypergraph-engine-WC6DMTYQ.js} +2 -2
  203. package/dist/cli/chunks/{hypergraph-handler-YMDGYCB6.js → hypergraph-handler-GTGA3TXJ.js} +3 -3
  204. package/dist/cli/chunks/impact-analyzer-TP5LRFYH.js +2 -0
  205. package/dist/cli/chunks/{init-handler-N57NW3QI.js → init-handler-N3Z72JNI.js} +6 -6
  206. package/dist/cli/chunks/init-wizard-AIOA5KOY.js +2 -0
  207. package/dist/cli/chunks/kernel-SQALRU6Q.js +2 -0
  208. package/dist/cli/chunks/{kilocode-installer-7ABTGXJ5.js → kilocode-installer-FUX4V6II.js} +2 -2
  209. package/dist/cli/chunks/{kiro-installer-2JFOHLVI.js → kiro-installer-ZSNZT7ZR.js} +2 -2
  210. package/dist/cli/chunks/knowledge-graph-JFVT6SNN.js +2 -0
  211. package/dist/cli/chunks/{learning-3P3ZXRGD.js → learning-UQY64COU.js} +3 -3
  212. package/dist/cli/chunks/{llm-router-AWB2KHDW.js → llm-router-CMHGGX6N.js} +4 -4
  213. package/dist/cli/chunks/llm-router-service-XHFKTH3I.js +2 -0
  214. package/dist/cli/chunks/{load-GGVBCBGX.js → load-E6WH4QN2.js} +2 -2
  215. package/dist/cli/chunks/load-test-JEIFJKNN.js +2 -0
  216. package/dist/cli/chunks/{mcp-33NHIBN3.js → mcp-UM5VTW6N.js} +2 -2
  217. package/dist/cli/chunks/{memory-IVAQS4OW.js → memory-7Q3XDUE5.js} +5 -5
  218. package/dist/cli/chunks/memory-backend-NT7I37CP.js +2 -0
  219. package/dist/cli/chunks/memory-handlers-746D7NE7.js +2 -0
  220. package/dist/cli/chunks/{multi-model-executor-NWQY6IN2.js → multi-model-executor-LZENWVRR.js} +2 -2
  221. package/dist/cli/chunks/{opencode-installer-FBB4JOEV.js → opencode-installer-O2JAIPLF.js} +2 -2
  222. package/dist/cli/chunks/{orchestrator-GDAXR7DH.js → orchestrator-DKZWXDRI.js} +5 -5
  223. package/dist/cli/chunks/pattern-null-store-6QU6WHDW.js +2 -0
  224. package/dist/cli/chunks/pattern-usage-recorder-CLUL4M55.js +2 -0
  225. package/dist/cli/chunks/{pipeline-VIKAOIBE.js → pipeline-2VDLTR5J.js} +2 -2
  226. package/dist/cli/chunks/{platform-FFVP36LH.js → platform-4N4Q5XYX.js} +2 -2
  227. package/dist/cli/chunks/{plugin-TI6QOLXH.js → plugin-GY5AU5CS.js} +2 -2
  228. package/dist/cli/chunks/{prime-radiant-advanced-wasm-AZRNI2OL.js → prime-radiant-advanced-wasm-TQ4DKDZS.js} +2 -2
  229. package/dist/cli/chunks/protocol-executor-GT2MZYUU.js +2 -0
  230. package/dist/cli/chunks/{protocol-handler-J4EA34B3.js → protocol-handler-T3LZ3WRG.js} +2 -2
  231. package/dist/cli/chunks/{prove-ADVRMAWS.js → prove-OV7S5J4W.js} +2 -2
  232. package/dist/cli/chunks/provider-manager-OATJ7R3D.js +2 -0
  233. package/dist/cli/chunks/qe-reasoning-bank-IJXNQ67O.js +2 -0
  234. package/dist/cli/chunks/{quality-GB5SJFSD.js → quality-AXD4NLQA.js} +2 -2
  235. package/dist/cli/chunks/queen-coordinator-6RBHWCUG.js +2 -0
  236. package/dist/cli/chunks/{real-embeddings-GDRJ4XSH.js → real-embeddings-2PUCC7FG.js} +2 -2
  237. package/dist/cli/chunks/{roocode-installer-Q6EISUDV.js → roocode-installer-WJ5ARGLW.js} +2 -2
  238. package/dist/cli/chunks/router-XKQRT5JK.js +2 -0
  239. package/dist/cli/chunks/routing-feedback-ACPSD4LW.js +2 -0
  240. package/dist/cli/chunks/{routing-handler-RO4RTRAG.js → routing-handler-CU6657SZ.js} +2 -2
  241. package/dist/cli/chunks/{ruvector-commands-FFIHCGVQ.js → ruvector-commands-IIF6VSFW.js} +2 -2
  242. package/dist/cli/chunks/{rvf-dual-writer-JGEK3A5Y.js → rvf-dual-writer-YMQI7XO2.js} +2 -2
  243. package/dist/cli/chunks/{rvf-migration-adapter-OVYC4QM6.js → rvf-migration-adapter-HDE3PR2W.js} +2 -2
  244. package/dist/cli/chunks/{rvf-migration-coordinator-U6L77QTS.js → rvf-migration-coordinator-MQV5OA7K.js} +2 -2
  245. package/dist/cli/chunks/rvf-native-adapter-SIWRKE33.js +2 -0
  246. package/dist/cli/chunks/safe-db-LCPUYMX4.js +2 -0
  247. package/dist/cli/chunks/schedule-HIQJCWXG.js +2 -0
  248. package/dist/cli/chunks/scheduler-QE5EJ5LE.js +2 -0
  249. package/dist/cli/chunks/{security-QPQIDAIL.js → security-UM3IGDSM.js} +3 -3
  250. package/dist/cli/chunks/{shared-rvf-adapter-JRJTI4UD.js → shared-rvf-adapter-I3SOJ6M4.js} +2 -2
  251. package/dist/cli/chunks/{shared-rvf-dual-writer-DSHGURDA.js → shared-rvf-dual-writer-KQGC2UO7.js} +2 -2
  252. package/dist/cli/chunks/sqlite-persistence-EU54UTMH.js +2 -0
  253. package/dist/cli/chunks/status-handler-OX4CJZME.js +46 -0
  254. package/dist/cli/chunks/{structural-health-UVECCN7U.js → structural-health-PYUMVBXJ.js} +2 -2
  255. package/dist/cli/chunks/{sync-XXIGTGCG.js → sync-2TED3YTY.js} +2 -2
  256. package/dist/cli/chunks/{sync-ZLZ4CZFJ.js → sync-VALFNTA6.js} +2 -2
  257. package/dist/cli/chunks/{task-handler-73YAVOKJ.js → task-handler-VPGAJVPC.js} +2 -2
  258. package/dist/cli/chunks/{task-handlers-PKECV27D.js → task-handlers-IB4UAMU6.js} +3 -3
  259. package/dist/cli/chunks/{test-U3SXW4SV.js → test-OMRJOZB6.js} +4 -4
  260. package/dist/cli/chunks/{test-scheduling-POJND3GV.js → test-scheduling-ZL3YFPBU.js} +3 -3
  261. package/dist/cli/chunks/{token-bootstrap-ICX6SIXJ.js → token-bootstrap-DNWZI7SH.js} +2 -2
  262. package/dist/cli/chunks/{token-usage-WCHJUVGT.js → token-usage-IYO7RGFF.js} +2 -2
  263. package/dist/cli/chunks/{transformers-L77UIHIY.js → transformers-53ALC34T.js} +2 -2
  264. package/dist/cli/chunks/{tree-sitter-wasm-parser-CVAXURQP.js → tree-sitter-wasm-parser-WUKJ2I2Q.js} +2 -2
  265. package/dist/cli/chunks/{types-LNVJBDM2.js → types-47FTEPMV.js} +2 -2
  266. package/dist/cli/chunks/unified-memory-CJLMC2I4.js +2 -0
  267. package/dist/cli/chunks/unified-memory-hnsw-FDGR4D2J.js +2 -0
  268. package/dist/cli/chunks/unified-persistence-UFH5GLDN.js +2 -0
  269. package/dist/cli/chunks/{upgrade-4ND5RQFY.js → upgrade-QPLMJA5Z.js} +2 -2
  270. package/dist/cli/chunks/{validate-ZA4XT6K2.js → validate-3GVKZOVF.js} +2 -2
  271. package/dist/cli/chunks/{validate-swarm-FNK3GCJ4.js → validate-swarm-XCRTLVM6.js} +2 -2
  272. package/dist/cli/chunks/{vibium-E2CK2GBQ.js → vibium-CH4VPKVZ.js} +2 -2
  273. package/dist/cli/chunks/visual-security-4ARJ7J2Y.js +2 -0
  274. package/dist/cli/chunks/{web-tree-sitter-63VRNKZV.js → web-tree-sitter-JDBNAZTV.js} +2 -2
  275. package/dist/cli/chunks/{windsurf-installer-5BTCVOLH.js → windsurf-installer-3MNPVJBP.js} +2 -2
  276. package/dist/cli/chunks/witness-chain-73QC33ED.js +2 -0
  277. package/dist/cli/chunks/{witness-chain-6CUUGISD.js → witness-chain-HR5UBV5J.js} +2 -2
  278. package/dist/cli/chunks/witness-key-manager-G5SQTIBZ.js +2 -0
  279. package/dist/cli/chunks/{workflow-V7ED22XT.js → workflow-43EMD5FY.js} +4 -4
  280. package/dist/cli/chunks/workflow-orchestrator-RKMMPXNA.js +2 -0
  281. package/dist/cli/chunks/{wrappers-7S3NTTLW.js → wrappers-3N7AYNM3.js} +2 -2
  282. package/dist/cli/commands/audit.d.ts +12 -0
  283. package/dist/cli/commands/audit.js +64 -4
  284. package/dist/cli/commands/hooks-handlers/hooks-dream-learning.js +45 -19
  285. package/dist/cli/commands/hooks-handlers/hooks-shared.d.ts +13 -0
  286. package/dist/cli/commands/hooks-handlers/hooks-shared.js +38 -0
  287. package/dist/cli/commands/hooks-handlers/task-hooks.js +19 -1
  288. package/dist/cli/handlers/status-handler.d.ts +18 -0
  289. package/dist/cli/handlers/status-handler.js +47 -0
  290. package/dist/coordination/consensus/providers/ollama-provider.js +3 -2
  291. package/dist/coordination/mincut/queen-integration.js +24 -7
  292. package/dist/coordination/protocol-executor.js +2 -1
  293. package/dist/coordination/queen-lifecycle.js +4 -1
  294. package/dist/domains/code-intelligence/coordinator.js +10 -6
  295. package/dist/domains/code-intelligence/services/product-factors-bridge.js +3 -1
  296. package/dist/domains/defect-intelligence/services/defect-predictor.d.ts +6 -0
  297. package/dist/domains/defect-intelligence/services/defect-predictor.js +21 -0
  298. package/dist/domains/learning-optimization/interfaces.d.ts +7 -0
  299. package/dist/domains/learning-optimization/plugin.js +5 -0
  300. package/dist/domains/learning-optimization/services/learning-coordinator.d.ts +10 -0
  301. package/dist/domains/learning-optimization/services/learning-coordinator.js +57 -0
  302. package/dist/domains/test-execution/plugin.js +2 -2
  303. package/dist/domains/test-execution/services/flaky-detector.js +1 -1
  304. package/dist/domains/test-generation/coordinator.js +22 -8
  305. package/dist/domains/test-generation/interfaces.d.ts +3 -0
  306. package/dist/domains/test-generation/services/test-generator.js +9 -1
  307. package/dist/integrations/ruvector/delta-tracker.js +10 -1
  308. package/dist/integrations/ruvector/proof-gate.d.ts +68 -0
  309. package/dist/integrations/ruvector/proof-gate.js +135 -0
  310. package/dist/integrations/ruvector/sona-persistence.d.ts +24 -0
  311. package/dist/integrations/ruvector/sona-persistence.js +76 -0
  312. package/dist/integrations/ruvector/sona-three-loop.d.ts +15 -0
  313. package/dist/integrations/ruvector/sona-three-loop.js +17 -0
  314. package/dist/kernel/unified-memory-schemas.d.ts +2 -2
  315. package/dist/kernel/unified-memory-schemas.js +48 -2
  316. package/dist/kernel/unified-memory.d.ts +57 -0
  317. package/dist/kernel/unified-memory.js +148 -0
  318. package/dist/learning/aqe-learning-engine.js +3 -1
  319. package/dist/learning/dream/concept-graph.d.ts +31 -1
  320. package/dist/learning/dream/concept-graph.js +109 -3
  321. package/dist/learning/dream/dream-engine.d.ts +13 -1
  322. package/dist/learning/dream/dream-engine.js +146 -10
  323. package/dist/learning/dream/index.d.ts +1 -1
  324. package/dist/learning/dream/types.d.ts +23 -0
  325. package/dist/learning/local-judge-client.js +2 -1
  326. package/dist/learning/pattern-store.d.ts +2 -2
  327. package/dist/learning/pattern-store.js +14 -3
  328. package/dist/learning/qe-reasoning-bank.js +34 -31
  329. package/dist/learning/routing-topology-gate.d.ts +12 -2
  330. package/dist/learning/routing-topology-gate.js +15 -3
  331. package/dist/learning/rvf-pattern-store.d.ts +1 -1
  332. package/dist/learning/rvf-pattern-store.js +21 -8
  333. package/dist/learning/sqlite-persistence.js +12 -9
  334. package/dist/mcp/bundle.js +524 -445
  335. package/dist/mcp/qe-tool-bridge.js +7 -2
  336. package/dist/mcp/tools/base.d.ts +29 -0
  337. package/dist/mcp/tools/base.js +25 -0
  338. package/dist/mcp/tools/coverage-analysis/index.js +6 -4
  339. package/dist/mcp/tools/learning-optimization/dream.d.ts +4 -13
  340. package/dist/mcp/tools/learning-optimization/dream.js +10 -96
  341. package/dist/mcp/tools/planning/goap-execute.d.ts +13 -1
  342. package/dist/mcp/tools/planning/goap-execute.js +33 -18
  343. package/dist/mcp/tools/registry.js +7 -2
  344. package/dist/persistence/rvf-migration-coordinator.js +2 -1
  345. package/dist/planning/actions/qe-action-library.js +124 -1
  346. package/dist/planning/goap-planner.d.ts +14 -2
  347. package/dist/planning/goap-planner.js +51 -9
  348. package/dist/planning/index.d.ts +1 -1
  349. package/dist/planning/plan-executor.d.ts +84 -4
  350. package/dist/planning/plan-executor.js +221 -56
  351. package/dist/planning/types.d.ts +27 -0
  352. package/dist/routing/free-tier/coordinator-support.d.ts +6 -3
  353. package/dist/routing/free-tier/coordinator-support.js +6 -3
  354. package/dist/routing/free-tier/executor.d.ts +14 -0
  355. package/dist/routing/free-tier/executor.js +21 -0
  356. package/dist/routing/free-tier/index.d.ts +1 -0
  357. package/dist/routing/free-tier/index.js +1 -0
  358. package/dist/routing/free-tier/pattern-cache.d.ts +57 -0
  359. package/dist/routing/free-tier/pattern-cache.js +148 -0
  360. package/dist/routing/free-tier/provider.js +9 -1
  361. package/dist/routing/value-score.js +3 -0
  362. package/dist/shared/embeddings/ollama-client.js +2 -1
  363. package/dist/shared/events/domain-events.d.ts +2 -0
  364. package/dist/shared/llm/model-mapping.js +26 -0
  365. package/dist/shared/llm/model-registry.d.ts +10 -0
  366. package/dist/shared/llm/model-registry.js +92 -0
  367. package/dist/shared/llm/ollama-url.d.ts +17 -0
  368. package/dist/shared/llm/ollama-url.js +25 -0
  369. package/dist/shared/llm/providers/ollama-timeout.d.ts +26 -0
  370. package/dist/shared/llm/providers/ollama-timeout.js +31 -0
  371. package/dist/shared/llm/providers/ollama.d.ts +10 -0
  372. package/dist/shared/llm/providers/ollama.js +31 -4
  373. package/dist/shared/llm/router/hybrid-router.js +18 -1
  374. package/dist/workers/workers/learning-consolidation.js +21 -1
  375. package/package.json +5 -1
  376. package/dist/cli/chunks/adapter-IU3H3MD7.js +0 -2
  377. package/dist/cli/chunks/aqe-learning-engine-BGOC63IN.js +0 -2
  378. package/dist/cli/chunks/audit-TTWAAV7P.js +0 -3
  379. package/dist/cli/chunks/base-DVPRE3WO.js +0 -2
  380. package/dist/cli/chunks/brain-handler-FXPLJCPV.js +0 -89
  381. package/dist/cli/chunks/browser-workflow-MP5P7KZF.js +0 -2
  382. package/dist/cli/chunks/chunk-2SZQDTI5.js +0 -2
  383. package/dist/cli/chunks/chunk-6IHB3T6M.js +0 -2
  384. package/dist/cli/chunks/chunk-7PDUD7FF.js +0 -2
  385. package/dist/cli/chunks/chunk-EBCUWMLX.js +0 -27
  386. package/dist/cli/chunks/chunk-NWUVXLBB.js +0 -65
  387. package/dist/cli/chunks/chunk-OCACCUFO.js +0 -2
  388. package/dist/cli/chunks/chunk-PY2Q6MN3.js +0 -24
  389. package/dist/cli/chunks/chunk-UNH2DE2G.js +0 -2
  390. package/dist/cli/chunks/client-ADCDBTEE.js +0 -2
  391. package/dist/cli/chunks/core-handlers-HCACMLUW.js +0 -2
  392. package/dist/cli/chunks/cross-domain-router-HXFQAU4M.js +0 -2
  393. package/dist/cli/chunks/daemon-ZSK6CLQR.js +0 -10
  394. package/dist/cli/chunks/domain-transfer-UWFKBZTJ.js +0 -2
  395. package/dist/cli/chunks/dream-SVWQH62A.js +0 -2
  396. package/dist/cli/chunks/heartbeat-scheduler-QW5TW5QS.js +0 -2
  397. package/dist/cli/chunks/hnsw-adapter-D6EJWYAL.js +0 -2
  398. package/dist/cli/chunks/hnsw-index-4MWR4U5W.js +0 -2
  399. package/dist/cli/chunks/hybrid-router-BYVUBHER.js +0 -2
  400. package/dist/cli/chunks/impact-analyzer-OK2UIMSG.js +0 -2
  401. package/dist/cli/chunks/init-wizard-6NNPNS6J.js +0 -2
  402. package/dist/cli/chunks/kernel-F4A4GRNO.js +0 -2
  403. package/dist/cli/chunks/knowledge-graph-MSJDEZCF.js +0 -2
  404. package/dist/cli/chunks/llm-router-service-27IQAO7G.js +0 -2
  405. package/dist/cli/chunks/load-test-TT5VLAN7.js +0 -2
  406. package/dist/cli/chunks/memory-backend-FVSK53IM.js +0 -2
  407. package/dist/cli/chunks/memory-handlers-OPUDOZNT.js +0 -2
  408. package/dist/cli/chunks/pattern-null-store-7MVEDWCY.js +0 -2
  409. package/dist/cli/chunks/protocol-executor-BLDDYEJ4.js +0 -2
  410. package/dist/cli/chunks/provider-manager-ZYCFRYZQ.js +0 -2
  411. package/dist/cli/chunks/qe-reasoning-bank-P66CCPHM.js +0 -2
  412. package/dist/cli/chunks/queen-coordinator-LPHT3SX5.js +0 -2
  413. package/dist/cli/chunks/router-XQ2TERUT.js +0 -2
  414. package/dist/cli/chunks/routing-feedback-K52O752B.js +0 -2
  415. package/dist/cli/chunks/rvf-native-adapter-G4DV7FK3.js +0 -2
  416. package/dist/cli/chunks/safe-db-TMSEITES.js +0 -2
  417. package/dist/cli/chunks/schedule-RWFLA43O.js +0 -2
  418. package/dist/cli/chunks/scheduler-2V55MJJR.js +0 -2
  419. package/dist/cli/chunks/sqlite-persistence-L7QM6IWF.js +0 -2
  420. package/dist/cli/chunks/status-handler-SBT3MZTX.js +0 -45
  421. package/dist/cli/chunks/unified-memory-ZSULA46X.js +0 -2
  422. package/dist/cli/chunks/unified-memory-hnsw-SQEWFUBN.js +0 -2
  423. package/dist/cli/chunks/unified-persistence-EDCTT6SE.js +0 -2
  424. package/dist/cli/chunks/visual-security-SOGAETFP.js +0 -2
  425. package/dist/cli/chunks/witness-chain-AJCECBH5.js +0 -2
  426. package/dist/cli/chunks/workflow-orchestrator-UXRUCOZR.js +0 -2
@@ -29,6 +29,7 @@ import * as os from 'os';
29
29
  import * as path from 'path';
30
30
  import { MEMORY_CONSTANTS } from './constants.js';
31
31
  import { LoggerFactory } from '../logging/index.js';
32
+ import { HashChainGate } from '../integrations/ruvector/proof-gate.js';
32
33
  const logger = LoggerFactory.create('unified-memory');
33
34
  // Re-export from shared module for backward compatibility
34
35
  export { validateTableName, ALLOWED_TABLE_NAMES } from '../shared/sql-safety.js';
@@ -122,6 +123,12 @@ export class UnifiedMemoryManager {
122
123
  vectorIndex = new UnifiedHnswIndex('qe-memory');
123
124
  // CRDT store for distributed state synchronization
124
125
  crdtStore = null;
126
+ // Proof-gate (AQE ADR-116; upstream ADR-194): tamper-evident SHA-256 hash chain over kv writes.
127
+ // Off by default; enable per audit window via enableProofGate() / AQE_PROOF_GATE=1.
128
+ proofGate = null;
129
+ proofGateEnvChecked = false;
130
+ static PROOF_NS = '__proofgate__';
131
+ static PROOF_KEY = 'chain';
125
132
  constructor(config) {
126
133
  const resolvedDefaults = getResolvedDefaultConfig();
127
134
  this.config = { ...resolvedDefaults, ...config };
@@ -472,6 +479,8 @@ export class UnifiedMemoryManager {
472
479
  }
473
480
  if (currentVersion < 10)
474
481
  this.db.exec(PATTERN_NULLS_SCHEMA);
482
+ if (currentVersion < 11)
483
+ this.migrateToV11GoapExecutionSteps();
475
484
  this.db.prepare(`
476
485
  INSERT OR REPLACE INTO schema_version (id, version, migrated_at)
477
486
  VALUES (1, ?, datetime('now'))
@@ -481,6 +490,47 @@ export class UnifiedMemoryManager {
481
490
  console.log(`[UnifiedMemory] Migration complete`);
482
491
  }
483
492
  }
493
+ /**
494
+ * A14: create/backfill goap_execution_steps and goap_actions' real-method
495
+ * binding columns (method/params/implemented).
496
+ *
497
+ * Re-running GOAP_SCHEMA's `CREATE TABLE IF NOT EXISTS` alone is
498
+ * insufficient here: some databases (this project's own dev DB included)
499
+ * already have a `goap_execution_steps` table left over from an older,
500
+ * narrower schema version that predates unified-memory-schemas.ts
501
+ * tracking this table at all — `IF NOT EXISTS` silently no-ops against it,
502
+ * permanently missing the columns plan-executor.ts now needs. Likewise
503
+ * `goap_actions` already exists in every migrated database (it's been
504
+ * part of the schema since v3), so the new method/params/implemented
505
+ * columns need an explicit ALTER, not just GOAP_SCHEMA's CREATE TABLE.
506
+ *
507
+ * Note: this only adds the columns — it does NOT backfill real method
508
+ * bindings onto already-seeded action rows (those exist with random,
509
+ * non-deterministic ids assigned at seed time, not stable across the
510
+ * qe-action-library.ts source). That backfill is a planning-layer
511
+ * concern, keyed by action `name` against the current library
512
+ * definitions — see GOAPPlanner.backfillActionMethodBindings().
513
+ */
514
+ migrateToV11GoapExecutionSteps() {
515
+ const db = this.db;
516
+ db.exec(GOAP_SCHEMA); // no-op for goap_goals/plans/signatures if already present; creates goap_execution_steps fresh if absent entirely; adds goap_actions if absent entirely (fresh installs only)
517
+ const addColumnIfMissing = (table, column, definition) => {
518
+ const cols = db.prepare(`SELECT name FROM pragma_table_info('${table}')`).all();
519
+ if (!cols.some((c) => c.name === column)) {
520
+ db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
521
+ }
522
+ };
523
+ // Nullable even though new rows always populate them — ALTER TABLE can't
524
+ // retroactively backfill a NOT NULL value for a pre-existing table.
525
+ addColumnIfMissing('goap_execution_steps', 'execution_id', 'TEXT');
526
+ addColumnIfMissing('goap_execution_steps', 'retries', 'INTEGER DEFAULT 0');
527
+ addColumnIfMissing('goap_execution_steps', 'started_at', 'TEXT');
528
+ addColumnIfMissing('goap_execution_steps', 'agent_output', 'TEXT');
529
+ addColumnIfMissing('goap_actions', 'method', 'TEXT');
530
+ addColumnIfMissing('goap_actions', 'params', 'TEXT');
531
+ addColumnIfMissing('goap_actions', 'implemented', 'INTEGER DEFAULT 0');
532
+ db.exec('CREATE INDEX IF NOT EXISTS idx_goap_exec_steps_execution ON goap_execution_steps(execution_id)');
533
+ }
484
534
  async loadVectorIndex() {
485
535
  if (this.vectorsLoaded)
486
536
  return;
@@ -506,6 +556,8 @@ export class UnifiedMemoryManager {
506
556
  INSERT OR REPLACE INTO kv_store (key, namespace, value, expires_at)
507
557
  VALUES (?, ?, ?, ?)
508
558
  `).run(key, namespace, serialized, expiresAt);
559
+ // ADR-194: tamper-evident audit (no-op unless the proof-gate is enabled).
560
+ this.auditWrite('kvSet', namespace, key, serialized);
509
561
  }
510
562
  async kvGet(key, namespace = 'default') {
511
563
  this.ensureInitialized();
@@ -524,6 +576,9 @@ export class UnifiedMemoryManager {
524
576
  async kvDelete(key, namespace = 'default') {
525
577
  this.ensureInitialized();
526
578
  const result = this.db.prepare('DELETE FROM kv_store WHERE key = ? AND namespace = ?').run(key, namespace);
579
+ // ADR-194: audit deletes too (no-op unless the proof-gate is enabled).
580
+ if (result.changes > 0)
581
+ this.auditWrite('kvDelete', namespace, key, '');
527
582
  return result.changes > 0;
528
583
  }
529
584
  async kvExists(key, namespace = 'default') {
@@ -551,6 +606,99 @@ export class UnifiedMemoryManager {
551
606
  return result.changes;
552
607
  }
553
608
  // ============================================================================
609
+ // Proof-Gate: tamper-evident write audit (ADR-194)
610
+ // ============================================================================
611
+ /**
612
+ * Enable the tamper-evident proof-gate audit. OFF by default — once enabled,
613
+ * every kv write/delete admits a receipt to a persisted SHA-256 hash chain so
614
+ * {@link verifyMemoryIntegrity} can later prove no admitted write was mutated,
615
+ * reordered, or dropped. Restores any chain persisted from a prior process.
616
+ *
617
+ * Intended for BOUNDED audit windows (a sync / migration / publish gate), not
618
+ * permanent always-on use: the chain grows O(n) with audited writes and its
619
+ * snapshot is rewritten per write. Idempotent.
620
+ */
621
+ enableProofGate() {
622
+ this.ensureInitialized();
623
+ this.proofGateEnvChecked = true;
624
+ if (this.proofGate)
625
+ return;
626
+ this.proofGate = this.loadProofChain() ?? new HashChainGate();
627
+ }
628
+ isProofGateEnabled() {
629
+ return this.proofGate !== null;
630
+ }
631
+ /**
632
+ * Re-derive the proof-gate chain from genesis. Returns true iff no admitted
633
+ * write was mutated, reordered, or dropped. Throws if the gate is not enabled.
634
+ */
635
+ verifyMemoryIntegrity() {
636
+ if (!this.proofGate) {
637
+ throw new Error('Proof-gate not enabled — call enableProofGate() or set AQE_PROOF_GATE=1');
638
+ }
639
+ return this.proofGate.verifyIntegrity();
640
+ }
641
+ /** Current proof-gate chain head (hex), or null if the gate is not enabled. */
642
+ getProofChainRoot() {
643
+ return this.proofGate ? this.proofGate.chainRoot() : null;
644
+ }
645
+ /** Number of writes admitted to the proof-gate chain (0 if not enabled). */
646
+ getProofChainLength() {
647
+ return this.proofGate ? this.proofGate.length : 0;
648
+ }
649
+ /**
650
+ * Best-effort audit of a kv mutation. Admits a content-bound receipt and
651
+ * persists the chain. NEVER throws into the caller — the actual write has
652
+ * already committed; a failed audit must not break or alter it.
653
+ */
654
+ auditWrite(op, namespace, key, serializedValue) {
655
+ // Lazy env-enable so an operator can turn auditing on without a code change.
656
+ if (!this.proofGate) {
657
+ if (this.proofGateEnvChecked)
658
+ return;
659
+ this.proofGateEnvChecked = true;
660
+ if (process.env.AQE_PROOF_GATE !== '1')
661
+ return;
662
+ this.proofGate = this.loadProofChain() ?? new HashChainGate();
663
+ }
664
+ // Never audit the chain's own persistence namespace (no self-reference / recursion).
665
+ if (namespace === UnifiedMemoryManager.PROOF_NS)
666
+ return;
667
+ try {
668
+ this.proofGate.admit({ op, ns: namespace, key, value: serializedValue });
669
+ this.persistProofChain();
670
+ }
671
+ catch (error) {
672
+ logger.warn(`proof-gate audit skipped for ${namespace}/${key}: ${toErrorMessage(error)}`);
673
+ }
674
+ }
675
+ /** Persist the chain snapshot via a DIRECT write (bypasses kvSet → no recursion). */
676
+ persistProofChain() {
677
+ if (!this.proofGate || !this.db)
678
+ return;
679
+ this.db.prepare(`
680
+ INSERT OR REPLACE INTO kv_store (key, namespace, value, expires_at)
681
+ VALUES (?, ?, ?, NULL)
682
+ `).run(UnifiedMemoryManager.PROOF_KEY, UnifiedMemoryManager.PROOF_NS, JSON.stringify(this.proofGate.toJSON()));
683
+ }
684
+ /** Restore a persisted chain from the reserved namespace, or null if none/corrupt. */
685
+ loadProofChain() {
686
+ if (!this.db)
687
+ return null;
688
+ const row = this.db.prepare(`
689
+ SELECT value FROM kv_store WHERE key = ? AND namespace = ?
690
+ `).get(UnifiedMemoryManager.PROOF_KEY, UnifiedMemoryManager.PROOF_NS);
691
+ if (!row)
692
+ return null;
693
+ try {
694
+ return HashChainGate.fromJSON(JSON.parse(row.value));
695
+ }
696
+ catch (error) {
697
+ logger.warn(`proof-gate chain failed to load (starting fresh): ${toErrorMessage(error)}`);
698
+ return null;
699
+ }
700
+ }
701
+ // ============================================================================
554
702
  // Vector Operations
555
703
  // ============================================================================
556
704
  async vectorStore(id, embedding, namespace = 'default', metadata) {
@@ -410,7 +410,9 @@ export class AQELearningEngine {
410
410
  const key = `pattern-usage:search:${Date.now()}-${randomUUID().slice(0, 8)}`;
411
411
  await this.memory.set(key, searchEvent, {
412
412
  persist: true,
413
- ttl: 7 * 24 * 60 * 60 * 1000, // 7 days retention
413
+ // ttl is in SECONDS, not ms (unified-memory.ts:607) the extra
414
+ // * 1000 made this ~19,178 years instead of 7 days.
415
+ ttl: 7 * 24 * 60 * 60, // 7 days retention
414
416
  });
415
417
  }
416
418
  catch (error) {
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * @module learning/dream/concept-graph
16
16
  */
17
- import type { ConceptNode, ConceptGraphConfig, ConceptGraphStats, ConceptType, EdgeType, CreateConceptNodeInput, PatternImportData, NeighborResult } from './types.js';
17
+ import type { ConceptNode, ConceptGraphConfig, ConceptGraphStats, ConceptType, EdgeType, CreateConceptNodeInput, PatternImportData, FailureImportData, SuccessImportData, NeighborResult } from './types.js';
18
18
  /**
19
19
  * Graph-based concept storage for dream-based pattern discovery
20
20
  *
@@ -95,6 +95,14 @@ export declare class ConceptGraph {
95
95
  * @param depth How many hops to traverse (default: 2)
96
96
  */
97
97
  getCluster(nodeId: string, depth?: number): Promise<ConceptNode[]>;
98
+ /**
99
+ * QEPatternType values representing methodology/approach — loaded as
100
+ * conceptType 'technique' rather than 'pattern' (A8-EXT). Without this
101
+ * split, no 'technique' node ever existed, so detectPatternMerges'
102
+ * pattern-OR-technique check and detectGaps' technique-presence check
103
+ * could never see a technique.
104
+ */
105
+ private static readonly TECHNIQUE_PATTERN_TYPES;
98
106
  /**
99
107
  * Load patterns into the concept graph as nodes with edge discovery.
100
108
  * Idempotent — skips patterns whose pattern_id already has a node.
@@ -114,6 +122,28 @@ export declare class ConceptGraph {
114
122
  * @returns Number of new edges created
115
123
  */
116
124
  discoverSameDomainEdges(newNodesByDomain?: Map<string, string[]>): Promise<number>;
125
+ /**
126
+ * Connect a newly-created node to up to `limit` existing pattern/technique
127
+ * nodes in the same domain — the resolution/technique signal detectGaps
128
+ * checks for. Deliberately domain-scoped only (never wired directly to the
129
+ * record's own source pattern) so "hasResolution" reflects whether some
130
+ * OTHER real pattern addresses the domain, not a trivial self-reference.
131
+ */
132
+ private connectToDomainMates;
133
+ /**
134
+ * Load real ADR-110 pattern-null (recorded failure) rows as 'error'
135
+ * concept nodes — real data source for detectGaps' "error without
136
+ * resolution" check. Idempotent via the synthetic `error:<null.id>` key
137
+ * stored in pattern_id (concept_nodes.pattern_id has no FK, so this
138
+ * distinctly-prefixed key space never collides with a real qe_patterns.id).
139
+ */
140
+ loadFailuresAsErrors(failures: FailureImportData[]): Promise<number>;
141
+ /**
142
+ * Load real qe_pattern_usage success rows as 'outcome' concept nodes —
143
+ * real data source for detectGaps' "outcome without technique" check.
144
+ * Same idempotency/domain-edge treatment as loadFailuresAsErrors.
145
+ */
146
+ loadSuccessesAsOutcomes(successes: SuccessImportData[]): Promise<number>;
117
147
  /**
118
148
  * Count existing similarity edges for a domain.
119
149
  * Uses concept_nodes metadata to identify domain membership.
@@ -358,6 +358,20 @@ export class ConceptGraph {
358
358
  // ==========================================================================
359
359
  // Pattern Import
360
360
  // ==========================================================================
361
+ /**
362
+ * QEPatternType values representing methodology/approach — loaded as
363
+ * conceptType 'technique' rather than 'pattern' (A8-EXT). Without this
364
+ * split, no 'technique' node ever existed, so detectPatternMerges'
365
+ * pattern-OR-technique check and detectGaps' technique-presence check
366
+ * could never see a technique.
367
+ */
368
+ static TECHNIQUE_PATTERN_TYPES = new Set([
369
+ 'coverage-strategy',
370
+ 'mutation-strategy',
371
+ 'refactor-safe',
372
+ 'error-handling',
373
+ 'meta-optimization',
374
+ ]);
361
375
  /**
362
376
  * Load patterns into the concept graph as nodes with edge discovery.
363
377
  * Idempotent — skips patterns whose pattern_id already has a node.
@@ -376,8 +390,11 @@ export class ConceptGraph {
376
390
  const existing = await this.findNodeByPatternId(pattern.id);
377
391
  if (existing)
378
392
  continue;
393
+ const conceptType = pattern.patternType && ConceptGraph.TECHNIQUE_PATTERN_TYPES.has(pattern.patternType)
394
+ ? 'technique'
395
+ : 'pattern';
379
396
  const patternNodeId = await this.addNode({
380
- conceptType: 'pattern',
397
+ conceptType,
381
398
  content: `${pattern.name}: ${pattern.description}`,
382
399
  patternId: pattern.id,
383
400
  metadata: {
@@ -457,7 +474,7 @@ export class ConceptGraph {
457
474
  const newIdSet = new Set(newIds);
458
475
  const domainBudget = MAX_TOTAL_EDGES_PER_DOMAIN - existingDomainEdgeCount;
459
476
  // Get existing (non-new) same-domain nodes
460
- const allDomainNodes = this.db.prepare("SELECT id, metadata FROM concept_nodes WHERE concept_type = 'pattern'").all();
477
+ const allDomainNodes = this.db.prepare("SELECT id, metadata FROM concept_nodes WHERE concept_type IN ('pattern', 'technique')").all();
461
478
  const existingDomainNodes = allDomainNodes.filter((n) => {
462
479
  if (newIdSet.has(n.id))
463
480
  return false;
@@ -548,6 +565,95 @@ export class ConceptGraph {
548
565
  }
549
566
  return edgesCreated;
550
567
  }
568
+ // ==========================================================================
569
+ // Failure / Success Import (A8-EXT — detectGaps real data)
570
+ // ==========================================================================
571
+ /**
572
+ * Connect a newly-created node to up to `limit` existing pattern/technique
573
+ * nodes in the same domain — the resolution/technique signal detectGaps
574
+ * checks for. Deliberately domain-scoped only (never wired directly to the
575
+ * record's own source pattern) so "hasResolution" reflects whether some
576
+ * OTHER real pattern addresses the domain, not a trivial self-reference.
577
+ */
578
+ connectToDomainMates(nodeId, domain, excludePatternId, limit = 10) {
579
+ if (!this.db)
580
+ return;
581
+ const mates = this.db.prepare(`SELECT id FROM concept_nodes
582
+ WHERE concept_type IN ('pattern', 'technique')
583
+ AND json_extract(metadata, '$.domain') = ?
584
+ AND (pattern_id IS NULL OR pattern_id != ?)
585
+ LIMIT ?`).all(domain, excludePatternId, limit);
586
+ for (const mate of mates) {
587
+ const existing = this.prepared.get('getEdge')?.get(nodeId, mate.id);
588
+ if (!existing) {
589
+ this.prepared.get('insertEdge').run(uuidv4(), nodeId, mate.id, 'co_occurrence', 0.4, 1);
590
+ }
591
+ }
592
+ }
593
+ /**
594
+ * Load real ADR-110 pattern-null (recorded failure) rows as 'error'
595
+ * concept nodes — real data source for detectGaps' "error without
596
+ * resolution" check. Idempotent via the synthetic `error:<null.id>` key
597
+ * stored in pattern_id (concept_nodes.pattern_id has no FK, so this
598
+ * distinctly-prefixed key space never collides with a real qe_patterns.id).
599
+ */
600
+ async loadFailuresAsErrors(failures) {
601
+ this.ensureInitialized();
602
+ let loaded = 0;
603
+ for (const failure of failures) {
604
+ try {
605
+ const syntheticKey = `error:${failure.id}`;
606
+ const existing = await this.findNodeByPatternId(syntheticKey);
607
+ if (existing)
608
+ continue;
609
+ const errorNodeId = await this.addNode({
610
+ conceptType: 'error',
611
+ content: failure.failureMode,
612
+ patternId: syntheticKey,
613
+ metadata: { domain: failure.domain, sourcePatternId: failure.sourcePatternId },
614
+ });
615
+ loaded++;
616
+ this.connectToDomainMates(errorNodeId, failure.domain, failure.sourcePatternId);
617
+ }
618
+ catch (error) {
619
+ if (this.config.debug) {
620
+ console.error(`[ConceptGraph] Failed to load failure: ${failure.id}`, error);
621
+ }
622
+ }
623
+ }
624
+ return loaded;
625
+ }
626
+ /**
627
+ * Load real qe_pattern_usage success rows as 'outcome' concept nodes —
628
+ * real data source for detectGaps' "outcome without technique" check.
629
+ * Same idempotency/domain-edge treatment as loadFailuresAsErrors.
630
+ */
631
+ async loadSuccessesAsOutcomes(successes) {
632
+ this.ensureInitialized();
633
+ let loaded = 0;
634
+ for (const success of successes) {
635
+ try {
636
+ const syntheticKey = `outcome:${success.id}`;
637
+ const existing = await this.findNodeByPatternId(syntheticKey);
638
+ if (existing)
639
+ continue;
640
+ const outcomeNodeId = await this.addNode({
641
+ conceptType: 'outcome',
642
+ content: success.description,
643
+ patternId: syntheticKey,
644
+ metadata: { domain: success.domain, sourcePatternId: success.sourcePatternId },
645
+ });
646
+ loaded++;
647
+ this.connectToDomainMates(outcomeNodeId, success.domain, success.sourcePatternId);
648
+ }
649
+ catch (error) {
650
+ if (this.config.debug) {
651
+ console.error(`[ConceptGraph] Failed to load success: ${success.id}`, error);
652
+ }
653
+ }
654
+ }
655
+ return loaded;
656
+ }
551
657
  /**
552
658
  * Count existing similarity edges for a domain.
553
659
  * Uses concept_nodes metadata to identify domain membership.
@@ -560,7 +666,7 @@ export class ConceptGraph {
560
666
  SELECT COUNT(*) as count FROM concept_edges e
561
667
  JOIN concept_nodes n ON e.source = n.id
562
668
  WHERE e.edge_type = 'similarity'
563
- AND n.concept_type = 'pattern'
669
+ AND n.concept_type IN ('pattern', 'technique')
564
670
  AND json_extract(n.metadata, '$.domain') = ?
565
671
  `).get(domain);
566
672
  return result.count;
@@ -18,7 +18,7 @@ import { type ActivationConfig } from './spreading-activation.js';
18
18
  import { type InsightConfig, type DreamInsight } from './insight-generator.js';
19
19
  import { RVCOWBranchManager, type Branch, type ValidationResult, type ValidationThresholds } from './rvcow-branch-manager.js';
20
20
  import type { WitnessChain } from '../../audit/witness-chain.js';
21
- import type { DreamCycle, PatternImportData } from './types.js';
21
+ import type { DreamCycle, PatternImportData, FailureImportData, SuccessImportData } from './types.js';
22
22
  /**
23
23
  * Complete DreamEngine configuration
24
24
  */
@@ -143,6 +143,18 @@ export declare class DreamEngine {
143
143
  * @returns Number of patterns successfully loaded
144
144
  */
145
145
  loadPatternsAsConcepts(patterns: PatternImportData[]): Promise<number>;
146
+ /**
147
+ * Load real ADR-110 pattern-null (failure) data as 'error' concept nodes
148
+ * (A8-EXT) — public wrapper for direct/test use; `ensureConceptsLoaded()`
149
+ * calls this automatically from the real qe_pattern_nulls table.
150
+ */
151
+ loadFailuresAsConcepts(failures: FailureImportData[]): Promise<number>;
152
+ /**
153
+ * Load real qe_pattern_usage success data as 'outcome' concept nodes
154
+ * (A8-EXT) — public wrapper for direct/test use; `ensureConceptsLoaded()`
155
+ * calls this automatically from the real qe_pattern_usage table.
156
+ */
157
+ loadSuccessesAsConcepts(successes: SuccessImportData[]): Promise<number>;
146
158
  /**
147
159
  * Ensure sufficient concepts are loaded for dreaming.
148
160
  * If the concept graph has fewer nodes than minConceptsRequired,
@@ -474,6 +474,24 @@ export class DreamEngine {
474
474
  this.ensureInitialized();
475
475
  return this.graph.loadFromPatterns(patterns);
476
476
  }
477
+ /**
478
+ * Load real ADR-110 pattern-null (failure) data as 'error' concept nodes
479
+ * (A8-EXT) — public wrapper for direct/test use; `ensureConceptsLoaded()`
480
+ * calls this automatically from the real qe_pattern_nulls table.
481
+ */
482
+ async loadFailuresAsConcepts(failures) {
483
+ this.ensureInitialized();
484
+ return this.graph.loadFailuresAsErrors(failures);
485
+ }
486
+ /**
487
+ * Load real qe_pattern_usage success data as 'outcome' concept nodes
488
+ * (A8-EXT) — public wrapper for direct/test use; `ensureConceptsLoaded()`
489
+ * calls this automatically from the real qe_pattern_usage table.
490
+ */
491
+ async loadSuccessesAsConcepts(successes) {
492
+ this.ensureInitialized();
493
+ return this.graph.loadSuccessesAsOutcomes(successes);
494
+ }
477
495
  /**
478
496
  * Ensure sufficient concepts are loaded for dreaming.
479
497
  * If the concept graph has fewer nodes than minConceptsRequired,
@@ -483,17 +501,70 @@ export class DreamEngine {
483
501
  */
484
502
  async ensureConceptsLoaded() {
485
503
  this.ensureInitialized();
504
+ // A8-EXT follow-up fix: this refresh must NOT be gated behind the
505
+ // "do we have enough concepts to dream at all" check below — on any
506
+ // project that's run more than a handful of dream cycles,
507
+ // `existing.length` permanently exceeds `minConceptsRequired`, so the
508
+ // gate would make this whole block unreachable in real, automatic
509
+ // operation forever (only reachable via the direct
510
+ // loadFailuresAsConcepts()/loadSuccessesAsConcepts() test/manual
511
+ // wrappers). Runs on every call instead: loadFailuresAsErrors() /
512
+ // loadSuccessesAsOutcomes() are idempotent (synthetic
513
+ // `error:<id>`/`outcome:<id>` keys), and each query is a single
514
+ // indexed LIMIT-100 read, so refreshing every dream cycle is cheap.
515
+ try {
516
+ const failureRows = this.db.prepare(`SELECT n.id as id, n.pattern_id as sourcePatternId, p.qe_domain as domain, n.failure_mode as failureMode
517
+ FROM qe_pattern_nulls n
518
+ JOIN qe_patterns p ON p.id = n.pattern_id
519
+ ORDER BY n.updated_at DESC
520
+ LIMIT 100`).all();
521
+ if (failureRows.length > 0) {
522
+ await this.graph.loadFailuresAsErrors(failureRows);
523
+ }
524
+ const successRows = this.db.prepare(`SELECT u.id as id, u.pattern_id as sourcePatternId, p.qe_domain as domain,
525
+ ('Pattern "' || p.name || '" applied successfully') as description
526
+ FROM qe_pattern_usage u
527
+ JOIN qe_patterns p ON p.id = u.pattern_id
528
+ WHERE u.success = 1
529
+ ORDER BY u.created_at DESC
530
+ LIMIT 100`).all();
531
+ if (successRows.length > 0) {
532
+ await this.graph.loadSuccessesAsOutcomes(successRows);
533
+ }
534
+ }
535
+ catch (error) {
536
+ if (process.env.DEBUG) {
537
+ dreamLogger.debug('Error/outcome concept loading skipped', { error: toErrorMessage(error) });
538
+ }
539
+ }
486
540
  const existing = await this.graph.getActiveNodes(0);
487
541
  if (existing.length >= this.config.minConceptsRequired) {
488
542
  return 0;
489
543
  }
490
- // Load patterns from qe_patterns table in the shared unified DB
491
- const rows = this.db.prepare(`SELECT id, name, description, qe_domain as domain, pattern_type as patternType,
492
- confidence, success_rate as successRate
493
- FROM qe_patterns
494
- WHERE confidence >= 0.3
495
- ORDER BY quality_score DESC
496
- LIMIT 200`).all();
544
+ // Load patterns from qe_patterns table in the shared unified DB.
545
+ // A8-EXT: the top-160-by-quality pool alone starves detectOptimizations
546
+ // quality_score already weights success_rate at 0.5, so the best-quality
547
+ // patterns are, by construction, rarely the "room for improvement"
548
+ // candidates that detector looks for. Union in a genuine low-performer
549
+ // sample (bottom-40 by success_rate among confidence>=0.3 patterns) so
550
+ // real optimization candidates actually reach the detector.
551
+ const rows = this.db.prepare(`SELECT * FROM (
552
+ SELECT id, name, description, qe_domain as domain, pattern_type as patternType,
553
+ confidence, success_rate as successRate
554
+ FROM qe_patterns
555
+ WHERE confidence >= 0.3
556
+ ORDER BY quality_score DESC
557
+ LIMIT 160
558
+ )
559
+ UNION
560
+ SELECT * FROM (
561
+ SELECT id, name, description, qe_domain as domain, pattern_type as patternType,
562
+ confidence, success_rate as successRate
563
+ FROM qe_patterns
564
+ WHERE confidence >= 0.3 AND success_rate < 0.7
565
+ ORDER BY usage_count DESC
566
+ LIMIT 40
567
+ )`).all();
497
568
  if (rows.length === 0) {
498
569
  return 0;
499
570
  }
@@ -526,9 +597,59 @@ export class DreamEngine {
526
597
  error: 'Insight already applied',
527
598
  };
528
599
  }
529
- // Generate a pattern ID
530
- const patternId = `dream-pattern-${uuidv4()}`;
531
- // Mark insight as applied
600
+ // Create a REAL pattern in QEReasoningBank — this used to mint a fake
601
+ // `dream-pattern-<uuid>` that never resolved to any qe_patterns row.
602
+ // Single implementation shared with the MCP `apply` action (dream.ts)
603
+ // and the scheduler's autoApplyInsights, both of which call this method
604
+ // directly — no duplicate pattern-creation logic to drift out of sync.
605
+ const { getSharedMemoryBackend } = await import('../../mcp/tools/base.js');
606
+ const { createQEReasoningBank } = await import('../qe-reasoning-bank.js');
607
+ const memoryBackend = await getSharedMemoryBackend();
608
+ const reasoningBank = createQEReasoningBank(memoryBackend);
609
+ await reasoningBank.initialize();
610
+ // Wire RVF dual-writer (optional, best-effort — matches the prior
611
+ // MCP-only implementation's parity with other pattern-creation paths).
612
+ try {
613
+ const { getSharedRvfDualWriter } = await import('../../integrations/ruvector/shared-rvf-dual-writer.js');
614
+ const dualWriter = await getSharedRvfDualWriter();
615
+ if (dualWriter)
616
+ reasoningBank.setRvfDualWriter(dualWriter);
617
+ }
618
+ catch (e) {
619
+ if (process.env.DEBUG)
620
+ dreamLogger.debug('RVF wiring skipped', { error: toErrorMessage(e) });
621
+ }
622
+ let sourceConcepts = [];
623
+ try {
624
+ sourceConcepts = safeJsonParse(insightRow.source_concepts);
625
+ }
626
+ catch {
627
+ // Malformed source_concepts shouldn't block pattern creation.
628
+ }
629
+ const patternResult = await reasoningBank.storePattern({
630
+ patternType: mapInsightTypeToPatternType(insightRow.insight_type),
631
+ name: `Dream Insight: ${insightRow.insight_type}`,
632
+ description: `${insightRow.description} (confidence: ${insightRow.confidence_score.toFixed(2)})`,
633
+ template: {
634
+ type: 'workflow',
635
+ content: insightRow.suggested_action || insightRow.description,
636
+ variables: [],
637
+ },
638
+ context: {
639
+ tags: ['dream-generated', insightRow.insight_type, ...sourceConcepts.slice(0, 3)],
640
+ complexity: 'medium',
641
+ },
642
+ });
643
+ if (!patternResult.success) {
644
+ // Do NOT mark applied — leave it retryable rather than silently
645
+ // swallowing a real pattern-creation failure behind a fake success.
646
+ return {
647
+ success: false,
648
+ error: `Failed to create pattern: ${patternResult.error?.message ?? 'unknown error'}`,
649
+ };
650
+ }
651
+ const patternId = patternResult.value.id;
652
+ // Mark insight as applied — pattern_id now points at the REAL row.
532
653
  const stmt = this.db.prepare(`
533
654
  UPDATE dream_insights
534
655
  SET applied = 1, pattern_id = ?
@@ -725,6 +846,21 @@ export class DreamEngine {
725
846
  };
726
847
  }
727
848
  }
849
+ /**
850
+ * Map a dream insight type to the closest QEPatternType. Shared by
851
+ * DreamEngine.applyInsight — the single implementation used by both the
852
+ * MCP `apply` action and the scheduler's auto-apply path.
853
+ */
854
+ function mapInsightTypeToPatternType(insightType) {
855
+ const mapping = {
856
+ 'cross-domain': 'coverage-strategy',
857
+ 'novel-path': 'test-template',
858
+ 'cluster': 'refactor-safe',
859
+ 'high-activation': 'assertion-pattern',
860
+ 'bridge': 'mock-pattern',
861
+ };
862
+ return mapping[insightType] || 'test-template';
863
+ }
728
864
  // ============================================================================
729
865
  // Factory Function
730
866
  // ============================================================================
@@ -48,7 +48,7 @@
48
48
  *
49
49
  * @module learning/dream
50
50
  */
51
- export type { ConceptType, EdgeType, InsightType, DreamCycleStatus, ConceptNode, CreateConceptNodeInput, ConceptEdge, CreateEdgeInput, DreamCycle, DreamInsight, ConceptGraphStats, ConceptGraphConfig, PatternImportData, NeighborResult, DreamEngineConfig, DreamCycleResult, } from './types.js';
51
+ export type { ConceptType, EdgeType, InsightType, DreamCycleStatus, ConceptNode, CreateConceptNodeInput, ConceptEdge, CreateEdgeInput, DreamCycle, DreamInsight, ConceptGraphStats, ConceptGraphConfig, PatternImportData, FailureImportData, SuccessImportData, NeighborResult, DreamEngineConfig, DreamCycleResult, } from './types.js';
52
52
  export { DEFAULT_CONCEPT_GRAPH_CONFIG } from './types.js';
53
53
  export { ConceptGraph, createConceptGraph } from './concept-graph.js';
54
54
  export { SpreadingActivation, type ActivationConfig, type ActivationResult, DEFAULT_ACTIVATION_CONFIG, MAX_ACTIVATION_HISTORY_ENTRIES, MAX_COACTIVATION_ENTRIES, HISTORY_TRIM_TARGET_RATIO, } from './spreading-activation.js';
@@ -227,6 +227,29 @@ export interface PatternImportData {
227
227
  confidence?: number;
228
228
  successRate?: number;
229
229
  }
230
+ /**
231
+ * Real ADR-110 pattern-null (recorded failure) data for importing as
232
+ * 'error' concept nodes — A8-EXT.
233
+ */
234
+ export interface FailureImportData {
235
+ /** qe_pattern_nulls.id — unique, used as the node's synthetic patternId key */
236
+ id: string;
237
+ /** The pattern that failed (NOT used to create an edge — that would trivially satisfy "hasResolution") */
238
+ sourcePatternId: string;
239
+ domain: string;
240
+ failureMode: string;
241
+ }
242
+ /**
243
+ * Real qe_pattern_usage (successful application) data for importing as
244
+ * 'outcome' concept nodes — A8-EXT.
245
+ */
246
+ export interface SuccessImportData {
247
+ /** qe_pattern_usage.id — unique, used as the node's synthetic patternId key */
248
+ id: number;
249
+ sourcePatternId: string;
250
+ domain: string;
251
+ description: string;
252
+ }
230
253
  /**
231
254
  * Neighbor result with node and edge
232
255
  */