agentic-qe 3.11.5 → 3.12.1
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/.helpers-version +1 -0
- package/.claude/helpers/auto-memory-hook.mjs +35 -3
- package/.claude/helpers/brain-checkpoint.cjs +16 -1
- package/.claude/helpers/helpers.manifest.json +12 -0
- package/.claude/helpers/hook-handler.cjs +26 -5
- package/.claude/helpers/intelligence.cjs +14 -1
- package/.claude/hooks/aqe-hook.cjs +14 -1
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +87 -0
- package/assets/skills/skills-manifest.json +1 -1
- package/dist/adapters/a2a/auth/routes.js +59 -28
- package/dist/cli/bundle.js +6 -6
- package/dist/cli/chunks/adapter-X4UEC6UJ.js +2 -0
- package/dist/cli/chunks/{agent-booster-wasm-CSTBLNYZ.js → agent-booster-wasm-P4VYM5KK.js} +2 -2
- package/dist/cli/chunks/{agent-handler-M4W4GTXN.js → agent-handler-PBQ7L2TO.js} +2 -2
- package/dist/cli/chunks/{agent-memory-branch-VGXFYLSQ.js → agent-memory-branch-UPWO3X6V.js} +2 -2
- package/dist/cli/chunks/aqe-learning-engine-5FG7JCY7.js +2 -0
- package/dist/cli/chunks/{arena-IQBRGWAG.js → arena-LEUTILZ7.js} +2 -2
- package/dist/cli/chunks/{arena-FKSD3LLM.js → arena-QYTP3FG6.js} +4 -4
- package/dist/cli/chunks/{audit-7NSGRR4Z.js → audit-TB6M2YLK.js} +3 -3
- package/dist/cli/chunks/base-CWPMFSZG.js +2 -0
- package/dist/cli/chunks/{hnswlib-node-E6NSZPP2.js → better-sqlite3-IPKCAVLS.js} +2 -2
- package/dist/cli/chunks/{brain-handler-M6A3UB66.js → brain-handler-JF3OK35F.js} +3 -3
- package/dist/cli/chunks/{branch-enumerator-2JGKY4BB.js → branch-enumerator-WEIP3DXB.js} +2 -2
- package/dist/cli/chunks/{browser-J43WQPJL.js → browser-HY6VLXHZ.js} +2 -2
- package/dist/cli/chunks/browser-workflow-A77OFBVY.js +2 -0
- package/dist/cli/chunks/{chunk-7BCRULCP.js → chunk-2PQ7YADF.js} +2 -2
- package/dist/cli/chunks/{chunk-XKQY2Z3Q.js → chunk-3I3Z4C5X.js} +1 -1
- package/dist/cli/chunks/{chunk-MCHEUSY4.js → chunk-3W2FZXFD.js} +1 -1
- package/dist/cli/chunks/{chunk-WMZ2QGGS.js → chunk-42GFB7VX.js} +2 -2
- package/dist/cli/chunks/{chunk-UBI2EOS3.js → chunk-42PYEEYQ.js} +1 -1
- package/dist/cli/chunks/{chunk-HJWT4KME.js → chunk-45QNHMTP.js} +1 -1
- package/dist/cli/chunks/{chunk-AGJOGUP5.js → chunk-4KI72C2E.js} +1 -1
- package/dist/cli/chunks/{chunk-5WMU7XCF.js → chunk-4LKQZW2H.js} +1 -1
- package/dist/cli/chunks/{chunk-SUL3I6QZ.js → chunk-4U5MJX2H.js} +2 -2
- package/dist/cli/chunks/{chunk-DFRRWOEX.js → chunk-55MQ2SFP.js} +2 -2
- package/dist/cli/chunks/{chunk-KP3R2M2G.js → chunk-5H5A74U2.js} +1 -1
- package/dist/cli/chunks/{chunk-YBPLJRVT.js → chunk-5HMGDB7B.js} +2 -2
- package/dist/cli/chunks/{chunk-YZSTZUGJ.js → chunk-6432JORM.js} +1 -1
- package/dist/cli/chunks/{chunk-CDJP6COA.js → chunk-6BCVKCG5.js} +2 -2
- package/dist/cli/chunks/{chunk-TBT3OFRW.js → chunk-6ONUCDVL.js} +2 -2
- package/dist/cli/chunks/{chunk-3LY7OCSO.js → chunk-6RX5QZMU.js} +1 -1
- package/dist/cli/chunks/chunk-74VIADSJ.js +2 -0
- package/dist/cli/chunks/{chunk-K4I7UIU5.js → chunk-75AVUS5U.js} +1 -1
- package/dist/cli/chunks/{chunk-KVVJVMDM.js → chunk-774X6OJY.js} +2 -2
- package/dist/cli/chunks/chunk-7KHIOWBN.js +2 -0
- package/dist/cli/chunks/{chunk-62OTU2AP.js → chunk-7KK6XSYK.js} +2 -2
- package/dist/cli/chunks/{chunk-RFLHPLET.js → chunk-7N2SCRWJ.js} +1 -1
- package/dist/cli/chunks/{chunk-OS2HHJTM.js → chunk-AGWKCY42.js} +2 -2
- package/dist/cli/chunks/chunk-BAHXVVX3.js +4 -0
- package/dist/cli/chunks/{chunk-6T65OKUM.js → chunk-BALFQQB7.js} +2 -2
- package/dist/cli/chunks/{chunk-I3ANRYQ6.js → chunk-BBNQDHGF.js} +2 -2
- package/dist/cli/chunks/{chunk-LOE2JETO.js → chunk-BCBITOMT.js} +2 -2
- package/dist/cli/chunks/{chunk-FII3WCCY.js → chunk-BKKJEKNT.js} +2 -2
- package/dist/cli/chunks/{chunk-TTJJ4DQE.js → chunk-BLU7OLQZ.js} +2 -2
- package/dist/cli/chunks/{chunk-AL5VJJN4.js → chunk-BNMV5DCM.js} +1 -1
- package/dist/cli/chunks/{chunk-4XJ2A3HY.js → chunk-BPM7NEHS.js} +4 -4
- package/dist/cli/chunks/{chunk-3V36WMIO.js → chunk-BWNMAXV7.js} +1 -1
- package/dist/cli/chunks/{chunk-EDOGRFAG.js → chunk-BXIJY6SB.js} +1 -1
- package/dist/cli/chunks/{chunk-ZXEWTZFR.js → chunk-C2K4LQI5.js} +1 -1
- package/dist/cli/chunks/{chunk-3WR35GFF.js → chunk-C7HGYLNF.js} +2 -2
- package/dist/cli/chunks/{chunk-7YSBATSN.js → chunk-CDVKFAYP.js} +2 -2
- package/dist/cli/chunks/{chunk-JBKZ5TUM.js → chunk-CJTXZI37.js} +2 -2
- package/dist/cli/chunks/{chunk-VMWRMINE.js → chunk-CP4GSICY.js} +1 -1
- package/dist/cli/chunks/{chunk-2XPMATEK.js → chunk-CXUHD2O5.js} +2 -2
- package/dist/cli/chunks/{chunk-W7TYKPLY.js → chunk-CYYT6YEV.js} +2 -2
- package/dist/cli/chunks/{chunk-SO6G4IX3.js → chunk-D72N5V2S.js} +2 -2
- package/dist/cli/chunks/{chunk-4LODYRNV.js → chunk-DQ3J7ZT6.js} +2 -2
- package/dist/cli/chunks/{chunk-PVDXNQPL.js → chunk-DSNFOX22.js} +2 -2
- package/dist/cli/chunks/{chunk-LPR2R3AN.js → chunk-EOBZJDJR.js} +3 -3
- package/dist/cli/chunks/{chunk-6R3YOAKO.js → chunk-FBYFDD7L.js} +2 -2
- package/dist/cli/chunks/{chunk-ZPP57WQU.js → chunk-FFSS3Y6W.js} +2 -2
- package/dist/cli/chunks/chunk-FNMEVLSN.js +2 -0
- package/dist/cli/chunks/{chunk-7KXPNNMR.js → chunk-GASACVTU.js} +2 -2
- package/dist/cli/chunks/{chunk-ABU64UWB.js → chunk-GGF5FZWS.js} +1 -1
- package/dist/cli/chunks/{chunk-M6FW56MV.js → chunk-GLO53MUQ.js} +2 -2
- package/dist/cli/chunks/{chunk-52U5BFZP.js → chunk-GW3M7GQH.js} +2 -2
- package/dist/cli/chunks/chunk-GXMNCW2M.js +2 -0
- package/dist/cli/chunks/{chunk-D45QLJEL.js → chunk-HDI3FD4G.js} +1 -1
- package/dist/cli/chunks/{chunk-26WEI3P4.js → chunk-HGKSU4QV.js} +2 -2
- package/dist/cli/chunks/{chunk-B2VBDMDI.js → chunk-HHMTQQUE.js} +2 -2
- package/dist/cli/chunks/{chunk-4Y3LGBKJ.js → chunk-HZGFER4N.js} +3 -3
- package/dist/cli/chunks/{chunk-AXKWV5NF.js → chunk-I4BZLVFE.js} +3 -3
- package/dist/cli/chunks/{chunk-JDSHUECG.js → chunk-IC6SOVGO.js} +2 -2
- package/dist/cli/chunks/{chunk-YFCULQBP.js → chunk-IE6FDICX.js} +2 -2
- package/dist/cli/chunks/{chunk-FGD6HINU.js → chunk-IHWWZOHP.js} +1 -1
- package/dist/cli/chunks/{chunk-HC6KTVFR.js → chunk-J4IAMQZI.js} +2 -2
- package/dist/cli/chunks/{chunk-VMFAANWX.js → chunk-J6ZCULWG.js} +2 -2
- package/dist/cli/chunks/{chunk-YGVDP6X7.js → chunk-JDZIBSMY.js} +1 -1
- package/dist/cli/chunks/{chunk-WPSK237F.js → chunk-JIM4VSLF.js} +3 -3
- package/dist/cli/chunks/{chunk-EK3HPH6A.js → chunk-JRHRC2MP.js} +1 -1
- package/dist/cli/chunks/{chunk-3JF5A72M.js → chunk-JRNDFC23.js} +2 -2
- package/dist/cli/chunks/chunk-JWZNWVLG.js +153 -0
- package/dist/cli/chunks/{chunk-Q5TR6ETB.js → chunk-KQV5644J.js} +3 -3
- package/dist/cli/chunks/{chunk-4RTWPR3X.js → chunk-LAJHHR3Q.js} +1 -1
- package/dist/cli/chunks/{chunk-AOXJFDH5.js → chunk-LF5XOYR7.js} +10 -10
- package/dist/cli/chunks/{chunk-I3NWKPXJ.js → chunk-LRWBOJ5Y.js} +2 -2
- package/dist/cli/chunks/{chunk-354367AP.js → chunk-LZ6TJ7XL.js} +2 -2
- package/dist/cli/chunks/{chunk-4QOI5JS7.js → chunk-M5P5WNXA.js} +1 -1
- package/dist/cli/chunks/{chunk-SE3JFUKP.js → chunk-MCUILJ33.js} +1 -1
- package/dist/cli/chunks/{chunk-ZG5UAEEO.js → chunk-MIAY35K6.js} +2 -2
- package/dist/cli/chunks/{chunk-6Q57K4YD.js → chunk-N3PSRG6F.js} +2 -2
- package/dist/cli/chunks/{chunk-FMNXHVIN.js → chunk-NEXJUTHF.js} +2 -2
- package/dist/cli/chunks/{chunk-RJN2RM76.js → chunk-NHRBKOYD.js} +2 -2
- package/dist/cli/chunks/{chunk-BJLA2IX7.js → chunk-NK2Z6FGF.js} +2 -2
- package/dist/cli/chunks/{chunk-Y25PO65W.js → chunk-NOCPO55P.js} +2 -2
- package/dist/cli/chunks/{chunk-XT4TDLOB.js → chunk-NTMN2ZJY.js} +2 -2
- package/dist/cli/chunks/{chunk-7DTMENY6.js → chunk-NVXSM7UO.js} +2 -2
- package/dist/cli/chunks/{chunk-CKOF27L7.js → chunk-O65OPAZH.js} +2 -2
- package/dist/cli/chunks/{chunk-OGNTCZKK.js → chunk-OEXSBR72.js} +1 -1
- package/dist/cli/chunks/{chunk-Y6DWJKHU.js → chunk-OJORNYN3.js} +3 -3
- package/dist/cli/chunks/{chunk-DPL762HU.js → chunk-ONSNNY6J.js} +1 -1
- package/dist/cli/chunks/{chunk-IBDQWKI3.js → chunk-OXVAGR64.js} +2 -2
- package/dist/cli/chunks/{chunk-C5C4W572.js → chunk-P7G5LGUE.js} +2 -2
- package/dist/cli/chunks/{chunk-XLT3FYS7.js → chunk-PDS5P5QD.js} +2 -2
- package/dist/cli/chunks/{chunk-IU5RSN6M.js → chunk-PQ4NSXZM.js} +2 -2
- package/dist/cli/chunks/{chunk-4MHN7JWC.js → chunk-PRA73XZY.js} +12 -12
- package/dist/cli/chunks/{chunk-2XQHG56O.js → chunk-PZ3Q34OT.js} +2 -2
- package/dist/cli/chunks/{chunk-EEKG35K5.js → chunk-PZZDAECU.js} +3 -3
- package/dist/cli/chunks/{chunk-J6PFPY7V.js → chunk-QJXUK54J.js} +2 -2
- package/dist/cli/chunks/{chunk-7P6X4BFO.js → chunk-QOAI6ETC.js} +3 -3
- package/dist/cli/chunks/{chunk-53YOYZW5.js → chunk-QORWBION.js} +2 -2
- package/dist/cli/chunks/{chunk-OS62Y77J.js → chunk-QXZOUETY.js} +2 -2
- package/dist/cli/chunks/{chunk-G2ZIJZJ7.js → chunk-QZBPXJ5C.js} +2 -2
- package/dist/cli/chunks/{chunk-WHHQIL4F.js → chunk-R4A6PY5D.js} +2 -2
- package/dist/cli/chunks/{chunk-ZLBY25MB.js → chunk-R7XEACKR.js} +1 -1
- package/dist/cli/chunks/{chunk-K4C25BWV.js → chunk-RAS7WRN5.js} +2 -2
- package/dist/cli/chunks/{chunk-MHMQ6MCT.js → chunk-REJGZP27.js} +2 -2
- package/dist/cli/chunks/{chunk-PW72M2FE.js → chunk-RIASOMB2.js} +2 -2
- package/dist/cli/chunks/{chunk-TEIWJ3GJ.js → chunk-RJ7TU2MP.js} +1 -1
- package/dist/cli/chunks/{chunk-W72FJA2H.js → chunk-S42RFOZJ.js} +2 -2
- package/dist/cli/chunks/chunk-SFQFBLWQ.js +2 -0
- package/dist/cli/chunks/{chunk-O7J54OHN.js → chunk-SHKOPOPD.js} +1 -1
- package/dist/cli/chunks/{chunk-QKK7VBVB.js → chunk-TGIKKD43.js} +2 -2
- package/dist/cli/chunks/chunk-TMPRR3FZ.js +2 -0
- package/dist/cli/chunks/{chunk-GW6XWMX2.js → chunk-U55X2ZUM.js} +2 -2
- package/dist/cli/chunks/{chunk-C4EZNOWK.js → chunk-U5ITD7ZD.js} +1 -1
- package/dist/cli/chunks/{chunk-RKXZLTWR.js → chunk-UBPJQKYS.js} +2 -2
- package/dist/cli/chunks/{chunk-DVW66FPU.js → chunk-UBWSYDO5.js} +1 -1
- package/dist/cli/chunks/chunk-UEC53US3.js +316 -0
- package/dist/cli/chunks/{chunk-UBY322ED.js → chunk-UGPBL7LX.js} +2 -2
- package/dist/cli/chunks/{chunk-MMEXHZUC.js → chunk-UKF4V7LE.js} +5 -5
- package/dist/cli/chunks/{chunk-FIPKIIMS.js → chunk-UR655D4K.js} +2 -2
- package/dist/cli/chunks/{chunk-GODAWJMZ.js → chunk-USTUWUCE.js} +2 -2
- package/dist/cli/chunks/{chunk-FGSIID5C.js → chunk-UZXDYT6O.js} +2 -2
- package/dist/cli/chunks/{chunk-JATLFS6A.js → chunk-VFRWLSQO.js} +1 -1
- package/dist/cli/chunks/{chunk-AF6P5RWY.js → chunk-VHJCQBD2.js} +2 -2
- package/dist/cli/chunks/{chunk-J5XDKVI7.js → chunk-VTFYY4SH.js} +2 -2
- package/dist/cli/chunks/{chunk-BTLUWH4R.js → chunk-W52R3G22.js} +2 -2
- package/dist/cli/chunks/{chunk-AOQYORVA.js → chunk-WBDV4V3H.js} +2 -2
- package/dist/cli/chunks/{chunk-3I4TCMOJ.js → chunk-WPEGG6DX.js} +1 -1
- package/dist/cli/chunks/{chunk-KQVIWE3W.js → chunk-WPG5LXR7.js} +2 -2
- package/dist/cli/chunks/{chunk-DLBVADWQ.js → chunk-X2CEX4KC.js} +42 -42
- package/dist/cli/chunks/{chunk-MTBGOWJA.js → chunk-X2K3BTI4.js} +2 -2
- package/dist/cli/chunks/{chunk-NCSXLMDL.js → chunk-XDRAU3W6.js} +2 -2
- package/dist/cli/chunks/{chunk-URP75DL4.js → chunk-XJTGLG7G.js} +1 -1
- package/dist/cli/chunks/{chunk-TRNBQFFG.js → chunk-XS6BIOPQ.js} +2 -2
- package/dist/cli/chunks/{chunk-MEIU7457.js → chunk-XTAXSKPC.js} +2 -2
- package/dist/cli/chunks/{chunk-VN2HHBZN.js → chunk-XYV6YUWS.js} +2 -2
- package/dist/cli/chunks/{chunk-UORTQXJ2.js → chunk-YGB3MT3R.js} +1 -1
- package/dist/cli/chunks/{chunk-37ZUF5NX.js → chunk-YNXQMJGJ.js} +1 -1
- package/dist/cli/chunks/{chunk-BLPWJQTY.js → chunk-ZCDGLNJ7.js} +2 -2
- package/dist/cli/chunks/{chunk-62UM7Q5N.js → chunk-ZNITDSWL.js} +1 -1
- package/dist/cli/chunks/{ci-CBNVLOOQ.js → ci-IU5HVUL5.js} +2 -2
- package/dist/cli/chunks/{ci-output-I4HY2FYJ.js → ci-output-CLI4A43F.js} +2 -2
- package/dist/cli/chunks/{circuit-breaker-5VRBKGWL.js → circuit-breaker-ZR5OFMW7.js} +2 -2
- package/dist/cli/chunks/{claude-flow-setup-XPJPKHIO.js → claude-flow-setup-UBMA6ZHJ.js} +2 -2
- package/dist/cli/chunks/client-KKCFGD7R.js +2 -0
- package/dist/cli/chunks/{cline-installer-OFRDUUWZ.js → cline-installer-EWYELOBI.js} +2 -2
- package/dist/cli/chunks/{code-QIZQVB3E.js → code-YSPF4MXN.js} +2 -2
- package/dist/cli/chunks/{code-index-extractor-LMUUWEX4.js → code-index-extractor-WW5OKSTN.js} +2 -2
- package/dist/cli/chunks/{codex-installer-N2MKIZ2S.js → codex-installer-GLADK5PY.js} +2 -2
- package/dist/cli/chunks/{completions-Y36S3C5J.js → completions-2KTWZ3AK.js} +2 -2
- package/dist/cli/chunks/{complexity-analyzer-73YS3WUD.js → complexity-analyzer-KMX4OWKB.js} +2 -2
- package/dist/cli/chunks/{continuedev-installer-SAOTP6J3.js → continuedev-installer-4FHU4OEJ.js} +2 -2
- package/dist/cli/chunks/{copilot-installer-A4HXF6HE.js → copilot-installer-AKR4WE7B.js} +2 -2
- package/dist/cli/chunks/core-handlers-KRSSJEO5.js +2 -0
- package/dist/cli/chunks/{cost-tracker-P26XUVZS.js → cost-tracker-BUJ6WEWY.js} +2 -2
- package/dist/cli/chunks/{coverage-HVNHSMVJ.js → coverage-OB6HVQS4.js} +3 -3
- package/dist/cli/chunks/cross-domain-router-27QGWU27.js +2 -0
- package/dist/cli/chunks/{cursor-installer-46BQFTYZ.js → cursor-installer-3AOE4O3Q.js} +2 -2
- package/dist/cli/chunks/{daemon-Y54O3FLT.js → daemon-4RAL5URG.js} +3 -3
- package/dist/cli/chunks/{daemon-YE7K2AZF.js → daemon-JGSPLYGO.js} +4 -4
- package/dist/cli/chunks/{dag-attention-scheduler-ETA7YY52.js → dag-attention-scheduler-DSBTHIMH.js} +2 -2
- package/dist/cli/chunks/{detect-5WLQ2J3E.js → detect-6CVW2VUQ.js} +2 -2
- package/dist/cli/chunks/{dist-node-45WW6I7J.js → dist-node-EWPKBTYA.js} +2 -2
- package/dist/cli/chunks/{domain-handler-J7DQV74M.js → domain-handler-HLVIJU25.js} +2 -2
- package/dist/cli/chunks/{domain-transfer-GD2EGQVR.js → domain-transfer-7Y3BR3YU.js} +2 -2
- package/dist/cli/chunks/dream-M6K47Q4H.js +2 -0
- package/dist/cli/chunks/{embed-and-insert-pattern-JELNEA2D.js → embed-and-insert-pattern-ZMJ3263X.js} +2 -2
- package/dist/cli/chunks/{eval-A4PA5G2U.js → eval-73XW2WJD.js} +2 -2
- package/dist/cli/chunks/{experience-capture-middleware-MLHTYWTA.js → experience-capture-middleware-OGJ3JOSQ.js} +3 -3
- package/dist/cli/chunks/{fast-paths-QYDTITRV.js → fast-paths-5XCY3Y6U.js} +2 -2
- package/dist/cli/chunks/{feature-flags-H4MSY26Z.js → feature-flags-R5V2FRJR.js} +2 -2
- package/dist/cli/chunks/{feature-flags-MQYYRHIK.js → feature-flags-VULQI6KY.js} +2 -2
- package/dist/cli/chunks/{file-discovery-RMFVJNGL.js → file-discovery-HW33C3HC.js} +2 -2
- package/dist/cli/chunks/{fleet-7KZQOTAC.js → fleet-NH3XR5OY.js} +3 -3
- package/dist/cli/chunks/{gnn-wrapper-NMZFTGVH.js → gnn-wrapper-L3XMLPTG.js} +2 -2
- package/dist/cli/chunks/{heartbeat-handler-7BQDK7MG.js → heartbeat-handler-TIQFBT4D.js} +4 -4
- package/dist/cli/chunks/heartbeat-scheduler-URXBF5RW.js +2 -0
- package/dist/cli/chunks/hnsw-adapter-WWAGM6HK.js +2 -0
- package/dist/cli/chunks/hnsw-index-UFV2HSZE.js +2 -0
- package/dist/cli/chunks/{hnsw-legacy-bridge-TPPGBPKF.js → hnsw-legacy-bridge-YL2SUIPA.js} +2 -2
- package/dist/cli/chunks/{better-sqlite3-2KR4LQRU.js → hnswlib-node-62RTSHAY.js} +2 -2
- package/dist/cli/chunks/{hooks-CYZIUYSH.js → hooks-UR2ZF54G.js} +10 -10
- package/dist/cli/chunks/hybrid-router-3U6Q6OTL.js +2 -0
- package/dist/cli/chunks/{hypergraph-engine-WC6DMTYQ.js → hypergraph-engine-NX45AOPY.js} +2 -2
- package/dist/cli/chunks/{hypergraph-handler-GTGA3TXJ.js → hypergraph-handler-LUM4YI4K.js} +3 -3
- package/dist/cli/chunks/impact-analyzer-EUEX6ZRO.js +2 -0
- package/dist/cli/chunks/{init-handler-N3Z72JNI.js → init-handler-YTKKNTVV.js} +6 -6
- package/dist/cli/chunks/init-wizard-POKY2LRY.js +2 -0
- package/dist/cli/chunks/kernel-HPAONLZY.js +2 -0
- package/dist/cli/chunks/{kilocode-installer-FUX4V6II.js → kilocode-installer-ZW7DVH7T.js} +2 -2
- package/dist/cli/chunks/{kiro-installer-ZSNZT7ZR.js → kiro-installer-IA7INW4N.js} +2 -2
- package/dist/cli/chunks/knowledge-graph-2WCUFG63.js +2 -0
- package/dist/cli/chunks/{learning-UQY64COU.js → learning-4AZ5PGTT.js} +3 -3
- package/dist/cli/chunks/{llm-router-CMHGGX6N.js → llm-router-WQ4E3AOP.js} +4 -4
- package/dist/cli/chunks/llm-router-service-D5VMG6SD.js +2 -0
- package/dist/cli/chunks/{load-E6WH4QN2.js → load-4FAH7CZO.js} +2 -2
- package/dist/cli/chunks/load-test-DHG26REU.js +2 -0
- package/dist/cli/chunks/{mcp-UM5VTW6N.js → mcp-KLLHI6DG.js} +2 -2
- package/dist/cli/chunks/{memory-7Q3XDUE5.js → memory-Q5HLIUC6.js} +5 -5
- package/dist/cli/chunks/memory-backend-GLWQ4DAL.js +2 -0
- package/dist/cli/chunks/memory-handlers-P72I4VV4.js +2 -0
- package/dist/cli/chunks/{multi-model-executor-LZENWVRR.js → multi-model-executor-ABI73AFV.js} +2 -2
- package/dist/cli/chunks/{opencode-installer-O2JAIPLF.js → opencode-installer-KRPQ6JOJ.js} +2 -2
- package/dist/cli/chunks/{orchestrator-DKZWXDRI.js → orchestrator-SUPEONRG.js} +18 -18
- package/dist/cli/chunks/pattern-null-store-Y2YFTE3V.js +2 -0
- package/dist/cli/chunks/{pattern-usage-recorder-CLUL4M55.js → pattern-usage-recorder-R4GKK6RZ.js} +2 -2
- package/dist/cli/chunks/{pipeline-2VDLTR5J.js → pipeline-LCUETNGD.js} +2 -2
- package/dist/cli/chunks/{platform-4N4Q5XYX.js → platform-WJDIB4X3.js} +2 -2
- package/dist/cli/chunks/{plugin-GY5AU5CS.js → plugin-2X5NY2RF.js} +2 -2
- package/dist/cli/chunks/{prime-radiant-advanced-wasm-TQ4DKDZS.js → prime-radiant-advanced-wasm-3T665QC6.js} +2 -2
- package/dist/cli/chunks/protocol-executor-HNT67NN5.js +2 -0
- package/dist/cli/chunks/{protocol-handler-T3LZ3WRG.js → protocol-handler-JTXRF7GU.js} +2 -2
- package/dist/cli/chunks/{prove-OV7S5J4W.js → prove-BFPWWPOC.js} +2 -2
- package/dist/cli/chunks/provider-manager-5YGPZIEZ.js +2 -0
- package/dist/cli/chunks/qe-reasoning-bank-Z5UGOA3F.js +2 -0
- package/dist/cli/chunks/{quality-AXD4NLQA.js → quality-F7UZU4RN.js} +2 -2
- package/dist/cli/chunks/quality-gate-R5L4UZIX.js +7 -0
- package/dist/cli/chunks/queen-coordinator-P5LU5NWI.js +2 -0
- package/dist/cli/chunks/{real-embeddings-2PUCC7FG.js → real-embeddings-LZD6HTQF.js} +2 -2
- package/dist/cli/chunks/{roocode-installer-WJ5ARGLW.js → roocode-installer-6TTG7VSH.js} +2 -2
- package/dist/cli/chunks/router-CRGHUAVR.js +2 -0
- package/dist/cli/chunks/routing-feedback-BVX5ZBCF.js +2 -0
- package/dist/cli/chunks/{routing-handler-CU6657SZ.js → routing-handler-SW442GK7.js} +2 -2
- package/dist/cli/chunks/{ruvector-commands-IIF6VSFW.js → ruvector-commands-CLFGKXMW.js} +2 -2
- package/dist/cli/chunks/{rvf-dual-writer-YMQI7XO2.js → rvf-dual-writer-EVPPXXXS.js} +2 -2
- package/dist/cli/chunks/{rvf-migration-adapter-HDE3PR2W.js → rvf-migration-adapter-NOHDIRIP.js} +2 -2
- package/dist/cli/chunks/{rvf-migration-coordinator-MQV5OA7K.js → rvf-migration-coordinator-BYJ3M7WZ.js} +2 -2
- package/dist/cli/chunks/rvf-native-adapter-FZJSQOJM.js +2 -0
- package/dist/cli/chunks/safe-db-USYNEOC6.js +2 -0
- package/dist/cli/chunks/schedule-KCRCQ3PS.js +2 -0
- package/dist/cli/chunks/scheduler-CX3UHI4U.js +2 -0
- package/dist/cli/chunks/{security-UM3IGDSM.js → security-IXDKBPSG.js} +3 -3
- package/dist/cli/chunks/{shared-rvf-adapter-I3SOJ6M4.js → shared-rvf-adapter-VCOK3OVD.js} +2 -2
- package/dist/cli/chunks/{shared-rvf-dual-writer-KQGC2UO7.js → shared-rvf-dual-writer-FFKBKYNL.js} +2 -2
- package/dist/cli/chunks/sqlite-persistence-K23C4TFH.js +2 -0
- package/dist/cli/chunks/{status-handler-OX4CJZME.js → status-handler-M5W64S5U.js} +2 -2
- package/dist/cli/chunks/{structural-health-PYUMVBXJ.js → structural-health-55X6BTLT.js} +2 -2
- package/dist/cli/chunks/{sync-VALFNTA6.js → sync-BUGDXW3Y.js} +2 -2
- package/dist/cli/chunks/{sync-2TED3YTY.js → sync-NUG67HGK.js} +2 -2
- package/dist/cli/chunks/{task-handler-VPGAJVPC.js → task-handler-T6ZKXV4S.js} +2 -2
- package/dist/cli/chunks/{task-handlers-IB4UAMU6.js → task-handlers-H63TB2UI.js} +3 -3
- package/dist/cli/chunks/{test-OMRJOZB6.js → test-VEK76SBT.js} +4 -4
- package/dist/cli/chunks/{test-scheduling-ZL3YFPBU.js → test-scheduling-QZM6PNZH.js} +3 -3
- package/dist/cli/chunks/{token-bootstrap-DNWZI7SH.js → token-bootstrap-W5IAMJW4.js} +2 -2
- package/dist/cli/chunks/{token-usage-IYO7RGFF.js → token-usage-OBY6UEUR.js} +2 -2
- package/dist/cli/chunks/{transformers-53ALC34T.js → transformers-EFNY2MRX.js} +2 -2
- package/dist/cli/chunks/{tree-sitter-wasm-parser-WUKJ2I2Q.js → tree-sitter-wasm-parser-EU2S5NVM.js} +2 -2
- package/dist/cli/chunks/{types-47FTEPMV.js → types-3DYRKX23.js} +2 -2
- package/dist/cli/chunks/unified-memory-NCDBQLLF.js +2 -0
- package/dist/cli/chunks/unified-memory-hnsw-T7NSGQ2H.js +2 -0
- package/dist/cli/chunks/unified-persistence-XUAYDCMM.js +2 -0
- package/dist/cli/chunks/{upgrade-QPLMJA5Z.js → upgrade-H5V53FRF.js} +2 -2
- package/dist/cli/chunks/{validate-3GVKZOVF.js → validate-IL22VB5I.js} +2 -2
- package/dist/cli/chunks/{validate-swarm-XCRTLVM6.js → validate-swarm-WZKECK3W.js} +2 -2
- package/dist/cli/chunks/{vibium-CH4VPKVZ.js → vibium-KKM23OTQ.js} +2 -2
- package/dist/cli/chunks/visual-security-3TUC4GPP.js +2 -0
- package/dist/cli/chunks/{web-tree-sitter-JDBNAZTV.js → web-tree-sitter-NJM5YBOY.js} +2 -2
- package/dist/cli/chunks/{windsurf-installer-3MNPVJBP.js → windsurf-installer-SLP43TVT.js} +2 -2
- package/dist/cli/chunks/witness-chain-QLOKUZXC.js +2 -0
- package/dist/cli/chunks/{witness-chain-HR5UBV5J.js → witness-chain-XBEPT4XD.js} +2 -2
- package/dist/cli/chunks/{witness-key-manager-G5SQTIBZ.js → witness-key-manager-DAAMNYOW.js} +2 -2
- package/dist/cli/chunks/{workflow-43EMD5FY.js → workflow-SZOOU6D3.js} +4 -4
- package/dist/cli/chunks/workflow-orchestrator-6JAYTZ7L.js +2 -0
- package/dist/cli/chunks/{wrappers-3N7AYNM3.js → wrappers-I2CBKWGF.js} +2 -2
- package/dist/cli/commands/quality-gate.d.ts +24 -0
- package/dist/cli/commands/quality-gate.js +135 -0
- package/dist/cli/index.js +5 -0
- package/dist/coordination/mincut/dream-integration.d.ts +11 -0
- package/dist/coordination/mincut/dream-integration.js +39 -12
- package/dist/init/init-wizard-hooks.js +11 -25
- package/dist/init/phases/07-hooks.js +15 -25
- package/dist/init/settings-merge.d.ts +44 -0
- package/dist/init/settings-merge.js +119 -4
- package/dist/integrations/ruvector/feature-flags.js +7 -0
- package/dist/learning/pattern-lifecycle.d.ts +16 -0
- package/dist/learning/pattern-lifecycle.js +77 -1
- package/dist/learning/provenance-tier.d.ts +52 -0
- package/dist/learning/provenance-tier.js +64 -0
- package/dist/learning/qe-flywheel/corpus-scorer.d.ts +55 -0
- package/dist/learning/qe-flywheel/corpus-scorer.js +293 -0
- package/dist/learning/qe-flywheel/coupled-anchor.d.ts +91 -0
- package/dist/learning/qe-flywheel/coupled-anchor.js +181 -0
- package/dist/learning/qe-flywheel/generation.d.ts +121 -0
- package/dist/learning/qe-flywheel/generation.js +167 -0
- package/dist/learning/qe-flywheel/policy.d.ts +37 -0
- package/dist/learning/qe-flywheel/policy.js +66 -0
- package/dist/learning/qe-flywheel/receipt-store.d.ts +31 -0
- package/dist/learning/qe-flywheel/receipt-store.js +89 -0
- package/dist/learning/qe-flywheel/receipt.d.ts +62 -0
- package/dist/learning/qe-flywheel/receipt.js +97 -0
- package/dist/mcp/bundle.js +396 -390
- package/dist/mcp/tools/quality-assessment/gate.d.ts +38 -0
- package/dist/mcp/tools/quality-assessment/gate.js +86 -0
- package/dist/mcp/tools/registry.d.ts +1 -0
- package/dist/mcp/tools/registry.js +3 -0
- package/dist/shared/safe-db.js +23 -4
- package/dist/validation/anchor-set.d.ts +74 -0
- package/dist/validation/anchor-set.js +78 -0
- package/dist/validation/frontier-judge.d.ts +99 -0
- package/dist/validation/frontier-judge.js +234 -0
- package/dist/validation/gate-reexecute.d.ts +165 -0
- package/dist/validation/gate-reexecute.js +255 -0
- package/dist/validation/quality-gate-runner.d.ts +49 -0
- package/dist/validation/quality-gate-runner.js +62 -0
- package/dist/validation/quality-verdict.d.ts +94 -0
- package/dist/validation/quality-verdict.js +120 -0
- package/package.json +1 -1
- package/dist/cli/chunks/adapter-KNM5R47J.js +0 -2
- package/dist/cli/chunks/aqe-learning-engine-MXPJLVR3.js +0 -2
- package/dist/cli/chunks/base-X4EXQ2AS.js +0 -2
- package/dist/cli/chunks/browser-workflow-4HX6RP5F.js +0 -2
- package/dist/cli/chunks/chunk-FHTYEAQ3.js +0 -2
- package/dist/cli/chunks/chunk-MIU5RUBJ.js +0 -149
- package/dist/cli/chunks/chunk-SK754ZSH.js +0 -316
- package/dist/cli/chunks/chunk-V6NAB5UZ.js +0 -2
- package/dist/cli/chunks/chunk-YR2JKBZO.js +0 -2
- package/dist/cli/chunks/chunk-ZMPAM4DY.js +0 -2
- package/dist/cli/chunks/client-AHXNCOHK.js +0 -2
- package/dist/cli/chunks/core-handlers-EEFLLMAZ.js +0 -2
- package/dist/cli/chunks/cross-domain-router-LT3H4SNJ.js +0 -2
- package/dist/cli/chunks/dream-4K3BK4IG.js +0 -2
- package/dist/cli/chunks/heartbeat-scheduler-IMPPGQUK.js +0 -2
- package/dist/cli/chunks/hnsw-adapter-EIAA6R2L.js +0 -2
- package/dist/cli/chunks/hnsw-index-ZXXP6AXZ.js +0 -2
- package/dist/cli/chunks/hybrid-router-LXWG4MLH.js +0 -2
- package/dist/cli/chunks/impact-analyzer-TP5LRFYH.js +0 -2
- package/dist/cli/chunks/init-wizard-AIOA5KOY.js +0 -2
- package/dist/cli/chunks/kernel-SQALRU6Q.js +0 -2
- package/dist/cli/chunks/knowledge-graph-JFVT6SNN.js +0 -2
- package/dist/cli/chunks/llm-router-service-XHFKTH3I.js +0 -2
- package/dist/cli/chunks/load-test-JEIFJKNN.js +0 -2
- package/dist/cli/chunks/memory-backend-NT7I37CP.js +0 -2
- package/dist/cli/chunks/memory-handlers-746D7NE7.js +0 -2
- package/dist/cli/chunks/pattern-null-store-6QU6WHDW.js +0 -2
- package/dist/cli/chunks/protocol-executor-GT2MZYUU.js +0 -2
- package/dist/cli/chunks/provider-manager-OATJ7R3D.js +0 -2
- package/dist/cli/chunks/qe-reasoning-bank-IJXNQ67O.js +0 -2
- package/dist/cli/chunks/queen-coordinator-6RBHWCUG.js +0 -2
- package/dist/cli/chunks/router-XKQRT5JK.js +0 -2
- package/dist/cli/chunks/routing-feedback-ACPSD4LW.js +0 -2
- package/dist/cli/chunks/rvf-native-adapter-SIWRKE33.js +0 -2
- package/dist/cli/chunks/safe-db-LCPUYMX4.js +0 -2
- package/dist/cli/chunks/schedule-HIQJCWXG.js +0 -2
- package/dist/cli/chunks/scheduler-QE5EJ5LE.js +0 -2
- package/dist/cli/chunks/sqlite-persistence-EU54UTMH.js +0 -2
- package/dist/cli/chunks/unified-memory-CJLMC2I4.js +0 -2
- package/dist/cli/chunks/unified-memory-hnsw-FDGR4D2J.js +0 -2
- package/dist/cli/chunks/unified-persistence-UFH5GLDN.js +0 -2
- package/dist/cli/chunks/visual-security-4ARJ7J2Y.js +0 -2
- package/dist/cli/chunks/witness-chain-73QC33ED.js +0 -2
- package/dist/cli/chunks/workflow-orchestrator-RKMMPXNA.js +0 -2
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coupled anchor scorer — retrieval → test-gen → anchor (ADR-118 / ADR-117).
|
|
3
|
+
*
|
|
4
|
+
* In the retrieval-only wiring the anchor was policy-INDEPENDENT (a flat guard):
|
|
5
|
+
* the retrieval policy didn't feed test generation, so it couldn't move the
|
|
6
|
+
* oracle score, and the no-regression guard was inert. This closes that loop:
|
|
7
|
+
*
|
|
8
|
+
* retrieve(inputUnderTest, policy) → few-shot examples
|
|
9
|
+
* → generate(inputUnderTest, examples) → a test
|
|
10
|
+
* → evaluateOracle(referenceImpl, test) → mutation kill rate
|
|
11
|
+
*
|
|
12
|
+
* Now `anchorMean` VARIES with the retrieval policy — a policy that surfaces
|
|
13
|
+
* more useful examples yields better generated tests and a higher oracle score.
|
|
14
|
+
* The guard gets teeth: a candidate that games the cheap self-retrieval proxy
|
|
15
|
+
* but produces WORSE tests drops the anchor mean and is rejected (ADR-117
|
|
16
|
+
* no-regression), and the promotion is now genuinely oracle:test-exec-backed
|
|
17
|
+
* (ADR-121) rather than a framing stretch.
|
|
18
|
+
*
|
|
19
|
+
* `retrieve` and `generate` are injected seams: fake/deterministic in tests,
|
|
20
|
+
* a real policy-weighted DB retriever + an LLM test generator in production
|
|
21
|
+
* (the LLM step is the metered part — bind it deliberately).
|
|
22
|
+
*/
|
|
23
|
+
import { computeRealEmbedding } from '../real-embeddings.js';
|
|
24
|
+
import { evaluateOracle } from '../../validation/oracle-eval.js';
|
|
25
|
+
import { loadAnchorSet, anchorMean as meanOf } from '../../validation/anchor-set.js';
|
|
26
|
+
import { createCorpusScorer } from './corpus-scorer.js';
|
|
27
|
+
const DEFAULT_ANCHOR_PATH = new URL('../../../verification/anchors/qe-anchor-v1.json', import.meta.url).pathname;
|
|
28
|
+
/**
|
|
29
|
+
* Build the coupled anchorMean scorer: `(policy) => Promise<number>`.
|
|
30
|
+
* Grades each frozen anchor item by generating a test from policy-retrieved
|
|
31
|
+
* examples and scoring its mutation kill rate. The anchor now moves with the
|
|
32
|
+
* policy.
|
|
33
|
+
*/
|
|
34
|
+
export function createCoupledAnchorScorer(opts) {
|
|
35
|
+
const anchor = loadAnchorSet(opts.anchorPath ?? DEFAULT_ANCHOR_PATH);
|
|
36
|
+
const threshold = opts.threshold ?? 0.8;
|
|
37
|
+
return async (policy) => {
|
|
38
|
+
const scores = [];
|
|
39
|
+
for (const item of anchor.items) {
|
|
40
|
+
const examples = await opts.retrieve(item.inputUnderTest, policy);
|
|
41
|
+
const generatedTest = await opts.generate(item.inputUnderTest, examples);
|
|
42
|
+
const result = evaluateOracle({
|
|
43
|
+
moduleName: item.moduleName,
|
|
44
|
+
referenceImpl: item.referenceImpl,
|
|
45
|
+
generatedTest,
|
|
46
|
+
threshold,
|
|
47
|
+
maxMutants: opts.maxMutants,
|
|
48
|
+
});
|
|
49
|
+
scores.push(result.mutationScore);
|
|
50
|
+
}
|
|
51
|
+
return meanOf(scores);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A full PolicyScorer where `heldOut` is the cheap self-retrieval proxy (train
|
|
56
|
+
* signal) and `anchorMean` is the COUPLED oracle test-gen quality (the guard
|
|
57
|
+
* that now moves). The flywheel's accept() then requires a proxy gain WITHOUT an
|
|
58
|
+
* oracle-quality regression — the proxy-overfitting veto ADR-117 exists for.
|
|
59
|
+
*/
|
|
60
|
+
export function createCoupledScorer(opts) {
|
|
61
|
+
const heldOutScorer = createCorpusScorer({ db: opts.db, anchorPath: opts.anchorPath, heldOutRatio: opts.heldOutRatio });
|
|
62
|
+
const anchorScorer = createCoupledAnchorScorer(opts);
|
|
63
|
+
return async (policy) => {
|
|
64
|
+
// heldOut comes from the corpus scorer (its own anchorMean is the flat guard
|
|
65
|
+
// and is discarded here — the coupled anchor replaces it).
|
|
66
|
+
const heldOut = (await heldOutScorer(policy)).heldOut;
|
|
67
|
+
const anchorMean = await anchorScorer(policy);
|
|
68
|
+
return { heldOut, anchorMean };
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A real policy-weighted DB retriever over `qe_patterns` — token overlap on the
|
|
73
|
+
* query, scaled by the policy's body/subject weights, top-K by score. Read-only.
|
|
74
|
+
* Injected as `retrieve` for live runs; tests use a deterministic fake instead.
|
|
75
|
+
*/
|
|
76
|
+
export function createDbRetriever(db, topK = 3) {
|
|
77
|
+
const rows = db.prepare(`SELECT id, name, COALESCE(description,'') AS body FROM qe_patterns WHERE deprecated_at IS NULL`).all();
|
|
78
|
+
const toks = (s) => new Set(s.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean));
|
|
79
|
+
const docs = rows.map((r) => ({ ...r, nameToks: toks(r.name), bodyToks: toks(r.body) }));
|
|
80
|
+
return (query, policy) => {
|
|
81
|
+
const q = toks(query);
|
|
82
|
+
const scored = docs.map((d) => {
|
|
83
|
+
let s = 0;
|
|
84
|
+
for (const t of q) {
|
|
85
|
+
if (d.bodyToks.has(t))
|
|
86
|
+
s += policy.alpha * policy.bodyWeight;
|
|
87
|
+
if (d.nameToks.has(t))
|
|
88
|
+
s += (1 - policy.alpha) * policy.subjectWeight;
|
|
89
|
+
}
|
|
90
|
+
return { d, s };
|
|
91
|
+
});
|
|
92
|
+
return scored
|
|
93
|
+
.sort((a, b) => b.s - a.s || a.d.id.localeCompare(b.d.id))
|
|
94
|
+
.slice(0, topK)
|
|
95
|
+
.map(({ d }) => ({ id: d.id, name: d.name, body: d.body }));
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Semantic retriever — policy-sensitive retrieval over real pattern embeddings
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
/** Cosine similarity of two equal-length vectors. */
|
|
102
|
+
function cosine(a, b) {
|
|
103
|
+
let dot = 0, na = 0, nb = 0;
|
|
104
|
+
for (let i = 0; i < a.length; i++) {
|
|
105
|
+
dot += a[i] * b[i];
|
|
106
|
+
na += a[i] * a[i];
|
|
107
|
+
nb += b[i] * b[i];
|
|
108
|
+
}
|
|
109
|
+
const d = Math.sqrt(na * nb);
|
|
110
|
+
return d === 0 ? 0 : dot / d;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Policy-sensitive SEMANTIC retriever over the pre-computed `qe_pattern_embeddings`
|
|
114
|
+
* (all-MiniLM-L6-v2). Fixes the lexical retriever's honest-null: the anchor
|
|
115
|
+
* queries (toy functions) have ~0 lexical overlap with the corpus, so lexical
|
|
116
|
+
* scores were identical for every policy. Cosine similarity is a real, varying
|
|
117
|
+
* signal, and the policy re-shapes retrieval three ways:
|
|
118
|
+
* - `alpha` blends semantic cosine vs lexical overlap,
|
|
119
|
+
* - `subjectWeight`/`bodyWeight` scale the lexical component,
|
|
120
|
+
* - `mmrLambda` trades relevance for diversity in a greedy MMR rerank
|
|
121
|
+
* (this is the lever that reorders even when lexical overlap is 0).
|
|
122
|
+
* Query embeddings are cached (same query across policies embeds once).
|
|
123
|
+
*/
|
|
124
|
+
export function createSemanticRetriever(opts) {
|
|
125
|
+
const embed = opts.embed ?? ((t) => computeRealEmbedding(t));
|
|
126
|
+
const topK = opts.topK ?? 3;
|
|
127
|
+
const rows = opts.db.prepare(`SELECT p.id AS id, p.name AS name, COALESCE(p.description,'') AS body,
|
|
128
|
+
e.embedding AS embedding, e.dimension AS dimension
|
|
129
|
+
FROM qe_patterns p JOIN qe_pattern_embeddings e ON e.pattern_id = p.id
|
|
130
|
+
WHERE p.deprecated_at IS NULL`).all();
|
|
131
|
+
const toks = (s) => new Set(s.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean));
|
|
132
|
+
const docs = rows.map((r) => ({
|
|
133
|
+
id: r.id, name: r.name, body: r.body,
|
|
134
|
+
vec: new Float32Array(r.embedding.buffer, r.embedding.byteOffset, r.dimension),
|
|
135
|
+
nameToks: toks(r.name), bodyToks: toks(r.body),
|
|
136
|
+
}));
|
|
137
|
+
const queryCache = new Map();
|
|
138
|
+
return async (query, policy) => {
|
|
139
|
+
if (docs.length === 0)
|
|
140
|
+
return [];
|
|
141
|
+
let qv = queryCache.get(query);
|
|
142
|
+
if (!qv) {
|
|
143
|
+
qv = new Float32Array(await embed(query));
|
|
144
|
+
queryCache.set(query, qv);
|
|
145
|
+
}
|
|
146
|
+
const q = toks(query);
|
|
147
|
+
// relevance = alpha * semantic-cosine + (1-alpha) * weighted-lexical-overlap
|
|
148
|
+
const scored = docs.map((d) => {
|
|
149
|
+
const sem = cosine(qv, d.vec);
|
|
150
|
+
let lex = 0;
|
|
151
|
+
for (const t of q) {
|
|
152
|
+
if (d.bodyToks.has(t))
|
|
153
|
+
lex += policy.bodyWeight;
|
|
154
|
+
if (d.nameToks.has(t))
|
|
155
|
+
lex += policy.subjectWeight;
|
|
156
|
+
}
|
|
157
|
+
lex = lex / Math.max(1, q.size); // normalize to a comparable scale
|
|
158
|
+
return { d, rel: policy.alpha * sem + (1 - policy.alpha) * lex };
|
|
159
|
+
});
|
|
160
|
+
// greedy MMR rerank: mmrLambda trades relevance vs diversity (cosine between
|
|
161
|
+
// candidate embeddings). This reorders retrieval as the policy changes even
|
|
162
|
+
// when the lexical term is zero.
|
|
163
|
+
const lambda = policy.mmrLambda;
|
|
164
|
+
const remaining = scored.slice().sort((a, b) => b.rel - a.rel || a.d.id.localeCompare(b.d.id));
|
|
165
|
+
const chosen = [];
|
|
166
|
+
while (remaining.length > 0 && chosen.length < topK) {
|
|
167
|
+
let bestIdx = 0, bestScore = -Infinity;
|
|
168
|
+
for (let i = 0; i < remaining.length; i++) {
|
|
169
|
+
const sim = chosen.length === 0 ? 0 : Math.max(...chosen.map((c) => cosine(remaining[i].d.vec, c.d.vec)));
|
|
170
|
+
const mmr = lambda * remaining[i].rel - (1 - lambda) * sim;
|
|
171
|
+
if (mmr > bestScore || (mmr === bestScore && remaining[i].d.id.localeCompare(remaining[bestIdx].d.id) < 0)) {
|
|
172
|
+
bestScore = mmr;
|
|
173
|
+
bestIdx = i;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
chosen.push(remaining.splice(bestIdx, 1)[0]);
|
|
177
|
+
}
|
|
178
|
+
return chosen.map(({ d }) => ({ id: d.id, name: d.name, body: d.body }));
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=coupled-anchor.js.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QE-policy flywheel — the generational loop (ADR-118).
|
|
3
|
+
*
|
|
4
|
+
* One generation: score the baseline champion and a candidate, seal the decision
|
|
5
|
+
* inputs, re-execute the FROZEN accept() rule (ADR-120 `accept/v1`: held-out
|
|
6
|
+
* beats baseline ∧ anchor no-regression (ADR-117) ∧ oracle tier (ADR-121)),
|
|
7
|
+
* and emit an Ed25519-signed receipt into an append-only lineage. Promotions
|
|
8
|
+
* compound: each generation re-bases on the previous promoted champion.
|
|
9
|
+
*
|
|
10
|
+
* The corpus SCORER is injected — harvesting `qe_patterns` and running retrieval
|
|
11
|
+
* + grading the anchor is the DB/model-touching part, wired separately. This
|
|
12
|
+
* keeps the loop, gate, receipts, and lineage fully testable and deterministic.
|
|
13
|
+
*
|
|
14
|
+
* Honest-null (ADR-234): a generation — or a whole run — that promotes NOTHING
|
|
15
|
+
* is a correct, valid, replayable outcome, not a failure.
|
|
16
|
+
*/
|
|
17
|
+
import type { RetrievalPolicy } from './policy.js';
|
|
18
|
+
import { type EvolveReceipt, type Signer } from './receipt.js';
|
|
19
|
+
/** Scores for a policy on the harvested corpus + the frozen anchor. */
|
|
20
|
+
export interface PolicyScores {
|
|
21
|
+
/** Self-retrieval on the held-out split (the train/serve signal — never the accept signal alone). */
|
|
22
|
+
heldOut: number;
|
|
23
|
+
/** Mean over the ADR-117 frozen anchor items (the no-regression signal). */
|
|
24
|
+
anchorMean: number;
|
|
25
|
+
}
|
|
26
|
+
/** Injected: evaluate a policy → its held-out + anchor scores. */
|
|
27
|
+
export type PolicyScorer = (policy: RetrievalPolicy) => PolicyScores | Promise<PolicyScores>;
|
|
28
|
+
export interface HeadroomResult {
|
|
29
|
+
hasHeadroom: boolean;
|
|
30
|
+
baselineHeldOut: number;
|
|
31
|
+
baselineAnchorMean: number;
|
|
32
|
+
reason: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* ADR-118 §1 headroom precondition. If the baseline already saturates the
|
|
36
|
+
* held-out signal, the loop must NOT run — it would spend compute for
|
|
37
|
+
* structurally-zero promotions (the MetaHarness SWE-bench null).
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkHeadroom(baseline: RetrievalPolicy, scorer: PolicyScorer, saturation?: number): Promise<HeadroomResult>;
|
|
40
|
+
export interface GenerationInput {
|
|
41
|
+
generation: number;
|
|
42
|
+
baseline: RetrievalPolicy;
|
|
43
|
+
candidate: RetrievalPolicy;
|
|
44
|
+
scorer: PolicyScorer;
|
|
45
|
+
/** ADR-117 frozen anchor content hash (which anchor was graded). */
|
|
46
|
+
anchorHash: string;
|
|
47
|
+
/** No-regression tolerance (ADR-117 sign-off: 0.0). */
|
|
48
|
+
anchorTol: number;
|
|
49
|
+
/** Provenance tier of the corpus evidence (ADR-121). Only oracle-tier promotes. */
|
|
50
|
+
provenanceTier?: string;
|
|
51
|
+
/** Whether judge-tier promotion is explicitly budgeted (ADR-121). */
|
|
52
|
+
allowJudgeTier?: boolean;
|
|
53
|
+
signer: Signer;
|
|
54
|
+
/** Frozen rule version (default 'accept/v1'). */
|
|
55
|
+
ruleVersion?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface GenerationResult {
|
|
58
|
+
generation: number;
|
|
59
|
+
verdict: 'promote' | 'reject';
|
|
60
|
+
baselinePolicyId: string;
|
|
61
|
+
candidatePolicyId: string;
|
|
62
|
+
scores: {
|
|
63
|
+
baseline: PolicyScores;
|
|
64
|
+
candidate: PolicyScores;
|
|
65
|
+
};
|
|
66
|
+
receipt: EvolveReceipt;
|
|
67
|
+
/** The champion AFTER this generation: candidate if promoted, else baseline unchanged. */
|
|
68
|
+
champion: RetrievalPolicy;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Run one flywheel generation. Deterministic given the scorer and signer seed.
|
|
72
|
+
* Never mutates fleet state — it returns the verdict + a signed receipt; serving
|
|
73
|
+
* the champion is a separate, reversible step (serveChampion / rollback).
|
|
74
|
+
*/
|
|
75
|
+
export declare function runFlywheelGeneration(input: GenerationInput): Promise<GenerationResult>;
|
|
76
|
+
export interface LineageResult {
|
|
77
|
+
/** Number of PROMOTED generations. */
|
|
78
|
+
promotions: number;
|
|
79
|
+
/** Every promoted child re-based on its parent's promoted candidate (compounding). */
|
|
80
|
+
lineageIntact: boolean;
|
|
81
|
+
/** Every receipt's signature verifies AND its frozen gate re-executes to the recorded verdict. */
|
|
82
|
+
allReplayable: boolean;
|
|
83
|
+
reason: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Reconstruct + validate a lineage from an ordered receipt list (ADR-118 §4).
|
|
87
|
+
* Proves the chain compounds and every step is replayable — the property that
|
|
88
|
+
* makes a stub unable to launder a regression (a forged promote fails
|
|
89
|
+
* verifyPromotion; a broken chain fails lineageIntact).
|
|
90
|
+
*/
|
|
91
|
+
export declare function reconstructLineage(receipts: EvolveReceipt[]): LineageResult;
|
|
92
|
+
export interface ActivePolicy {
|
|
93
|
+
current: RetrievalPolicy;
|
|
94
|
+
currentId: string;
|
|
95
|
+
/** Rollback target — the policy served before `current`. */
|
|
96
|
+
previous: RetrievalPolicy | null;
|
|
97
|
+
previousId: string | null;
|
|
98
|
+
generation: number;
|
|
99
|
+
}
|
|
100
|
+
/** Initialize the active pointer at the gen-0 root policy. */
|
|
101
|
+
export declare function initActivePolicy(root: RetrievalPolicy): ActivePolicy;
|
|
102
|
+
/**
|
|
103
|
+
* Serve a newly-promoted champion, shifting the old current into `previous` as
|
|
104
|
+
* the rollback target (serve-then-shadow: the new policy is served, the old is
|
|
105
|
+
* retained one generation for the canary to fall back to).
|
|
106
|
+
*/
|
|
107
|
+
export declare function serveChampion(active: ActivePolicy, champion: RetrievalPolicy, generation: number): ActivePolicy;
|
|
108
|
+
/** Roll the active pointer back to its previous policy (drift-canary auto-rollback). */
|
|
109
|
+
export declare function rollback(active: ActivePolicy): ActivePolicy;
|
|
110
|
+
export interface DriftCanaryResult {
|
|
111
|
+
drifted: boolean;
|
|
112
|
+
reason: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Drift canary (ADR-118 §5, ruflo `:259-302`): re-score the served champion
|
|
116
|
+
* against its predecessor on a FRESH harvest; if EITHER the held-out or the
|
|
117
|
+
* anchor score drops below the predecessor, the promotion regressed in
|
|
118
|
+
* production and must be rolled back.
|
|
119
|
+
*/
|
|
120
|
+
export declare function checkDriftCanary(served: PolicyScores, predecessor: PolicyScores, tol?: number): DriftCanaryResult;
|
|
121
|
+
//# sourceMappingURL=generation.d.ts.map
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QE-policy flywheel — the generational loop (ADR-118).
|
|
3
|
+
*
|
|
4
|
+
* One generation: score the baseline champion and a candidate, seal the decision
|
|
5
|
+
* inputs, re-execute the FROZEN accept() rule (ADR-120 `accept/v1`: held-out
|
|
6
|
+
* beats baseline ∧ anchor no-regression (ADR-117) ∧ oracle tier (ADR-121)),
|
|
7
|
+
* and emit an Ed25519-signed receipt into an append-only lineage. Promotions
|
|
8
|
+
* compound: each generation re-bases on the previous promoted champion.
|
|
9
|
+
*
|
|
10
|
+
* The corpus SCORER is injected — harvesting `qe_patterns` and running retrieval
|
|
11
|
+
* + grading the anchor is the DB/model-touching part, wired separately. This
|
|
12
|
+
* keeps the loop, gate, receipts, and lineage fully testable and deterministic.
|
|
13
|
+
*
|
|
14
|
+
* Honest-null (ADR-234): a generation — or a whole run — that promotes NOTHING
|
|
15
|
+
* is a correct, valid, replayable outcome, not a failure.
|
|
16
|
+
*/
|
|
17
|
+
import { DEFAULT_PROVENANCE_TIER } from '../provenance-tier.js';
|
|
18
|
+
import { reExecuteGate, gateFingerprint, sealedHash, verifyPromotion, } from '../../validation/gate-reexecute.js';
|
|
19
|
+
import { policyId } from './policy.js';
|
|
20
|
+
import { signReceipt, verifyReceiptSignature, toPromotionReceipt, } from './receipt.js';
|
|
21
|
+
/**
|
|
22
|
+
* ADR-118 §1 headroom precondition. If the baseline already saturates the
|
|
23
|
+
* held-out signal, the loop must NOT run — it would spend compute for
|
|
24
|
+
* structurally-zero promotions (the MetaHarness SWE-bench null).
|
|
25
|
+
*/
|
|
26
|
+
export async function checkHeadroom(baseline, scorer, saturation = 0.999) {
|
|
27
|
+
const s = await scorer(baseline);
|
|
28
|
+
const hasHeadroom = s.heldOut < saturation;
|
|
29
|
+
return {
|
|
30
|
+
hasHeadroom,
|
|
31
|
+
baselineHeldOut: s.heldOut,
|
|
32
|
+
baselineAnchorMean: s.anchorMean,
|
|
33
|
+
reason: hasHeadroom
|
|
34
|
+
? `baseline held-out ${s.heldOut.toFixed(4)} < saturation ${saturation} — headroom exists`
|
|
35
|
+
: `baseline held-out ${s.heldOut.toFixed(4)} >= saturation ${saturation} — no headroom, loop must not run`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Run one flywheel generation. Deterministic given the scorer and signer seed.
|
|
40
|
+
* Never mutates fleet state — it returns the verdict + a signed receipt; serving
|
|
41
|
+
* the champion is a separate, reversible step (serveChampion / rollback).
|
|
42
|
+
*/
|
|
43
|
+
export async function runFlywheelGeneration(input) {
|
|
44
|
+
const ruleVersion = input.ruleVersion ?? 'accept/v1';
|
|
45
|
+
const provenanceTier = input.provenanceTier ?? DEFAULT_PROVENANCE_TIER;
|
|
46
|
+
const baselineScores = await input.scorer(input.baseline);
|
|
47
|
+
const candidateScores = await input.scorer(input.candidate);
|
|
48
|
+
const sealed = {
|
|
49
|
+
candidateHeldOut: candidateScores.heldOut,
|
|
50
|
+
baselineHeldOut: baselineScores.heldOut,
|
|
51
|
+
candidateAnchorMean: candidateScores.anchorMean,
|
|
52
|
+
baselineAnchorMean: baselineScores.anchorMean,
|
|
53
|
+
anchorHash: input.anchorHash,
|
|
54
|
+
anchorTol: input.anchorTol,
|
|
55
|
+
provenanceTier,
|
|
56
|
+
allowJudgeTier: input.allowJudgeTier,
|
|
57
|
+
};
|
|
58
|
+
const ruleResult = reExecuteGate(ruleVersion, sealed);
|
|
59
|
+
const verdict = ruleResult.promote ? 'promote' : 'reject';
|
|
60
|
+
const baselinePolicyId = policyId(input.baseline);
|
|
61
|
+
const candidatePolicyId = policyId(input.candidate);
|
|
62
|
+
const receipt = signReceipt({
|
|
63
|
+
generation: input.generation,
|
|
64
|
+
ruleVersion,
|
|
65
|
+
ruleFingerprint: gateFingerprint(ruleVersion),
|
|
66
|
+
sealed,
|
|
67
|
+
sealedHash: sealedHash(sealed),
|
|
68
|
+
verdict,
|
|
69
|
+
baselinePolicyId,
|
|
70
|
+
candidatePolicyId,
|
|
71
|
+
signerKeyId: input.signer.keyId,
|
|
72
|
+
publicKeyPem: input.signer.publicKeyPem,
|
|
73
|
+
}, input.signer);
|
|
74
|
+
return {
|
|
75
|
+
generation: input.generation,
|
|
76
|
+
verdict,
|
|
77
|
+
baselinePolicyId,
|
|
78
|
+
candidatePolicyId,
|
|
79
|
+
scores: { baseline: baselineScores, candidate: candidateScores },
|
|
80
|
+
receipt,
|
|
81
|
+
champion: verdict === 'promote' ? input.candidate : input.baseline,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Reconstruct + validate a lineage from an ordered receipt list (ADR-118 §4).
|
|
86
|
+
* Proves the chain compounds and every step is replayable — the property that
|
|
87
|
+
* makes a stub unable to launder a regression (a forged promote fails
|
|
88
|
+
* verifyPromotion; a broken chain fails lineageIntact).
|
|
89
|
+
*/
|
|
90
|
+
export function reconstructLineage(receipts) {
|
|
91
|
+
let promotions = 0;
|
|
92
|
+
let lineageIntact = true;
|
|
93
|
+
let allReplayable = true;
|
|
94
|
+
let lastPromotedCandidate = null;
|
|
95
|
+
for (const r of receipts) {
|
|
96
|
+
// Replayability: signature + frozen-rule re-execution (ADR-120).
|
|
97
|
+
if (!verifyReceiptSignature(r))
|
|
98
|
+
allReplayable = false;
|
|
99
|
+
const replay = verifyPromotion(toPromotionReceipt(r));
|
|
100
|
+
if (!replay.valid)
|
|
101
|
+
allReplayable = false;
|
|
102
|
+
if (r.verdict === 'promote') {
|
|
103
|
+
// A promoted generation must re-base on the previous promoted champion.
|
|
104
|
+
if (lastPromotedCandidate !== null && r.baselinePolicyId !== lastPromotedCandidate) {
|
|
105
|
+
lineageIntact = false;
|
|
106
|
+
}
|
|
107
|
+
lastPromotedCandidate = r.candidatePolicyId;
|
|
108
|
+
promotions++;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
promotions,
|
|
113
|
+
lineageIntact,
|
|
114
|
+
allReplayable,
|
|
115
|
+
reason: `${promotions} promotion(s); lineage ${lineageIntact ? 'intact' : 'BROKEN'}; `
|
|
116
|
+
+ `${allReplayable ? 'all replayable' : 'NOT all replayable'}`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Initialize the active pointer at the gen-0 root policy. */
|
|
120
|
+
export function initActivePolicy(root) {
|
|
121
|
+
return { current: root, currentId: policyId(root), previous: null, previousId: null, generation: 0 };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Serve a newly-promoted champion, shifting the old current into `previous` as
|
|
125
|
+
* the rollback target (serve-then-shadow: the new policy is served, the old is
|
|
126
|
+
* retained one generation for the canary to fall back to).
|
|
127
|
+
*/
|
|
128
|
+
export function serveChampion(active, champion, generation) {
|
|
129
|
+
return {
|
|
130
|
+
current: champion,
|
|
131
|
+
currentId: policyId(champion),
|
|
132
|
+
previous: active.current,
|
|
133
|
+
previousId: active.currentId,
|
|
134
|
+
generation,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** Roll the active pointer back to its previous policy (drift-canary auto-rollback). */
|
|
138
|
+
export function rollback(active) {
|
|
139
|
+
if (active.previous === null)
|
|
140
|
+
return active; // nothing to roll back to
|
|
141
|
+
return {
|
|
142
|
+
current: active.previous,
|
|
143
|
+
currentId: active.previousId,
|
|
144
|
+
previous: null,
|
|
145
|
+
previousId: null,
|
|
146
|
+
generation: active.generation,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Drift canary (ADR-118 §5, ruflo `:259-302`): re-score the served champion
|
|
151
|
+
* against its predecessor on a FRESH harvest; if EITHER the held-out or the
|
|
152
|
+
* anchor score drops below the predecessor, the promotion regressed in
|
|
153
|
+
* production and must be rolled back.
|
|
154
|
+
*/
|
|
155
|
+
export function checkDriftCanary(served, predecessor, tol = 0) {
|
|
156
|
+
const heldOutDrift = served.heldOut < predecessor.heldOut - tol;
|
|
157
|
+
const anchorDrift = served.anchorMean < predecessor.anchorMean - tol;
|
|
158
|
+
const drifted = heldOutDrift || anchorDrift;
|
|
159
|
+
return {
|
|
160
|
+
drifted,
|
|
161
|
+
reason: drifted
|
|
162
|
+
? `drift detected: ${heldOutDrift ? `held-out ${served.heldOut.toFixed(4)}<${predecessor.heldOut.toFixed(4)} ` : ''}`
|
|
163
|
+
+ `${anchorDrift ? `anchor ${served.anchorMean.toFixed(4)}<${predecessor.anchorMean.toFixed(4)}` : ''}`.trim()
|
|
164
|
+
: 'served champion holds vs predecessor — no rollback',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=generation.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieval policy — the hyperparameters the QE-policy flywheel tunes (ADR-118).
|
|
3
|
+
*
|
|
4
|
+
* The flywheel optimizes AQE's hybrid retrieval/selection policy over
|
|
5
|
+
* `qe_patterns` (the ruflo RetrievalConfig shape), one generation at a time,
|
|
6
|
+
* behind the frozen accept() gate. This module defines the policy and the
|
|
7
|
+
* candidate proposal; it does NOT touch the DB or evaluate anything (the scorer
|
|
8
|
+
* is injected in generation.ts).
|
|
9
|
+
*/
|
|
10
|
+
/** The tunable hybrid-retrieval hyperparameters. */
|
|
11
|
+
export interface RetrievalPolicy {
|
|
12
|
+
/** Dense/sparse blend weight [0,1]. */
|
|
13
|
+
alpha: number;
|
|
14
|
+
/** Weight on subject/title token match. */
|
|
15
|
+
subjectWeight: number;
|
|
16
|
+
/** Weight on body/content token match. */
|
|
17
|
+
bodyWeight: number;
|
|
18
|
+
/** MMR diversity vs relevance tradeoff [0,1]. */
|
|
19
|
+
mmrLambda: number;
|
|
20
|
+
/** Penalty factor for pattern-type mismatch [0,1]. */
|
|
21
|
+
typePenaltyFactor: number;
|
|
22
|
+
}
|
|
23
|
+
/** ADR-082 defaults — the gen-0 root policy. */
|
|
24
|
+
export declare const DEFAULT_POLICY: RetrievalPolicy;
|
|
25
|
+
/**
|
|
26
|
+
* Stable id of a policy — canonical (sorted-key, fixed-precision) hash. Two
|
|
27
|
+
* numerically-equal policies get the same id, so lineage links are exact.
|
|
28
|
+
*/
|
|
29
|
+
export declare function policyId(p: RetrievalPolicy): string;
|
|
30
|
+
/**
|
|
31
|
+
* Propose candidate policies around a baseline — a coarse ±step grid, one axis
|
|
32
|
+
* moved at a time (plus a floor of exploration on every axis). Later generations
|
|
33
|
+
* can bias this toward historically-effective axes (ruflo `biasedGrid`), but the
|
|
34
|
+
* gate is what makes any proposal safe, so a simple grid is a fine start.
|
|
35
|
+
*/
|
|
36
|
+
export declare function proposeCandidates(baseline: RetrievalPolicy, step?: number): RetrievalPolicy[];
|
|
37
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieval policy — the hyperparameters the QE-policy flywheel tunes (ADR-118).
|
|
3
|
+
*
|
|
4
|
+
* The flywheel optimizes AQE's hybrid retrieval/selection policy over
|
|
5
|
+
* `qe_patterns` (the ruflo RetrievalConfig shape), one generation at a time,
|
|
6
|
+
* behind the frozen accept() gate. This module defines the policy and the
|
|
7
|
+
* candidate proposal; it does NOT touch the DB or evaluate anything (the scorer
|
|
8
|
+
* is injected in generation.ts).
|
|
9
|
+
*/
|
|
10
|
+
import { createHash } from 'node:crypto';
|
|
11
|
+
/** ADR-082 defaults — the gen-0 root policy. */
|
|
12
|
+
export const DEFAULT_POLICY = {
|
|
13
|
+
alpha: 0.5,
|
|
14
|
+
subjectWeight: 1.0,
|
|
15
|
+
bodyWeight: 1.0,
|
|
16
|
+
mmrLambda: 0.5,
|
|
17
|
+
typePenaltyFactor: 0.1,
|
|
18
|
+
};
|
|
19
|
+
const AXES = ['alpha', 'subjectWeight', 'bodyWeight', 'mmrLambda', 'typePenaltyFactor'];
|
|
20
|
+
/** Clamp helper — keep weights in sane bounds so candidates stay well-formed. */
|
|
21
|
+
function clamp(v, lo, hi) {
|
|
22
|
+
return Math.min(hi, Math.max(lo, v));
|
|
23
|
+
}
|
|
24
|
+
const BOUNDS = {
|
|
25
|
+
alpha: [0, 1],
|
|
26
|
+
subjectWeight: [0, 4],
|
|
27
|
+
bodyWeight: [0, 4],
|
|
28
|
+
mmrLambda: [0, 1],
|
|
29
|
+
typePenaltyFactor: [0, 1],
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Stable id of a policy — canonical (sorted-key, fixed-precision) hash. Two
|
|
33
|
+
* numerically-equal policies get the same id, so lineage links are exact.
|
|
34
|
+
*/
|
|
35
|
+
export function policyId(p) {
|
|
36
|
+
const canon = AXES.map((k) => `${k}:${p[k].toFixed(6)}`).join('|');
|
|
37
|
+
return createHash('sha256').update(canon).digest('hex').slice(0, 16);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Propose candidate policies around a baseline — a coarse ±step grid, one axis
|
|
41
|
+
* moved at a time (plus a floor of exploration on every axis). Later generations
|
|
42
|
+
* can bias this toward historically-effective axes (ruflo `biasedGrid`), but the
|
|
43
|
+
* gate is what makes any proposal safe, so a simple grid is a fine start.
|
|
44
|
+
*/
|
|
45
|
+
export function proposeCandidates(baseline, step = 0.1) {
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const axis of AXES) {
|
|
48
|
+
for (const dir of [-1, 1]) {
|
|
49
|
+
const [lo, hi] = BOUNDS[axis];
|
|
50
|
+
const moved = clamp(baseline[axis] + dir * step, lo, hi);
|
|
51
|
+
if (moved === baseline[axis])
|
|
52
|
+
continue; // no-op at a bound
|
|
53
|
+
out.push({ ...baseline, [axis]: moved });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// de-dup by id (a bound can collapse two moves)
|
|
57
|
+
const seen = new Set();
|
|
58
|
+
return out.filter((p) => {
|
|
59
|
+
const id = policyId(p);
|
|
60
|
+
if (seen.has(id))
|
|
61
|
+
return false;
|
|
62
|
+
seen.add(id);
|
|
63
|
+
return true;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=policy.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable, append-only persistence for flywheel evolve receipts (ADR-118 §4).
|
|
3
|
+
*
|
|
4
|
+
* The generational lineage is only trustworthy if it survives the process: a
|
|
5
|
+
* third party must be able to reload the receipts and re-verify each one
|
|
6
|
+
* (signature + frozen-gate re-execution) offline. This stores every receipt —
|
|
7
|
+
* promoted OR rejected — in an append-only table in the unified `memory.db`.
|
|
8
|
+
*
|
|
9
|
+
* Data safety (unified-memory rule): CREATE TABLE IF NOT EXISTS is additive;
|
|
10
|
+
* writes are INSERT-only (no UPDATE/DELETE/DROP in this API); the caller opens
|
|
11
|
+
* the DB and is responsible for backups. The `db` handle is injected so tests
|
|
12
|
+
* run against an in-memory database.
|
|
13
|
+
*/
|
|
14
|
+
import type { Database as DatabaseType } from 'better-sqlite3';
|
|
15
|
+
import { type LineageResult } from './generation.js';
|
|
16
|
+
import type { EvolveReceipt } from './receipt.js';
|
|
17
|
+
/** Idempotent, additive migration — creates the receipts table if absent. */
|
|
18
|
+
export declare function ensureReceiptTable(db: DatabaseType): void;
|
|
19
|
+
/** Append one receipt (INSERT-only). Returns its assigned seq. */
|
|
20
|
+
export declare function persistReceipt(db: DatabaseType, receipt: EvolveReceipt): number;
|
|
21
|
+
/** Append many receipts in one transaction (still INSERT-only). */
|
|
22
|
+
export declare function persistReceipts(db: DatabaseType, receipts: EvolveReceipt[]): number;
|
|
23
|
+
/** Load persisted receipts back into EvolveReceipt objects, ordered by seq. */
|
|
24
|
+
export declare function loadReceipts(db: DatabaseType): EvolveReceipt[];
|
|
25
|
+
/**
|
|
26
|
+
* Reload the persisted lineage and re-verify it end-to-end (signatures +
|
|
27
|
+
* frozen-gate re-execution + compounding chain). This is the offline
|
|
28
|
+
* "trust the re-run, not the log" check applied to what's actually on disk.
|
|
29
|
+
*/
|
|
30
|
+
export declare function verifyPersistedLineage(db: DatabaseType): LineageResult;
|
|
31
|
+
//# sourceMappingURL=receipt-store.d.ts.map
|