agentic-qe 3.11.4 → 3.12.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 (449) hide show
  1. package/.claude/helpers/.helpers-version +1 -0
  2. package/.claude/helpers/auto-memory-hook.mjs +35 -3
  3. package/.claude/helpers/brain-checkpoint.cjs +16 -1
  4. package/.claude/helpers/helpers.manifest.json +12 -0
  5. package/.claude/helpers/hook-handler.cjs +26 -5
  6. package/.claude/helpers/intelligence.cjs +14 -1
  7. package/.claude/hooks/aqe-hook.cjs +57 -10
  8. package/.claude/skills/skills-manifest.json +1 -1
  9. package/CHANGELOG.md +110 -0
  10. package/assets/skills/skills-manifest.json +1 -1
  11. package/dist/adapters/a2a/auth/routes.js +59 -28
  12. package/dist/audit/witness-chain.d.ts +25 -0
  13. package/dist/audit/witness-chain.js +69 -22
  14. package/dist/audit/witness-key-manager.d.ts +11 -0
  15. package/dist/audit/witness-key-manager.js +24 -0
  16. package/dist/cli/brain-commands.js +2 -1
  17. package/dist/cli/bundle.js +6 -6
  18. package/dist/cli/chunks/adapter-6IWRIHF3.js +2 -0
  19. package/dist/cli/chunks/{agent-booster-wasm-62I6ZNRW.js → agent-booster-wasm-IO54X6IQ.js} +2 -2
  20. package/dist/cli/chunks/{agent-handler-E2TZKKBS.js → agent-handler-A57SZUCW.js} +2 -2
  21. package/dist/cli/chunks/{agent-memory-branch-JHAHC2NH.js → agent-memory-branch-BX7LRFGN.js} +2 -2
  22. package/dist/cli/chunks/aqe-learning-engine-FSF5U67K.js +2 -0
  23. package/dist/cli/chunks/{arena-72ZV65BR.js → arena-UTC4YY6Y.js} +4 -4
  24. package/dist/cli/chunks/{arena-KLG3YSSR.js → arena-Y3XTX6O7.js} +2 -2
  25. package/dist/cli/chunks/audit-L4RL2AOY.js +3 -0
  26. package/dist/cli/chunks/base-2CKCJU3O.js +2 -0
  27. package/dist/cli/chunks/{hnswlib-node-LAFK5QZ4.js → better-sqlite3-LRDXKYOJ.js} +2 -2
  28. package/dist/cli/chunks/brain-handler-OHDPI5TQ.js +89 -0
  29. package/dist/cli/chunks/{branch-enumerator-C7MPNYT7.js → branch-enumerator-ZRXE2CQ7.js} +2 -2
  30. package/dist/cli/chunks/{browser-UUDUDYLR.js → browser-NT33FG76.js} +2 -2
  31. package/dist/cli/chunks/browser-workflow-UGYJE64S.js +2 -0
  32. package/dist/cli/chunks/{chunk-7QTB5XIQ.js → chunk-27JCWG5J.js} +2 -2
  33. package/dist/cli/chunks/{chunk-3FJZMQJ7.js → chunk-2ALNNXFF.js} +2 -2
  34. package/dist/cli/chunks/{chunk-LMJUMUQJ.js → chunk-2AOOIAW3.js} +4 -4
  35. package/dist/cli/chunks/{chunk-CNF3ZWLM.js → chunk-2AR4B3DI.js} +2 -2
  36. package/dist/cli/chunks/{chunk-7ADD2ZQL.js → chunk-2KHDGC7N.js} +2 -2
  37. package/dist/cli/chunks/{chunk-P6S6ZVB5.js → chunk-2UMCB7AH.js} +1 -1
  38. package/dist/cli/chunks/{chunk-HH6NCBSP.js → chunk-335GHVJV.js} +22 -22
  39. package/dist/cli/chunks/{chunk-2WPSMQIL.js → chunk-36MPDANH.js} +1 -1
  40. package/dist/cli/chunks/{chunk-Y4AXOHW4.js → chunk-3AFNXU45.js} +1 -1
  41. package/dist/cli/chunks/{chunk-SL3SNOO2.js → chunk-3B4XXFKD.js} +2 -2
  42. package/dist/cli/chunks/{chunk-7IKWF2AD.js → chunk-4GU656WM.js} +1 -1
  43. package/dist/cli/chunks/{chunk-IQBZBUP5.js → chunk-4SALW7OT.js} +2 -2
  44. package/dist/cli/chunks/{chunk-TCVEKRPI.js → chunk-5FR5GBUT.js} +2 -2
  45. package/dist/cli/chunks/chunk-5VBPIJUZ.js +65 -0
  46. package/dist/cli/chunks/chunk-5XFX25AJ.js +4 -0
  47. package/dist/cli/chunks/{chunk-QSDIY3E2.js → chunk-5YGESYBC.js} +1 -1
  48. package/dist/cli/chunks/{chunk-5U2WHPXL.js → chunk-62RELCU6.js} +1 -1
  49. package/dist/cli/chunks/{chunk-QJ5NCYJ3.js → chunk-64M3FFM4.js} +2 -2
  50. package/dist/cli/chunks/{chunk-BMQDELPA.js → chunk-6JNNZGI2.js} +1 -1
  51. package/dist/cli/chunks/{chunk-U34OZXD6.js → chunk-6X3RJBA3.js} +2 -2
  52. package/dist/cli/chunks/{chunk-AE6HXMOG.js → chunk-72VZGAMJ.js} +1 -1
  53. package/dist/cli/chunks/{chunk-4JFH3MVA.js → chunk-7F7U2HUH.js} +1 -1
  54. package/dist/cli/chunks/{chunk-A4OMK3FO.js → chunk-7HJHXSYT.js} +2 -2
  55. package/dist/cli/chunks/chunk-7WX3MKRS.js +2 -0
  56. package/dist/cli/chunks/{chunk-O7PVZ32A.js → chunk-7ZIVDGSN.js} +1 -1
  57. package/dist/cli/chunks/{chunk-EZRHSHOQ.js → chunk-AAATFEIL.js} +2 -2
  58. package/dist/cli/chunks/{chunk-TQ373GGI.js → chunk-AEX75YGI.js} +2 -2
  59. package/dist/cli/chunks/chunk-BA6U7NSR.js +2 -0
  60. package/dist/cli/chunks/chunk-BB4OVXWF.js +14 -0
  61. package/dist/cli/chunks/{chunk-GRQ36XUH.js → chunk-BBC526PL.js} +2 -2
  62. package/dist/cli/chunks/{chunk-EONKMHKO.js → chunk-BGRJZH5Q.js} +2 -2
  63. package/dist/cli/chunks/{chunk-XQ6DW5FV.js → chunk-BUYPRUNY.js} +2 -2
  64. package/dist/cli/chunks/{chunk-TU6YN43Q.js → chunk-BZPF6GTL.js} +1 -1
  65. package/dist/cli/chunks/{chunk-TPMBFARK.js → chunk-C4SZSPXY.js} +67 -22
  66. package/dist/cli/chunks/{chunk-D6CKKNYC.js → chunk-C6GYLCTX.js} +2 -2
  67. package/dist/cli/chunks/{chunk-YNK6SUPU.js → chunk-CC5G3K4X.js} +2 -2
  68. package/dist/cli/chunks/{chunk-ADFKY3X2.js → chunk-CHO54B34.js} +2 -2
  69. package/dist/cli/chunks/{chunk-WQZ2WRO4.js → chunk-CMGYUCM7.js} +1 -1
  70. package/dist/cli/chunks/{chunk-QMC5MTBV.js → chunk-CSEEGX5T.js} +2 -2
  71. package/dist/cli/chunks/{chunk-FSGMRQFC.js → chunk-CVGXB7IX.js} +2 -2
  72. package/dist/cli/chunks/{chunk-5VSQAGA2.js → chunk-DQDFACYW.js} +1 -1
  73. package/dist/cli/chunks/chunk-DR7PCO3S.js +153 -0
  74. package/dist/cli/chunks/{chunk-D5S47YUS.js → chunk-DTOE3NYW.js} +3 -3
  75. package/dist/cli/chunks/{chunk-WZYNY3VF.js → chunk-DXOMRWDC.js} +1 -1
  76. package/dist/cli/chunks/{chunk-HJ24KMC2.js → chunk-EGH3H7QO.js} +1 -1
  77. package/dist/cli/chunks/{chunk-JFLSQH2X.js → chunk-EM2JIIAQ.js} +2 -2
  78. package/dist/cli/chunks/{chunk-MWFJC5HR.js → chunk-ESDGCTC4.js} +1 -1
  79. package/dist/cli/chunks/{chunk-SRVTNG6L.js → chunk-EZE2HRQB.js} +2 -2
  80. package/dist/cli/chunks/{chunk-ZFCVT43J.js → chunk-FEEMJDUF.js} +2 -2
  81. package/dist/cli/chunks/{chunk-HJO4RNOW.js → chunk-FI5SSLEF.js} +2 -2
  82. package/dist/cli/chunks/{chunk-XHRLBJTM.js → chunk-FKPUPQQT.js} +2 -2
  83. package/dist/cli/chunks/{chunk-ODZSQVEW.js → chunk-FOPS6DRZ.js} +1 -1
  84. package/dist/cli/chunks/{chunk-AQIEK4SY.js → chunk-FU5RNEXV.js} +2 -2
  85. package/dist/cli/chunks/{chunk-PQUXFSN6.js → chunk-FZIHOMGY.js} +2 -2
  86. package/dist/cli/chunks/{chunk-Z2REKBD6.js → chunk-FZRU73M4.js} +2 -2
  87. package/dist/cli/chunks/{chunk-NBBLPDJX.js → chunk-G5JQLUUO.js} +2 -2
  88. package/dist/cli/chunks/{chunk-4BFCLSDN.js → chunk-G6LR7FK7.js} +2 -2
  89. package/dist/cli/chunks/{chunk-QEVX4GWF.js → chunk-G6RKUEGL.js} +2 -2
  90. package/dist/cli/chunks/{chunk-HWBMYR5W.js → chunk-GCF42L7M.js} +5 -5
  91. package/dist/cli/chunks/{chunk-TSWF3AGQ.js → chunk-GGMQOEZZ.js} +2 -2
  92. package/dist/cli/chunks/{chunk-PFWJQPUC.js → chunk-HAEUPIKW.js} +2 -2
  93. package/dist/cli/chunks/{chunk-63QUN3JK.js → chunk-HDJMD6UH.js} +1 -1
  94. package/dist/cli/chunks/{chunk-JPENUVCI.js → chunk-HW62TB4T.js} +1 -1
  95. package/dist/cli/chunks/{chunk-WMIRAD3J.js → chunk-I6WHYRWB.js} +2 -2
  96. package/dist/cli/chunks/{chunk-YZ5EQR37.js → chunk-ICK3B24H.js} +2 -2
  97. package/dist/cli/chunks/{chunk-FRFVN6AA.js → chunk-IDLNLSQI.js} +2 -2
  98. package/dist/cli/chunks/{chunk-VQU7DMEY.js → chunk-IJUYHIKN.js} +2 -2
  99. package/dist/cli/chunks/{chunk-6JUOH6L4.js → chunk-IKVNYK7Y.js} +2 -2
  100. package/dist/cli/chunks/{chunk-ZKCKOQJI.js → chunk-JOBCMNTP.js} +2 -2
  101. package/dist/cli/chunks/{chunk-ARPBG6FQ.js → chunk-JYX7AZHE.js} +2 -2
  102. package/dist/cli/chunks/{chunk-SFDUT5WM.js → chunk-JYXSVSH2.js} +2 -2
  103. package/dist/cli/chunks/{chunk-VJGHRWMH.js → chunk-K5SN66B4.js} +2 -2
  104. package/dist/cli/chunks/{chunk-DNOU2HVQ.js → chunk-KDLYTJ5C.js} +2 -2
  105. package/dist/cli/chunks/{chunk-T76RFXQX.js → chunk-KI5BP4X5.js} +2 -2
  106. package/dist/cli/chunks/{chunk-7AWK43JN.js → chunk-KJWQ7ENF.js} +2 -2
  107. package/dist/cli/chunks/{chunk-BRLUNIR4.js → chunk-KN5GOEYK.js} +2 -2
  108. package/dist/cli/chunks/{chunk-VKJQAKYG.js → chunk-KZ37VHMJ.js} +2 -2
  109. package/dist/cli/chunks/{chunk-NV3TXXOW.js → chunk-KZMRU7DL.js} +2 -2
  110. package/dist/cli/chunks/{chunk-LLUPRGOR.js → chunk-L5ZLOW3K.js} +2 -2
  111. package/dist/cli/chunks/{chunk-THKZVOZV.js → chunk-LMJUQWR7.js} +1 -1
  112. package/dist/cli/chunks/{chunk-2KNFS3L5.js → chunk-MBF3Q7FQ.js} +1 -1
  113. package/dist/cli/chunks/chunk-MDT3LIXS.js +2 -0
  114. package/dist/cli/chunks/{chunk-B5XUWHKQ.js → chunk-MJPYNGZ7.js} +1 -1
  115. package/dist/cli/chunks/{chunk-UCYTY4LG.js → chunk-MK3J7JVZ.js} +2 -2
  116. package/dist/cli/chunks/{chunk-MCT4CD5M.js → chunk-MUAHFGIX.js} +2 -2
  117. package/dist/cli/chunks/{chunk-3SBUL72V.js → chunk-MUV56BPK.js} +2 -2
  118. package/dist/cli/chunks/{chunk-WNMDWP5A.js → chunk-NLHISTL2.js} +2 -2
  119. package/dist/cli/chunks/{chunk-UJMTKXPI.js → chunk-NNGCUJWQ.js} +2 -2
  120. package/dist/cli/chunks/chunk-NW7G57NR.js +27 -0
  121. package/dist/cli/chunks/{chunk-3SRPFBU7.js → chunk-O3C5RRDQ.js} +3 -3
  122. package/dist/cli/chunks/{chunk-AYGEWPN4.js → chunk-OHSVDMF7.js} +1 -1
  123. package/dist/cli/chunks/{chunk-AJXGGTX7.js → chunk-OPIWFXME.js} +1 -1
  124. package/dist/cli/chunks/{chunk-ZSBJNE35.js → chunk-P52YORQG.js} +2 -2
  125. package/dist/cli/chunks/chunk-PM566XEO.js +2 -0
  126. package/dist/cli/chunks/chunk-POKMJTD2.js +2 -0
  127. package/dist/cli/chunks/{chunk-GOQ4P2PB.js → chunk-PQMLIVGV.js} +2 -2
  128. package/dist/cli/chunks/{chunk-IB3ZPLFA.js → chunk-PT3FTGKZ.js} +2 -2
  129. package/dist/cli/chunks/{chunk-U3AVZGQA.js → chunk-Q5YRPS4P.js} +1 -1
  130. package/dist/cli/chunks/{chunk-5Z4FBCBK.js → chunk-QJ6H2HQQ.js} +1 -1
  131. package/dist/cli/chunks/{chunk-DRMHVY4T.js → chunk-RG552ROA.js} +4 -4
  132. package/dist/cli/chunks/{chunk-PEIQDQXN.js → chunk-RHC7TFPU.js} +2 -2
  133. package/dist/cli/chunks/{chunk-JNQN5DNS.js → chunk-RMFRFING.js} +1 -1
  134. package/dist/cli/chunks/{chunk-4YT5YN5G.js → chunk-RQN4HWGV.js} +2 -2
  135. package/dist/cli/chunks/{chunk-5P7Q5YNC.js → chunk-RYUSZ43T.js} +1 -1
  136. package/dist/cli/chunks/{chunk-O5NEJIHB.js → chunk-RZDNCTOA.js} +2 -2
  137. package/dist/cli/chunks/chunk-SCMXIBI7.js +2 -0
  138. package/dist/cli/chunks/{chunk-6545AS2J.js → chunk-SPEUF7ZL.js} +2 -2
  139. package/dist/cli/chunks/{chunk-LW5DHT3Z.js → chunk-SSXAW3ER.js} +2 -2
  140. package/dist/cli/chunks/{chunk-Q7ORVHJB.js → chunk-TC2JE5OK.js} +3 -3
  141. package/dist/cli/chunks/{chunk-MALOUGSF.js → chunk-TED4KOSK.js} +2 -2
  142. package/dist/cli/chunks/{chunk-ICCTQ5LO.js → chunk-TJ6N4CCX.js} +2 -2
  143. package/dist/cli/chunks/{chunk-6GYGAW53.js → chunk-TJEJ4UVX.js} +2 -2
  144. package/dist/cli/chunks/{chunk-VO6YJGB4.js → chunk-TO5PQSDD.js} +2 -2
  145. package/dist/cli/chunks/{chunk-LKURMUBU.js → chunk-TR5GOGH3.js} +37 -12
  146. package/dist/cli/chunks/{chunk-JCTCM6IR.js → chunk-UGJQJSPB.js} +1 -1
  147. package/dist/cli/chunks/{chunk-4RHNPRAP.js → chunk-USB44IHJ.js} +2 -2
  148. package/dist/cli/chunks/{chunk-JDFPAJGB.js → chunk-UUOXV3NS.js} +92 -92
  149. package/dist/cli/chunks/chunk-UVVKFBF7.js +2 -0
  150. package/dist/cli/chunks/{chunk-VCUCD3B5.js → chunk-V2MD5EDD.js} +2 -2
  151. package/dist/cli/chunks/{chunk-RFQBDMAP.js → chunk-VA7TEOPM.js} +1 -1
  152. package/dist/cli/chunks/{chunk-IF3HPQNV.js → chunk-VMP4M5PB.js} +1 -1
  153. package/dist/cli/chunks/{chunk-KUZMVH6N.js → chunk-VS4GMNJK.js} +3 -3
  154. package/dist/cli/chunks/{chunk-ZYZT2CDX.js → chunk-VWJSWXHG.js} +1 -1
  155. package/dist/cli/chunks/{chunk-54B6P2WS.js → chunk-VZ67ZDB3.js} +3 -3
  156. package/dist/cli/chunks/{chunk-NSPCZPTB.js → chunk-W2OMW6UU.js} +2 -2
  157. package/dist/cli/chunks/{chunk-3SKIZDKL.js → chunk-W766S4SK.js} +1 -1
  158. package/dist/cli/chunks/{chunk-N2BJN6AO.js → chunk-WJYTLRA5.js} +3 -3
  159. package/dist/cli/chunks/{chunk-X64BEXUY.js → chunk-WNASEUBW.js} +117 -113
  160. package/dist/cli/chunks/{chunk-HT6WAYIR.js → chunk-WT4ZDDFM.js} +1 -1
  161. package/dist/cli/chunks/chunk-XEYW3V5I.js +2 -0
  162. package/dist/cli/chunks/{chunk-6W3QHS45.js → chunk-XIFPIVZI.js} +2 -2
  163. package/dist/cli/chunks/{chunk-3E7D3A35.js → chunk-Y2MCIIJD.js} +1 -1
  164. package/dist/cli/chunks/{chunk-YUHM72VQ.js → chunk-YKOTOCO6.js} +2 -2
  165. package/dist/cli/chunks/{chunk-YKSWC7I4.js → chunk-Z3W3R4CW.js} +8 -20
  166. package/dist/cli/chunks/chunk-ZT2WHCVM.js +2 -0
  167. package/dist/cli/chunks/{chunk-G3TFNY4T.js → chunk-ZVPAFX4I.js} +2 -2
  168. package/dist/cli/chunks/{chunk-NFJT7XXR.js → chunk-ZWC6CM4R.js} +1 -1
  169. package/dist/cli/chunks/{ci-HQCRSCC7.js → ci-RJH5LAL3.js} +2 -2
  170. package/dist/cli/chunks/{ci-output-YBVXLA6O.js → ci-output-62SGMGB2.js} +2 -2
  171. package/dist/cli/chunks/{circuit-breaker-ULGMF2QN.js → circuit-breaker-QXTS5ZAW.js} +2 -2
  172. package/dist/cli/chunks/{claude-flow-setup-MKZ2LJXK.js → claude-flow-setup-BBCCT5WV.js} +2 -2
  173. package/dist/cli/chunks/client-E2XUBCLK.js +2 -0
  174. package/dist/cli/chunks/{cline-installer-WZQ6XBWN.js → cline-installer-IZCUJJ3I.js} +2 -2
  175. package/dist/cli/chunks/{code-H3KGH45S.js → code-AWNVOZ7S.js} +2 -2
  176. package/dist/cli/chunks/{code-index-extractor-NUVEAJ7C.js → code-index-extractor-MX65BKMI.js} +2 -2
  177. package/dist/cli/chunks/{codex-installer-JQI6E6CV.js → codex-installer-EQT6JVLM.js} +2 -2
  178. package/dist/cli/chunks/{completions-NDF4PFE7.js → completions-WOJAM45W.js} +2 -2
  179. package/dist/cli/chunks/{complexity-analyzer-XCZH66HG.js → complexity-analyzer-3DJB7V3K.js} +2 -2
  180. package/dist/cli/chunks/{continuedev-installer-Z4AJGZ7S.js → continuedev-installer-P4KWUTCJ.js} +2 -2
  181. package/dist/cli/chunks/{copilot-installer-K4IPAL7C.js → copilot-installer-FFZWTMWQ.js} +2 -2
  182. package/dist/cli/chunks/core-handlers-46Z5VOO6.js +2 -0
  183. package/dist/cli/chunks/{cost-tracker-35KXAB23.js → cost-tracker-CYBOV3NI.js} +2 -2
  184. package/dist/cli/chunks/{coverage-QW5I4TYZ.js → coverage-GTZJBSC4.js} +3 -3
  185. package/dist/cli/chunks/cross-domain-router-SXQ3HFRY.js +2 -0
  186. package/dist/cli/chunks/{cursor-installer-P4Z7RMIZ.js → cursor-installer-WZIVXGGB.js} +2 -2
  187. package/dist/cli/chunks/daemon-JWMHEJEN.js +10 -0
  188. package/dist/cli/chunks/{daemon-WQWTCYBM.js → daemon-MSFN2LXY.js} +3 -3
  189. package/dist/cli/chunks/{dag-attention-scheduler-7XD2VGON.js → dag-attention-scheduler-4TWOTTQE.js} +2 -2
  190. package/dist/cli/chunks/{detect-GZ3P4DI7.js → detect-YZ6AGQPB.js} +2 -2
  191. package/dist/cli/chunks/{dist-node-6WWAW7OP.js → dist-node-3EM2XH54.js} +2 -2
  192. package/dist/cli/chunks/{domain-handler-3GTLWARQ.js → domain-handler-4XU5BINU.js} +2 -2
  193. package/dist/cli/chunks/domain-transfer-HUFC7I52.js +2 -0
  194. package/dist/cli/chunks/dream-R6MQQQ3N.js +2 -0
  195. package/dist/cli/chunks/{embed-and-insert-pattern-BGIMA77V.js → embed-and-insert-pattern-J5ZFM6YX.js} +2 -2
  196. package/dist/cli/chunks/{eval-SXV6DRDD.js → eval-XYOA3EH2.js} +2 -2
  197. package/dist/cli/chunks/{experience-capture-middleware-TT6WCT2S.js → experience-capture-middleware-E3RYQB6Z.js} +3 -3
  198. package/dist/cli/chunks/{fast-paths-HTAZHEQP.js → fast-paths-DKIYN2YS.js} +2 -2
  199. package/dist/cli/chunks/{feature-flags-DIE3Z2B4.js → feature-flags-S2RNZATS.js} +2 -2
  200. package/dist/cli/chunks/{feature-flags-WBUKU54W.js → feature-flags-ZB63Z7N5.js} +2 -2
  201. package/dist/cli/chunks/{file-discovery-SKDETFS3.js → file-discovery-USJJLYQU.js} +2 -2
  202. package/dist/cli/chunks/{fleet-WCWEPAVU.js → fleet-4MUPHSF5.js} +4 -4
  203. package/dist/cli/chunks/{gnn-wrapper-KWZOWBYS.js → gnn-wrapper-PYOQZKX6.js} +2 -2
  204. package/dist/cli/chunks/{heartbeat-handler-3AGYHVG2.js → heartbeat-handler-HLO5XCG7.js} +4 -4
  205. package/dist/cli/chunks/heartbeat-scheduler-OSDPJT6A.js +2 -0
  206. package/dist/cli/chunks/hnsw-adapter-KMGSHBIN.js +2 -0
  207. package/dist/cli/chunks/hnsw-index-IMFRAOPE.js +2 -0
  208. package/dist/cli/chunks/{hnsw-legacy-bridge-6OJJDZHL.js → hnsw-legacy-bridge-FZEH2KLM.js} +2 -2
  209. package/dist/cli/chunks/{better-sqlite3-URULPKRF.js → hnswlib-node-VS6L5VUG.js} +2 -2
  210. package/dist/cli/chunks/{hooks-OXEBTLXV.js → hooks-R2757K57.js} +48 -52
  211. package/dist/cli/chunks/hybrid-router-57QSWSWC.js +2 -0
  212. package/dist/cli/chunks/{hypergraph-engine-NL74PRHD.js → hypergraph-engine-EAV3GJ5D.js} +2 -2
  213. package/dist/cli/chunks/{hypergraph-handler-KZ54AEEL.js → hypergraph-handler-5ERXAVGH.js} +3 -3
  214. package/dist/cli/chunks/impact-analyzer-OC4MPBGA.js +2 -0
  215. package/dist/cli/chunks/{init-handler-XKZXRXPG.js → init-handler-RXUSEMG7.js} +6 -6
  216. package/dist/cli/chunks/init-wizard-CDBRL4PO.js +2 -0
  217. package/dist/cli/chunks/kernel-CQ7R3AAV.js +2 -0
  218. package/dist/cli/chunks/{kilocode-installer-WISQMJK7.js → kilocode-installer-ZUBVBHGT.js} +2 -2
  219. package/dist/cli/chunks/{kiro-installer-O7TBB3GM.js → kiro-installer-TRTRQDGL.js} +2 -2
  220. package/dist/cli/chunks/knowledge-graph-UXNH7RY4.js +2 -0
  221. package/dist/cli/chunks/{learning-6IZBGVRU.js → learning-UYXWAU5D.js} +3 -3
  222. package/dist/cli/chunks/{llm-router-QDMQPPQ7.js → llm-router-TB5OJPEV.js} +4 -4
  223. package/dist/cli/chunks/llm-router-service-UV34YXBE.js +2 -0
  224. package/dist/cli/chunks/{load-KLAJJGL5.js → load-ELPSUIPV.js} +2 -2
  225. package/dist/cli/chunks/load-test-2VEN3PQZ.js +2 -0
  226. package/dist/cli/chunks/{mcp-SZOPQZIZ.js → mcp-UX7TK3XV.js} +2 -2
  227. package/dist/cli/chunks/{memory-G3WY74C6.js → memory-W3LG6H6N.js} +5 -5
  228. package/dist/cli/chunks/memory-backend-TZL5U6F3.js +2 -0
  229. package/dist/cli/chunks/memory-handlers-BNXAYS2P.js +2 -0
  230. package/dist/cli/chunks/{multi-model-executor-TDNQGTOT.js → multi-model-executor-227LWZRY.js} +2 -2
  231. package/dist/cli/chunks/{opencode-installer-NGYGEDMV.js → opencode-installer-F4WKVWDL.js} +2 -2
  232. package/dist/cli/chunks/{orchestrator-KPI5DY2C.js → orchestrator-V4DBMGK6.js} +5 -5
  233. package/dist/cli/chunks/pattern-null-store-KLX2RNHM.js +2 -0
  234. package/dist/cli/chunks/pattern-usage-recorder-BY3HEWSU.js +2 -0
  235. package/dist/cli/chunks/{pipeline-CSDCC675.js → pipeline-3F5RIESX.js} +2 -2
  236. package/dist/cli/chunks/{platform-Q5XKEVKH.js → platform-KCGXTZO3.js} +2 -2
  237. package/dist/cli/chunks/{plugin-XKKR3GVL.js → plugin-2H552KOV.js} +2 -2
  238. package/dist/cli/chunks/{prime-radiant-advanced-wasm-22QVNKEN.js → prime-radiant-advanced-wasm-EFKVL7VN.js} +2 -2
  239. package/dist/cli/chunks/protocol-executor-5HJKW6MC.js +2 -0
  240. package/dist/cli/chunks/{protocol-handler-REQKTJGG.js → protocol-handler-ELGYV7D2.js} +2 -2
  241. package/dist/cli/chunks/{prove-NOFUFSQN.js → prove-AYJCQYNI.js} +2 -2
  242. package/dist/cli/chunks/provider-manager-TRZSBXD3.js +2 -0
  243. package/dist/cli/chunks/qe-reasoning-bank-RCEYSLVV.js +2 -0
  244. package/dist/cli/chunks/{quality-3DQ2H5TK.js → quality-HH7L5A7V.js} +2 -2
  245. package/dist/cli/chunks/quality-gate-NAQLXE4C.js +7 -0
  246. package/dist/cli/chunks/queen-coordinator-6JFZD54W.js +2 -0
  247. package/dist/cli/chunks/{real-embeddings-FCGNYWLL.js → real-embeddings-IO3F4ZFR.js} +2 -2
  248. package/dist/cli/chunks/{roocode-installer-HX3CNRIR.js → roocode-installer-X4TU5HO4.js} +2 -2
  249. package/dist/cli/chunks/router-KRLC46NS.js +2 -0
  250. package/dist/cli/chunks/routing-feedback-WW26H6SA.js +2 -0
  251. package/dist/cli/chunks/{routing-handler-YRZ2LDCR.js → routing-handler-ZJKGDDMT.js} +2 -2
  252. package/dist/cli/chunks/{ruvector-commands-GCQVBJ4E.js → ruvector-commands-NXCSUBN2.js} +2 -2
  253. package/dist/cli/chunks/{rvf-dual-writer-B562P3ZC.js → rvf-dual-writer-JMA74SKP.js} +2 -2
  254. package/dist/cli/chunks/{rvf-migration-adapter-NAGFKCMD.js → rvf-migration-adapter-BNTGH2KU.js} +2 -2
  255. package/dist/cli/chunks/{rvf-migration-coordinator-WWFBEJ5Q.js → rvf-migration-coordinator-7T2HHUOH.js} +2 -2
  256. package/dist/cli/chunks/rvf-native-adapter-OVQKPQUH.js +2 -0
  257. package/dist/cli/chunks/safe-db-UQOCQIH2.js +2 -0
  258. package/dist/cli/chunks/schedule-EUX7ZQUK.js +2 -0
  259. package/dist/cli/chunks/scheduler-MALHQKNR.js +2 -0
  260. package/dist/cli/chunks/{security-IFOYTD75.js → security-XSK2QHB3.js} +3 -3
  261. package/dist/cli/chunks/{shared-rvf-adapter-TYD5TQ35.js → shared-rvf-adapter-WLRKI7RY.js} +2 -2
  262. package/dist/cli/chunks/{shared-rvf-dual-writer-YGOOVDQZ.js → shared-rvf-dual-writer-SZW3J7ZK.js} +2 -2
  263. package/dist/cli/chunks/sqlite-persistence-OBCLRP4L.js +2 -0
  264. package/dist/cli/chunks/status-handler-HGCKYJX2.js +46 -0
  265. package/dist/cli/chunks/{structural-health-KZI6YMKV.js → structural-health-4SJCFX63.js} +2 -2
  266. package/dist/cli/chunks/{sync-Z5BDDBMK.js → sync-7WAVNZGL.js} +2 -2
  267. package/dist/cli/chunks/{sync-ABZNNYRC.js → sync-ATR4DUSA.js} +2 -2
  268. package/dist/cli/chunks/{task-handler-5ACZEPJ7.js → task-handler-O6REL34Y.js} +2 -2
  269. package/dist/cli/chunks/{task-handlers-UZWDPL6A.js → task-handlers-WFV2ZYWW.js} +3 -3
  270. package/dist/cli/chunks/{test-APO3MCVV.js → test-4LXUVHEU.js} +4 -4
  271. package/dist/cli/chunks/{test-scheduling-EFZA5G5C.js → test-scheduling-OTN3DMKY.js} +3 -3
  272. package/dist/cli/chunks/{token-bootstrap-J2OPLNUK.js → token-bootstrap-VA7T4P42.js} +2 -2
  273. package/dist/cli/chunks/{token-usage-VHWVNN4R.js → token-usage-TLT6OXXR.js} +2 -2
  274. package/dist/cli/chunks/{transformers-PX4HPO75.js → transformers-JI7LZRQ3.js} +2 -2
  275. package/dist/cli/chunks/{tree-sitter-wasm-parser-44HA2Z3F.js → tree-sitter-wasm-parser-QNIMHB4K.js} +2 -2
  276. package/dist/cli/chunks/{types-IMOP7F4R.js → types-DJNWOAC6.js} +2 -2
  277. package/dist/cli/chunks/unified-memory-A5BS3LGX.js +2 -0
  278. package/dist/cli/chunks/unified-memory-hnsw-WJLJO5MY.js +2 -0
  279. package/dist/cli/chunks/unified-persistence-CFC2BKI5.js +2 -0
  280. package/dist/cli/chunks/{upgrade-OZ3O6ZZI.js → upgrade-VEW4FL23.js} +2 -2
  281. package/dist/cli/chunks/{validate-DRY5BMWX.js → validate-O3P6PF7B.js} +2 -2
  282. package/dist/cli/chunks/{validate-swarm-QD3LYPUF.js → validate-swarm-M2HXHZVC.js} +2 -2
  283. package/dist/cli/chunks/{vibium-2J3H2ITD.js → vibium-GOU55LUO.js} +2 -2
  284. package/dist/cli/chunks/visual-security-VPB6KVYJ.js +2 -0
  285. package/dist/cli/chunks/{web-tree-sitter-KRNUOGKI.js → web-tree-sitter-MXOI4GH3.js} +2 -2
  286. package/dist/cli/chunks/{windsurf-installer-PQIPH3WP.js → windsurf-installer-6GKT53IH.js} +2 -2
  287. package/dist/cli/chunks/{witness-chain-HPLOYPS7.js → witness-chain-OXGQGL26.js} +2 -2
  288. package/dist/cli/chunks/witness-chain-ZZAUAXDY.js +2 -0
  289. package/dist/cli/chunks/witness-key-manager-PGFSQXUJ.js +2 -0
  290. package/dist/cli/chunks/{workflow-OAQ3FWCY.js → workflow-ENBWRMBA.js} +4 -4
  291. package/dist/cli/chunks/workflow-orchestrator-S4LBFTYD.js +2 -0
  292. package/dist/cli/chunks/{wrappers-UPIU6S5S.js → wrappers-MHLNYANQ.js} +2 -2
  293. package/dist/cli/commands/audit.d.ts +12 -0
  294. package/dist/cli/commands/audit.js +64 -4
  295. package/dist/cli/commands/hooks-handlers/hooks-dream-learning.js +45 -19
  296. package/dist/cli/commands/hooks-handlers/hooks-shared.d.ts +13 -0
  297. package/dist/cli/commands/hooks-handlers/hooks-shared.js +38 -0
  298. package/dist/cli/commands/hooks-handlers/task-hooks.js +19 -1
  299. package/dist/cli/commands/quality-gate.d.ts +24 -0
  300. package/dist/cli/commands/quality-gate.js +135 -0
  301. package/dist/cli/handlers/status-handler.d.ts +18 -0
  302. package/dist/cli/handlers/status-handler.js +47 -0
  303. package/dist/cli/index.js +5 -0
  304. package/dist/coordination/mincut/dream-integration.d.ts +11 -0
  305. package/dist/coordination/mincut/dream-integration.js +39 -12
  306. package/dist/coordination/mincut/queen-integration.js +24 -7
  307. package/dist/coordination/protocol-executor.js +2 -1
  308. package/dist/coordination/queen-lifecycle.js +4 -1
  309. package/dist/domains/code-intelligence/coordinator.js +10 -6
  310. package/dist/domains/code-intelligence/services/product-factors-bridge.js +3 -1
  311. package/dist/domains/defect-intelligence/services/defect-predictor.d.ts +6 -0
  312. package/dist/domains/defect-intelligence/services/defect-predictor.js +21 -0
  313. package/dist/domains/learning-optimization/interfaces.d.ts +7 -0
  314. package/dist/domains/learning-optimization/plugin.js +5 -0
  315. package/dist/domains/learning-optimization/services/learning-coordinator.d.ts +10 -0
  316. package/dist/domains/learning-optimization/services/learning-coordinator.js +57 -0
  317. package/dist/domains/test-execution/plugin.js +2 -2
  318. package/dist/domains/test-execution/services/flaky-detector.js +1 -1
  319. package/dist/domains/test-generation/coordinator.js +22 -8
  320. package/dist/domains/test-generation/interfaces.d.ts +3 -0
  321. package/dist/domains/test-generation/services/test-generator.js +9 -1
  322. package/dist/integrations/ruvector/delta-tracker.js +10 -1
  323. package/dist/integrations/ruvector/feature-flags.js +7 -0
  324. package/dist/integrations/ruvector/sona-persistence.d.ts +24 -0
  325. package/dist/integrations/ruvector/sona-persistence.js +76 -0
  326. package/dist/integrations/ruvector/sona-three-loop.d.ts +15 -0
  327. package/dist/integrations/ruvector/sona-three-loop.js +17 -0
  328. package/dist/kernel/unified-memory-schemas.d.ts +2 -2
  329. package/dist/kernel/unified-memory-schemas.js +48 -2
  330. package/dist/kernel/unified-memory.d.ts +22 -0
  331. package/dist/kernel/unified-memory.js +43 -0
  332. package/dist/learning/aqe-learning-engine.js +3 -1
  333. package/dist/learning/dream/concept-graph.d.ts +31 -1
  334. package/dist/learning/dream/concept-graph.js +109 -3
  335. package/dist/learning/dream/dream-engine.d.ts +13 -1
  336. package/dist/learning/dream/dream-engine.js +146 -10
  337. package/dist/learning/dream/index.d.ts +1 -1
  338. package/dist/learning/dream/types.d.ts +23 -0
  339. package/dist/learning/pattern-lifecycle.d.ts +16 -0
  340. package/dist/learning/pattern-lifecycle.js +77 -1
  341. package/dist/learning/pattern-store.d.ts +2 -2
  342. package/dist/learning/pattern-store.js +14 -3
  343. package/dist/learning/provenance-tier.d.ts +52 -0
  344. package/dist/learning/provenance-tier.js +64 -0
  345. package/dist/learning/qe-flywheel/corpus-scorer.d.ts +55 -0
  346. package/dist/learning/qe-flywheel/corpus-scorer.js +293 -0
  347. package/dist/learning/qe-flywheel/coupled-anchor.d.ts +91 -0
  348. package/dist/learning/qe-flywheel/coupled-anchor.js +181 -0
  349. package/dist/learning/qe-flywheel/generation.d.ts +121 -0
  350. package/dist/learning/qe-flywheel/generation.js +167 -0
  351. package/dist/learning/qe-flywheel/policy.d.ts +37 -0
  352. package/dist/learning/qe-flywheel/policy.js +66 -0
  353. package/dist/learning/qe-flywheel/receipt-store.d.ts +31 -0
  354. package/dist/learning/qe-flywheel/receipt-store.js +89 -0
  355. package/dist/learning/qe-flywheel/receipt.d.ts +62 -0
  356. package/dist/learning/qe-flywheel/receipt.js +97 -0
  357. package/dist/learning/qe-reasoning-bank.js +34 -31
  358. package/dist/learning/routing-topology-gate.d.ts +12 -2
  359. package/dist/learning/routing-topology-gate.js +15 -3
  360. package/dist/learning/rvf-pattern-store.d.ts +1 -1
  361. package/dist/learning/rvf-pattern-store.js +21 -8
  362. package/dist/learning/sqlite-persistence.js +12 -9
  363. package/dist/mcp/bundle.js +540 -460
  364. package/dist/mcp/qe-tool-bridge.js +7 -2
  365. package/dist/mcp/tools/base.d.ts +29 -0
  366. package/dist/mcp/tools/base.js +25 -0
  367. package/dist/mcp/tools/coverage-analysis/index.js +6 -4
  368. package/dist/mcp/tools/learning-optimization/dream.d.ts +4 -13
  369. package/dist/mcp/tools/learning-optimization/dream.js +10 -96
  370. package/dist/mcp/tools/planning/goap-execute.d.ts +13 -1
  371. package/dist/mcp/tools/planning/goap-execute.js +33 -18
  372. package/dist/mcp/tools/quality-assessment/gate.d.ts +38 -0
  373. package/dist/mcp/tools/quality-assessment/gate.js +86 -0
  374. package/dist/mcp/tools/registry.d.ts +1 -0
  375. package/dist/mcp/tools/registry.js +10 -2
  376. package/dist/persistence/rvf-migration-coordinator.js +2 -1
  377. package/dist/planning/actions/qe-action-library.js +124 -1
  378. package/dist/planning/goap-planner.d.ts +14 -2
  379. package/dist/planning/goap-planner.js +51 -9
  380. package/dist/planning/index.d.ts +1 -1
  381. package/dist/planning/plan-executor.d.ts +84 -4
  382. package/dist/planning/plan-executor.js +221 -56
  383. package/dist/planning/types.d.ts +27 -0
  384. package/dist/shared/events/domain-events.d.ts +2 -0
  385. package/dist/shared/safe-db.js +23 -4
  386. package/dist/validation/anchor-set.d.ts +74 -0
  387. package/dist/validation/anchor-set.js +78 -0
  388. package/dist/validation/frontier-judge.d.ts +99 -0
  389. package/dist/validation/frontier-judge.js +234 -0
  390. package/dist/validation/gate-reexecute.d.ts +165 -0
  391. package/dist/validation/gate-reexecute.js +255 -0
  392. package/dist/validation/quality-gate-runner.d.ts +49 -0
  393. package/dist/validation/quality-gate-runner.js +62 -0
  394. package/dist/validation/quality-verdict.d.ts +94 -0
  395. package/dist/validation/quality-verdict.js +120 -0
  396. package/dist/workers/workers/learning-consolidation.js +21 -1
  397. package/package.json +1 -1
  398. package/dist/cli/chunks/adapter-2HMUXHWY.js +0 -2
  399. package/dist/cli/chunks/aqe-learning-engine-M2NKRVRE.js +0 -2
  400. package/dist/cli/chunks/audit-EPB7ETMT.js +0 -3
  401. package/dist/cli/chunks/base-CCHC2DAC.js +0 -2
  402. package/dist/cli/chunks/brain-handler-FBMYEERK.js +0 -89
  403. package/dist/cli/chunks/browser-workflow-4DGHFYY3.js +0 -2
  404. package/dist/cli/chunks/chunk-37ZDGJ3H.js +0 -2
  405. package/dist/cli/chunks/chunk-5AQ7FXYG.js +0 -27
  406. package/dist/cli/chunks/chunk-KYTFIP6R.js +0 -2
  407. package/dist/cli/chunks/chunk-MYMIEQSZ.js +0 -65
  408. package/dist/cli/chunks/chunk-RCPD6F4R.js +0 -2
  409. package/dist/cli/chunks/chunk-TCWR6TDN.js +0 -2
  410. package/dist/cli/chunks/chunk-UQ72K44T.js +0 -149
  411. package/dist/cli/chunks/chunk-XXRTWG7O.js +0 -2
  412. package/dist/cli/chunks/chunk-ZSA6V5FH.js +0 -2
  413. package/dist/cli/chunks/client-2OVEDWGU.js +0 -2
  414. package/dist/cli/chunks/core-handlers-UXRRYP52.js +0 -2
  415. package/dist/cli/chunks/cross-domain-router-PV3VQVLO.js +0 -2
  416. package/dist/cli/chunks/daemon-ESUEM6VB.js +0 -10
  417. package/dist/cli/chunks/domain-transfer-TQYO3SVG.js +0 -2
  418. package/dist/cli/chunks/dream-UFUXVJQC.js +0 -2
  419. package/dist/cli/chunks/heartbeat-scheduler-MBG3SARO.js +0 -2
  420. package/dist/cli/chunks/hnsw-adapter-5HXA3QB3.js +0 -2
  421. package/dist/cli/chunks/hnsw-index-PZRQWBRG.js +0 -2
  422. package/dist/cli/chunks/hybrid-router-NQRIE2GG.js +0 -2
  423. package/dist/cli/chunks/impact-analyzer-46347ZDV.js +0 -2
  424. package/dist/cli/chunks/init-wizard-CJYP4WKO.js +0 -2
  425. package/dist/cli/chunks/kernel-22KQZ56U.js +0 -2
  426. package/dist/cli/chunks/knowledge-graph-KM3JDBGR.js +0 -2
  427. package/dist/cli/chunks/llm-router-service-IFO6GRRO.js +0 -2
  428. package/dist/cli/chunks/load-test-TTKCYAPB.js +0 -2
  429. package/dist/cli/chunks/memory-backend-ELHCX2ZT.js +0 -2
  430. package/dist/cli/chunks/memory-handlers-3SKYQZTL.js +0 -2
  431. package/dist/cli/chunks/pattern-null-store-TMXAYD43.js +0 -2
  432. package/dist/cli/chunks/protocol-executor-BPLR5EJC.js +0 -2
  433. package/dist/cli/chunks/provider-manager-4MMD5QKL.js +0 -2
  434. package/dist/cli/chunks/qe-reasoning-bank-P7KNT3WZ.js +0 -2
  435. package/dist/cli/chunks/queen-coordinator-NBZZ4MGC.js +0 -2
  436. package/dist/cli/chunks/router-2RXR6J2Q.js +0 -2
  437. package/dist/cli/chunks/routing-feedback-AVAA76TK.js +0 -2
  438. package/dist/cli/chunks/rvf-native-adapter-X2YDJA55.js +0 -2
  439. package/dist/cli/chunks/safe-db-4PRU65BK.js +0 -2
  440. package/dist/cli/chunks/schedule-2AST5CHW.js +0 -2
  441. package/dist/cli/chunks/scheduler-SW6II7OU.js +0 -2
  442. package/dist/cli/chunks/sqlite-persistence-OB5NEGAK.js +0 -2
  443. package/dist/cli/chunks/status-handler-HFPWSCBY.js +0 -45
  444. package/dist/cli/chunks/unified-memory-X7OJYGSD.js +0 -2
  445. package/dist/cli/chunks/unified-memory-hnsw-O6HOD5YL.js +0 -2
  446. package/dist/cli/chunks/unified-persistence-C332CER2.js +0 -2
  447. package/dist/cli/chunks/visual-security-MPUG5HPI.js +0 -2
  448. package/dist/cli/chunks/witness-chain-Q4BZHPDF.js +0 -2
  449. package/dist/cli/chunks/workflow-orchestrator-4NDWECYK.js +0 -2
