agentic-qe 3.9.30 → 3.9.31

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 (326) hide show
  1. package/.claude/skills/skills-manifest.json +1 -1
  2. package/CHANGELOG.md +120 -0
  3. package/assets/skills/skills-manifest.json +1 -1
  4. package/dist/bridge/captured-experience-bridge.js +31 -2
  5. package/dist/cli/bundle.js +5 -5
  6. package/dist/cli/chunks/adapter-CI2GZYME.js +2 -0
  7. package/dist/cli/chunks/{agent-booster-wasm-TOSXWTUQ.js → agent-booster-wasm-AQXZYWZY.js} +2 -2
  8. package/dist/cli/chunks/{agent-handler-2BU6TYZZ.js → agent-handler-7N4ZPXCY.js} +2 -2
  9. package/dist/cli/chunks/{agent-memory-branch-JFG3BXZY.js → agent-memory-branch-FLKF2JVX.js} +2 -2
  10. package/dist/cli/chunks/aqe-learning-engine-KNQKALLI.js +2 -0
  11. package/dist/cli/chunks/{audit-4IGZZKUW.js → audit-B4V4IKTA.js} +2 -2
  12. package/dist/cli/chunks/base-P7PRMQWY.js +2 -0
  13. package/dist/cli/chunks/{hnswlib-node-STKRZIU3.js → better-sqlite3-NYOVLWBG.js} +2 -2
  14. package/dist/cli/chunks/{brain-handler-RIDW27HH.js → brain-handler-OOXJ2KYY.js} +4 -4
  15. package/dist/cli/chunks/{branch-enumerator-GMYHLLWD.js → branch-enumerator-LFKFW3A4.js} +2 -2
  16. package/dist/cli/chunks/{browser-N76A3I2P.js → browser-F72IES2I.js} +2 -2
  17. package/dist/cli/chunks/browser-workflow-QUP4A763.js +2 -0
  18. package/dist/cli/chunks/{chunk-JCDEMPJS.js → chunk-2NLZXG6V.js} +1 -1
  19. package/dist/cli/chunks/{chunk-ETEHVG76.js → chunk-35SFAIXE.js} +2 -2
  20. package/dist/cli/chunks/{chunk-FG5GL26L.js → chunk-3VKB4HVT.js} +2 -2
  21. package/dist/cli/chunks/{chunk-XKH4E2IQ.js → chunk-462MZLJB.js} +1 -1
  22. package/dist/cli/chunks/{chunk-MZ7M2CDV.js → chunk-47QIAHUJ.js} +2 -2
  23. package/dist/cli/chunks/{chunk-IP6ZTXNJ.js → chunk-4N736EES.js} +2 -2
  24. package/dist/cli/chunks/{chunk-YXR5RYRE.js → chunk-52D3CYE5.js} +2 -2
  25. package/dist/cli/chunks/{chunk-C6TNYLD7.js → chunk-5AMAJCZS.js} +3 -3
  26. package/dist/cli/chunks/{chunk-ZKZTSYPU.js → chunk-5G2L4XRU.js} +2 -2
  27. package/dist/cli/chunks/{chunk-2MKSEL6F.js → chunk-5M4F3PAL.js} +1 -1
  28. package/dist/cli/chunks/{chunk-37I6K7QO.js → chunk-5WWQLPB4.js} +2 -2
  29. package/dist/cli/chunks/chunk-5Z6PYYWK.js +2 -0
  30. package/dist/cli/chunks/{chunk-MHPK4ZPK.js → chunk-62KYX5NH.js} +2 -2
  31. package/dist/cli/chunks/{chunk-TYZGEVP6.js → chunk-7MXQV7RB.js} +12 -6
  32. package/dist/cli/chunks/{chunk-XVTZXCHI.js → chunk-7OVVBBOZ.js} +2 -2
  33. package/dist/cli/chunks/{chunk-MOLOWMON.js → chunk-7RPEBKQZ.js} +2 -2
  34. package/dist/cli/chunks/{chunk-5F26LSG2.js → chunk-7UHRT5AX.js} +2 -2
  35. package/dist/cli/chunks/{chunk-MV3NUANS.js → chunk-7V7TP242.js} +1 -1
  36. package/dist/cli/chunks/{chunk-WTXRPYNN.js → chunk-A424Z7LA.js} +1 -1
  37. package/dist/cli/chunks/{chunk-UYLHIGNC.js → chunk-AKFRM4IO.js} +2 -2
  38. package/dist/cli/chunks/{chunk-OEGFOMXP.js → chunk-AKJWBJDK.js} +2 -2
  39. package/dist/cli/chunks/{chunk-2GBBZLXT.js → chunk-AQN6PDHI.js} +1 -1
  40. package/dist/cli/chunks/{chunk-ITBPDVK5.js → chunk-BMS7WFDB.js} +1 -1
  41. package/dist/cli/chunks/{chunk-2O5TT3UT.js → chunk-BYHUGO73.js} +3 -3
  42. package/dist/cli/chunks/{chunk-CNNVL5W4.js → chunk-CFLA2GBS.js} +2 -2
  43. package/dist/cli/chunks/{chunk-Y57V4FDT.js → chunk-CNKOIHF6.js} +2 -2
  44. package/dist/cli/chunks/{chunk-3EP2YZSY.js → chunk-CQWZNVIM.js} +2 -2
  45. package/dist/cli/chunks/{chunk-GEXVUFK4.js → chunk-CUSLB7MB.js} +2 -2
  46. package/dist/cli/chunks/chunk-CYUGE5ZQ.js +2 -0
  47. package/dist/cli/chunks/{chunk-QNSUPXUU.js → chunk-DMF4Z2M6.js} +2 -2
  48. package/dist/cli/chunks/{chunk-Z3TXQOS7.js → chunk-DUF733Z7.js} +1 -1
  49. package/dist/cli/chunks/{chunk-XK6YXCS7.js → chunk-EAIPJSKH.js} +2 -2
  50. package/dist/cli/chunks/{chunk-TULNR2AH.js → chunk-EJXRBAQF.js} +2 -2
  51. package/dist/cli/chunks/{chunk-XDYTQPJM.js → chunk-EKYPQ5DX.js} +1 -1
  52. package/dist/cli/chunks/{chunk-QBDXUI2H.js → chunk-ENCFLC44.js} +2 -2
  53. package/dist/cli/chunks/{chunk-SAVITYEX.js → chunk-FOAWHNOP.js} +2 -2
  54. package/dist/cli/chunks/{chunk-QOJ7EAF5.js → chunk-FUHPLXJX.js} +1 -1
  55. package/dist/cli/chunks/{chunk-KR2PGNXX.js → chunk-G2U7Q6V6.js} +2 -2
  56. package/dist/cli/chunks/{chunk-DDMFTEJP.js → chunk-G3YKCZWQ.js} +3 -3
  57. package/dist/cli/chunks/{chunk-YETPSL6H.js → chunk-GJSH4UZ3.js} +3 -3
  58. package/dist/cli/chunks/{chunk-BQLFOJ5G.js → chunk-GN7FUCJH.js} +1 -1
  59. package/dist/cli/chunks/{chunk-GY4EGQO3.js → chunk-GQFAVT2I.js} +1 -1
  60. package/dist/cli/chunks/{chunk-IHRFR5SV.js → chunk-HHEIQHLQ.js} +2 -2
  61. package/dist/cli/chunks/{chunk-YKFURJNP.js → chunk-I3TFGMOQ.js} +1 -1
  62. package/dist/cli/chunks/{chunk-LDGNVPBZ.js → chunk-IRRGUXAU.js} +1 -1
  63. package/dist/cli/chunks/{chunk-IWC6GR24.js → chunk-IY4P35N3.js} +2 -2
  64. package/dist/cli/chunks/{chunk-AWWD3EI3.js → chunk-JF3U456G.js} +2 -2
  65. package/dist/cli/chunks/{chunk-5E3YCZC5.js → chunk-JJRZOLDY.js} +2 -2
  66. package/dist/cli/chunks/{chunk-Q53UMLLC.js → chunk-JKKV5KKS.js} +2 -2
  67. package/dist/cli/chunks/{chunk-MYF7F3ZP.js → chunk-JMLOEW7Y.js} +2 -2
  68. package/dist/cli/chunks/chunk-JRIDPOEZ.js +95 -0
  69. package/dist/cli/chunks/{chunk-T2DIMSQF.js → chunk-K37CNLQZ.js} +1 -1
  70. package/dist/cli/chunks/{chunk-RNO6CE7I.js → chunk-K6MFAVXK.js} +2 -2
  71. package/dist/cli/chunks/{chunk-UWWX4RK7.js → chunk-KJAIE7SL.js} +4 -4
  72. package/dist/cli/chunks/{chunk-ND6VCNN5.js → chunk-KXRDQQGN.js} +2 -2
  73. package/dist/cli/chunks/{chunk-GRPEDIYG.js → chunk-L4JTTPU7.js} +2 -2
  74. package/dist/cli/chunks/{chunk-BM73MJLE.js → chunk-L63KB63A.js} +2 -2
  75. package/dist/cli/chunks/{chunk-R57J3O6I.js → chunk-L7DNPOAQ.js} +2 -2
  76. package/dist/cli/chunks/{chunk-SJCEPKZO.js → chunk-LF5RO6WO.js} +1 -1
  77. package/dist/cli/chunks/{chunk-GZ3U2QT2.js → chunk-LRWRFKQH.js} +1 -1
  78. package/dist/cli/chunks/{chunk-QTS2DS42.js → chunk-M6RVKGIP.js} +2 -2
  79. package/dist/cli/chunks/{chunk-ECX6VXMW.js → chunk-MAJ5QFVY.js} +1 -1
  80. package/dist/cli/chunks/chunk-MYCVU3D3.js +14 -0
  81. package/dist/cli/chunks/{chunk-3AICELMQ.js → chunk-N6P7ENG7.js} +2 -2
  82. package/dist/cli/chunks/{chunk-7D2DM23U.js → chunk-N6SIKSCO.js} +2 -2
  83. package/dist/cli/chunks/{chunk-FI4HRS2G.js → chunk-NBKM7NKX.js} +2 -2
  84. package/dist/cli/chunks/{chunk-QSV4ROZD.js → chunk-NLUBN642.js} +2 -2
  85. package/dist/cli/chunks/{chunk-FGDEM4HU.js → chunk-NNF3GCGF.js} +2 -2
  86. package/dist/cli/chunks/{chunk-5DJAJPBG.js → chunk-NTVJKQ5S.js} +2 -2
  87. package/dist/cli/chunks/{chunk-3WIU2E2Y.js → chunk-NZQYNUGM.js} +2 -2
  88. package/dist/cli/chunks/{chunk-52TRKIAQ.js → chunk-ONMJJ2C3.js} +1 -1
  89. package/dist/cli/chunks/{chunk-JNRRDG7O.js → chunk-OXOXNAEZ.js} +2 -2
  90. package/dist/cli/chunks/chunk-PSF6YQQM.js +180 -0
  91. package/dist/cli/chunks/{chunk-WP6X67YI.js → chunk-PTOTOBOU.js} +1 -1
  92. package/dist/cli/chunks/{chunk-UEXOMDRS.js → chunk-PUSZ4NBY.js} +2 -2
  93. package/dist/cli/chunks/chunk-PYYNY7RJ.js +2 -0
  94. package/dist/cli/chunks/{chunk-L7X3A36M.js → chunk-QEJBJST4.js} +1 -1
  95. package/dist/cli/chunks/{chunk-TA3QYAZ6.js → chunk-QGLWFZVQ.js} +2 -2
  96. package/dist/cli/chunks/{chunk-HB52S6IV.js → chunk-QITO7E7Y.js} +1 -1
  97. package/dist/cli/chunks/{chunk-KJZXBZQR.js → chunk-QMSDKKYG.js} +1 -1
  98. package/dist/cli/chunks/{chunk-AQJ6XS34.js → chunk-RBDAHW2M.js} +2 -2
  99. package/dist/cli/chunks/{chunk-VOBNJWZF.js → chunk-RDJWUKIR.js} +2 -2
  100. package/dist/cli/chunks/{chunk-EWNJ6OAT.js → chunk-REJEFTWX.js} +1 -1
  101. package/dist/cli/chunks/{chunk-H27XUYWZ.js → chunk-ROEIR3OD.js} +1 -1
  102. package/dist/cli/chunks/{chunk-JCWHX4XV.js → chunk-RTGNWRQI.js} +2 -2
  103. package/dist/cli/chunks/{chunk-FU74OETU.js → chunk-SL4TAJOE.js} +2 -2
  104. package/dist/cli/chunks/{chunk-3PZDXE5E.js → chunk-T4DDCMKG.js} +113 -113
  105. package/dist/cli/chunks/{chunk-UROPIIB2.js → chunk-TJGIIGKL.js} +2 -2
  106. package/dist/cli/chunks/{chunk-BFJLKG3D.js → chunk-TLCCM2AF.js} +1 -1
  107. package/dist/cli/chunks/{chunk-HJDHQBMJ.js → chunk-TVHWI77X.js} +1 -1
  108. package/dist/cli/chunks/{chunk-ER6BT4GS.js → chunk-TYUIQSSF.js} +2 -2
  109. package/dist/cli/chunks/{chunk-R5IW5ARI.js → chunk-UIIEZMSM.js} +1 -1
  110. package/dist/cli/chunks/{chunk-NMBHF7ZD.js → chunk-UIRTXM7C.js} +15 -15
  111. package/dist/cli/chunks/{chunk-RYMHYTOK.js → chunk-UNXUSYRL.js} +3 -3
  112. package/dist/cli/chunks/chunk-VA45HLBF.js +2 -0
  113. package/dist/cli/chunks/{chunk-DEDFPHJL.js → chunk-VAIOZDG5.js} +1 -1
  114. package/dist/cli/chunks/{chunk-IEGAEXQX.js → chunk-VLAGWLHF.js} +2 -2
  115. package/dist/cli/chunks/{chunk-WVODEWH5.js → chunk-VOOJDHLI.js} +14 -8
  116. package/dist/cli/chunks/{chunk-IOINZWNA.js → chunk-VSKABN3B.js} +29 -17
  117. package/dist/cli/chunks/{chunk-HQIWLMDS.js → chunk-VUL5HIKR.js} +2 -2
  118. package/dist/cli/chunks/{chunk-OOFWYDG6.js → chunk-W7XVEWKQ.js} +1 -1
  119. package/dist/cli/chunks/{chunk-Q4HJRYQB.js → chunk-WB6TI6Q3.js} +2 -2
  120. package/dist/cli/chunks/{chunk-DJRWVNHK.js → chunk-X2FLWV5C.js} +2 -2
  121. package/dist/cli/chunks/{chunk-QLNS6DGB.js → chunk-XE4YKDIM.js} +2 -2
  122. package/dist/cli/chunks/{chunk-6EP3GHED.js → chunk-XGBIXRKD.js} +2 -2
  123. package/dist/cli/chunks/{chunk-AUNNGKLN.js → chunk-XMMWYQJK.js} +2 -2
  124. package/dist/cli/chunks/{chunk-FGMHVSLV.js → chunk-XNJ6DIEW.js} +2 -2
  125. package/dist/cli/chunks/{chunk-4UZQSPR4.js → chunk-XTWYCMAM.js} +2 -2
  126. package/dist/cli/chunks/{chunk-2NFGUFYU.js → chunk-XY3WUGD3.js} +2 -2
  127. package/dist/cli/chunks/{chunk-VRP4GB4Y.js → chunk-YEZJE2ZW.js} +4 -4
  128. package/dist/cli/chunks/{chunk-MCXRS2TZ.js → chunk-YLEMSN46.js} +1 -1
  129. package/dist/cli/chunks/{chunk-Q26GG6WO.js → chunk-YMN4C32S.js} +3 -3
  130. package/dist/cli/chunks/{chunk-HA7N45KB.js → chunk-YN7HCVUP.js} +2 -2
  131. package/dist/cli/chunks/{chunk-E7UHOKKL.js → chunk-YQJBE6NX.js} +2 -2
  132. package/dist/cli/chunks/{chunk-OTFJCZNY.js → chunk-ZBJRNCWX.js} +2 -2
  133. package/dist/cli/chunks/{chunk-QHKK2H4H.js → chunk-ZG4EKPGV.js} +1 -1
  134. package/dist/cli/chunks/{chunk-USN2JKUW.js → chunk-ZWSRIJ2T.js} +2 -2
  135. package/dist/cli/chunks/{ci-BYCH3NPL.js → ci-LRTJSZHT.js} +2 -2
  136. package/dist/cli/chunks/{ci-output-P7P4XH6F.js → ci-output-LISCHUKD.js} +2 -2
  137. package/dist/cli/chunks/{circuit-breaker-VLX556ZI.js → circuit-breaker-7PMP25KZ.js} +2 -2
  138. package/dist/cli/chunks/{claude-flow-setup-JPR425PL.js → claude-flow-setup-DOW4QVMC.js} +2 -2
  139. package/dist/cli/chunks/client-XF6SJO2C.js +2 -0
  140. package/dist/cli/chunks/{cline-installer-FOY47NSH.js → cline-installer-2NXQGW73.js} +2 -2
  141. package/dist/cli/chunks/{code-57SN4ZDY.js → code-3X6RWAS7.js} +2 -2
  142. package/dist/cli/chunks/{code-index-extractor-GT7UFRYU.js → code-index-extractor-4ABP5WCP.js} +2 -2
  143. package/dist/cli/chunks/{codex-installer-JAGWONAV.js → codex-installer-V7PII6GL.js} +2 -2
  144. package/dist/cli/chunks/{completions-7YLHPGSV.js → completions-Y7LNQ63I.js} +2 -2
  145. package/dist/cli/chunks/{complexity-analyzer-TQUF6BEI.js → complexity-analyzer-XLYMAM6I.js} +2 -2
  146. package/dist/cli/chunks/{continuedev-installer-TICV6IGT.js → continuedev-installer-GOT4TKNT.js} +2 -2
  147. package/dist/cli/chunks/{copilot-installer-A6PDMI52.js → copilot-installer-D6BAQVIO.js} +2 -2
  148. package/dist/cli/chunks/{cost-tracker-NZPNHNV2.js → cost-tracker-VT7C5Q52.js} +2 -2
  149. package/dist/cli/chunks/{coverage-HBEB2LKS.js → coverage-C62MRP4M.js} +3 -3
  150. package/dist/cli/chunks/cross-domain-router-J2OFPM6R.js +2 -0
  151. package/dist/cli/chunks/{cursor-installer-R4FM7MGN.js → cursor-installer-WAWSS2K2.js} +2 -2
  152. package/dist/cli/chunks/{daemon-PHIZPZIE.js → daemon-CP2ETHRF.js} +3 -3
  153. package/dist/cli/chunks/{dag-attention-scheduler-2L7VCYZ3.js → dag-attention-scheduler-SZIZWPV7.js} +2 -2
  154. package/dist/cli/chunks/{detect-EEWB4IYE.js → detect-AJX6NJEP.js} +2 -2
  155. package/dist/cli/chunks/{dist-node-7RM6BB2X.js → dist-node-E5X47QTY.js} +2 -2
  156. package/dist/cli/chunks/{domain-handler-RVGHBDUJ.js → domain-handler-FN3PIP45.js} +2 -2
  157. package/dist/cli/chunks/{domain-transfer-M5MERQG5.js → domain-transfer-N3TOJEMT.js} +2 -2
  158. package/dist/cli/chunks/dream-D5LD5SOZ.js +2 -0
  159. package/dist/cli/chunks/{embed-and-insert-pattern-MS55QS73.js → embed-and-insert-pattern-PJI5TZKR.js} +2 -2
  160. package/dist/cli/chunks/{eval-MBTMI7KN.js → eval-OS54TDQU.js} +2 -2
  161. package/dist/cli/chunks/{experience-capture-middleware-Z5XB7D6A.js → experience-capture-middleware-FBM4ANZW.js} +3 -3
  162. package/dist/cli/chunks/{fast-paths-FSWLHI4I.js → fast-paths-2CVAAPQO.js} +2 -2
  163. package/dist/cli/chunks/{feature-flags-QUPNH2J5.js → feature-flags-A5KFWVFC.js} +2 -2
  164. package/dist/cli/chunks/{feature-flags-ATYOPR5D.js → feature-flags-GEXTW6OT.js} +2 -2
  165. package/dist/cli/chunks/{file-discovery-SOJJEQ2E.js → file-discovery-KWLVC7KN.js} +2 -2
  166. package/dist/cli/chunks/{fleet-PWBTDWVG.js → fleet-MNKH356S.js} +3 -3
  167. package/dist/cli/chunks/{gnn-wrapper-2N67VQOQ.js → gnn-wrapper-ALTWYFVZ.js} +2 -2
  168. package/dist/cli/chunks/{heartbeat-handler-5PSG2UPO.js → heartbeat-handler-MBMEPEGW.js} +4 -4
  169. package/dist/cli/chunks/{heartbeat-scheduler-CNJBAO5C.js → heartbeat-scheduler-OH3SS7MH.js} +2 -2
  170. package/dist/cli/chunks/hnsw-adapter-M2MMM3N6.js +2 -0
  171. package/dist/cli/chunks/hnsw-index-JO7KNF7M.js +2 -0
  172. package/dist/cli/chunks/{hnsw-legacy-bridge-YIXH5T4U.js → hnsw-legacy-bridge-WTD5PR5V.js} +2 -2
  173. package/dist/cli/chunks/{better-sqlite3-3U2AVWQ3.js → hnswlib-node-WENGW3YX.js} +2 -2
  174. package/dist/cli/chunks/hooks-ELHGEBFK.js +248 -0
  175. package/dist/cli/chunks/{hybrid-router-RL47S47Z.js → hybrid-router-D6ZMIZCE.js} +2 -2
  176. package/dist/cli/chunks/{hypergraph-engine-XW2IHFWW.js → hypergraph-engine-JOQ6TERZ.js} +2 -2
  177. package/dist/cli/chunks/{hypergraph-handler-AQXKY4UF.js → hypergraph-handler-HX45YWWN.js} +3 -3
  178. package/dist/cli/chunks/impact-analyzer-ROQL4J7P.js +2 -0
  179. package/dist/cli/chunks/{init-handler-KXYGJQI5.js → init-handler-TNVU6NQ6.js} +6 -6
  180. package/dist/cli/chunks/init-wizard-4BDFZX4M.js +2 -0
  181. package/dist/cli/chunks/kernel-37Y63WKR.js +2 -0
  182. package/dist/cli/chunks/{kilocode-installer-VSULDGRO.js → kilocode-installer-YC5RJIY4.js} +2 -2
  183. package/dist/cli/chunks/{kiro-installer-SH4D2UXW.js → kiro-installer-EAB26M55.js} +2 -2
  184. package/dist/cli/chunks/knowledge-graph-V3DX6ZCX.js +2 -0
  185. package/dist/cli/chunks/learning-A2OB7D2B.js +117 -0
  186. package/dist/cli/chunks/{llm-router-YXXSQX5K.js → llm-router-KEG6PA7C.js} +4 -4
  187. package/dist/cli/chunks/{load-S52R2SLL.js → load-D6ZDLVA3.js} +2 -2
  188. package/dist/cli/chunks/load-test-HPBA2CMT.js +2 -0
  189. package/dist/cli/chunks/{mcp-ZWMAJIU7.js → mcp-ERJHZ6FN.js} +2 -2
  190. package/dist/cli/chunks/{memory-4YTWWDK7.js → memory-GSRIJIVR.js} +5 -5
  191. package/dist/cli/chunks/memory-backend-DODDBB46.js +2 -0
  192. package/dist/cli/chunks/memory-handlers-MFLCRS7V.js +2 -0
  193. package/dist/cli/chunks/{multi-model-executor-F3VEM2UF.js → multi-model-executor-GK3V7ERC.js} +2 -2
  194. package/dist/cli/chunks/{opencode-installer-Z2CUJQ6D.js → opencode-installer-6TTN26RG.js} +2 -2
  195. package/dist/cli/chunks/{orchestrator-UPXR2XOF.js → orchestrator-YVTSM6QW.js} +37 -18
  196. package/dist/cli/chunks/{pipeline-6MEMAIXM.js → pipeline-EWLJCY5G.js} +2 -2
  197. package/dist/cli/chunks/{platform-H72FLOM7.js → platform-2ULHQQME.js} +2 -2
  198. package/dist/cli/chunks/{plugin-GIMQFDVR.js → plugin-PYN2KOXA.js} +2 -2
  199. package/dist/cli/chunks/{prime-radiant-advanced-wasm-DM5FR5SV.js → prime-radiant-advanced-wasm-IULCTOGZ.js} +2 -2
  200. package/dist/cli/chunks/protocol-executor-D56OYMCJ.js +2 -0
  201. package/dist/cli/chunks/{protocol-handler-YW3N333B.js → protocol-handler-FZYI2SBP.js} +2 -2
  202. package/dist/cli/chunks/{prove-IJY524KK.js → prove-DN7S74SP.js} +2 -2
  203. package/dist/cli/chunks/{provider-manager-FNG6YR2V.js → provider-manager-FT3MCROB.js} +2 -2
  204. package/dist/cli/chunks/qe-reasoning-bank-KXROIEK7.js +2 -0
  205. package/dist/cli/chunks/{quality-EZLAMSCP.js → quality-ITBU6LGC.js} +2 -2
  206. package/dist/cli/chunks/queen-coordinator-XOGATERL.js +2 -0
  207. package/dist/cli/chunks/{real-embeddings-MFRCC6GH.js → real-embeddings-PZUZ5RXJ.js} +2 -2
  208. package/dist/cli/chunks/{roocode-installer-H3ZIRGWU.js → roocode-installer-2LMVZOUZ.js} +2 -2
  209. package/dist/cli/chunks/router-3EHNUCOM.js +2 -0
  210. package/dist/cli/chunks/routing-feedback-ZHKGET22.js +2 -0
  211. package/dist/cli/chunks/{routing-handler-T2A7FYHW.js → routing-handler-5RB73UCF.js} +2 -2
  212. package/dist/cli/chunks/{ruvector-commands-TCLWBP2M.js → ruvector-commands-VBN4APMG.js} +2 -2
  213. package/dist/cli/chunks/{rvf-dual-writer-BE3JCPYC.js → rvf-dual-writer-BNY4AUWT.js} +2 -2
  214. package/dist/cli/chunks/{rvf-migration-adapter-MLUX5YGR.js → rvf-migration-adapter-73MKPBGV.js} +2 -2
  215. package/dist/cli/chunks/{rvf-migration-coordinator-OAQXTASZ.js → rvf-migration-coordinator-SGVB7ZAZ.js} +2 -2
  216. package/dist/cli/chunks/rvf-native-adapter-4YC5IQUW.js +2 -0
  217. package/dist/cli/chunks/safe-db-PLJRHQIC.js +2 -0
  218. package/dist/cli/chunks/schedule-7DGELVJE.js +2 -0
  219. package/dist/cli/chunks/scheduler-VWASEC2J.js +2 -0
  220. package/dist/cli/chunks/{security-SHWJWJ4M.js → security-XUH4H7R3.js} +3 -3
  221. package/dist/cli/chunks/shared-rvf-adapter-DCVDY2XW.js +2 -0
  222. package/dist/cli/chunks/{shared-rvf-dual-writer-BKSR2FFK.js → shared-rvf-dual-writer-GML4EDYF.js} +2 -2
  223. package/dist/cli/chunks/sqlite-persistence-CTEBGVOW.js +2 -0
  224. package/dist/cli/chunks/{status-handler-QK5KMKYC.js → status-handler-XI7GJF6Z.js} +2 -2
  225. package/dist/cli/chunks/{structural-health-3BRNCAYQ.js → structural-health-WPCYKOXV.js} +2 -2
  226. package/dist/cli/chunks/{sync-5CDYOT3H.js → sync-SFKTCRZC.js} +2 -2
  227. package/dist/cli/chunks/{task-handler-VH2CLUIA.js → task-handler-FZB55IEG.js} +2 -2
  228. package/dist/cli/chunks/{task-handlers-BUZNV2VX.js → task-handlers-EXZGFH7F.js} +3 -3
  229. package/dist/cli/chunks/{test-K24JQQZ2.js → test-XYRN4OVU.js} +4 -4
  230. package/dist/cli/chunks/{test-scheduling-MHXRV5VI.js → test-scheduling-FLVOPGOT.js} +3 -3
  231. package/dist/cli/chunks/{token-bootstrap-3NZDLG52.js → token-bootstrap-FDCFVRHM.js} +2 -2
  232. package/dist/cli/chunks/{token-usage-C4BGA2O7.js → token-usage-MHNZF3DM.js} +2 -2
  233. package/dist/cli/chunks/{transformers-ZIIFB2V4.js → transformers-4CRVTMWY.js} +2 -2
  234. package/dist/cli/chunks/{tree-sitter-wasm-parser-GES2AV7A.js → tree-sitter-wasm-parser-CI3V4AND.js} +2 -2
  235. package/dist/cli/chunks/{types-L3MO5VNC.js → types-RKCD4BNL.js} +2 -2
  236. package/dist/cli/chunks/unified-memory-YDKXKW3D.js +2 -0
  237. package/dist/cli/chunks/unified-memory-hnsw-6N7YZCLR.js +2 -0
  238. package/dist/cli/chunks/unified-persistence-UTWLPUQI.js +2 -0
  239. package/dist/cli/chunks/{upgrade-EKJYS5S5.js → upgrade-463W7VKH.js} +2 -2
  240. package/dist/cli/chunks/{validate-WYWWB5PQ.js → validate-LENSMEAY.js} +2 -2
  241. package/dist/cli/chunks/{validate-swarm-SBSWKJ3H.js → validate-swarm-4FEBNAWA.js} +2 -2
  242. package/dist/cli/chunks/{vibium-VEMTLNFV.js → vibium-TXNVIVWJ.js} +2 -2
  243. package/dist/cli/chunks/visual-security-DGXSOFKD.js +2 -0
  244. package/dist/cli/chunks/{web-tree-sitter-STW2WR2J.js → web-tree-sitter-BZEGWID4.js} +2 -2
  245. package/dist/cli/chunks/{windsurf-installer-6ZXMJASZ.js → windsurf-installer-7AFXJTPU.js} +2 -2
  246. package/dist/cli/chunks/{witness-chain-PTULB4MR.js → witness-chain-G6SUZOZG.js} +2 -2
  247. package/dist/cli/chunks/witness-chain-VP4MF6EU.js +2 -0
  248. package/dist/cli/chunks/{workflow-TEBAAHNR.js → workflow-EVQPO6FH.js} +4 -4
  249. package/dist/cli/chunks/workflow-orchestrator-VXSYAKQY.js +2 -0
  250. package/dist/cli/chunks/{wrappers-DVMVRKXK.js → wrappers-HR6RUDI2.js} +2 -2
  251. package/dist/cli/commands/hooks-handlers/editing-hooks.js +9 -3
  252. package/dist/cli/commands/hooks-handlers/hooks-dream-learning.js +16 -24
  253. package/dist/cli/commands/hooks-handlers/hooks-shared.d.ts +1 -1
  254. package/dist/cli/commands/hooks-handlers/hooks-shared.js +8 -1
  255. package/dist/cli/commands/hooks-handlers/routing-hooks.js +15 -3
  256. package/dist/cli/commands/hooks-handlers/task-hooks.js +37 -46
  257. package/dist/cli/commands/learning.js +194 -0
  258. package/dist/init/phases/10-workers.js +20 -1
  259. package/dist/kernel/interfaces.d.ts +12 -0
  260. package/dist/kernel/kernel.d.ts +1 -0
  261. package/dist/kernel/kernel.js +57 -0
  262. package/dist/kernel/unified-memory-schemas.d.ts +1 -1
  263. package/dist/kernel/unified-memory-schemas.js +7 -1
  264. package/dist/learning/agent-routing.d.ts +134 -1
  265. package/dist/learning/agent-routing.js +185 -2
  266. package/dist/learning/dream/dream-insights-pruner.d.ts +49 -0
  267. package/dist/learning/dream/dream-insights-pruner.js +53 -0
  268. package/dist/learning/dream/dream-scheduler.js +17 -0
  269. package/dist/learning/loop-health.d.ts +84 -0
  270. package/dist/learning/loop-health.js +91 -0
  271. package/dist/learning/pattern-usage-recorder.d.ts +58 -0
  272. package/dist/learning/pattern-usage-recorder.js +72 -0
  273. package/dist/learning/qe-reasoning-bank-types.d.ts +11 -0
  274. package/dist/learning/qe-reasoning-bank.d.ts +11 -0
  275. package/dist/learning/qe-reasoning-bank.js +86 -3
  276. package/dist/learning/routing-topology-gate.d.ts +40 -0
  277. package/dist/learning/routing-topology-gate.js +55 -0
  278. package/dist/learning/sqlite-persistence.d.ts +6 -1
  279. package/dist/learning/sqlite-persistence.js +14 -20
  280. package/dist/mcp/bundle.js +3831 -3805
  281. package/dist/routing/routing-feedback.js +7 -3
  282. package/dist/routing/routing-outcomes-migration.d.ts +31 -0
  283. package/dist/routing/routing-outcomes-migration.js +60 -0
  284. package/dist/workers/workers/learning-consolidation.d.ts +28 -0
  285. package/dist/workers/workers/learning-consolidation.js +204 -0
  286. package/package.json +1 -1
  287. package/dist/cli/chunks/adapter-HV42JOZD.js +0 -2
  288. package/dist/cli/chunks/aqe-learning-engine-GL22PE2V.js +0 -2
  289. package/dist/cli/chunks/base-4KQ2FGUX.js +0 -2
  290. package/dist/cli/chunks/browser-workflow-CTE7BDM4.js +0 -2
  291. package/dist/cli/chunks/chunk-3NGNSKL3.js +0 -14
  292. package/dist/cli/chunks/chunk-6HSFZ6SL.js +0 -180
  293. package/dist/cli/chunks/chunk-7Z3GBQNV.js +0 -2
  294. package/dist/cli/chunks/chunk-H2IMXQCJ.js +0 -2
  295. package/dist/cli/chunks/chunk-SPCANEJY.js +0 -95
  296. package/dist/cli/chunks/client-FRVNMXQO.js +0 -2
  297. package/dist/cli/chunks/cross-domain-router-BVCPAWG2.js +0 -2
  298. package/dist/cli/chunks/dream-77ODIFIF.js +0 -2
  299. package/dist/cli/chunks/hnsw-adapter-CQGQS3V7.js +0 -2
  300. package/dist/cli/chunks/hnsw-index-2ACF6FOJ.js +0 -2
  301. package/dist/cli/chunks/hooks-YROFO6PE.js +0 -259
  302. package/dist/cli/chunks/impact-analyzer-LWEGK23B.js +0 -2
  303. package/dist/cli/chunks/init-wizard-7BS3QMWR.js +0 -2
  304. package/dist/cli/chunks/kernel-TX67WXSI.js +0 -2
  305. package/dist/cli/chunks/knowledge-graph-TDSP2UE2.js +0 -2
  306. package/dist/cli/chunks/learning-RRWV3SEL.js +0 -107
  307. package/dist/cli/chunks/load-test-GEBBBUMV.js +0 -2
  308. package/dist/cli/chunks/memory-backend-WQS2MLW2.js +0 -2
  309. package/dist/cli/chunks/memory-handlers-RTY5MBA5.js +0 -2
  310. package/dist/cli/chunks/protocol-executor-DT7XHMLL.js +0 -2
  311. package/dist/cli/chunks/qe-reasoning-bank-LDNETZVA.js +0 -2
  312. package/dist/cli/chunks/queen-coordinator-AF7HCQSM.js +0 -2
  313. package/dist/cli/chunks/router-OWQ5EI72.js +0 -2
  314. package/dist/cli/chunks/routing-feedback-B43DEQMK.js +0 -2
  315. package/dist/cli/chunks/rvf-native-adapter-XBJDXHNI.js +0 -2
  316. package/dist/cli/chunks/safe-db-RT3LEDUG.js +0 -2
  317. package/dist/cli/chunks/schedule-EHUDCKS2.js +0 -2
  318. package/dist/cli/chunks/scheduler-GEGZ4J3C.js +0 -2
  319. package/dist/cli/chunks/shared-rvf-adapter-LNBUNRAM.js +0 -2
  320. package/dist/cli/chunks/sqlite-persistence-3DGRJH3K.js +0 -2
  321. package/dist/cli/chunks/unified-memory-ZSBX4LYU.js +0 -2
  322. package/dist/cli/chunks/unified-memory-hnsw-Y6EKAMRP.js +0 -2
  323. package/dist/cli/chunks/unified-persistence-2PDVU2U5.js +0 -2
  324. package/dist/cli/chunks/visual-security-RHMFLKVQ.js +0 -2
  325. package/dist/cli/chunks/witness-chain-QO237QOF.js +0 -2
  326. package/dist/cli/chunks/workflow-orchestrator-RHM5MIGE.js +0 -2
