agentic-qe 3.15.8 → 3.15.9

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 (479) hide show
  1. package/.claude/skills/skills-manifest.json +1 -1
  2. package/CHANGELOG.md +183 -0
  3. package/assets/skills/skills-manifest.json +1 -1
  4. package/dist/agents/claim-verifier/claim-verifier-service.js +13 -8
  5. package/dist/bridge/captured-experience-bridge.js +12 -13
  6. package/dist/cli/bundle.js +6 -6
  7. package/dist/cli/chunks/adapter-R2Q4QGXQ.js +2 -0
  8. package/dist/cli/chunks/{agent-booster-wasm-W3V5P7LE.js → agent-booster-wasm-427FRKWG.js} +2 -2
  9. package/dist/cli/chunks/{agent-handler-2NQFHAWE.js → agent-handler-RIYHTHVZ.js} +2 -2
  10. package/dist/cli/chunks/{agent-memory-branch-457ECHHK.js → agent-memory-branch-WSUCUHOO.js} +2 -2
  11. package/dist/cli/chunks/aqe-learning-engine-3RENLQWP.js +2 -0
  12. package/dist/cli/chunks/{arena-JV3WSEHU.js → arena-KRIBMIXX.js} +2 -2
  13. package/dist/cli/chunks/{arena-IYBQ3GPY.js → arena-YAJZX6MC.js} +4 -4
  14. package/dist/cli/chunks/{audit-5OS3T3K6.js → audit-7ZNOXWP3.js} +3 -3
  15. package/dist/cli/chunks/base-67DXSAYM.js +2 -0
  16. package/dist/cli/chunks/{better-sqlite3-IQKBFVAO.js → better-sqlite3-ZQAT4I6H.js} +2 -2
  17. package/dist/cli/chunks/{brain-handler-KA3SGAFM.js → brain-handler-452WCPZC.js} +3 -3
  18. package/dist/cli/chunks/{branch-enumerator-QZDU2VOQ.js → branch-enumerator-IJFXJRPN.js} +2 -2
  19. package/dist/cli/chunks/{browser-ZL7OLKJQ.js → browser-CT3MTV6G.js} +2 -2
  20. package/dist/cli/chunks/browser-workflow-NDXRROWZ.js +2 -0
  21. package/dist/cli/chunks/{chunk-IJSFZO7P.js → chunk-2BA45H64.js} +2 -2
  22. package/dist/cli/chunks/{chunk-6GIC2263.js → chunk-2HL3UM5P.js} +2 -2
  23. package/dist/cli/chunks/{chunk-KVMKYUOE.js → chunk-2I2UPJS7.js} +2 -2
  24. package/dist/cli/chunks/{chunk-22DOS3PM.js → chunk-2TDIS6YK.js} +2 -2
  25. package/dist/cli/chunks/{chunk-5MBNRTT5.js → chunk-2URBI52G.js} +2 -2
  26. package/dist/cli/chunks/{chunk-A6GCO6ZU.js → chunk-2XITOPYV.js} +2 -2
  27. package/dist/cli/chunks/{chunk-I77D65X5.js → chunk-2YH62JCN.js} +2 -2
  28. package/dist/cli/chunks/{chunk-2JCLACCS.js → chunk-32UTLDNY.js} +2 -2
  29. package/dist/cli/chunks/{chunk-UTNKMPTC.js → chunk-37BIGMJI.js} +1 -1
  30. package/dist/cli/chunks/{chunk-767SR7WH.js → chunk-3CJCROMW.js} +2 -2
  31. package/dist/cli/chunks/{chunk-LVHZK7GW.js → chunk-3LYU7BLY.js} +2 -2
  32. package/dist/cli/chunks/{chunk-5DZDLOY6.js → chunk-47TYABPD.js} +3 -3
  33. package/dist/cli/chunks/{chunk-SWY6KGMF.js → chunk-47V7FQGX.js} +2 -2
  34. package/dist/cli/chunks/{chunk-KMZW2P3R.js → chunk-4JCY45KV.js} +2 -2
  35. package/dist/cli/chunks/{chunk-D4IBIMWI.js → chunk-4SUOVLJ6.js} +2 -2
  36. package/dist/cli/chunks/{chunk-J7RCI25Q.js → chunk-4URT6JO2.js} +1 -1
  37. package/dist/cli/chunks/{chunk-SHEVM5PF.js → chunk-4V27J6YN.js} +2 -2
  38. package/dist/cli/chunks/{chunk-JWPYMRIX.js → chunk-4W4DYVSH.js} +1 -1
  39. package/dist/cli/chunks/chunk-55HRSNGN.js +2 -0
  40. package/dist/cli/chunks/{chunk-R2NHGESM.js → chunk-5D2I7JUP.js} +2 -2
  41. package/dist/cli/chunks/{chunk-GGSTLKY5.js → chunk-5JWGCIQW.js} +1 -1
  42. package/dist/cli/chunks/chunk-5LAAZLUC.js +4 -0
  43. package/dist/cli/chunks/{chunk-YNQPHRUZ.js → chunk-5NS3USRW.js} +1 -1
  44. package/dist/cli/chunks/{chunk-4YUBWU3E.js → chunk-6EPHNJTL.js} +1 -1
  45. package/dist/cli/chunks/{chunk-ZBI7PJFX.js → chunk-6OOYIO3W.js} +2 -2
  46. package/dist/cli/chunks/{chunk-ST7ASEJO.js → chunk-6PXA2BQJ.js} +58 -58
  47. package/dist/cli/chunks/{chunk-LPSMVBB3.js → chunk-6YL6JOQB.js} +2 -2
  48. package/dist/cli/chunks/{chunk-DY37YMMQ.js → chunk-72AMFDC7.js} +1 -1
  49. package/dist/cli/chunks/{chunk-OWBFVAEH.js → chunk-763SUL4B.js} +2 -2
  50. package/dist/cli/chunks/{chunk-4GYFONJB.js → chunk-7DMA5NYL.js} +1 -1
  51. package/dist/cli/chunks/{chunk-4GUVVGJX.js → chunk-7JKB3Q7O.js} +1 -1
  52. package/dist/cli/chunks/{chunk-DN3AKAPY.js → chunk-7KII4CQG.js} +2 -2
  53. package/dist/cli/chunks/{chunk-VKFVJCIH.js → chunk-7QGYJ5OY.js} +1 -1
  54. package/dist/cli/chunks/{chunk-HNGNRIZZ.js → chunk-7QTB5VJZ.js} +2 -2
  55. package/dist/cli/chunks/{chunk-GSOK4M6V.js → chunk-7X2Y727E.js} +1 -1
  56. package/dist/cli/chunks/{chunk-PZ7FJ4UG.js → chunk-A4RU67VX.js} +2 -2
  57. package/dist/cli/chunks/{chunk-VWSGWYRB.js → chunk-A6YIH4C4.js} +2 -2
  58. package/dist/cli/chunks/{chunk-4I35ARWW.js → chunk-ABFDB4X3.js} +1 -1
  59. package/dist/cli/chunks/{chunk-NQDYOF35.js → chunk-AJ4YDSOI.js} +2 -2
  60. package/dist/cli/chunks/{chunk-CDLG3Q2O.js → chunk-AOFO4N32.js} +2 -2
  61. package/dist/cli/chunks/{chunk-WAWKAYPY.js → chunk-AQTVVLNP.js} +1 -1
  62. package/dist/cli/chunks/chunk-AR2E4B7K.js +6 -0
  63. package/dist/cli/chunks/{chunk-HXCGV5UJ.js → chunk-AVB5QY2Q.js} +2 -2
  64. package/dist/cli/chunks/{chunk-JFWQFB3S.js → chunk-BHKXMIWX.js} +2 -2
  65. package/dist/cli/chunks/{chunk-BEVWCF3Q.js → chunk-BXO536GT.js} +3 -3
  66. package/dist/cli/chunks/{chunk-IMSRWNWF.js → chunk-C6RTMTEH.js} +1 -1
  67. package/dist/cli/chunks/{chunk-UKKFZJME.js → chunk-CTZJUV5I.js} +1 -1
  68. package/dist/cli/chunks/{chunk-MV4S3TEC.js → chunk-D6XVGFTI.js} +2 -2
  69. package/dist/cli/chunks/{chunk-5YOO5QSE.js → chunk-DDPPSSHW.js} +1 -1
  70. package/dist/cli/chunks/{chunk-NHOMVBCI.js → chunk-DGTLJNJH.js} +2 -2
  71. package/dist/cli/chunks/{chunk-NWFBF3KT.js → chunk-DINZR5CF.js} +1 -1
  72. package/dist/cli/chunks/{chunk-RG42LDOB.js → chunk-EFBLP43U.js} +2 -2
  73. package/dist/cli/chunks/chunk-ETG7O5E5.js +5 -0
  74. package/dist/cli/chunks/{chunk-KNHLOANK.js → chunk-F2SQPP6U.js} +2 -2
  75. package/dist/cli/chunks/{chunk-62T7U25U.js → chunk-F3PQZX44.js} +1 -1
  76. package/dist/cli/chunks/{chunk-X3HM7SV4.js → chunk-F4JYIRW2.js} +2 -2
  77. package/dist/cli/chunks/{chunk-NZATJ2C6.js → chunk-FJ4VTLLK.js} +2 -2
  78. package/dist/cli/chunks/{chunk-TMNEK7TP.js → chunk-FL3OYGCS.js} +2 -2
  79. package/dist/cli/chunks/{chunk-HI6OBDDY.js → chunk-FLASM2XB.js} +2 -2
  80. package/dist/cli/chunks/{chunk-GENNJRNK.js → chunk-FV3NHVC7.js} +22 -22
  81. package/dist/cli/chunks/{chunk-PICEGWGB.js → chunk-FV7VAG74.js} +1 -1
  82. package/dist/cli/chunks/{chunk-PWA6XBW4.js → chunk-G3BKZNFL.js} +5 -5
  83. package/dist/cli/chunks/{chunk-T2TDTBFV.js → chunk-GBUIG3FS.js} +1 -1
  84. package/dist/cli/chunks/{chunk-QFYUZYRA.js → chunk-GCWSX2NY.js} +4 -4
  85. package/dist/cli/chunks/{chunk-KJNUETCB.js → chunk-GII5WVAK.js} +1 -1
  86. package/dist/cli/chunks/{chunk-YVWMJZ6O.js → chunk-GKPQ2GRR.js} +2 -2
  87. package/dist/cli/chunks/chunk-GR3JYE5A.js +2 -0
  88. package/dist/cli/chunks/{chunk-CQ5G64EA.js → chunk-H3KBIWTO.js} +2 -2
  89. package/dist/cli/chunks/{chunk-V4QJ3MMT.js → chunk-HAROIAJE.js} +1 -1
  90. package/dist/cli/chunks/{chunk-OJWEZYLR.js → chunk-HCYQHWI2.js} +2 -2
  91. package/dist/cli/chunks/{chunk-FAYXES7R.js → chunk-HGTWAZWU.js} +2 -2
  92. package/dist/cli/chunks/{chunk-LHRVSK44.js → chunk-HTZJSQ3C.js} +2 -2
  93. package/dist/cli/chunks/{chunk-DAFMHM64.js → chunk-HWK5L7IJ.js} +2 -2
  94. package/dist/cli/chunks/{chunk-K5R3WUJP.js → chunk-HZ5NC6U5.js} +1 -1
  95. package/dist/cli/chunks/{chunk-Y5ZBF7MA.js → chunk-I6S35FRO.js} +2 -2
  96. package/dist/cli/chunks/{chunk-UDCYQLTD.js → chunk-ICP2ORGI.js} +2 -2
  97. package/dist/cli/chunks/{chunk-KMVFBYJO.js → chunk-IFEIY3NQ.js} +2 -2
  98. package/dist/cli/chunks/{chunk-NW7HTOSN.js → chunk-J3DTDJDT.js} +2 -2
  99. package/dist/cli/chunks/chunk-J3WGK22W.js +2 -0
  100. package/dist/cli/chunks/{chunk-5ONJ7AV6.js → chunk-J5KNRVXR.js} +1 -1
  101. package/dist/cli/chunks/{chunk-G77Q22EN.js → chunk-JAV5WPSY.js} +2 -2
  102. package/dist/cli/chunks/{chunk-VVK4ECVJ.js → chunk-JEP4ULR6.js} +2 -2
  103. package/dist/cli/chunks/{chunk-TC52M542.js → chunk-JK2ME6IT.js} +2 -2
  104. package/dist/cli/chunks/chunk-JNNZK7KH.js +2 -0
  105. package/dist/cli/chunks/{chunk-NLYUC63R.js → chunk-JP4P3P3D.js} +2 -2
  106. package/dist/cli/chunks/{chunk-BTMEOZYY.js → chunk-JUVHZG7I.js} +1 -1
  107. package/dist/cli/chunks/{chunk-PUYQ6EKC.js → chunk-JWGRWMZP.js} +2 -2
  108. package/dist/cli/chunks/{chunk-OCLAMZJG.js → chunk-K5DJXMAA.js} +2 -2
  109. package/dist/cli/chunks/{chunk-X7ZQIFES.js → chunk-KFUUIAR4.js} +2 -2
  110. package/dist/cli/chunks/chunk-KHSRIPBP.js +180 -0
  111. package/dist/cli/chunks/{chunk-U3BWBP6B.js → chunk-KIKWJM6J.js} +2 -2
  112. package/dist/cli/chunks/{chunk-MUDBF2JC.js → chunk-KIXYKUCI.js} +1 -1
  113. package/dist/cli/chunks/{chunk-P4UT4LBE.js → chunk-KLGYIEJK.js} +3 -3
  114. package/dist/cli/chunks/{chunk-G6CLO74Q.js → chunk-KR3M44CF.js} +3 -3
  115. package/dist/cli/chunks/chunk-KTSLTZSG.js +2 -0
  116. package/dist/cli/chunks/{chunk-FJAO4UX2.js → chunk-KVBEGOJE.js} +2 -2
  117. package/dist/cli/chunks/{chunk-BLZEOGQE.js → chunk-L42JPFCC.js} +2 -2
  118. package/dist/cli/chunks/{chunk-ZOVAZTXE.js → chunk-LCJTEUDC.js} +370 -370
  119. package/dist/cli/chunks/{chunk-JLTGO5BB.js → chunk-LEAKYZ37.js} +2 -2
  120. package/dist/cli/chunks/{chunk-RSMPJWQH.js → chunk-LMU5DUDK.js} +1 -1
  121. package/dist/cli/chunks/{chunk-FEN2DHFM.js → chunk-MZS32SYS.js} +1 -1
  122. package/dist/cli/chunks/{chunk-J7FLNP5L.js → chunk-N3KEY4XJ.js} +2 -2
  123. package/dist/cli/chunks/{chunk-ZG7UKWBB.js → chunk-N3NP6PTT.js} +2 -2
  124. package/dist/cli/chunks/{chunk-2DPHFCMW.js → chunk-N5PDFGCQ.js} +2 -2
  125. package/dist/cli/chunks/{chunk-BQUIZ5QT.js → chunk-NDKLQW6N.js} +2 -2
  126. package/dist/cli/chunks/{chunk-52YRSWPS.js → chunk-NHZIWIQZ.js} +2 -2
  127. package/dist/cli/chunks/{chunk-ZOHS32SI.js → chunk-NTAD5UX4.js} +2 -2
  128. package/dist/cli/chunks/{chunk-7H3GNRNA.js → chunk-O3JLOVZX.js} +2 -2
  129. package/dist/cli/chunks/{chunk-7XGM7Q2N.js → chunk-OCESWNAZ.js} +3 -3
  130. package/dist/cli/chunks/{chunk-7SLEUVPZ.js → chunk-OG2UI6A3.js} +2 -2
  131. package/dist/cli/chunks/{chunk-4TZLZRZ4.js → chunk-OXTFSIGN.js} +1 -1
  132. package/dist/cli/chunks/{chunk-2QRGIEQV.js → chunk-OXZLKP6C.js} +1 -1
  133. package/dist/cli/chunks/{chunk-FEPFXXI7.js → chunk-P2CXVNKK.js} +2 -2
  134. package/dist/cli/chunks/{chunk-P2EA62YS.js → chunk-P73W2K7T.js} +1 -1
  135. package/dist/cli/chunks/{chunk-V7VZSNDK.js → chunk-PBZI2ZPV.js} +3 -3
  136. package/dist/cli/chunks/{chunk-MMY52Y6R.js → chunk-PMCRCEW5.js} +2 -2
  137. package/dist/cli/chunks/{chunk-FWXNFPLS.js → chunk-PVIA2FPD.js} +2 -2
  138. package/dist/cli/chunks/{chunk-NF63NHJH.js → chunk-PX2B5TS2.js} +2 -2
  139. package/dist/cli/chunks/{chunk-SFPGLUXS.js → chunk-Q3JVJRVJ.js} +1 -1
  140. package/dist/cli/chunks/{chunk-XOOBLZXR.js → chunk-QQ5SZH4D.js} +2 -2
  141. package/dist/cli/chunks/{chunk-KITKQUBX.js → chunk-QTVWUQTB.js} +1 -1
  142. package/dist/cli/chunks/{chunk-2UN4JOTN.js → chunk-REUFWGMA.js} +2 -2
  143. package/dist/cli/chunks/{chunk-CQ3SBRDP.js → chunk-SNBYYO6F.js} +2 -2
  144. package/dist/cli/chunks/{chunk-A2UGPKCS.js → chunk-SVHUYVUR.js} +2 -2
  145. package/dist/cli/chunks/{chunk-PIEKGKW6.js → chunk-THAY7WHO.js} +2 -2
  146. package/dist/cli/chunks/{chunk-WLXGUQOZ.js → chunk-TNMQVG4A.js} +2 -2
  147. package/dist/cli/chunks/{chunk-2GSAAUW3.js → chunk-TSYQDRNK.js} +1 -1
  148. package/dist/cli/chunks/{chunk-7DHSHD5B.js → chunk-TUYJ53V4.js} +2 -2
  149. package/dist/cli/chunks/{chunk-U7CIY3YR.js → chunk-UNUTC6TX.js} +2 -2
  150. package/dist/cli/chunks/{chunk-CRUQ6RXU.js → chunk-UOJBR4J3.js} +2 -2
  151. package/dist/cli/chunks/{chunk-3LFLO2WK.js → chunk-UOWHE77F.js} +2 -2
  152. package/dist/cli/chunks/{chunk-O4RRVTXN.js → chunk-UYLYMWV5.js} +2 -2
  153. package/dist/cli/chunks/{chunk-D4O3TJI7.js → chunk-V5PXQSFS.js} +2 -2
  154. package/dist/cli/chunks/{chunk-VQRBBR27.js → chunk-VCMINU7K.js} +2 -2
  155. package/dist/cli/chunks/{chunk-3N627QRU.js → chunk-VQHVHVSF.js} +2 -2
  156. package/dist/cli/chunks/{chunk-J6LL25QJ.js → chunk-VRGCKBF7.js} +2 -2
  157. package/dist/cli/chunks/{chunk-VWRNG3UK.js → chunk-VU2EL424.js} +1 -1
  158. package/dist/cli/chunks/{chunk-KNQUHGNY.js → chunk-VXZJOKOX.js} +2 -2
  159. package/dist/cli/chunks/{chunk-EUVSSIGR.js → chunk-VYLM2YV5.js} +3 -3
  160. package/dist/cli/chunks/{chunk-PJGQ2TKN.js → chunk-W32YU3VI.js} +2 -2
  161. package/dist/cli/chunks/{chunk-YRH7KMTU.js → chunk-W5VJRDDG.js} +2 -2
  162. package/dist/cli/chunks/{chunk-PPIM7B5G.js → chunk-WGDR2KIR.js} +2 -2
  163. package/dist/cli/chunks/{chunk-2ZRNXEVI.js → chunk-WRRCQ2UE.js} +1 -1
  164. package/dist/cli/chunks/{chunk-7C6FMLQR.js → chunk-XDBD4GXO.js} +2 -2
  165. package/dist/cli/chunks/{chunk-W5A36V3Z.js → chunk-XOLDMK23.js} +2 -2
  166. package/dist/cli/chunks/{chunk-DCYUHCPK.js → chunk-XOVNZT7F.js} +1 -1
  167. package/dist/cli/chunks/{chunk-4C7KE2EL.js → chunk-XQ3DDY7X.js} +2 -2
  168. package/dist/cli/chunks/{chunk-K4N2MBCE.js → chunk-XUIA5KMS.js} +2 -2
  169. package/dist/cli/chunks/{chunk-YUP3APSN.js → chunk-XWIUFYM3.js} +1 -1
  170. package/dist/cli/chunks/{chunk-SJMZZMHP.js → chunk-XYCKHYBM.js} +2 -2
  171. package/dist/cli/chunks/{chunk-4NTLGGXO.js → chunk-XZJ2O3VC.js} +1 -1
  172. package/dist/cli/chunks/{chunk-UQLAN5TX.js → chunk-YRBBBUJX.js} +5 -5
  173. package/dist/cli/chunks/{chunk-XZQVC3GD.js → chunk-YZGSJG34.js} +1 -1
  174. package/dist/cli/chunks/{chunk-7CVMT64N.js → chunk-YZYDTABJ.js} +1 -1
  175. package/dist/cli/chunks/{chunk-4C3RYBTT.js → chunk-ZANDSVCK.js} +2 -2
  176. package/dist/cli/chunks/{chunk-6E7EOHMN.js → chunk-ZBDRLF43.js} +2 -2
  177. package/dist/cli/chunks/{chunk-UTFMMZ57.js → chunk-ZVSLCEVC.js} +3 -3
  178. package/dist/cli/chunks/{chunk-DKFSCJEF.js → chunk-ZXBCCO2H.js} +2 -2
  179. package/dist/cli/chunks/{ci-7NUCRGWO.js → ci-7SGRCFPS.js} +2 -2
  180. package/dist/cli/chunks/{ci-config-VQVECCFI.js → ci-config-MX3URPZA.js} +2 -2
  181. package/dist/cli/chunks/{ci-output-P7GQ6TKF.js → ci-output-M47NJY6D.js} +2 -2
  182. package/dist/cli/chunks/{circuit-breaker-5YP6N6HE.js → circuit-breaker-5GAK45SW.js} +2 -2
  183. package/dist/cli/chunks/{claude-flow-setup-W5H7CMU6.js → claude-flow-setup-YXYSRH4Y.js} +2 -2
  184. package/dist/cli/chunks/client-ZP3CTVRF.js +2 -0
  185. package/dist/cli/chunks/{cline-installer-OYANSZ54.js → cline-installer-DLJ5QD5N.js} +2 -2
  186. package/dist/cli/chunks/{code-OMT4UEZI.js → code-ONKLMVQ2.js} +25 -24
  187. package/dist/cli/chunks/{code-index-extractor-M2JEWKNF.js → code-index-extractor-2232LGZN.js} +2 -2
  188. package/dist/cli/chunks/{codex-installer-YBS6N5O3.js → codex-installer-UOWLYCMH.js} +2 -2
  189. package/dist/cli/chunks/{completions-U7GS5RG6.js → completions-MHX7GCC7.js} +2 -2
  190. package/dist/cli/chunks/{complexity-analyzer-QSXPIUIU.js → complexity-analyzer-43ZUJKZU.js} +2 -2
  191. package/dist/cli/chunks/{continuedev-installer-W5TTT743.js → continuedev-installer-6Q5JR4FF.js} +2 -2
  192. package/dist/cli/chunks/{copilot-installer-KC2RT24C.js → copilot-installer-CZUMVHSI.js} +2 -2
  193. package/dist/cli/chunks/core-handlers-JSRXQWPE.js +2 -0
  194. package/dist/cli/chunks/{cost-tracker-OQPVR6V4.js → cost-tracker-VS5ZW3XN.js} +2 -2
  195. package/dist/cli/chunks/{coverage-TCO2A2NX.js → coverage-VWKTWZ6D.js} +3 -3
  196. package/dist/cli/chunks/cross-domain-router-7UKODQWG.js +2 -0
  197. package/dist/cli/chunks/{cursor-installer-MH7GWD4L.js → cursor-installer-YIFEMORH.js} +2 -2
  198. package/dist/cli/chunks/{daemon-UJEARJZ2.js → daemon-SHWJSJW5.js} +7 -7
  199. package/dist/cli/chunks/daemon-YIFT46FH.js +34 -0
  200. package/dist/cli/chunks/{dag-attention-scheduler-F3SUJU5O.js → dag-attention-scheduler-TCC2WM46.js} +2 -2
  201. package/dist/cli/chunks/{detect-5QTCRB32.js → detect-IGTWSQMA.js} +2 -2
  202. package/dist/cli/chunks/{dist-node-XKZPHDBO.js → dist-node-TCOTJVQX.js} +2 -2
  203. package/dist/cli/chunks/{domain-handler-V3UEADKW.js → domain-handler-55ZVYODR.js} +2 -2
  204. package/dist/cli/chunks/{domain-plugins-7PES4UHZ.js → domain-plugins-GJRWOHQP.js} +2 -2
  205. package/dist/cli/chunks/{domain-transfer-NF7UJW7B.js → domain-transfer-6EF75EKU.js} +2 -2
  206. package/dist/cli/chunks/dream-UDLM6M55.js +2 -0
  207. package/dist/cli/chunks/{embed-and-insert-pattern-D2HWORHF.js → embed-and-insert-pattern-XAMNIKQL.js} +2 -2
  208. package/dist/cli/chunks/{eval-UF2UBAUC.js → eval-GO22R4OZ.js} +2 -2
  209. package/dist/cli/chunks/{experience-capture-middleware-2OUCEHHM.js → experience-capture-middleware-F2BRMJ3Y.js} +3 -3
  210. package/dist/cli/chunks/{fast-paths-KV5DKKHC.js → fast-paths-6RGPYALD.js} +2 -2
  211. package/dist/cli/chunks/{feature-flags-6YWMTNO5.js → feature-flags-MIWQIOHU.js} +2 -2
  212. package/dist/cli/chunks/{feature-flags-MTW6NMR3.js → feature-flags-ZGS3KLPH.js} +2 -2
  213. package/dist/cli/chunks/file-discovery-THWOUQ7Z.js +2 -0
  214. package/dist/cli/chunks/fleet-ADL57COA.js +44 -0
  215. package/dist/cli/chunks/{gnn-wrapper-52V6ANOY.js → gnn-wrapper-ALBJVW6T.js} +2 -2
  216. package/dist/cli/chunks/{heartbeat-handler-X7NHNRC7.js → heartbeat-handler-ZMM53NDY.js} +4 -4
  217. package/dist/cli/chunks/heartbeat-scheduler-HGOC5KH3.js +2 -0
  218. package/dist/cli/chunks/hnsw-adapter-EPSA6AP7.js +2 -0
  219. package/dist/cli/chunks/hnsw-index-RMFOPYGY.js +2 -0
  220. package/dist/cli/chunks/{hnsw-legacy-bridge-DZBE3KMK.js → hnsw-legacy-bridge-RYUJPA7B.js} +2 -2
  221. package/dist/cli/chunks/{hnswlib-node-2AWWUJAZ.js → hnswlib-node-XM6XF3YV.js} +2 -2
  222. package/dist/cli/chunks/{hooks-XLPVROL3.js → hooks-X62O7TJO.js} +10 -10
  223. package/dist/cli/chunks/hybrid-backend-NZ3G4WBX.js +2 -0
  224. package/dist/cli/chunks/{hypergraph-engine-6TI7YP6P.js → hypergraph-engine-ZBWUPTVD.js} +2 -2
  225. package/dist/cli/chunks/{hypergraph-handler-DBIBBOXS.js → hypergraph-handler-DUMF6SJV.js} +3 -3
  226. package/dist/cli/chunks/impact-analyzer-WZC6NHFP.js +2 -0
  227. package/dist/cli/chunks/{init-guard-OSO6MIDD.js → init-guard-S4I2R46S.js} +2 -2
  228. package/dist/cli/chunks/{init-handler-7S7IHMUF.js → init-handler-L4KJHVWS.js} +6 -6
  229. package/dist/cli/chunks/init-wizard-422UZYQ5.js +2 -0
  230. package/dist/cli/chunks/kernel-N7PJ6FCE.js +2 -0
  231. package/dist/cli/chunks/{kilocode-installer-2KBRFXMA.js → kilocode-installer-GNNB5FCZ.js} +2 -2
  232. package/dist/cli/chunks/{kiro-installer-5VFR4OQZ.js → kiro-installer-HR6ZAH7T.js} +2 -2
  233. package/dist/cli/chunks/knowledge-graph-SZCVQF37.js +2 -0
  234. package/dist/cli/chunks/{learning-G5NHL3DV.js → learning-4IEEOHJS.js} +3 -3
  235. package/dist/cli/chunks/{llm-router-4EAPPMHS.js → llm-router-ZFMORP36.js} +4 -4
  236. package/dist/cli/chunks/llm-router-service-4DE5WDUZ.js +2 -0
  237. package/dist/cli/chunks/{load-UYMZPEY6.js → load-ZM43WGDO.js} +2 -2
  238. package/dist/cli/chunks/load-test-POMIF4Q4.js +2 -0
  239. package/dist/cli/chunks/{mcp-NOTDZBW5.js → mcp-CRZKZE37.js} +2 -2
  240. package/dist/cli/chunks/{memory-QL53YIHP.js → memory-W5FZGVAD.js} +5 -5
  241. package/dist/cli/chunks/memory-backend-4P6AHSOY.js +2 -0
  242. package/dist/cli/chunks/memory-handlers-NK6NV3GE.js +2 -0
  243. package/dist/cli/chunks/{multi-model-executor-PDDDXF2B.js → multi-model-executor-SXXGAQ2G.js} +2 -2
  244. package/dist/cli/chunks/{opencode-installer-75D2SKOT.js → opencode-installer-PIRBUAB5.js} +2 -2
  245. package/dist/cli/chunks/{orchestrator-3WIZBV4T.js → orchestrator-H5SQCQTB.js} +11 -10
  246. package/dist/cli/chunks/pattern-null-store-CCHQHGQG.js +2 -0
  247. package/dist/cli/chunks/{pattern-usage-recorder-TEX2JGHA.js → pattern-usage-recorder-XZTWDI2T.js} +2 -2
  248. package/dist/cli/chunks/{pipeline-7ATPA6LU.js → pipeline-5LMLBIJ7.js} +2 -2
  249. package/dist/cli/chunks/{platform-WPSKRJE7.js → platform-KJDABL5C.js} +2 -2
  250. package/dist/cli/chunks/{plugin-UUFOVVMU.js → plugin-V4KSBVVM.js} +2 -2
  251. package/dist/cli/chunks/{prime-radiant-advanced-wasm-PDFSYWKZ.js → prime-radiant-advanced-wasm-JDHTKQAT.js} +2 -2
  252. package/dist/cli/chunks/project-root-X72FSM2F.js +2 -0
  253. package/dist/cli/chunks/protocol-executor-QW6XN6QN.js +2 -0
  254. package/dist/cli/chunks/{protocol-handler-3VRYRIQB.js → protocol-handler-BNRONTQV.js} +2 -2
  255. package/dist/cli/chunks/{prove-2NAUROGF.js → prove-ELLL6XMX.js} +2 -2
  256. package/dist/cli/chunks/qe-reasoning-bank-ZD3WF647.js +2 -0
  257. package/dist/cli/chunks/{quality-ZIEI2WGA.js → quality-NH2QA4D4.js} +2 -2
  258. package/dist/cli/chunks/{quality-gate-KWJO4SWQ.js → quality-gate-JTKLF7GW.js} +3 -3
  259. package/dist/cli/chunks/queen-coordinator-S4U4MKK2.js +2 -0
  260. package/dist/cli/chunks/{real-embeddings-TSZ4UIAE.js → real-embeddings-J3KCKLPB.js} +2 -2
  261. package/dist/cli/chunks/{ref-validation-DWFFRETJ.js → ref-validation-HNXQRP4F.js} +2 -2
  262. package/dist/cli/chunks/{roocode-installer-XTZHLUBO.js → roocode-installer-COJ6CX6S.js} +2 -2
  263. package/dist/cli/chunks/router-CXZKOOTR.js +2 -0
  264. package/dist/cli/chunks/routing-feedback-IYFANYY5.js +2 -0
  265. package/dist/cli/chunks/{routing-handler-GG525TDM.js → routing-handler-WM33ZILE.js} +2 -2
  266. package/dist/cli/chunks/{ruvector-commands-QKRJDM7Z.js → ruvector-commands-BBLXEA7A.js} +2 -2
  267. package/dist/cli/chunks/rvf-dual-writer-HCLQ5WUQ.js +2 -0
  268. package/dist/cli/chunks/rvf-migration-adapter-XCLUWOO3.js +2 -0
  269. package/dist/cli/chunks/{rvf-migration-coordinator-FF52OS6Q.js → rvf-migration-coordinator-P7H6HCAG.js} +2 -2
  270. package/dist/cli/chunks/rvf-native-adapter-MRT5H3IP.js +2 -0
  271. package/dist/cli/chunks/{rvf-store-integrity-M6DXTAZ4.js → rvf-store-integrity-R5SPVRFP.js} +2 -2
  272. package/dist/cli/chunks/safe-db-WFODRGVZ.js +2 -0
  273. package/dist/cli/chunks/schedule-RO55OQXG.js +2 -0
  274. package/dist/cli/chunks/scheduler-XXMJCH24.js +2 -0
  275. package/dist/cli/chunks/{security-EHXSW22U.js → security-AUDTRX3I.js} +3 -3
  276. package/dist/cli/chunks/{shared-rvf-adapter-6EH7UVJL.js → shared-rvf-adapter-PVDGBGI2.js} +2 -2
  277. package/dist/cli/chunks/{shared-rvf-dual-writer-WML274E7.js → shared-rvf-dual-writer-LZ2GMSS2.js} +2 -2
  278. package/dist/cli/chunks/sqlite-persistence-AWRIS4MK.js +2 -0
  279. package/dist/cli/chunks/{standalone-memory-C7QKAXS4.js → standalone-memory-XNOAI4G4.js} +2 -2
  280. package/dist/cli/chunks/{status-handler-VLI7MRLM.js → status-handler-K72XZE4T.js} +2 -2
  281. package/dist/cli/chunks/{structural-health-3LPG6MQN.js → structural-health-NF3YY7U5.js} +2 -2
  282. package/dist/cli/chunks/{sync-4IMMQEPT.js → sync-UVXA6CT2.js} +2 -2
  283. package/dist/cli/chunks/{sync-JFJEJBVK.js → sync-VBD5Y3E2.js} +2 -2
  284. package/dist/cli/chunks/{task-handler-IED3K6E4.js → task-handler-24S3WFVJ.js} +13 -7
  285. package/dist/cli/chunks/task-handlers-GUYW2EPJ.js +9 -0
  286. package/dist/cli/chunks/{test-GPKT3CKZ.js → test-XFSGQELD.js} +4 -4
  287. package/dist/cli/chunks/{test-scheduling-Z42XXZP6.js → test-scheduling-VYUQ4CDE.js} +3 -3
  288. package/dist/cli/chunks/{token-bootstrap-HMM3AHXM.js → token-bootstrap-EDK6FNQ3.js} +2 -2
  289. package/dist/cli/chunks/{token-usage-6Y2ERYIY.js → token-usage-VLQ6WO2L.js} +2 -2
  290. package/dist/cli/chunks/{transformers-MB63T2XO.js → transformers-TOFMWWNM.js} +2 -2
  291. package/dist/cli/chunks/{tree-sitter-wasm-parser-56GDQCMR.js → tree-sitter-wasm-parser-MI3NZKUD.js} +2 -2
  292. package/dist/cli/chunks/{types-J4J6QV3I.js → types-JTWLBAZJ.js} +2 -2
  293. package/dist/cli/chunks/unified-memory-6JWHV6EF.js +2 -0
  294. package/dist/cli/chunks/unified-memory-hnsw-4UANU6NU.js +2 -0
  295. package/dist/cli/chunks/unified-persistence-KGGNA46H.js +2 -0
  296. package/dist/cli/chunks/{upgrade-U4XU7LFM.js → upgrade-4ABM72T4.js} +2 -2
  297. package/dist/cli/chunks/{validate-B57HA4YK.js → validate-UDJCWKXI.js} +2 -2
  298. package/dist/cli/chunks/{validate-swarm-UPPA4M6T.js → validate-swarm-TODOUWNN.js} +2 -2
  299. package/dist/cli/chunks/visual-security-6VZNQLH7.js +2 -0
  300. package/dist/cli/chunks/{web-tree-sitter-GDZMUKOZ.js → web-tree-sitter-WBMAJPM5.js} +2 -2
  301. package/dist/cli/chunks/{windsurf-installer-VJRWCHXP.js → windsurf-installer-BTT53TUL.js} +2 -2
  302. package/dist/cli/chunks/witness-chain-AKKHWEWU.js +2 -0
  303. package/dist/cli/chunks/{witness-chain-LFASSMZK.js → witness-chain-TATPXQRK.js} +2 -2
  304. package/dist/cli/chunks/{witness-chain-repair-TPHN4DXN.js → witness-chain-repair-2HGJGE7O.js} +2 -2
  305. package/dist/cli/chunks/{witness-chain-verifier-Z23FVABW.js → witness-chain-verifier-FRY3LMGH.js} +2 -2
  306. package/dist/cli/chunks/{witness-key-manager-745MJ7WO.js → witness-key-manager-X7QHQQWL.js} +2 -2
  307. package/dist/cli/chunks/{workflow-T245QNQM.js → workflow-QMZPAWQW.js} +4 -4
  308. package/dist/cli/chunks/workflow-orchestrator-4GAW7HNZ.js +2 -0
  309. package/dist/cli/chunks/{wrappers-WCAYIQUX.js → wrappers-ZD5NBHYI.js} +2 -2
  310. package/dist/cli/commands/code.js +8 -0
  311. package/dist/cli/commands/daemon.js +8 -0
  312. package/dist/cli/commands/fleet.js +14 -9
  313. package/dist/cli/handlers/task-handler.js +21 -1
  314. package/dist/coordination/handlers/code-intelligence-handlers.js +14 -2
  315. package/dist/coordination/handlers/coverage-collection.js +9 -10
  316. package/dist/coordination/handlers/coverage-handlers.js +21 -3
  317. package/dist/coordination/handlers/coverage-runner.d.ts +2 -1
  318. package/dist/coordination/handlers/coverage-runner.js +9 -2
  319. package/dist/coordination/handlers/coverage-target.d.ts +13 -3
  320. package/dist/coordination/handlers/coverage-target.js +224 -7
  321. package/dist/coordination/handlers/handler-types.d.ts +2 -0
  322. package/dist/coordination/handlers/test-execution-handlers.js +32 -5
  323. package/dist/coordination/index.d.ts +2 -2
  324. package/dist/coordination/index.js +1 -1
  325. package/dist/coordination/protocols/learning-consolidation-archive.d.ts +39 -0
  326. package/dist/coordination/protocols/learning-consolidation-archive.js +57 -0
  327. package/dist/coordination/protocols/learning-consolidation.d.ts +38 -3
  328. package/dist/coordination/protocols/learning-consolidation.js +128 -50
  329. package/dist/coordination/queen-coordinator.d.ts +12 -1
  330. package/dist/coordination/queen-coordinator.js +24 -1
  331. package/dist/coordination/queen-event-handlers.js +2 -1
  332. package/dist/coordination/queen-lifecycle.js +9 -0
  333. package/dist/coordination/queen-task-management.js +113 -40
  334. package/dist/coordination/queen-types.d.ts +10 -0
  335. package/dist/coordination/queen-types.js +8 -0
  336. package/dist/coordination/task-dag/dag-algorithms.d.ts +33 -0
  337. package/dist/coordination/task-dag/dag-algorithms.js +162 -0
  338. package/dist/coordination/task-dag/dag-obligations.d.ts +21 -0
  339. package/dist/coordination/task-dag/dag-obligations.js +83 -0
  340. package/dist/coordination/task-dag/dag.d.ts +69 -19
  341. package/dist/coordination/task-dag/dag.js +215 -269
  342. package/dist/coordination/task-dag/index.d.ts +12 -4
  343. package/dist/coordination/task-dag/index.js +11 -3
  344. package/dist/coordination/task-dag/prerequisite-ledger.d.ts +84 -0
  345. package/dist/coordination/task-dag/prerequisite-ledger.js +252 -0
  346. package/dist/coordination/task-dag/scheduler.d.ts +19 -9
  347. package/dist/coordination/task-dag/scheduler.js +36 -12
  348. package/dist/coordination/task-dag/types.d.ts +160 -1
  349. package/dist/coordination/task-dag/types.js +2 -1
  350. package/dist/coordination/task-executability.d.ts +18 -0
  351. package/dist/coordination/task-executability.js +31 -0
  352. package/dist/coordination/task-executor.d.ts +1 -0
  353. package/dist/coordination/task-executor.js +5 -0
  354. package/dist/domains/code-intelligence/coordinator.js +35 -9
  355. package/dist/domains/code-intelligence/index-path-guard.d.ts +49 -0
  356. package/dist/domains/code-intelligence/index-path-guard.js +125 -0
  357. package/dist/domains/code-intelligence/interfaces.d.ts +12 -0
  358. package/dist/domains/code-intelligence/services/knowledge-graph.d.ts +6 -0
  359. package/dist/domains/code-intelligence/services/knowledge-graph.js +42 -5
  360. package/dist/domains/contract-testing/coordinator.js +3 -1
  361. package/dist/domains/defect-intelligence/services/defect-predictor.js +4 -2
  362. package/dist/domains/learning-optimization/active-patterns.d.ts +12 -12
  363. package/dist/domains/learning-optimization/active-patterns.js +15 -12
  364. package/dist/domains/learning-optimization/coordinator-helpers.js +2 -3
  365. package/dist/domains/learning-optimization/coordinator.d.ts +0 -3
  366. package/dist/domains/learning-optimization/coordinator.js +43 -102
  367. package/dist/domains/learning-optimization/index.d.ts +1 -1
  368. package/dist/domains/learning-optimization/interfaces.d.ts +56 -4
  369. package/dist/domains/learning-optimization/plugin.js +11 -1
  370. package/dist/domains/learning-optimization/reward-source.d.ts +37 -0
  371. package/dist/domains/learning-optimization/reward-source.js +58 -0
  372. package/dist/domains/learning-optimization/services/learning-coordinator.d.ts +4 -4
  373. package/dist/domains/learning-optimization/services/learning-coordinator.js +59 -23
  374. package/dist/domains/learning-optimization/services/metrics-optimizer.d.ts +14 -4
  375. package/dist/domains/learning-optimization/services/metrics-optimizer.js +129 -63
  376. package/dist/domains/learning-optimization/services/transfer-specialist.js +25 -15
  377. package/dist/domains/test-execution/interfaces.d.ts +16 -0
  378. package/dist/domains/test-execution/services/runner-test-cases.d.ts +21 -0
  379. package/dist/domains/test-execution/services/runner-test-cases.js +69 -0
  380. package/dist/domains/test-execution/services/test-executor.d.ts +5 -0
  381. package/dist/domains/test-execution/services/test-executor.js +24 -2
  382. package/dist/init/fleet-integration.js +2 -0
  383. package/dist/init/init-wizard-steps.js +2 -0
  384. package/dist/init/phases/06-code-intelligence.js +2 -0
  385. package/dist/init/phases/10-workers.js +2 -1
  386. package/dist/kernel/anti-drift-middleware.d.ts +44 -5
  387. package/dist/kernel/anti-drift-middleware.js +147 -11
  388. package/dist/kernel/interfaces.d.ts +5 -0
  389. package/dist/learning/dream/dream-insights-pruner.d.ts +18 -4
  390. package/dist/learning/dream/dream-insights-pruner.js +99 -11
  391. package/dist/learning/skill-validation-learner.d.ts +2 -0
  392. package/dist/learning/skill-validation-learner.js +29 -21
  393. package/dist/mcp/background-workers.js +8 -2
  394. package/dist/mcp/bundle.js +507 -483
  395. package/dist/mcp/handlers/domain-handler-configs.d.ts +14 -0
  396. package/dist/mcp/handlers/domain-handler-configs.js +68 -30
  397. package/dist/mcp/handlers/handler-factory.js +1 -0
  398. package/dist/mcp/handlers/task-handlers.js +37 -1
  399. package/dist/mcp/metrics/metrics-collector.d.ts +11 -9
  400. package/dist/mcp/metrics/metrics-collector.js +13 -26
  401. package/dist/mcp/protocol-server.js +8 -3
  402. package/dist/mcp/tools/learning-optimization/optimize.d.ts +34 -3
  403. package/dist/mcp/tools/learning-optimization/optimize.js +106 -70
  404. package/dist/memory/crdt/lww-register.js +11 -1
  405. package/dist/routing/calibration/ema-calibrator.js +3 -1
  406. package/dist/shared/base-domain-plugin.d.ts +4 -0
  407. package/dist/shared/base-domain-plugin.js +6 -0
  408. package/dist/shared/llm/cache.js +4 -1
  409. package/dist/shared/security/compliance-patterns.js +3 -1
  410. package/dist/shared/test-runner-process.d.ts +26 -0
  411. package/dist/shared/test-runner-process.js +91 -0
  412. package/dist/shared/types/index.d.ts +9 -0
  413. package/dist/shared/types/index.js +13 -0
  414. package/dist/shared/utils/namespaced-search.d.ts +42 -0
  415. package/dist/shared/utils/namespaced-search.js +53 -0
  416. package/dist/strange-loop/infra-healing/infra-action-executor.js +7 -3
  417. package/dist/strange-loop/infra-healing/infra-healing-orchestrator.js +10 -9
  418. package/dist/workers/daemon.d.ts +2 -0
  419. package/dist/workers/daemon.js +10 -5
  420. package/dist/workers/namespaced-keys.d.ts +4 -7
  421. package/dist/workers/namespaced-keys.js +4 -15
  422. package/dist/workers/quality-daemon/ci-monitor.js +9 -5
  423. package/dist/workers/worker-env.d.ts +16 -8
  424. package/dist/workers/worker-env.js +25 -12
  425. package/dist/workers/worker-manager.js +4 -0
  426. package/dist/workers/workers/learning-consolidation.d.ts +1 -1
  427. package/dist/workers/workers/learning-consolidation.js +11 -8
  428. package/package.json +1 -1
  429. package/dist/cli/chunks/adapter-FC4EY447.js +0 -2
  430. package/dist/cli/chunks/aqe-learning-engine-AUAL6UBL.js +0 -2
  431. package/dist/cli/chunks/base-2XML4WH7.js +0 -2
  432. package/dist/cli/chunks/browser-workflow-2IFEUAAK.js +0 -2
  433. package/dist/cli/chunks/chunk-6CKTLVYV.js +0 -2
  434. package/dist/cli/chunks/chunk-I4U7YCXG.js +0 -180
  435. package/dist/cli/chunks/chunk-LZWBUVCK.js +0 -5
  436. package/dist/cli/chunks/chunk-X6VYQVUM.js +0 -2
  437. package/dist/cli/chunks/chunk-YTYS2XSY.js +0 -2
  438. package/dist/cli/chunks/chunk-Z3LDUPLQ.js +0 -6
  439. package/dist/cli/chunks/chunk-ZWMFKZEQ.js +0 -3
  440. package/dist/cli/chunks/client-RFUSQRUZ.js +0 -2
  441. package/dist/cli/chunks/core-handlers-ZC7QB432.js +0 -2
  442. package/dist/cli/chunks/cross-domain-router-GRBK7YFZ.js +0 -2
  443. package/dist/cli/chunks/daemon-JER6HE2J.js +0 -12
  444. package/dist/cli/chunks/dream-VALD726W.js +0 -2
  445. package/dist/cli/chunks/file-discovery-VL73ASNI.js +0 -2
  446. package/dist/cli/chunks/fleet-GJ66QFXK.js +0 -43
  447. package/dist/cli/chunks/heartbeat-scheduler-FSX7A3ZA.js +0 -2
  448. package/dist/cli/chunks/hnsw-adapter-UX2QT6RL.js +0 -2
  449. package/dist/cli/chunks/hnsw-index-WRDDAMXH.js +0 -2
  450. package/dist/cli/chunks/hybrid-backend-O67NGIB5.js +0 -2
  451. package/dist/cli/chunks/impact-analyzer-6VXWWYWM.js +0 -2
  452. package/dist/cli/chunks/init-wizard-VH34J4TL.js +0 -2
  453. package/dist/cli/chunks/kernel-KJD24NO7.js +0 -2
  454. package/dist/cli/chunks/knowledge-graph-343O2HEZ.js +0 -2
  455. package/dist/cli/chunks/llm-router-service-2M4BT2AO.js +0 -2
  456. package/dist/cli/chunks/load-test-OTQ2JQ5F.js +0 -2
  457. package/dist/cli/chunks/memory-backend-4QSNRRV6.js +0 -2
  458. package/dist/cli/chunks/memory-handlers-YFFYRSM6.js +0 -2
  459. package/dist/cli/chunks/pattern-null-store-5USH5MNR.js +0 -2
  460. package/dist/cli/chunks/project-root-SRTA6TBL.js +0 -2
  461. package/dist/cli/chunks/protocol-executor-4WYPCNBS.js +0 -2
  462. package/dist/cli/chunks/qe-reasoning-bank-I4D6SFS4.js +0 -2
  463. package/dist/cli/chunks/queen-coordinator-24UMTZTE.js +0 -2
  464. package/dist/cli/chunks/router-AUD4GATI.js +0 -2
  465. package/dist/cli/chunks/routing-feedback-2FE6SIKQ.js +0 -2
  466. package/dist/cli/chunks/rvf-dual-writer-P5LEUF25.js +0 -2
  467. package/dist/cli/chunks/rvf-migration-adapter-ZCYD5YJS.js +0 -2
  468. package/dist/cli/chunks/rvf-native-adapter-QGV6BW2W.js +0 -2
  469. package/dist/cli/chunks/safe-db-Q6JUKG2A.js +0 -2
  470. package/dist/cli/chunks/schedule-44OSMGE5.js +0 -2
  471. package/dist/cli/chunks/scheduler-V3HO2QQT.js +0 -2
  472. package/dist/cli/chunks/sqlite-persistence-N5T7DWMR.js +0 -2
  473. package/dist/cli/chunks/task-handlers-FH6DNTHW.js +0 -9
  474. package/dist/cli/chunks/unified-memory-RQ3Q4CU3.js +0 -2
  475. package/dist/cli/chunks/unified-memory-hnsw-ZOP5FEYX.js +0 -2
  476. package/dist/cli/chunks/unified-persistence-72OCJJKK.js +0 -2
  477. package/dist/cli/chunks/visual-security-7F5UV23J.js +0 -2
  478. package/dist/cli/chunks/witness-chain-KZ57QUFE.js +0 -2
  479. package/dist/cli/chunks/workflow-orchestrator-ZNWEUYBN.js +0 -2