@@ -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
  */
@@ -37,6 +37,12 @@ export interface PatternLifecycleConfig {
37
37
  promotionActivityWindowDays: number;
38
38
  /** ADR-061: Asymmetric learning config */
39
39
  asymmetricLearning: Partial<AsymmetricLearningConfig>;
40
+ /**
41
+ * ADR-121: allow `judge:llm`-tier evidence to promote patterns. A single LLM
42
+ * judgment is noisy (ADR-119), so judge-tier promotion is an explicit,
43
+ * cost-bearing opt-in. Default false — only `oracle:test-exec` promotes.
44
+ */
45
+ allowJudgeTierPromotion: boolean;
40
46
  }
41
47
  /**
42
48
  * Default lifecycle configuration
@@ -103,6 +109,10 @@ export interface PromotionCheckResult {
103
109
  currentReward: number;
104
110
  currentOccurrences: number;
105
111
  currentSuccessRate: number;
112
+ /** ADR-121: evidence tier of the pattern (gates promotion). */
113
+ provenanceTier: string;
114
+ /** ADR-121: whether the pattern's evidence tier is strong enough to promote. */
115
+ meetsProvenanceTier: boolean;
106
116
  }
107
117
  /**
108
118
  * Result of deprecation check
@@ -178,6 +188,12 @@ export declare class PatternLifecycleManager {
178
188
  * Generate template content from experience aggregate
179
189
  */