@@ -65,6 +65,7 @@ Examples:
65
65
  registerDreamCommand(learning);
66
66
  registerRepairCommand(learning);
67
67
  registerHealthCommand(learning);
68
+ registerLoopHealthCommand(learning);
68
69
  return learning;
69
70
  }
70
71
  // ============================================================================
@@ -1414,6 +1415,199 @@ function registerHealthCommand(learning) {
1414
1415
  });
1415
1416
  }
1416
1417
  // ============================================================================
1418
+ // Subcommand: loop-health (#488 B.2)
1419
+ // ============================================================================
1420
+ /**
1421
+ * Component staleness thresholds (ms). Each component has its own expected
1422
+ * cadence — the bridge polls every 5s, the learning worker ticks every 30
1423
+ * min, the dream scheduler is variable. Anything older than ~2x its cadence
1424
+ * counts as stale and operators should investigate.
1425
+ */
1426
+ const COMPONENT_STALE_THRESHOLDS = {
1427
+ bridge: 30_000, // 5s poll → stale at 30s
1428
+ learningWorker: 2 * 3600_000, // 30 min tick → stale at 2h
1429
+ dreamScheduler: 2 * 3600_000, // similar cadence to worker
1430
+ };
1431
+ function registerLoopHealthCommand(learning) {
1432
+ learning
1433
+ .command('loop-health')
1434
+ .description('Show pipeline component liveness for the self-learning loop')
1435
+ .option('--json', 'Output as JSON')
1436
+ .action(async (options) => {
1437
+ try {
1438
+ const projectRoot = findProjectRoot();
1439
+ const dbPath = path.join(projectRoot, '.agentic-qe', 'memory.db');
1440
+ if (!existsSync(dbPath)) {
1441
+ throw new Error('Database not found. Run "aqe init --auto" first.');
1442
+ }
1443
+ const db = openDatabase(dbPath, { readonly: true });
1444
+ let raw;
1445
+ try {
1446
+ // Try the unified kv_store first (kernel-owned key).
1447
+ const row = db
1448
+ .prepare(`SELECT value FROM kv_store WHERE key = 'learning:loop-health' LIMIT 1`)
1449
+ .get();
1450
+ raw = row?.value;
1451
+ }
1452
+ catch {
1453
+ // kv_store may not exist yet on a freshly-init'd shop.
1454
+ }
1455
+ // ADR-095: routing diversification stats (7-day rolling window)
1456
+ let routingStats = null;
1457
+ try {
1458
+ const colCheck = db
1459
+ .prepare("PRAGMA table_info(routing_outcomes)")
1460
+ .all();
1461
+ const hasExploration = colCheck.some((c) => c.name === 'exploration');
1462
+ if (hasExploration) {
1463
+ const totals = db
1464
+ .prepare(`SELECT
1465
+ COUNT(*) AS total,
1466
+ SUM(CASE WHEN exploration = 1 THEN 1 ELSE 0 END) AS explore,
1467
+ AVG(criticality) AS avgCrit,
1468
+ AVG(q_weight) AS avgQ
1469
+ FROM routing_outcomes
1470
+ WHERE created_at >= datetime('now', '-7 days')`)
1471
+ .get();
1472
+ const total = totals.total ?? 0;
1473
+ const explore = totals.explore ?? 0;
1474
+ const exploit = total - explore;
1475
+ const exploitQ = db
1476
+ .prepare(`SELECT AVG(quality_score) AS avgQ FROM routing_outcomes
1477
+ WHERE exploration = 0 AND quality_score >= 0
1478
+ AND created_at >= datetime('now', '-7 days')`)
1479
+ .get();
1480
+ const exploreQ = db
1481
+ .prepare(`SELECT AVG(quality_score) AS avgQ FROM routing_outcomes
1482
+ WHERE exploration = 1 AND quality_score >= 0
1483
+ AND created_at >= datetime('now', '-7 days')`)
1484
+ .get();
1485
+ routingStats = {
1486
+ totalDecisions: total,
1487
+ explorationCount: explore,
1488
+ exploitCount: exploit,
1489
+ explorationRate: total > 0 ? explore / total : 0,
1490
+ avgQualityExploit: exploitQ.avgQ,
1491
+ avgQualityExplore: exploreQ.avgQ,
1492
+ avgCriticality: totals.avgCrit,
1493
+ avgQWeight: totals.avgQ,
1494
+ };
1495
+ }
1496
+ }
1497
+ catch {
1498
+ // routing_outcomes missing or pre-ADR-095 schema — skip silently.
1499
+ }
1500
+ db.close();
1501
+ let health = null;
1502
+ if (raw) {
1503
+ try {
1504
+ health = safeJsonParse(raw);
1505
+ }
1506
+ catch {
1507
+ health = null;
1508
+ }
1509
+ }
1510
+ const now = Date.now();
1511
+ const verdict = (componentKey, c) => {
1512
+ const threshold = COMPONENT_STALE_THRESHOLDS[componentKey] ?? 600_000;
1513
+ if (!c || !c.lastSuccessAt)
1514
+ return 'never-ran';
1515
+ const age = now - new Date(c.lastSuccessAt).getTime();
1516
+ return age > threshold ? 'stale' : 'live';
1517
+ };
1518
+ if (options.json) {
1519
+ if (!health) {
1520
+ printJson({
1521
+ overallLastSuccess: null,
1522
+ bootedAt: null,
1523
+ components: {},
1524
+ verdicts: {},
1525
+ routingDiversification: routingStats,
1526
+ note: 'No loop-health record yet. Workers must run at least once for this to populate.',
1527
+ });
1528
+ return;
1529
+ }
1530
+ const verdicts = {};
1531
+ for (const key of Object.keys(health.components)) {
1532
+ verdicts[key] = verdict(key, health.components[key]);
1533
+ }
1534
+ printJson({ ...health, verdicts, routingDiversification: routingStats });
1535
+ return;
1536
+ }
1537
+ console.log('');
1538
+ console.log(chalk.bold('Self-Learning Loop Health'));
1539
+ console.log('');
1540
+ if (!health) {
1541
+ console.log(chalk.dim(' No loop-health record yet.'));
1542
+ console.log(chalk.dim(' Workers must run at least once to populate.'));
1543
+ console.log(chalk.dim(' Start the daemon: aqe daemon start'));
1544
+ // FALL THROUGH (no early return): routing-diversification stats may
1545
+ // still be available even when loop-health components haven't ticked
1546
+ // yet (e.g., routing happened via hook handlers but daemon-side
1547
+ // workers never ran). Operators need both signals visible.
1548
+ }
1549
+ else {
1550
+ console.log(` Booted at: ${chalk.dim(health.bootedAt)}`);
1551
+ console.log(` Last success (any): ${health.overallLastSuccess || chalk.dim('(none yet)')}`);
1552
+ console.log('');
1553
+ console.log(chalk.bold(' Components:'));
1554
+ const known = [
1555
+ ['bridge', 'CapturedExperienceBridge'],
1556
+ ['learningWorker', 'LearningConsolidationWorker'],
1557
+ ['dreamScheduler', 'DreamScheduler'],
1558
+ ];
1559
+ for (const [key, label] of known) {
1560
+ const c = health.components[key];
1561
+ const v = verdict(key, c);
1562
+ const colored = v === 'live'
1563
+ ? chalk.green('● live')
1564
+ : v === 'stale'
1565
+ ? chalk.yellow('● stale')
1566
+ : chalk.dim('○ never-ran');
1567
+ const lastSuccess = c?.lastSuccessAt || chalk.dim('(never)');
1568
+ const ticks = c
1569
+ ? `${c.successesSinceBoot}/${c.ticksSinceBoot} ticks ok`
1570
+ : chalk.dim('no ticks');
1571
+ console.log(` ${label.padEnd(32)} ${colored.padEnd(20)} ${ticks}`);
1572
+ console.log(` ${chalk.dim('last success:')} ${lastSuccess}`);
1573
+ if (c?.lastError) {
1574
+ console.log(` ${chalk.red('last error:')} ${c.lastError.message} ${chalk.dim('(at ' + c.lastError.at + ')')}`);
1575
+ }
1576
+ }
1577
+ const stale = known.filter(([k, _]) => verdict(k, health.components[k]) === 'stale');
1578
+ if (stale.length > 0) {
1579
+ console.log('');
1580
+ console.log(chalk.yellow(` Warning: ${stale.length} component(s) stale — daemon may not be running or the loop is wedged.`));
1581
+ }
1582
+ }
1583
+ // ADR-095: routing diversification dashboard
1584
+ if (routingStats && routingStats.totalDecisions > 0) {
1585
+ console.log('');
1586
+ console.log(chalk.bold(' Routing diversification (last 7 days):'));
1587
+ const ratePct = (routingStats.explorationRate * 100).toFixed(1);
1588
+ console.log(` Decisions: ${routingStats.totalDecisions} (${routingStats.exploitCount} exploit, ${routingStats.explorationCount} explore = ${ratePct}%)`);
1589
+ if (routingStats.avgQualityExploit !== null && routingStats.avgQualityExplore !== null) {
1590
+ const delta = routingStats.avgQualityExplore - routingStats.avgQualityExploit;
1591
+ const deltaStr = delta >= 0 ? chalk.green(`+${delta.toFixed(3)}`) : chalk.red(delta.toFixed(3));
1592
+ console.log(` Avg quality: exploit=${routingStats.avgQualityExploit.toFixed(3)}, explore=${routingStats.avgQualityExplore.toFixed(3)} (Δ ${deltaStr})`);
1593
+ }
1594
+ if (routingStats.avgCriticality !== null) {
1595
+ console.log(` Avg mincut multiplier: ${routingStats.avgCriticality.toFixed(2)} (1.0=full rate, 0.2=critical-topology dampening)`);
1596
+ }
1597
+ if (routingStats.avgQWeight !== null && routingStats.avgQWeight > 0) {
1598
+ console.log(` Avg Q-weight: ${routingStats.avgQWeight.toFixed(3)} (0=cold start, ${0.4} max)`);
1599
+ }
1600
+ }
1601
+ console.log('');
1602
+ return;
1603
+ }
1604
+ catch (error) {
1605
+ printError(`loop-health failed: ${error instanceof Error ? error.message : 'unknown'}`);
1606
+ throw error;
1607
+ }
1608
+ });
1609
+ }
1610
+ // ============================================================================
1417
1611
  // Exports
