agentic-qe 3.11.4 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (449) hide show
  1. package/.claude/helpers/.helpers-version +1 -0
  2. package/.claude/helpers/auto-memory-hook.mjs +35 -3
  3. package/.claude/helpers/brain-checkpoint.cjs +16 -1
  4. package/.claude/helpers/helpers.manifest.json +12 -0
  5. package/.claude/helpers/hook-handler.cjs +26 -5
  6. package/.claude/helpers/intelligence.cjs +14 -1
  7. package/.claude/hooks/aqe-hook.cjs +57 -10
  8. package/.claude/skills/skills-manifest.json +1 -1
  9. package/CHANGELOG.md +110 -0
  10. package/assets/skills/skills-manifest.json +1 -1
  11. package/dist/adapters/a2a/auth/routes.js +59 -28
  12. package/dist/audit/witness-chain.d.ts +25 -0
  13. package/dist/audit/witness-chain.js +69 -22
  14. package/dist/audit/witness-key-manager.d.ts +11 -0
  15. package/dist/audit/witness-key-manager.js +24 -0
  16. package/dist/cli/brain-commands.js +2 -1
  17. package/dist/cli/bundle.js +6 -6
  18. package/dist/cli/chunks/adapter-6IWRIHF3.js +2 -0
  19. package/dist/cli/chunks/{agent-booster-wasm-62I6ZNRW.js → agent-booster-wasm-IO54X6IQ.js} +2 -2
  20. package/dist/cli/chunks/{agent-handler-E2TZKKBS.js → agent-handler-A57SZUCW.js} +2 -2
  21. package/dist/cli/chunks/{agent-memory-branch-JHAHC2NH.js → agent-memory-branch-BX7LRFGN.js} +2 -2
  22. package/dist/cli/chunks/aqe-learning-engine-FSF5U67K.js +2 -0
  23. package/dist/cli/chunks/{arena-72ZV65BR.js → arena-UTC4YY6Y.js} +4 -4
  24. package/dist/cli/chunks/{arena-KLG3YSSR.js → arena-Y3XTX6O7.js} +2 -2
  25. package/dist/cli/chunks/audit-L4RL2AOY.js +3 -0
  26. package/dist/cli/chunks/base-2CKCJU3O.js +2 -0
  27. package/dist/cli/chunks/{hnswlib-node-LAFK5QZ4.js → better-sqlite3-LRDXKYOJ.js} +2 -2
  28. package/dist/cli/chunks/brain-handler-OHDPI5TQ.js +89 -0
  29. package/dist/cli/chunks/{branch-enumerator-C7MPNYT7.js → branch-enumerator-ZRXE2CQ7.js} +2 -2
  30. package/dist/cli/chunks/{browser-UUDUDYLR.js → browser-NT33FG76.js} +2 -2
  31. package/dist/cli/chunks/browser-workflow-UGYJE64S.js +2 -0
  32. package/dist/cli/chunks/{chunk-7QTB5XIQ.js → chunk-27JCWG5J.js} +2 -2
  33. package/dist/cli/chunks/{chunk-3FJZMQJ7.js → chunk-2ALNNXFF.js} +2 -2
  34. package/dist/cli/chunks/{chunk-LMJUMUQJ.js → chunk-2AOOIAW3.js} +4 -4
  35. package/dist/cli/chunks/{chunk-CNF3ZWLM.js → chunk-2AR4B3DI.js} +2 -2
  36. package/dist/cli/chunks/{chunk-7ADD2ZQL.js → chunk-2KHDGC7N.js} +2 -2
  37. package/dist/cli/chunks/{chunk-P6S6ZVB5.js → chunk-2UMCB7AH.js} +1 -1
  38. package/dist/cli/chunks/{chunk-HH6NCBSP.js → chunk-335GHVJV.js} +22 -22
  39. package/dist/cli/chunks/{chunk-2WPSMQIL.js → chunk-36MPDANH.js} +1 -1
  40. package/dist/cli/chunks/{chunk-Y4AXOHW4.js → chunk-3AFNXU45.js} +1 -1
  41. package/dist/cli/chunks/{chunk-SL3SNOO2.js → chunk-3B4XXFKD.js} +2 -2
  42. package/dist/cli/chunks/{chunk-7IKWF2AD.js → chunk-4GU656WM.js} +1 -1
  43. package/dist/cli/chunks/{chunk-IQBZBUP5.js → chunk-4SALW7OT.js} +2 -2
  44. package/dist/cli/chunks/{chunk-TCVEKRPI.js → chunk-5FR5GBUT.js} +2 -2
  45. package/dist/cli/chunks/chunk-5VBPIJUZ.js +65 -0
  46. package/dist/cli/chunks/chunk-5XFX25AJ.js +4 -0
  47. package/dist/cli/chunks/{chunk-QSDIY3E2.js → chunk-5YGESYBC.js} +1 -1
  48. package/dist/cli/chunks/{chunk-5U2WHPXL.js → chunk-62RELCU6.js} +1 -1
  49. package/dist/cli/chunks/{chunk-QJ5NCYJ3.js → chunk-64M3FFM4.js} +2 -2
  50. package/dist/cli/chunks/{chunk-BMQDELPA.js → chunk-6JNNZGI2.js} +1 -1
  51. package/dist/cli/chunks/{chunk-U34OZXD6.js → chunk-6X3RJBA3.js} +2 -2
  52. package/dist/cli/chunks/{chunk-AE6HXMOG.js → chunk-72VZGAMJ.js} +1 -1
  53. package/dist/cli/chunks/{chunk-4JFH3MVA.js → chunk-7F7U2HUH.js} +1 -1
  54. package/dist/cli/chunks/{chunk-A4OMK3FO.js → chunk-7HJHXSYT.js} +2 -2
  55. package/dist/cli/chunks/chunk-7WX3MKRS.js +2 -0
  56. package/dist/cli/chunks/{chunk-O7PVZ32A.js → chunk-7ZIVDGSN.js} +1 -1
  57. package/dist/cli/chunks/{chunk-EZRHSHOQ.js → chunk-AAATFEIL.js} +2 -2
  58. package/dist/cli/chunks/{chunk-TQ373GGI.js → chunk-AEX75YGI.js} +2 -2
  59. package/dist/cli/chunks/chunk-BA6U7NSR.js +2 -0
  60. package/dist/cli/chunks/chunk-BB4OVXWF.js +14 -0
  61. package/dist/cli/chunks/{chunk-GRQ36XUH.js → chunk-BBC526PL.js} +2 -2
  62. package/dist/cli/chunks/{chunk-EONKMHKO.js → chunk-BGRJZH5Q.js} +2 -2
  63. package/dist/cli/chunks/{chunk-XQ6DW5FV.js → chunk-BUYPRUNY.js} +2 -2
  64. package/dist/cli/chunks/{chunk-TU6YN43Q.js → chunk-BZPF6GTL.js} +1 -1
  65. package/dist/cli/chunks/{chunk-TPMBFARK.js → chunk-C4SZSPXY.js} +67 -22
  66. package/dist/cli/chunks/{chunk-D6CKKNYC.js → chunk-C6GYLCTX.js} +2 -2
  67. package/dist/cli/chunks/{chunk-YNK6SUPU.js → chunk-CC5G3K4X.js} +2 -2
  68. package/dist/cli/chunks/{chunk-ADFKY3X2.js → chunk-CHO54B34.js} +2 -2
  69. package/dist/cli/chunks/{chunk-WQZ2WRO4.js → chunk-CMGYUCM7.js} +1 -1
  70. package/dist/cli/chunks/{chunk-QMC5MTBV.js → chunk-CSEEGX5T.js} +2 -2
  71. package/dist/cli/chunks/{chunk-FSGMRQFC.js → chunk-CVGXB7IX.js} +2 -2
  72. package/dist/cli/chunks/{chunk-5VSQAGA2.js → chunk-DQDFACYW.js} +1 -1
  73. package/dist/cli/chunks/chunk-DR7PCO3S.js +153 -0
  74. package/dist/cli/chunks/{chunk-D5S47YUS.js → chunk-DTOE3NYW.js} +3 -3
  75. package/dist/cli/chunks/{chunk-WZYNY3VF.js → chunk-DXOMRWDC.js} +1 -1
  76. package/dist/cli/chunks/{chunk-HJ24KMC2.js → chunk-EGH3H7QO.js} +1 -1
  77. package/dist/cli/chunks/{chunk-JFLSQH2X.js → chunk-EM2JIIAQ.js} +2 -2
  78. package/dist/cli/chunks/{chunk-MWFJC5HR.js → chunk-ESDGCTC4.js} +1 -1
  79. package/dist/cli/chunks/{chunk-SRVTNG6L.js → chunk-EZE2HRQB.js} +2 -2
  80. package/dist/cli/chunks/{chunk-ZFCVT43J.js → chunk-FEEMJDUF.js} +2 -2
  81. package/dist/cli/chunks/{chunk-HJO4RNOW.js → chunk-FI5SSLEF.js} +2 -2
  82. package/dist/cli/chunks/{chunk-XHRLBJTM.js → chunk-FKPUPQQT.js} +2 -2
  83. package/dist/cli/chunks/{chunk-ODZSQVEW.js → chunk-FOPS6DRZ.js} +1 -1
  84. package/dist/cli/chunks/{chunk-AQIEK4SY.js → chunk-FU5RNEXV.js} +2 -2
  85. package/dist/cli/chunks/{chunk-PQUXFSN6.js → chunk-FZIHOMGY.js} +2 -2
  86. package/dist/cli/chunks/{chunk-Z2REKBD6.js → chunk-FZRU73M4.js} +2 -2
  87. package/dist/cli/chunks/{chunk-NBBLPDJX.js → chunk-G5JQLUUO.js} +2 -2
  88. package/dist/cli/chunks/{chunk-4BFCLSDN.js → chunk-G6LR7FK7.js} +2 -2
  89. package/dist/cli/chunks/{chunk-QEVX4GWF.js → chunk-G6RKUEGL.js} +2 -2
  90. package/dist/cli/chunks/{chunk-HWBMYR5W.js → chunk-GCF42L7M.js} +5 -5
  91. package/dist/cli/chunks/{chunk-TSWF3AGQ.js → chunk-GGMQOEZZ.js} +2 -2
  92. package/dist/cli/chunks/{chunk-PFWJQPUC.js → chunk-HAEUPIKW.js} +2 -2
  93. package/dist/cli/chunks/{chunk-63QUN3JK.js → chunk-HDJMD6UH.js} +1 -1
  94. package/dist/cli/chunks/{chunk-JPENUVCI.js → chunk-HW62TB4T.js} +1 -1
  95. package/dist/cli/chunks/{chunk-WMIRAD3J.js → chunk-I6WHYRWB.js} +2 -2
  96. package/dist/cli/chunks/{chunk-YZ5EQR37.js → chunk-ICK3B24H.js} +2 -2
  97. package/dist/cli/chunks/{chunk-FRFVN6AA.js → chunk-IDLNLSQI.js} +2 -2
  98. package/dist/cli/chunks/{chunk-VQU7DMEY.js → chunk-IJUYHIKN.js} +2 -2
  99. package/dist/cli/chunks/{chunk-6JUOH6L4.js → chunk-IKVNYK7Y.js} +2 -2
  100. package/dist/cli/chunks/{chunk-ZKCKOQJI.js → chunk-JOBCMNTP.js} +2 -2
  101. package/dist/cli/chunks/{chunk-ARPBG6FQ.js → chunk-JYX7AZHE.js} +2 -2
  102. package/dist/cli/chunks/{chunk-SFDUT5WM.js → chunk-JYXSVSH2.js} +2 -2
  103. package/dist/cli/chunks/{chunk-VJGHRWMH.js → chunk-K5SN66B4.js} +2 -2
  104. package/dist/cli/chunks/{chunk-DNOU2HVQ.js → chunk-KDLYTJ5C.js} +2 -2
  105. package/dist/cli/chunks/{chunk-T76RFXQX.js → chunk-KI5BP4X5.js} +2 -2
  106. package/dist/cli/chunks/{chunk-7AWK43JN.js → chunk-KJWQ7ENF.js} +2 -2
  107. package/dist/cli/chunks/{chunk-BRLUNIR4.js → chunk-KN5GOEYK.js} +2 -2
  108. package/dist/cli/chunks/{chunk-VKJQAKYG.js → chunk-KZ37VHMJ.js} +2 -2
  109. package/dist/cli/chunks/{chunk-NV3TXXOW.js → chunk-KZMRU7DL.js} +2 -2
  110. package/dist/cli/chunks/{chunk-LLUPRGOR.js → chunk-L5ZLOW3K.js} +2 -2
  111. package/dist/cli/chunks/{chunk-THKZVOZV.js → chunk-LMJUQWR7.js} +1 -1
  112. package/dist/cli/chunks/{chunk-2KNFS3L5.js → chunk-MBF3Q7FQ.js} +1 -1
  113. package/dist/cli/chunks/chunk-MDT3LIXS.js +2 -0
  114. package/dist/cli/chunks/{chunk-B5XUWHKQ.js → chunk-MJPYNGZ7.js} +1 -1
  115. package/dist/cli/chunks/{chunk-UCYTY4LG.js → chunk-MK3J7JVZ.js} +2 -2
  116. package/dist/cli/chunks/{chunk-MCT4CD5M.js → chunk-MUAHFGIX.js} +2 -2
  117. package/dist/cli/chunks/{chunk-3SBUL72V.js → chunk-MUV56BPK.js} +2 -2
  118. package/dist/cli/chunks/{chunk-WNMDWP5A.js → chunk-NLHISTL2.js} +2 -2
  119. package/dist/cli/chunks/{chunk-UJMTKXPI.js → chunk-NNGCUJWQ.js} +2 -2
  120. package/dist/cli/chunks/chunk-NW7G57NR.js +27 -0
  121. package/dist/cli/chunks/{chunk-3SRPFBU7.js → chunk-O3C5RRDQ.js} +3 -3
  122. package/dist/cli/chunks/{chunk-AYGEWPN4.js → chunk-OHSVDMF7.js} +1 -1
  123. package/dist/cli/chunks/{chunk-AJXGGTX7.js → chunk-OPIWFXME.js} +1 -1
  124. package/dist/cli/chunks/{chunk-ZSBJNE35.js → chunk-P52YORQG.js} +2 -2
  125. package/dist/cli/chunks/chunk-PM566XEO.js +2 -0
  126. package/dist/cli/chunks/chunk-POKMJTD2.js +2 -0
  127. package/dist/cli/chunks/{chunk-GOQ4P2PB.js → chunk-PQMLIVGV.js} +2 -2
  128. package/dist/cli/chunks/{chunk-IB3ZPLFA.js → chunk-PT3FTGKZ.js} +2 -2
  129. package/dist/cli/chunks/{chunk-U3AVZGQA.js → chunk-Q5YRPS4P.js} +1 -1
  130. package/dist/cli/chunks/{chunk-5Z4FBCBK.js → chunk-QJ6H2HQQ.js} +1 -1
  131. package/dist/cli/chunks/{chunk-DRMHVY4T.js → chunk-RG552ROA.js} +4 -4
  132. package/dist/cli/chunks/{chunk-PEIQDQXN.js → chunk-RHC7TFPU.js} +2 -2
  133. package/dist/cli/chunks/{chunk-JNQN5DNS.js → chunk-RMFRFING.js} +1 -1
  134. package/dist/cli/chunks/{chunk-4YT5YN5G.js → chunk-RQN4HWGV.js} +2 -2
  135. package/dist/cli/chunks/{chunk-5P7Q5YNC.js → chunk-RYUSZ43T.js} +1 -1
  136. package/dist/cli/chunks/{chunk-O5NEJIHB.js → chunk-RZDNCTOA.js} +2 -2
  137. package/dist/cli/chunks/chunk-SCMXIBI7.js +2 -0
  138. package/dist/cli/chunks/{chunk-6545AS2J.js → chunk-SPEUF7ZL.js} +2 -2
  139. package/dist/cli/chunks/{chunk-LW5DHT3Z.js → chunk-SSXAW3ER.js} +2 -2
  140. package/dist/cli/chunks/{chunk-Q7ORVHJB.js → chunk-TC2JE5OK.js} +3 -3
  141. package/dist/cli/chunks/{chunk-MALOUGSF.js → chunk-TED4KOSK.js} +2 -2
  142. package/dist/cli/chunks/{chunk-ICCTQ5LO.js → chunk-TJ6N4CCX.js} +2 -2
  143. package/dist/cli/chunks/{chunk-6GYGAW53.js → chunk-TJEJ4UVX.js} +2 -2
  144. package/dist/cli/chunks/{chunk-VO6YJGB4.js → chunk-TO5PQSDD.js} +2 -2
  145. package/dist/cli/chunks/{chunk-LKURMUBU.js → chunk-TR5GOGH3.js} +37 -12
  146. package/dist/cli/chunks/{chunk-JCTCM6IR.js → chunk-UGJQJSPB.js} +1 -1
  147. package/dist/cli/chunks/{chunk-4RHNPRAP.js → chunk-USB44IHJ.js} +2 -2
  148. package/dist/cli/chunks/{chunk-JDFPAJGB.js → chunk-UUOXV3NS.js} +92 -92
  149. package/dist/cli/chunks/chunk-UVVKFBF7.js +2 -0
  150. package/dist/cli/chunks/{chunk-VCUCD3B5.js → chunk-V2MD5EDD.js} +2 -2
  151. package/dist/cli/chunks/{chunk-RFQBDMAP.js → chunk-VA7TEOPM.js} +1 -1
  152. package/dist/cli/chunks/{chunk-IF3HPQNV.js → chunk-VMP4M5PB.js} +1 -1
  153. package/dist/cli/chunks/{chunk-KUZMVH6N.js → chunk-VS4GMNJK.js} +3 -3
  154. package/dist/cli/chunks/{chunk-ZYZT2CDX.js → chunk-VWJSWXHG.js} +1 -1
  155. package/dist/cli/chunks/{chunk-54B6P2WS.js → chunk-VZ67ZDB3.js} +3 -3
  156. package/dist/cli/chunks/{chunk-NSPCZPTB.js → chunk-W2OMW6UU.js} +2 -2
  157. package/dist/cli/chunks/{chunk-3SKIZDKL.js → chunk-W766S4SK.js} +1 -1
  158. package/dist/cli/chunks/{chunk-N2BJN6AO.js → chunk-WJYTLRA5.js} +3 -3
  159. package/dist/cli/chunks/{chunk-X64BEXUY.js → chunk-WNASEUBW.js} +117 -113
  160. package/dist/cli/chunks/{chunk-HT6WAYIR.js → chunk-WT4ZDDFM.js} +1 -1
  161. package/dist/cli/chunks/chunk-XEYW3V5I.js +2 -0
  162. package/dist/cli/chunks/{chunk-6W3QHS45.js → chunk-XIFPIVZI.js} +2 -2
  163. package/dist/cli/chunks/{chunk-3E7D3A35.js → chunk-Y2MCIIJD.js} +1 -1
  164. package/dist/cli/chunks/{chunk-YUHM72VQ.js → chunk-YKOTOCO6.js} +2 -2
  165. package/dist/cli/chunks/{chunk-YKSWC7I4.js → chunk-Z3W3R4CW.js} +8 -20
  166. package/dist/cli/chunks/chunk-ZT2WHCVM.js +2 -0
  167. package/dist/cli/chunks/{chunk-G3TFNY4T.js → chunk-ZVPAFX4I.js} +2 -2
  168. package/dist/cli/chunks/{chunk-NFJT7XXR.js → chunk-ZWC6CM4R.js} +1 -1
  169. package/dist/cli/chunks/{ci-HQCRSCC7.js → ci-RJH5LAL3.js} +2 -2
  170. package/dist/cli/chunks/{ci-output-YBVXLA6O.js → ci-output-62SGMGB2.js} +2 -2
  171. package/dist/cli/chunks/{circuit-breaker-ULGMF2QN.js → circuit-breaker-QXTS5ZAW.js} +2 -2
  172. package/dist/cli/chunks/{claude-flow-setup-MKZ2LJXK.js → claude-flow-setup-BBCCT5WV.js} +2 -2
  173. package/dist/cli/chunks/client-E2XUBCLK.js +2 -0
  174. package/dist/cli/chunks/{cline-installer-WZQ6XBWN.js → cline-installer-IZCUJJ3I.js} +2 -2
  175. package/dist/cli/chunks/{code-H3KGH45S.js → code-AWNVOZ7S.js} +2 -2
  176. package/dist/cli/chunks/{code-index-extractor-NUVEAJ7C.js → code-index-extractor-MX65BKMI.js} +2 -2
  177. package/dist/cli/chunks/{codex-installer-JQI6E6CV.js → codex-installer-EQT6JVLM.js} +2 -2
  178. package/dist/cli/chunks/{completions-NDF4PFE7.js → completions-WOJAM45W.js} +2 -2
  179. package/dist/cli/chunks/{complexity-analyzer-XCZH66HG.js → complexity-analyzer-3DJB7V3K.js} +2 -2
  180. package/dist/cli/chunks/{continuedev-installer-Z4AJGZ7S.js → continuedev-installer-P4KWUTCJ.js} +2 -2
  181. package/dist/cli/chunks/{copilot-installer-K4IPAL7C.js → copilot-installer-FFZWTMWQ.js} +2 -2
  182. package/dist/cli/chunks/core-handlers-46Z5VOO6.js +2 -0
  183. package/dist/cli/chunks/{cost-tracker-35KXAB23.js → cost-tracker-CYBOV3NI.js} +2 -2
  184. package/dist/cli/chunks/{coverage-QW5I4TYZ.js → coverage-GTZJBSC4.js} +3 -3
  185. package/dist/cli/chunks/cross-domain-router-SXQ3HFRY.js +2 -0
  186. package/dist/cli/chunks/{cursor-installer-P4Z7RMIZ.js → cursor-installer-WZIVXGGB.js} +2 -2
  187. package/dist/cli/chunks/daemon-JWMHEJEN.js +10 -0
  188. package/dist/cli/chunks/{daemon-WQWTCYBM.js → daemon-MSFN2LXY.js} +3 -3
  189. package/dist/cli/chunks/{dag-attention-scheduler-7XD2VGON.js → dag-attention-scheduler-4TWOTTQE.js} +2 -2
  190. package/dist/cli/chunks/{detect-GZ3P4DI7.js → detect-YZ6AGQPB.js} +2 -2
  191. package/dist/cli/chunks/{dist-node-6WWAW7OP.js → dist-node-3EM2XH54.js} +2 -2
  192. package/dist/cli/chunks/{domain-handler-3GTLWARQ.js → domain-handler-4XU5BINU.js} +2 -2
  193. package/dist/cli/chunks/domain-transfer-HUFC7I52.js +2 -0
  194. package/dist/cli/chunks/dream-R6MQQQ3N.js +2 -0
  195. package/dist/cli/chunks/{embed-and-insert-pattern-BGIMA77V.js → embed-and-insert-pattern-J5ZFM6YX.js} +2 -2
  196. package/dist/cli/chunks/{eval-SXV6DRDD.js → eval-XYOA3EH2.js} +2 -2
  197. package/dist/cli/chunks/{experience-capture-middleware-TT6WCT2S.js → experience-capture-middleware-E3RYQB6Z.js} +3 -3
  198. package/dist/cli/chunks/{fast-paths-HTAZHEQP.js → fast-paths-DKIYN2YS.js} +2 -2
  199. package/dist/cli/chunks/{feature-flags-DIE3Z2B4.js → feature-flags-S2RNZATS.js} +2 -2
  200. package/dist/cli/chunks/{feature-flags-WBUKU54W.js → feature-flags-ZB63Z7N5.js} +2 -2
  201. package/dist/cli/chunks/{file-discovery-SKDETFS3.js → file-discovery-USJJLYQU.js} +2 -2
  202. package/dist/cli/chunks/{fleet-WCWEPAVU.js → fleet-4MUPHSF5.js} +4 -4
  203. package/dist/cli/chunks/{gnn-wrapper-KWZOWBYS.js → gnn-wrapper-PYOQZKX6.js} +2 -2
  204. package/dist/cli/chunks/{heartbeat-handler-3AGYHVG2.js → heartbeat-handler-HLO5XCG7.js} +4 -4
  205. package/dist/cli/chunks/heartbeat-scheduler-OSDPJT6A.js +2 -0
  206. package/dist/cli/chunks/hnsw-adapter-KMGSHBIN.js +2 -0
  207. package/dist/cli/chunks/hnsw-index-IMFRAOPE.js +2 -0
  208. package/dist/cli/chunks/{hnsw-legacy-bridge-6OJJDZHL.js → hnsw-legacy-bridge-FZEH2KLM.js} +2 -2
  209. package/dist/cli/chunks/{better-sqlite3-URULPKRF.js → hnswlib-node-VS6L5VUG.js} +2 -2
  210. package/dist/cli/chunks/{hooks-OXEBTLXV.js → hooks-R2757K57.js} +48 -52
  211. package/dist/cli/chunks/hybrid-router-57QSWSWC.js +2 -0
  212. package/dist/cli/chunks/{hypergraph-engine-NL74PRHD.js → hypergraph-engine-EAV3GJ5D.js} +2 -2
  213. package/dist/cli/chunks/{hypergraph-handler-KZ54AEEL.js → hypergraph-handler-5ERXAVGH.js} +3 -3
  214. package/dist/cli/chunks/impact-analyzer-OC4MPBGA.js +2 -0
  215. package/dist/cli/chunks/{init-handler-XKZXRXPG.js → init-handler-RXUSEMG7.js} +6 -6
  216. package/dist/cli/chunks/init-wizard-CDBRL4PO.js +2 -0
  217. package/dist/cli/chunks/kernel-CQ7R3AAV.js +2 -0
  218. package/dist/cli/chunks/{kilocode-installer-WISQMJK7.js → kilocode-installer-ZUBVBHGT.js} +2 -2
  219. package/dist/cli/chunks/{kiro-installer-O7TBB3GM.js → kiro-installer-TRTRQDGL.js} +2 -2
  220. package/dist/cli/chunks/knowledge-graph-UXNH7RY4.js +2 -0
  221. package/dist/cli/chunks/{learning-6IZBGVRU.js → learning-UYXWAU5D.js} +3 -3
  222. package/dist/cli/chunks/{llm-router-QDMQPPQ7.js → llm-router-TB5OJPEV.js} +4 -4
  223. package/dist/cli/chunks/llm-router-service-UV34YXBE.js +2 -0
  224. package/dist/cli/chunks/{load-KLAJJGL5.js → load-ELPSUIPV.js} +2 -2
  225. package/dist/cli/chunks/load-test-2VEN3PQZ.js +2 -0
  226. package/dist/cli/chunks/{mcp-SZOPQZIZ.js → mcp-UX7TK3XV.js} +2 -2
  227. package/dist/cli/chunks/{memory-G3WY74C6.js → memory-W3LG6H6N.js} +5 -5
  228. package/dist/cli/chunks/memory-backend-TZL5U6F3.js +2 -0
  229. package/dist/cli/chunks/memory-handlers-BNXAYS2P.js +2 -0
  230. package/dist/cli/chunks/{multi-model-executor-TDNQGTOT.js → multi-model-executor-227LWZRY.js} +2 -2
  231. package/dist/cli/chunks/{opencode-installer-NGYGEDMV.js → opencode-installer-F4WKVWDL.js} +2 -2
  232. package/dist/cli/chunks/{orchestrator-KPI5DY2C.js → orchestrator-V4DBMGK6.js} +5 -5
  233. package/dist/cli/chunks/pattern-null-store-KLX2RNHM.js +2 -0
  234. package/dist/cli/chunks/pattern-usage-recorder-BY3HEWSU.js +2 -0
  235. package/dist/cli/chunks/{pipeline-CSDCC675.js → pipeline-3F5RIESX.js} +2 -2
  236. package/dist/cli/chunks/{platform-Q5XKEVKH.js → platform-KCGXTZO3.js} +2 -2
  237. package/dist/cli/chunks/{plugin-XKKR3GVL.js → plugin-2H552KOV.js} +2 -2
  238. package/dist/cli/chunks/{prime-radiant-advanced-wasm-22QVNKEN.js → prime-radiant-advanced-wasm-EFKVL7VN.js} +2 -2
  239. package/dist/cli/chunks/protocol-executor-5HJKW6MC.js +2 -0
  240. package/dist/cli/chunks/{protocol-handler-REQKTJGG.js → protocol-handler-ELGYV7D2.js} +2 -2
  241. package/dist/cli/chunks/{prove-NOFUFSQN.js → prove-AYJCQYNI.js} +2 -2
  242. package/dist/cli/chunks/provider-manager-TRZSBXD3.js +2 -0
  243. package/dist/cli/chunks/qe-reasoning-bank-RCEYSLVV.js +2 -0
  244. package/dist/cli/chunks/{quality-3DQ2H5TK.js → quality-HH7L5A7V.js} +2 -2
  245. package/dist/cli/chunks/quality-gate-NAQLXE4C.js +7 -0
  246. package/dist/cli/chunks/queen-coordinator-6JFZD54W.js +2 -0
  247. package/dist/cli/chunks/{real-embeddings-FCGNYWLL.js → real-embeddings-IO3F4ZFR.js} +2 -2
  248. package/dist/cli/chunks/{roocode-installer-HX3CNRIR.js → roocode-installer-X4TU5HO4.js} +2 -2
  249. package/dist/cli/chunks/router-KRLC46NS.js +2 -0
  250. package/dist/cli/chunks/routing-feedback-WW26H6SA.js +2 -0
  251. package/dist/cli/chunks/{routing-handler-YRZ2LDCR.js → routing-handler-ZJKGDDMT.js} +2 -2
  252. package/dist/cli/chunks/{ruvector-commands-GCQVBJ4E.js → ruvector-commands-NXCSUBN2.js} +2 -2
  253. package/dist/cli/chunks/{rvf-dual-writer-B562P3ZC.js → rvf-dual-writer-JMA74SKP.js} +2 -2
  254. package/dist/cli/chunks/{rvf-migration-adapter-NAGFKCMD.js → rvf-migration-adapter-BNTGH2KU.js} +2 -2
  255. package/dist/cli/chunks/{rvf-migration-coordinator-WWFBEJ5Q.js → rvf-migration-coordinator-7T2HHUOH.js} +2 -2
  256. package/dist/cli/chunks/rvf-native-adapter-OVQKPQUH.js +2 -0
  257. package/dist/cli/chunks/safe-db-UQOCQIH2.js +2 -0
  258. package/dist/cli/chunks/schedule-EUX7ZQUK.js +2 -0
  259. package/dist/cli/chunks/scheduler-MALHQKNR.js +2 -0
  260. package/dist/cli/chunks/{security-IFOYTD75.js → security-XSK2QHB3.js} +3 -3
  261. package/dist/cli/chunks/{shared-rvf-adapter-TYD5TQ35.js → shared-rvf-adapter-WLRKI7RY.js} +2 -2
  262. package/dist/cli/chunks/{shared-rvf-dual-writer-YGOOVDQZ.js → shared-rvf-dual-writer-SZW3J7ZK.js} +2 -2
  263. package/dist/cli/chunks/sqlite-persistence-OBCLRP4L.js +2 -0
  264. package/dist/cli/chunks/status-handler-HGCKYJX2.js +46 -0
  265. package/dist/cli/chunks/{structural-health-KZI6YMKV.js → structural-health-4SJCFX63.js} +2 -2
  266. package/dist/cli/chunks/{sync-Z5BDDBMK.js → sync-7WAVNZGL.js} +2 -2
  267. package/dist/cli/chunks/{sync-ABZNNYRC.js → sync-ATR4DUSA.js} +2 -2
  268. package/dist/cli/chunks/{task-handler-5ACZEPJ7.js → task-handler-O6REL34Y.js} +2 -2
  269. package/dist/cli/chunks/{task-handlers-UZWDPL6A.js → task-handlers-WFV2ZYWW.js} +3 -3
  270. package/dist/cli/chunks/{test-APO3MCVV.js → test-4LXUVHEU.js} +4 -4
  271. package/dist/cli/chunks/{test-scheduling-EFZA5G5C.js → test-scheduling-OTN3DMKY.js} +3 -3
  272. package/dist/cli/chunks/{token-bootstrap-J2OPLNUK.js → token-bootstrap-VA7T4P42.js} +2 -2
  273. package/dist/cli/chunks/{token-usage-VHWVNN4R.js → token-usage-TLT6OXXR.js} +2 -2
  274. package/dist/cli/chunks/{transformers-PX4HPO75.js → transformers-JI7LZRQ3.js} +2 -2
  275. package/dist/cli/chunks/{tree-sitter-wasm-parser-44HA2Z3F.js → tree-sitter-wasm-parser-QNIMHB4K.js} +2 -2
  276. package/dist/cli/chunks/{types-IMOP7F4R.js → types-DJNWOAC6.js} +2 -2
  277. package/dist/cli/chunks/unified-memory-A5BS3LGX.js +2 -0
  278. package/dist/cli/chunks/unified-memory-hnsw-WJLJO5MY.js +2 -0
  279. package/dist/cli/chunks/unified-persistence-CFC2BKI5.js +2 -0
  280. package/dist/cli/chunks/{upgrade-OZ3O6ZZI.js → upgrade-VEW4FL23.js} +2 -2
  281. package/dist/cli/chunks/{validate-DRY5BMWX.js → validate-O3P6PF7B.js} +2 -2
  282. package/dist/cli/chunks/{validate-swarm-QD3LYPUF.js → validate-swarm-M2HXHZVC.js} +2 -2
  283. package/dist/cli/chunks/{vibium-2J3H2ITD.js → vibium-GOU55LUO.js} +2 -2
  284. package/dist/cli/chunks/visual-security-VPB6KVYJ.js +2 -0
  285. package/dist/cli/chunks/{web-tree-sitter-KRNUOGKI.js → web-tree-sitter-MXOI4GH3.js} +2 -2
  286. package/dist/cli/chunks/{windsurf-installer-PQIPH3WP.js → windsurf-installer-6GKT53IH.js} +2 -2
  287. package/dist/cli/chunks/{witness-chain-HPLOYPS7.js → witness-chain-OXGQGL26.js} +2 -2
  288. package/dist/cli/chunks/witness-chain-ZZAUAXDY.js +2 -0
  289. package/dist/cli/chunks/witness-key-manager-PGFSQXUJ.js +2 -0
  290. package/dist/cli/chunks/{workflow-OAQ3FWCY.js → workflow-ENBWRMBA.js} +4 -4
  291. package/dist/cli/chunks/workflow-orchestrator-S4LBFTYD.js +2 -0
  292. package/dist/cli/chunks/{wrappers-UPIU6S5S.js → wrappers-MHLNYANQ.js} +2 -2
  293. package/dist/cli/commands/audit.d.ts +12 -0
  294. package/dist/cli/commands/audit.js +64 -4
  295. package/dist/cli/commands/hooks-handlers/hooks-dream-learning.js +45 -19
  296. package/dist/cli/commands/hooks-handlers/hooks-shared.d.ts +13 -0
  297. package/dist/cli/commands/hooks-handlers/hooks-shared.js +38 -0
  298. package/dist/cli/commands/hooks-handlers/task-hooks.js +19 -1
  299. package/dist/cli/commands/quality-gate.d.ts +24 -0
  300. package/dist/cli/commands/quality-gate.js +135 -0
  301. package/dist/cli/handlers/status-handler.d.ts +18 -0
  302. package/dist/cli/handlers/status-handler.js +47 -0
  303. package/dist/cli/index.js +5 -0
  304. package/dist/coordination/mincut/dream-integration.d.ts +11 -0
  305. package/dist/coordination/mincut/dream-integration.js +39 -12
  306. package/dist/coordination/mincut/queen-integration.js +24 -7
  307. package/dist/coordination/protocol-executor.js +2 -1
  308. package/dist/coordination/queen-lifecycle.js +4 -1
  309. package/dist/domains/code-intelligence/coordinator.js +10 -6
  310. package/dist/domains/code-intelligence/services/product-factors-bridge.js +3 -1
  311. package/dist/domains/defect-intelligence/services/defect-predictor.d.ts +6 -0
  312. package/dist/domains/defect-intelligence/services/defect-predictor.js +21 -0
  313. package/dist/domains/learning-optimization/interfaces.d.ts +7 -0
  314. package/dist/domains/learning-optimization/plugin.js +5 -0
  315. package/dist/domains/learning-optimization/services/learning-coordinator.d.ts +10 -0
  316. package/dist/domains/learning-optimization/services/learning-coordinator.js +57 -0
  317. package/dist/domains/test-execution/plugin.js +2 -2
  318. package/dist/domains/test-execution/services/flaky-detector.js +1 -1
  319. package/dist/domains/test-generation/coordinator.js +22 -8
  320. package/dist/domains/test-generation/interfaces.d.ts +3 -0
  321. package/dist/domains/test-generation/services/test-generator.js +9 -1
  322. package/dist/integrations/ruvector/delta-tracker.js +10 -1
  323. package/dist/integrations/ruvector/feature-flags.js +7 -0
  324. package/dist/integrations/ruvector/sona-persistence.d.ts +24 -0
  325. package/dist/integrations/ruvector/sona-persistence.js +76 -0
  326. package/dist/integrations/ruvector/sona-three-loop.d.ts +15 -0
  327. package/dist/integrations/ruvector/sona-three-loop.js +17 -0
  328. package/dist/kernel/unified-memory-schemas.d.ts +2 -2
  329. package/dist/kernel/unified-memory-schemas.js +48 -2
  330. package/dist/kernel/unified-memory.d.ts +22 -0
  331. package/dist/kernel/unified-memory.js +43 -0
  332. package/dist/learning/aqe-learning-engine.js +3 -1
  333. package/dist/learning/dream/concept-graph.d.ts +31 -1
  334. package/dist/learning/dream/concept-graph.js +109 -3
  335. package/dist/learning/dream/dream-engine.d.ts +13 -1
  336. package/dist/learning/dream/dream-engine.js +146 -10
  337. package/dist/learning/dream/index.d.ts +1 -1
  338. package/dist/learning/dream/types.d.ts +23 -0
  339. package/dist/learning/pattern-lifecycle.d.ts +16 -0
  340. package/dist/learning/pattern-lifecycle.js +77 -1
  341. package/dist/learning/pattern-store.d.ts +2 -2
  342. package/dist/learning/pattern-store.js +14 -3
  343. package/dist/learning/provenance-tier.d.ts +52 -0
  344. package/dist/learning/provenance-tier.js +64 -0
  345. package/dist/learning/qe-flywheel/corpus-scorer.d.ts +55 -0
  346. package/dist/learning/qe-flywheel/corpus-scorer.js +293 -0
  347. package/dist/learning/qe-flywheel/coupled-anchor.d.ts +91 -0
  348. package/dist/learning/qe-flywheel/coupled-anchor.js +181 -0
  349. package/dist/learning/qe-flywheel/generation.d.ts +121 -0
  350. package/dist/learning/qe-flywheel/generation.js +167 -0
  351. package/dist/learning/qe-flywheel/policy.d.ts +37 -0
  352. package/dist/learning/qe-flywheel/policy.js +66 -0
  353. package/dist/learning/qe-flywheel/receipt-store.d.ts +31 -0
  354. package/dist/learning/qe-flywheel/receipt-store.js +89 -0
  355. package/dist/learning/qe-flywheel/receipt.d.ts +62 -0
  356. package/dist/learning/qe-flywheel/receipt.js +97 -0
  357. package/dist/learning/qe-reasoning-bank.js +34 -31
  358. package/dist/learning/routing-topology-gate.d.ts +12 -2
  359. package/dist/learning/routing-topology-gate.js +15 -3
  360. package/dist/learning/rvf-pattern-store.d.ts +1 -1
  361. package/dist/learning/rvf-pattern-store.js +21 -8
  362. package/dist/learning/sqlite-persistence.js +12 -9
  363. package/dist/mcp/bundle.js +540 -460
  364. package/dist/mcp/qe-tool-bridge.js +7 -2
  365. package/dist/mcp/tools/base.d.ts +29 -0
  366. package/dist/mcp/tools/base.js +25 -0
  367. package/dist/mcp/tools/coverage-analysis/index.js +6 -4
  368. package/dist/mcp/tools/learning-optimization/dream.d.ts +4 -13
  369. package/dist/mcp/tools/learning-optimization/dream.js +10 -96
  370. package/dist/mcp/tools/planning/goap-execute.d.ts +13 -1
  371. package/dist/mcp/tools/planning/goap-execute.js +33 -18
  372. package/dist/mcp/tools/quality-assessment/gate.d.ts +38 -0
  373. package/dist/mcp/tools/quality-assessment/gate.js +86 -0
  374. package/dist/mcp/tools/registry.d.ts +1 -0
  375. package/dist/mcp/tools/registry.js +10 -2
  376. package/dist/persistence/rvf-migration-coordinator.js +2 -1
  377. package/dist/planning/actions/qe-action-library.js +124 -1
  378. package/dist/planning/goap-planner.d.ts +14 -2
  379. package/dist/planning/goap-planner.js +51 -9
  380. package/dist/planning/index.d.ts +1 -1
  381. package/dist/planning/plan-executor.d.ts +84 -4
  382. package/dist/planning/plan-executor.js +221 -56
  383. package/dist/planning/types.d.ts +27 -0
  384. package/dist/shared/events/domain-events.d.ts +2 -0
  385. package/dist/shared/safe-db.js +23 -4
  386. package/dist/validation/anchor-set.d.ts +74 -0
  387. package/dist/validation/anchor-set.js +78 -0
  388. package/dist/validation/frontier-judge.d.ts +99 -0
  389. package/dist/validation/frontier-judge.js +234 -0
  390. package/dist/validation/gate-reexecute.d.ts +165 -0
  391. package/dist/validation/gate-reexecute.js +255 -0
  392. package/dist/validation/quality-gate-runner.d.ts +49 -0
  393. package/dist/validation/quality-gate-runner.js +62 -0
  394. package/dist/validation/quality-verdict.d.ts +94 -0
  395. package/dist/validation/quality-verdict.js +120 -0
  396. package/dist/workers/workers/learning-consolidation.js +21 -1
  397. package/package.json +1 -1
  398. package/dist/cli/chunks/adapter-2HMUXHWY.js +0 -2
  399. package/dist/cli/chunks/aqe-learning-engine-M2NKRVRE.js +0 -2
  400. package/dist/cli/chunks/audit-EPB7ETMT.js +0 -3
  401. package/dist/cli/chunks/base-CCHC2DAC.js +0 -2
  402. package/dist/cli/chunks/brain-handler-FBMYEERK.js +0 -89
  403. package/dist/cli/chunks/browser-workflow-4DGHFYY3.js +0 -2
  404. package/dist/cli/chunks/chunk-37ZDGJ3H.js +0 -2
  405. package/dist/cli/chunks/chunk-5AQ7FXYG.js +0 -27
  406. package/dist/cli/chunks/chunk-KYTFIP6R.js +0 -2
  407. package/dist/cli/chunks/chunk-MYMIEQSZ.js +0 -65
  408. package/dist/cli/chunks/chunk-RCPD6F4R.js +0 -2
  409. package/dist/cli/chunks/chunk-TCWR6TDN.js +0 -2
  410. package/dist/cli/chunks/chunk-UQ72K44T.js +0 -149
  411. package/dist/cli/chunks/chunk-XXRTWG7O.js +0 -2
  412. package/dist/cli/chunks/chunk-ZSA6V5FH.js +0 -2
  413. package/dist/cli/chunks/client-2OVEDWGU.js +0 -2
  414. package/dist/cli/chunks/core-handlers-UXRRYP52.js +0 -2
  415. package/dist/cli/chunks/cross-domain-router-PV3VQVLO.js +0 -2
  416. package/dist/cli/chunks/daemon-ESUEM6VB.js +0 -10
  417. package/dist/cli/chunks/domain-transfer-TQYO3SVG.js +0 -2
  418. package/dist/cli/chunks/dream-UFUXVJQC.js +0 -2
  419. package/dist/cli/chunks/heartbeat-scheduler-MBG3SARO.js +0 -2
  420. package/dist/cli/chunks/hnsw-adapter-5HXA3QB3.js +0 -2
  421. package/dist/cli/chunks/hnsw-index-PZRQWBRG.js +0 -2
  422. package/dist/cli/chunks/hybrid-router-NQRIE2GG.js +0 -2
  423. package/dist/cli/chunks/impact-analyzer-46347ZDV.js +0 -2
  424. package/dist/cli/chunks/init-wizard-CJYP4WKO.js +0 -2
  425. package/dist/cli/chunks/kernel-22KQZ56U.js +0 -2
  426. package/dist/cli/chunks/knowledge-graph-KM3JDBGR.js +0 -2
  427. package/dist/cli/chunks/llm-router-service-IFO6GRRO.js +0 -2
  428. package/dist/cli/chunks/load-test-TTKCYAPB.js +0 -2
  429. package/dist/cli/chunks/memory-backend-ELHCX2ZT.js +0 -2
  430. package/dist/cli/chunks/memory-handlers-3SKYQZTL.js +0 -2
  431. package/dist/cli/chunks/pattern-null-store-TMXAYD43.js +0 -2
  432. package/dist/cli/chunks/protocol-executor-BPLR5EJC.js +0 -2
  433. package/dist/cli/chunks/provider-manager-4MMD5QKL.js +0 -2
  434. package/dist/cli/chunks/qe-reasoning-bank-P7KNT3WZ.js +0 -2
  435. package/dist/cli/chunks/queen-coordinator-NBZZ4MGC.js +0 -2
  436. package/dist/cli/chunks/router-2RXR6J2Q.js +0 -2
  437. package/dist/cli/chunks/routing-feedback-AVAA76TK.js +0 -2
  438. package/dist/cli/chunks/rvf-native-adapter-X2YDJA55.js +0 -2
  439. package/dist/cli/chunks/safe-db-4PRU65BK.js +0 -2
  440. package/dist/cli/chunks/schedule-2AST5CHW.js +0 -2
  441. package/dist/cli/chunks/scheduler-SW6II7OU.js +0 -2
  442. package/dist/cli/chunks/sqlite-persistence-OB5NEGAK.js +0 -2
  443. package/dist/cli/chunks/status-handler-HFPWSCBY.js +0 -45
  444. package/dist/cli/chunks/unified-memory-X7OJYGSD.js +0 -2
  445. package/dist/cli/chunks/unified-memory-hnsw-O6HOD5YL.js +0 -2
  446. package/dist/cli/chunks/unified-persistence-C332CER2.js +0 -2
  447. package/dist/cli/chunks/visual-security-MPUG5HPI.js +0 -2
  448. package/dist/cli/chunks/witness-chain-Q4BZHPDF.js +0 -2
  449. package/dist/cli/chunks/workflow-orchestrator-4NDWECYK.js +0 -2
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Coupled anchor scorer — retrieval → test-gen → anchor (ADR-118 / ADR-117).
3
+ *
4
+ * In the retrieval-only wiring the anchor was policy-INDEPENDENT (a flat guard):
5
+ * the retrieval policy didn't feed test generation, so it couldn't move the
6
+ * oracle score, and the no-regression guard was inert. This closes that loop:
7
+ *
8
+ * retrieve(inputUnderTest, policy) → few-shot examples
9
+ * → generate(inputUnderTest, examples) → a test
10
+ * → evaluateOracle(referenceImpl, test) → mutation kill rate
11
+ *
12
+ * Now `anchorMean` VARIES with the retrieval policy — a policy that surfaces
13
+ * more useful examples yields better generated tests and a higher oracle score.
14
+ * The guard gets teeth: a candidate that games the cheap self-retrieval proxy
15
+ * but produces WORSE tests drops the anchor mean and is rejected (ADR-117
16
+ * no-regression), and the promotion is now genuinely oracle:test-exec-backed
17
+ * (ADR-121) rather than a framing stretch.
18
+ *
19
+ * `retrieve` and `generate` are injected seams: fake/deterministic in tests,
20
+ * a real policy-weighted DB retriever + an LLM test generator in production
21
+ * (the LLM step is the metered part — bind it deliberately).
22
+ */
23
+ import { computeRealEmbedding } from '../real-embeddings.js';
24
+ import { evaluateOracle } from '../../validation/oracle-eval.js';
25
+ import { loadAnchorSet, anchorMean as meanOf } from '../../validation/anchor-set.js';
26
+ import { createCorpusScorer } from './corpus-scorer.js';
27
+ const DEFAULT_ANCHOR_PATH = new URL('../../../verification/anchors/qe-anchor-v1.json', import.meta.url).pathname;
28
+ /**
29
+ * Build the coupled anchorMean scorer: `(policy) => Promise<number>`.
30
+ * Grades each frozen anchor item by generating a test from policy-retrieved
31
+ * examples and scoring its mutation kill rate. The anchor now moves with the
32
+ * policy.
33
+ */
34
+ export function createCoupledAnchorScorer(opts) {
35
+ const anchor = loadAnchorSet(opts.anchorPath ?? DEFAULT_ANCHOR_PATH);
36
+ const threshold = opts.threshold ?? 0.8;
37
+ return async (policy) => {
38
+ const scores = [];
39
+ for (const item of anchor.items) {
40
+ const examples = await opts.retrieve(item.inputUnderTest, policy);
41
+ const generatedTest = await opts.generate(item.inputUnderTest, examples);
42
+ const result = evaluateOracle({
43
+ moduleName: item.moduleName,
44
+ referenceImpl: item.referenceImpl,
45
+ generatedTest,
46
+ threshold,
47
+ maxMutants: opts.maxMutants,
48
+ });
49
+ scores.push(result.mutationScore);
50
+ }
51
+ return meanOf(scores);
52
+ };
53
+ }
54
+ /**
55
+ * A full PolicyScorer where `heldOut` is the cheap self-retrieval proxy (train
56
+ * signal) and `anchorMean` is the COUPLED oracle test-gen quality (the guard
57
+ * that now moves). The flywheel's accept() then requires a proxy gain WITHOUT an
58
+ * oracle-quality regression — the proxy-overfitting veto ADR-117 exists for.
59
+ */
60
+ export function createCoupledScorer(opts) {
61
+ const heldOutScorer = createCorpusScorer({ db: opts.db, anchorPath: opts.anchorPath, heldOutRatio: opts.heldOutRatio });
62
+ const anchorScorer = createCoupledAnchorScorer(opts);
63
+ return async (policy) => {
64
+ // heldOut comes from the corpus scorer (its own anchorMean is the flat guard
65
+ // and is discarded here — the coupled anchor replaces it).
66
+ const heldOut = (await heldOutScorer(policy)).heldOut;
67
+ const anchorMean = await anchorScorer(policy);
68
+ return { heldOut, anchorMean };
69
+ };
70
+ }
71
+ /**
72
+ * A real policy-weighted DB retriever over `qe_patterns` — token overlap on the
73
+ * query, scaled by the policy's body/subject weights, top-K by score. Read-only.
74
+ * Injected as `retrieve` for live runs; tests use a deterministic fake instead.
75
+ */
76
+ export function createDbRetriever(db, topK = 3) {
77
+ const rows = db.prepare(`SELECT id, name, COALESCE(description,'') AS body FROM qe_patterns WHERE deprecated_at IS NULL`).all();
78
+ const toks = (s) => new Set(s.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean));
79
+ const docs = rows.map((r) => ({ ...r, nameToks: toks(r.name), bodyToks: toks(r.body) }));
80
+ return (query, policy) => {
81
+ const q = toks(query);
82
+ const scored = docs.map((d) => {
83
+ let s = 0;
84
+ for (const t of q) {
85
+ if (d.bodyToks.has(t))
86
+ s += policy.alpha * policy.bodyWeight;
87
+ if (d.nameToks.has(t))
88
+ s += (1 - policy.alpha) * policy.subjectWeight;
89
+ }
90
+ return { d, s };
91
+ });
92
+ return scored
93
+ .sort((a, b) => b.s - a.s || a.d.id.localeCompare(b.d.id))
94
+ .slice(0, topK)
95
+ .map(({ d }) => ({ id: d.id, name: d.name, body: d.body }));
96
+ };
97
+ }
98
+ // ---------------------------------------------------------------------------
99
+ // Semantic retriever — policy-sensitive retrieval over real pattern embeddings
100
+ // ---------------------------------------------------------------------------
101
+ /** Cosine similarity of two equal-length vectors. */
102
+ function cosine(a, b) {
103
+ let dot = 0, na = 0, nb = 0;
104
+ for (let i = 0; i < a.length; i++) {
105
+ dot += a[i] * b[i];
106
+ na += a[i] * a[i];
107
+ nb += b[i] * b[i];
108
+ }
109
+ const d = Math.sqrt(na * nb);
110
+ return d === 0 ? 0 : dot / d;
111
+ }
112
+ /**
113
+ * Policy-sensitive SEMANTIC retriever over the pre-computed `qe_pattern_embeddings`
114
+ * (all-MiniLM-L6-v2). Fixes the lexical retriever's honest-null: the anchor
115
+ * queries (toy functions) have ~0 lexical overlap with the corpus, so lexical
116
+ * scores were identical for every policy. Cosine similarity is a real, varying
117
+ * signal, and the policy re-shapes retrieval three ways:
118
+ * - `alpha` blends semantic cosine vs lexical overlap,
119
+ * - `subjectWeight`/`bodyWeight` scale the lexical component,
120
+ * - `mmrLambda` trades relevance for diversity in a greedy MMR rerank
121
+ * (this is the lever that reorders even when lexical overlap is 0).
122
+ * Query embeddings are cached (same query across policies embeds once).
123
+ */
124
+ export function createSemanticRetriever(opts) {
125
+ const embed = opts.embed ?? ((t) => computeRealEmbedding(t));
126
+ const topK = opts.topK ?? 3;
127
+ const rows = opts.db.prepare(`SELECT p.id AS id, p.name AS name, COALESCE(p.description,'') AS body,
128
+ e.embedding AS embedding, e.dimension AS dimension
129
+ FROM qe_patterns p JOIN qe_pattern_embeddings e ON e.pattern_id = p.id
130
+ WHERE p.deprecated_at IS NULL`).all();
131
+ const toks = (s) => new Set(s.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean));
132
+ const docs = rows.map((r) => ({
133
+ id: r.id, name: r.name, body: r.body,
134
+ vec: new Float32Array(r.embedding.buffer, r.embedding.byteOffset, r.dimension),
135
+ nameToks: toks(r.name), bodyToks: toks(r.body),
136
+ }));
137
+ const queryCache = new Map();
138
+ return async (query, policy) => {
139
+ if (docs.length === 0)
140
+ return [];
141
+ let qv = queryCache.get(query);
142
+ if (!qv) {
143
+ qv = new Float32Array(await embed(query));
144
+ queryCache.set(query, qv);
145
+ }
146
+ const q = toks(query);
147
+ // relevance = alpha * semantic-cosine + (1-alpha) * weighted-lexical-overlap
148
+ const scored = docs.map((d) => {
149
+ const sem = cosine(qv, d.vec);
150
+ let lex = 0;
151
+ for (const t of q) {
152
+ if (d.bodyToks.has(t))
153
+ lex += policy.bodyWeight;
154
+ if (d.nameToks.has(t))
155
+ lex += policy.subjectWeight;
156
+ }
157
+ lex = lex / Math.max(1, q.size); // normalize to a comparable scale
158
+ return { d, rel: policy.alpha * sem + (1 - policy.alpha) * lex };
159
+ });
160
+ // greedy MMR rerank: mmrLambda trades relevance vs diversity (cosine between
161
+ // candidate embeddings). This reorders retrieval as the policy changes even
162
+ // when the lexical term is zero.
163
+ const lambda = policy.mmrLambda;
164
+ const remaining = scored.slice().sort((a, b) => b.rel - a.rel || a.d.id.localeCompare(b.d.id));
165
+ const chosen = [];
166
+ while (remaining.length > 0 && chosen.length < topK) {
167
+ let bestIdx = 0, bestScore = -Infinity;
168
+ for (let i = 0; i < remaining.length; i++) {
169
+ const sim = chosen.length === 0 ? 0 : Math.max(...chosen.map((c) => cosine(remaining[i].d.vec, c.d.vec)));
170
+ const mmr = lambda * remaining[i].rel - (1 - lambda) * sim;
171
+ if (mmr > bestScore || (mmr === bestScore && remaining[i].d.id.localeCompare(remaining[bestIdx].d.id) < 0)) {
172
+ bestScore = mmr;
173
+ bestIdx = i;
174
+ }
175
+ }
176
+ chosen.push(remaining.splice(bestIdx, 1)[0]);
177
+ }
178
+ return chosen.map(({ d }) => ({ id: d.id, name: d.name, body: d.body }));
179
+ };
180
+ }
181
+ //# sourceMappingURL=coupled-anchor.js.map
@@ -0,0 +1,121 @@
1
+ /**
2
+ * QE-policy flywheel — the generational loop (ADR-118).
3
+ *
4
+ * One generation: score the baseline champion and a candidate, seal the decision
5
+ * inputs, re-execute the FROZEN accept() rule (ADR-120 `accept/v1`: held-out
6
+ * beats baseline ∧ anchor no-regression (ADR-117) ∧ oracle tier (ADR-121)),
7
+ * and emit an Ed25519-signed receipt into an append-only lineage. Promotions
8
+ * compound: each generation re-bases on the previous promoted champion.
9
+ *
10
+ * The corpus SCORER is injected — harvesting `qe_patterns` and running retrieval
11
+ * + grading the anchor is the DB/model-touching part, wired separately. This
12
+ * keeps the loop, gate, receipts, and lineage fully testable and deterministic.
13
+ *
14
+ * Honest-null (ADR-234): a generation — or a whole run — that promotes NOTHING
15
+ * is a correct, valid, replayable outcome, not a failure.
16
+ */
17
+ import type { RetrievalPolicy } from './policy.js';
18
+ import { type EvolveReceipt, type Signer } from './receipt.js';
19
+ /** Scores for a policy on the harvested corpus + the frozen anchor. */
20
+ export interface PolicyScores {
21
+ /** Self-retrieval on the held-out split (the train/serve signal — never the accept signal alone). */
22
+ heldOut: number;
23
+ /** Mean over the ADR-117 frozen anchor items (the no-regression signal). */
24
+ anchorMean: number;
25
+ }
26
+ /** Injected: evaluate a policy → its held-out + anchor scores. */
27
+ export type PolicyScorer = (policy: RetrievalPolicy) => PolicyScores | Promise<PolicyScores>;
28
+ export interface HeadroomResult {
29
+ hasHeadroom: boolean;
30
+ baselineHeldOut: number;
31
+ baselineAnchorMean: number;
32
+ reason: string;
33
+ }
34
+ /**
35
+ * ADR-118 §1 headroom precondition. If the baseline already saturates the
36
+ * held-out signal, the loop must NOT run — it would spend compute for
37
+ * structurally-zero promotions (the MetaHarness SWE-bench null).
38
+ */
39
+ export declare function checkHeadroom(baseline: RetrievalPolicy, scorer: PolicyScorer, saturation?: number): Promise<HeadroomResult>;
40
+ export interface GenerationInput {
41
+ generation: number;
42
+ baseline: RetrievalPolicy;
43
+ candidate: RetrievalPolicy;
44
+ scorer: PolicyScorer;
45
+ /** ADR-117 frozen anchor content hash (which anchor was graded). */
46
+ anchorHash: string;
47
+ /** No-regression tolerance (ADR-117 sign-off: 0.0). */
48
+ anchorTol: number;
49
+ /** Provenance tier of the corpus evidence (ADR-121). Only oracle-tier promotes. */
50
+ provenanceTier?: string;
51
+ /** Whether judge-tier promotion is explicitly budgeted (ADR-121). */
52
+ allowJudgeTier?: boolean;
53
+ signer: Signer;
54
+ /** Frozen rule version (default 'accept/v1'). */
55
+ ruleVersion?: string;
56
+ }
57
+ export interface GenerationResult {
58
+ generation: number;
59
+ verdict: 'promote' | 'reject';
60
+ baselinePolicyId: string;
61
+ candidatePolicyId: string;
62
+ scores: {
63
+ baseline: PolicyScores;
64
+ candidate: PolicyScores;
65
+ };
66
+ receipt: EvolveReceipt;
67
+ /** The champion AFTER this generation: candidate if promoted, else baseline unchanged. */
68
+ champion: RetrievalPolicy;
69
+ }
70
+ /**
71
+ * Run one flywheel generation. Deterministic given the scorer and signer seed.
72
+ * Never mutates fleet state — it returns the verdict + a signed receipt; serving
73
+ * the champion is a separate, reversible step (serveChampion / rollback).
74
+ */
75
+ export declare function runFlywheelGeneration(input: GenerationInput): Promise<GenerationResult>;
76
+ export interface LineageResult {
77
+ /** Number of PROMOTED generations. */
78
+ promotions: number;
79
+ /** Every promoted child re-based on its parent's promoted candidate (compounding). */
80
+ lineageIntact: boolean;
81
+ /** Every receipt's signature verifies AND its frozen gate re-executes to the recorded verdict. */
82
+ allReplayable: boolean;
83
+ reason: string;
84
+ }
85
+ /**
86
+ * Reconstruct + validate a lineage from an ordered receipt list (ADR-118 §4).
87
+ * Proves the chain compounds and every step is replayable — the property that
88
+ * makes a stub unable to launder a regression (a forged promote fails
89
+ * verifyPromotion; a broken chain fails lineageIntact).
90
+ */
91
+ export declare function reconstructLineage(receipts: EvolveReceipt[]): LineageResult;
92
+ export interface ActivePolicy {
93
+ current: RetrievalPolicy;
94
+ currentId: string;
95
+ /** Rollback target — the policy served before `current`. */
96
+ previous: RetrievalPolicy | null;
97
+ previousId: string | null;
98
+ generation: number;
99
+ }
100
+ /** Initialize the active pointer at the gen-0 root policy. */
101
+ export declare function initActivePolicy(root: RetrievalPolicy): ActivePolicy;
102
+ /**
103
+ * Serve a newly-promoted champion, shifting the old current into `previous` as
104
+ * the rollback target (serve-then-shadow: the new policy is served, the old is
105
+ * retained one generation for the canary to fall back to).
106
+ */
107
+ export declare function serveChampion(active: ActivePolicy, champion: RetrievalPolicy, generation: number): ActivePolicy;
108
+ /** Roll the active pointer back to its previous policy (drift-canary auto-rollback). */
109
+ export declare function rollback(active: ActivePolicy): ActivePolicy;
110
+ export interface DriftCanaryResult {
111
+ drifted: boolean;
112
+ reason: string;
113
+ }
114
+ /**
115
+ * Drift canary (ADR-118 §5, ruflo `:259-302`): re-score the served champion
116
+ * against its predecessor on a FRESH harvest; if EITHER the held-out or the
117
+ * anchor score drops below the predecessor, the promotion regressed in
118
+ * production and must be rolled back.
119
+ */
120
+ export declare function checkDriftCanary(served: PolicyScores, predecessor: PolicyScores, tol?: number): DriftCanaryResult;
121
+ //# sourceMappingURL=generation.d.ts.map
@@ -0,0 +1,167 @@
1
+ /**
2
+ * QE-policy flywheel — the generational loop (ADR-118).
3
+ *
4
+ * One generation: score the baseline champion and a candidate, seal the decision
5
+ * inputs, re-execute the FROZEN accept() rule (ADR-120 `accept/v1`: held-out
6
+ * beats baseline ∧ anchor no-regression (ADR-117) ∧ oracle tier (ADR-121)),
7
+ * and emit an Ed25519-signed receipt into an append-only lineage. Promotions
8
+ * compound: each generation re-bases on the previous promoted champion.
9
+ *
10
+ * The corpus SCORER is injected — harvesting `qe_patterns` and running retrieval
11
+ * + grading the anchor is the DB/model-touching part, wired separately. This
12
+ * keeps the loop, gate, receipts, and lineage fully testable and deterministic.
13
+ *
14
+ * Honest-null (ADR-234): a generation — or a whole run — that promotes NOTHING
15
+ * is a correct, valid, replayable outcome, not a failure.
16
+ */
17
+ import { DEFAULT_PROVENANCE_TIER } from '../provenance-tier.js';
18
+ import { reExecuteGate, gateFingerprint, sealedHash, verifyPromotion, } from '../../validation/gate-reexecute.js';
19
+ import { policyId } from './policy.js';
20
+ import { signReceipt, verifyReceiptSignature, toPromotionReceipt, } from './receipt.js';
21
+ /**
22
+ * ADR-118 §1 headroom precondition. If the baseline already saturates the
23
+ * held-out signal, the loop must NOT run — it would spend compute for
24
+ * structurally-zero promotions (the MetaHarness SWE-bench null).
25
+ */
26
+ export async function checkHeadroom(baseline, scorer, saturation = 0.999) {
27
+ const s = await scorer(baseline);
28
+ const hasHeadroom = s.heldOut < saturation;
29
+ return {
30
+ hasHeadroom,
31
+ baselineHeldOut: s.heldOut,
32
+ baselineAnchorMean: s.anchorMean,
33
+ reason: hasHeadroom
34
+ ? `baseline held-out ${s.heldOut.toFixed(4)} < saturation ${saturation} — headroom exists`
35
+ : `baseline held-out ${s.heldOut.toFixed(4)} >= saturation ${saturation} — no headroom, loop must not run`,
36
+ };
37
+ }
38
+ /**
39
+ * Run one flywheel generation. Deterministic given the scorer and signer seed.
40
+ * Never mutates fleet state — it returns the verdict + a signed receipt; serving
41
+ * the champion is a separate, reversible step (serveChampion / rollback).
42
+ */
43
+ export async function runFlywheelGeneration(input) {
44
+ const ruleVersion = input.ruleVersion ?? 'accept/v1';
45
+ const provenanceTier = input.provenanceTier ?? DEFAULT_PROVENANCE_TIER;
46
+ const baselineScores = await input.scorer(input.baseline);
47
+ const candidateScores = await input.scorer(input.candidate);
48
+ const sealed = {
49
+ candidateHeldOut: candidateScores.heldOut,
50
+ baselineHeldOut: baselineScores.heldOut,
51
+ candidateAnchorMean: candidateScores.anchorMean,
52
+ baselineAnchorMean: baselineScores.anchorMean,
53
+ anchorHash: input.anchorHash,
54
+ anchorTol: input.anchorTol,
55
+ provenanceTier,
56
+ allowJudgeTier: input.allowJudgeTier,
57
+ };
58
+ const ruleResult = reExecuteGate(ruleVersion, sealed);
59
+ const verdict = ruleResult.promote ? 'promote' : 'reject';
60
+ const baselinePolicyId = policyId(input.baseline);
61
+ const candidatePolicyId = policyId(input.candidate);
62
+ const receipt = signReceipt({
63
+ generation: input.generation,
64
+ ruleVersion,
65
+ ruleFingerprint: gateFingerprint(ruleVersion),
66
+ sealed,
67
+ sealedHash: sealedHash(sealed),
68
+ verdict,
69
+ baselinePolicyId,
70
+ candidatePolicyId,
71
+ signerKeyId: input.signer.keyId,
72
+ publicKeyPem: input.signer.publicKeyPem,
73
+ }, input.signer);
74
+ return {
75
+ generation: input.generation,
76
+ verdict,
77
+ baselinePolicyId,
78
+ candidatePolicyId,
79
+ scores: { baseline: baselineScores, candidate: candidateScores },
80
+ receipt,
81
+ champion: verdict === 'promote' ? input.candidate : input.baseline,
82
+ };
83
+ }
84
+ /**
85
+ * Reconstruct + validate a lineage from an ordered receipt list (ADR-118 §4).
86
+ * Proves the chain compounds and every step is replayable — the property that
87
+ * makes a stub unable to launder a regression (a forged promote fails
88
+ * verifyPromotion; a broken chain fails lineageIntact).
89
+ */
90
+ export function reconstructLineage(receipts) {
91
+ let promotions = 0;
92
+ let lineageIntact = true;
93
+ let allReplayable = true;
94
+ let lastPromotedCandidate = null;
95
+ for (const r of receipts) {
96
+ // Replayability: signature + frozen-rule re-execution (ADR-120).
97
+ if (!verifyReceiptSignature(r))
98
+ allReplayable = false;
99
+ const replay = verifyPromotion(toPromotionReceipt(r));
100
+ if (!replay.valid)
101
+ allReplayable = false;
102
+ if (r.verdict === 'promote') {
103
+ // A promoted generation must re-base on the previous promoted champion.
104
+ if (lastPromotedCandidate !== null && r.baselinePolicyId !== lastPromotedCandidate) {
105
+ lineageIntact = false;
106
+ }
107
+ lastPromotedCandidate = r.candidatePolicyId;
108
+ promotions++;
109
+ }
110
+ }
111
+ return {
112
+ promotions,
113
+ lineageIntact,
114
+ allReplayable,
115
+ reason: `${promotions} promotion(s); lineage ${lineageIntact ? 'intact' : 'BROKEN'}; `
116
+ + `${allReplayable ? 'all replayable' : 'NOT all replayable'}`,
117
+ };
118
+ }
119
+ /** Initialize the active pointer at the gen-0 root policy. */
120
+ export function initActivePolicy(root) {
121
+ return { current: root, currentId: policyId(root), previous: null, previousId: null, generation: 0 };
122
+ }
123
+ /**
124
+ * Serve a newly-promoted champion, shifting the old current into `previous` as
125
+ * the rollback target (serve-then-shadow: the new policy is served, the old is
126
+ * retained one generation for the canary to fall back to).
127
+ */
128
+ export function serveChampion(active, champion, generation) {
129
+ return {
130
+ current: champion,
131
+ currentId: policyId(champion),
132
+ previous: active.current,
133
+ previousId: active.currentId,
134
+ generation,
135
+ };
136
+ }
137
+ /** Roll the active pointer back to its previous policy (drift-canary auto-rollback). */
138
+ export function rollback(active) {
139
+ if (active.previous === null)
140
+ return active; // nothing to roll back to
141
+ return {
142
+ current: active.previous,
143
+ currentId: active.previousId,
144
+ previous: null,
145
+ previousId: null,
146
+ generation: active.generation,
147
+ };
148
+ }
149
+ /**
150
+ * Drift canary (ADR-118 §5, ruflo `:259-302`): re-score the served champion
151
+ * against its predecessor on a FRESH harvest; if EITHER the held-out or the
152
+ * anchor score drops below the predecessor, the promotion regressed in
153
+ * production and must be rolled back.
154
+ */
155
+ export function checkDriftCanary(served, predecessor, tol = 0) {
156
+ const heldOutDrift = served.heldOut < predecessor.heldOut - tol;
157
+ const anchorDrift = served.anchorMean < predecessor.anchorMean - tol;
158
+ const drifted = heldOutDrift || anchorDrift;
159
+ return {
160
+ drifted,
161
+ reason: drifted
162
+ ? `drift detected: ${heldOutDrift ? `held-out ${served.heldOut.toFixed(4)}<${predecessor.heldOut.toFixed(4)} ` : ''}`
163
+ + `${anchorDrift ? `anchor ${served.anchorMean.toFixed(4)}<${predecessor.anchorMean.toFixed(4)}` : ''}`.trim()
164
+ : 'served champion holds vs predecessor — no rollback',
165
+ };
166
+ }
167
+ //# sourceMappingURL=generation.js.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Retrieval policy — the hyperparameters the QE-policy flywheel tunes (ADR-118).
3
+ *
4
+ * The flywheel optimizes AQE's hybrid retrieval/selection policy over
5
+ * `qe_patterns` (the ruflo RetrievalConfig shape), one generation at a time,
6
+ * behind the frozen accept() gate. This module defines the policy and the
7
+ * candidate proposal; it does NOT touch the DB or evaluate anything (the scorer
8
+ * is injected in generation.ts).
9
+ */
10
+ /** The tunable hybrid-retrieval hyperparameters. */
11
+ export interface RetrievalPolicy {
12
+ /** Dense/sparse blend weight [0,1]. */
13
+ alpha: number;
14
+ /** Weight on subject/title token match. */
15
+ subjectWeight: number;
16
+ /** Weight on body/content token match. */
17
+ bodyWeight: number;
18
+ /** MMR diversity vs relevance tradeoff [0,1]. */
19
+ mmrLambda: number;
20
+ /** Penalty factor for pattern-type mismatch [0,1]. */
21
+ typePenaltyFactor: number;
22
+ }
23
+ /** ADR-082 defaults — the gen-0 root policy. */
24
+ export declare const DEFAULT_POLICY: RetrievalPolicy;
25
+ /**
26
+ * Stable id of a policy — canonical (sorted-key, fixed-precision) hash. Two
27
+ * numerically-equal policies get the same id, so lineage links are exact.
28
+ */
29
+ export declare function policyId(p: RetrievalPolicy): string;
30
+ /**
31
+ * Propose candidate policies around a baseline — a coarse ±step grid, one axis
32
+ * moved at a time (plus a floor of exploration on every axis). Later generations
33
+ * can bias this toward historically-effective axes (ruflo `biasedGrid`), but the
34
+ * gate is what makes any proposal safe, so a simple grid is a fine start.
35
+ */
36
+ export declare function proposeCandidates(baseline: RetrievalPolicy, step?: number): RetrievalPolicy[];
37
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Retrieval policy — the hyperparameters the QE-policy flywheel tunes (ADR-118).
3
+ *
4
+ * The flywheel optimizes AQE's hybrid retrieval/selection policy over
5
+ * `qe_patterns` (the ruflo RetrievalConfig shape), one generation at a time,
6
+ * behind the frozen accept() gate. This module defines the policy and the
7
+ * candidate proposal; it does NOT touch the DB or evaluate anything (the scorer
8
+ * is injected in generation.ts).
9
+ */
10
+ import { createHash } from 'node:crypto';
11
+ /** ADR-082 defaults — the gen-0 root policy. */
12
+ export const DEFAULT_POLICY = {
13
+ alpha: 0.5,
14
+ subjectWeight: 1.0,
15
+ bodyWeight: 1.0,
16
+ mmrLambda: 0.5,
17
+ typePenaltyFactor: 0.1,
18
+ };
19
+ const AXES = ['alpha', 'subjectWeight', 'bodyWeight', 'mmrLambda', 'typePenaltyFactor'];
20
+ /** Clamp helper — keep weights in sane bounds so candidates stay well-formed. */
21
+ function clamp(v, lo, hi) {
22
+ return Math.min(hi, Math.max(lo, v));
23
+ }
24
+ const BOUNDS = {
25
+ alpha: [0, 1],
26
+ subjectWeight: [0, 4],
27
+ bodyWeight: [0, 4],
28
+ mmrLambda: [0, 1],
29
+ typePenaltyFactor: [0, 1],
30
+ };
31
+ /**
32
+ * Stable id of a policy — canonical (sorted-key, fixed-precision) hash. Two
33
+ * numerically-equal policies get the same id, so lineage links are exact.
34
+ */
35
+ export function policyId(p) {
36
+ const canon = AXES.map((k) => `${k}:${p[k].toFixed(6)}`).join('|');
37
+ return createHash('sha256').update(canon).digest('hex').slice(0, 16);
38
+ }
39
+ /**
40
+ * Propose candidate policies around a baseline — a coarse ±step grid, one axis
41
+ * moved at a time (plus a floor of exploration on every axis). Later generations
42
+ * can bias this toward historically-effective axes (ruflo `biasedGrid`), but the
43
+ * gate is what makes any proposal safe, so a simple grid is a fine start.
44
+ */
45
+ export function proposeCandidates(baseline, step = 0.1) {
46
+ const out = [];
47
+ for (const axis of AXES) {
48
+ for (const dir of [-1, 1]) {
49
+ const [lo, hi] = BOUNDS[axis];
50
+ const moved = clamp(baseline[axis] + dir * step, lo, hi);
51
+ if (moved === baseline[axis])
52
+ continue; // no-op at a bound
53
+ out.push({ ...baseline, [axis]: moved });
54
+ }
55
+ }
56
+ // de-dup by id (a bound can collapse two moves)
57
+ const seen = new Set();
58
+ return out.filter((p) => {
59
+ const id = policyId(p);
60
+ if (seen.has(id))
61
+ return false;
62
+ seen.add(id);
63
+ return true;
64
+ });
65
+ }
66
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Durable, append-only persistence for flywheel evolve receipts (ADR-118 §4).
3
+ *
4
+ * The generational lineage is only trustworthy if it survives the process: a
5
+ * third party must be able to reload the receipts and re-verify each one
6
+ * (signature + frozen-gate re-execution) offline. This stores every receipt —
7
+ * promoted OR rejected — in an append-only table in the unified `memory.db`.
8
+ *
9
+ * Data safety (unified-memory rule): CREATE TABLE IF NOT EXISTS is additive;
10
+ * writes are INSERT-only (no UPDATE/DELETE/DROP in this API); the caller opens
11
+ * the DB and is responsible for backups. The `db` handle is injected so tests
12
+ * run against an in-memory database.
13
+ */
14
+ import type { Database as DatabaseType } from 'better-sqlite3';
15
+ import { type LineageResult } from './generation.js';
16
+ import type { EvolveReceipt } from './receipt.js';
17
+ /** Idempotent, additive migration — creates the receipts table if absent. */
18
+ export declare function ensureReceiptTable(db: DatabaseType): void;
19
+ /** Append one receipt (INSERT-only). Returns its assigned seq. */
20
+ export declare function persistReceipt(db: DatabaseType, receipt: EvolveReceipt): number;
21
+ /** Append many receipts in one transaction (still INSERT-only). */
22
+ export declare function persistReceipts(db: DatabaseType, receipts: EvolveReceipt[]): number;
23
+ /** Load persisted receipts back into EvolveReceipt objects, ordered by seq. */
24
+ export declare function loadReceipts(db: DatabaseType): EvolveReceipt[];
25
+ /**
26
+ * Reload the persisted lineage and re-verify it end-to-end (signatures +
27
+ * frozen-gate re-execution + compounding chain). This is the offline
28
+ * "trust the re-run, not the log" check applied to what's actually on disk.
29
+ */
30
+ export declare function verifyPersistedLineage(db: DatabaseType): LineageResult;
31
+ //# sourceMappingURL=receipt-store.d.ts.map