180
190
  private generateTemplateContent;
191
+ /**
192
+ * ADR-121: read a pattern's provenance tier. Tolerant of an un-migrated DB
193
+ * (column absent) and of a NULL/unknown value — both degrade to the
194
+ * conservative default so the gate can never be bypassed by a missing tier.
195
+ */
196
+ private getProvenanceTier;
181
197
  /**
182
198
  * Check if a pattern should be promoted
183
199
  */
@@ -11,6 +11,8 @@
11
11
  import { PROMOTION_THRESHOLD } from './qe-patterns.js';
12
12
  import { AsymmetricLearningEngine } from './asymmetric-learning.js';
13
13
  import { safeJsonParse } from '../shared/safe-json.js';
14
+ import { tierAllowsPromotion, DEFAULT_PROVENANCE_TIER } from './provenance-tier.js';
15
+ import { reExecutePathGate, pathGateFingerprint, pathSealedHash, verifyPathPromotion, } from '../validation/gate-reexecute.js';
14
16
  import { LoggerFactory } from '../logging/index.js';
15
17
  import { isTemporalCompressionEnabled } from '../integrations/ruvector/feature-flags.js';
16
18
  const logger = LoggerFactory.create('pattern-lifecycle');
@@ -28,6 +30,7 @@ export const DEFAULT_LIFECYCLE_CONFIG = {
28
30
  maxAgeForActivePatterns: 90,
29
31
  promotionActivityWindowDays: 30,
30
32
  asymmetricLearning: {},
33
+ allowJudgeTierPromotion: false,
31
34
  };