1418
1612
  // ============================================================================
1419
1613
  export { initializeLearningSystem } from './learning-helpers.js';
@@ -121,12 +121,30 @@ if (existsSync(pidFile)) {
121
121
  const ts = new Date().toISOString();
122
122
  appendFileSync(logFile, '[' + ts + '] Starting AQE v3 Worker Daemon...\\n');
123
123
 
124
- // Find the best way to run aqe-mcp
124
+ // Find the best way to run aqe-mcp.
125
+ //
126
+ // #488 B.1: candidate ordering matters for the pidfile contract. When we
127
+ // spawn the real MCP binary directly, child.pid is the long-lived process
128
+ // — \`process.kill(pid, 0)\` against the pidfile correctly reports liveness.
129
+ // When we fall back to \`npx --yes agentic-qe mcp\`, child.pid is the npx
130
+ // wrapper PID, which exits as soon as it has forked the real bundle. The
131
+ // pidfile then points at a dead process and idempotency checks misbehave.
132
+ //
133
+ // We try in order: local .bin → local node_modules bundle → global install
134
+ // via require.resolve → npx wrapper (last resort, with the caveat above).
125
135
  const candidates = [
126
136
  join(projectRoot, 'node_modules', '.bin', 'aqe-mcp'),
127
137
  join(projectRoot, 'node_modules', 'agentic-qe', 'dist', 'mcp', 'bundle.js'),
128
138
  ];
129
139
 
140
+ // Probe globally-installed agentic-qe (npm install -g) via require.resolve.
141
+ // This is the case the npx fallback used to silently cover with a bad PID.
142
+ try {
143
+ candidates.push(require.resolve('agentic-qe/dist/mcp/bundle.js'));
144
+ } catch {
145
+ // Not globally installed — fall through to npx fallback below.
146
+ }
147
+
130
148
  let mcpCmd, mcpArgs;
131
149
  const binCandidate = candidates.find(c => existsSync(c));
132
150
 
@@ -139,6 +157,7 @@ if (binCandidate && binCandidate.endsWith('bundle.js')) {
139
157
  } else {
140
158
  mcpCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
141
159
  mcpArgs = ['--yes', 'agentic-qe', 'mcp'];
160
+ appendFileSync(logFile, '[' + ts + '] WARNING: using npx fallback — daemon.pid will point at the npx wrapper, not the MCP server. \`aqe daemon status\` may misreport liveness after the wrapper exits.\\n');
142
161
  }
143
162
 
144
163
  appendFileSync(logFile, '[' + ts + '] Using: ' + mcpCmd + ' ' + mcpArgs.join(' ') + '\\n');
@@ -297,6 +297,18 @@ export interface KernelConfig {
297
297
  * can set false to skip the plugin-load cost.
298
298
  */
299
299
  enableExperienceBridge?: boolean;
300
+ /**
301
+ * Whether to start the DreamScheduler during initialize() (ADR-094).
302
+ * When true (default), dream cycles run inside the long-lived kernel
303
+ * process instead of hook subprocesses. Hook subprocesses keep only
304
+ * `incrementDreamExperience` — the kernel-side scheduler is the
305
+ * authoritative trigger.
306
+ *
307
+ * Long-lived processes (MCP server, daemon) want this true.
308
+ * Short-lived CLI commands that complete in <1s can set false to skip
309
+ * DreamEngine init cost.
310
+ */
311
+ enableDreamScheduler?: boolean;
300
312
  }
301
313
  /**
302
314
  * Event middleware interface for anti-drift and other event processing (ADR-060)
@@ -21,6 +21,7 @@ export declare class QEKernelImpl implements QEKernel {
21
21
  private _initialized;
22
22
  private _loopTracker;
23
23
  private _experienceBridge?;
24
+ private _dreamScheduler?;
24
25
  constructor(config?: Partial<KernelConfig>);
25
26
  get eventBus(): EventBus;
26
27
  get coordinator(): AgentCoordinator;
@@ -19,6 +19,8 @@ import * as fs from 'fs';
19
19
  import { PluginLifecycleManager } from '../plugins/lifecycle';
20
20
  import { PluginCache } from '../plugins/cache';
21
21
  import { CapturedExperienceBridge } from '../bridge/captured-experience-bridge.js';
22
+ import { DreamScheduler } from '../learning/dream/dream-scheduler.js';
23
+ import { createDreamEngine } from '../learning/dream/dream-engine.js';
22
24
  // Import domain plugin factories
23
25
  import { createTestGenerationPlugin } from '../domains/test-generation/plugin';
24
26
  import { createTestExecutionPlugin } from '../domains/test-execution/plugin';
@@ -69,6 +71,10 @@ const DEFAULT_CONFIG = {
69
71
  // working out of the box. CLI commands that don't need event-driven
70
72
  // domain reactions opt out by passing `enableExperienceBridge: false`.
71
73
  enableExperienceBridge: true,
74
+ // ADR-094: kernel-side dream cycles. Defaults match the bridge — long-lived
75
+ // processes start the scheduler so dream cycles run in the kernel rather
76
+ // than inside hook subprocesses. Short-lived CLIs opt out.
77
+ enableDreamScheduler: true,
72
78
  };
73
79
  export class QEKernelImpl {
74
80
  _eventBus;
@@ -83,6 +89,10 @@ export class QEKernelImpl {
83
89
  // Issue #479: drains captured_experiences into the eventBus so hook-driven
84
90
  // activity reaches the 13 domain plugins' subscribeToEvents() handlers.
85
91
  _experienceBridge;
92
+ // ADR-094: kernel-side dream cycles. Replaces the in-hook
93
+ // checkAndTriggerDream path so 10-second SQLite write transactions move
94
+ // out of short-lived hook subprocesses into the long-lived kernel.
95
+ _dreamScheduler;
86
96
  constructor(config = {}) {
87
97
  this._config = { ...DEFAULT_CONFIG, ...config };
88
98
  this._startTime = new Date();
@@ -262,9 +272,56 @@ export class QEKernelImpl {
262
272
  this._experienceBridge = undefined;
263
273
  }
264
274
  }
275
+ // ADR-094: Start the kernel-side DreamScheduler so dream cycles run in
276
+ // the long-lived process. Hook subprocesses no longer trigger dreams —
277
+ // they only bump the experience counter (incrementDreamExperience).
278
+ // The scheduler subscribes to its own event triggers (quality-gate
279
+ // failure, domain milestones) and runs time-based dreams on its own
280
+ // cadence (default 1h). DreamEngine.ensureConceptsLoaded() auto-loads
281
+ // patterns from qe_patterns, so no separate ReasoningBank is needed here.
282
+ if (this._config.enableDreamScheduler !== false) {
283
+ try {
284
+ const dreamEngine = createDreamEngine({
285
+ maxDurationMs: 10_000,
286
+ minConceptsRequired: 3,
287
+ });
288
+ await dreamEngine.initialize();
289
+ this._dreamScheduler = new DreamScheduler({
290
+ dreamEngine,
291
+ eventBus: this._eventBus,
292
+ memoryBackend: this._memory,
293
+ });
294
+ await this._dreamScheduler.initialize();
295
+ this._dreamScheduler.start();
296
+ }
297
+ catch (err) {
298
+ console.warn('[QEKernel] DreamScheduler failed to start:', err instanceof Error ? err.message : err);
299
+ // Tear down anything we partially constructed so we don't leak a
300
+ // half-initialized scheduler (e.g., engine init succeeded but
301
+ // scheduler.start threw).
302
+ if (this._dreamScheduler) {
303
+ try {
304
+ await this._dreamScheduler.dispose();
305
+ }
306
+ catch { /* swallow during cleanup */ }
307
+ }
308
+ this._dreamScheduler = undefined;
309
+ }
310
+ }
265
311
  this._initialized = true;
