agentic-qe 3.9.18 → 3.9.20
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.
- package/.claude/helpers/statusline-v3.cjs +1 -1
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +62 -0
- package/assets/skills/skills-manifest.json +1 -1
- package/dist/adapters/claude-flow/trajectory-bridge.d.ts +12 -1
- package/dist/adapters/claude-flow/trajectory-bridge.js +33 -31
- package/dist/cli/bundle.js +5 -5
- package/dist/cli/chunks/adapter-UOX57IAN.js +2 -0
- package/dist/cli/chunks/{agent-booster-wasm-RJHBIG5V.js → agent-booster-wasm-T5JB3MOF.js} +2 -2
- package/dist/cli/chunks/{agent-handler-CXS6EE2V.js → agent-handler-EASMQSQO.js} +2 -2
- package/dist/cli/chunks/{agent-memory-branch-7NV5DD5A.js → agent-memory-branch-7GWN2KCG.js} +2 -2
- package/dist/cli/chunks/aqe-learning-engine-KZES2SKE.js +2 -0
- package/dist/cli/chunks/{audit-3NWGSPJW.js → audit-VHV4GXPW.js} +2 -2
- package/dist/cli/chunks/base-7MXMBRSW.js +2 -0
- package/dist/cli/chunks/{better-sqlite3-NXOMSJDC.js → better-sqlite3-GNK7MDXZ.js} +2 -2
- package/dist/cli/chunks/{brain-handler-6N5WWZVA.js → brain-handler-ALXZKWO4.js} +3 -3
- package/dist/cli/chunks/{branch-enumerator-I7UTOCAW.js → branch-enumerator-JNYLOLMM.js} +2 -2
- package/dist/cli/chunks/{browser-6VOFWA52.js → browser-FXRW6LID.js} +2 -2
- package/dist/cli/chunks/browser-workflow-4C5R54CZ.js +2 -0
- package/dist/cli/chunks/{chunk-BFM47L3X.js → chunk-2J5OO63R.js} +2 -2
- package/dist/cli/chunks/{chunk-7OGUAZGJ.js → chunk-35HDLA22.js} +1 -1
- package/dist/cli/chunks/{chunk-P6HIDCTQ.js → chunk-3BFNYFXV.js} +1 -1
- package/dist/cli/chunks/{chunk-KFITGSW3.js → chunk-3CLKKAGH.js} +2 -2
- package/dist/cli/chunks/{chunk-WC5A7C5L.js → chunk-3GPNZPM4.js} +1 -1
- package/dist/cli/chunks/{chunk-HLXPD4Y2.js → chunk-3HQ4VKK6.js} +79 -67
- package/dist/cli/chunks/{chunk-ENYQUSSK.js → chunk-3ZHUKLU7.js} +2 -2
- package/dist/cli/chunks/{chunk-4BIWQLD3.js → chunk-4G6OH5LQ.js} +2 -2
- package/dist/cli/chunks/{chunk-ODGACHEZ.js → chunk-4HD7YRW7.js} +2 -2
- package/dist/cli/chunks/{chunk-MBGWDELE.js → chunk-4IUNBRKQ.js} +2 -2
- package/dist/cli/chunks/{chunk-S2XBAOXE.js → chunk-4PNLBMKY.js} +1 -1
- package/dist/cli/chunks/{chunk-FTIHPDWV.js → chunk-4SBMTHTA.js} +2 -2
- package/dist/cli/chunks/{chunk-H5JZZH2C.js → chunk-5GA4BUQU.js} +2 -2
- package/dist/cli/chunks/{chunk-AMRUZ6XG.js → chunk-5ILP2ZDZ.js} +2 -2
- package/dist/cli/chunks/{chunk-G2H4W7NN.js → chunk-5LM2W3NE.js} +1 -1
- package/dist/cli/chunks/{chunk-BGSYFAEJ.js → chunk-6LKEFWKI.js} +3 -3
- package/dist/cli/chunks/{chunk-MDCTQOUJ.js → chunk-6R7SJ5FS.js} +1 -1
- package/dist/cli/chunks/{chunk-7XLTLFP5.js → chunk-7I6ROJGF.js} +2 -2
- package/dist/cli/chunks/{chunk-4666TC3P.js → chunk-7J34I3CI.js} +2 -2
- package/dist/cli/chunks/{chunk-6QSB4XOL.js → chunk-7OGFOHG5.js} +2 -2
- package/dist/cli/chunks/{chunk-B6BAK2JI.js → chunk-7Q7SCQMQ.js} +2 -2
- package/dist/cli/chunks/{chunk-X2T4TI7D.js → chunk-7R45TEY6.js} +2 -2
- package/dist/cli/chunks/{chunk-27MW2RFA.js → chunk-7WXYQDML.js} +2 -2
- package/dist/cli/chunks/{chunk-IJPTWPXG.js → chunk-7Y4QQ6JL.js} +1 -1
- package/dist/cli/chunks/{chunk-QGSELG75.js → chunk-AFMLL2G3.js} +2 -2
- package/dist/cli/chunks/{chunk-JBW2A2O6.js → chunk-AVVRA6FG.js} +2 -2
- package/dist/cli/chunks/{chunk-2A4JCRAW.js → chunk-BIODM56C.js} +2 -2
- package/dist/cli/chunks/{chunk-KMHGQD76.js → chunk-BJF77EFA.js} +2 -2
- package/dist/cli/chunks/chunk-BKGCMWFL.js +12 -0
- package/dist/cli/chunks/{chunk-JMK5OCWL.js → chunk-BXGAXGME.js} +2 -2
- package/dist/cli/chunks/{chunk-RPT7HCMH.js → chunk-CEVIRL2S.js} +2 -2
- package/dist/cli/chunks/{chunk-DC3PADV3.js → chunk-CPVGZYEP.js} +1 -1
- package/dist/cli/chunks/chunk-CQSME43Z.js +69 -0
- package/dist/cli/chunks/{chunk-VRHKEJR6.js → chunk-DERQRIAR.js} +3 -3
- package/dist/cli/chunks/{chunk-XBWVHO6G.js → chunk-DJCLA5AG.js} +2 -2
- package/dist/cli/chunks/{chunk-EN2A2CVT.js → chunk-DODH6CEQ.js} +1 -1
- package/dist/cli/chunks/{chunk-4U2JKV44.js → chunk-DSPH4GI3.js} +1 -1
- package/dist/cli/chunks/{chunk-HZKY5KPB.js → chunk-EJQRDMON.js} +1 -1
- package/dist/cli/chunks/{chunk-OXL6JSVR.js → chunk-EYSGJZ7Y.js} +9 -9
- package/dist/cli/chunks/chunk-F32R4LVS.js +2 -0
- package/dist/cli/chunks/{chunk-DCB2VUYM.js → chunk-F3PX6EJX.js} +1 -1
- package/dist/cli/chunks/{chunk-RI3NTZ2I.js → chunk-FAQPPMEC.js} +2 -2
- package/dist/cli/chunks/{chunk-6G3RNT5H.js → chunk-FHDYN73D.js} +2 -2
- package/dist/cli/chunks/{chunk-DQCWNCOT.js → chunk-FPBNTPCM.js} +2 -2
- package/dist/cli/chunks/{chunk-TFUWIKGZ.js → chunk-FUTRX4ZT.js} +2 -2
- package/dist/cli/chunks/{chunk-IS2PMHB5.js → chunk-G7HYTJDG.js} +2 -2
- package/dist/cli/chunks/{chunk-4ELLGWTS.js → chunk-GJACTPDK.js} +2 -2
- package/dist/cli/chunks/{chunk-EZN7QMOZ.js → chunk-GXO42P3X.js} +4 -4
- package/dist/cli/chunks/{chunk-FKNYOKIK.js → chunk-H647PYXW.js} +1 -1
- package/dist/cli/chunks/{chunk-MLVVYUFS.js → chunk-HCFRGEMK.js} +1 -1
- package/dist/cli/chunks/{chunk-DOSDUAVZ.js → chunk-HW47UOFK.js} +2 -2
- package/dist/cli/chunks/{chunk-JGNVI5UB.js → chunk-HXQ7GAUV.js} +3 -3
- package/dist/cli/chunks/{chunk-BRWWIY6O.js → chunk-ICLWWAGZ.js} +2 -2
- package/dist/cli/chunks/{chunk-A26GU6YU.js → chunk-IHBRFVGA.js} +1 -1
- package/dist/cli/chunks/{chunk-ZURHHRSA.js → chunk-J7SDO52P.js} +2 -2
- package/dist/cli/chunks/{chunk-6ZMQL3U6.js → chunk-JCPXG42O.js} +2 -2
- package/dist/cli/chunks/{chunk-BSQTOKNR.js → chunk-K2D5L7YV.js} +1 -1
- package/dist/cli/chunks/{chunk-JZG23IPV.js → chunk-KMDZOVCF.js} +1 -1
- package/dist/cli/chunks/{chunk-VW7FKTFO.js → chunk-KNOZWD6E.js} +2 -2
- package/dist/cli/chunks/{chunk-JZTB35EQ.js → chunk-LATJ2LKJ.js} +1 -1
- package/dist/cli/chunks/{chunk-WMJCFDTA.js → chunk-LGSPAQSP.js} +2 -2
- package/dist/cli/chunks/{chunk-D7SS56EG.js → chunk-LJW7BTMK.js} +2 -2
- package/dist/cli/chunks/{chunk-ZHA5Z5V4.js → chunk-LSYMQG52.js} +1 -1
- package/dist/cli/chunks/{chunk-6KTF7QB3.js → chunk-MIST354H.js} +2 -2
- package/dist/cli/chunks/{chunk-AGPZVE6B.js → chunk-MXAEZHW6.js} +2 -2
- package/dist/cli/chunks/{chunk-6IBFYVLK.js → chunk-MXDGMXJA.js} +2 -2
- package/dist/cli/chunks/{chunk-R3U3ARVJ.js → chunk-MXHJUAM7.js} +2 -2
- package/dist/cli/chunks/{chunk-BXTHB2A2.js → chunk-NGWGOMOP.js} +2 -2
- package/dist/cli/chunks/{chunk-UNPTSPAO.js → chunk-NN6VRHNL.js} +2 -2
- package/dist/cli/chunks/{chunk-LVABI4OA.js → chunk-NQIOXSHW.js} +1 -1
- package/dist/cli/chunks/{chunk-CSYQKVZY.js → chunk-NWYYWFUO.js} +1 -1
- package/dist/cli/chunks/{chunk-CCM7MBLA.js → chunk-O3PLWCCD.js} +2 -2
- package/dist/cli/chunks/{chunk-3DLD7OMF.js → chunk-OD5SVOVP.js} +1 -1
- package/dist/cli/chunks/{chunk-FDDB7QTM.js → chunk-P2ABIGYB.js} +1 -1
- package/dist/cli/chunks/{chunk-QTUTQLOY.js → chunk-Q4OITFDX.js} +2 -2
- package/dist/cli/chunks/{chunk-3GA7M5NK.js → chunk-QAZYSC3T.js} +2 -2
- package/dist/cli/chunks/{chunk-UPP5V7Y3.js → chunk-QCLEA3CM.js} +2 -2
- package/dist/cli/chunks/{chunk-ZWR4PZ4Z.js → chunk-QKOPJ5CZ.js} +2 -2
- package/dist/cli/chunks/{chunk-Z4YHL4JU.js → chunk-QLZPCEVI.js} +1 -1
- package/dist/cli/chunks/{chunk-7GGSUXVM.js → chunk-QMGXALN3.js} +2 -2
- package/dist/cli/chunks/{chunk-SQHM6WUF.js → chunk-QMUZMIV7.js} +3 -3
- package/dist/cli/chunks/{chunk-5SZLQCFP.js → chunk-QQMHE4RT.js} +2 -2
- package/dist/cli/chunks/{chunk-NBQW7MXF.js → chunk-RCPFDAOC.js} +1 -1
- package/dist/cli/chunks/{chunk-JD6KE6DJ.js → chunk-RVWGW7TI.js} +2 -2
- package/dist/cli/chunks/{chunk-ZJEVL5O3.js → chunk-RXXKU3VP.js} +2 -2
- package/dist/cli/chunks/{chunk-AZGESIFV.js → chunk-RYBFRFKY.js} +1 -1
- package/dist/cli/chunks/{chunk-WKQSZTU6.js → chunk-S6SRHNJV.js} +2 -2
- package/dist/cli/chunks/{chunk-BADBKGZE.js → chunk-SGGY4QYU.js} +2 -2
- package/dist/cli/chunks/{chunk-YZIOM7JL.js → chunk-SH2UPGO7.js} +2 -2
- package/dist/cli/chunks/{chunk-PM77Z4PR.js → chunk-SL7WTN5Z.js} +2 -2
- package/dist/cli/chunks/{chunk-KV6PIOHN.js → chunk-SMQ5OARZ.js} +1 -1
- package/dist/cli/chunks/{chunk-YQL6JH2Y.js → chunk-SYXPLFK7.js} +2 -2
- package/dist/cli/chunks/{chunk-6BGSH2YR.js → chunk-T3TEQH2H.js} +1 -1
- package/dist/cli/chunks/{chunk-YNVVRND7.js → chunk-T5MMSSSF.js} +2 -2
- package/dist/cli/chunks/{chunk-BY44ODHD.js → chunk-TG6P44UT.js} +4 -4
- package/dist/cli/chunks/{chunk-TPL3CBMS.js → chunk-TV5OVFKK.js} +1 -1
- package/dist/cli/chunks/{chunk-54TOOHER.js → chunk-U7RTH6F4.js} +2 -2
- package/dist/cli/chunks/{chunk-XTCV5UOJ.js → chunk-UABC2Z3S.js} +2 -2
- package/dist/cli/chunks/{chunk-I3POPZT5.js → chunk-UAE37LHP.js} +2 -2
- package/dist/cli/chunks/{chunk-5ROA7KOT.js → chunk-UHWRRJBH.js} +1 -1
- package/dist/cli/chunks/{chunk-J7BG55VG.js → chunk-UNAVOVD7.js} +3 -3
- package/dist/cli/chunks/{chunk-MJ7UYPGY.js → chunk-V5UB75TQ.js} +2 -2
- package/dist/cli/chunks/{chunk-WH7ZOJCF.js → chunk-VQI6JQQP.js} +1 -1
- package/dist/cli/chunks/{chunk-KYLE6ZSC.js → chunk-WALYYW6B.js} +4 -4
- package/dist/cli/chunks/{chunk-UFGFV4BO.js → chunk-WF6MKBRI.js} +2 -2
- package/dist/cli/chunks/{chunk-F7XU7KZL.js → chunk-X3NADG4S.js} +2 -2
- package/dist/cli/chunks/{chunk-7ZIKFJ6X.js → chunk-XJRXB5Z5.js} +2 -2
- package/dist/cli/chunks/{chunk-V2N7KWT7.js → chunk-Y6U4CCPP.js} +1 -1
- package/dist/cli/chunks/{chunk-VXQK4GKV.js → chunk-YPUDYGIU.js} +1 -1
- package/dist/cli/chunks/{chunk-K5NFP7B5.js → chunk-YPVPWDKL.js} +2 -2
- package/dist/cli/chunks/{chunk-VZO5I23B.js → chunk-Z5MG54R4.js} +1 -1
- package/dist/cli/chunks/{chunk-QTNDHCZ7.js → chunk-Z65DB2Z7.js} +3 -3
- package/dist/cli/chunks/{chunk-XSLKR2DM.js → chunk-ZBBHJGPI.js} +2 -2
- package/dist/cli/chunks/{chunk-RGLCMGNZ.js → chunk-ZCH5MNST.js} +2 -2
- package/dist/cli/chunks/{chunk-QW2RFI73.js → chunk-ZTWHRDUY.js} +2 -2
- package/dist/cli/chunks/{ci-LYAVZLM3.js → ci-TE3744OR.js} +2 -2
- package/dist/cli/chunks/{ci-output-L7TR2NCN.js → ci-output-GSNS52SY.js} +2 -2
- package/dist/cli/chunks/{circuit-breaker-AQOGJGKI.js → circuit-breaker-7ROW7QBW.js} +2 -2
- package/dist/cli/chunks/{claude-flow-setup-SO2ZN26K.js → claude-flow-setup-Z5GPMILN.js} +2 -2
- package/dist/cli/chunks/client-S5TFLKHN.js +2 -0
- package/dist/cli/chunks/{cline-installer-XCXFH4UR.js → cline-installer-6D4SAAM4.js} +2 -2
- package/dist/cli/chunks/{code-3Z2HMS5I.js → code-JZKH7FRS.js} +2 -2
- package/dist/cli/chunks/{code-index-extractor-KE362AJX.js → code-index-extractor-JJFTZLOK.js} +2 -2
- package/dist/cli/chunks/{codex-installer-GTD3GFTF.js → codex-installer-O5KIPN3Z.js} +2 -2
- package/dist/cli/chunks/{completions-EDCXRRJO.js → completions-QNMAUYKK.js} +2 -2
- package/dist/cli/chunks/{complexity-analyzer-QMN3V6D3.js → complexity-analyzer-JYJ7TLYE.js} +2 -2
- package/dist/cli/chunks/{continuedev-installer-U6HN376C.js → continuedev-installer-JYMVLG6S.js} +2 -2
- package/dist/cli/chunks/{copilot-installer-54PZIREM.js → copilot-installer-SSV6GF5G.js} +2 -2
- package/dist/cli/chunks/{cost-tracker-33O475QA.js → cost-tracker-2VZ3IMJZ.js} +2 -2
- package/dist/cli/chunks/{coverage-B7E545AJ.js → coverage-KW4V5D5L.js} +3 -3
- package/dist/cli/chunks/cross-domain-router-GZG5GU7Q.js +2 -0
- package/dist/cli/chunks/{cursor-installer-LKKSPZUM.js → cursor-installer-QVGDAHOI.js} +2 -2
- package/dist/cli/chunks/{daemon-DVOHWXUR.js → daemon-JKMFDYK2.js} +3 -3
- package/dist/cli/chunks/{dag-attention-scheduler-EQOHQBUG.js → dag-attention-scheduler-WKRV7DFE.js} +2 -2
- package/dist/cli/chunks/{detect-OCB2XT6C.js → detect-ROCCKX63.js} +2 -2
- package/dist/cli/chunks/{dist-node-HSG4QK4G.js → dist-node-QGU7TJTW.js} +2 -2
- package/dist/cli/chunks/{domain-handler-USGF4CIG.js → domain-handler-3UJHQPOR.js} +2 -2
- package/dist/cli/chunks/{domain-transfer-OUERZRGL.js → domain-transfer-R47ISVU5.js} +2 -2
- package/dist/cli/chunks/dream-PGYTIOQS.js +2 -0
- package/dist/cli/chunks/embed-and-insert-pattern-ZVK7WSY2.js +3 -0
- package/dist/cli/chunks/{eval-LHYXXWFK.js → eval-WNZWXFOW.js} +2 -2
- package/dist/cli/chunks/{fast-paths-UTK7BN63.js → fast-paths-QPF47RZJ.js} +2 -2
- package/dist/cli/chunks/{feature-flags-XB6ALB3X.js → feature-flags-2MAHHM66.js} +2 -2
- package/dist/cli/chunks/{feature-flags-XEP6B4GN.js → feature-flags-PGIG2W3G.js} +2 -2
- package/dist/cli/chunks/{file-discovery-O4DUCNHK.js → file-discovery-JL6FCXRB.js} +2 -2
- package/dist/cli/chunks/{fleet-37NGGRJI.js → fleet-LMBZU2GU.js} +3 -3
- package/dist/cli/chunks/{gnn-wrapper-5E7T3IQX.js → gnn-wrapper-GFNFVEER.js} +2 -2
- package/dist/cli/chunks/{heartbeat-handler-Q44PCI7K.js → heartbeat-handler-YN7ES3AX.js} +4 -4
- package/dist/cli/chunks/{heartbeat-scheduler-6JPB2AQS.js → heartbeat-scheduler-SII2KJSQ.js} +2 -2
- package/dist/cli/chunks/hnsw-adapter-ANJKCXK6.js +2 -0
- package/dist/cli/chunks/hnsw-index-D4CJEP7L.js +2 -0
- package/dist/cli/chunks/{hnsw-legacy-bridge-B55GGQYA.js → hnsw-legacy-bridge-CPMBYE7C.js} +2 -2
- package/dist/cli/chunks/{hnswlib-node-B3D2XIL5.js → hnswlib-node-NWNBNU3W.js} +2 -2
- package/dist/cli/chunks/hooks-EYSB7XDW.js +225 -0
- package/dist/cli/chunks/{hybrid-router-RV34PYQD.js → hybrid-router-BR7O6WT2.js} +2 -2
- package/dist/cli/chunks/{hypergraph-engine-FT5YK5RF.js → hypergraph-engine-HAKGWDYX.js} +2 -2
- package/dist/cli/chunks/{hypergraph-handler-EUS6MIYW.js → hypergraph-handler-UCI3LXUF.js} +3 -3
- package/dist/cli/chunks/impact-analyzer-55JW3OK6.js +2 -0
- package/dist/cli/chunks/{init-handler-3MV32TKZ.js → init-handler-7RYGU3W5.js} +6 -6
- package/dist/cli/chunks/init-wizard-MWKJNVB2.js +2 -0
- package/dist/cli/chunks/kernel-5MKKDS4J.js +2 -0
- package/dist/cli/chunks/{kilocode-installer-RZPRXQI2.js → kilocode-installer-W6ITMEFA.js} +2 -2
- package/dist/cli/chunks/{kiro-installer-BGDBNZHI.js → kiro-installer-2BO34D3O.js} +2 -2
- package/dist/cli/chunks/knowledge-graph-2A7AE7L7.js +2 -0
- package/dist/cli/chunks/{learning-KNEBWLEZ.js → learning-GEXYG72Z.js} +3 -3
- package/dist/cli/chunks/{llm-router-Q2VQPOQ3.js → llm-router-EGHA5YOC.js} +4 -4
- package/dist/cli/chunks/{load-RL53SYBD.js → load-VU2OOAEF.js} +2 -2
- package/dist/cli/chunks/load-test-UD4ZXCGG.js +2 -0
- package/dist/cli/chunks/{mcp-GTINFFUF.js → mcp-NVQFFQ2R.js} +2 -2
- package/dist/cli/chunks/{memory-STPMUUAK.js → memory-JNXMKTZQ.js} +5 -5
- package/dist/cli/chunks/memory-backend-X3Z4IAYG.js +2 -0
- package/dist/cli/chunks/{memory-handlers-LWX3LPVF.js → memory-handlers-NLGQ5I7K.js} +2 -2
- package/dist/cli/chunks/{multi-model-executor-36ZYYDA6.js → multi-model-executor-SG6OME2A.js} +2 -2
- package/dist/cli/chunks/{opencode-installer-KTCQKS2K.js → opencode-installer-AY4JCZIM.js} +2 -2
- package/dist/cli/chunks/{orchestrator-6EGOOXQG.js → orchestrator-GWI7HQG6.js} +6 -6
- package/dist/cli/chunks/{pipeline-WSLAIOYC.js → pipeline-7T6IAMC7.js} +2 -2
- package/dist/cli/chunks/{platform-MNUN663B.js → platform-IXUST66M.js} +2 -2
- package/dist/cli/chunks/{plugin-PLDTG4A2.js → plugin-PW7F6MVH.js} +2 -2
- package/dist/cli/chunks/{prime-radiant-advanced-wasm-B4UFONWB.js → prime-radiant-advanced-wasm-BUAZHZCM.js} +2 -2
- package/dist/cli/chunks/protocol-executor-AB6KPFK5.js +2 -0
- package/dist/cli/chunks/{protocol-handler-VAVLLAI2.js → protocol-handler-6746OC4P.js} +2 -2
- package/dist/cli/chunks/{prove-WVNPDWUC.js → prove-VYV5DQGC.js} +2 -2
- package/dist/cli/chunks/{provider-manager-VJF4D6AW.js → provider-manager-GEO3CUOO.js} +3 -3
- package/dist/cli/chunks/qe-reasoning-bank-Y4IDDIYA.js +2 -0
- package/dist/cli/chunks/{quality-LTMHVQBG.js → quality-4XXENNNW.js} +2 -2
- package/dist/cli/chunks/queen-coordinator-GBSTXGA2.js +2 -0
- package/dist/cli/chunks/{real-embeddings-6ACQACTM.js → real-embeddings-ZVEZVXVT.js} +2 -2
- package/dist/cli/chunks/{roocode-installer-T5ZWC3SS.js → roocode-installer-ZRNDOIDL.js} +2 -2
- package/dist/cli/chunks/router-JA2X4MF6.js +2 -0
- package/dist/cli/chunks/routing-feedback-YCVJIWFM.js +2 -0
- package/dist/cli/chunks/{routing-handler-Y2O2I2HM.js → routing-handler-MPSJ7DDI.js} +2 -2
- package/dist/cli/chunks/{ruvector-commands-F2V36B4W.js → ruvector-commands-V4BVCY2U.js} +2 -2
- package/dist/cli/chunks/{rvf-dual-writer-R6CNMPQD.js → rvf-dual-writer-X4VNU5KH.js} +2 -2
- package/dist/cli/chunks/{rvf-migration-adapter-IDVOB3LN.js → rvf-migration-adapter-KOYYJSNH.js} +2 -2
- package/dist/cli/chunks/{rvf-migration-coordinator-VM4AMFZG.js → rvf-migration-coordinator-SF5IBKTK.js} +2 -2
- package/dist/cli/chunks/rvf-native-adapter-5YN7EEB5.js +2 -0
- package/dist/cli/chunks/safe-db-S46Y7IC5.js +2 -0
- package/dist/cli/chunks/schedule-KSDHFWSY.js +2 -0
- package/dist/cli/chunks/scheduler-PLFJHU54.js +2 -0
- package/dist/cli/chunks/{security-WQ7YMR6M.js → security-AA5GBNNU.js} +3 -3
- package/dist/cli/chunks/shared-rvf-adapter-MLXVW4N6.js +2 -0
- package/dist/cli/chunks/{shared-rvf-dual-writer-HYI64CBX.js → shared-rvf-dual-writer-EGP3BYIY.js} +2 -2
- package/dist/cli/chunks/sqlite-persistence-RK3JWKB4.js +2 -0
- package/dist/cli/chunks/{status-handler-BH2WCMPA.js → status-handler-ARHPRXJ4.js} +2 -2
- package/dist/cli/chunks/{structural-health-XWX6FKVF.js → structural-health-IDV4RBZV.js} +2 -2
- package/dist/cli/chunks/{sync-PRDGCHE2.js → sync-7BRLSLDG.js} +2 -2
- package/dist/cli/chunks/{task-handler-YFHFBMHO.js → task-handler-XY42QA3K.js} +2 -2
- package/dist/cli/chunks/task-handlers-QEHOKEJC.js +9 -0
- package/dist/cli/chunks/{test-ZBTQ4Z66.js → test-TQIHDBEX.js} +4 -4
- package/dist/cli/chunks/{test-scheduling-F47Y3KNO.js → test-scheduling-BBVOLGFT.js} +3 -3
- package/dist/cli/chunks/{token-bootstrap-XOGAEQPG.js → token-bootstrap-BUHTWVEF.js} +2 -2
- package/dist/cli/chunks/{token-usage-2KZ7WE5J.js → token-usage-MRVQ7G3H.js} +2 -2
- package/dist/cli/chunks/{transformers-KCJ7PWZ4.js → transformers-3PFLFSWR.js} +2 -2
- package/dist/cli/chunks/{tree-sitter-wasm-parser-H6DL2DFA.js → tree-sitter-wasm-parser-6GDZQNFV.js} +2 -2
- package/dist/cli/chunks/{types-633TMIO3.js → types-F2LWFMRI.js} +2 -2
- package/dist/cli/chunks/unified-memory-JVZZMZRE.js +2 -0
- package/dist/cli/chunks/unified-memory-hnsw-EJJHCMFR.js +2 -0
- package/dist/cli/chunks/unified-persistence-IEKOYCBL.js +2 -0
- package/dist/cli/chunks/{upgrade-CH742GRF.js → upgrade-N676MSDA.js} +2 -2
- package/dist/cli/chunks/{validate-44WH3CKE.js → validate-56AA6YYM.js} +2 -2
- package/dist/cli/chunks/{validate-swarm-W2A7CUM7.js → validate-swarm-YPHV7MMC.js} +2 -2
- package/dist/cli/chunks/{vibium-B25MIEBK.js → vibium-ABPFT3DX.js} +2 -2
- package/dist/cli/chunks/visual-security-APS7K3TZ.js +2 -0
- package/dist/cli/chunks/{web-tree-sitter-B54K47HF.js → web-tree-sitter-KN4PWKMV.js} +2 -2
- package/dist/cli/chunks/{windsurf-installer-EWL7COTI.js → windsurf-installer-IZOJBDNN.js} +2 -2
- package/dist/cli/chunks/witness-chain-DMHO7R75.js +2 -0
- package/dist/cli/chunks/{witness-chain-DWNP7VR6.js → witness-chain-H2DM5WMB.js} +2 -2
- package/dist/cli/chunks/{workflow-LT2J7U23.js → workflow-R42PK45F.js} +4 -4
- package/dist/cli/chunks/workflow-orchestrator-BDHRNVOG.js +2 -0
- package/dist/cli/chunks/{wrappers-OAZ6MKXO.js → wrappers-6TIJNWN4.js} +2 -2
- package/dist/cli/commands/hooks-handlers/command-hooks.js +104 -11
- package/dist/cli/commands/hooks-handlers/hooks-dream-learning.d.ts +98 -0
- package/dist/cli/commands/hooks-handlers/hooks-dream-learning.js +339 -1
- package/dist/cli/commands/hooks-handlers/hooks-shared.d.ts +20 -1
- package/dist/cli/commands/hooks-handlers/hooks-shared.js +35 -3
- package/dist/cli/commands/hooks-handlers/routing-hooks.js +15 -5
- package/dist/cli/commands/hooks-handlers/task-hooks.js +216 -5
- package/dist/cli/commands/init.js +3 -1
- package/dist/coordination/consensus/providers/claude-provider.js +1 -1
- package/dist/coordination/task-executor.js +11 -2
- package/dist/init/phases/07-hooks.js +2 -2
- package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.js +82 -0
- package/dist/integrations/ruvector/hypergraph-engine.js +63 -4
- package/dist/integrations/ruvector/hypergraph-schema.d.ts +6 -2
- package/dist/learning/dream/dream-engine.js +8 -0
- package/dist/learning/embed-and-insert-pattern.d.ts +36 -0
- package/dist/learning/embed-and-insert-pattern.js +52 -0
- package/dist/learning/pattern-store.d.ts +8 -0
- package/dist/learning/pattern-store.js +66 -43
- package/dist/mcp/bundle.js +372 -357
- package/dist/mcp/entry.js +36 -1
- package/dist/mcp/handlers/core-handlers.js +2 -2
- package/dist/mcp/handlers/task-handlers.js +45 -0
- package/dist/mcp/handlers/trajectory-judge.d.ts +13 -0
- package/dist/mcp/handlers/trajectory-judge.js +100 -0
- package/dist/shared/llm/providers/claude.js +1 -1
- package/dist/workers/workers/learning-consolidation.js +6 -1
- package/package.json +1 -1
- package/dist/cli/chunks/adapter-C7AKAAPC.js +0 -2
- package/dist/cli/chunks/aqe-learning-engine-7P3AXQNO.js +0 -2
- package/dist/cli/chunks/base-GIDVLEPA.js +0 -2
- package/dist/cli/chunks/browser-workflow-DAUS4Z5V.js +0 -2
- package/dist/cli/chunks/chunk-4XYQJ4LQ.js +0 -2
- package/dist/cli/chunks/chunk-NKOLFLXF.js +0 -66
- package/dist/cli/chunks/chunk-RHYGRUNU.js +0 -24
- package/dist/cli/chunks/client-LIKTMSIP.js +0 -2
- package/dist/cli/chunks/cross-domain-router-SSBT32Q3.js +0 -2
- package/dist/cli/chunks/dream-FAHB6BWB.js +0 -2
- package/dist/cli/chunks/hnsw-adapter-GQM3ONQE.js +0 -2
- package/dist/cli/chunks/hnsw-index-XF3NY4R4.js +0 -2
- package/dist/cli/chunks/hooks-MOBQSJLJ.js +0 -101
- package/dist/cli/chunks/impact-analyzer-V6PBIMZH.js +0 -2
- package/dist/cli/chunks/init-wizard-7ROJWLEO.js +0 -2
- package/dist/cli/chunks/kernel-AOUBGDXU.js +0 -2
- package/dist/cli/chunks/knowledge-graph-SJA3YGMQ.js +0 -2
- package/dist/cli/chunks/load-test-NSHIGHCV.js +0 -2
- package/dist/cli/chunks/memory-backend-SZAYMQVP.js +0 -2
- package/dist/cli/chunks/protocol-executor-22KKAYX2.js +0 -2
- package/dist/cli/chunks/qe-reasoning-bank-N7ZXOAEN.js +0 -2
- package/dist/cli/chunks/queen-coordinator-BC54OCHH.js +0 -2
- package/dist/cli/chunks/router-YTQZRTIB.js +0 -2
- package/dist/cli/chunks/routing-feedback-AASAMEUY.js +0 -2
- package/dist/cli/chunks/rvf-native-adapter-VHIHJOPA.js +0 -2
- package/dist/cli/chunks/safe-db-NVEBL662.js +0 -2
- package/dist/cli/chunks/schedule-KVUFE56T.js +0 -2
- package/dist/cli/chunks/scheduler-6GRLJZ2A.js +0 -2
- package/dist/cli/chunks/shared-rvf-adapter-XORIDF3Q.js +0 -2
- package/dist/cli/chunks/sqlite-persistence-25TDMX6G.js +0 -2
- package/dist/cli/chunks/task-handlers-4OQRADMG.js +0 -2
- package/dist/cli/chunks/unified-memory-BTX45KY5.js +0 -2
- package/dist/cli/chunks/unified-memory-hnsw-MMHMQ4CP.js +0 -2
- package/dist/cli/chunks/unified-persistence-GA7HKYZC.js +0 -2
- package/dist/cli/chunks/visual-security-HPF5HCYF.js +0 -2
- package/dist/cli/chunks/witness-chain-LROQLFND.js +0 -2
- package/dist/cli/chunks/workflow-orchestrator-VFRKGG5Y.js +0 -2
|
@@ -4,11 +4,86 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Handles file guardian and Bash command lifecycle hooks.
|
|
6
6
|
*/
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
7
9
|
import chalk from 'chalk';
|
|
8
10
|
import path from 'node:path';
|
|
9
11
|
import { QE_HOOK_EVENTS } from '../../../learning/qe-hooks.js';
|
|
10
|
-
import { findProjectRoot } from '../../../kernel/unified-memory.js';
|
|
11
|
-
import { getHooksSystem, createHybridBackendWithTimeout, incrementDreamExperience, persistCommandExperience, printJson, printSuccess, printError, } from './hooks-shared.js';
|
|
12
|
+
import { findProjectRoot, getUnifiedMemory } from '../../../kernel/unified-memory.js';
|
|
13
|
+
import { applyHookBusyTimeout, getHooksSystem, createHybridBackendWithTimeout, incrementDreamExperience, persistCommandExperience, printJson, printSuccess, printError, } from './hooks-shared.js';
|
|
14
|
+
/**
|
|
15
|
+
* Detect test framework from a Bash command. Returns null when no recognized
|
|
16
|
+
* framework is invoked.
|
|
17
|
+
*/
|
|
18
|
+
function detectTestFramework(command) {
|
|
19
|
+
if (/\bjest\b/i.test(command))
|
|
20
|
+
return 'jest';
|
|
21
|
+
if (/\bvitest\b/i.test(command))
|
|
22
|
+
return 'vitest';
|
|
23
|
+
if (/\bpytest\b/i.test(command))
|
|
24
|
+
return 'pytest';
|
|
25
|
+
if (/\bmocha\b/i.test(command))
|
|
26
|
+
return 'mocha';
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Persist test_outcomes (patch 070) and coverage_sessions (patch 170) for a
|
|
31
|
+
* test-framework command. Best-effort — failures are logged at debug level.
|
|
32
|
+
*/
|
|
33
|
+
async function persistTestAndCoverage(opts) {
|
|
34
|
+
try {
|
|
35
|
+
const um = getUnifiedMemory();
|
|
36
|
+
if (!um.isInitialized()) {
|
|
37
|
+
await um.initialize();
|
|
38
|
+
}
|
|
39
|
+
const db = um.getDatabase();
|
|
40
|
+
applyHookBusyTimeout(db);
|
|
41
|
+
const language = opts.framework === 'pytest' ? 'python' : 'javascript';
|
|
42
|
+
const cmdSlug = opts.command.split(/\s+/).slice(0, 3).join('-').slice(0, 80);
|
|
43
|
+
db.prepare(`
|
|
44
|
+
INSERT INTO test_outcomes (
|
|
45
|
+
id, test_id, test_name, generated_by, framework, language, domain,
|
|
46
|
+
passed, execution_time_ms, maintainability_score, created_at
|
|
47
|
+
) VALUES (?, ?, ?, 'cli-hook-post-command', ?, ?, 'test-execution',
|
|
48
|
+
?, ?, 0.5, datetime('now'))
|
|
49
|
+
`).run(`to-${Date.now()}-${randomUUID().slice(0, 8)}`, `cmd:${cmdSlug}`, opts.command.slice(0, 200), opts.framework, language, opts.success ? 1 : 0, opts.durationMs);
|
|
50
|
+
// Patch 170: parse Istanbul coverage summary if it exists. Reuses the
|
|
51
|
+
// previous after_* values as before_* so coverage delta is calculable.
|
|
52
|
+
try {
|
|
53
|
+
const summaryPath = path.join(process.cwd(), 'coverage', 'coverage-summary.json');
|
|
54
|
+
if (existsSync(summaryPath)) {
|
|
55
|
+
const summary = JSON.parse(readFileSync(summaryPath, 'utf-8'));
|
|
56
|
+
const total = summary.total ?? {};
|
|
57
|
+
const afterLines = Number(total.lines?.pct ?? 0);
|
|
58
|
+
const afterBranches = Number(total.branches?.pct ?? 0);
|
|
59
|
+
const afterFunctions = Number(total.functions?.pct ?? 0);
|
|
60
|
+
const prev = db.prepare(`
|
|
61
|
+
SELECT after_lines, after_branches, after_functions
|
|
62
|
+
FROM coverage_sessions
|
|
63
|
+
WHERE target_path = ?
|
|
64
|
+
ORDER BY created_at DESC
|
|
65
|
+
LIMIT 1
|
|
66
|
+
`).get(process.cwd());
|
|
67
|
+
const nowIso = new Date().toISOString();
|
|
68
|
+
db.prepare(`
|
|
69
|
+
INSERT INTO coverage_sessions (
|
|
70
|
+
id, target_path, agent_id, technique,
|
|
71
|
+
before_lines, before_branches, before_functions,
|
|
72
|
+
after_lines, after_branches, after_functions,
|
|
73
|
+
tests_generated, tests_passed, duration_ms,
|
|
74
|
+
started_at, completed_at
|
|
75
|
+
) VALUES (?, ?, 'cli-hook-post-command', ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?)
|
|
76
|
+
`).run(`cs-${Date.now()}-${randomUUID().slice(0, 8)}`, process.cwd(), opts.framework, prev?.after_lines ?? 0, prev?.after_branches ?? 0, prev?.after_functions ?? 0, afterLines, afterBranches, afterFunctions, opts.success ? 1 : 0, opts.durationMs, nowIso, nowIso);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (covErr) {
|
|
80
|
+
console.error(chalk.dim(`[hooks] coverage_sessions: ${covErr instanceof Error ? covErr.message : 'unknown'}`));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error(chalk.dim(`[hooks] test_outcomes: ${error instanceof Error ? error.message : 'unknown'}`));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
12
87
|
/**
|
|
13
88
|
* Register guard, pre-command, and post-command subcommands on the hooks command.
|
|
14
89
|
*/
|
|
@@ -211,15 +286,33 @@ export function registerCommandHooks(hooks) {
|
|
|
211
286
|
feedback: `Command: ${command}, exit: ${exitCode}`,
|
|
212
287
|
});
|
|
213
288
|
patternsLearned = 1;
|
|
214
|
-
// Persist as captured experience
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
289
|
+
// Persist as captured experience — gated to test/build/lint commands
|
|
290
|
+
// so non-test Bash (git, ls, etc.) doesn't flood captured_experiences
|
|
291
|
+
// with low-success-rate noise that dilutes pattern signal.
|
|
292
|
+
// reasoningBank.recordOutcome above is the broader metric path and
|
|
293
|
+
// stays unconditional.
|
|
294
|
+
if (isTestCmd || isBuildCmd || isLintCmd) {
|
|
295
|
+
await persistCommandExperience({
|
|
296
|
+
task: `bash: ${command}`,
|
|
297
|
+
agent: 'cli-hook',
|
|
298
|
+
domain,
|
|
299
|
+
success,
|
|
300
|
+
source: 'cli-hook-post-command',
|
|
301
|
+
});
|
|
302
|
+
experienceRecorded = true;
|
|
303
|
+
}
|
|
304
|
+
// Patches 070 + 170: when a recognized test framework ran, write
|
|
305
|
+
// test_outcomes and (if Istanbul coverage summary is present) a
|
|
306
|
+
// coverage_sessions row. Best-effort.
|
|
307
|
+
const framework = detectTestFramework(command);
|
|
308
|
+
if (framework) {
|
|
309
|
+
await persistTestAndCoverage({
|
|
310
|
+
command,
|
|
311
|
+
framework,
|
|
312
|
+
success,
|
|
313
|
+
durationMs: 0, // post-command does not currently track exec time
|
|
314
|
+
});
|
|
315
|
+
}
|
|
223
316
|
// Increment dream experience counter
|
|
224
317
|
const projectRoot = findProjectRoot();
|
|
225
318
|
const dataDir = path.join(projectRoot, '.agentic-qe');
|
|
@@ -47,6 +47,104 @@ export declare function persistCommandExperience(opts: {
|
|
|
47
47
|
durationMs?: number;
|
|
48
48
|
source: string;
|
|
49
49
|
}): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Bridge payload written by pre-task into kv_store namespace='task-bridge'.
|
|
52
|
+
* Read by persistTaskOutcome to fan out per-pattern apps + derive q-learning state.
|
|
53
|
+
*/
|
|
54
|
+
export interface TaskBridgePayload {
|
|
55
|
+
selectedPatternIds: string[];
|
|
56
|
+
agent: string | null;
|
|
57
|
+
description: string;
|
|
58
|
+
taskType: string;
|
|
59
|
+
priority: string;
|
|
60
|
+
domain: string;
|
|
61
|
+
complexityBucket: number;
|
|
62
|
+
estimatedTokenSavings: number;
|
|
63
|
+
ts: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Result of persistTaskOutcome — surfaces fields the q-learning post-task
|
|
67
|
+
* integration needs (patch 280 / Stream F).
|
|
68
|
+
*/
|
|
69
|
+
export interface TaskOutcomeResult {
|
|
70
|
+
/** captured_experiences row id (FK target for experience_applications) */
|
|
71
|
+
experienceId: string;
|
|
72
|
+
/** Outcome quality computed via the 6-dim formula */
|
|
73
|
+
qualityScore: number;
|
|
74
|
+
/** Bridge payload that was consumed (null if no bridge entry found) */
|
|
75
|
+
bridge: TaskBridgePayload | null;
|
|
76
|
+
/** Number of multi-step siblings stitched into the trajectory (0 if single-step) */
|
|
77
|
+
stitchedSiblings: number;
|
|
78
|
+
/** Number of dream_insights rows whose applied counter was incremented */
|
|
79
|
+
insightsApplied: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Persist a Task() outcome through the full experience pipeline.
|
|
83
|
+
*
|
|
84
|
+
* Pipeline rolled into one helper that:
|
|
85
|
+
*
|
|
86
|
+
* 1. Writes captured_experiences (source='cli-hook-post-task')
|
|
87
|
+
* 2. Reads kv_store task-bridge (selectedPatternIds + estimatedTokenSavings)
|
|
88
|
+
* 3. Writes experience_applications: 1 base row + 1 per pattern_id (160/300)
|
|
89
|
+
* 4. Deletes the bridge entry to prevent double-consumption
|
|
90
|
+
* 5. Writes a single-step qe_trajectories row (120)
|
|
91
|
+
* 6. Looks for sibling captured_experiences with task LIKE '%:taskId' in the
|
|
92
|
+
* last hour; if ≥2, creates a multi-step traj-multi-... row and marks
|
|
93
|
+
* siblings consolidated_into = traj-multi-id (180)
|
|
94
|
+
* 7. Increments dream_insights.applied for top-3 most-recent actionable rows
|
|
95
|
+
* when the task succeeded (110)
|
|
96
|
+
*
|
|
97
|
+
* All steps run inside a single transaction so partial failures don't leave
|
|
98
|
+
* inconsistent state. Returns the experience_id and derived fields for the
|
|
99
|
+
* q-learning post-task integration (Stream F / patch 280).
|
|
100
|
+
*/
|
|
101
|
+
export declare function persistTaskOutcome(opts: {
|
|
102
|
+
taskId: string;
|
|
103
|
+
agent: string;
|
|
104
|
+
domain?: string;
|
|
105
|
+
success: boolean;
|
|
106
|
+
durationMs?: number;
|
|
107
|
+
}): Promise<TaskOutcomeResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Q-learning Bellman update for the hook-router state-action pair.
|
|
110
|
+
*
|
|
111
|
+
* Aligned to ADR-061/087:
|
|
112
|
+
* - algorithm='q-learning' (not 'asymmetric-hebbian'; that label is for
|
|
113
|
+
* ReasoningBank confidence updates, not Q-learning)
|
|
114
|
+
* - agent_id='aqe-hook-router' (per-instance partition; persistent-q-router
|
|
115
|
+
* convention so we don't collide with canonical RuVector q-router writes
|
|
116
|
+
* at agent_id='q-router')
|
|
117
|
+
* - state_key='${taskType}|${priority}|${domain}|${complexityBucket}'
|
|
118
|
+
* (structural; see q-learning-router.ts:591)
|
|
119
|
+
* - action_key=agent name chosen
|
|
120
|
+
* - id='q-learning:aqe-hook-router:${stateKey}:${actionKey}'
|
|
121
|
+
*
|
|
122
|
+
* Update: Q ← Q + α(r + γ·max_a' Q(s',a') − Q) with α=0.1, γ=0.9.
|
|
123
|
+
* Reward: success +0.1, failure −1.0 (asymmetric per ADR-061).
|
|
124
|
+
*
|
|
125
|
+
* Best-effort — failures swallowed to keep post-task hook responsive.
|
|
126
|
+
*/
|
|
127
|
+
export declare function updateHookRouterQValue(opts: {
|
|
128
|
+
taskType: string;
|
|
129
|
+
priority: string;
|
|
130
|
+
domain: string;
|
|
131
|
+
complexityBucket: number;
|
|
132
|
+
agent: string;
|
|
133
|
+
success: boolean;
|
|
134
|
+
}): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Update the routing_outcomes sentinel row that pre-task wrote with
|
|
137
|
+
* quality=-1, success=0. Patch 150: applies the 6-dim outcome quality and
|
|
138
|
+
* success bit to the most-recent pending sentinel matching the agent.
|
|
139
|
+
*
|
|
140
|
+
* Best-effort — no-op when no sentinel found.
|
|
141
|
+
*/
|
|
142
|
+
export declare function updateRoutingOutcomeQuality(opts: {
|
|
143
|
+
agent: string;
|
|
144
|
+
success: boolean;
|
|
145
|
+
durationMs: number;
|
|
146
|
+
qualityScore: number;
|
|
147
|
+
}): Promise<void>;
|
|
50
148
|
/**
|
|
51
149
|
* Lightweight experience-to-pattern consolidation.
|
|
52
150
|
* Aggregates captured_experiences by domain+agent, and for clusters that meet
|
|
@@ -128,6 +128,10 @@ export async function persistCommandExperience(opts) {
|
|
|
128
128
|
await um.initialize();
|
|
129
129
|
}
|
|
130
130
|
const db = um.getDatabase();
|
|
131
|
+
try {
|
|
132
|
+
db.pragma('busy_timeout = 60000');
|
|
133
|
+
}
|
|
134
|
+
catch { /* hook-side patient timeout (ADR-001 / patch 260) */ }
|
|
131
135
|
const id = `cli-${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
132
136
|
// Compute quality based on context rather than binary success/fail.
|
|
133
137
|
// Duration-aware: fast successful ops get higher quality.
|
|
@@ -151,12 +155,336 @@ export async function persistCommandExperience(opts) {
|
|
|
151
155
|
started_at, completed_at, source)
|
|
152
156
|
VALUES (?, ?, ?, ?, ?, ?, ?, datetime('now'), datetime('now'), ?)
|
|
153
157
|
`).run(id, opts.task.slice(0, 500), opts.agent, opts.domain, opts.success ? 1 : 0, quality, durationMs, opts.source);
|
|
158
|
+
// Fire-and-forget embedding write so HNSW C is searchable from the next
|
|
159
|
+
// boot's loadEmbeddingIndex() without waiting for the patch-350 backfill.
|
|
160
|
+
// Without this, hook-side writes accumulate as "ghosts" until the next
|
|
161
|
+
// restart catches them.
|
|
162
|
+
void (async () => {
|
|
163
|
+
try {
|
|
164
|
+
const { computeRealEmbedding } = await import('../../../learning/real-embeddings.js');
|
|
165
|
+
const text = `${opts.domain}: ${opts.task}`.slice(0, 512);
|
|
166
|
+
const embedding = await computeRealEmbedding(text);
|
|
167
|
+
db.prepare(`UPDATE captured_experiences SET embedding = ?, embedding_dimension = ? WHERE id = ?`)
|
|
168
|
+
.run(Buffer.from(new Float32Array(embedding).buffer), embedding.length, id);
|
|
169
|
+
}
|
|
170
|
+
catch { /* fail-soft */ }
|
|
171
|
+
})();
|
|
154
172
|
}
|
|
155
173
|
catch (error) {
|
|
156
174
|
// Best-effort — don't fail the hook
|
|
157
175
|
console.error(chalk.dim(`[hooks] persistCommandExperience: ${error instanceof Error ? error.message : 'unknown'}`));
|
|
158
176
|
}
|
|
159
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Persist a Task() outcome through the full experience pipeline.
|
|
180
|
+
*
|
|
181
|
+
* Pipeline rolled into one helper that:
|
|
182
|
+
*
|
|
183
|
+
* 1. Writes captured_experiences (source='cli-hook-post-task')
|
|
184
|
+
* 2. Reads kv_store task-bridge (selectedPatternIds + estimatedTokenSavings)
|
|
185
|
+
* 3. Writes experience_applications: 1 base row + 1 per pattern_id (160/300)
|
|
186
|
+
* 4. Deletes the bridge entry to prevent double-consumption
|
|
187
|
+
* 5. Writes a single-step qe_trajectories row (120)
|
|
188
|
+
* 6. Looks for sibling captured_experiences with task LIKE '%:taskId' in the
|
|
189
|
+
* last hour; if ≥2, creates a multi-step traj-multi-... row and marks
|
|
190
|
+
* siblings consolidated_into = traj-multi-id (180)
|
|
191
|
+
* 7. Increments dream_insights.applied for top-3 most-recent actionable rows
|
|
192
|
+
* when the task succeeded (110)
|
|
193
|
+
*
|
|
194
|
+
* All steps run inside a single transaction so partial failures don't leave
|
|
195
|
+
* inconsistent state. Returns the experience_id and derived fields for the
|
|
196
|
+
* q-learning post-task integration (Stream F / patch 280).
|
|
197
|
+
*/
|
|
198
|
+
export async function persistTaskOutcome(opts) {
|
|
199
|
+
const { getUnifiedMemory } = await import('../../../kernel/unified-memory.js');
|
|
200
|
+
const um = getUnifiedMemory();
|
|
201
|
+
if (!um.isInitialized()) {
|
|
202
|
+
await um.initialize();
|
|
203
|
+
}
|
|
204
|
+
const db = um.getDatabase();
|
|
205
|
+
try {
|
|
206
|
+
db.pragma('busy_timeout = 60000');
|
|
207
|
+
}
|
|
208
|
+
catch { /* hook-side patient timeout (ADR-001 / patch 260) */ }
|
|
209
|
+
const experienceId = `exp-${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
210
|
+
const taskField = `${opts.agent}:${opts.taskId}`;
|
|
211
|
+
const durationMs = opts.durationMs ?? 0;
|
|
212
|
+
// 6-dim outcome quality (patch 080/150 canonical formula)
|
|
213
|
+
// 0.25 * effectiveness + 0.325 baseline + 0.10 * duration_tier
|
|
214
|
+
// Other 4 dims default-0.5 weighted contribute via the 0.325 baseline term.
|
|
215
|
+
const successScore = opts.success ? 1 : 0;
|
|
216
|
+
const durationTier = durationMs < 100 ? 1.0 :
|
|
217
|
+
durationMs < 500 ? 0.8 :
|
|
218
|
+
durationMs < 2000 ? 0.6 :
|
|
219
|
+
durationMs < 5000 ? 0.4 :
|
|
220
|
+
durationMs < 10000 ? 0.2 : 0.1;
|
|
221
|
+
const qualityScore = 0.25 * successScore + 0.325 + 0.10 * durationTier;
|
|
222
|
+
let bridge = null;
|
|
223
|
+
let stitchedSiblings = 0;
|
|
224
|
+
let insightsApplied = 0;
|
|
225
|
+
const txn = db.transaction(() => {
|
|
226
|
+
// 1. captured_experiences row
|
|
227
|
+
db.prepare(`
|
|
228
|
+
INSERT INTO captured_experiences
|
|
229
|
+
(id, task, agent, domain, success, quality, duration_ms,
|
|
230
|
+
model_tier, started_at, completed_at, source)
|
|
231
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, NULL, datetime('now'), datetime('now'), ?)
|
|
232
|
+
`).run(experienceId, taskField.slice(0, 500), opts.agent, opts.domain ?? 'general', opts.success ? 1 : 0, qualityScore, durationMs, 'cli-hook-post-task');
|
|
233
|
+
// 2. Base experience_applications row
|
|
234
|
+
db.prepare(`
|
|
235
|
+
INSERT INTO experience_applications
|
|
236
|
+
(id, experience_id, task, success, tokens_saved, feedback, applied_at)
|
|
237
|
+
VALUES (?, ?, ?, ?, ?, ?, datetime('now'))
|
|
238
|
+
`).run(`app-${Date.now()}-${randomUUID().slice(0, 8)}`, experienceId, taskField, opts.success ? 1 : 0, 0, `[Patch 060] post-task outcome: ${opts.success ? 'success' : 'failure'}`);
|
|
239
|
+
// 3. Read bridge → fan out per-pattern application rows + delete bridge
|
|
240
|
+
try {
|
|
241
|
+
const bridgeRow = db.prepare(`
|
|
242
|
+
SELECT key, value FROM kv_store
|
|
243
|
+
WHERE namespace = 'task-bridge'
|
|
244
|
+
AND (expires_at IS NULL OR expires_at > strftime('%s','now') * 1000)
|
|
245
|
+
ORDER BY created_at DESC
|
|
246
|
+
LIMIT 1
|
|
247
|
+
`).get();
|
|
248
|
+
if (bridgeRow?.value) {
|
|
249
|
+
try {
|
|
250
|
+
bridge = JSON.parse(bridgeRow.value);
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
bridge = null;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (bridge && Array.isArray(bridge.selectedPatternIds) && bridge.selectedPatternIds.length > 0) {
|
|
257
|
+
const perPatternTokens = bridge.estimatedTokenSavings && bridge.selectedPatternIds.length
|
|
258
|
+
? Math.round(bridge.estimatedTokenSavings / bridge.selectedPatternIds.length)
|
|
259
|
+
: 0;
|
|
260
|
+
const insertApp = db.prepare(`
|
|
261
|
+
INSERT INTO experience_applications
|
|
262
|
+
(id, experience_id, task, success, tokens_saved, feedback, applied_at)
|
|
263
|
+
VALUES (?, ?, ?, ?, ?, ?, datetime('now'))
|
|
264
|
+
`);
|
|
265
|
+
// Mirror SQLitePatternStore.recordUsage() so the hook flow updates
|
|
266
|
+
// qe_patterns.{usage_count, successful_uses, success_rate, quality_score}.
|
|
267
|
+
// recordUsage() is otherwise only reachable via HandleTaskOutcomeRecord
|
|
268
|
+
// — never from this hook path — so 88/89 patterns stayed pinned at the
|
|
269
|
+
// bootstrap quality_score floor (~0.30) and never promoted to long-term.
|
|
270
|
+
// Quality formula: confidence*0.3 + min(usage_count/100,1)*0.2 + success_rate*0.5
|
|
271
|
+
const updatePatternUsage = db.prepare(`
|
|
272
|
+
UPDATE qe_patterns SET
|
|
273
|
+
usage_count = usage_count + 1,
|
|
274
|
+
successful_uses = successful_uses + ?,
|
|
275
|
+
success_rate = CAST(successful_uses + ? AS REAL) / CAST(usage_count + 1 AS REAL),
|
|
276
|
+
quality_score = ? * 0.3
|
|
277
|
+
+ MIN(CAST(usage_count + 1 AS REAL) / 100.0, 1.0) * 0.2
|
|
278
|
+
+ (CAST(successful_uses + ? AS REAL) / CAST(usage_count + 1 AS REAL)) * 0.5,
|
|
279
|
+
last_used_at = datetime('now'),
|
|
280
|
+
updated_at = datetime('now')
|
|
281
|
+
WHERE id = ?
|
|
282
|
+
`);
|
|
283
|
+
const getPatternConfidence = db.prepare(`SELECT confidence FROM qe_patterns WHERE id = ?`);
|
|
284
|
+
for (const patternId of bridge.selectedPatternIds) {
|
|
285
|
+
insertApp.run(`app-${Date.now()}-${randomUUID().slice(0, 8)}`, experienceId, `${taskField}:pattern:${patternId}`, opts.success ? 1 : 0, perPatternTokens, `[Patch 160+300] task-bridge pattern_id=${patternId} ts=${perPatternTokens}`);
|
|
286
|
+
try {
|
|
287
|
+
const row = getPatternConfidence.get(patternId);
|
|
288
|
+
if (row) {
|
|
289
|
+
const successInc = opts.success ? 1 : 0;
|
|
290
|
+
updatePatternUsage.run(successInc, successInc, row.confidence, successInc, patternId);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
catch { /* fail-soft per pattern */ }
|
|
294
|
+
}
|
|
295
|
+
// 4. Delete bridge entry (one-shot consumption)
|
|
296
|
+
if (bridgeRow) {
|
|
297
|
+
db.prepare(`DELETE FROM kv_store WHERE namespace='task-bridge' AND key = ?`).run(bridgeRow.key);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch (bridgeErr) {
|
|
302
|
+
console.error(chalk.dim(`[hooks] post-task bridge: ${bridgeErr instanceof Error ? bridgeErr.message : 'unknown'}`));
|
|
303
|
+
}
|
|
304
|
+
// 5. Single-step qe_trajectories row
|
|
305
|
+
const trajId = `traj-${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
306
|
+
db.prepare(`
|
|
307
|
+
INSERT INTO qe_trajectories (id, task, agent, domain, started_at, ended_at, success, steps_json)
|
|
308
|
+
VALUES (?, ?, ?, ?, datetime('now'), datetime('now'), ?, ?)
|
|
309
|
+
`).run(trajId, taskField, opts.agent, opts.domain ?? 'general', opts.success ? 1 : 0, JSON.stringify([{ step: 1, task: opts.taskId, success: opts.success }]));
|
|
310
|
+
// 6. Multi-step stitch — siblings sharing the same suffix taskId in the
|
|
311
|
+
// last hour. Only fires when ≥2 unconsolidated siblings exist.
|
|
312
|
+
try {
|
|
313
|
+
const siblings = db.prepare(`
|
|
314
|
+
SELECT id, task, agent, success, started_at, completed_at
|
|
315
|
+
FROM captured_experiences
|
|
316
|
+
WHERE consolidated_into IS NULL
|
|
317
|
+
AND task LIKE ?
|
|
318
|
+
AND started_at > datetime('now', '-1 hour')
|
|
319
|
+
ORDER BY started_at ASC
|
|
320
|
+
`).all(`%:${opts.taskId}`);
|
|
321
|
+
if (siblings.length >= 2) {
|
|
322
|
+
const multiTrajId = `traj-multi-${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
323
|
+
const stepsJson = JSON.stringify(siblings.map((s, i) => ({
|
|
324
|
+
step: i + 1,
|
|
325
|
+
task: s.task,
|
|
326
|
+
agent: s.agent,
|
|
327
|
+
success: !!s.success,
|
|
328
|
+
started_at: s.started_at,
|
|
329
|
+
completed_at: s.completed_at,
|
|
330
|
+
})));
|
|
331
|
+
const allSuccess = siblings.every((s) => !!s.success);
|
|
332
|
+
db.prepare(`
|
|
333
|
+
INSERT INTO qe_trajectories (id, task, agent, domain, started_at, ended_at, success, steps_json)
|
|
334
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
335
|
+
`).run(multiTrajId, `multi:${opts.taskId}`, opts.agent, opts.domain ?? 'general', siblings[0].started_at, siblings[siblings.length - 1].completed_at, allSuccess ? 1 : 0, stepsJson);
|
|
336
|
+
const placeholders = siblings.map(() => '?').join(',');
|
|
337
|
+
db.prepare(`UPDATE captured_experiences SET consolidated_into = ? WHERE id IN (${placeholders})`).run(multiTrajId, ...siblings.map((s) => s.id));
|
|
338
|
+
stitchedSiblings = siblings.length;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
catch (stitchErr) {
|
|
342
|
+
console.error(chalk.dim(`[hooks] post-task stitch: ${stitchErr instanceof Error ? stitchErr.message : 'unknown'}`));
|
|
343
|
+
}
|
|
344
|
+
// 7. dream_insights.applied counter — only on success
|
|
345
|
+
if (opts.success) {
|
|
346
|
+
try {
|
|
347
|
+
const result = db.prepare(`
|
|
348
|
+
UPDATE dream_insights
|
|
349
|
+
SET applied = COALESCE(applied, 0) + 1
|
|
350
|
+
WHERE id IN (
|
|
351
|
+
SELECT id FROM dream_insights
|
|
352
|
+
WHERE actionable = 1
|
|
353
|
+
ORDER BY created_at DESC
|
|
354
|
+
LIMIT 3
|
|
355
|
+
)
|
|
356
|
+
`).run();
|
|
357
|
+
insightsApplied = result.changes ?? 0;
|
|
358
|
+
}
|
|
359
|
+
catch {
|
|
360
|
+
// dream_insights may not exist on minimal schemas
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
try {
|
|
365
|
+
txn();
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
console.error(chalk.dim(`[hooks] persistTaskOutcome txn: ${error instanceof Error ? error.message : 'unknown'}`));
|
|
369
|
+
}
|
|
370
|
+
// Fire-and-forget embedding write for the captured_experiences row inserted
|
|
371
|
+
// inside the transaction above. Same rationale as the persistCommandExperience
|
|
372
|
+
// site — without this, post-task writes are ghosts until next-boot backfill.
|
|
373
|
+
void (async () => {
|
|
374
|
+
try {
|
|
375
|
+
const { computeRealEmbedding } = await import('../../../learning/real-embeddings.js');
|
|
376
|
+
const text = `${opts.domain ?? 'general'}: ${taskField}`.slice(0, 512);
|
|
377
|
+
const embedding = await computeRealEmbedding(text);
|
|
378
|
+
db.prepare(`UPDATE captured_experiences SET embedding = ?, embedding_dimension = ? WHERE id = ?`)
|
|
379
|
+
.run(Buffer.from(new Float32Array(embedding).buffer), embedding.length, experienceId);
|
|
380
|
+
}
|
|
381
|
+
catch { /* fail-soft */ }
|
|
382
|
+
})();
|
|
383
|
+
return {
|
|
384
|
+
experienceId,
|
|
385
|
+
qualityScore,
|
|
386
|
+
bridge,
|
|
387
|
+
stitchedSiblings,
|
|
388
|
+
insightsApplied,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Q-learning Bellman update for the hook-router state-action pair.
|
|
393
|
+
*
|
|
394
|
+
* Aligned to ADR-061/087:
|
|
395
|
+
* - algorithm='q-learning' (not 'asymmetric-hebbian'; that label is for
|
|
396
|
+
* ReasoningBank confidence updates, not Q-learning)
|
|
397
|
+
* - agent_id='aqe-hook-router' (per-instance partition; persistent-q-router
|
|
398
|
+
* convention so we don't collide with canonical RuVector q-router writes
|
|
399
|
+
* at agent_id='q-router')
|
|
400
|
+
* - state_key='${taskType}|${priority}|${domain}|${complexityBucket}'
|
|
401
|
+
* (structural; see q-learning-router.ts:591)
|
|
402
|
+
* - action_key=agent name chosen
|
|
403
|
+
* - id='q-learning:aqe-hook-router:${stateKey}:${actionKey}'
|
|
404
|
+
*
|
|
405
|
+
* Update: Q ← Q + α(r + γ·max_a' Q(s',a') − Q) with α=0.1, γ=0.9.
|
|
406
|
+
* Reward: success +0.1, failure −1.0 (asymmetric per ADR-061).
|
|
407
|
+
*
|
|
408
|
+
* Best-effort — failures swallowed to keep post-task hook responsive.
|
|
409
|
+
*/
|
|
410
|
+
export async function updateHookRouterQValue(opts) {
|
|
411
|
+
try {
|
|
412
|
+
const { getUnifiedMemory } = await import('../../../kernel/unified-memory.js');
|
|
413
|
+
const um = getUnifiedMemory();
|
|
414
|
+
if (!um.isInitialized()) {
|
|
415
|
+
await um.initialize();
|
|
416
|
+
}
|
|
417
|
+
const db = um.getDatabase();
|
|
418
|
+
try {
|
|
419
|
+
db.pragma('busy_timeout = 60000');
|
|
420
|
+
}
|
|
421
|
+
catch { /* hook-side patient timeout (ADR-001 / patch 260) */ }
|
|
422
|
+
const stateKey = `${opts.taskType}|${opts.priority}|${opts.domain || 'any'}|${opts.complexityBucket}`;
|
|
423
|
+
const actionKey = opts.agent;
|
|
424
|
+
const id = `q-learning:aqe-hook-router:${stateKey}:${actionKey}`;
|
|
425
|
+
const reward = opts.success ? 0.1 : -1.0;
|
|
426
|
+
const alpha = 0.1;
|
|
427
|
+
const gamma = 0.9;
|
|
428
|
+
const existing = db.prepare(`
|
|
429
|
+
SELECT q_value FROM rl_q_values WHERE id = ?
|
|
430
|
+
`).get(id);
|
|
431
|
+
const oldQ = (existing && typeof existing.q_value === 'number') ? existing.q_value : 0;
|
|
432
|
+
const futureRow = db.prepare(`
|
|
433
|
+
SELECT MAX(q_value) AS m FROM rl_q_values WHERE state_key = ?
|
|
434
|
+
`).get(stateKey);
|
|
435
|
+
const futureMaxQ = (futureRow && typeof futureRow.m === 'number') ? futureRow.m : 0;
|
|
436
|
+
// Bellman update
|
|
437
|
+
const newQ = oldQ + alpha * (reward + gamma * futureMaxQ - oldQ);
|
|
438
|
+
db.prepare(`
|
|
439
|
+
INSERT INTO rl_q_values
|
|
440
|
+
(id, algorithm, agent_id, state_key, action_key, q_value, visits, last_reward, domain, created_at, updated_at)
|
|
441
|
+
VALUES (?, 'q-learning', 'aqe-hook-router', ?, ?, ?, 1, ?, ?, datetime('now'), datetime('now'))
|
|
442
|
+
ON CONFLICT(algorithm, agent_id, state_key, action_key) DO UPDATE SET
|
|
443
|
+
q_value = excluded.q_value,
|
|
444
|
+
visits = visits + 1,
|
|
445
|
+
last_reward = excluded.last_reward,
|
|
446
|
+
updated_at = datetime('now')
|
|
447
|
+
`).run(id, stateKey, actionKey, newQ, reward, opts.domain || 'any');
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
console.error(chalk.dim(`[hooks] q-learning update: ${error instanceof Error ? error.message : 'unknown'}`));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Update the routing_outcomes sentinel row that pre-task wrote with
|
|
455
|
+
* quality=-1, success=0. Patch 150: applies the 6-dim outcome quality and
|
|
456
|
+
* success bit to the most-recent pending sentinel matching the agent.
|
|
457
|
+
*
|
|
458
|
+
* Best-effort — no-op when no sentinel found.
|
|
459
|
+
*/
|
|
460
|
+
export async function updateRoutingOutcomeQuality(opts) {
|
|
461
|
+
try {
|
|
462
|
+
const { getUnifiedMemory } = await import('../../../kernel/unified-memory.js');
|
|
463
|
+
const um = getUnifiedMemory();
|
|
464
|
+
if (!um.isInitialized()) {
|
|
465
|
+
await um.initialize();
|
|
466
|
+
}
|
|
467
|
+
const db = um.getDatabase();
|
|
468
|
+
try {
|
|
469
|
+
db.pragma('busy_timeout = 60000');
|
|
470
|
+
}
|
|
471
|
+
catch { /* hook-side patient timeout (ADR-001 / patch 260) */ }
|
|
472
|
+
db.prepare(`
|
|
473
|
+
UPDATE routing_outcomes
|
|
474
|
+
SET success = ?, quality_score = ?, duration_ms = ?
|
|
475
|
+
WHERE id IN (
|
|
476
|
+
SELECT id FROM routing_outcomes
|
|
477
|
+
WHERE quality_score = -1
|
|
478
|
+
AND created_at > datetime('now', '-30 minutes')
|
|
479
|
+
ORDER BY (CASE WHEN used_agent = ? THEN 0 ELSE 1 END), created_at DESC
|
|
480
|
+
LIMIT 1
|
|
481
|
+
)
|
|
482
|
+
`).run(opts.success ? 1 : 0, opts.qualityScore, opts.durationMs, opts.agent);
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
console.error(chalk.dim(`[hooks] routing UPDATE: ${error instanceof Error ? error.message : 'unknown'}`));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
160
488
|
/**
|
|
161
489
|
* Lightweight experience-to-pattern consolidation.
|
|
162
490
|
* Aggregates captured_experiences by domain+agent, and for clusters that meet
|
|
@@ -170,6 +498,10 @@ export async function consolidateExperiencesToPatterns() {
|
|
|
170
498
|
await um.initialize();
|
|
171
499
|
}
|
|
172
500
|
const db = um.getDatabase();
|
|
501
|
+
try {
|
|
502
|
+
db.pragma('busy_timeout = 60000');
|
|
503
|
+
}
|
|
504
|
+
catch { /* hook-side patient timeout (ADR-001 / patch 260) */ }
|
|
173
505
|
// Ensure consolidation columns exist (may be missing on older DBs)
|
|
174
506
|
const existingCols = new Set(db.prepare('PRAGMA table_info(captured_experiences)').all().map(c => c.name));
|
|
175
507
|
const migrations = [
|
|
@@ -238,13 +570,19 @@ export async function consolidateExperiencesToPatterns() {
|
|
|
238
570
|
const patternId = uuidv4();
|
|
239
571
|
const confidence = Math.min(0.95, agg.avg_quality * 0.8 + agg.success_rate * 0.2);
|
|
240
572
|
const qualityScore = confidence * 0.3 + (Math.min(agg.cnt, 100) / 100) * 0.2 + agg.success_rate * 0.5;
|
|
573
|
+
const description = `Auto-consolidated from ${agg.cnt} experiences. Agent: ${agg.agent}, success rate: ${(agg.success_rate * 100).toFixed(0)}%`;
|
|
574
|
+
const tags = (agg.sources || '').split(',').filter(Boolean);
|
|
241
575
|
db.prepare(`
|
|
242
576
|
INSERT INTO qe_patterns (
|
|
243
577
|
id, pattern_type, qe_domain, domain, name, description,
|
|
244
578
|
confidence, usage_count, success_rate, quality_score, tier,
|
|
245
579
|
template_json, context_json, created_at, successful_uses
|
|
246
580
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now'), ?)
|
|
247
|
-
`).run(patternId, 'workflow', agg.domain, agg.domain, patternName,
|
|
581
|
+
`).run(patternId, 'workflow', agg.domain, agg.domain, patternName, description, confidence, agg.cnt, agg.success_rate, qualityScore, 'short-term', JSON.stringify({ type: 'workflow', content: `${agg.agent} pattern for ${agg.domain}`, variables: [] }), JSON.stringify({ tags, sourceType: 'session-consolidation', extractedAt: new Date().toISOString() }), agg.successes);
|
|
582
|
+
// Pair the qe_patterns row with an embedding so HNSW pattern recall
|
|
583
|
+
// doesn't see this as a "ghost" (ADR-058 embedding-locality). Fail-soft.
|
|
584
|
+
const { ensurePatternEmbedding } = await import('../../../learning/embed-and-insert-pattern.js');
|
|
585
|
+
await ensurePatternEmbedding(db, patternId, patternName, description, tags);
|
|
248
586
|
created++;
|
|
249
587
|
}
|
|
250
588
|
// Mark experiences as processed
|
|
@@ -33,6 +33,25 @@ export declare function getHooksSystem(): Promise<{
|
|
|
33
33
|
* Initialize the hooks system
|
|
34
34
|
*/
|
|
35
35
|
export declare function initializeHooksSystem(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Hook-side busy_timeout (ADR-001 Option C / patch 260).
|
|
38
|
+
*
|
|
39
|
+
* Hooks fire from short-lived `npx aqe hooks ...` subprocesses. They open the
|
|
40
|
+
* shared memory.db while MCP-daemon workers may be holding the WAL write-lock
|
|
41
|
+
* for several seconds during dream-cycle / pattern-promotion. With the default
|
|
42
|
+
* 5s busy_timeout, hooks fail under contention. With 60s, they wait patiently
|
|
43
|
+
* — the hook subprocess exits as soon as it's done, so the longer timeout has
|
|
44
|
+
* no broader cost.
|
|
45
|
+
*
|
|
46
|
+
* Workers in MCP still use the platform default (5s) so they fail fast and
|
|
47
|
+
* retry on the next tick — they yield the lock to hooks under contention.
|
|
48
|
+
*
|
|
49
|
+
* This is per-connection: setting the pragma in a hook subprocess only affects
|
|
50
|
+
* that subprocess's connection, not the MCP daemon's.
|
|
51
|
+
*/
|
|
52
|
+
export declare function applyHookBusyTimeout(db: {
|
|
53
|
+
pragma: (s: string) => void;
|
|
54
|
+
}): void;
|
|
36
55
|
/**
|
|
37
56
|
* Create hybrid backend with timeout protection
|
|
38
57
|
*
|
|
@@ -48,5 +67,5 @@ export declare function printJson(data: unknown): void;
|
|
|
48
67
|
export declare function printSuccess(message: string): void;
|
|
49
68
|
export declare function printError(message: string): void;
|
|
50
69
|
export declare function printGuidance(guidance: string[]): void;
|
|
51
|
-
export { DREAM_STATE_KEY, DREAM_INTERVAL_MS, DREAM_EXPERIENCE_THRESHOLD, DREAM_MIN_GAP_MS, type DreamHookState, checkAndTriggerDream, incrementDreamExperience, persistCommandExperience, consolidateExperiencesToPatterns, } from './hooks-dream-learning.js';
|
|
70
|
+
export { DREAM_STATE_KEY, DREAM_INTERVAL_MS, DREAM_EXPERIENCE_THRESHOLD, DREAM_MIN_GAP_MS, type DreamHookState, type TaskBridgePayload, type TaskOutcomeResult, checkAndTriggerDream, incrementDreamExperience, persistCommandExperience, persistTaskOutcome, updateHookRouterQValue, updateRoutingOutcomeQuality, consolidateExperiencesToPatterns, } from './hooks-dream-learning.js';
|
|
52
71
|
//# sourceMappingURL=hooks-shared.d.ts.map
|