32
35
  // ============================================================================
33
36
  // EWC++ catastrophic-forgetting protection (#510 item 6)
@@ -143,6 +146,23 @@ export class PatternLifecycleManager {
143
146
  `);
144
147
  console.log('[PatternLifecycle] Added promotion_date column to qe_patterns');
145
148
  }
149
+ // ADR-121: provenance_tier — additive, conservative-default migration.
150
+ // The DEFAULT backfills every existing row as 'proxy:structural', which can
151
+ // never over-credit legacy history. Rows re-derived from execution evidence
152
+ // are re-tiered upward through the normal write path (never up-tiered here).
153
+ // Distinct from the lifecycle `tier` (short-term/long-term) column.
154
+ try {
155
+ this.db.prepare(`
156
+ SELECT provenance_tier FROM qe_patterns LIMIT 1
157
+ `).get();
158
+ }
159
+ catch (e) {
160
+ logger.debug('Adding missing provenance_tier column', { error: e instanceof Error ? e.message : String(e) });
161
+ this.db.exec(`
162
+ ALTER TABLE qe_patterns ADD COLUMN provenance_tier TEXT DEFAULT '${DEFAULT_PROVENANCE_TIER}'
163
+ `);
164
+ console.log(`[PatternLifecycle] Added provenance_tier column to qe_patterns (backfilled '${DEFAULT_PROVENANCE_TIER}')`);
165
+ }
146
166
  }
147
167
  // ============================================================================
148
168
  // Experience Extraction
@@ -344,6 +364,20 @@ Pattern extracted from ${exp.count} successful experiences.`;
344
364
  // ============================================================================
345
365
  // Pattern Promotion
346
366
  // ============================================================================
367
+ /**
368
+ * ADR-121: read a pattern's provenance tier. Tolerant of an un-migrated DB
369
+ * (column absent) and of a NULL/unknown value — both degrade to the
370
+ * conservative default so the gate can never be bypassed by a missing tier.
371
+ */
372
+ getProvenanceTier(patternId) {
373
+ try {
374
+ const row = this.db.prepare(`SELECT provenance_tier FROM qe_patterns WHERE id = ?`).get(patternId);
375
+ return row?.provenance_tier ?? DEFAULT_PROVENANCE_TIER;
376
+ }
377
+ catch {
378
+ return DEFAULT_PROVENANCE_TIER;
379
+ }
380
+ }
347
381
  /**
348
382
  * Check if a pattern should be promoted
349
383
  */
@@ -359,23 +393,35 @@ Pattern extracted from ${exp.count} successful experiences.`;
359
393
  currentReward: 0,
360
394
  currentOccurrences: 0,
361
395
  currentSuccessRate: 0,
396
+ provenanceTier: DEFAULT_PROVENANCE_TIER,
397
+ meetsProvenanceTier: false,
362
398
  };
363
399
  }
364
400
  const avgReward = pattern.qualityScore;
365
401
  const meetsReward = avgReward >= this.config.promotionRewardThreshold;
366
402
  const meetsOccurrences = pattern.usageCount >= this.config.promotionMinOccurrences;
367
403
  const meetsSuccessRate = pattern.successRate >= this.config.promotionMinSuccessRate;
404
+ // ADR-121: evidence-tier gate. Only oracle:test-exec (or judge:llm under an
405
+ // explicit budget flag) may promote; proxy:structural is never auto-promoted.
406
+ // Read the tier directly — the column is additive and may be absent on an
407
+ // un-migrated DB, in which case it defaults to the conservative tier.
408
+ const provenanceTier = this.getProvenanceTier(patternId);
409
+ const meetsProvenanceTier = tierAllowsPromotion(provenanceTier, {
410
+ allowJudgeTier: this.config.allowJudgeTierPromotion,
411
+ });
368
412
  // Temporal window: require activity within configured window to prevent
369
413
  // promoting stale patterns that haven't been validated recently
370
414
  const PROMOTION_ACTIVITY_WINDOW_MS = this.config.promotionActivityWindowDays * 24 * 60 * 60 * 1000;
371
415
  const lastActivity = pattern.lastUsedAt?.getTime() ?? pattern.createdAt.getTime();
372
416
  const meetsActivityWindow = (Date.now() - lastActivity) < PROMOTION_ACTIVITY_WINDOW_MS;
373
417
  return {
374
- shouldPromote: pattern.tier === 'short-term' && meetsReward && meetsOccurrences && meetsSuccessRate && meetsActivityWindow,
418
+ shouldPromote: pattern.tier === 'short-term' && meetsProvenanceTier && meetsReward && meetsOccurrences && meetsSuccessRate && meetsActivityWindow,
375
419
  meetsRewardThreshold: meetsReward,
376
420
  meetsOccurrenceThreshold: meetsOccurrences,
377
421
  meetsSuccessRateThreshold: meetsSuccessRate,
378
422
  meetsActivityWindow,
423
+ provenanceTier,
424
+ meetsProvenanceTier,
379
425
  currentReward: avgReward,
380
426
  currentOccurrences: pattern.usageCount,
381
427
  currentSuccessRate: pattern.successRate,
@@ -389,6 +435,36 @@ Pattern extracted from ${exp.count} successful experiences.`;
389
435
  if (!check.shouldPromote) {
390
436
  return false;
391
437
  }
438
+ // ADR-120: re-execute the frozen `pattern-promote/v1` rule on the sealed
439
+ // check result before writing. `checkPromotion` is advisory; the frozen
440
+ // rule is authoritative. A forged/stale promote (proxy-tier or sub-threshold
441
+ // inputs logged as `promote`) fails `verifyPathPromotion` and the UPDATE is
442
+ // skipped — the same defense the flywheel accept path gets (ADR-120 §5).
443
+ const sealed = {
444
+ provenanceTier: check.provenanceTier,
445
+ allowJudgeTier: this.config.allowJudgeTierPromotion,
446
+ reward: check.currentReward,
447
+ rewardThreshold: this.config.promotionRewardThreshold,
448
+ occurrences: check.currentOccurrences,
449
+ occurrenceThreshold: this.config.promotionMinOccurrences,
450
+ successRate: check.currentSuccessRate,
451
+ successRateThreshold: this.config.promotionMinSuccessRate,
452
+ withinActivityWindow: check.meetsActivityWindow,
453
+ };
454
+ const rerun = reExecutePathGate('pattern-promote/v1', sealed);
455
+ const receipt = {
456
+ ruleVersion: 'pattern-promote/v1',
457
+ ruleFingerprint: pathGateFingerprint('pattern-promote/v1'),
458
+ sealedHash: pathSealedHash(sealed),
459
+ sealed,
460
+ recordedVerdict: rerun.promote ? 'promote' : 'reject',
461
+ };
462
+ const verdict = verifyPathPromotion(receipt);
463
+ if (!verdict.valid || !rerun.promote) {
464
+ // The advisory verdict is not reproducible under the frozen rule — refuse.
465
+ console.warn(`[PatternLifecycle] Refusing to promote ${patternId}: ${rerun.reason} (${verdict.reason})`);
466
+ return false;
467
+ }
392
468
  this.db.prepare(`
393
469
  UPDATE qe_patterns
394
470
  SET tier = 'long-term',
@@ -175,7 +175,7 @@ export interface IPatternStore {
175
175
  /** Search for patterns */
176
176
  search(query: string | number[], options?: PatternSearchOptions): Promise<Result<PatternSearchResult[]>>;
177
177
  /** Update pattern after use */
178
- recordUsage(id: string, success: boolean): Promise<Result<void>>;
178
+ recordUsage(id: string, success: boolean, metrics?: Record<string, unknown>, feedback?: string): Promise<Result<void>>;
179
179
  /** Promote pattern from short-term to long-term */
180
180
  promote(id: string): Promise<Result<void>>;
181
181
  /** Delete a pattern */
@@ -315,7 +315,7 @@ export declare class PatternStore implements IPatternStore {
315
315
  /**
316
316
  * Record pattern usage and update stats
317
317
  */
318
- recordUsage(id: string, success: boolean): Promise<Result<void>>;
318
+ recordUsage(id: string, success: boolean, metrics?: Record<string, unknown>, feedback?: string): Promise<Result<void>>;
319
319
  /**
320
320
  * Promote pattern from short-term to long-term storage
321
321
  */