266
312
  }
267
313
  async dispose() {
314
+ // ADR-094: Stop the dream scheduler first so a dream-in-progress doesn't
315
+ // try to write to a disposed memory backend.
316
+ if (this._dreamScheduler) {
317
+ try {
318
+ await this._dreamScheduler.dispose();
319
+ }
320
+ catch (err) {
321
+ console.warn('[QEKernel] DreamScheduler dispose failed:', err instanceof Error ? err.message : err);
322
+ }
323
+ this._dreamScheduler = undefined;
324
+ }
268
325
  // Stop the bridge first so it doesn't try to publish to a disposed bus.
269
326
  if (this._experienceBridge) {
270
327
  await this._experienceBridge.stop();
@@ -17,6 +17,6 @@ export declare const QE_PATTERNS_SCHEMA = "\n -- QE Patterns table (unified fro
17
17
  export declare const MINCUT_SCHEMA = "\n -- MinCut Graph Snapshots (ADR-047)\n CREATE TABLE IF NOT EXISTS mincut_snapshots (\n id TEXT PRIMARY KEY,\n timestamp TEXT NOT NULL DEFAULT (datetime('now')),\n vertex_count INTEGER NOT NULL,\n edge_count INTEGER NOT NULL,\n total_weight REAL NOT NULL DEFAULT 0.0,\n is_connected INTEGER NOT NULL DEFAULT 1,\n component_count INTEGER NOT NULL DEFAULT 1,\n vertices_json TEXT NOT NULL,\n edges_json TEXT NOT NULL,\n created_at TEXT DEFAULT (datetime('now'))\n );\n\n -- MinCut History (time-series MinCut values)\n CREATE TABLE IF NOT EXISTS mincut_history (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n timestamp TEXT NOT NULL DEFAULT (datetime('now')),\n mincut_value REAL NOT NULL,\n vertex_count INTEGER NOT NULL,\n edge_count INTEGER NOT NULL,\n algorithm TEXT NOT NULL DEFAULT 'weighted-degree',\n duration_ms INTEGER,\n snapshot_id TEXT,\n created_at TEXT DEFAULT (datetime('now')),\n FOREIGN KEY (snapshot_id) REFERENCES mincut_snapshots(id) ON DELETE SET NULL\n );\n\n -- MinCut Weak Vertices (detected bottlenecks)\n CREATE TABLE IF NOT EXISTS mincut_weak_vertices (\n id TEXT PRIMARY KEY,\n vertex_id TEXT NOT NULL,\n weighted_degree REAL NOT NULL,\n risk_score REAL NOT NULL,\n reason TEXT NOT NULL,\n domain TEXT,\n vertex_type TEXT NOT NULL,\n suggestions_json TEXT,\n detected_at TEXT NOT NULL DEFAULT (datetime('now')),\n resolved_at TEXT,\n snapshot_id TEXT,\n created_at TEXT DEFAULT (datetime('now')),\n FOREIGN KEY (snapshot_id) REFERENCES mincut_snapshots(id) ON DELETE SET NULL\n );\n\n -- MinCut Alerts\n CREATE TABLE IF NOT EXISTS mincut_alerts (\n id TEXT PRIMARY KEY,\n severity TEXT NOT NULL,\n message TEXT NOT NULL,\n mincut_value REAL NOT NULL,\n threshold REAL NOT NULL,\n affected_vertices_json TEXT,\n remediations_json TEXT,\n acknowledged INTEGER DEFAULT 0,\n acknowledged_at TEXT,\n acknowledged_by TEXT,\n timestamp TEXT NOT NULL DEFAULT (datetime('now')),\n created_at TEXT DEFAULT (datetime('now'))\n );\n\n -- MinCut Healing Actions (self-healing history)\n CREATE TABLE IF NOT EXISTS mincut_healing_actions (\n id TEXT PRIMARY KEY,\n action_type TEXT NOT NULL,\n action_params_json TEXT NOT NULL,\n success INTEGER NOT NULL,\n mincut_before REAL NOT NULL,\n mincut_after REAL NOT NULL,\n improvement REAL NOT NULL DEFAULT 0.0,\n error_message TEXT,\n duration_ms INTEGER NOT NULL,\n triggered_by TEXT,\n snapshot_before_id TEXT,\n snapshot_after_id TEXT,\n created_at TEXT DEFAULT (datetime('now')),\n FOREIGN KEY (snapshot_before_id) REFERENCES mincut_snapshots(id) ON DELETE SET NULL,\n FOREIGN KEY (snapshot_after_id) REFERENCES mincut_snapshots(id) ON DELETE SET NULL\n );\n\n -- MinCut Strange Loop Observations (P1: self-organizing)\n CREATE TABLE IF NOT EXISTS mincut_observations (\n id TEXT PRIMARY KEY,\n iteration INTEGER NOT NULL,\n mincut_value REAL NOT NULL,\n weak_vertex_count INTEGER NOT NULL DEFAULT 0,\n weak_vertices_json TEXT,\n snapshot_id TEXT,\n prediction_json TEXT,\n actual_vs_predicted_diff REAL,\n timestamp TEXT NOT NULL DEFAULT (datetime('now')),\n FOREIGN KEY (snapshot_id) REFERENCES mincut_snapshots(id) ON DELETE SET NULL\n );\n\n -- MinCut Indexes\n CREATE INDEX IF NOT EXISTS idx_mincut_history_timestamp ON mincut_history(timestamp DESC);\n CREATE INDEX IF NOT EXISTS idx_mincut_history_value ON mincut_history(mincut_value);\n CREATE INDEX IF NOT EXISTS idx_mincut_weak_vertex ON mincut_weak_vertices(vertex_id);\n CREATE INDEX IF NOT EXISTS idx_mincut_weak_risk ON mincut_weak_vertices(risk_score DESC);\n CREATE INDEX IF NOT EXISTS idx_mincut_weak_resolved ON mincut_weak_vertices(resolved_at);\n CREATE INDEX IF NOT EXISTS idx_mincut_alerts_severity ON mincut_alerts(severity);\n CREATE INDEX IF NOT EXISTS idx_mincut_alerts_ack ON mincut_alerts(acknowledged);\n CREATE INDEX IF NOT EXISTS idx_mincut_healing_type ON mincut_healing_actions(action_type);\n CREATE INDEX IF NOT EXISTS idx_mincut_healing_success ON mincut_healing_actions(success);\n CREATE INDEX IF NOT EXISTS idx_mincut_observations_iter ON mincut_observations(iteration);\n";
18
18
  export declare const SONA_PATTERNS_SCHEMA = "\n -- SONA Patterns table (ADR-046: Pattern Persistence for Neural Backbone)\n CREATE TABLE IF NOT EXISTS sona_patterns (\n id TEXT PRIMARY KEY,\n type TEXT NOT NULL,\n domain TEXT NOT NULL,\n state_embedding BLOB,\n action_embedding BLOB,\n action_type TEXT NOT NULL,\n action_value TEXT,\n outcome_reward REAL NOT NULL DEFAULT 0.0,\n outcome_success INTEGER NOT NULL DEFAULT 0,\n outcome_quality REAL NOT NULL DEFAULT 0.0,\n confidence REAL DEFAULT 0.5,\n usage_count INTEGER DEFAULT 0,\n success_count INTEGER DEFAULT 0,\n failure_count INTEGER DEFAULT 0,\n metadata TEXT,\n created_at TEXT DEFAULT (datetime('now')),\n updated_at TEXT DEFAULT (datetime('now')),\n last_used_at TEXT\n );\n CREATE INDEX IF NOT EXISTS idx_sona_patterns_type ON sona_patterns(type);\n CREATE INDEX IF NOT EXISTS idx_sona_patterns_domain ON sona_patterns(domain);\n CREATE INDEX IF NOT EXISTS idx_sona_patterns_confidence ON sona_patterns(confidence DESC);\n CREATE INDEX IF NOT EXISTS idx_sona_patterns_updated ON sona_patterns(updated_at DESC);\n";
19
19
  export declare const WITNESS_CHAIN_SCHEMA = "\n -- Witness Chain (ADR-070: Cryptographic audit trail for QE decisions)\n CREATE TABLE IF NOT EXISTS witness_chain (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n prev_hash TEXT NOT NULL,\n action_hash TEXT NOT NULL,\n action_type TEXT NOT NULL,\n action_data TEXT,\n timestamp TEXT NOT NULL,\n actor TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS idx_witness_action_type ON witness_chain(action_type);\n CREATE INDEX IF NOT EXISTS idx_witness_timestamp ON witness_chain(timestamp);\n";
20
- export declare const FEEDBACK_SCHEMA = "\n -- Test outcomes (ADR-023: Quality Feedback Loop)\n CREATE TABLE IF NOT EXISTS test_outcomes (\n id TEXT PRIMARY KEY,\n test_id TEXT NOT NULL,\n test_name TEXT NOT NULL,\n generated_by TEXT NOT NULL,\n pattern_id TEXT,\n framework TEXT NOT NULL,\n language TEXT NOT NULL,\n domain TEXT NOT NULL,\n passed INTEGER NOT NULL,\n error_message TEXT,\n coverage_lines REAL DEFAULT 0,\n coverage_branches REAL DEFAULT 0,\n coverage_functions REAL DEFAULT 0,\n mutation_score REAL,\n execution_time_ms REAL NOT NULL,\n flaky INTEGER DEFAULT 0,\n flakiness_score REAL,\n maintainability_score REAL NOT NULL,\n complexity REAL,\n lines_of_code INTEGER,\n assertion_count INTEGER,\n file_path TEXT,\n source_file_path TEXT,\n metadata_json TEXT,\n created_at TEXT DEFAULT (datetime('now'))\n );\n CREATE INDEX IF NOT EXISTS idx_test_outcomes_pattern ON test_outcomes(pattern_id);\n CREATE INDEX IF NOT EXISTS idx_test_outcomes_agent ON test_outcomes(generated_by);\n CREATE INDEX IF NOT EXISTS idx_test_outcomes_domain ON test_outcomes(domain);\n CREATE INDEX IF NOT EXISTS idx_test_outcomes_created ON test_outcomes(created_at);\n\n -- Routing outcomes (ADR-022: Adaptive QE Agent Routing, ADR-092: advisor_consultation_json)\n CREATE TABLE IF NOT EXISTS routing_outcomes (\n id TEXT PRIMARY KEY,\n task_json TEXT NOT NULL,\n decision_json TEXT NOT NULL,\n used_agent TEXT NOT NULL,\n followed_recommendation INTEGER NOT NULL,\n success INTEGER NOT NULL,\n quality_score REAL NOT NULL,\n duration_ms REAL NOT NULL,\n error TEXT,\n model_tier TEXT,\n advisor_consultation_json TEXT,\n created_at TEXT DEFAULT (datetime('now'))\n );\n CREATE INDEX IF NOT EXISTS idx_routing_outcomes_agent ON routing_outcomes(used_agent);\n CREATE INDEX IF NOT EXISTS idx_routing_outcomes_created ON routing_outcomes(created_at);\n CREATE INDEX IF NOT EXISTS idx_routing_outcomes_tier ON routing_outcomes(model_tier);\n\n -- Coverage sessions (ADR-023: Coverage Learning)\n CREATE TABLE IF NOT EXISTS coverage_sessions (\n id TEXT PRIMARY KEY,\n target_path TEXT NOT NULL,\n agent_id TEXT NOT NULL,\n technique TEXT NOT NULL,\n before_lines REAL DEFAULT 0,\n before_branches REAL DEFAULT 0,\n before_functions REAL DEFAULT 0,\n after_lines REAL DEFAULT 0,\n after_branches REAL DEFAULT 0,\n after_functions REAL DEFAULT 0,\n tests_generated INTEGER DEFAULT 0,\n tests_passed INTEGER DEFAULT 0,\n gaps_json TEXT,\n duration_ms REAL NOT NULL,\n started_at TEXT NOT NULL,\n completed_at TEXT NOT NULL,\n context_json TEXT,\n created_at TEXT DEFAULT (datetime('now'))\n );\n CREATE INDEX IF NOT EXISTS idx_coverage_sessions_technique ON coverage_sessions(technique);\n CREATE INDEX IF NOT EXISTS idx_coverage_sessions_agent ON coverage_sessions(agent_id);\n CREATE INDEX IF NOT EXISTS idx_coverage_sessions_created ON coverage_sessions(created_at);\n";
20
+ export declare const FEEDBACK_SCHEMA = "\n -- Test outcomes (ADR-023: Quality Feedback Loop)\n CREATE TABLE IF NOT EXISTS test_outcomes (\n id TEXT PRIMARY KEY,\n test_id TEXT NOT NULL,\n test_name TEXT NOT NULL,\n generated_by TEXT NOT NULL,\n pattern_id TEXT,\n framework TEXT NOT NULL,\n language TEXT NOT NULL,\n domain TEXT NOT NULL,\n passed INTEGER NOT NULL,\n error_message TEXT,\n coverage_lines REAL DEFAULT 0,\n coverage_branches REAL DEFAULT 0,\n coverage_functions REAL DEFAULT 0,\n mutation_score REAL,\n execution_time_ms REAL NOT NULL,\n flaky INTEGER DEFAULT 0,\n flakiness_score REAL,\n maintainability_score REAL NOT NULL,\n complexity REAL,\n lines_of_code INTEGER,\n assertion_count INTEGER,\n file_path TEXT,\n source_file_path TEXT,\n metadata_json TEXT,\n created_at TEXT DEFAULT (datetime('now'))\n );\n CREATE INDEX IF NOT EXISTS idx_test_outcomes_pattern ON test_outcomes(pattern_id);\n CREATE INDEX IF NOT EXISTS idx_test_outcomes_agent ON test_outcomes(generated_by);\n CREATE INDEX IF NOT EXISTS idx_test_outcomes_domain ON test_outcomes(domain);\n CREATE INDEX IF NOT EXISTS idx_test_outcomes_created ON test_outcomes(created_at);\n\n -- Routing outcomes (ADR-022: Adaptive QE Agent Routing, ADR-092: advisor_consultation_json,\n -- ADR-095: exploration / criticality / q_weight for \u03B5-greedy routing telemetry)\n CREATE TABLE IF NOT EXISTS routing_outcomes (\n id TEXT PRIMARY KEY,\n task_json TEXT NOT NULL,\n decision_json TEXT NOT NULL,\n used_agent TEXT NOT NULL,\n followed_recommendation INTEGER NOT NULL,\n success INTEGER NOT NULL,\n quality_score REAL NOT NULL,\n duration_ms REAL NOT NULL,\n error TEXT,\n model_tier TEXT,\n advisor_consultation_json TEXT,\n -- ADR-095: routing exploration telemetry\n exploration INTEGER NOT NULL DEFAULT 0,\n criticality REAL,\n q_weight REAL,\n created_at TEXT DEFAULT (datetime('now'))\n );\n CREATE INDEX IF NOT EXISTS idx_routing_outcomes_agent ON routing_outcomes(used_agent);\n CREATE INDEX IF NOT EXISTS idx_routing_outcomes_created ON routing_outcomes(created_at);\n CREATE INDEX IF NOT EXISTS idx_routing_outcomes_tier ON routing_outcomes(model_tier);\n CREATE INDEX IF NOT EXISTS idx_routing_outcomes_exploration ON routing_outcomes(exploration);\n\n -- Coverage sessions (ADR-023: Coverage Learning)\n CREATE TABLE IF NOT EXISTS coverage_sessions (\n id TEXT PRIMARY KEY,\n target_path TEXT NOT NULL,\n agent_id TEXT NOT NULL,\n technique TEXT NOT NULL,\n before_lines REAL DEFAULT 0,\n before_branches REAL DEFAULT 0,\n before_functions REAL DEFAULT 0,\n after_lines REAL DEFAULT 0,\n after_branches REAL DEFAULT 0,\n after_functions REAL DEFAULT 0,\n tests_generated INTEGER DEFAULT 0,\n tests_passed INTEGER DEFAULT 0,\n gaps_json TEXT,\n duration_ms REAL NOT NULL,\n started_at TEXT NOT NULL,\n completed_at TEXT NOT NULL,\n context_json TEXT,\n created_at TEXT DEFAULT (datetime('now'))\n );\n CREATE INDEX IF NOT EXISTS idx_coverage_sessions_technique ON coverage_sessions(technique);\n CREATE INDEX IF NOT EXISTS idx_coverage_sessions_agent ON coverage_sessions(agent_id);\n CREATE INDEX IF NOT EXISTS idx_coverage_sessions_created ON coverage_sessions(created_at);\n";
21
21
  export declare const STATS_TABLES: string[];
22
22
  //# sourceMappingURL=unified-memory-schemas.d.ts.map
@@ -540,7 +540,8 @@ export const FEEDBACK_SCHEMA = `
540
540
  CREATE INDEX IF NOT EXISTS idx_test_outcomes_domain ON test_outcomes(domain);
541
541
  CREATE INDEX IF NOT EXISTS idx_test_outcomes_created ON test_outcomes(created_at);
542
542
 
543
- -- Routing outcomes (ADR-022: Adaptive QE Agent Routing, ADR-092: advisor_consultation_json)
543
+ -- Routing outcomes (ADR-022: Adaptive QE Agent Routing, ADR-092: advisor_consultation_json,
544
+ -- ADR-095: exploration / criticality / q_weight for ε-greedy routing telemetry)
544
545
  CREATE TABLE IF NOT EXISTS routing_outcomes (
545
546
  id TEXT PRIMARY KEY,
546
547
  task_json TEXT NOT NULL,
@@ -553,11 +554,16 @@ export const FEEDBACK_SCHEMA = `
553
554
  error TEXT,
554
555
  model_tier TEXT,
555
556
  advisor_consultation_json TEXT,
557
+ -- ADR-095: routing exploration telemetry
558
+ exploration INTEGER NOT NULL DEFAULT 0,
559
+ criticality REAL,
560
+ q_weight REAL,
556
561
  created_at TEXT DEFAULT (datetime('now'))
557
562
  );
558
563
  CREATE INDEX IF NOT EXISTS idx_routing_outcomes_agent ON routing_outcomes(used_agent);
559
564
  CREATE INDEX IF NOT EXISTS idx_routing_outcomes_created ON routing_outcomes(created_at);
560
565
  CREATE INDEX IF NOT EXISTS idx_routing_outcomes_tier ON routing_outcomes(model_tier);
566
+ CREATE INDEX IF NOT EXISTS idx_routing_outcomes_exploration ON routing_outcomes(exploration);
561
567
 
562
568
  -- Coverage sessions (ADR-023: Coverage Learning)
563
569
  CREATE TABLE IF NOT EXISTS coverage_sessions (
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Agentic QE v3 - Agent Routing
3
3
  * ADR-021: QE ReasoningBank for Pattern Learning
4
+ * ADR-095: ε-greedy exploration with Q-value blending and mincut safety gate
4
5
  *
5
6
  * Static agent capability mapping and routing score calculation
6
7
  * used by QEReasoningBank.routeTask().
@@ -22,11 +23,28 @@ export interface AgentCapabilityProfile {
22
23
  export declare const AGENT_CAPABILITIES: Record<string, AgentCapabilityProfile>;
23
24
  /**
24
25
  * Scored agent with reasoning trace.
26
+ *
27
+ * ADR-095 telemetry fields (all optional, populated only when the
28
+ * corresponding signal source is wired):
29
+ * - `staticScore`: the pre-blend score (domain + capability + perf + …)
30
+ * - `qWeight`, `qValue`: when Q-table data was available
31
+ * - `exploration`: true if this agent was promoted to position 0 by the
32
+ * ε-greedy policy rather than scored to the top deterministically
25
33
  */
26
34
  export interface ScoredAgent {
27
35
  agent: string;
28
36
  score: number;
29
37
  reasoning: string[];
38
+ /** ADR-095: pre-blend static score for retrospective explainability */
39
+ staticScore?: number;
40
+ /** ADR-095: Q-value influence (0..MAX_Q_WEIGHT) on the final score */
41
+ qWeight?: number;
42
+ /** ADR-095: raw q_value from rl_q_values, for telemetry */
43
+ qValue?: number;
44
+ /** ADR-095: number of (state_key, action_key) visits behind the Q value */
45
+ qVisits?: number;
46
+ /** ADR-095: true when ε-greedy promoted this agent over the greedy winner */
47
+ exploration?: boolean;
30
48
  }
31
49
  /**
32
50
  * Routing weight configuration.
@@ -38,6 +56,114 @@ export interface RoutingWeights {
38
56
  /** Weight for language match boost (default: 1.0) */
39
57
  language?: number;
40
58
  }
59
+ /**
60
+ * Maximum Q-value influence on the final score.
61
+ *
62
+ * 0.4 means a fully-mature Q-value can move the score by up to ±0.2 (since
63
+ * normalizedQ ranges over (0, 1) and the static contribution clamps the
64
+ * upper bound). This is intentionally bounded so Q-values inform rather
65
+ * than override the static features.
66
+ *
67
+ * Tuning: post-deploy telemetry will tell us whether agents are actually
68
+ * being separated by Q-values. If the avg `q_weight` in routing_outcomes
69
+ * climbs but quality_score doesn't improve, this constant is too high.
70
+ */
71
+ export declare const MAX_Q_WEIGHT = 0.4;
72
+ /**
73
+ * Number of (state_key, action_key) visits at which qWeight saturates at
74
+ * MAX_Q_WEIGHT. Below this, qWeight ramps linearly from 0.
75
+ *
76
+ * 20 visits at the default 30-min worker tick + typical session cadence
77
+ * implies ~1 week of activity before a (state, agent) pair drives the
78
+ * decision. Adjust downward if cold-start latency proves problematic.
79
+ */
80
+ export declare const QWEIGHT_RAMP_VISITS = 20;
81
+ /**
82
+ * Q-value lookup callback supplied by the caller (QEReasoningBank.routeTask).
83
+ * Returns undefined when the (stateKey, agentType) pair has no recorded
84
+ * Q-value yet — caller does not need to handle missing-row vs zero-visits.
85
+ */
86
+ export type QValueLookup = (agentType: string) => {
87
+ qValue: number;
88
+ visits: number;
89
+ } | undefined;
90
+ /**
91
+ * Blend a static score with a Q-value contribution.
92
+ *
93
+ * effectiveScore = staticScore * (1 - qWeight) + normalizedQ * qWeight
94
+ *
95
+ * Returns { score, qWeight, qValue, qVisits } so callers can attach the
96
+ * telemetry fields to the ScoredAgent record.
97
+ */
98
+ export declare function blendStaticAndQValue(staticScore: number, qLookup: {
99
+ qValue: number;
100
+ visits: number;
101
+ } | undefined): {
102
+ score: number;
103
+ qWeight: number;
104
+ qValue: number;
105
+ qVisits: number;
106
+ };
107
+ /**
108
+ * Resolve the per-decision ε for the exploration policy.
109
+ *
110
+ * Priority order:
111
+ * 1. AQE_ROUTER_EXPLORATION_RATE env var (operator override, fixed)
112
+ * 2. Default base rate (0.05)
113
+ * The result is then multiplied by the mincut safety gate (caller passes
114
+ * `topologyCritical` derived from getSharedMinCutMonitor().isCritical()):
115
+ * critical topology → 0.2x dampening, healthy/unknown → 1.0x.
116
+ *
117
+ * Returns a number in [0, 1].
118
+ */
119
+ export declare function resolveExplorationRate(opts: {
120
+ envOverride?: string;
121
+ topologyCritical?: boolean;
122
+ }): {
123
+ epsilon: number;
124
+ baseEpsilon: number;
125
+ safetyMultiplier: number;
126
+ };
127
+ /**
128
+ * Apply the ε-greedy exploration policy to a sorted score list.
129
+ *
130
+ * With probability ε (computed from resolveExplorationRate), swaps the
131
+ * top-scored agent with a uniformly-random pick from positions 1..3 (or
132
+ * fewer if the list is shorter). Mutates `agentScores` in place. The
133
+ * promoted agent gets `exploration = true`.
134
+ *
135
+ * Uses `crypto.randomInt` for cryptographically-strong uniform sampling —
136
+ * matches the codebase convention (randomUUID is imported from 'crypto'
137
+ * in the same modules). Math.random() would work but breaks consistency.
138
+ */
139
+ export declare function applyExplorationPolicy(agentScores: ScoredAgent[], epsilon: number): void;
140
+ /**
141
+ * Derive a structural taskType from a free-form task description. Used to
142
+ * build the q-learning state_key shared with the post-task Bellman update
143
+ * (hooks-dream-learning.ts).
144
+ *
145
+ * Exported (rather than kept private in task-hooks) so QEReasoningBank can
146
+ * compute the same state_key at routing time as post-task does at outcome
147
+ * time — without that, the Q-table writer and reader would address
148
+ * different keys.
149
+ */
150
+ export declare function deriveTaskType(description: string): string;
151
+ /**
152
+ * Build the canonical Q-learning state_key. Must match the format used by
153
+ * `updateHookRouterQValue` in hooks-dream-learning.ts — the writer and
154
+ * reader must agree on the key shape.
155
+ */
156
+ export declare function buildRoutingStateKey(opts: {
157
+ taskType: string;
158
+ priority?: string;
159
+ domain?: string;
160
+ complexityBucket: number;
161
+ }): string;
162
+ /**
163
+ * Compute the complexity bucket [0, 10] from a task description length.
164
+ * Mirrors the formula in task-hooks.ts pre-task bridge.
165
+ */
166
+ export declare function deriveComplexityBucket(description: string): number;
41
167
  /**
42
168
  * Calculate agent scores for a routing request.
43
169
  *
@@ -49,7 +175,14 @@ export interface RoutingWeights {
49
175
  * @param requestLanguage - Optional language to boost agents with matching language expertise
50
176
  * @returns Sorted array of scored agents (highest score first)
51
177
  */
52
- export declare function calculateAgentScores(detectedDomains: QEDomain[], requestCapabilities: string[] | undefined, agentDomainPatternCounts: Map<string, number>, routingWeights: RoutingWeights, agentCapabilities?: Record<string, AgentCapabilityProfile>, requestLanguage?: string): ScoredAgent[];
178
+ export declare function calculateAgentScores(detectedDomains: QEDomain[], requestCapabilities: string[] | undefined, agentDomainPatternCounts: Map<string, number>, routingWeights: RoutingWeights, agentCapabilities?: Record<string, AgentCapabilityProfile>, requestLanguage?: string,
179
+ /**
180
+ * ADR-095: optional per-agent Q-value lookup. When provided, the static
181
+ * score is blended with the Q-value contribution via blendStaticAndQValue.
182
+ * When omitted (or returning undefined for every agent), behavior is
183
+ * identical to the pre-ADR-095 deterministic scoring.
184
+ */
185
+ qValueLookup?: QValueLookup): ScoredAgent[];
53
186
  /**
54
187
  * Domain compatibility matrix for cross-domain pattern transfer.
55
188
  * Maps each domain to its related domains (same as TransferSpecialistService).