@@ -0,0 +1,5 @@
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.9");process.exit(0)}
2
+ import{a as O}from"./chunk-4URT6JO2.js";import{a as F}from"./chunk-HAROIAJE.js";import{a as W,b as _,c as P,e as B}from"./chunk-OG2UI6A3.js";import{b as N,d as j}from"./chunk-4V27J6YN.js";var G=new Set(["false","0","off","no"]),J=new Set([...G,"disabled","disable","none","never"]),K=30,E=36500;function ge(l=process.env){let e=l.AQE_WORKERS_ENABLED;return e===void 0?!0:!G.has(e.trim().toLowerCase())}function fe(l=process.env){let e=l.AQE_DISABLED_WORKERS;if(!e)return[];let t=e.split(",").map(i=>i.trim().toLowerCase()).filter(i=>i.length>0);return Array.from(new Set(t))}function ye(l=process.env){let e=l.AQE_DREAM_INSIGHTS_RETENTION_DAYS;if(e===void 0||e.trim()==="")return{retentionDays:K};let t=e.trim().toLowerCase();if(J.has(t))return{retentionDays:null};if(/^\d+$/.test(t)){let i=Number(t);if(i>=1&&i<=E)return{retentionDays:i}}return{retentionDays:null,warning:`Invalid AQE_DREAM_INSIGHTS_RETENTION_DAYS=${JSON.stringify(e)}; expected a whole number of days (1-${E}), 0 or "off". The dream_insights retention sweep is off until this is fixed; nothing is deleted.`}}var x="quality-daemon",R=class{constructor(e){this.backend=e}backend;async get(e,t){return this.backend.kvGet(e,t?.namespace??x)}async set(e,t){await this.backend.kvSet(e,t,x)}async search(e,t,i){return this.backend.kvSearch(e,i?.namespace??x,t)}};import{cpus as de,freemem as he,totalmem as me,loadavg as pe}from"os";var p=class{queues={now:[],next:[],later:[]};_maxSize;constructor(e=1e3){this._maxSize=e}enqueue(e){return this.size>=this._maxSize&&(this.pruneExpired(),this.size>=this._maxSize)?!1:(this.queues[e.priority].push(e),!0)}dequeue(){let e=Date.now();for(let t of["now","next","later"]){let i=this.queues[t];for(;i.length>0;){let r=i.shift();if(!(r.ttlMs&&e-r.createdAt>r.ttlMs))return r}}}peek(){let e=Date.now();for(let t of["now","next","later"]){let i=this.queues[t];for(let r of i)if(!r.ttlMs||e-r.createdAt<=r.ttlMs)return r}}drainPriority(e){let t=this.queues[e].splice(0),i=Date.now();return t.filter(r=>!r.ttlMs||i-r.createdAt<=r.ttlMs)}pruneExpired(){let e=0,t=Date.now();for(let i of["now","next","later"]){let r=this.queues[i].length;this.queues[i]=this.queues[i].filter(o=>!o.ttlMs||t-o.createdAt<=o.ttlMs),e+=r-this.queues[i].length}return e}get size(){return this.queues.now.length+this.queues.next.length+this.queues.later.length}get depths(){return{now:this.queues.now.length,next:this.queues.next.length,later:this.queues.later.length}}get isEmpty(){return this.size===0}clear(){this.queues.now=[],this.queues.next=[],this.queues.later=[]}};import{watch as V}from"fs";import{execFile as Y}from"child_process";import{promisify as X}from"util";import{resolve as Q,join as Z}from"path";import{existsSync as ee,readFileSync as te}from"fs";var I=X(Y),ie={repoRoot:process.cwd(),debounceMs:500,maxChangedFiles:200,pollIntervalMs:5e3},g=class{constructor(e,t){this.queue=e;this.options={...ie,...t}}queue;watcher;pollTimer;options;lastKnownHeads=new Map;debounceTimer;_running=!1;_polling=!1;get running(){return this._running}async start(){if(this._running)return;let e=Q(this.options.repoRoot,".git","refs","heads");if(!ee(e))throw new Error(`Git refs directory not found: ${e}`);await this.snapshotHeads(),process.platform==="darwin"||process.platform==="win32"?this.watcher=V(e,{recursive:!0},(i,r)=>{r&&this.handleRefChange(r)}):(this.pollTimer=setInterval(()=>{this.poll().catch(i=>{console.debug("[GitWatcher] Poll error:",i)})},this.options.pollIntervalMs),this.pollTimer.unref?.()),this._running=!0}stop(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=void 0),this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=void 0),this.watcher&&(this.watcher.close(),this.watcher=void 0),this._running=!1}async poll(){if(this._polling)return[];this._polling=!0;let e=[];try{let{stdout:t}=await I("git",["for-each-ref","--format=%(refname:short) %(objectname:short)","refs/heads/"],{cwd:this.options.repoRoot});for(let i of t.trim().split(`
3
+ `)){if(!i)continue;let[r,o]=i.split(" "),n=this.lastKnownHeads.get(r);n&&n!==o&&(e.push(r),await this.enqueueCommitAnalysis(r,o)),this.lastKnownHeads.set(r,o)}}catch{}finally{this._polling=!1}return e}handleRefChange(e){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.processRefChange(e).catch(t=>{console.debug("[GitWatcher] Error processing ref change:",t)})},this.options.debounceMs)}async processRefChange(e){let t=e.replace(/\\/g,"/"),i=Q(this.options.repoRoot,".git","refs","heads"),r=Z(i,e),o;try{o=te(r,"utf-8").trim()}catch{return}this.lastKnownHeads.get(t)!==o&&(this.lastKnownHeads.set(t,o),await this.enqueueCommitAnalysis(t,o))}async enqueueCommitAnalysis(e,t){if(F(t,"commit hash"))return;let i=[];try{let{stdout:n}=await I("git",["diff-tree","--no-commit-id","--name-only","-r",t],{cwd:this.options.repoRoot});i=n.trim().split(`
4
+ `).filter(Boolean).slice(0,this.options.maxChangedFiles)}catch{}let r={type:"git_commit",branch:e,commitHash:t,changedFiles:i},o={id:`git-${t}-${Date.now()}`,priority:"next",payload:r,createdAt:Date.now(),source:"git-watcher",ttlMs:300*1e3};this.queue.enqueue(o)}async snapshotHeads(){try{let{stdout:e}=await I("git",["for-each-ref","--format=%(refname:short) %(objectname:short)","refs/heads/"],{cwd:this.options.repoRoot});for(let t of e.trim().split(`
5
+ `)){if(!t)continue;let[i,r]=t.split(" ");this.lastKnownHeads.set(i,r)}}catch{}}};function M(l,e){return l===null||e===null?0:l-e}var re={regressionThreshold:2,gapThreshold:60,memoryPrefix:"quality-daemon:coverage"},f=class{constructor(e,t){this.queue=e;this.options={...re,...t}}queue;options;async analyze(e,t,i){let r=await t.get(`${this.options.memoryPrefix}:snapshot`);if(await t.set(`${this.options.memoryPrefix}:snapshot`,e),!r)return{regressionDetected:!1,overallDelta:{line:0,branch:0,function:0,statement:0},affectedFiles:[],newGaps:[]};let o=r,n={line:e.overall.line-o.overall.line,branch:M(e.overall.branch,o.overall.branch??null),function:M(e.overall.function,o.overall.function??null),statement:M(e.overall.statement,o.overall.statement??null)},s=n.line<-this.options.regressionThreshold||(n.branch??0)<-this.options.regressionThreshold,a=i??Object.keys(e.files),c=[],d=[];for(let h of a){let u=e.files[h],m=o.files[h];if(!u)continue;let A=m?u.line-m.line:0,q=m?u.branch-m.branch:0,D=m?u.uncoveredLines.filter(T=>!m.uncoveredLines.includes(T)):u.uncoveredLines;if((A!==0||q!==0||D.length>0)&&c.push({file:h,lineDelta:A,branchDelta:q,newUncoveredLines:D}),u.line<this.options.gapThreshold){let T=this.computeRiskScore(u,D.length);d.push({file:h,uncoveredLines:u.uncoveredLines,currentCoverage:u.line,riskScore:T})}}return(s||d.length>0)&&this.enqueueTestSuggestion(e,o,d),await t.set(`${this.options.memoryPrefix}:delta`,{timestamp:Date.now(),overallDelta:n,regressionDetected:s,affectedFileCount:c.length,gapCount:d.length}),{regressionDetected:s,overallDelta:n,affectedFiles:c,newGaps:d}}async buildSnapshot(e){let t=await e.get("coverage:latest"),i=O(t);if(i)return{timestamp:Date.now(),overall:{line:i.line,branch:i.branch,function:i.function,statement:i.statement},files:t&&typeof t.files=="object"?t.files:{}}}computeRiskScore(e,t){let r=1-Math.min(100,Math.max(0,e.line))/100,o=Math.min(t/50,1);return Math.min(1,r*.6+o*.4)}enqueueTestSuggestion(e,t,i){let r={type:"coverage_delta",previousSnapshot:`snapshot-${t.timestamp}`,currentSnapshot:`snapshot-${e.timestamp}`},o={id:`coverage-delta-${Date.now()}`,priority:i.some(n=>n.riskScore>.8)?"now":"next",payload:r,createdAt:Date.now(),source:"coverage-delta",ttlMs:600*1e3};this.queue.enqueue(o)}};B();import{execFile as oe}from"child_process";import{promisify as ne}from"util";var se=ne(oe),ae={runsPerWorkflow:10,flakyThreshold:3,repo:""},y=class{constructor(e,t){this.queue=e;this.options={...ae,...t}}queue;options;async check(){let e=await this.fetchRecentRuns(),t=this.groupByWorkflow(e),i=[],r=[],o=0;for(let[s,a]of Object.entries(t)){let c=a.filter(m=>m.conclusion==="failure").length,d=a.length>0?(a.length-c)/a.length*100:100,h=this.countConsecutiveFailures(a),u=a[0]?.conclusion??"unknown";u==="failure"&&o++,h>=this.options.flakyThreshold&&(r.push(s),this.enqueueFailureAlert(s,a[0])),i.push({name:s,recentRuns:a.length,failedRuns:c,successRate:Math.round(d*10)/10,lastConclusion:u,consecutiveFailures:h})}let n=this.calculateHealthScore(i);return{timestamp:Date.now(),workflows:i,failingWorkflows:o,flakyWorkflows:r,healthScore:n}}async fetchRecentRuns(){try{let e=["run","list","--limit",String(this.options.runsPerWorkflow*5),"--json","name,status,conclusion,headBranch,number,databaseId,createdAt"];this.options.repo&&e.push("--repo",this.options.repo);let{stdout:t}=await se("gh",e,{timeout:15e3});return JSON.parse(t).map(r=>({name:r.name,status:r.status,conclusion:r.conclusion??"pending",headBranch:r.headBranch,runNumber:r.number,databaseId:r.databaseId,createdAt:r.createdAt}))}catch{return[]}}groupByWorkflow(e){let t=W();for(let i of e){let r=_(t,i.name);r||(r=[],P(t,i.name,r)),r.push(i)}for(let i of Object.keys(t))P(t,i,_(t,i).slice(0,this.options.runsPerWorkflow));return t}countConsecutiveFailures(e){let t=0;for(let i of e)if(i.conclusion==="failure")t++;else break;return t}calculateHealthScore(e){if(e.length===0)return 100;let t=e.reduce((i,r)=>i+r.successRate,0)/e.length;return Math.round(t)}enqueueFailureAlert(e,t){let i={type:"ci_failure",workflowName:e,runId:t.databaseId,conclusion:t.conclusion},r={id:`ci-failure-${e}-${Date.now()}`,priority:"now",payload:i,createdAt:Date.now(),source:"ci-monitor",ttlMs:1800*1e3};this.queue.enqueue(r)}};var le={memoryPrefix:"quality-daemon:suggestions",maxSuggestions:100,minRiskScore:.3},v=class{options;constructor(e){this.options={...le,...e}}async suggest(e,t,i){let r=[],o=e.filter(s=>s.riskScore>=this.options.minRiskScore);for(let s of o){let a=t.includes(s.file),c=this.determinePriority(s,a),d=this.determineTestType(s.file),h=this.estimateEffort(s);r.push({id:`suggestion-${Date.now()}-${r.length}`,file:s.file,uncoveredLines:s.uncoveredLines.slice(0,50),suggestedTestType:d,description:this.generateDescription(s,d),priority:c,estimatedEffort:h,createdAt:Date.now(),status:"pending"})}r.sort((s,a)=>{let c={high:0,medium:1,low:2};return c[s.priority]-c[a.priority]});let n=r.slice(0,this.options.maxSuggestions);return await this.storeSuggestions(n,i),n}async getPending(e){return(await e.get(`${this.options.memoryPrefix}:list`)??[]).filter(i=>i.status==="pending")}async updateStatus(e,t,i){let r=await i.get(`${this.options.memoryPrefix}:list`);if(!r)return!1;let o=r.findIndex(s=>s.id===e);if(o===-1)return!1;let n=r.map((s,a)=>a===o?{...s,status:t}:s);return await i.set(`${this.options.memoryPrefix}:list`,n),!0}determinePriority(e,t){return e.riskScore>.8?"high":t||e.riskScore>.5?"medium":"low"}determineTestType(e){return e.includes("/api/")||e.includes("/routes/")||e.includes("/handlers/")?"integration":e.includes("/e2e/")||e.includes("/pages/")||e.includes("/views/")?"e2e":"unit"}estimateEffort(e){return e.uncoveredLines.length<=10?"small":e.uncoveredLines.length<=50?"medium":"large"}generateDescription(e,t){let i=e.uncoveredLines.length,r=Math.round(e.currentCoverage);return`Add ${t} tests for ${e.file} (${i} uncovered lines, ${r}% coverage, risk ${(e.riskScore*100).toFixed(0)}%)`}async storeSuggestions(e,t){let o=[...(await t.get(`${this.options.memoryPrefix}:list`)??[]).filter(n=>n.status!=="pending"),...e].slice(-this.options.maxSuggestions);await t.set(`${this.options.memoryPrefix}:list`,o),await t.set(`${this.options.memoryPrefix}:count`,{pending:e.length,total:o.length,lastUpdated:Date.now()})}};var ue={memoryPrefix:"quality-daemon:nightly",maxEntryAge:6048e5,nightlyHour:2},w=class{constructor(e,t){this.queue=e;this.options={...ue,...t}}queue;options;lastRunDate;shouldRun(){let e=new Date,t=e.toISOString().split("T")[0];return this.lastRunDate===t?!1:e.getHours()>=this.options.nightlyHour}scheduleIfDue(){if(!this.shouldRun())return!1;let e={type:"nightly",tasks:["consolidate_patterns","prune_expired","generate_report"]},t={id:`nightly-${Date.now()}`,priority:"later",payload:e,createdAt:Date.now(),source:"nightly-consolidation",ttlMs:720*60*1e3};return this.queue.enqueue(t)}async execute(e,t){let i=Date.now(),r=new Date().toISOString().split("T")[0],o=await this.consolidatePatterns(e),n=await this.pruneExpired(e),s=this.generateReport(r,t);await e.set(`${this.options.memoryPrefix}:report:${r}`,s),this.lastRunDate=r;let a={timestamp:Date.now(),patternsConsolidated:o,entriesPruned:n,reportGenerated:!0,durationMs:Date.now()-i};return await e.set(`${this.options.memoryPrefix}:last-result`,a),a}async getLastResult(e){return e.get(`${this.options.memoryPrefix}:last-result`)}async consolidatePatterns(e){let t=await e.search("quality-daemon:*"),i=0;return await e.get("quality-daemon:suggestions:count")&&i++,await e.get("quality-daemon:coverage:delta")&&i++,i}async pruneExpired(e){let t=await e.search("quality-daemon:*"),i=0,r=Date.now();for(let o of t){if(o.endsWith(":snapshot")||o.endsWith(":list"))continue;let n=await e.get(o);n&&typeof n.timestamp=="number"&&r-n.timestamp>this.options.maxEntryAge&&(await e.set(o,{pruned:!0,prunedAt:r}),i++)}return i}generateReport(e,t){return{date:e,coverageHealth:t.coverageHealth??0,ciHealth:t.ciHealth??0,commitsAnalyzed:t.commitsAnalyzed??0,suggestionsGenerated:t.suggestionsGenerated??0,notificationsSent:t.notificationsSent??0,queueDepthAvg:t.queueDepthAvg??0,daemonUptime:t.uptimeSeconds??0}}};j();import{writeFileSync as $,mkdirSync as H,readdirSync as C,readFileSync as L,unlinkSync as U}from"fs";import{join as b}from"path";var ce={maxNotifications:200},k=class{notificationsDir;maxNotifications;webhookUrl;urlValidator;_sentCount=0;constructor(e){this.notificationsDir=e?.notificationsDir??N("notifications"),this.maxNotifications=e?.maxNotifications??ce.maxNotifications,this.webhookUrl=e?.webhookUrl,this.urlValidator=e?.urlValidator}get sentCount(){return this._sentCount}initialize(){H(this.notificationsDir,{recursive:!0})}async send(e){let t={...e,id:`notif-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,timestamp:Date.now(),read:!1};return this.writeToFile(t),this.webhookUrl&&await this.sendWebhook(t),this._sentCount++,this.pruneOldNotifications(),t}list(e){let t=e?.limit??50;try{let i=C(this.notificationsDir).filter(o=>o.endsWith(".json")).sort().reverse(),r=[];for(let o of i){if(r.length>=t)break;try{let n=L(b(this.notificationsDir,o),"utf-8"),s=JSON.parse(n);if(e?.unreadOnly&&s.read||e?.type&&s.type!==e.type)continue;r.push(s)}catch{}}return r}catch{return[]}}markRead(e){try{let t=C(this.notificationsDir).filter(n=>n.endsWith(`-${e}.json`));if(t.length===0)return!1;let i=b(this.notificationsDir,t[0]),o={...JSON.parse(L(i,"utf-8")),read:!0};return $(i,JSON.stringify(o,null,2)),!0}catch{return!1}}clear(){try{let e=C(this.notificationsDir).filter(t=>t.endsWith(".json"));for(let t of e)U(b(this.notificationsDir,t));return e.length}catch{return 0}}writeToFile(e){try{H(this.notificationsDir,{recursive:!0});let t=`${e.timestamp}-${e.id}.json`,i=b(this.notificationsDir,t);$(i,JSON.stringify(e,null,2))}catch(t){console.debug("[NotificationService] Failed to write notification:",t)}}async sendWebhook(e){if(this.webhookUrl){if(this.urlValidator&&!this.urlValidator(this.webhookUrl)){console.warn("[NotificationService] Webhook URL blocked by SSRF guard:",this.webhookUrl);return}try{let t=await fetch(this.webhookUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(5e3)});t.ok||console.debug(`[NotificationService] Webhook returned ${t.status}`)}catch(t){console.debug("[NotificationService] Webhook delivery failed:",t)}}}pruneOldNotifications(){try{let e=C(this.notificationsDir).filter(i=>i.endsWith(".json")).sort();if(e.length<=this.maxNotifications)return;let t=e.slice(0,e.length-this.maxNotifications);for(let i of t)U(b(this.notificationsDir,i))}catch{}}};var S={tickIntervalMs:3e4,ciPollIntervalMs:5*6e4,coverageCheckIntervalMs:2*6e4,cpuThreshold:.7,memoryThreshold:.8},z=class{queue;gitWatcher;coverageDelta;ciMonitor;testSuggester;nightlyConsolidation;notificationService;tickTimer;_running=!1;_startedAt=0;_tickCount=0;_lastTickAt;_throttled=!1;_commitsAnalyzed=0;_suggestionsGenerated=0;_ciHealth=100;_coverageHealth=100;_lastCICheck;_lastCoverageCheck;_memory;config;constructor(e){this.config={tickIntervalMs:e?.tickIntervalMs??S.tickIntervalMs,ciPollIntervalMs:e?.ciPollIntervalMs??S.ciPollIntervalMs,coverageCheckIntervalMs:e?.coverageCheckIntervalMs??S.coverageCheckIntervalMs,cpuThreshold:e?.cpuThreshold??S.cpuThreshold,memoryThreshold:e?.memoryThreshold??S.memoryThreshold},this.queue=new p,this.gitWatcher=new g(this.queue,e?.git),this.coverageDelta=new f(this.queue,e?.coverage),this.ciMonitor=new y(this.queue,e?.ci),this.testSuggester=new v(e?.suggestions),this.nightlyConsolidation=new w(this.queue,e?.nightly),this.notificationService=new k(e?.notifications)}get running(){return this._running}async start(e){this._running||(this._memory=e,this._running=!0,this._startedAt=Date.now(),this.notificationService.initialize(),await this.gitWatcher.start().catch(t=>{console.debug("[QualityDaemon] Git watcher failed to start:",t)}),this.scheduleTick())}async stop(){this._running&&(this._running=!1,this.tickTimer&&(clearTimeout(this.tickTimer),this.tickTimer=void 0),this.gitWatcher.stop(),this._memory&&await this._memory.set("quality-daemon:state",{stoppedAt:Date.now(),tickCount:this._tickCount,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated}))}getStatus(){return{running:this._running,uptimeSeconds:this._running?Math.floor((Date.now()-this._startedAt)/1e3):0,tickCount:this._tickCount,queueDepth:this.queue.depths,lastTickAt:this._lastTickAt,throttled:this._throttled,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated,notificationsSent:this.notificationService.sentCount,ciHealth:this._ciHealth,coverageHealth:this._coverageHealth,lastCICheck:this._lastCICheck,lastCoverageCheck:this._lastCoverageCheck}}scheduleTick(){this._running&&(this.tickTimer=setTimeout(()=>this.tick(),this.config.tickIntervalMs),this.tickTimer.unref?.())}async tick(){if(!(!this._running||!this._memory)){if(this._tickCount++,this._lastTickAt=Date.now(),this._throttled=this.isResourceConstrained(),this._throttled){await this.processNowItems(this._memory),this.scheduleTick();return}await this.processQueue(this._memory),await this.runPeriodicChecks(this._memory),this.nightlyConsolidation.scheduleIfDue(),this.queue.pruneExpired(),this.scheduleTick()}}async processQueue(e){let t=0,i=10;for(;t<i&&!this.queue.isEmpty;){let r=this.queue.dequeue();if(!r)break;await this.handleQueueItem(r,e),t++}}async processNowItems(e){let t=this.queue.drainPriority("now");for(let i of t)await this.handleQueueItem(i,e)}async handleQueueItem(e,t){let i=e.payload;switch(i.type){case"git_commit":{this._commitsAnalyzed++;let r=await this.coverageDelta.buildSnapshot(t);if(r){let o=await this.coverageDelta.analyze(r,t,i.changedFiles);if(o.regressionDetected&&await this.notificationService.send({type:"coverage_drop",title:"Coverage Regression Detected",message:`Line coverage delta: ${o.overallDelta.line.toFixed(1)}% (${o.affectedFiles.length} files affected)`,severity:"high",metadata:{delta:o.overallDelta,commit:i.commitHash}}),o.newGaps.length>0){let n=await this.testSuggester.suggest(o.newGaps,i.changedFiles,t);this._suggestionsGenerated+=n.length,n.length>0&&await this.notificationService.send({type:"suggestion_available",title:"New Test Suggestions Available",message:`${n.length} test suggestions generated for uncovered code`,severity:"info",metadata:{count:n.length}})}}break}case"coverage_delta":{let r=await this.testSuggester.getPending(t);r.length>0&&await this.notificationService.send({type:"suggestion_available",title:"Test Suggestions Pending",message:`${r.length} test suggestions awaiting review`,severity:"info",metadata:{count:r.length}});break}case"gate_failure":await this.notificationService.send({type:"gate_failure",title:`Quality Gate Failed: ${i.gateName}`,message:`Score ${i.score} below threshold ${i.threshold}`,severity:"critical",metadata:{gate:i.gateName,score:i.score,threshold:i.threshold}});break;case"ci_failure":await this.notificationService.send({type:"ci_failure",title:`CI Failure: ${i.workflowName}`,message:`Workflow ${i.workflowName} run #${i.runId} concluded: ${i.conclusion}`,severity:"high",metadata:{workflow:i.workflowName,runId:i.runId}});break;case"nightly":{let r={coverageHealth:this._coverageHealth,ciHealth:this._ciHealth,commitsAnalyzed:this._commitsAnalyzed,suggestionsGenerated:this._suggestionsGenerated,notificationsSent:this.notificationService.sentCount,queueDepthAvg:this.queue.size,uptimeSeconds:Math.floor((Date.now()-this._startedAt)/1e3)};await this.nightlyConsolidation.execute(t,r);break}default:console.warn("[QualityDaemon] Unhandled payload type:",i.type)}}async runPeriodicChecks(e){let t=Date.now();if(!this._lastCICheck||t-this._lastCICheck>=this.config.ciPollIntervalMs)try{let i=await this.ciMonitor.check();this._ciHealth=i.healthScore,this._lastCICheck=t,i.flakyWorkflows.length>0&&await this.notificationService.send({type:"flaky_detected",title:"Flaky Workflows Detected",message:`${i.flakyWorkflows.length} workflows showing repeated failures: ${i.flakyWorkflows.join(", ")}`,severity:"medium",metadata:{workflows:i.flakyWorkflows}})}catch{}if(!this._lastCoverageCheck||t-this._lastCoverageCheck>=this.config.coverageCheckIntervalMs)try{let i=await this.coverageDelta.buildSnapshot(e);if(i){let r=[i.overall.line,i.overall.branch,i.overall.function,i.overall.statement].filter(o=>typeof o=="number");this._coverageHealth=Math.round(r.reduce((o,n)=>o+n,0)/r.length),this._lastCoverageCheck=t}}catch{}}isResourceConstrained(){if(1-he()/me()>this.config.memoryThreshold)return!0;let t=de().length;return(t>0?pe()[0]/t:0)>this.config.cpuThreshold}};export{ge as a,fe as b,ye as c,R as d,z as e};
@@ -1,4 +1,4 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.8");process.exit(0)}
2
- import{b as M}from"./chunk-W5A36V3Z.js";import{i as D,j as x,k,m as h}from"./chunk-Z3LDUPLQ.js";import{c as y}from"./chunk-ZWMFKZEQ.js";import N from"chalk";import*as m from"fs";import*as d from"path";var T=["coverage/coverage-final.json","coverage/coverage-summary.json",".coverage/coverage-final.json"];function E(e){for(let t of T){let n=d.join(e,t);if(m.existsSync(n))try{let r=m.readFileSync(n,"utf-8"),a=JSON.parse(r);if(a.total&&a.total.lines)return w(a,e);let o=new Map;for(let s of y(r).files)o.set(s.path,s);return o.size>0?o:null}catch{continue}}return null}function w(e,t){let n=new Map;for(let[r,a]of Object.entries(e)){if(r==="total")continue;let o=a;n.set(r,{path:r,lines:{covered:o.lines.covered,total:o.lines.total},branches:{covered:o.branches.covered,total:o.branches.total},functions:{covered:o.functions.covered,total:o.functions.total},statements:{covered:o.statements.covered,total:o.statements.total},uncoveredLines:[],uncoveredBranches:[]})}return n.size>0?n:null}function j(e,t){let r=t.split(`
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.9");process.exit(0)}
2
+ import{b as M}from"./chunk-XOLDMK23.js";import{j as D,k as x,l as k,n as h}from"./chunk-AR2E4B7K.js";import{c as y}from"./chunk-5LAAZLUC.js";import N from"chalk";import*as m from"fs";import*as d from"path";var T=["coverage/coverage-final.json","coverage/coverage-summary.json",".coverage/coverage-final.json"];function E(e){for(let t of T){let n=d.join(e,t);if(m.existsSync(n))try{let r=m.readFileSync(n,"utf-8"),a=JSON.parse(r);if(a.total&&a.total.lines)return w(a,e);let o=new Map;for(let s of y(r).files)o.set(s.path,s);return o.size>0?o:null}catch{continue}}return null}function w(e,t){let n=new Map;for(let[r,a]of Object.entries(e)){if(r==="total")continue;let o=a;n.set(r,{path:r,lines:{covered:o.lines.covered,total:o.lines.total},branches:{covered:o.branches.covered,total:o.branches.total},functions:{covered:o.functions.covered,total:o.functions.total},statements:{covered:o.statements.covered,total:o.statements.total},uncoveredLines:[],uncoveredBranches:[]})}return n.size>0?n:null}function j(e,t){let r=t.split(`
3
3
  `).length,o=[e.replace(".ts",".test.ts").replace("/src/","/tests/"),e.replace(".ts",".spec.ts").replace("/src/","/tests/"),e.replace(".ts",".test.ts"),e.replace("/src/","/test/").replace(".ts",".test.ts")].some(g=>m.existsSync(g)),s=(t.match(/\bexport\b/g)||[]).length,i=(t.match(/\b(function|=>)\b/g)||[]).length,c=(t.match(/\b(if|switch|case|\?\?|\|\|)\b/g)||[]).length,l;if(o){let g=Math.min(c*.005,.15),b=Math.min(r*1e-4,.1);l=.85-g-b}else l=.2+(s>5?.1:0);l=Math.max(.05,Math.min(.95,l));let u=Math.floor(r*l),f=Math.max(i,1),C=Math.max(c,1),F=Math.floor(u*.7),S=Math.floor(f*l*.9),v=Array.from({length:r-u},(g,b)=>b+u+1);return{path:e,lines:{covered:u,total:r},branches:{covered:Math.min(F,C),total:C},functions:{covered:Math.min(S,f),total:f},statements:{covered:u,total:r},uncoveredLines:v,uncoveredBranches:v.slice(0,Math.floor(v.length/2))}}function p(e){let t=s=>e.reduce((i,c)=>i+s(c),0),n=(s,i)=>i>0?Math.round(s/i*100):0,r=t(s=>s.lines.total),a=t(s=>s.lines.covered),o=t(s=>s.statements.total);return{line:n(a,r),branch:n(t(s=>s.branches.covered),t(s=>s.branches.total)),function:n(t(s=>s.functions.covered),t(s=>s.functions.total)),statement:o>0?n(t(s=>s.statements.covered),o):n(a,r),files:e.length}}function R(e,t){let n=t||process.cwd(),r=E(n),a=[],o=[],s=!1;if(r&&r.size>0){s=!0;for(let i of e){let c=d.resolve(i),l=r.get(c)||r.get(i)||r.get(d.relative(n,c));l?a.push({...l,path:i}):o.push(i)}}else for(let i of e){let c=m.existsSync(i)?m.readFileSync(i,"utf-8"):"";a.push(j(i,c))}return{files:a,summary:p(a),instrumented:s,...o.length>0?{unmeasuredFiles:o}:{}}}var A=3,z="instrumented-report",O="static-estimation";async function I(e,t=n=>console.log(n)){let n=await D(e);if(n.status==="target-missing")return{kind:"no-data",reason:"target-missing",message:h("target-missing",e,null)};if(n.status==="evaluated"){let{evaluation:a,projectRoot:o}=n;if(a.status==="measured"){let s=a.files;return{kind:"data",data:{files:s,summary:p(s),instrumented:!0},projectRoot:o}}return{kind:"no-data",reason:a.reason,message:h(a.reason,e,o)}}let r=M(n.target,{includeTests:!1});return r.length===0?{kind:"no-sources"}:(t(N.gray(` Analyzing ${r.length} files...
4
4
  `)),{kind:"data",data:R(r,n.projectRoot),projectRoot:n.projectRoot})}function P(e){return{branch:e.files.some(t=>t.branches.total>0),function:e.files.some(t=>t.functions.total>0),statement:e.files.some(t=>t.statements.total>0)}}var L=e=>e==="target-missing"||e==="unreadable-report";function _(){return"UNMEASURED: no coverage report exists for this project, so these figures are a STATIC ESTIMATE derived from source shape \u2014 not measured coverage. No threshold verdict is given and nothing is stored as evidence. Run your tests with coverage first (e.g. `npm test -- --coverage`) and re-run."}async function G(e,t,n,r){let a=await I(t,r);if(a.kind==="no-sources")return a;if(a.kind==="no-data")return L(a.reason)?{kind:"error",reason:a.reason,message:a.message}:{kind:"unmeasured",reason:a.reason,message:a.message};let o=a.data,s=o.instrumented,i=await e.analyze({coverageData:o,threshold:n,includeFileDetails:!0,measured:s,...a.projectRoot?{projectRoot:a.projectRoot}:{}});if(!i.success||!i.value)return{kind:"analysis-failed",message:i.error?.message||"Coverage analysis failed"};let c=i.value;if(!s)return{kind:"estimate",data:o,summary:{...c.summary},message:_()};let l=P(o),u=x(c.summary,n,l);return{kind:"measured",data:o,collected:l,verdict:u,summary:{...c.summary,branch:l.branch?c.summary.branch:null,function:l.function?c.summary.function:null,statement:l.statement?c.summary.statement:null},recommendations:k(c.recommendations??[],u,n,l)}}function X(e,t){switch(e.kind){case"measured":{let{overall:n,meetsThreshold:r}=e.verdict;return r?n<t+5?2:0:1}case"estimate":case"unmeasured":return A;case"no-sources":return 0;default:return 1}}function $(e,t,n){let r={line:null,branch:null,function:null,statement:null};switch(e.kind){case"measured":return{summary:e.summary,meetsThreshold:e.verdict.meetsThreshold,threshold:t,recommendations:e.recommendations,measured:!0,estimated:!1,coverageMethod:z,branchDataCollected:e.collected.branch,functionDataCollected:e.collected.function,statementDataCollected:e.collected.statement,...e.data.unmeasuredFiles?.length?{unmeasuredFiles:e.data.unmeasuredFiles}:{}};case"estimate":return{summary:e.summary,meetsThreshold:null,threshold:t,measured:!1,estimated:!0,unmeasured:!0,coverageMethod:O,reason:"no-coverage-report",target:n,warning:e.message};case"unmeasured":case"error":return{summary:r,meetsThreshold:null,threshold:t,measured:!1,unmeasured:e.kind==="unmeasured",reason:e.reason,target:n,warning:e.message};case"analysis-failed":return{summary:r,meetsThreshold:null,threshold:t,measured:!1,target:n,error:e.message};case"no-sources":return{summary:r,meetsThreshold:null,threshold:t,measured:!1,target:n,warning:"No source files found"}}}export{A as a,I as b,G as c,X as d,$ as e};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.8");process.exit(0)}
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.9");process.exit(0)}
2
2
  var s={"test-generation":/test|spec|describe|it\(|expect|assert|mock|stub|fixture|tdd|bdd/i,"test-execution":/run|execute|parallel|retry|flaky|timeout|worker|orchestrat/i,"coverage-analysis":/coverage|branch|line|uncovered|gap|untested|percentage|sublinear/i,"quality-assessment":/quality|gate|deploy|readiness|metric|threshold|sla|score/i,"defect-intelligence":/defect|bug|predict|root.?cause|regression|failure|incident/i,"requirements-validation":/requirement|bdd|gherkin|testabil|accept|criteri|scenario/i,"code-intelligence":/semantic|knowledge|graph|ast|symbol|reference|impact|depend/i,"security-compliance":/vuln|cve|owasp|xss|sqli|injection|csrf|auth|secret|compliance|sast|dast/i,"contract-testing":/contract|pact|openapi|swagger|graphql|schema|endpoint|api/i,"visual-accessibility":/screenshot|visual|snapshot|pixel|percy|a11y|aria|wcag|screen.?reader|accessible|contrast/i,"chaos-resilience":/chaos|resilience|fault|inject|blast|recover|latency|failure|stress|load/i,"learning-optimization":/learn|pattern|optim|neural|embedding|vector|memory|adapt|train/i};function m(e){for(let[t,a]of Object.entries(s))if(a.test(e))return t;return null}function u(e){let t=[];for(let[a,n]of Object.entries(s))n.test(e)&&t.push(a);return t}function d(e){return e}function p(e){let t=Math.min(e.usageCount/100,1);return e.confidence*.3+t*.2+e.successRate*.5}var c=3,l=.7;function y(e,t,a=.4){let n=e.tier==="short-term"&&e.successfulUses>=c,r=e.successRate>=l&&e.confidence>=.6,i=t===void 0||t<a,o;return n?r?i||(o="coherence_violation"):o="low_quality":o="insufficient_usage",{meetsUsageCriteria:n,meetsQualityCriteria:r,meetsCoherenceCriteria:i,blockReason:o}}function f(e){let t=[];if(e.id||t.push("Pattern ID is required"),e.patternType||t.push("Pattern type is required"),e.qeDomain||t.push("QE domain is required"),e.name||t.push("Pattern name is required"),e.template?.content||t.push("Template content is required"),e.confidence!==void 0&&(e.confidence<0||e.confidence>1)&&t.push("Confidence must be between 0 and 1"),e.successRate!==void 0&&(e.successRate<0||e.successRate>1)&&t.push("Success rate must be between 0 and 1"),e.template?.variables){let a=new Set;for(let n of e.template.variables)a.has(n.name)&&t.push(`Duplicate variable name: ${n.name}`),a.add(n.name),e.template.content.includes(`{{${n.name}}}`)||t.push(`Variable ${n.name} not referenced in template`)}return{valid:t.length===0,errors:t}}function g(e,t){let a=e.content;for(let n of e.variables){let r=t[n.name]??n.defaultValue;if(n.required&&r===void 0)throw new Error(`Required variable ${n.name} not provided`);if(r!==void 0){let i=`{{${n.name}}}`,o=typeof r=="object"?JSON.stringify(r):String(r);a=a.split(i).join(o)}}return a}var b=Object.keys(s);export{m as a,u as b,d as c,p as d,c as e,l as f,y as g,f as h,g as i,b as j};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.8");process.exit(0)}
2
- import{o as K,s as ot}from"./chunk-7XGM7Q2N.js";import{a as G,d as at}from"./chunk-RG42LDOB.js";import{a as nt,b as it}from"./chunk-DKFSCJEF.js";import{a as rt}from"./chunk-X6VYQVUM.js";import{e as U}from"./chunk-7H3GNRNA.js";import{a as j,e as et}from"./chunk-J7FLNP5L.js";import{b as H,d as V,f as w}from"./chunk-K5R3WUJP.js";var Z={};V(Z,{DotProductAttention:()=>yt,FlashAttention:()=>ft,HyperbolicAttention:()=>At,LinearAttention:()=>vt,MoEAttention:()=>Et,MultiHeadAttention:()=>bt,RuvectorLayer:()=>ut,SonaEngine:()=>T,TensorCompress:()=>ht,default:()=>ct,differentiableSearch:()=>mt,getCompressionLevel:()=>pt,hierarchicalForward:()=>dt,init:()=>gt,pipeline:()=>Ft});import{createRequire as st}from"module";var lt,$,ct,ut,ht,mt,dt,pt,gt,ft,yt,bt,At,vt,Et,T,Ft,k=H(()=>{lt=st(import.meta.url),$=lt("@ruvector/sona"),ct=$,{RuvectorLayer:ut,TensorCompress:ht,differentiableSearch:mt,hierarchicalForward:dt,getCompressionLevel:pt,init:gt,FlashAttention:ft,DotProductAttention:yt,MultiHeadAttention:bt,HyperbolicAttention:At,LinearAttention:vt,MoEAttention:Et,SonaEngine:T,pipeline:Ft}=$||{}});var N={};V(N,{DotProductAttention:()=>zt,FlashAttention:()=>It,HyperbolicAttention:()=>_t,LinearAttention:()=>Ht,MoEAttention:()=>Vt,MultiHeadAttention:()=>qt,RuvectorLayer:()=>Qt,SonaEngine:()=>jt,TensorCompress:()=>Nt,default:()=>xt,differentiableSearch:()=>Ot,getCompressionLevel:()=>Wt,hierarchicalForward:()=>Dt,init:()=>Bt,pipeline:()=>Ut});import{createRequire as kt}from"module";var Rt,X,xt,Qt,Nt,Ot,Dt,Wt,Bt,It,zt,qt,_t,Ht,Vt,jt,Ut,O=H(()=>{Rt=kt(import.meta.url),X=Rt("@ruvector/attention"),xt=X,{RuvectorLayer:Qt,TensorCompress:Nt,differentiableSearch:Ot,hierarchicalForward:Dt,getCompressionLevel:Wt,init:Bt,FlashAttention:It,DotProductAttention:zt,MultiHeadAttention:qt,HyperbolicAttention:_t,LinearAttention:Ht,MoEAttention:Vt,SonaEngine:jt,pipeline:Ut}=X||{}});k();at();import{randomUUID as Ct}from"crypto";rt();import{createRequire as wt}from"module";var f=U.create("sona-three-loop"),S=wt(import.meta.url),M=null,J=!1;function St(){if(J)return M;J=!0;try{let l=S("@ruvector/learning-wasm"),t=S("fs"),e=S("path"),r=e.join(e.dirname(S.resolve("@ruvector/learning-wasm")),"ruvector_learning_wasm_bg.wasm");l.initSync({module:t.readFileSync(r)}),M=l,f.info("WASM MicroLoRA loaded from @ruvector/learning-wasm (6.4x faster than TS)")}catch{M=null,f.debug("@ruvector/learning-wasm not available, using TypeScript MicroLoRA")}return M}var Mt={dimension:384,microLoraLr:.001,consolidationInterval:100,ewcLambda:1e3,taskBoundaryZScoreThreshold:2.5,fisherDecay:.9,fisherSampleSize:200,importanceThreshold:.01},R=class{adaptationVector;baseWeights;lr;adaptationCount=0;constructor(t,e=.001){this.adaptationVector=new Float32Array(t),this.baseWeights=new Float32Array(t),this.lr=e}adapt(t){let e=this.baseWeights.length,r=new Float32Array(e),a=Math.min(t.length,e);for(let n=0;n<e;n++){let o=n<a?t[n]:0;r[n]=this.baseWeights[n]+this.adaptationVector[n]+this.lr*o}for(let n=0;n<a;n++)this.adaptationVector[n]+=this.lr*t[n];return this.adaptationCount++,r}consolidate(){let t=this.adaptationCount,e=this.baseWeights.length;for(let r=0;r<e;r++)this.baseWeights[r]+=this.adaptationVector[r],this.adaptationVector[r]=0;return this.adaptationCount=0,t}getAdaptationCount(){return this.adaptationCount}getEffectiveWeights(){let t=this.baseWeights.length,e=new Float32Array(t);for(let r=0;r<t;r++)e[r]=this.baseWeights[r]+this.adaptationVector[r];return e}getAdaptationMagnitude(){let t=0;for(let e=0;e<this.adaptationVector.length;e++)t+=this.adaptationVector[e]*this.adaptationVector[e];return Math.sqrt(t)}resetAdaptation(){this.adaptationVector.fill(0),this.adaptationCount=0}},x=class{fisherMatrix;optimalParams;lambda;fisherDecay;zScoreThreshold;importanceThreshold;gradientHistory=[];gradientMean=0;gradientVariance=0;taskBoundaryCount=0;consolidationCount=0;constructor(t,e=1e3,r=.9,a=2.5,n=.01){this.fisherMatrix=new Float32Array(t),this.optimalParams=new Float32Array(t),this.lambda=e,this.fisherDecay=r,this.zScoreThreshold=a,this.importanceThreshold=n}detectTaskBoundary(t){let e=0;for(let i=0;i<t.length;i++)e+=t[i]*t[i];if(e=Math.sqrt(e),this.gradientHistory.length<5)return this.gradientHistory.push(e),this.updateGradientStats(),!1;let r=Math.sqrt(this.gradientVariance),a=0,n=Math.abs(e-this.gradientMean);return r>1e-10?a=n/r:n>1e-10&&this.gradientMean>1e-10&&(a=n/(this.gradientMean*.01+1e-10)),this.gradientHistory.push(e),this.gradientHistory.length>100&&this.gradientHistory.shift(),this.updateGradientStats(),a>this.zScoreThreshold?(this.taskBoundaryCount++,!0):!1}computeLoss(t){let e=0,r=Math.min(t.length,this.fisherMatrix.length,this.optimalParams.length);for(let a=0;a<r;a++){let n=t[a]-this.optimalParams[a];e+=this.fisherMatrix[a]*n*n}return this.lambda/2*e}updateFisher(t,e){if(t.length===0)return;let r=this.fisherMatrix.length,a=new Float32Array(r);for(let s of t){let u=Math.min(s.length,r);for(let c=0;c<u;c++)a[c]+=s[c]*s[c]}let n=t.length;for(let s=0;s<r;s++)a[s]/=n;let o=this.fisherDecay;for(let s=0;s<r;s++)this.fisherMatrix[s]=o*this.fisherMatrix[s]+(1-o)*a[s];let i=Math.min(e.length,r);for(let s=0;s<i;s++)this.optimalParams[s]=e[s];this.consolidationCount++}getMetrics(){let t=this.fisherMatrix.length,e=0,r=0,a=0;for(let n=0;n<t;n++)e+=this.fisherMatrix[n],this.fisherMatrix[n]>r&&(r=this.fisherMatrix[n]),this.fisherMatrix[n]>this.importanceThreshold&&a++;return{regularizationLoss:0,taskBoundariesDetected:this.taskBoundaryCount,fisherTrace:e,avgFisherImportance:t>0?e/t:0,maxFisherImportance:r,protectedParams:a,consolidationCycles:this.consolidationCount,lambda:this.lambda}}getTaskBoundaryCount(){return this.taskBoundaryCount}getFisherDiagonal(){return new Float32Array(this.fisherMatrix)}getOptimalParams(){return new Float32Array(this.optimalParams)}loadFisher(t,e){let r=this.fisherMatrix.length,a=Math.min(t.length,r),n=Math.min(e.length,r);for(let o=0;o<a;o++)this.fisherMatrix[o]=t[o];for(let o=0;o<n;o++)this.optimalParams[o]=e[o]}updateGradientStats(){let t=this.gradientHistory.length;if(t===0)return;let e=0;for(let a of this.gradientHistory)e+=a;e/=t;let r=0;for(let a of this.gradientHistory){let n=a-e;r+=n*n}r=t>1?r/(t-1):0,this.gradientMean=e,this.gradientVariance=r}},C=class{config;microLora;ewc;nativeEngine;wasmLora=null;requestCount=0;lastConsolidationRequest=0;peerStates=new Map;gradientBuffer=[];lastFeatures=null;constructor(t={},e){this.config={...Mt,...t},this.nativeEngine=e??null,this.microLora=new R(this.config.dimension,this.config.microLoraLr),this.ewc=new x(this.config.dimension,this.config.ewcLambda,this.config.fisherDecay,this.config.taskBoundaryZScoreThreshold,this.config.importanceThreshold);let r=St();if(r)try{this.wasmLora=new r.WasmMicroLoRA(this.config.dimension,1,this.config.microLoraLr),f.info("SONA Three-Loop using WASM MicroLoRA (0.07us/adapt)")}catch(a){f.debug("WASM MicroLoRA creation failed, falling back",{error:String(a)}),this.wasmLora=null}!this.wasmLora&&this.nativeEngine&&f.info("SONA Three-Loop using native @ruvector/sona engine for MicroLoRA delegation")}instantAdapt(t){let e=performance.now(),r;if(this.wasmLora)try{let o=new Float32Array(t),i=this.wasmLora.adapt(o);i&&i.length>0?(r=i,this.microLora.adapt(t)):r=this.microLora.adapt(t)}catch{r=this.microLora.adapt(t)}else if(this.nativeEngine)try{let o=this.nativeEngine.applyMicroLora(t);r=new Float32Array(o),this.microLora.adapt(t)}catch{r=this.microLora.adapt(t)}else r=this.microLora.adapt(t);let a=this.microLora.getAdaptationMagnitude();this.requestCount++,this.lastFeatures=[...t];let n=(performance.now()-e)*1e3;return{adaptedWeights:r,latencyUs:n,applied:!0,magnitude:a,requestIndex:this.requestCount}}recordOutcome(t,e){if(this.lastFeatures===null){f.warn("recordOutcome called without a preceding instantAdapt()");return}let r=this.lastFeatures.length,a=new Float32Array(r);for(let n=0;n<r;n++)a[n]=t*this.lastFeatures[n];this.gradientBuffer.push(a),this.gradientBuffer.length>this.config.fisherSampleSize&&this.gradientBuffer.shift(),this.lastFeatures=null}backgroundConsolidate(){let t=performance.now();if(this.nativeEngine)try{this.nativeEngine.forceLearn(),this.nativeEngine.tick()}catch(i){f.warn("Native SONA background learning failed, continuing with TypeScript",{error:String(i)})}let e=this.ewc.computeLoss(this.microLora.getEffectiveWeights()),r=!1;if(this.gradientBuffer.length>0){let i=this.gradientBuffer[this.gradientBuffer.length-1];r=this.ewc.detectTaskBoundary(i)}if(r&&this.gradientBuffer.length>0&&(this.ewc.updateFisher(this.gradientBuffer,this.microLora.getEffectiveWeights()),f.info("Task boundary detected, Fisher updated",{boundaries:this.ewc.getTaskBoundaryCount(),requestCount:this.requestCount})),this.gradientBuffer.length>1){let i=!1,s=this.gradientBuffer[0];for(let u=1;u<this.gradientBuffer.length&&!i;u++)for(let c=0;c<s.length;c++)if(Math.abs(this.gradientBuffer[u][c]-s[c])>1e-8){i=!0;break}i||f.warn("All gradient samples identical \u2014 Fisher estimate may be poor. Ensure recordOutcome() is called with diverse rewards.")}let a=this.microLora.consolidate();this.applyEWCRegularization();let n=this.ewc.computeLoss(this.microLora.getEffectiveWeights());this.lastConsolidationRequest=this.requestCount,this.gradientBuffer=[];let o=performance.now()-t;return{consolidated:a>0||r,adaptationsMerged:a,ewcLossBefore:e,ewcLossAfter:n,taskBoundaryDetected:r,durationMs:o}}shouldConsolidate(){return this.requestCount-this.lastConsolidationRequest>=this.config.consolidationInterval}syncWithPeers(t){if(t.length===0)return;for(let i of t)this.peerStates.set(i.peerId,i);let e=this.config.dimension,r=new Float32Array(e),a=new Float32Array(e),n=this.ewc.getFisherDiagonal(),o=this.microLora.adaptationVector;for(let i=0;i<e;i++){let s=n[i]+1e-10;r[i]+=s*o[i],a[i]+=s}for(let i of t){let s=Math.min(i.adaptationVector.length,e);for(let u=0;u<s;u++){let c=(u<i.fisherDiagonal.length?i.fisherDiagonal[u]:0)+1e-10;r[u]+=c*i.adaptationVector[u],a[u]+=c}}for(let i=0;i<e;i++)this.microLora.adaptationVector[i]=r[i]/a[i];f.debug("Synced with peers",{peerCount:t.length,peersStored:this.peerStates.size})}getLocalPeerState(t,e){return{peerId:t,domain:e,adaptationVector:new Float32Array(this.microLora.adaptationVector),fisherDiagonal:this.ewc.getFisherDiagonal(),requestCount:this.requestCount,lastUpdateMs:Date.now()}}getEWCMetrics(){let t=this.ewc.getMetrics();return t.regularizationLoss=this.ewc.computeLoss(this.microLora.getEffectiveWeights()),t}getFisherDiagonal(){return this.ewc.getFisherDiagonal()}getOptimalParams(){return this.ewc.getOptimalParams()}loadFisher(t,e){this.ewc.loadFisher(t,e)}getBaseWeights(){return new Float32Array(this.microLora.baseWeights)}setBaseWeights(t){let e=Math.min(t.length,this.microLora.baseWeights.length);for(let r=0;r<e;r++)this.microLora.baseWeights[r]=t[r]}getEffectiveWeights(){return this.microLora.getEffectiveWeights()}getRequestCount(){return this.requestCount}restoreRequestCount(t){this.requestCount=t}getConfig(){return{...this.config}}getPeerStates(){return new Map(this.peerStates)}getMicroLoRA(){return this.microLora}getEWC(){return this.ewc}applyEWCRegularization(){let t=this.config.dimension,e=this.ewc.fisherMatrix,r=this.ewc.optimalParams,a=this.microLora.baseWeights,n=.01;for(let o=0;o<t;o++)if(e[o]>this.config.importanceThreshold){let i=a[o]-r[o];a[o]-=n*e[o]*i}}persistFisher(t,e){let r=this.ewc.getMetrics();t(e,this.ewc.getFisherDiagonal(),this.ewc.getOptimalParams(),this.getBaseWeights(),{taskBoundaries:r.taskBoundariesDetected,consolidationCycles:r.consolidationCycles,requestCount:this.requestCount,ewcLambda:r.lambda}),f.info("Fisher matrix persisted to SQLite",{domain:e,requestCount:this.requestCount,taskBoundaries:r.taskBoundariesDetected})}restoreFisher(t){this.ewc.loadFisher(t.fisherDiagonal,t.optimalParams),t.baseWeights&&this.setBaseWeights(t.baseWeights),this.requestCount=t.requestCount,f.info("Fisher matrix restored from SQLite",{requestCount:t.requestCount,dimension:t.fisherDiagonal.length})}};var Lt={hiddenDim:256,embeddingDim:384,microLoraRank:1,baseLoraRank:8,microLoraLr:.001,baseLoraLr:1e-4,ewcLambda:1e3,patternClusters:50,trajectoryCapacity:1e4,backgroundIntervalMs:36e5,qualityThreshold:.5,enableSimd:!0,minConfidence:.5,maxPatterns:1e4},Q=class{patterns;trajectoryMap;maxPatterns;constructor(t=1e4){this.patterns=new Map,this.trajectoryMap=new Map,this.maxPatterns=t}register(t){if(this.patterns.size>=this.maxPatterns&&!this.patterns.has(t.id)){let e=Array.from(this.patterns.entries()).sort(([,r],[,a])=>(r.lastUsedAt?.getTime()??r.createdAt.getTime())-(a.lastUsedAt?.getTime()??a.createdAt.getTime()))[0];e&&this.patterns.delete(e[0])}this.patterns.set(t.id,t)}get(t){return this.patterns.get(t)}getByTrajectory(t){let e=this.trajectoryMap.get(t);return e?this.patterns.get(e):void 0}associateTrajectory(t,e){this.trajectoryMap.set(t,e)}update(t,e){let r=this.patterns.get(t);return r?(this.patterns.set(t,{...r,...e}),!0):!1}getAll(){return Array.from(this.patterns.values())}getByType(t){return Array.from(this.patterns.values()).filter(e=>e.type===t)}getByDomain(t){return Array.from(this.patterns.values()).filter(e=>e.domain===t)}delete(t){let e=this.patterns.delete(t);for(let[r,a]of this.trajectoryMap)a===t&&this.trajectoryMap.delete(r);return e}clear(){this.patterns.clear(),this.trajectoryMap.clear()}size(){return this.patterns.size}},v=class{engine;registry;config;adaptationTimes=[];cacheHits=0;totalAdaptations=0;threeLoopEngine=null;fisherPersistFn=null;fisherDomain="default";constructor(t={}){this.config={...Lt,...t};let e={hiddenDim:this.config.hiddenDim,embeddingDim:this.config.embeddingDim,microLoraRank:this.config.microLoraRank,baseLoraRank:this.config.baseLoraRank,microLoraLr:this.config.microLoraLr,baseLoraLr:this.config.baseLoraLr,ewcLambda:this.config.ewcLambda,patternClusters:this.config.patternClusters,trajectoryCapacity:this.config.trajectoryCapacity,backgroundIntervalMs:this.config.backgroundIntervalMs,qualityThreshold:this.config.qualityThreshold,enableSimd:this.config.enableSimd};this.engine=T.withConfig(e),this.registry=new Q(this.config.maxPatterns??1e4)}async adaptPattern(t,e,r){let a=performance.now();try{let n=this.createStateEmbedding(t),o=this.engine.findPatterns(n,5),i=[];for(let h of o){let g=this.findByRawPattern(h);if(g||(g=this.createQEPatternFromRaw(h,e,r)),g.type===e&&g.domain===r&&g.confidence>=(this.config.minConfidence??.5)){let m=this.calculateSimilarity(n,h.centroid);i.push({pattern:g,similarity:m})}}if(i.length===0){let h=performance.now()-a;return this.recordAdaptation(h),{success:!1,pattern:null,adaptationTimeMs:h,similarity:0,reasoning:"No suitable pattern found"}}let s=i[0],u={...s.pattern,usageCount:s.pattern.usageCount+1,lastUsedAt:new Date};this.registry.update(u.id,u);let c=performance.now()-a;return this.recordAdaptation(c),{success:!0,pattern:u,adaptationTimeMs:c,similarity:s.similarity,reasoning:`Pattern adapted from @ruvector/sona with ${s.similarity.toFixed(3)} similarity`}}catch(n){let o=performance.now()-a;return this.recordAdaptation(o),{success:!1,pattern:null,adaptationTimeMs:o,similarity:0,reasoning:`Adaptation failed: ${n.message}`}}}recallPattern(t,e,r){let a=this.createStateEmbedding(t),n=this.engine.findPatterns(a,1);for(let o of n){let i=this.findByRawPattern(o);if(i&&i.type===e&&i.domain===r)return i}return null}storePattern(t){this.registry.register(t);let e=this.engine.beginTrajectory(t.stateEmbedding),r=this.createActionEmbedding(t.action),a=new Array(r.length).fill(1),n=t.outcome.success?t.outcome.quality:-t.outcome.quality;this.engine.addTrajectoryStep(e,r,a,n),this.engine.endTrajectory(e,t.outcome.quality),this.registry.associateTrajectory(e,t.id)}storePatternsBatch(t){for(let e of t)this.storePattern(e)}createPattern(t,e,r,a,n,o){let i={id:`qesona-${Date.now()}-${Ct().slice(0,7)}`,type:a,domain:n,stateEmbedding:this.createStateEmbedding(t),action:e,outcome:r,confidence:.5,usageCount:0,createdAt:new Date,metadata:o};return this.storePattern(i),i}updatePattern(t,e,r){let a=this.registry.get(t);if(!a)return!1;let n=e?r:-r,i=a.confidence+.1*(n-a.confidence),s={...a,confidence:Math.max(0,Math.min(1,i)),usageCount:a.usageCount+1,lastUsedAt:new Date};return this.registry.update(t,s)}applyMicroLora(t){return this.engine.applyMicroLora(t)}applyBaseLora(t,e){return this.engine.applyBaseLora(t,e)}forceLearn(){return this.engine.forceLearn()}tick(){return this.engine.tick()}getAllPatterns(){return this.registry.getAll()}getPatternsByType(t){return this.registry.getByType(t)}getPatternsByDomain(t){return this.registry.getByDomain(t)}getStats(){let t=this.registry.getAll(),e=this.engine.getStats(),r={"test-generation":0,"defect-prediction":0,"coverage-optimization":0,"quality-assessment":0,"resource-allocation":0};for(let a of t)r[a.type]++;return{totalPatterns:t.length,patternsByType:r,avgAdaptationTimeMs:this.avgAdaptationTime(),minAdaptationTimeMs:this.minAdaptationTime(),maxAdaptationTimeMs:this.maxAdaptationTime(),totalAdaptations:this.totalAdaptations,cacheHitRate:this.totalAdaptations>0?this.cacheHits/this.totalAdaptations:0,engineStats:e}}deletePattern(t){return this.registry.delete(t)}clear(){this.registry.clear(),this.adaptationTimes=[],this.cacheHits=0,this.totalAdaptations=0}exportPatterns(){return this.registry.getAll()}importPatterns(t){this.clear(),this.storePatternsBatch(t)}getConfig(){return{...this.config}}setEnabled(t){this.engine.setEnabled(t)}isEnabled(){return this.engine.isEnabled()}createStateEmbedding(t){let e=t.features;if(e.length===0)return new Array(this.config.embeddingDim??384).fill(0);let r=Math.max(...e.map(Math.abs));if(r===0)return[...e];let a=e.map(o=>o/r),n=this.config.embeddingDim??384;return a.length>=n?a.slice(0,n):[...a,...new Array(n-a.length).fill(0)]}createActionEmbedding(t){let e=[],r=this.hashCode(t.type);if(e.push(r%1e3/1e3),typeof t.value=="number")e.push(Math.min(1,Math.max(-1,t.value)));else if(typeof t.value=="string"){let n=this.hashCode(t.value);e.push(n%1e3/1e3)}else if(Array.isArray(t.value))for(let n of t.value.slice(0,10))typeof n=="number"&&e.push(Math.min(1,Math.max(-1,n)));let a=this.config.embeddingDim??384;for(;e.length<a;)e.push(0);return e.slice(0,a)}findByRawPattern(t){let e=this.registry.getAll();for(let r of e)if(r.rawPattern?.patternType===t.id)return r}createQEPatternFromRaw(t,e,r){let a={centroid:t.centroid,clusterSize:1,totalWeight:1,avgQuality:t.avgQuality,createdAt:new Date().toISOString(),lastAccessed:new Date().toISOString(),accessCount:0,patternType:t.patternType};return{id:`qesona-${t.id}`,type:e,domain:r,stateEmbedding:t.centroid,action:{type:"learned",value:t.patternType},outcome:{reward:t.avgQuality,success:t.avgQuality>.5,quality:t.avgQuality},confidence:t.avgQuality,usageCount:0,createdAt:new Date,rawPattern:a}}calculateSimilarity(t,e){let r=Math.min(t.length,e.length),a=0,n=0,o=0;for(let s=0;s<r;s++)a+=t[s]*e[s],n+=t[s]*t[s],o+=e[s]*e[s];return(a/(Math.sqrt(n)*Math.sqrt(o)+1e-10)+1)/2}hashCode(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e=e|0;return Math.abs(e)}recordAdaptation(t){this.adaptationTimes.push(t),this.totalAdaptations++,this.adaptationTimes.length>1e3&&this.adaptationTimes.shift()}avgAdaptationTime(){return this.adaptationTimes.length===0?0:this.adaptationTimes.reduce((e,r)=>e+r,0)/this.adaptationTimes.length}minAdaptationTime(){return this.adaptationTimes.length===0?0:Math.min(...this.adaptationTimes)}maxAdaptationTime(){return this.adaptationTimes.length===0?0:Math.max(...this.adaptationTimes)}initThreeLoopEngine(t){this.threeLoopEngine=new C({dimension:this.config.embeddingDim??384,microLoraLr:this.config.microLoraLr??.001,ewcLambda:this.config.ewcLambda??1e3,...t},this.engine)}getThreeLoopEngine(){return this.threeLoopEngine}instantAdapt(t){return this.threeLoopEngine?this.threeLoopEngine.instantAdapt(t):null}recordOutcome(t,e){this.threeLoopEngine&&this.threeLoopEngine.recordOutcome(t,e)}backgroundConsolidate(){if(!this.threeLoopEngine)return null;let t=this.threeLoopEngine.backgroundConsolidate();if(t&&(t.consolidated||t.taskBoundaryDetected)&&this.fisherPersistFn)try{this.threeLoopEngine.persistFisher(this.fisherPersistFn,this.fisherDomain)}catch(e){console.warn("[QESONA] Fisher persistence failed:",e instanceof Error?e.message:e)}return t}setFisherPersistence(t,e){this.fisherPersistFn=t,this.fisherDomain=e}syncWithPeers(t){this.threeLoopEngine&&this.threeLoopEngine.syncWithPeers(t)}getEWCMetrics(){return this.threeLoopEngine?this.threeLoopEngine.getEWCMetrics():null}shouldConsolidate(){return this.threeLoopEngine?this.threeLoopEngine.shouldConsolidate():!1}getLocalPeerState(t,e){return this.threeLoopEngine?this.threeLoopEngine.getLocalPeerState(t,e):null}isThreeLoopEnabled(){return this.threeLoopEngine!==null}async verifyPerformance(t=1e3){let e=[],r={id:"test-state",features:new Array(384).fill(0).map(()=>G())};for(let s=0;s<t;s++){let u=performance.now();await this.adaptPattern(r,"test-generation","test-generation");let c=performance.now();e.push({iteration:s,timeMs:c-u})}let a=e.map(s=>s.timeMs),n=a.reduce((s,u)=>s+u,0)/a.length,o=Math.min(...a),i=Math.max(...a);return{targetMet:n<.05,avgTimeMs:n,minTimeMs:o,maxTimeMs:i,details:e}}};function Pt(l){return new v(l)}function Tt(l,t){return new v({...t,maxPatterns:t?.maxPatterns||5e3})}ot();et();var F=null,D=null,W=null,B=null,I=null,z=null,q=!1;try{let l=(O(),w(N));F=l.FlashAttention,D=l.DotProductAttention,W=l.MultiHeadAttention,B=l.HyperbolicAttention,I=l.LinearAttention,z=l.MoEAttention,q=!0}catch{}function Gt(){return q}function b(){if(!q)throw new Error("@ruvector/attention native module is not available on this platform. Install the appropriate optional dependency for your platform, or use a platform where pre-built binaries are available.")}var P={"test-similarity":{dim:384,strategy:"flash",blockSize:64},"code-embedding":{dim:512,strategy:"flash",blockSize:128},"defect-matching":{dim:384,strategy:"flash",blockSize:64},"coverage-analysis":{dim:384,strategy:"flash",blockSize:256},"pattern-adaptation":{dim:256,strategy:"flash",blockSize:32}},Kt={"test-similarity":{enabled:!0,microLoRARank:4,targetAdaptationMs:.05,patternCacheSize:1e3},"code-embedding":{enabled:!0,microLoRARank:2,targetAdaptationMs:.03,patternCacheSize:5e3},"defect-matching":{enabled:!0,microLoRARank:8,targetAdaptationMs:.05,patternCacheSize:2e3},"coverage-analysis":{enabled:!1,microLoRARank:2,targetAdaptationMs:.01,patternCacheSize:100},"pattern-adaptation":{enabled:!0,microLoRARank:2,targetAdaptationMs:.05,patternCacheSize:1e4}},$t={"test-similarity":{latency:{before:50,after:15},memory:{before:200,after:80},throughput:{min:1e3}},"code-embedding":{latency:{before:50,after:15},memory:{before:200,after:80},throughput:{min:2e3}},"defect-matching":{latency:{before:20,after:5},memory:{before:150,after:50},throughput:{min:500}},"coverage-analysis":{latency:{before:100,after:1},memory:{before:100,after:30},throughput:{min:1e4}},"pattern-adaptation":{latency:{before:2,after:.05},memory:{before:50,after:20},throughput:{min:2e4}}};function Zt(l){return l<=128?{queryChunkSize:128,kvChunkSize:128}:l<=256?{queryChunkSize:256,kvChunkSize:256}:l<=512?{queryChunkSize:512,kvChunkSize:512}:l<=1024?{queryChunkSize:1024,kvChunkSize:1024}:{queryChunkSize:1024,kvChunkSize:2048}}var E=class{static create(t){switch(b(),t.strategy){case"flash":return new F(t.dim,t.blockSize);case"dot-product":return new D(t.dim);case"multi-head":return new W(t.dim,t.numHeads??8);case"hyperbolic":return new B(t.dim,t.curvature);case"linear":return new I(t.dim,t.features);case"moe":return z.simple(t.dim,t.moeConfig?.numExperts??8,t.moeConfig?.topK??2);default:return new F(t.dim,t.blockSize)}}},L=class l{attention;config;workload;metrics=[];db=null;persistCount=0;static KV_NAMESPACE="attention-metrics";static KV_TTL=3600;static PERSIST_INTERVAL=10;constructor(t,e){this.workload=t;let r=P[t];this.config={...r,...e},this.attention=E.create(this.config)}async initialize(){try{this.db=K(),this.db.isInitialized()||await this.db.initialize(),await this.loadFromKv()}catch(t){console.warn("[QEFlashAttention] DB init failed, using memory-only:",j(t)),this.db=null}}async computeFlashAttention(t,e,r,a,n){let o=performance.now(),i=process.memoryUsage().heapUsed/1024/1024,s=this.toFloat32Array(t,a,n),u=this.splitMatrix(e,a,n),c=this.splitMatrix(r,a,n),h,g=this.attention;typeof g.compute=="function"?h=g.compute(s,u,c):(b(),h=new F(this.config.dim).compute(s,u,c));let m=performance.now(),d=process.memoryUsage().heapUsed/1024/1024;return this.metrics.push({timeMs:m-o,memoryMB:d-i,speedup:1,throughput:a*a/((m-o)/1e3),peakMemoryMB:d}),this.maybePersistToKv(),h}async computeBaselineAttention(t,e,r,a,n){let o=performance.now(),i=process.memoryUsage().heapUsed/1024/1024,s=new Float32Array(a*a),u=1/Math.sqrt(n);for(let m=0;m<a;m++)for(let d=0;d<a;d++){let A=0;for(let p=0;p<n;p++)A+=t[m*n+p]*e[d*n+p];s[m*a+d]=A*u}for(let m=0;m<a;m++){let d=m*a,A=d+a,p=s.subarray(d,A),tt=Math.max(...p),_=0;for(let y=0;y<a;y++)p[y]=Math.exp(p[y]-tt),_+=p[y];for(let y=0;y<a;y++)p[y]/=_}let c=new Float32Array(a*n);for(let m=0;m<a;m++)for(let d=0;d<a;d++){let A=s[m*a+d];for(let p=0;p<n;p++)c[m*n+p]+=A*r[d*n+p]}let h=performance.now(),g=process.memoryUsage().heapUsed/1024/1024;return c}async computeTestSimilarity(t,e,r=5){let a=e.length,n=t.length,o=new Float32Array(a*n),i=new Float32Array(a*n);for(let h=0;h<a;h++)o.set(t,h*n),i.set(e[h],h*n);let s=new Float32Array(a*n),u=await this.computeFlashAttention(o,i,s,a,n),c=[];for(let h=0;h<a;h++)c.push({index:h,similarity:u[h*n]});return c.sort((h,g)=>g.similarity-h.similarity),c.slice(0,r)}async generateCodeEmbedding(t,e){let r=t.length/e.length,a=e.length;return await this.computeFlashAttention(t,e,t,r,a)}async matchDefectPattern(t,e){let r=e.length,a=t.length,n=new Float32Array(r*a),o=new Float32Array(r*a);for(let c=0;c<r;c++)n.set(t,c*a),o.set(e[c],c*a);let i=new Float32Array(r*a),s=await this.computeFlashAttention(n,o,i,r,a),u=[];for(let c=0;c<r;c++)u.push({pattern:c,score:s[c*a]});return u.sort((c,h)=>h.score-c.score),u}getMetrics(){return[...this.metrics]}getAverageSpeedup(){return this.metrics.length===0?1:this.metrics.reduce((t,e)=>t+e.speedup,0)/this.metrics.length}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t},this.attention=E.create(this.config)}changeStrategy(t){this.config.strategy=t,this.attention=E.create(this.config)}resetMetrics(){this.metrics=[]}getWorkload(){return this.workload}dispose(){this.metrics=[]}async persistToKv(){if(!this.db)return;let t=`attention-metrics-${this.workload}`,e={workload:this.workload,metrics:this.metrics.slice(-50),savedAt:Date.now()};await this.db.kvSet(t,e,l.KV_NAMESPACE,l.KV_TTL)}async loadFromKv(){if(!this.db)return;let t=`attention-metrics-${this.workload}`,e=await this.db.kvGet(t,l.KV_NAMESPACE);e?.metrics?.length&&(this.metrics=e.metrics)}maybePersistToKv(){this.persistCount++,this.persistCount>=l.PERSIST_INTERVAL&&(this.persistCount=0,this.persistToKv().catch(()=>{}))}toFloat32Array(t,e,r){return t.slice(0,r)}splitMatrix(t,e,r){let a=[];for(let n=0;n<e;n++)a.push(t.slice(n*r,(n+1)*r));return a}};async function Y(l,t){let e=new L(l,t);return await e.initialize(),e}function Jt(l){return{...P[l]}}function Xt(){return Object.keys(P)}function Yt(){return b(),F}function te(){return b(),D}function ee(){return b(),W}function re(){return b(),B}function ae(){return b(),I}function ne(){return b(),z}function ie(l){return l instanceof Float32Array?l:new Float32Array(l)}function oe(l){return Array.from(l)}async function se(l,t,e,r){let a=await Y(l),n=[],o=t[0].length,i=e.length;for(let s of t){let u=new Float32Array(i*o),c=new Float32Array(i*o),h=new Float32Array(i*o);u.set(s,0);for(let m=0;m<i;m++)c.set(e[m],m*o),h.set(r[m],m*o);let g=await a.computeFlashAttention(u,c,h,i,o);n.push(g.slice(0,o))}return a.dispose(),n}function We(){return{"@ruvector/sona":"^0.1.5","@ruvector/attention":"^0.1.4","@ruvector/gnn":"^0.1.22"}}function Be(){let l={sona:!1,attention:!1,gnn:!1,all:!1};try{k(),l.sona=!0}catch{}try{O(),l.attention=!0}catch{}try{let t=(it(),w(nt));t.init();let e=new Float32Array([.1,.2,.3]),r=[new Float32Array([.1,.2,.3]),new Float32Array([.4,.5,.6])],a=t.differentiableSearch(e,r,1,1);a&&Array.isArray(a.indices)&&Array.isArray(a.weights)&&(l.gnn=!0)}catch{}return l.all=l.sona&&l.attention&&l.gnn,l}async function Ie(){let{initGNN:l}=await import("./gnn-wrapper-52V6ANOY.js");return[l(),"SONA: Ready (no initialization required)","Attention: Ready (no initialization required)"]}export{v as a,Pt as b,Tt as c,Gt as d,P as e,Kt as f,$t as g,Zt as h,L as i,Y as j,Jt as k,Xt as l,Yt as m,te as n,ee as o,re as p,ae as q,ne as r,ie as s,oe as t,se as u,We as v,Be as w,Ie as x};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.9");process.exit(0)}
2
+ import{o as K,s as ot}from"./chunk-OCESWNAZ.js";import{a as G,d as at}from"./chunk-EFBLP43U.js";import{a as nt,b as it}from"./chunk-ZXBCCO2H.js";import{a as rt}from"./chunk-KTSLTZSG.js";import{e as U}from"./chunk-O3JLOVZX.js";import{a as j,e as et}from"./chunk-N3KEY4XJ.js";import{b as H,d as V,f as w}from"./chunk-HZ5NC6U5.js";var Z={};V(Z,{DotProductAttention:()=>yt,FlashAttention:()=>ft,HyperbolicAttention:()=>At,LinearAttention:()=>vt,MoEAttention:()=>Et,MultiHeadAttention:()=>bt,RuvectorLayer:()=>ut,SonaEngine:()=>T,TensorCompress:()=>ht,default:()=>ct,differentiableSearch:()=>mt,getCompressionLevel:()=>pt,hierarchicalForward:()=>dt,init:()=>gt,pipeline:()=>Ft});import{createRequire as st}from"module";var lt,$,ct,ut,ht,mt,dt,pt,gt,ft,yt,bt,At,vt,Et,T,Ft,k=H(()=>{lt=st(import.meta.url),$=lt("@ruvector/sona"),ct=$,{RuvectorLayer:ut,TensorCompress:ht,differentiableSearch:mt,hierarchicalForward:dt,getCompressionLevel:pt,init:gt,FlashAttention:ft,DotProductAttention:yt,MultiHeadAttention:bt,HyperbolicAttention:At,LinearAttention:vt,MoEAttention:Et,SonaEngine:T,pipeline:Ft}=$||{}});var N={};V(N,{DotProductAttention:()=>zt,FlashAttention:()=>It,HyperbolicAttention:()=>_t,LinearAttention:()=>Ht,MoEAttention:()=>Vt,MultiHeadAttention:()=>qt,RuvectorLayer:()=>Qt,SonaEngine:()=>jt,TensorCompress:()=>Nt,default:()=>xt,differentiableSearch:()=>Ot,getCompressionLevel:()=>Wt,hierarchicalForward:()=>Dt,init:()=>Bt,pipeline:()=>Ut});import{createRequire as kt}from"module";var Rt,X,xt,Qt,Nt,Ot,Dt,Wt,Bt,It,zt,qt,_t,Ht,Vt,jt,Ut,O=H(()=>{Rt=kt(import.meta.url),X=Rt("@ruvector/attention"),xt=X,{RuvectorLayer:Qt,TensorCompress:Nt,differentiableSearch:Ot,hierarchicalForward:Dt,getCompressionLevel:Wt,init:Bt,FlashAttention:It,DotProductAttention:zt,MultiHeadAttention:qt,HyperbolicAttention:_t,LinearAttention:Ht,MoEAttention:Vt,SonaEngine:jt,pipeline:Ut}=X||{}});k();at();import{randomUUID as Ct}from"crypto";rt();import{createRequire as wt}from"module";var f=U.create("sona-three-loop"),S=wt(import.meta.url),M=null,J=!1;function St(){if(J)return M;J=!0;try{let l=S("@ruvector/learning-wasm"),t=S("fs"),e=S("path"),r=e.join(e.dirname(S.resolve("@ruvector/learning-wasm")),"ruvector_learning_wasm_bg.wasm");l.initSync({module:t.readFileSync(r)}),M=l,f.info("WASM MicroLoRA loaded from @ruvector/learning-wasm (6.4x faster than TS)")}catch{M=null,f.debug("@ruvector/learning-wasm not available, using TypeScript MicroLoRA")}return M}var Mt={dimension:384,microLoraLr:.001,consolidationInterval:100,ewcLambda:1e3,taskBoundaryZScoreThreshold:2.5,fisherDecay:.9,fisherSampleSize:200,importanceThreshold:.01},R=class{adaptationVector;baseWeights;lr;adaptationCount=0;constructor(t,e=.001){this.adaptationVector=new Float32Array(t),this.baseWeights=new Float32Array(t),this.lr=e}adapt(t){let e=this.baseWeights.length,r=new Float32Array(e),a=Math.min(t.length,e);for(let n=0;n<e;n++){let o=n<a?t[n]:0;r[n]=this.baseWeights[n]+this.adaptationVector[n]+this.lr*o}for(let n=0;n<a;n++)this.adaptationVector[n]+=this.lr*t[n];return this.adaptationCount++,r}consolidate(){let t=this.adaptationCount,e=this.baseWeights.length;for(let r=0;r<e;r++)this.baseWeights[r]+=this.adaptationVector[r],this.adaptationVector[r]=0;return this.adaptationCount=0,t}getAdaptationCount(){return this.adaptationCount}getEffectiveWeights(){let t=this.baseWeights.length,e=new Float32Array(t);for(let r=0;r<t;r++)e[r]=this.baseWeights[r]+this.adaptationVector[r];return e}getAdaptationMagnitude(){let t=0;for(let e=0;e<this.adaptationVector.length;e++)t+=this.adaptationVector[e]*this.adaptationVector[e];return Math.sqrt(t)}resetAdaptation(){this.adaptationVector.fill(0),this.adaptationCount=0}},x=class{fisherMatrix;optimalParams;lambda;fisherDecay;zScoreThreshold;importanceThreshold;gradientHistory=[];gradientMean=0;gradientVariance=0;taskBoundaryCount=0;consolidationCount=0;constructor(t,e=1e3,r=.9,a=2.5,n=.01){this.fisherMatrix=new Float32Array(t),this.optimalParams=new Float32Array(t),this.lambda=e,this.fisherDecay=r,this.zScoreThreshold=a,this.importanceThreshold=n}detectTaskBoundary(t){let e=0;for(let i=0;i<t.length;i++)e+=t[i]*t[i];if(e=Math.sqrt(e),this.gradientHistory.length<5)return this.gradientHistory.push(e),this.updateGradientStats(),!1;let r=Math.sqrt(this.gradientVariance),a=0,n=Math.abs(e-this.gradientMean);return r>1e-10?a=n/r:n>1e-10&&this.gradientMean>1e-10&&(a=n/(this.gradientMean*.01+1e-10)),this.gradientHistory.push(e),this.gradientHistory.length>100&&this.gradientHistory.shift(),this.updateGradientStats(),a>this.zScoreThreshold?(this.taskBoundaryCount++,!0):!1}computeLoss(t){let e=0,r=Math.min(t.length,this.fisherMatrix.length,this.optimalParams.length);for(let a=0;a<r;a++){let n=t[a]-this.optimalParams[a];e+=this.fisherMatrix[a]*n*n}return this.lambda/2*e}updateFisher(t,e){if(t.length===0)return;let r=this.fisherMatrix.length,a=new Float32Array(r);for(let s of t){let u=Math.min(s.length,r);for(let c=0;c<u;c++)a[c]+=s[c]*s[c]}let n=t.length;for(let s=0;s<r;s++)a[s]/=n;let o=this.fisherDecay;for(let s=0;s<r;s++)this.fisherMatrix[s]=o*this.fisherMatrix[s]+(1-o)*a[s];let i=Math.min(e.length,r);for(let s=0;s<i;s++)this.optimalParams[s]=e[s];this.consolidationCount++}getMetrics(){let t=this.fisherMatrix.length,e=0,r=0,a=0;for(let n=0;n<t;n++)e+=this.fisherMatrix[n],this.fisherMatrix[n]>r&&(r=this.fisherMatrix[n]),this.fisherMatrix[n]>this.importanceThreshold&&a++;return{regularizationLoss:0,taskBoundariesDetected:this.taskBoundaryCount,fisherTrace:e,avgFisherImportance:t>0?e/t:0,maxFisherImportance:r,protectedParams:a,consolidationCycles:this.consolidationCount,lambda:this.lambda}}getTaskBoundaryCount(){return this.taskBoundaryCount}getFisherDiagonal(){return new Float32Array(this.fisherMatrix)}getOptimalParams(){return new Float32Array(this.optimalParams)}loadFisher(t,e){let r=this.fisherMatrix.length,a=Math.min(t.length,r),n=Math.min(e.length,r);for(let o=0;o<a;o++)this.fisherMatrix[o]=t[o];for(let o=0;o<n;o++)this.optimalParams[o]=e[o]}updateGradientStats(){let t=this.gradientHistory.length;if(t===0)return;let e=0;for(let a of this.gradientHistory)e+=a;e/=t;let r=0;for(let a of this.gradientHistory){let n=a-e;r+=n*n}r=t>1?r/(t-1):0,this.gradientMean=e,this.gradientVariance=r}},C=class{config;microLora;ewc;nativeEngine;wasmLora=null;requestCount=0;lastConsolidationRequest=0;peerStates=new Map;gradientBuffer=[];lastFeatures=null;constructor(t={},e){this.config={...Mt,...t},this.nativeEngine=e??null,this.microLora=new R(this.config.dimension,this.config.microLoraLr),this.ewc=new x(this.config.dimension,this.config.ewcLambda,this.config.fisherDecay,this.config.taskBoundaryZScoreThreshold,this.config.importanceThreshold);let r=St();if(r)try{this.wasmLora=new r.WasmMicroLoRA(this.config.dimension,1,this.config.microLoraLr),f.info("SONA Three-Loop using WASM MicroLoRA (0.07us/adapt)")}catch(a){f.debug("WASM MicroLoRA creation failed, falling back",{error:String(a)}),this.wasmLora=null}!this.wasmLora&&this.nativeEngine&&f.info("SONA Three-Loop using native @ruvector/sona engine for MicroLoRA delegation")}instantAdapt(t){let e=performance.now(),r;if(this.wasmLora)try{let o=new Float32Array(t),i=this.wasmLora.adapt(o);i&&i.length>0?(r=i,this.microLora.adapt(t)):r=this.microLora.adapt(t)}catch{r=this.microLora.adapt(t)}else if(this.nativeEngine)try{let o=this.nativeEngine.applyMicroLora(t);r=new Float32Array(o),this.microLora.adapt(t)}catch{r=this.microLora.adapt(t)}else r=this.microLora.adapt(t);let a=this.microLora.getAdaptationMagnitude();this.requestCount++,this.lastFeatures=[...t];let n=(performance.now()-e)*1e3;return{adaptedWeights:r,latencyUs:n,applied:!0,magnitude:a,requestIndex:this.requestCount}}recordOutcome(t,e){if(this.lastFeatures===null){f.warn("recordOutcome called without a preceding instantAdapt()");return}let r=this.lastFeatures.length,a=new Float32Array(r);for(let n=0;n<r;n++)a[n]=t*this.lastFeatures[n];this.gradientBuffer.push(a),this.gradientBuffer.length>this.config.fisherSampleSize&&this.gradientBuffer.shift(),this.lastFeatures=null}backgroundConsolidate(){let t=performance.now();if(this.nativeEngine)try{this.nativeEngine.forceLearn(),this.nativeEngine.tick()}catch(i){f.warn("Native SONA background learning failed, continuing with TypeScript",{error:String(i)})}let e=this.ewc.computeLoss(this.microLora.getEffectiveWeights()),r=!1;if(this.gradientBuffer.length>0){let i=this.gradientBuffer[this.gradientBuffer.length-1];r=this.ewc.detectTaskBoundary(i)}if(r&&this.gradientBuffer.length>0&&(this.ewc.updateFisher(this.gradientBuffer,this.microLora.getEffectiveWeights()),f.info("Task boundary detected, Fisher updated",{boundaries:this.ewc.getTaskBoundaryCount(),requestCount:this.requestCount})),this.gradientBuffer.length>1){let i=!1,s=this.gradientBuffer[0];for(let u=1;u<this.gradientBuffer.length&&!i;u++)for(let c=0;c<s.length;c++)if(Math.abs(this.gradientBuffer[u][c]-s[c])>1e-8){i=!0;break}i||f.warn("All gradient samples identical \u2014 Fisher estimate may be poor. Ensure recordOutcome() is called with diverse rewards.")}let a=this.microLora.consolidate();this.applyEWCRegularization();let n=this.ewc.computeLoss(this.microLora.getEffectiveWeights());this.lastConsolidationRequest=this.requestCount,this.gradientBuffer=[];let o=performance.now()-t;return{consolidated:a>0||r,adaptationsMerged:a,ewcLossBefore:e,ewcLossAfter:n,taskBoundaryDetected:r,durationMs:o}}shouldConsolidate(){return this.requestCount-this.lastConsolidationRequest>=this.config.consolidationInterval}syncWithPeers(t){if(t.length===0)return;for(let i of t)this.peerStates.set(i.peerId,i);let e=this.config.dimension,r=new Float32Array(e),a=new Float32Array(e),n=this.ewc.getFisherDiagonal(),o=this.microLora.adaptationVector;for(let i=0;i<e;i++){let s=n[i]+1e-10;r[i]+=s*o[i],a[i]+=s}for(let i of t){let s=Math.min(i.adaptationVector.length,e);for(let u=0;u<s;u++){let c=(u<i.fisherDiagonal.length?i.fisherDiagonal[u]:0)+1e-10;r[u]+=c*i.adaptationVector[u],a[u]+=c}}for(let i=0;i<e;i++)this.microLora.adaptationVector[i]=r[i]/a[i];f.debug("Synced with peers",{peerCount:t.length,peersStored:this.peerStates.size})}getLocalPeerState(t,e){return{peerId:t,domain:e,adaptationVector:new Float32Array(this.microLora.adaptationVector),fisherDiagonal:this.ewc.getFisherDiagonal(),requestCount:this.requestCount,lastUpdateMs:Date.now()}}getEWCMetrics(){let t=this.ewc.getMetrics();return t.regularizationLoss=this.ewc.computeLoss(this.microLora.getEffectiveWeights()),t}getFisherDiagonal(){return this.ewc.getFisherDiagonal()}getOptimalParams(){return this.ewc.getOptimalParams()}loadFisher(t,e){this.ewc.loadFisher(t,e)}getBaseWeights(){return new Float32Array(this.microLora.baseWeights)}setBaseWeights(t){let e=Math.min(t.length,this.microLora.baseWeights.length);for(let r=0;r<e;r++)this.microLora.baseWeights[r]=t[r]}getEffectiveWeights(){return this.microLora.getEffectiveWeights()}getRequestCount(){return this.requestCount}restoreRequestCount(t){this.requestCount=t}getConfig(){return{...this.config}}getPeerStates(){return new Map(this.peerStates)}getMicroLoRA(){return this.microLora}getEWC(){return this.ewc}applyEWCRegularization(){let t=this.config.dimension,e=this.ewc.fisherMatrix,r=this.ewc.optimalParams,a=this.microLora.baseWeights,n=.01;for(let o=0;o<t;o++)if(e[o]>this.config.importanceThreshold){let i=a[o]-r[o];a[o]-=n*e[o]*i}}persistFisher(t,e){let r=this.ewc.getMetrics();t(e,this.ewc.getFisherDiagonal(),this.ewc.getOptimalParams(),this.getBaseWeights(),{taskBoundaries:r.taskBoundariesDetected,consolidationCycles:r.consolidationCycles,requestCount:this.requestCount,ewcLambda:r.lambda}),f.info("Fisher matrix persisted to SQLite",{domain:e,requestCount:this.requestCount,taskBoundaries:r.taskBoundariesDetected})}restoreFisher(t){this.ewc.loadFisher(t.fisherDiagonal,t.optimalParams),t.baseWeights&&this.setBaseWeights(t.baseWeights),this.requestCount=t.requestCount,f.info("Fisher matrix restored from SQLite",{requestCount:t.requestCount,dimension:t.fisherDiagonal.length})}};var Lt={hiddenDim:256,embeddingDim:384,microLoraRank:1,baseLoraRank:8,microLoraLr:.001,baseLoraLr:1e-4,ewcLambda:1e3,patternClusters:50,trajectoryCapacity:1e4,backgroundIntervalMs:36e5,qualityThreshold:.5,enableSimd:!0,minConfidence:.5,maxPatterns:1e4},Q=class{patterns;trajectoryMap;maxPatterns;constructor(t=1e4){this.patterns=new Map,this.trajectoryMap=new Map,this.maxPatterns=t}register(t){if(this.patterns.size>=this.maxPatterns&&!this.patterns.has(t.id)){let e=Array.from(this.patterns.entries()).sort(([,r],[,a])=>(r.lastUsedAt?.getTime()??r.createdAt.getTime())-(a.lastUsedAt?.getTime()??a.createdAt.getTime()))[0];e&&this.patterns.delete(e[0])}this.patterns.set(t.id,t)}get(t){return this.patterns.get(t)}getByTrajectory(t){let e=this.trajectoryMap.get(t);return e?this.patterns.get(e):void 0}associateTrajectory(t,e){this.trajectoryMap.set(t,e)}update(t,e){let r=this.patterns.get(t);return r?(this.patterns.set(t,{...r,...e}),!0):!1}getAll(){return Array.from(this.patterns.values())}getByType(t){return Array.from(this.patterns.values()).filter(e=>e.type===t)}getByDomain(t){return Array.from(this.patterns.values()).filter(e=>e.domain===t)}delete(t){let e=this.patterns.delete(t);for(let[r,a]of this.trajectoryMap)a===t&&this.trajectoryMap.delete(r);return e}clear(){this.patterns.clear(),this.trajectoryMap.clear()}size(){return this.patterns.size}},v=class{engine;registry;config;adaptationTimes=[];cacheHits=0;totalAdaptations=0;threeLoopEngine=null;fisherPersistFn=null;fisherDomain="default";constructor(t={}){this.config={...Lt,...t};let e={hiddenDim:this.config.hiddenDim,embeddingDim:this.config.embeddingDim,microLoraRank:this.config.microLoraRank,baseLoraRank:this.config.baseLoraRank,microLoraLr:this.config.microLoraLr,baseLoraLr:this.config.baseLoraLr,ewcLambda:this.config.ewcLambda,patternClusters:this.config.patternClusters,trajectoryCapacity:this.config.trajectoryCapacity,backgroundIntervalMs:this.config.backgroundIntervalMs,qualityThreshold:this.config.qualityThreshold,enableSimd:this.config.enableSimd};this.engine=T.withConfig(e),this.registry=new Q(this.config.maxPatterns??1e4)}async adaptPattern(t,e,r){let a=performance.now();try{let n=this.createStateEmbedding(t),o=this.engine.findPatterns(n,5),i=[];for(let h of o){let g=this.findByRawPattern(h);if(g||(g=this.createQEPatternFromRaw(h,e,r)),g.type===e&&g.domain===r&&g.confidence>=(this.config.minConfidence??.5)){let m=this.calculateSimilarity(n,h.centroid);i.push({pattern:g,similarity:m})}}if(i.length===0){let h=performance.now()-a;return this.recordAdaptation(h),{success:!1,pattern:null,adaptationTimeMs:h,similarity:0,reasoning:"No suitable pattern found"}}let s=i[0],u={...s.pattern,usageCount:s.pattern.usageCount+1,lastUsedAt:new Date};this.registry.update(u.id,u);let c=performance.now()-a;return this.recordAdaptation(c),{success:!0,pattern:u,adaptationTimeMs:c,similarity:s.similarity,reasoning:`Pattern adapted from @ruvector/sona with ${s.similarity.toFixed(3)} similarity`}}catch(n){let o=performance.now()-a;return this.recordAdaptation(o),{success:!1,pattern:null,adaptationTimeMs:o,similarity:0,reasoning:`Adaptation failed: ${n.message}`}}}recallPattern(t,e,r){let a=this.createStateEmbedding(t),n=this.engine.findPatterns(a,1);for(let o of n){let i=this.findByRawPattern(o);if(i&&i.type===e&&i.domain===r)return i}return null}storePattern(t){this.registry.register(t);let e=this.engine.beginTrajectory(t.stateEmbedding),r=this.createActionEmbedding(t.action),a=new Array(r.length).fill(1),n=t.outcome.success?t.outcome.quality:-t.outcome.quality;this.engine.addTrajectoryStep(e,r,a,n),this.engine.endTrajectory(e,t.outcome.quality),this.registry.associateTrajectory(e,t.id)}storePatternsBatch(t){for(let e of t)this.storePattern(e)}createPattern(t,e,r,a,n,o){let i={id:`qesona-${Date.now()}-${Ct().slice(0,7)}`,type:a,domain:n,stateEmbedding:this.createStateEmbedding(t),action:e,outcome:r,confidence:.5,usageCount:0,createdAt:new Date,metadata:o};return this.storePattern(i),i}updatePattern(t,e,r){let a=this.registry.get(t);if(!a)return!1;let n=e?r:-r,i=a.confidence+.1*(n-a.confidence),s={...a,confidence:Math.max(0,Math.min(1,i)),usageCount:a.usageCount+1,lastUsedAt:new Date};return this.registry.update(t,s)}applyMicroLora(t){return this.engine.applyMicroLora(t)}applyBaseLora(t,e){return this.engine.applyBaseLora(t,e)}forceLearn(){return this.engine.forceLearn()}tick(){return this.engine.tick()}getAllPatterns(){return this.registry.getAll()}getPatternsByType(t){return this.registry.getByType(t)}getPatternsByDomain(t){return this.registry.getByDomain(t)}getStats(){let t=this.registry.getAll(),e=this.engine.getStats(),r={"test-generation":0,"defect-prediction":0,"coverage-optimization":0,"quality-assessment":0,"resource-allocation":0};for(let a of t)r[a.type]++;return{totalPatterns:t.length,patternsByType:r,avgAdaptationTimeMs:this.avgAdaptationTime(),minAdaptationTimeMs:this.minAdaptationTime(),maxAdaptationTimeMs:this.maxAdaptationTime(),totalAdaptations:this.totalAdaptations,cacheHitRate:this.totalAdaptations>0?this.cacheHits/this.totalAdaptations:0,engineStats:e}}deletePattern(t){return this.registry.delete(t)}clear(){this.registry.clear(),this.adaptationTimes=[],this.cacheHits=0,this.totalAdaptations=0}exportPatterns(){return this.registry.getAll()}importPatterns(t){this.clear(),this.storePatternsBatch(t)}getConfig(){return{...this.config}}setEnabled(t){this.engine.setEnabled(t)}isEnabled(){return this.engine.isEnabled()}createStateEmbedding(t){let e=t.features;if(e.length===0)return new Array(this.config.embeddingDim??384).fill(0);let r=Math.max(...e.map(Math.abs));if(r===0)return[...e];let a=e.map(o=>o/r),n=this.config.embeddingDim??384;return a.length>=n?a.slice(0,n):[...a,...new Array(n-a.length).fill(0)]}createActionEmbedding(t){let e=[],r=this.hashCode(t.type);if(e.push(r%1e3/1e3),typeof t.value=="number")e.push(Math.min(1,Math.max(-1,t.value)));else if(typeof t.value=="string"){let n=this.hashCode(t.value);e.push(n%1e3/1e3)}else if(Array.isArray(t.value))for(let n of t.value.slice(0,10))typeof n=="number"&&e.push(Math.min(1,Math.max(-1,n)));let a=this.config.embeddingDim??384;for(;e.length<a;)e.push(0);return e.slice(0,a)}findByRawPattern(t){let e=this.registry.getAll();for(let r of e)if(r.rawPattern?.patternType===t.id)return r}createQEPatternFromRaw(t,e,r){let a={centroid:t.centroid,clusterSize:1,totalWeight:1,avgQuality:t.avgQuality,createdAt:new Date().toISOString(),lastAccessed:new Date().toISOString(),accessCount:0,patternType:t.patternType};return{id:`qesona-${t.id}`,type:e,domain:r,stateEmbedding:t.centroid,action:{type:"learned",value:t.patternType},outcome:{reward:t.avgQuality,success:t.avgQuality>.5,quality:t.avgQuality},confidence:t.avgQuality,usageCount:0,createdAt:new Date,rawPattern:a}}calculateSimilarity(t,e){let r=Math.min(t.length,e.length),a=0,n=0,o=0;for(let s=0;s<r;s++)a+=t[s]*e[s],n+=t[s]*t[s],o+=e[s]*e[s];return(a/(Math.sqrt(n)*Math.sqrt(o)+1e-10)+1)/2}hashCode(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e=e|0;return Math.abs(e)}recordAdaptation(t){this.adaptationTimes.push(t),this.totalAdaptations++,this.adaptationTimes.length>1e3&&this.adaptationTimes.shift()}avgAdaptationTime(){return this.adaptationTimes.length===0?0:this.adaptationTimes.reduce((e,r)=>e+r,0)/this.adaptationTimes.length}minAdaptationTime(){return this.adaptationTimes.length===0?0:Math.min(...this.adaptationTimes)}maxAdaptationTime(){return this.adaptationTimes.length===0?0:Math.max(...this.adaptationTimes)}initThreeLoopEngine(t){this.threeLoopEngine=new C({dimension:this.config.embeddingDim??384,microLoraLr:this.config.microLoraLr??.001,ewcLambda:this.config.ewcLambda??1e3,...t},this.engine)}getThreeLoopEngine(){return this.threeLoopEngine}instantAdapt(t){return this.threeLoopEngine?this.threeLoopEngine.instantAdapt(t):null}recordOutcome(t,e){this.threeLoopEngine&&this.threeLoopEngine.recordOutcome(t,e)}backgroundConsolidate(){if(!this.threeLoopEngine)return null;let t=this.threeLoopEngine.backgroundConsolidate();if(t&&(t.consolidated||t.taskBoundaryDetected)&&this.fisherPersistFn)try{this.threeLoopEngine.persistFisher(this.fisherPersistFn,this.fisherDomain)}catch(e){console.warn("[QESONA] Fisher persistence failed:",e instanceof Error?e.message:e)}return t}setFisherPersistence(t,e){this.fisherPersistFn=t,this.fisherDomain=e}syncWithPeers(t){this.threeLoopEngine&&this.threeLoopEngine.syncWithPeers(t)}getEWCMetrics(){return this.threeLoopEngine?this.threeLoopEngine.getEWCMetrics():null}shouldConsolidate(){return this.threeLoopEngine?this.threeLoopEngine.shouldConsolidate():!1}getLocalPeerState(t,e){return this.threeLoopEngine?this.threeLoopEngine.getLocalPeerState(t,e):null}isThreeLoopEnabled(){return this.threeLoopEngine!==null}async verifyPerformance(t=1e3){let e=[],r={id:"test-state",features:new Array(384).fill(0).map(()=>G())};for(let s=0;s<t;s++){let u=performance.now();await this.adaptPattern(r,"test-generation","test-generation");let c=performance.now();e.push({iteration:s,timeMs:c-u})}let a=e.map(s=>s.timeMs),n=a.reduce((s,u)=>s+u,0)/a.length,o=Math.min(...a),i=Math.max(...a);return{targetMet:n<.05,avgTimeMs:n,minTimeMs:o,maxTimeMs:i,details:e}}};function Pt(l){return new v(l)}function Tt(l,t){return new v({...t,maxPatterns:t?.maxPatterns||5e3})}ot();et();var F=null,D=null,W=null,B=null,I=null,z=null,q=!1;try{let l=(O(),w(N));F=l.FlashAttention,D=l.DotProductAttention,W=l.MultiHeadAttention,B=l.HyperbolicAttention,I=l.LinearAttention,z=l.MoEAttention,q=!0}catch{}function Gt(){return q}function b(){if(!q)throw new Error("@ruvector/attention native module is not available on this platform. Install the appropriate optional dependency for your platform, or use a platform where pre-built binaries are available.")}var P={"test-similarity":{dim:384,strategy:"flash",blockSize:64},"code-embedding":{dim:512,strategy:"flash",blockSize:128},"defect-matching":{dim:384,strategy:"flash",blockSize:64},"coverage-analysis":{dim:384,strategy:"flash",blockSize:256},"pattern-adaptation":{dim:256,strategy:"flash",blockSize:32}},Kt={"test-similarity":{enabled:!0,microLoRARank:4,targetAdaptationMs:.05,patternCacheSize:1e3},"code-embedding":{enabled:!0,microLoRARank:2,targetAdaptationMs:.03,patternCacheSize:5e3},"defect-matching":{enabled:!0,microLoRARank:8,targetAdaptationMs:.05,patternCacheSize:2e3},"coverage-analysis":{enabled:!1,microLoRARank:2,targetAdaptationMs:.01,patternCacheSize:100},"pattern-adaptation":{enabled:!0,microLoRARank:2,targetAdaptationMs:.05,patternCacheSize:1e4}},$t={"test-similarity":{latency:{before:50,after:15},memory:{before:200,after:80},throughput:{min:1e3}},"code-embedding":{latency:{before:50,after:15},memory:{before:200,after:80},throughput:{min:2e3}},"defect-matching":{latency:{before:20,after:5},memory:{before:150,after:50},throughput:{min:500}},"coverage-analysis":{latency:{before:100,after:1},memory:{before:100,after:30},throughput:{min:1e4}},"pattern-adaptation":{latency:{before:2,after:.05},memory:{before:50,after:20},throughput:{min:2e4}}};function Zt(l){return l<=128?{queryChunkSize:128,kvChunkSize:128}:l<=256?{queryChunkSize:256,kvChunkSize:256}:l<=512?{queryChunkSize:512,kvChunkSize:512}:l<=1024?{queryChunkSize:1024,kvChunkSize:1024}:{queryChunkSize:1024,kvChunkSize:2048}}var E=class{static create(t){switch(b(),t.strategy){case"flash":return new F(t.dim,t.blockSize);case"dot-product":return new D(t.dim);case"multi-head":return new W(t.dim,t.numHeads??8);case"hyperbolic":return new B(t.dim,t.curvature);case"linear":return new I(t.dim,t.features);case"moe":return z.simple(t.dim,t.moeConfig?.numExperts??8,t.moeConfig?.topK??2);default:return new F(t.dim,t.blockSize)}}},L=class l{attention;config;workload;metrics=[];db=null;persistCount=0;static KV_NAMESPACE="attention-metrics";static KV_TTL=3600;static PERSIST_INTERVAL=10;constructor(t,e){this.workload=t;let r=P[t];this.config={...r,...e},this.attention=E.create(this.config)}async initialize(){try{this.db=K(),this.db.isInitialized()||await this.db.initialize(),await this.loadFromKv()}catch(t){console.warn("[QEFlashAttention] DB init failed, using memory-only:",j(t)),this.db=null}}async computeFlashAttention(t,e,r,a,n){let o=performance.now(),i=process.memoryUsage().heapUsed/1024/1024,s=this.toFloat32Array(t,a,n),u=this.splitMatrix(e,a,n),c=this.splitMatrix(r,a,n),h,g=this.attention;typeof g.compute=="function"?h=g.compute(s,u,c):(b(),h=new F(this.config.dim).compute(s,u,c));let m=performance.now(),d=process.memoryUsage().heapUsed/1024/1024;return this.metrics.push({timeMs:m-o,memoryMB:d-i,speedup:1,throughput:a*a/((m-o)/1e3),peakMemoryMB:d}),this.maybePersistToKv(),h}async computeBaselineAttention(t,e,r,a,n){let o=performance.now(),i=process.memoryUsage().heapUsed/1024/1024,s=new Float32Array(a*a),u=1/Math.sqrt(n);for(let m=0;m<a;m++)for(let d=0;d<a;d++){let A=0;for(let p=0;p<n;p++)A+=t[m*n+p]*e[d*n+p];s[m*a+d]=A*u}for(let m=0;m<a;m++){let d=m*a,A=d+a,p=s.subarray(d,A),tt=Math.max(...p),_=0;for(let y=0;y<a;y++)p[y]=Math.exp(p[y]-tt),_+=p[y];for(let y=0;y<a;y++)p[y]/=_}let c=new Float32Array(a*n);for(let m=0;m<a;m++)for(let d=0;d<a;d++){let A=s[m*a+d];for(let p=0;p<n;p++)c[m*n+p]+=A*r[d*n+p]}let h=performance.now(),g=process.memoryUsage().heapUsed/1024/1024;return c}async computeTestSimilarity(t,e,r=5){let a=e.length,n=t.length,o=new Float32Array(a*n),i=new Float32Array(a*n);for(let h=0;h<a;h++)o.set(t,h*n),i.set(e[h],h*n);let s=new Float32Array(a*n),u=await this.computeFlashAttention(o,i,s,a,n),c=[];for(let h=0;h<a;h++)c.push({index:h,similarity:u[h*n]});return c.sort((h,g)=>g.similarity-h.similarity),c.slice(0,r)}async generateCodeEmbedding(t,e){let r=t.length/e.length,a=e.length;return await this.computeFlashAttention(t,e,t,r,a)}async matchDefectPattern(t,e){let r=e.length,a=t.length,n=new Float32Array(r*a),o=new Float32Array(r*a);for(let c=0;c<r;c++)n.set(t,c*a),o.set(e[c],c*a);let i=new Float32Array(r*a),s=await this.computeFlashAttention(n,o,i,r,a),u=[];for(let c=0;c<r;c++)u.push({pattern:c,score:s[c*a]});return u.sort((c,h)=>h.score-c.score),u}getMetrics(){return[...this.metrics]}getAverageSpeedup(){return this.metrics.length===0?1:this.metrics.reduce((t,e)=>t+e.speedup,0)/this.metrics.length}getConfig(){return{...this.config}}updateConfig(t){this.config={...this.config,...t},this.attention=E.create(this.config)}changeStrategy(t){this.config.strategy=t,this.attention=E.create(this.config)}resetMetrics(){this.metrics=[]}getWorkload(){return this.workload}dispose(){this.metrics=[]}async persistToKv(){if(!this.db)return;let t=`attention-metrics-${this.workload}`,e={workload:this.workload,metrics:this.metrics.slice(-50),savedAt:Date.now()};await this.db.kvSet(t,e,l.KV_NAMESPACE,l.KV_TTL)}async loadFromKv(){if(!this.db)return;let t=`attention-metrics-${this.workload}`,e=await this.db.kvGet(t,l.KV_NAMESPACE);e?.metrics?.length&&(this.metrics=e.metrics)}maybePersistToKv(){this.persistCount++,this.persistCount>=l.PERSIST_INTERVAL&&(this.persistCount=0,this.persistToKv().catch(()=>{}))}toFloat32Array(t,e,r){return t.slice(0,r)}splitMatrix(t,e,r){let a=[];for(let n=0;n<e;n++)a.push(t.slice(n*r,(n+1)*r));return a}};async function Y(l,t){let e=new L(l,t);return await e.initialize(),e}function Jt(l){return{...P[l]}}function Xt(){return Object.keys(P)}function Yt(){return b(),F}function te(){return b(),D}function ee(){return b(),W}function re(){return b(),B}function ae(){return b(),I}function ne(){return b(),z}function ie(l){return l instanceof Float32Array?l:new Float32Array(l)}function oe(l){return Array.from(l)}async function se(l,t,e,r){let a=await Y(l),n=[],o=t[0].length,i=e.length;for(let s of t){let u=new Float32Array(i*o),c=new Float32Array(i*o),h=new Float32Array(i*o);u.set(s,0);for(let m=0;m<i;m++)c.set(e[m],m*o),h.set(r[m],m*o);let g=await a.computeFlashAttention(u,c,h,i,o);n.push(g.slice(0,o))}return a.dispose(),n}function We(){return{"@ruvector/sona":"^0.1.5","@ruvector/attention":"^0.1.4","@ruvector/gnn":"^0.1.22"}}function Be(){let l={sona:!1,attention:!1,gnn:!1,all:!1};try{k(),l.sona=!0}catch{}try{O(),l.attention=!0}catch{}try{let t=(it(),w(nt));t.init();let e=new Float32Array([.1,.2,.3]),r=[new Float32Array([.1,.2,.3]),new Float32Array([.4,.5,.6])],a=t.differentiableSearch(e,r,1,1);a&&Array.isArray(a.indices)&&Array.isArray(a.weights)&&(l.gnn=!0)}catch{}return l.all=l.sona&&l.attention&&l.gnn,l}async function Ie(){let{initGNN:l}=await import("./gnn-wrapper-ALBJVW6T.js");return[l(),"SONA: Ready (no initialization required)","Attention: Ready (no initialization required)"]}export{v as a,Pt as b,Tt as c,Gt as d,P as e,Kt as f,$t as g,Zt as h,L as i,Y as j,Jt as k,Xt as l,Yt as m,te as n,ee as o,re as p,ae as q,ne as r,ie as s,oe as t,se as u,We as v,Be as w,Ie as x};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.8");process.exit(0)}
2
- import{c as r,e as u}from"./chunk-J7FLNP5L.js";u();var a='expected [{ "functionName": "add", "args": [2, 3], "expected": 5 }]',p={type:"object",description:"One caller-owned specification example",properties:{functionName:{type:"string",description:"Named export of the source file to call"},args:{type:"array",description:"Positional JSON arguments; length must equal the function arity",items:{}},expected:{description:"Expected JSON return value (use null for a null result)"}},required:["functionName","args","expected"]};function s(o,n="Behavior example value"){let i=(e,t)=>{if(!(e===null||typeof e=="string"||typeof e=="boolean")&&!(typeof e=="number"&&Number.isFinite(e)&&!Object.is(e,-0))){if(typeof e!="object"||t.has(e))throw new r(`${n} must be finite JSON data (no undefined, functions, NaN/Infinity, cycles, or negative zero)`);if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new r(`${n} must contain only plain JSON objects`);t.add(e);for(let c of Array.isArray(e)?Array.from(e):Object.values(e))i(c,t);t.delete(e)}};i(o,new Set)}function l(o){if(o!==void 0){if(!Array.isArray(o))throw new r(`behaviorExamples must be an array; ${a}`);return o.forEach((n,i)=>{let e=`behaviorExamples[${i}]`;if(typeof n!="object"||n===null||Array.isArray(n))throw new r(`${e} must be an object; ${a}`);let t=n;if(typeof t.functionName!="string"||t.functionName.trim()==="")throw new r(`${e}.functionName must be a non-empty string`);if(!Array.isArray(t.args))throw new r(`${e}.args must be an array of arguments`);if(!Object.prototype.hasOwnProperty.call(t,"expected"))throw new r(`${e}.expected is required (use null for a null result)`);s(t.args,`${e}.args`),s(t.expected,`${e}.expected`)}),o}}export{p as a,s as b,l as c};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.9");process.exit(0)}
2
+ import{c as r,e as u}from"./chunk-N3KEY4XJ.js";u();var a='expected [{ "functionName": "add", "args": [2, 3], "expected": 5 }]',p={type:"object",description:"One caller-owned specification example",properties:{functionName:{type:"string",description:"Named export of the source file to call"},args:{type:"array",description:"Positional JSON arguments; length must equal the function arity",items:{}},expected:{description:"Expected JSON return value (use null for a null result)"}},required:["functionName","args","expected"]};function s(o,n="Behavior example value"){let i=(e,t)=>{if(!(e===null||typeof e=="string"||typeof e=="boolean")&&!(typeof e=="number"&&Number.isFinite(e)&&!Object.is(e,-0))){if(typeof e!="object"||t.has(e))throw new r(`${n} must be finite JSON data (no undefined, functions, NaN/Infinity, cycles, or negative zero)`);if(!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw new r(`${n} must contain only plain JSON objects`);t.add(e);for(let c of Array.isArray(e)?Array.from(e):Object.values(e))i(c,t);t.delete(e)}};i(o,new Set)}function l(o){if(o!==void 0){if(!Array.isArray(o))throw new r(`behaviorExamples must be an array; ${a}`);return o.forEach((n,i)=>{let e=`behaviorExamples[${i}]`;if(typeof n!="object"||n===null||Array.isArray(n))throw new r(`${e} must be an object; ${a}`);let t=n;if(typeof t.functionName!="string"||t.functionName.trim()==="")throw new r(`${e}.functionName must be a non-empty string`);if(!Array.isArray(t.args))throw new r(`${e}.args must be an array of arguments`);if(!Object.prototype.hasOwnProperty.call(t,"expected"))throw new r(`${e}.expected is required (use null for a null result)`);s(t.args,`${e}.args`),s(t.expected,`${e}.expected`)}),o}}export{p as a,s as b,l as c};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.8");process.exit(0)}
2
- import{a as o,b as s,c as n,f as a}from"./chunk-CQ5G64EA.js";a();import{existsSync as d,statSync as l}from"node:fs";import{join as u,resolve as p}from"node:path";function c(r=process.cwd(),t=process.env){return p(r,t.AQE_PROJECT_ROOT||".")}function E(r,t){return(t?o(r)||s(r)&&!d(u(r,".git")):n(r))?`Refusing to initialize in "${r}": it is a shared temp/system directory, so a store here would be shared by every unrelated project below it and later commands would not use it. Create a project directory first (mkdir my-project && cd my-project) or set AQE_PROJECT_ROOT to a project directory.`:null}function O(r,t=process.env){return E(c(r,t),!!t.AQE_PROJECT_ROOT)}function h(r=process.cwd(),t=process.env){if(!t.AQE_PROJECT_ROOT)return null;let e=c(r,t),i=!1;try{i=l(e).isDirectory()}catch{i=!1}return i?null:`AQE_PROJECT_ROOT "${e}" is not an existing directory. Create it first (mkdir -p) or correct the path; aqe init does not create the project root.`}export{c as a,E as b,O as c,h as d};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.9");process.exit(0)}
2
+ import{a as o,b as s,c as n,f as a}from"./chunk-H3KBIWTO.js";a();import{existsSync as d,statSync as l}from"node:fs";import{join as u,resolve as p}from"node:path";function c(r=process.cwd(),t=process.env){return p(r,t.AQE_PROJECT_ROOT||".")}function E(r,t){return(t?o(r)||s(r)&&!d(u(r,".git")):n(r))?`Refusing to initialize in "${r}": it is a shared temp/system directory, so a store here would be shared by every unrelated project below it and later commands would not use it. Create a project directory first (mkdir my-project && cd my-project) or set AQE_PROJECT_ROOT to a project directory.`:null}function O(r,t=process.env){return E(c(r,t),!!t.AQE_PROJECT_ROOT)}function h(r=process.cwd(),t=process.env){if(!t.AQE_PROJECT_ROOT)return null;let e=c(r,t),i=!1;try{i=l(e).isDirectory()}catch{i=!1}return i?null:`AQE_PROJECT_ROOT "${e}" is not an existing directory. Create it first (mkdir -p) or correct the path; aqe init does not create the project root.`}export{c as a,E as b,O as c,h as d};
@@ -1,2 +1,2 @@
1
- import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.8");process.exit(0)}
2
- import{a as T}from"./chunk-X6VYQVUM.js";import{e as g}from"./chunk-7H3GNRNA.js";import{S,b as l}from"./chunk-KVMKYUOE.js";T();S();import{createRequire as B}from"module";var G=B(import.meta.url),d=class{validateTransfer(e,t){return{approved:!0}}};function R(){if(l().useCoherenceGate)try{let{CoherenceGate:o}=G("./coherence-gate.js");return new o}catch{}return new d}T();var x=g.create("transfer-verification"),A={maxSourceRegression:.05,minTargetImprovement:0,maxSourceConfidenceRegression:.1},b=class{config;constructor(e={}){this.config={...A,...e}}verifyTransfer(e){let t=e.sourcePerformanceAfter.successRate-e.sourcePerformanceBefore.successRate,r=e.targetPerformanceAfter.successRate-e.targetPerformanceBefore.successRate,n=e.sourcePerformanceAfter.avgConfidence-e.sourcePerformanceBefore.avgConfidence,a=e.targetPerformanceAfter.avgConfidence-e.targetPerformanceBefore.avgConfidence,s=t>=-this.config.maxSourceRegression&&n>=-this.config.maxSourceConfidenceRegression,c=r>=this.config.minTargetImprovement,u=s&&c,m;if(!u){let i=[];s||i.push(`source domain regressed: successRate delta=${t.toFixed(4)}, confidence delta=${n.toFixed(4)}`),c||i.push(`target domain did not improve: successRate delta=${r.toFixed(4)}`),m=i.join("; ")}return u?x.debug("Transfer verification passed",{transferId:e.transferId,sourceDelta:t,targetDelta:r}):x.warn("Transfer verification failed",{transferId:e.transferId,sourceDomain:e.sourceDomain,targetDomain:e.targetDomain,sourceDelta:t,targetDelta:r,failureReason:m}),{passed:u,sourceStable:s,targetImproved:c,sourceDelta:t,targetDelta:r,sourceConfidenceDelta:n,targetConfidenceDelta:a,failureReason:m}}getConfig(){return{...this.config}}};function M(o){return new b(o)}S();var p=class{alphas=new Map;betas=new Map;sample(e){let t=this.alphas.get(e)??1,r=this.betas.get(e)??1;return this.sampleBeta(t,r)}update(e,t){t?this.alphas.set(e,(this.alphas.get(e)??1)+1):this.betas.set(e,(this.betas.get(e)??1)+1)}getMean(e){let t=this.alphas.get(e)??1,r=this.betas.get(e)??1;return t/(t+r)}getObservationCount(e){let t=this.alphas.get(e)??1,r=this.betas.get(e)??1;return t-1+(r-1)}getAlpha(e){return this.alphas.get(e)??1}getBeta(e){return this.betas.get(e)??1}sampleBeta(e,t){let r=this.sampleGamma(e),n=this.sampleGamma(t);return r+n===0?.5:r/(r+n)}sampleGamma(e){if(e<1){let n=Math.random();return this.sampleGamma(e+1)*Math.pow(n,1/e)}let t=e-1/3,r=1/Math.sqrt(9*t);for(;;){let n,a;do n=this.standardNormal(),a=1+r*n;while(a<=0);a=a*a*a;let s=Math.random();if(s<1-.0331*n*n*n*n||Math.log(s)<.5*n*n+t*(1-a+Math.log(a)))return t*a}}standardNormal(){let e=Math.random(),t=Math.random();return Math.sqrt(-2*Math.log(e||1e-10))*Math.cos(2*Math.PI*t)}};var I={threshold:5,slack:.5,resetOnAlarm:!0,warmupSamples:20},h=class{config;states=new Map;constructor(e={}){this.config={...I,...e}}update(e,t){let r=this.getOrCreateState(e);if(r.samplesSinceReset++,r.mu===null)return r.warmupSum+=t,r.warmupCount++,r.warmupCount>=this.config.warmupSamples&&(r.mu=r.warmupSum/r.warmupCount),{driftDetected:!1,cumulativeSum:0,direction:"none",samplesSinceReset:r.samplesSinceReset};r.sPlus=Math.max(0,r.sPlus+(t-r.mu-this.config.slack)),r.sMinus=Math.max(0,r.sMinus+(-t+r.mu-this.config.slack));let n=Math.max(r.sPlus,r.sMinus),a=!1,s="none";r.sPlus>this.config.threshold?(a=!0,s="positive"):r.sMinus>this.config.threshold&&(a=!0,s="negative");let c={driftDetected:a,cumulativeSum:n,direction:s,samplesSinceReset:r.samplesSinceReset};return a&&this.config.resetOnAlarm&&(r.sPlus=0,r.sMinus=0,r.samplesSinceReset=0),c}reset(e){e?this.states.delete(e):this.states.clear()}getState(e){let t=this.states.get(e);if(!t)return{driftDetected:!1,cumulativeSum:0,direction:"none",samplesSinceReset:0};let r=Math.max(t.sPlus,t.sMinus),n="none";return t.sPlus>this.config.threshold?n="positive":t.sMinus>this.config.threshold&&(n="negative"),{driftDetected:t.sPlus>this.config.threshold||t.sMinus>this.config.threshold,cumulativeSum:r,direction:n,samplesSinceReset:t.samplesSinceReset}}getOrCreateState(e){let t=this.states.get(e);return t||(t={sPlus:0,sMinus:0,samplesSinceReset:0,warmupSum:0,warmupCount:0,mu:null},this.states.set(e,t)),t}};var w=g.create("domain-transfer"),V={minTransferProbability:.3,explorationWarmup:5,verification:{},maxHistorySize:1e3,useMetaLearningEnhancements:!0},v=class{constructor(e=100){this.decayThreshold=e}decayThreshold;getDecayMultiplier(e){return e<=0?1:Math.pow(.5,e/this.decayThreshold)}applyDecay(e,t,r){return t+(e-t)*this.getDecayMultiplier(r)}},y=class{cusum;outcomes=[];windowSize;constructor(e=20){this.windowSize=e,this.cusum=new h({threshold:3,slack:.1,resetOnAlarm:!1,warmupSamples:Math.min(10,Math.floor(e/2))})}record(e){this.outcomes.push(e),this.outcomes.length>this.windowSize*2&&this.outcomes.splice(0,this.outcomes.length-this.windowSize*2);let t=this.getCurrentRate();this.cusum.update("learn",t)}isPlateaued(){return this.outcomes.length<this.windowSize?!1:!this.cusum.getState("learn").driftDetected}getCurrentRate(){if(this.outcomes.length===0)return 0;let e=this.outcomes.slice(-this.windowSize);return e.filter(Boolean).length/e.length}getOutcomeCount(){return this.outcomes.length}getCusumState(){return this.cusum.getState("learn")}},D=class{front=[];dominates(e,t){let r=e.successRate>=t.successRate&&e.speed>=t.speed&&e.confidence>=t.confidence,n=e.successRate>t.successRate||e.speed>t.speed||e.confidence>t.confidence;return r&&n}add(e){for(let t=this.front.length-1;t>=0;t--)this.dominates(e,this.front[t])&&this.front.splice(t,1);this.front.some(t=>this.dominates(t,e))||this.front.push(e)}getFront(){return[...this.front]}isNonDominated(e){return!this.front.some(t=>this.dominates(t,e))}},C=class{constructor(e=.2){this.bonusScale=e}bonusScale;triedPairs=new Set;markTried(e){this.triedPairs.add(e)}isTried(e){return this.triedPairs.has(e)}getBonus(e){return this.triedPairs.has(e)?0:this.bonusScale}apply(e,t){return Math.min(1,e+this.getBonus(t))}getTriedCount(){return this.triedPairs.size}},P=class{config;sampler;verifier;coherenceGate;transferHistory=[];affinityScores=new Map;performanceProvider=null;transferExecutor=null;nativeModule=null;decayingBeta;plateauDetector;paretoFront;curiosityBonus;constructor(e={}){this.config={...V,...e},this.sampler=new p,this.verifier=M(this.config.verification),this.coherenceGate=R(),this.decayingBeta=new v,this.plateauDetector=new y,this.paretoFront=new D,this.curiosityBonus=new C,this.tryLoadNativeModule()}evaluateTransfer(e,t){if(!this.isEnabled())return this.createRejectedCandidate(e,t);let r=this.makePairKey(e,t),n=this.sampler.sample(r),s=this.sampler.getObservationCount(r)<this.config.explorationWarmup,c=this.getAffinityScore(e,t);if(this.isMetaLearningEnabled()){let u=this.sampler.getMean(r),m=this.sampler.getAlpha(r)-1;n=this.decayingBeta.applyDecay(n,u,m),n=this.curiosityBonus.apply(n,r)}return{sourceDomain:e,targetDomain:t,sampledProbability:n,affinityScore:c,isExploration:s,pairKey:r}}executeTransfer(e){let t=`transfer-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,r=this.coherenceGate.validateTransfer({domain:e.sourceDomain},e.targetDomain);if(!r.approved)return w.info("Transfer blocked by coherence gate",{transferId:t,source:e.sourceDomain,target:e.targetDomain,reason:r.rejectionReason}),this.createBlockedResult(t,e,r);let n=this.getPerformanceSnapshot(e.sourceDomain),a=this.getPerformanceSnapshot(e.targetDomain),s=this.computeSqrtDampening(e),c=this.doTransfer(e.sourceDomain,e.targetDomain,s),u=this.getPerformanceSnapshot(e.sourceDomain),m=this.getPerformanceSnapshot(e.targetDomain),i=this.verifier.verifyTransfer({transferId:t,sourceDomain:e.sourceDomain,targetDomain:e.targetDomain,sourcePerformanceBefore:n,sourcePerformanceAfter:u,targetPerformanceBefore:a,targetPerformanceAfter:m}),f=c&&i.passed;if(this.sampler.update(e.pairKey,f),this.updateAffinityScore(e.pairKey,f),this.isMetaLearningEnabled()){this.plateauDetector.record(f),this.curiosityBonus.markTried(e.pairKey);let F=this.sampler.getMean(e.pairKey);this.paretoFront.add({pairKey:e.pairKey,successRate:F,speed:1/(1+s),confidence:this.getAffinityScore(e.sourceDomain,e.targetDomain)})}return this.addToHistory({transferId:t,sourceDomain:e.sourceDomain,targetDomain:e.targetDomain,success:f,sampledProbability:e.sampledProbability,dampeningFactor:s,sourceDelta:i.sourceDelta,targetDelta:i.targetDelta,timestamp:Date.now()}),w.info("Transfer completed",{transferId:t,source:e.sourceDomain,target:e.targetDomain,success:f,dampeningFactor:s.toFixed(4),sourceDelta:i.sourceDelta.toFixed(4),targetDelta:i.targetDelta.toFixed(4)}),{transferId:t,candidate:e,success:f,dampeningFactor:s,verification:i,coherenceResult:r,sourcePerformanceBefore:n,sourcePerformanceAfter:u,targetPerformanceBefore:a,targetPerformanceAfter:m,timestamp:Date.now()}}getAffinityScore(e,t){return this.affinityScores.get(this.makePairKey(e,t))??.5}getTransferHistory(){return[...this.transferHistory]}getExpectedSuccessRate(e,t){return this.sampler.getMean(this.makePairKey(e,t))}getObservationCount(e,t){return this.sampler.getObservationCount(this.makePairKey(e,t))}setPerformanceProvider(e){this.performanceProvider=e}setTransferExecutor(e){this.transferExecutor=e}getSampler(){return this.sampler}getCoherenceGate(){return this.coherenceGate}getDecayingBeta(){return this.decayingBeta}getPlateauDetector(){return this.plateauDetector}getParetoFront(){return this.paretoFront}getCuriosityBonus(){return this.curiosityBonus}isLearningPlateaued(){return this.plateauDetector.isPlateaued()}isEnabled(){return l().useCrossDomainTransfer===!0}isMetaLearningEnabled(){return this.config.useMetaLearningEnhancements===!0&&l().useMetaLearningEnhancements!==!1}makePairKey(e,t){return`${e}->${t}`}computeSqrtDampening(e){let t=this.sampler.getObservationCount(e.pairKey);return Math.sqrt(t/(t+this.config.explorationWarmup))}doTransfer(e,t,r){return this.transferExecutor?this.transferExecutor(e,t,r):!0}getPerformanceSnapshot(e){return this.performanceProvider?this.performanceProvider(e):{domain:e,successRate:.5,avgConfidence:.5,patternCount:0,timestamp:Date.now()}}updateAffinityScore(e,t){let r=this.affinityScores.get(e)??.5;this.affinityScores.set(e,.2*(t?1:0)+.8*r)}addToHistory(e){for(this.transferHistory.push(e);this.transferHistory.length>this.config.maxHistorySize;)this.transferHistory.shift()}createBlockedResult(e,t,r){let n={domain:"",successRate:0,avgConfidence:0,patternCount:0,timestamp:Date.now()};return{transferId:e,candidate:t,success:!1,dampeningFactor:0,verification:{passed:!1,sourceStable:!1,targetImproved:!1,sourceDelta:0,targetDelta:0,sourceConfidenceDelta:0,targetConfidenceDelta:0,failureReason:`Coherence gate rejected: ${r.rejectionReason??"unknown"}`},coherenceResult:r,sourcePerformanceBefore:{...n,domain:t.sourceDomain},sourcePerformanceAfter:{...n,domain:t.sourceDomain},targetPerformanceBefore:{...n,domain:t.targetDomain},targetPerformanceAfter:{...n,domain:t.targetDomain},timestamp:Date.now()}}createRejectedCandidate(e,t){return{sourceDomain:e,targetDomain:t,sampledProbability:0,affinityScore:0,isExploration:!1,pairKey:this.makePairKey(e,t)}}tryLoadNativeModule(){this.nativeModule=null}};function J(o){return new P(o)}export{p as a,h as b,V as c,v as d,y as e,D as f,C as g,P as h,J as i};
1
+ import{createRequire as __cr}from"module";const require=__cr(import.meta.url);if(process.argv.includes('--version')||process.argv.includes('-v')){console.log("3.15.9");process.exit(0)}
2
+ import{a as T}from"./chunk-KTSLTZSG.js";import{e as g}from"./chunk-O3JLOVZX.js";import{S,b as l}from"./chunk-2I2UPJS7.js";T();S();import{createRequire as B}from"module";var G=B(import.meta.url),d=class{validateTransfer(e,t){return{approved:!0}}};function R(){if(l().useCoherenceGate)try{let{CoherenceGate:o}=G("./coherence-gate.js");return new o}catch{}return new d}T();var x=g.create("transfer-verification"),A={maxSourceRegression:.05,minTargetImprovement:0,maxSourceConfidenceRegression:.1},b=class{config;constructor(e={}){this.config={...A,...e}}verifyTransfer(e){let t=e.sourcePerformanceAfter.successRate-e.sourcePerformanceBefore.successRate,r=e.targetPerformanceAfter.successRate-e.targetPerformanceBefore.successRate,n=e.sourcePerformanceAfter.avgConfidence-e.sourcePerformanceBefore.avgConfidence,a=e.targetPerformanceAfter.avgConfidence-e.targetPerformanceBefore.avgConfidence,s=t>=-this.config.maxSourceRegression&&n>=-this.config.maxSourceConfidenceRegression,c=r>=this.config.minTargetImprovement,u=s&&c,m;if(!u){let i=[];s||i.push(`source domain regressed: successRate delta=${t.toFixed(4)}, confidence delta=${n.toFixed(4)}`),c||i.push(`target domain did not improve: successRate delta=${r.toFixed(4)}`),m=i.join("; ")}return u?x.debug("Transfer verification passed",{transferId:e.transferId,sourceDelta:t,targetDelta:r}):x.warn("Transfer verification failed",{transferId:e.transferId,sourceDomain:e.sourceDomain,targetDomain:e.targetDomain,sourceDelta:t,targetDelta:r,failureReason:m}),{passed:u,sourceStable:s,targetImproved:c,sourceDelta:t,targetDelta:r,sourceConfidenceDelta:n,targetConfidenceDelta:a,failureReason:m}}getConfig(){return{...this.config}}};function M(o){return new b(o)}S();var p=class{alphas=new Map;betas=new Map;sample(e){let t=this.alphas.get(e)??1,r=this.betas.get(e)??1;return this.sampleBeta(t,r)}update(e,t){t?this.alphas.set(e,(this.alphas.get(e)??1)+1):this.betas.set(e,(this.betas.get(e)??1)+1)}getMean(e){let t=this.alphas.get(e)??1,r=this.betas.get(e)??1;return t/(t+r)}getObservationCount(e){let t=this.alphas.get(e)??1,r=this.betas.get(e)??1;return t-1+(r-1)}getAlpha(e){return this.alphas.get(e)??1}getBeta(e){return this.betas.get(e)??1}sampleBeta(e,t){let r=this.sampleGamma(e),n=this.sampleGamma(t);return r+n===0?.5:r/(r+n)}sampleGamma(e){if(e<1){let n=Math.random();return this.sampleGamma(e+1)*Math.pow(n,1/e)}let t=e-1/3,r=1/Math.sqrt(9*t);for(;;){let n,a;do n=this.standardNormal(),a=1+r*n;while(a<=0);a=a*a*a;let s=Math.random();if(s<1-.0331*n*n*n*n||Math.log(s)<.5*n*n+t*(1-a+Math.log(a)))return t*a}}standardNormal(){let e=Math.random(),t=Math.random();return Math.sqrt(-2*Math.log(e||1e-10))*Math.cos(2*Math.PI*t)}};var I={threshold:5,slack:.5,resetOnAlarm:!0,warmupSamples:20},h=class{config;states=new Map;constructor(e={}){this.config={...I,...e}}update(e,t){let r=this.getOrCreateState(e);if(r.samplesSinceReset++,r.mu===null)return r.warmupSum+=t,r.warmupCount++,r.warmupCount>=this.config.warmupSamples&&(r.mu=r.warmupSum/r.warmupCount),{driftDetected:!1,cumulativeSum:0,direction:"none",samplesSinceReset:r.samplesSinceReset};r.sPlus=Math.max(0,r.sPlus+(t-r.mu-this.config.slack)),r.sMinus=Math.max(0,r.sMinus+(-t+r.mu-this.config.slack));let n=Math.max(r.sPlus,r.sMinus),a=!1,s="none";r.sPlus>this.config.threshold?(a=!0,s="positive"):r.sMinus>this.config.threshold&&(a=!0,s="negative");let c={driftDetected:a,cumulativeSum:n,direction:s,samplesSinceReset:r.samplesSinceReset};return a&&this.config.resetOnAlarm&&(r.sPlus=0,r.sMinus=0,r.samplesSinceReset=0),c}reset(e){e?this.states.delete(e):this.states.clear()}getState(e){let t=this.states.get(e);if(!t)return{driftDetected:!1,cumulativeSum:0,direction:"none",samplesSinceReset:0};let r=Math.max(t.sPlus,t.sMinus),n="none";return t.sPlus>this.config.threshold?n="positive":t.sMinus>this.config.threshold&&(n="negative"),{driftDetected:t.sPlus>this.config.threshold||t.sMinus>this.config.threshold,cumulativeSum:r,direction:n,samplesSinceReset:t.samplesSinceReset}}getOrCreateState(e){let t=this.states.get(e);return t||(t={sPlus:0,sMinus:0,samplesSinceReset:0,warmupSum:0,warmupCount:0,mu:null},this.states.set(e,t)),t}};var w=g.create("domain-transfer"),V={minTransferProbability:.3,explorationWarmup:5,verification:{},maxHistorySize:1e3,useMetaLearningEnhancements:!0},v=class{constructor(e=100){this.decayThreshold=e}decayThreshold;getDecayMultiplier(e){return e<=0?1:Math.pow(.5,e/this.decayThreshold)}applyDecay(e,t,r){return t+(e-t)*this.getDecayMultiplier(r)}},y=class{cusum;outcomes=[];windowSize;constructor(e=20){this.windowSize=e,this.cusum=new h({threshold:3,slack:.1,resetOnAlarm:!1,warmupSamples:Math.min(10,Math.floor(e/2))})}record(e){this.outcomes.push(e),this.outcomes.length>this.windowSize*2&&this.outcomes.splice(0,this.outcomes.length-this.windowSize*2);let t=this.getCurrentRate();this.cusum.update("learn",t)}isPlateaued(){return this.outcomes.length<this.windowSize?!1:!this.cusum.getState("learn").driftDetected}getCurrentRate(){if(this.outcomes.length===0)return 0;let e=this.outcomes.slice(-this.windowSize);return e.filter(Boolean).length/e.length}getOutcomeCount(){return this.outcomes.length}getCusumState(){return this.cusum.getState("learn")}},D=class{front=[];dominates(e,t){let r=e.successRate>=t.successRate&&e.speed>=t.speed&&e.confidence>=t.confidence,n=e.successRate>t.successRate||e.speed>t.speed||e.confidence>t.confidence;return r&&n}add(e){for(let t=this.front.length-1;t>=0;t--)this.dominates(e,this.front[t])&&this.front.splice(t,1);this.front.some(t=>this.dominates(t,e))||this.front.push(e)}getFront(){return[...this.front]}isNonDominated(e){return!this.front.some(t=>this.dominates(t,e))}},C=class{constructor(e=.2){this.bonusScale=e}bonusScale;triedPairs=new Set;markTried(e){this.triedPairs.add(e)}isTried(e){return this.triedPairs.has(e)}getBonus(e){return this.triedPairs.has(e)?0:this.bonusScale}apply(e,t){return Math.min(1,e+this.getBonus(t))}getTriedCount(){return this.triedPairs.size}},P=class{config;sampler;verifier;coherenceGate;transferHistory=[];affinityScores=new Map;performanceProvider=null;transferExecutor=null;nativeModule=null;decayingBeta;plateauDetector;paretoFront;curiosityBonus;constructor(e={}){this.config={...V,...e},this.sampler=new p,this.verifier=M(this.config.verification),this.coherenceGate=R(),this.decayingBeta=new v,this.plateauDetector=new y,this.paretoFront=new D,this.curiosityBonus=new C,this.tryLoadNativeModule()}evaluateTransfer(e,t){if(!this.isEnabled())return this.createRejectedCandidate(e,t);let r=this.makePairKey(e,t),n=this.sampler.sample(r),s=this.sampler.getObservationCount(r)<this.config.explorationWarmup,c=this.getAffinityScore(e,t);if(this.isMetaLearningEnabled()){let u=this.sampler.getMean(r),m=this.sampler.getAlpha(r)-1;n=this.decayingBeta.applyDecay(n,u,m),n=this.curiosityBonus.apply(n,r)}return{sourceDomain:e,targetDomain:t,sampledProbability:n,affinityScore:c,isExploration:s,pairKey:r}}executeTransfer(e){let t=`transfer-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,r=this.coherenceGate.validateTransfer({domain:e.sourceDomain},e.targetDomain);if(!r.approved)return w.info("Transfer blocked by coherence gate",{transferId:t,source:e.sourceDomain,target:e.targetDomain,reason:r.rejectionReason}),this.createBlockedResult(t,e,r);let n=this.getPerformanceSnapshot(e.sourceDomain),a=this.getPerformanceSnapshot(e.targetDomain),s=this.computeSqrtDampening(e),c=this.doTransfer(e.sourceDomain,e.targetDomain,s),u=this.getPerformanceSnapshot(e.sourceDomain),m=this.getPerformanceSnapshot(e.targetDomain),i=this.verifier.verifyTransfer({transferId:t,sourceDomain:e.sourceDomain,targetDomain:e.targetDomain,sourcePerformanceBefore:n,sourcePerformanceAfter:u,targetPerformanceBefore:a,targetPerformanceAfter:m}),f=c&&i.passed;if(this.sampler.update(e.pairKey,f),this.updateAffinityScore(e.pairKey,f),this.isMetaLearningEnabled()){this.plateauDetector.record(f),this.curiosityBonus.markTried(e.pairKey);let F=this.sampler.getMean(e.pairKey);this.paretoFront.add({pairKey:e.pairKey,successRate:F,speed:1/(1+s),confidence:this.getAffinityScore(e.sourceDomain,e.targetDomain)})}return this.addToHistory({transferId:t,sourceDomain:e.sourceDomain,targetDomain:e.targetDomain,success:f,sampledProbability:e.sampledProbability,dampeningFactor:s,sourceDelta:i.sourceDelta,targetDelta:i.targetDelta,timestamp:Date.now()}),w.info("Transfer completed",{transferId:t,source:e.sourceDomain,target:e.targetDomain,success:f,dampeningFactor:s.toFixed(4),sourceDelta:i.sourceDelta.toFixed(4),targetDelta:i.targetDelta.toFixed(4)}),{transferId:t,candidate:e,success:f,dampeningFactor:s,verification:i,coherenceResult:r,sourcePerformanceBefore:n,sourcePerformanceAfter:u,targetPerformanceBefore:a,targetPerformanceAfter:m,timestamp:Date.now()}}getAffinityScore(e,t){return this.affinityScores.get(this.makePairKey(e,t))??.5}getTransferHistory(){return[...this.transferHistory]}getExpectedSuccessRate(e,t){return this.sampler.getMean(this.makePairKey(e,t))}getObservationCount(e,t){return this.sampler.getObservationCount(this.makePairKey(e,t))}setPerformanceProvider(e){this.performanceProvider=e}setTransferExecutor(e){this.transferExecutor=e}getSampler(){return this.sampler}getCoherenceGate(){return this.coherenceGate}getDecayingBeta(){return this.decayingBeta}getPlateauDetector(){return this.plateauDetector}getParetoFront(){return this.paretoFront}getCuriosityBonus(){return this.curiosityBonus}isLearningPlateaued(){return this.plateauDetector.isPlateaued()}isEnabled(){return l().useCrossDomainTransfer===!0}isMetaLearningEnabled(){return this.config.useMetaLearningEnhancements===!0&&l().useMetaLearningEnhancements!==!1}makePairKey(e,t){return`${e}->${t}`}computeSqrtDampening(e){let t=this.sampler.getObservationCount(e.pairKey);return Math.sqrt(t/(t+this.config.explorationWarmup))}doTransfer(e,t,r){return this.transferExecutor?this.transferExecutor(e,t,r):!0}getPerformanceSnapshot(e){return this.performanceProvider?this.performanceProvider(e):{domain:e,successRate:.5,avgConfidence:.5,patternCount:0,timestamp:Date.now()}}updateAffinityScore(e,t){let r=this.affinityScores.get(e)??.5;this.affinityScores.set(e,.2*(t?1:0)+.8*r)}addToHistory(e){for(this.transferHistory.push(e);this.transferHistory.length>this.config.maxHistorySize;)this.transferHistory.shift()}createBlockedResult(e,t,r){let n={domain:"",successRate:0,avgConfidence:0,patternCount:0,timestamp:Date.now()};return{transferId:e,candidate:t,success:!1,dampeningFactor:0,verification:{passed:!1,sourceStable:!1,targetImproved:!1,sourceDelta:0,targetDelta:0,sourceConfidenceDelta:0,targetConfidenceDelta:0,failureReason:`Coherence gate rejected: ${r.rejectionReason??"unknown"}`},coherenceResult:r,sourcePerformanceBefore:{...n,domain:t.sourceDomain},sourcePerformanceAfter:{...n,domain:t.sourceDomain},targetPerformanceBefore:{...n,domain:t.targetDomain},targetPerformanceAfter:{...n,domain:t.targetDomain},timestamp:Date.now()}}createRejectedCandidate(e,t){return{sourceDomain:e,targetDomain:t,sampledProbability:0,affinityScore:0,isExploration:!1,pairKey:this.makePairKey(e,t)}}tryLoadNativeModule(){this.nativeModule=null}};function J(o){return new P(o)}export{p as a,h as b,V as c,v as d,y as e,D as f,C as g,P as h,J as i};