agentic-qe 3.12.2 → 3.13.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 (401) hide show
  1. package/.claude/helpers/.helpers-version +1 -1
  2. package/.claude/helpers/auto-memory-hook.mjs +430 -430
  3. package/.claude/helpers/helpers.manifest.json +6 -5
  4. package/.claude/helpers/hook-handler.cjs +565 -311
  5. package/.claude/helpers/intelligence.cjs +1058 -1058
  6. package/.claude/helpers/statusline.cjs +995 -682
  7. package/.claude/skills/qe-court/SKILL.md +186 -0
  8. package/.claude/skills/qe-court/config.json +27 -0
  9. package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/README.md +38 -0
  10. package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.test.ts +21 -0
  11. package/.claude/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.ts +25 -0
  12. package/.claude/skills/qe-court/evals/qe-court.yaml +70 -0
  13. package/.claude/skills/qe-court/schemas/output.json +92 -0
  14. package/.claude/skills/qe-court/scripts/validate-config.json +30 -0
  15. package/.claude/skills/skills-manifest.json +9 -8
  16. package/CHANGELOG.md +104 -0
  17. package/README.md +3 -3
  18. package/assets/skills/qe-court/SKILL.md +186 -0
  19. package/assets/skills/qe-court/config.json +27 -0
  20. package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/README.md +38 -0
  21. package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.test.ts +21 -0
  22. package/assets/skills/qe-court/evals/fixtures/seeded-mutant-delivery/budget.ts +25 -0
  23. package/assets/skills/qe-court/evals/qe-court.yaml +70 -0
  24. package/assets/skills/qe-court/schemas/output.json +92 -0
  25. package/assets/skills/qe-court/scripts/validate-config.json +30 -0
  26. package/assets/skills/skills-manifest.json +9 -8
  27. package/dist/cli/bundle.js +5 -5
  28. package/dist/cli/chunks/adapter-CWIMFWAI.js +2 -0
  29. package/dist/cli/chunks/{agent-booster-wasm-3KYNICBC.js → agent-booster-wasm-ACX2DK7Y.js} +2 -2
  30. package/dist/cli/chunks/{agent-handler-NGPTMI6E.js → agent-handler-B45WP4ZJ.js} +2 -2
  31. package/dist/cli/chunks/{agent-memory-branch-GNTQKQMG.js → agent-memory-branch-QQLZDE56.js} +2 -2
  32. package/dist/cli/chunks/aqe-learning-engine-OTXT2DLN.js +2 -0
  33. package/dist/cli/chunks/{arena-HQEP2NWI.js → arena-G3IKZAG5.js} +4 -4
  34. package/dist/cli/chunks/{arena-PA7VIYD4.js → arena-SDB7723R.js} +2 -2
  35. package/dist/cli/chunks/{audit-XSDM57GC.js → audit-GY46XUZA.js} +3 -3
  36. package/dist/cli/chunks/base-O3SPSWBA.js +2 -0
  37. package/dist/cli/chunks/{hnswlib-node-BCASOCNU.js → better-sqlite3-DUZ6FFAH.js} +2 -2
  38. package/dist/cli/chunks/brain-handler-347CYMPN.js +89 -0
  39. package/dist/cli/chunks/{branch-enumerator-ZW7RNMUF.js → branch-enumerator-Z3ULBFSM.js} +2 -2
  40. package/dist/cli/chunks/{browser-4LU22CPP.js → browser-OYEIHD7F.js} +2 -2
  41. package/dist/cli/chunks/browser-workflow-MXS3ZKY2.js +2 -0
  42. package/dist/cli/chunks/{chunk-CKFZOPZN.js → chunk-2DIT5AUU.js} +2 -2
  43. package/dist/cli/chunks/{chunk-RXH2TC2K.js → chunk-2NRZYQSF.js} +2 -2
  44. package/dist/cli/chunks/chunk-2VQVEQS4.js +153 -0
  45. package/dist/cli/chunks/{chunk-KDGLNJPB.js → chunk-32ZGV4Q4.js} +1 -1
  46. package/dist/cli/chunks/{chunk-327YEKBU.js → chunk-34PEINFS.js} +2 -2
  47. package/dist/cli/chunks/{chunk-CTFW7CMI.js → chunk-3GSYD5SL.js} +2 -2
  48. package/dist/cli/chunks/{chunk-YRO7HNS4.js → chunk-3JVUWKCO.js} +2 -2
  49. package/dist/cli/chunks/{chunk-TERRRQVY.js → chunk-3K4SF57Q.js} +1 -1
  50. package/dist/cli/chunks/{chunk-6N62KS3C.js → chunk-3NOCK6ED.js} +2 -2
  51. package/dist/cli/chunks/{chunk-7DV42KFP.js → chunk-3UHEZ5HZ.js} +2 -2
  52. package/dist/cli/chunks/{chunk-N57BKUVE.js → chunk-4BDLD7V2.js} +1 -1
  53. package/dist/cli/chunks/{chunk-5SM57X4D.js → chunk-4BESADKE.js} +2 -2
  54. package/dist/cli/chunks/{chunk-GCQATSMK.js → chunk-54MFKCLT.js} +2 -2
  55. package/dist/cli/chunks/{chunk-GUGUYFU5.js → chunk-56WZFXTQ.js} +2 -2
  56. package/dist/cli/chunks/{chunk-OELLHV7S.js → chunk-5EIOQCGN.js} +2 -2
  57. package/dist/cli/chunks/{chunk-Z63IOTDW.js → chunk-5FLTZ3KT.js} +2 -2
  58. package/dist/cli/chunks/{chunk-EKTWIEEO.js → chunk-5ICQL42E.js} +2 -2
  59. package/dist/cli/chunks/{chunk-VQU2JXTK.js → chunk-5KAT6WBQ.js} +2 -2
  60. package/dist/cli/chunks/{chunk-VHYACXLN.js → chunk-6AOBLBR4.js} +2 -2
  61. package/dist/cli/chunks/{chunk-Z3FA5KR6.js → chunk-6DTOGSDV.js} +4 -4
  62. package/dist/cli/chunks/{chunk-SYLTJKN2.js → chunk-6SXKCIN5.js} +2 -2
  63. package/dist/cli/chunks/{chunk-MF4FULAI.js → chunk-7DMXCCSD.js} +1 -1
  64. package/dist/cli/chunks/{chunk-BOR5MME3.js → chunk-7UNY32PU.js} +1 -1
  65. package/dist/cli/chunks/{chunk-T6TQPF5P.js → chunk-7YXT6BXN.js} +3 -3
  66. package/dist/cli/chunks/{chunk-ADZTWGEB.js → chunk-A4QLGPYO.js} +2 -2
  67. package/dist/cli/chunks/{chunk-RFQIC6ZF.js → chunk-A7GLWWSE.js} +1 -1
  68. package/dist/cli/chunks/{chunk-WC5PM33J.js → chunk-ANIDFJCT.js} +3 -3
  69. package/dist/cli/chunks/{chunk-TFVWUR2U.js → chunk-ANYYTWOQ.js} +2 -2
  70. package/dist/cli/chunks/{chunk-YZ44FUVJ.js → chunk-AO7AHX6K.js} +2 -2
  71. package/dist/cli/chunks/{chunk-PHIEJAQK.js → chunk-BCKTBGDM.js} +3 -3
  72. package/dist/cli/chunks/{chunk-GECWGFRR.js → chunk-BGYLNCL6.js} +2 -2
  73. package/dist/cli/chunks/{chunk-PXKVW6PT.js → chunk-BOVH6WSM.js} +2 -2
  74. package/dist/cli/chunks/{chunk-P65S7AZA.js → chunk-BUGWPTMF.js} +2 -2
  75. package/dist/cli/chunks/{chunk-RXEQB4OT.js → chunk-CFVEDUTW.js} +2 -2
  76. package/dist/cli/chunks/{chunk-HNU32LN3.js → chunk-CPH5JP4L.js} +1 -1
  77. package/dist/cli/chunks/{chunk-LIAW5FD7.js → chunk-CQFT7H3F.js} +2 -2
  78. package/dist/cli/chunks/{chunk-WY5CX3VH.js → chunk-CWUBOLKY.js} +2 -2
  79. package/dist/cli/chunks/{chunk-X47GHZY3.js → chunk-CYL2FV23.js} +2 -2
  80. package/dist/cli/chunks/{chunk-W7LBT3BF.js → chunk-D3MPV5G7.js} +2 -2
  81. package/dist/cli/chunks/{chunk-7KMYBRKJ.js → chunk-DRIJYTSK.js} +2 -2
  82. package/dist/cli/chunks/{chunk-BDVOXGY5.js → chunk-DYUC7WFA.js} +1 -1
  83. package/dist/cli/chunks/{chunk-ZBYMF2QJ.js → chunk-E3B5XTXJ.js} +1 -1
  84. package/dist/cli/chunks/{chunk-TMQ3S7HR.js → chunk-EECM5XKY.js} +1 -1
  85. package/dist/cli/chunks/{chunk-7OD6HFCP.js → chunk-EFRESRLB.js} +3 -3
  86. package/dist/cli/chunks/{chunk-HU6ETNA7.js → chunk-ES7WCYOU.js} +1 -1
  87. package/dist/cli/chunks/chunk-FAQLI3P5.js +2 -0
  88. package/dist/cli/chunks/{chunk-K43YXI7C.js → chunk-FBBZHATF.js} +2 -2
  89. package/dist/cli/chunks/{chunk-2R7J4ZGT.js → chunk-FL3BM54K.js} +1 -1
  90. package/dist/cli/chunks/{chunk-KBXW7S3W.js → chunk-FQLWQWRU.js} +3 -3
  91. package/dist/cli/chunks/{chunk-LWVUNBZO.js → chunk-FQY3UTGA.js} +2 -2
  92. package/dist/cli/chunks/{chunk-2L7K2J2T.js → chunk-FUU32QY5.js} +2 -2
  93. package/dist/cli/chunks/{chunk-3LELACAQ.js → chunk-G4GTE3RJ.js} +2 -2
  94. package/dist/cli/chunks/{chunk-APVXTHTA.js → chunk-G5DFYX3J.js} +3 -3
  95. package/dist/cli/chunks/chunk-G7FMYFTN.js +2 -0
  96. package/dist/cli/chunks/{chunk-CMKCPRWX.js → chunk-GFBLWFRV.js} +1 -1
  97. package/dist/cli/chunks/{chunk-5YLY2WT2.js → chunk-GJMZR7WU.js} +3 -3
  98. package/dist/cli/chunks/{chunk-R6LDR3IO.js → chunk-GTUFX7AR.js} +2 -2
  99. package/dist/cli/chunks/{chunk-5CGTBAVF.js → chunk-GUEZQOHL.js} +1 -1
  100. package/dist/cli/chunks/{chunk-DGOZ3CGB.js → chunk-HL2QMM4M.js} +2 -2
  101. package/dist/cli/chunks/{chunk-VOHYQ6MX.js → chunk-HOKON5EL.js} +2 -2
  102. package/dist/cli/chunks/{chunk-DTXHRALB.js → chunk-HTPM3URI.js} +2 -2
  103. package/dist/cli/chunks/chunk-HVB2L52I.js +2 -0
  104. package/dist/cli/chunks/{chunk-GP7IXYOY.js → chunk-IHQTXJAQ.js} +1 -1
  105. package/dist/cli/chunks/{chunk-LOZAUP6L.js → chunk-IPHLXAMX.js} +2 -2
  106. package/dist/cli/chunks/{chunk-56MXYSYY.js → chunk-IYDYJ33J.js} +2 -2
  107. package/dist/cli/chunks/{chunk-QYST2TZW.js → chunk-IZRLIWFN.js} +2 -2
  108. package/dist/cli/chunks/{chunk-XNNYHQLW.js → chunk-J3L52EA4.js} +5 -5
  109. package/dist/cli/chunks/{chunk-P2FYRAC5.js → chunk-JGM6XCCP.js} +1 -1
  110. package/dist/cli/chunks/chunk-JPIBPKBP.js +54 -0
  111. package/dist/cli/chunks/{chunk-ILNQPPKB.js → chunk-K5N6SLHO.js} +1 -1
  112. package/dist/cli/chunks/{chunk-UEIIIDBJ.js → chunk-KSYLRM4Q.js} +2 -2
  113. package/dist/cli/chunks/{chunk-TRHUH24V.js → chunk-KUA4HHU6.js} +2 -2
  114. package/dist/cli/chunks/{chunk-OEZNUXY7.js → chunk-KVL63BSU.js} +1 -1
  115. package/dist/cli/chunks/{chunk-WMNGPIP3.js → chunk-KZTBNDNE.js} +1 -1
  116. package/dist/cli/chunks/{chunk-OSAPKOGN.js → chunk-L2SFGFE6.js} +1 -1
  117. package/dist/cli/chunks/{chunk-IQ56KMMH.js → chunk-L4LLA5U7.js} +1 -1
  118. package/dist/cli/chunks/{chunk-KBAXD6PH.js → chunk-L4S722JD.js} +1 -1
  119. package/dist/cli/chunks/{chunk-C7VNQ4PY.js → chunk-LBE2P6UC.js} +2 -2
  120. package/dist/cli/chunks/{chunk-KNOO6TFO.js → chunk-LOXVVMS4.js} +3 -3
  121. package/dist/cli/chunks/{chunk-B7DI76SY.js → chunk-LWYLW7RX.js} +2 -2
  122. package/dist/cli/chunks/{chunk-6SWR2BN7.js → chunk-LXPB7H2P.js} +1 -1
  123. package/dist/cli/chunks/{chunk-LGEPR7MH.js → chunk-MBCGI3M2.js} +3 -3
  124. package/dist/cli/chunks/{chunk-WL5VMIO4.js → chunk-MVI2QMRW.js} +1 -1
  125. package/dist/cli/chunks/{chunk-OIUIVV2N.js → chunk-N5MMBA35.js} +1 -1
  126. package/dist/cli/chunks/{chunk-TQNNKW7K.js → chunk-N7VOOI3U.js} +2 -2
  127. package/dist/cli/chunks/{chunk-BPSEFLJ6.js → chunk-NETN3OUG.js} +1 -1
  128. package/dist/cli/chunks/chunk-NQNKKVNO.js +29 -0
  129. package/dist/cli/chunks/{chunk-ACDZ2CRV.js → chunk-NUQBJGGF.js} +2 -2
  130. package/dist/cli/chunks/chunk-OETDMOOE.js +2 -0
  131. package/dist/cli/chunks/{chunk-R5HC6JVJ.js → chunk-OXXMVQDF.js} +2 -2
  132. package/dist/cli/chunks/{chunk-J6EFAKDQ.js → chunk-OZR25R7W.js} +2 -2
  133. package/dist/cli/chunks/{chunk-ZL7ZOIHO.js → chunk-PERJO2DY.js} +1 -1
  134. package/dist/cli/chunks/{chunk-WKWIUS5G.js → chunk-PP2RYSHT.js} +3 -3
  135. package/dist/cli/chunks/{chunk-WE5QHYL7.js → chunk-Q7PBGNUD.js} +1 -1
  136. package/dist/cli/chunks/{chunk-E5XWCGSX.js → chunk-QCEW4ZDW.js} +2 -2
  137. package/dist/cli/chunks/{chunk-EGU54SNK.js → chunk-QI4CGJNK.js} +1 -1
  138. package/dist/cli/chunks/{chunk-MNNNA57O.js → chunk-QQB55ZJJ.js} +2 -2
  139. package/dist/cli/chunks/{chunk-KV5OZ6T3.js → chunk-QTU3CVOB.js} +2 -2
  140. package/dist/cli/chunks/{chunk-M4XVEUUM.js → chunk-QWYISZTN.js} +2 -2
  141. package/dist/cli/chunks/{chunk-OMIGKGJJ.js → chunk-R3GEXYO4.js} +2 -2
  142. package/dist/cli/chunks/{chunk-4KEOBDEI.js → chunk-RDU4WTV2.js} +2 -2
  143. package/dist/cli/chunks/{chunk-3AJUJAUJ.js → chunk-RJZRWVL4.js} +1 -1
  144. package/dist/cli/chunks/{chunk-UFPCNUJA.js → chunk-RLCWR7TS.js} +10 -10
  145. package/dist/cli/chunks/{chunk-FTG4ZVTX.js → chunk-RSFIOR2I.js} +10 -10
  146. package/dist/cli/chunks/{chunk-FKUH33L3.js → chunk-RVJPWRV6.js} +2 -2
  147. package/dist/cli/chunks/{chunk-AMPYON7M.js → chunk-RVRBTOWX.js} +2 -2
  148. package/dist/cli/chunks/{chunk-AJ6DZXKK.js → chunk-SHCTEXNH.js} +2 -2
  149. package/dist/cli/chunks/chunk-SNTUKW4Q.js +2 -0
  150. package/dist/cli/chunks/{chunk-F3CKOVZM.js → chunk-SRQ3CPJE.js} +6 -6
  151. package/dist/cli/chunks/{chunk-V2QYW5KW.js → chunk-THBTN7XB.js} +2 -2
  152. package/dist/cli/chunks/{chunk-6FBXYS6X.js → chunk-TNRIGQ6U.js} +2 -2
  153. package/dist/cli/chunks/{chunk-UF3YOGHV.js → chunk-TVMFH5N2.js} +2 -2
  154. package/dist/cli/chunks/{chunk-FUBN5GPY.js → chunk-TZ73SXQ5.js} +1 -1
  155. package/dist/cli/chunks/chunk-TZPKTRJB.js +9 -0
  156. package/dist/cli/chunks/{chunk-IKIKIHFQ.js → chunk-U2SW6KK5.js} +2 -2
  157. package/dist/cli/chunks/{chunk-ZHWXI4SK.js → chunk-UIPPJKON.js} +2 -2
  158. package/dist/cli/chunks/{chunk-MNHGBG4D.js → chunk-UMG5URNV.js} +1 -1
  159. package/dist/cli/chunks/{chunk-YYV3FYVB.js → chunk-UNIBND6A.js} +1 -1
  160. package/dist/cli/chunks/{chunk-HH5Y4NCR.js → chunk-USMDIIHY.js} +2 -2
  161. package/dist/cli/chunks/{chunk-TLYZPOA7.js → chunk-VC6EXDGY.js} +2 -2
  162. package/dist/cli/chunks/{chunk-BMRR3MBR.js → chunk-VHYMSZNF.js} +2 -2
  163. package/dist/cli/chunks/{chunk-SVUWAV6Y.js → chunk-VLBV2VL3.js} +1 -1
  164. package/dist/cli/chunks/{chunk-BDX54WJV.js → chunk-VLNPJAVH.js} +1 -1
  165. package/dist/cli/chunks/{chunk-R554WVIG.js → chunk-VSNRPMAZ.js} +2 -2
  166. package/dist/cli/chunks/{chunk-AL5QT6OX.js → chunk-W5YEIHIO.js} +2 -2
  167. package/dist/cli/chunks/{chunk-NDAJWCXN.js → chunk-WRYT4HTZ.js} +2 -2
  168. package/dist/cli/chunks/{chunk-PSA2SOON.js → chunk-XFCWYQHW.js} +2 -2
  169. package/dist/cli/chunks/{chunk-6X65BGGK.js → chunk-XKFE3FLI.js} +2 -2
  170. package/dist/cli/chunks/{chunk-ZF65VOQH.js → chunk-YFGAHNCG.js} +2 -2
  171. package/dist/cli/chunks/{chunk-YSCEUK55.js → chunk-YPTGE5NJ.js} +2 -2
  172. package/dist/cli/chunks/{chunk-YDZIPP3Y.js → chunk-YRQLVGCI.js} +2 -2
  173. package/dist/cli/chunks/{chunk-ERQL3D2O.js → chunk-Z6QCOZ2H.js} +2 -2
  174. package/dist/cli/chunks/{chunk-WYFEVPLO.js → chunk-ZCFZ4USU.js} +1 -1
  175. package/dist/cli/chunks/{chunk-2R7XZ2WP.js → chunk-ZEIG5IQ4.js} +2 -2
  176. package/dist/cli/chunks/{chunk-KJJP446A.js → chunk-ZJG6N2OK.js} +1 -1
  177. package/dist/cli/chunks/{chunk-BUKGW63B.js → chunk-ZJIX5FGQ.js} +3 -3
  178. package/dist/cli/chunks/{chunk-EZ3JVN6S.js → chunk-ZLXBNNNT.js} +2 -2
  179. package/dist/cli/chunks/{chunk-4FHJYJCH.js → chunk-ZOXWASCC.js} +2 -2
  180. package/dist/cli/chunks/{ci-NT4DUGQ4.js → ci-74ZUCO5V.js} +2 -2
  181. package/dist/cli/chunks/{ci-output-PXBD2QPH.js → ci-output-HD6IZNJA.js} +2 -2
  182. package/dist/cli/chunks/{circuit-breaker-ZPCCEEDX.js → circuit-breaker-USZVMA42.js} +2 -2
  183. package/dist/cli/chunks/{claude-flow-setup-CZCDFZOE.js → claude-flow-setup-S4XKNCD5.js} +2 -2
  184. package/dist/cli/chunks/client-33PGO5FA.js +2 -0
  185. package/dist/cli/chunks/{cline-installer-6J2S7GLM.js → cline-installer-6EW4CHAR.js} +2 -2
  186. package/dist/cli/chunks/{code-UTERK5AP.js → code-TOLWD2XL.js} +2 -2
  187. package/dist/cli/chunks/{code-index-extractor-O3MJTOS2.js → code-index-extractor-UA4QQ7B3.js} +2 -2
  188. package/dist/cli/chunks/{codex-installer-AZJIVXJR.js → codex-installer-C2CUP4FW.js} +2 -2
  189. package/dist/cli/chunks/{completions-A6ANQSZN.js → completions-KVUMQQ4K.js} +2 -2
  190. package/dist/cli/chunks/{complexity-analyzer-MRSN7VUP.js → complexity-analyzer-DFH6LMK2.js} +2 -2
  191. package/dist/cli/chunks/{continuedev-installer-6LMKQRUI.js → continuedev-installer-LYDQSAU7.js} +2 -2
  192. package/dist/cli/chunks/{copilot-installer-KP3TWUNO.js → copilot-installer-7USXLZHZ.js} +2 -2
  193. package/dist/cli/chunks/core-handlers-CSNZIM3A.js +2 -0
  194. package/dist/cli/chunks/{cost-tracker-R3C5IQPZ.js → cost-tracker-JBDIUMKZ.js} +2 -2
  195. package/dist/cli/chunks/{coverage-MR4QA2NM.js → coverage-RGO3K357.js} +3 -3
  196. package/dist/cli/chunks/cross-domain-router-DRIBR5L3.js +2 -0
  197. package/dist/cli/chunks/{cursor-installer-LPZ7NGOS.js → cursor-installer-YEZGD37F.js} +2 -2
  198. package/dist/cli/chunks/{daemon-X5KXHRY3.js → daemon-FVETQ3LL.js} +3 -3
  199. package/dist/cli/chunks/{daemon-K3KW2UDV.js → daemon-LPEXHNYG.js} +4 -4
  200. package/dist/cli/chunks/{dag-attention-scheduler-J4FJSGNN.js → dag-attention-scheduler-UKYE2FII.js} +2 -2
  201. package/dist/cli/chunks/{detect-22TX2NCA.js → detect-WBG5P7ER.js} +2 -2
  202. package/dist/cli/chunks/{dist-node-QI4I4QPS.js → dist-node-YW6YRBCU.js} +2 -2
  203. package/dist/cli/chunks/{domain-handler-ZYZGPNOQ.js → domain-handler-HH7J4A32.js} +2 -2
  204. package/dist/cli/chunks/{domain-transfer-2EEQTNIU.js → domain-transfer-V34GXD5I.js} +2 -2
  205. package/dist/cli/chunks/dream-WUNO723O.js +2 -0
  206. package/dist/cli/chunks/{embed-and-insert-pattern-LYCTU5BS.js → embed-and-insert-pattern-WYLRS3CL.js} +2 -2
  207. package/dist/cli/chunks/{eval-SOA72GUX.js → eval-EIMVXY5J.js} +2 -2
  208. package/dist/cli/chunks/{experience-capture-middleware-AFFYOMYM.js → experience-capture-middleware-QMZHRUKM.js} +3 -3
  209. package/dist/cli/chunks/{fast-paths-WNMHOSUH.js → fast-paths-NHLW6XS6.js} +2 -2
  210. package/dist/cli/chunks/{feature-flags-HAP5IAAY.js → feature-flags-N3UHMSZ3.js} +2 -2
  211. package/dist/cli/chunks/{feature-flags-FT4YBZH4.js → feature-flags-NE3MBL3P.js} +2 -2
  212. package/dist/cli/chunks/{file-discovery-B4FFOH3Z.js → file-discovery-SI44X4YS.js} +2 -2
  213. package/dist/cli/chunks/{fleet-2ICPYV3J.js → fleet-MMYUXRRM.js} +3 -3
  214. package/dist/cli/chunks/{gnn-wrapper-XIBJAHMW.js → gnn-wrapper-RLYXYU2Q.js} +2 -2
  215. package/dist/cli/chunks/{heartbeat-handler-NSLSKDOI.js → heartbeat-handler-6EDRUYLV.js} +4 -4
  216. package/dist/cli/chunks/heartbeat-scheduler-VAFQDJLL.js +2 -0
  217. package/dist/cli/chunks/hnsw-adapter-TIRPA7XE.js +2 -0
  218. package/dist/cli/chunks/hnsw-index-SSQBRQCQ.js +2 -0
  219. package/dist/cli/chunks/{hnsw-legacy-bridge-FTV4CCBB.js → hnsw-legacy-bridge-RVM7EAIH.js} +2 -2
  220. package/dist/cli/chunks/{better-sqlite3-RQCOOAZC.js → hnswlib-node-RJPBJU2Q.js} +2 -2
  221. package/dist/cli/chunks/{hooks-SM4EU52N.js → hooks-ZF4VKHEO.js} +10 -10
  222. package/dist/cli/chunks/hybrid-router-AKBWZOQ3.js +2 -0
  223. package/dist/cli/chunks/{hypergraph-engine-RRMX4N3L.js → hypergraph-engine-YWS66PGO.js} +2 -2
  224. package/dist/cli/chunks/{hypergraph-handler-MNFGDKAP.js → hypergraph-handler-OQHVRPWB.js} +3 -3
  225. package/dist/cli/chunks/impact-analyzer-46FQIZ6Y.js +2 -0
  226. package/dist/cli/chunks/{init-handler-BNHIJ5TX.js → init-handler-YW74YF2V.js} +6 -6
  227. package/dist/cli/chunks/init-wizard-U3NHGYSS.js +2 -0
  228. package/dist/cli/chunks/kernel-ZDXHT6QF.js +2 -0
  229. package/dist/cli/chunks/{kilocode-installer-GFKUKPLY.js → kilocode-installer-APWB2GMA.js} +2 -2
  230. package/dist/cli/chunks/{kiro-installer-YBIYKODN.js → kiro-installer-DICKFVNC.js} +2 -2
  231. package/dist/cli/chunks/knowledge-graph-6XTW6WO6.js +2 -0
  232. package/dist/cli/chunks/{learning-QEWUPCK6.js → learning-MXHNYW5D.js} +3 -3
  233. package/dist/cli/chunks/{llm-router-D5FQIMVQ.js → llm-router-LTFIX7NY.js} +5 -5
  234. package/dist/cli/chunks/llm-router-service-3F4E64SY.js +2 -0
  235. package/dist/cli/chunks/{load-CLBUCKZQ.js → load-JUMIQ4LZ.js} +2 -2
  236. package/dist/cli/chunks/load-test-SWZNGEIY.js +2 -0
  237. package/dist/cli/chunks/{mcp-VOMG5DPV.js → mcp-WHIARJGO.js} +2 -2
  238. package/dist/cli/chunks/{memory-WZO63VSC.js → memory-KAHS6Z5A.js} +5 -5
  239. package/dist/cli/chunks/memory-backend-PR74ZPBA.js +2 -0
  240. package/dist/cli/chunks/memory-handlers-DG3RRXB6.js +2 -0
  241. package/dist/cli/chunks/{multi-model-executor-7UKW43VV.js → multi-model-executor-E3Y2RHMX.js} +2 -2
  242. package/dist/cli/chunks/{opencode-installer-MLFPRRL2.js → opencode-installer-3RKGNGGE.js} +2 -2
  243. package/dist/cli/chunks/{orchestrator-XNYDBGIN.js → orchestrator-TXITUKWD.js} +5 -5
  244. package/dist/cli/chunks/pattern-null-store-EPE36BVT.js +2 -0
  245. package/dist/cli/chunks/{pattern-usage-recorder-ZAP7ASQI.js → pattern-usage-recorder-EE2BUFZT.js} +2 -2
  246. package/dist/cli/chunks/{pipeline-4EJYOPBC.js → pipeline-AXTT6KZB.js} +2 -2
  247. package/dist/cli/chunks/{platform-ALPOWCOH.js → platform-TICPVKE2.js} +2 -2
  248. package/dist/cli/chunks/{plugin-S2RX3KHR.js → plugin-VQKNV3EM.js} +2 -2
  249. package/dist/cli/chunks/{prime-radiant-advanced-wasm-P2JB73XX.js → prime-radiant-advanced-wasm-6GY5YY7D.js} +2 -2
  250. package/dist/cli/chunks/protocol-executor-IELENNST.js +2 -0
  251. package/dist/cli/chunks/{protocol-handler-ZBJXSESA.js → protocol-handler-YFWDR7UZ.js} +2 -2
  252. package/dist/cli/chunks/{prove-MYJ5YV45.js → prove-FUMRCXAA.js} +2 -2
  253. package/dist/cli/chunks/provider-manager-3R3KOBHG.js +2 -0
  254. package/dist/cli/chunks/qe-reasoning-bank-S2R2PCBS.js +2 -0
  255. package/dist/cli/chunks/{quality-NIACQC4M.js → quality-2APISBW5.js} +2 -2
  256. package/dist/cli/chunks/{quality-gate-OAZ23ON5.js → quality-gate-MCC3E5TM.js} +3 -3
  257. package/dist/cli/chunks/queen-coordinator-2E23NEV4.js +2 -0
  258. package/dist/cli/chunks/{real-embeddings-6I4LP7PL.js → real-embeddings-CC5TNOTI.js} +2 -2
  259. package/dist/cli/chunks/{roocode-installer-LRQHP6MK.js → roocode-installer-YAHTEVPI.js} +2 -2
  260. package/dist/cli/chunks/router-3FVLWO6S.js +2 -0
  261. package/dist/cli/chunks/routing-feedback-ZQLRNNR7.js +2 -0
  262. package/dist/cli/chunks/{routing-handler-A7BW7MV4.js → routing-handler-6NQBW4TQ.js} +2 -2
  263. package/dist/cli/chunks/{ruvector-commands-ZDRRFSJS.js → ruvector-commands-ZHXLHUPG.js} +2 -2
  264. package/dist/cli/chunks/{rvf-dual-writer-QWE3Z6BB.js → rvf-dual-writer-5KF2DGCW.js} +2 -2
  265. package/dist/cli/chunks/{rvf-migration-adapter-6UDAP7QB.js → rvf-migration-adapter-BBU57BGF.js} +2 -2
  266. package/dist/cli/chunks/{rvf-migration-coordinator-FEW2N4R4.js → rvf-migration-coordinator-VN4VRZA4.js} +2 -2
  267. package/dist/cli/chunks/rvf-native-adapter-YFGLQNEB.js +2 -0
  268. package/dist/cli/chunks/rvf-store-integrity-XCY2XQZA.js +2 -0
  269. package/dist/cli/chunks/safe-db-4SBLBTW7.js +2 -0
  270. package/dist/cli/chunks/schedule-5Y3BGVAA.js +2 -0
  271. package/dist/cli/chunks/scheduler-DOID3QF3.js +2 -0
  272. package/dist/cli/chunks/{security-KFXBV65O.js → security-PYP4H3KN.js} +3 -3
  273. package/dist/cli/chunks/shared-rvf-adapter-3CJHRNX6.js +2 -0
  274. package/dist/cli/chunks/{shared-rvf-dual-writer-CXXTB7CU.js → shared-rvf-dual-writer-MKSLKWDI.js} +2 -2
  275. package/dist/cli/chunks/sqlite-persistence-M4JEQO57.js +2 -0
  276. package/dist/cli/chunks/{status-handler-CXSVM236.js → status-handler-VYIZ3VJF.js} +2 -2
  277. package/dist/cli/chunks/{structural-health-LMHSM7MJ.js → structural-health-MVV4OWXP.js} +2 -2
  278. package/dist/cli/chunks/{sync-DMOUY2EY.js → sync-G47OYIQ3.js} +2 -2
  279. package/dist/cli/chunks/sync-VNX6L3TI.js +2 -0
  280. package/dist/cli/chunks/{task-handler-DMSNFIH3.js → task-handler-GOWF2GEH.js} +2 -2
  281. package/dist/cli/chunks/{task-handlers-3Z3QV7X7.js → task-handlers-J2WC6J37.js} +3 -3
  282. package/dist/cli/chunks/{test-U6CGMDLN.js → test-DMCJ3BXS.js} +4 -4
  283. package/dist/cli/chunks/{test-scheduling-YHYA3BP5.js → test-scheduling-TRFHHKFM.js} +3 -3
  284. package/dist/cli/chunks/token-bootstrap-KEQ7AHFF.js +2 -0
  285. package/dist/cli/chunks/{token-usage-EOOTM7Q3.js → token-usage-B54FOFOF.js} +2 -2
  286. package/dist/cli/chunks/transformers-IACZG7IV.js +2 -0
  287. package/dist/cli/chunks/{tree-sitter-wasm-parser-HTGAXDQA.js → tree-sitter-wasm-parser-N7H4X37E.js} +2 -2
  288. package/dist/cli/chunks/{types-GLRXY4RY.js → types-B3SHT4OD.js} +2 -2
  289. package/dist/cli/chunks/unified-memory-WNYWTGVX.js +2 -0
  290. package/dist/cli/chunks/unified-memory-hnsw-YPAV7U4E.js +2 -0
  291. package/dist/cli/chunks/unified-persistence-TJ252S7L.js +2 -0
  292. package/dist/cli/chunks/{upgrade-KU55H77X.js → upgrade-A2PQ5EWK.js} +2 -2
  293. package/dist/cli/chunks/{validate-26VSBOJN.js → validate-UXV7UQUT.js} +2 -2
  294. package/dist/cli/chunks/{validate-swarm-OIALRDKF.js → validate-swarm-MMBU4FPP.js} +2 -2
  295. package/dist/cli/chunks/{vibium-LOTWW25P.js → vibium-R4GUVADA.js} +2 -2
  296. package/dist/cli/chunks/visual-security-VKYXEGJB.js +2 -0
  297. package/dist/cli/chunks/{web-tree-sitter-6LWPPBYU.js → web-tree-sitter-MP6E6CJB.js} +2 -2
  298. package/dist/cli/chunks/{windsurf-installer-ILOQYENG.js → windsurf-installer-Z6BWMUUO.js} +2 -2
  299. package/dist/cli/chunks/{witness-chain-YBS6OHS4.js → witness-chain-EFLTABBA.js} +2 -2
  300. package/dist/cli/chunks/witness-chain-WVXRXKQP.js +2 -0
  301. package/dist/cli/chunks/{witness-key-manager-SI3WV3ZQ.js → witness-key-manager-PN36TV43.js} +2 -2
  302. package/dist/cli/chunks/{workflow-GY6SJRQW.js → workflow-A2AX3RJU.js} +4 -4
  303. package/dist/cli/chunks/workflow-orchestrator-GOWSPR3G.js +2 -0
  304. package/dist/cli/chunks/{wrappers-MMO5YKOZ.js → wrappers-NA6FHA63.js} +2 -2
  305. package/dist/cli/commands/llm-router.js +1 -0
  306. package/dist/init/skills-installer.js +1 -0
  307. package/dist/integrations/embeddings/base/EmbeddingGenerator.js +13 -1
  308. package/dist/integrations/ruvector/brain-rvf-exporter.js +115 -13
  309. package/dist/integrations/ruvector/rvf-dual-writer.js +20 -3
  310. package/dist/integrations/ruvector/rvf-store-integrity.d.ts +49 -0
  311. package/dist/integrations/ruvector/rvf-store-integrity.js +137 -0
  312. package/dist/integrations/ruvector/shared-rvf-adapter.js +23 -5
  313. package/dist/kernel/unified-memory.js +4 -0
  314. package/dist/learning/pattern-store.js +23 -5
  315. package/dist/learning/qe-flywheel/corpus-scorer.js +10 -7
  316. package/dist/learning/qe-flywheel/generation.d.ts +7 -0
  317. package/dist/learning/qe-flywheel/generation.js +5 -0
  318. package/dist/learning/qe-flywheel/platform-signer.d.ts +32 -0
  319. package/dist/learning/qe-flywheel/platform-signer.js +60 -0
  320. package/dist/learning/qe-flywheel/receipt.js +9 -2
  321. package/dist/learning/qe-flywheel/witness-verify.d.ts +86 -0
  322. package/dist/learning/qe-flywheel/witness-verify.js +156 -0
  323. package/dist/mcp/bundle.js +398 -387
  324. package/dist/shared/db-recovery.d.ts +55 -0
  325. package/dist/shared/db-recovery.js +184 -0
  326. package/dist/shared/llm/billing-modes.js +5 -2
  327. package/dist/shared/llm/cost-tracker.js +1 -0
  328. package/dist/shared/llm/interfaces.d.ts +14 -1
  329. package/dist/shared/llm/provider-manager.d.ts +1 -1
  330. package/dist/shared/llm/provider-manager.js +7 -3
  331. package/dist/shared/llm/providers/claude-code.js +12 -3
  332. package/dist/shared/llm/providers/codex.d.ts +58 -0
  333. package/dist/shared/llm/providers/codex.js +305 -0
  334. package/dist/shared/llm/providers/index.d.ts +1 -0
  335. package/dist/shared/llm/providers/index.js +1 -0
  336. package/dist/shared/llm/router/config-store.js +5 -0
  337. package/dist/shared/llm/router/hybrid-router.js +2 -2
  338. package/dist/shared/llm/spend-ledger.d.ts +24 -0
  339. package/dist/shared/llm/spend-ledger.js +86 -15
  340. package/dist/shared/llm/translation/message-formatter.js +1 -0
  341. package/dist/shared/safe-db.d.ts +10 -0
  342. package/dist/shared/safe-db.js +17 -0
  343. package/dist/skills/qe-court/referee.d.ts +62 -0
  344. package/dist/skills/qe-court/referee.js +78 -0
  345. package/dist/validation/gate-reexecute.d.ts +9 -0
  346. package/dist/validation/gate-reexecute.js +61 -0
  347. package/dist/validation/paired-bootstrap.d.ts +36 -0
  348. package/dist/validation/paired-bootstrap.js +58 -0
  349. package/package.json +8 -4
  350. package/dist/cli/chunks/adapter-RL6GNUOS.js +0 -2
  351. package/dist/cli/chunks/aqe-learning-engine-UEEW6AQG.js +0 -2
  352. package/dist/cli/chunks/base-JQA5YULE.js +0 -2
  353. package/dist/cli/chunks/brain-handler-T7RDPKNM.js +0 -89
  354. package/dist/cli/chunks/browser-workflow-XTKUHTIT.js +0 -2
  355. package/dist/cli/chunks/chunk-ABHKXMOJ.js +0 -2
  356. package/dist/cli/chunks/chunk-CDMAVNV5.js +0 -2
  357. package/dist/cli/chunks/chunk-CQKEVUMO.js +0 -153
  358. package/dist/cli/chunks/chunk-KPV4N4KT.js +0 -9
  359. package/dist/cli/chunks/chunk-MALFTRCT.js +0 -29
  360. package/dist/cli/chunks/chunk-T75VH6NT.js +0 -2
  361. package/dist/cli/chunks/chunk-VM6VBRRU.js +0 -43
  362. package/dist/cli/chunks/chunk-WRMUQVKY.js +0 -2
  363. package/dist/cli/chunks/chunk-YY4KXDI6.js +0 -2
  364. package/dist/cli/chunks/client-S7DIRNFJ.js +0 -2
  365. package/dist/cli/chunks/core-handlers-NM2KCI6Z.js +0 -2
  366. package/dist/cli/chunks/cross-domain-router-3TSZMCBM.js +0 -2
  367. package/dist/cli/chunks/dream-QIIJONYI.js +0 -2
  368. package/dist/cli/chunks/heartbeat-scheduler-CDNGLJJO.js +0 -2
  369. package/dist/cli/chunks/hnsw-adapter-CR7Y4OAM.js +0 -2
  370. package/dist/cli/chunks/hnsw-index-TEDO4MQC.js +0 -2
  371. package/dist/cli/chunks/hybrid-router-O24ZDIP5.js +0 -2
  372. package/dist/cli/chunks/impact-analyzer-PDM4SDB6.js +0 -2
  373. package/dist/cli/chunks/init-wizard-F4KODPNW.js +0 -2
  374. package/dist/cli/chunks/kernel-77UM35L6.js +0 -2
  375. package/dist/cli/chunks/knowledge-graph-R6ZWWV2K.js +0 -2
  376. package/dist/cli/chunks/llm-router-service-7QYCZ66H.js +0 -2
  377. package/dist/cli/chunks/load-test-AWVA3CAQ.js +0 -2
  378. package/dist/cli/chunks/memory-backend-YESSIHFW.js +0 -2
  379. package/dist/cli/chunks/memory-handlers-EOOWSUHI.js +0 -2
  380. package/dist/cli/chunks/pattern-null-store-X3UXLJNL.js +0 -2
  381. package/dist/cli/chunks/protocol-executor-KXDCTMWI.js +0 -2
  382. package/dist/cli/chunks/provider-manager-XJZVHYI6.js +0 -2
  383. package/dist/cli/chunks/qe-reasoning-bank-DPHPNIC6.js +0 -2
  384. package/dist/cli/chunks/queen-coordinator-EVGWME5C.js +0 -2
  385. package/dist/cli/chunks/router-R2N7TMAS.js +0 -2
  386. package/dist/cli/chunks/routing-feedback-G6W3H26L.js +0 -2
  387. package/dist/cli/chunks/rvf-native-adapter-D7R2GWXK.js +0 -2
  388. package/dist/cli/chunks/safe-db-CQZGF2KA.js +0 -2
  389. package/dist/cli/chunks/schedule-UP7E3LRC.js +0 -2
  390. package/dist/cli/chunks/scheduler-ENIZHYSL.js +0 -2
  391. package/dist/cli/chunks/shared-rvf-adapter-HDDCXCHY.js +0 -2
  392. package/dist/cli/chunks/sqlite-persistence-CEVJVWS5.js +0 -2
  393. package/dist/cli/chunks/sync-REEFKICL.js +0 -2
  394. package/dist/cli/chunks/token-bootstrap-MQCTJURQ.js +0 -2
  395. package/dist/cli/chunks/transformers-EKDJW2H6.js +0 -2
  396. package/dist/cli/chunks/unified-memory-PXOQ4N53.js +0 -2
  397. package/dist/cli/chunks/unified-memory-hnsw-VEXD6ASE.js +0 -2
  398. package/dist/cli/chunks/unified-persistence-46G6MZYC.js +0 -2
  399. package/dist/cli/chunks/visual-security-4X3T3MFL.js +0 -2
  400. package/dist/cli/chunks/witness-chain-XW4S3LVW.js +0 -2
  401. package/dist/cli/chunks/workflow-orchestrator-IIVV6TCP.js +0 -2
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Auto-restore for the unified `memory.db` (M3.2, inspired by ruflo v3.25.2's
3
+ * backup-auto-restore, adapted to better-sqlite3).
4
+ *
5
+ * Hardened after a qe-court review (ADR-124) surfaced three data-loss risks in
6
+ * the first cut:
7
+ * F3 — `isDbHealthy` via a readonly open + integrity_check FALSE-NEGATIVES a
8
+ * HEALTHY WAL db when `-shm` is zeroed/inaccessible over virtiofs (the
9
+ * exact documented failure mode), which would have parked a good DB and
10
+ * reverted to an older backup. FIX: the live-corruption signal is now the
11
+ * SQLite HEADER — a `-wal`/`-shm` problem does not corrupt the main file,
12
+ * so we only treat a missing/garbage header (zeroed/not-a-db) as corrupt.
13
+ * F2 — non-atomic `copyFileSync` + no lock let concurrent hook processes tear
14
+ * the restored image. FIX: copy to a temp in the same dir → atomic rename,
15
+ * under a best-effort exclusive lock so only one process restores.
16
+ * backup trust — a backup we are about to promote to the LIVE db still gets a
17
+ * FULL `integrity_check` (it is a static file, safe to open readonly).
18
+ *
19
+ * DATA-PROTECTION INVARIANTS (this file must never make things worse):
20
+ * - The corrupt original is RENAMED to `<db>.corrupt-<ts>`, NEVER deleted.
21
+ * - A header-valid main file is treated as HEALTHY — we never park a DB that
22
+ * might just have a transient `-wal`/`-shm` issue (a writable open rebuilds
23
+ * `-shm`). We prefer "manual restore" over "auto-destroy a healthy DB".
24
+ * - A backup is used only if it passes `PRAGMA integrity_check`.
25
+ * - If no verified backup exists, we do NOTHING (leave the DB for inspection).
26
+ */
27
+ /**
28
+ * True if the main DB file is structurally a database (or absent/empty = a fresh
29
+ * DB the caller will create). LIVE-corruption signal only: it deliberately does
30
+ * NOT open the DB or run integrity_check, because a `-wal`/`-shm` fault over
31
+ * virtiofs makes a HEALTHY db unreadable and we must not mistake that for
32
+ * corruption (F3). Only a missing/garbage header — the zeroed/not-a-db case —
33
+ * is "corrupt". A header-valid-but-page-corrupt file is left for MANUAL restore
34
+ * rather than risk auto-parking a healthy DB.
35
+ */
36
+ export declare function isDbHealthy(dbPath: string): boolean;
37
+ export interface RestoreResult {
38
+ restored: boolean;
39
+ reason: 'healthy' | 'no-verified-backup' | 'restored-from-backup' | 'restore-in-progress' | 'park-failed' | 'copy-failed';
40
+ backupUsed?: string;
41
+ parkedTo?: string;
42
+ }
43
+ /** Default verified-backup directory (matches `scripts/aqe-db-backup.sh`). */
44
+ export declare function defaultBackupDir(dbPath: string): string;
45
+ /**
46
+ * If `dbPath`'s main file is unambiguously corrupt (bad SQLite header), park it
47
+ * and atomically restore the newest verified backup. No-op (and non-destructive)
48
+ * when the DB is healthy, when no good backup exists, or when another process is
49
+ * already restoring.
50
+ */
51
+ export declare function attemptAutoRestore(dbPath: string, opts?: {
52
+ backupDir?: string;
53
+ now?: number;
54
+ }): RestoreResult;
55
+ //# sourceMappingURL=db-recovery.d.ts.map
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Auto-restore for the unified `memory.db` (M3.2, inspired by ruflo v3.25.2's
3
+ * backup-auto-restore, adapted to better-sqlite3).
4
+ *
5
+ * Hardened after a qe-court review (ADR-124) surfaced three data-loss risks in
6
+ * the first cut:
7
+ * F3 — `isDbHealthy` via a readonly open + integrity_check FALSE-NEGATIVES a
8
+ * HEALTHY WAL db when `-shm` is zeroed/inaccessible over virtiofs (the
9
+ * exact documented failure mode), which would have parked a good DB and
10
+ * reverted to an older backup. FIX: the live-corruption signal is now the
11
+ * SQLite HEADER — a `-wal`/`-shm` problem does not corrupt the main file,
12
+ * so we only treat a missing/garbage header (zeroed/not-a-db) as corrupt.
13
+ * F2 — non-atomic `copyFileSync` + no lock let concurrent hook processes tear
14
+ * the restored image. FIX: copy to a temp in the same dir → atomic rename,
15
+ * under a best-effort exclusive lock so only one process restores.
16
+ * backup trust — a backup we are about to promote to the LIVE db still gets a
17
+ * FULL `integrity_check` (it is a static file, safe to open readonly).
18
+ *
19
+ * DATA-PROTECTION INVARIANTS (this file must never make things worse):
20
+ * - The corrupt original is RENAMED to `<db>.corrupt-<ts>`, NEVER deleted.
21
+ * - A header-valid main file is treated as HEALTHY — we never park a DB that
22
+ * might just have a transient `-wal`/`-shm` issue (a writable open rebuilds
23
+ * `-shm`). We prefer "manual restore" over "auto-destroy a healthy DB".
24
+ * - A backup is used only if it passes `PRAGMA integrity_check`.
25
+ * - If no verified backup exists, we do NOTHING (leave the DB for inspection).
26
+ */
27
+ import { existsSync, renameSync, copyFileSync, readdirSync, statSync, openSync, readSync, closeSync, writeFileSync, rmSync, } from 'node:fs';
28
+ import { join, dirname } from 'node:path';
29
+ import Database from 'better-sqlite3';
30
+ /** The 16-byte magic every valid SQLite database file starts with. */
31
+ const SQLITE_MAGIC = Buffer.concat([Buffer.from('SQLite format 3', 'latin1'), Buffer.from([0])]);
32
+ /**
33
+ * True if the main DB file is structurally a database (or absent/empty = a fresh
34
+ * DB the caller will create). LIVE-corruption signal only: it deliberately does
35
+ * NOT open the DB or run integrity_check, because a `-wal`/`-shm` fault over
36
+ * virtiofs makes a HEALTHY db unreadable and we must not mistake that for
37
+ * corruption (F3). Only a missing/garbage header — the zeroed/not-a-db case —
38
+ * is "corrupt". A header-valid-but-page-corrupt file is left for MANUAL restore
39
+ * rather than risk auto-parking a healthy DB.
40
+ */
41
+ export function isDbHealthy(dbPath) {
42
+ if (!existsSync(dbPath))
43
+ return true;
44
+ let size;
45
+ try {
46
+ size = statSync(dbPath).size;
47
+ }
48
+ catch {
49
+ return false;
50
+ }
51
+ if (size === 0)
52
+ return true; // freshly-created, not yet written — not corrupt
53
+ if (size < SQLITE_MAGIC.length)
54
+ return false; // too small to be a real db
55
+ let fd;
56
+ try {
57
+ fd = openSync(dbPath, 'r');
58
+ const header = Buffer.alloc(SQLITE_MAGIC.length);
59
+ readSync(fd, header, 0, SQLITE_MAGIC.length, 0);
60
+ return header.equals(SQLITE_MAGIC);
61
+ }
62
+ catch {
63
+ return false;
64
+ }
65
+ finally {
66
+ if (fd !== undefined) {
67
+ try {
68
+ closeSync(fd);
69
+ }
70
+ catch {
71
+ /* ignore */
72
+ }
73
+ }
74
+ }
75
+ }
76
+ /** Full integrity check for a backup we are about to promote to the live DB. */
77
+ function backupIsRestorable(path) {
78
+ let db;
79
+ try {
80
+ db = new Database(path, { readonly: true, fileMustExist: true });
81
+ return db.pragma('integrity_check', { simple: true }) === 'ok';
82
+ }
83
+ catch {
84
+ return false;
85
+ }
86
+ finally {
87
+ try {
88
+ db?.close();
89
+ }
90
+ catch {
91
+ /* ignore */
92
+ }
93
+ }
94
+ }
95
+ /** Default verified-backup directory (matches `scripts/aqe-db-backup.sh`). */
96
+ export function defaultBackupDir(dbPath) {
97
+ return join(dirname(dbPath), 'backups', 'verified');
98
+ }
99
+ /** Newest `memory-*.db` in the backup dir that passes a full integrity_check, or null. */
100
+ function newestVerifiedBackup(backupDir) {
101
+ if (!existsSync(backupDir))
102
+ return null;
103
+ const candidates = readdirSync(backupDir)
104
+ .filter((f) => f.startsWith('memory-') && f.endsWith('.db'))
105
+ .map((f) => {
106
+ const path = join(backupDir, f);
107
+ return { path, mtime: statSync(path).mtimeMs };
108
+ })
109
+ .sort((a, b) => b.mtime - a.mtime);
110
+ for (const c of candidates) {
111
+ if (backupIsRestorable(c.path))
112
+ return c.path;
113
+ }
114
+ return null;
115
+ }
116
+ /**
117
+ * If `dbPath`'s main file is unambiguously corrupt (bad SQLite header), park it
118
+ * and atomically restore the newest verified backup. No-op (and non-destructive)
119
+ * when the DB is healthy, when no good backup exists, or when another process is
120
+ * already restoring.
121
+ */
122
+ export function attemptAutoRestore(dbPath, opts) {
123
+ if (isDbHealthy(dbPath))
124
+ return { restored: false, reason: 'healthy' };
125
+ const backupDir = opts?.backupDir ?? defaultBackupDir(dbPath);
126
+ const good = newestVerifiedBackup(backupDir);
127
+ if (!good)
128
+ return { restored: false, reason: 'no-verified-backup' };
129
+ // F2: best-effort exclusive lock so concurrent processes don't both restore.
130
+ const lockPath = `${dbPath}.restore.lock`;
131
+ try {
132
+ writeFileSync(lockPath, String(process.pid), { flag: 'wx' });
133
+ }
134
+ catch {
135
+ return { restored: false, reason: 'restore-in-progress' };
136
+ }
137
+ try {
138
+ // Re-check under the lock: a peer may have just restored a healthy DB.
139
+ if (isDbHealthy(dbPath))
140
+ return { restored: false, reason: 'healthy' };
141
+ const ts = opts?.now ?? Date.now();
142
+ const parked = `${dbPath}.corrupt-${ts}`;
143
+ // Park the corrupt original + any stale WAL/shm. NEVER delete.
144
+ try {
145
+ if (existsSync(dbPath))
146
+ renameSync(dbPath, parked);
147
+ for (const suffix of ['-wal', '-shm']) {
148
+ if (existsSync(dbPath + suffix))
149
+ renameSync(dbPath + suffix, parked + suffix);
150
+ }
151
+ }
152
+ catch {
153
+ return { restored: false, reason: 'park-failed' };
154
+ }
155
+ // F2: restore atomically — copy to a temp on the same filesystem, then rename.
156
+ const tmp = `${dbPath}.restoring-${ts}`;
157
+ try {
158
+ copyFileSync(good, tmp);
159
+ renameSync(tmp, dbPath); // atomic on the same fs
160
+ }
161
+ catch {
162
+ try {
163
+ if (existsSync(tmp))
164
+ rmSync(tmp, { force: true });
165
+ if (!existsSync(dbPath) && existsSync(parked))
166
+ renameSync(parked, dbPath);
167
+ }
168
+ catch {
169
+ /* leave parked copy for manual recovery */
170
+ }
171
+ return { restored: false, reason: 'copy-failed' };
172
+ }
173
+ return { restored: true, reason: 'restored-from-backup', backupUsed: good, parkedTo: parked };
174
+ }
175
+ finally {
176
+ try {
177
+ rmSync(lockPath, { force: true });
178
+ }
179
+ catch {
180
+ /* ignore */
181
+ }
182
+ }
183
+ }
184
+ //# sourceMappingURL=db-recovery.js.map
@@ -10,6 +10,7 @@
10
10
  const BILLING_MODE_BY_TYPE = {
11
11
  claude: 'metered-api',
12
12
  'claude-code': 'subscription',
13
+ codex: 'subscription',
13
14
  openai: 'metered-api',
14
15
  openrouter: 'metered-api',
15
16
  gemini: 'metered-api',
@@ -45,10 +46,12 @@ export function billingNotice(provider, mode) {
45
46
  case 'metered-capped':
46
47
  return (`ℹ️ LLM provider "${provider}" bills per-token but enforces a server-side ` +
47
48
  `hard spend cap; it will pause at the cap rather than overspend.`);
48
- case 'subscription':
49
- return (`ℹ️ LLM provider "${provider}" runs on your Claude Code subscription ` +
49
+ case 'subscription': {
50
+ const sub = provider === 'codex' ? 'ChatGPT' : 'Claude Code';
51
+ return (`ℹ️ LLM provider "${provider}" runs on your ${sub} subscription ` +
50
52
  `(shared plan usage). Worst case is hitting your plan's rate limit and pausing — ` +
51
53
  `no per-token API charges.`);
54
+ }
52
55
  case 'local':
53
56
  return undefined;
54
57
  }
@@ -177,6 +177,7 @@ export class CostTracker {
177
177
  const byProvider = {
178
178
  claude: 0,
179
179
  'claude-code': 0,
180
+ codex: 0,
180
181
  openai: 0,
181
182
  ollama: 0,
182
183
  openrouter: 0,
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * Supported LLM provider types
13
13
  */
14
- export type LLMProviderType = 'claude' | 'claude-code' | 'openai' | 'ollama' | 'openrouter' | 'bedrock' | 'azure-openai' | 'gemini' | 'cognitum';
14
+ export type LLMProviderType = 'claude' | 'claude-code' | 'codex' | 'openai' | 'ollama' | 'openrouter' | 'bedrock' | 'azure-openai' | 'gemini' | 'cognitum';
15
15
  /**
16
16
  * Message role in a conversation
17
17
  */
@@ -273,6 +273,18 @@ export interface ClaudeCodeConfig extends LLMConfig {
273
273
  /** Tools to disallow in the headless session (safety). */
274
274
  disallowedTools?: string[];
275
275
  }
276
+ /**
277
+ * Codex CLI (subscription) provider configuration (ADR-123 / ADR-124 M3.5).
278
+ * Runs on the user's ChatGPT subscription by shelling out to `codex exec`,
279
+ * mirroring the claude-code provider. Gives AQE a cross-vendor (GPT-family)
280
+ * engine for provider fallback and qe-court prosecutor/juror diversity.
281
+ */
282
+ export interface CodexConfig extends LLMConfig {
283
+ /** Path to the `codex` binary (default: 'codex' on PATH). */
284
+ binaryPath?: string;
285
+ /** Max concurrent `codex exec` subprocesses. */
286
+ maxConcurrency?: number;
287
+ }
276
288
  /**
277
289
  * Cognitum provider configuration (ADR-123). OpenAI-compatible gateway with
278
290
  * per-request cost receipts and a server-side hard spend cap.
@@ -294,6 +306,7 @@ export interface ProviderManagerConfig {
294
306
  providers: {
295
307
  claude?: ClaudeConfig;
296
308
  'claude-code'?: ClaudeCodeConfig;
309
+ codex?: CodexConfig;
297
310
  openai?: OpenAIConfig;
298
311
  ollama?: OllamaConfig;
299
312
  openrouter?: OpenRouterConfig;
@@ -70,7 +70,7 @@ export declare class ProviderManager {
70
70
  */
71
71
  assertWithinBudget(input: string | Message[], options?: GenerateOptions | CompleteOptions): void;
72
72
  /** ADR-123: public spend recorder for those same bypassing callers. */
73
- recordResponseSpend(response: LLMResponse): void;
73
+ recordResponseSpend(response: LLMResponse, agent?: string): void;
74
74
  /**
75
75
  * Generate text using the best available provider
76
76
  */
@@ -18,6 +18,7 @@ import { createDefaultSpendLedger, InMemorySpendLedger, } from './spend-ledger';
18
18
  import { resolveBillingMode, billingNotice } from './billing-modes';
19
19
  import { ClaudeProvider } from './providers/claude';
20
20
  import { ClaudeCodeProvider } from './providers/claude-code';
21
+ import { CodexProvider } from './providers/codex';
21
22
  import { CognitumProvider } from './providers/cognitum';
22
23
  import { OpenAIProvider } from './providers/openai';
23
24
  import { OllamaProvider } from './providers/ollama';
@@ -169,7 +170,7 @@ export class ProviderManager {
169
170
  }
170
171
  }
171
172
  /** ADR-123: persist a completed charge to the cross-process ledger. */
172
- recordSpend(response) {
173
+ recordSpend(response, agent) {
173
174
  if (!this.spendLedger)
174
175
  return;
175
176
  this.spendLedger.record({
@@ -180,6 +181,7 @@ export class ProviderManager {
180
181
  promptTokens: response.usage.promptTokens,
181
182
  completionTokens: response.usage.completionTokens,
182
183
  requestId: response.requestId,
184
+ agent, // ADR-124 M2.3: per-agent attribution when the caller has context.
183
185
  });
184
186
  }
185
187
  /**
@@ -192,8 +194,8 @@ export class ProviderManager {
192
194
  this.enforceBudget(input, options);
193
195
  }
194
196
  /** ADR-123: public spend recorder for those same bypassing callers. */
195
- recordResponseSpend(response) {
196
- this.recordSpend(response);
197
+ recordResponseSpend(response, agent) {
198
+ this.recordSpend(response, agent);
197
199
  }
198
200
  /**
199
201
  * Generate text using the best available provider
@@ -417,6 +419,8 @@ export class ProviderManager {
417
419
  return new ClaudeProvider(this.config.providers.claude);
418
420
  case 'claude-code':
419
421
  return new ClaudeCodeProvider(this.config.providers['claude-code']);
422
+ case 'codex':
423
+ return new CodexProvider(this.config.providers.codex);
420
424
  case 'cognitum':
421
425
  return new CognitumProvider(this.config.providers.cognitum);
422
426
  case 'openai':
@@ -285,10 +285,19 @@ export class ClaudeCodeProvider {
285
285
  clearTimeout(timer);
286
286
  resolve({ code: code ?? 0, stdout, stderr });
287
287
  });
288
- if (stdin !== undefined) {
289
- child.stdin.write(stdin);
288
+ // EPIPE guard (qe-court finding): if `claude` exits before reading stdin,
289
+ // an unhandled 'error' on the stdin stream crashes the calling process. The
290
+ // 'close'/'error' handlers above already capture the real outcome.
291
+ child.stdin.on('error', () => { });
292
+ try {
293
+ if (stdin !== undefined) {
294
+ child.stdin.write(stdin);
295
+ }
296
+ child.stdin.end();
297
+ }
298
+ catch {
299
+ /* stream already torn down — process handlers report the failure */
290
300
  }
291
- child.stdin.end();
292
301
  });
293
302
  }
294
303
  /** Simple semaphore so we don't spawn unbounded `claude` subprocesses. */
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Agentic QE v3 — Codex CLI (subscription) Provider (ADR-123 / ADR-124 M3.5)
3
+ *
4
+ * Runs QE analysis on the user's ChatGPT subscription by shelling out to the
5
+ * Codex CLI (`codex exec`) instead of calling the OpenAI API with a paid key.
6
+ * The CLI authenticates with the user's existing ChatGPT login (~/.codex/auth.json)
7
+ * and draws from the subscription allowance, so the worst case is "hit the plan
8
+ * limit and pause" rather than a per-token bill. Mirrors the claude-code provider.
9
+ *
10
+ * WHY: gives AQE a cross-vendor (GPT-family) engine — used as a provider fallback
11
+ * and, crucially, as an independent prosecutor/juror in qe-court (ADR-124), where
12
+ * a non-Claude, non-Cognitum brain is the strongest form of writer≠juror.
13
+ *
14
+ * LOAD-BEARING: the child process env has OPENAI_API_KEY / CODEX_API_KEY stripped.
15
+ * If present, the CLI could revert to API-key billing and this provider would be
16
+ * a lie. `parity` test coverage asserts the strip.
17
+ */
18
+ import { LLMProvider, LLMProviderType, BillingMode, CodexConfig, Message, GenerateOptions, EmbedOptions, CompleteOptions, LLMResponse, EmbeddingResponse, CompletionResponse, HealthCheckResult } from '../interfaces';
19
+ export type { CodexConfig };
20
+ /** Env vars whose presence could flip the CLI from subscription to API billing. */
21
+ export declare const API_BILLING_ENV_VARS: readonly ["OPENAI_API_KEY", "CODEX_API_KEY"];
22
+ /** Sentinel meaning "let Codex use its own configured default model". */
23
+ export declare const CODEX_DEFAULT_MODEL = "default";
24
+ export declare const DEFAULT_CODEX_CONFIG: CodexConfig;
25
+ export declare class CodexProvider implements LLMProvider {
26
+ readonly type: LLMProviderType;
27
+ readonly name: string;
28
+ readonly billingMode: BillingMode;
29
+ private config;
30
+ private requestId;
31
+ private availabilityCache?;
32
+ private active;
33
+ private readonly queue;
34
+ constructor(config?: Partial<CodexConfig>);
35
+ isAvailable(): Promise<boolean>;
36
+ healthCheck(): Promise<HealthCheckResult>;
37
+ generate(input: string | Message[], options?: GenerateOptions): Promise<LLMResponse>;
38
+ embed(_text: string, _options?: EmbedOptions): Promise<EmbeddingResponse>;
39
+ complete(prompt: string, options?: CompleteOptions): Promise<CompletionResponse>;
40
+ getConfig(): CodexConfig;
41
+ getSupportedModels(): string[];
42
+ getCostPerToken(): {
43
+ input: number;
44
+ output: number;
45
+ };
46
+ dispose(): Promise<void>;
47
+ private flatten;
48
+ private classifyError;
49
+ /**
50
+ * Build the child env with API-billing keys stripped (LOAD-BEARING).
51
+ * Exported logic tested by parity/env-strip tests.
52
+ */
53
+ static childEnv(base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
54
+ private runProcess;
55
+ /** Simple semaphore so we don't spawn unbounded `codex` subprocesses. */
56
+ private withConcurrency;
57
+ }
58
+ //# sourceMappingURL=codex.d.ts.map