@ebrindley/build 0.0.0-stage → 1.42.1-rc28
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/.build-project/providers/catalog.json +13951 -0
- package/.build-project/providers/pricing.json +1978 -0
- package/.build-project/providers/registry.json +4103 -0
- package/.github/SECURITY.md +75 -0
- package/.nvmrc +1 -0
- package/CHANGELOG.md +661 -0
- package/CODE_OF_CONDUCT.md +44 -0
- package/CONTRIBUTING.md +24 -0
- package/INSTALL.md +623 -0
- package/LICENSE +21 -0
- package/README.md +118 -2
- package/THIRD_PARTY_NOTICES.txt +26 -0
- package/dist/ai-judge-UE5UOYOO.js +191 -0
- package/dist/allowlist-grounding-KPLN6NC5.js +16 -0
- package/dist/allowlist-utils-MZZKKXRD.js +31 -0
- package/dist/apply-completion-mode-EM37UZHB.js +110 -0
- package/dist/artifact-migrator-WPACNSEP.js +276 -0
- package/dist/ask-2OZ4JFQR.js +176 -0
- package/dist/auth-6UKBTJUQ.js +185 -0
- package/dist/auth-H5KJL6HL.js +165 -0
- package/dist/auth-LVJRJDMU.js +12 -0
- package/dist/auth-NHZOCNRR.js +94 -0
- package/dist/auth-PBXHWXGW.js +95 -0
- package/dist/auth-T7Y5DCAH.js +91 -0
- package/dist/auth-TVVKCHQW.js +13 -0
- package/dist/auth-UHB2UCSS.js +97 -0
- package/dist/auth-VACA3VUL.js +98 -0
- package/dist/auth-VVLC77S3.js +44 -0
- package/dist/auth-liveness-XO4AGDDD.js +53 -0
- package/dist/autoloop-cleanup-SI3VGAAR.js +106 -0
- package/dist/autoloop-evidence-gates-J5GG5YQB.js +39 -0
- package/dist/autoloop-gate-policy-SUNAEP6Q.js +169 -0
- package/dist/autoloop-helpers-VQGQNTT6.js +52 -0
- package/dist/autoloop-ledger-P6TIDP7C.js +96 -0
- package/dist/autoloop-ledger-subscriber-HFAGOZXH.js +161 -0
- package/dist/autoloop-run-defaults-GWGZBNT7.js +27 -0
- package/dist/autoloop-run-lock-GBWRM5A2.js +197 -0
- package/dist/autoloop-success-C32QVWOP.js +93 -0
- package/dist/autoloop-termination-summary-GI6IBQWD.js +58 -0
- package/dist/autoloop-trajectory-AMKSQISD.js +70 -0
- package/dist/autoloop-wall-clock-T7ZVIQOC.js +12 -0
- package/dist/automatic-branch-cleanup-R62X2C5O.js +49 -0
- package/dist/autonomous-loop-controller-2WL363LW.js +4386 -0
- package/dist/backend-YUTFDZXZ.js +30 -0
- package/dist/background-executor-Z3ODTMD7.js +260 -0
- package/dist/backlog-75QPEAMW.js +403 -0
- package/dist/backlog-execution-intent-GWUV5TUK.js +19 -0
- package/dist/backup-active-store-XHWLN34M.js +16 -0
- package/dist/backup-machine-stores-UI4LTJOY.js +251 -0
- package/dist/backup-telemetry-db-Z4ICYCNW.js +26 -0
- package/dist/branch-archive-manager-FMSQ7YJF.js +18 -0
- package/dist/branch-cleanup-manager-ST6FJGND.js +35 -0
- package/dist/build-gate-7NKWPY62.js +68 -0
- package/dist/build-root-S7DINODY.js +18 -0
- package/dist/change-summary-R6CB6VXJ.js +50 -0
- package/dist/chunk-24MNKKOM.js +173 -0
- package/dist/chunk-2H6VZFIO.js +235 -0
- package/dist/chunk-2JIX3EKV.js +39 -0
- package/dist/chunk-2KO7HVZM.js +106 -0
- package/dist/chunk-2L36U25O.js +100 -0
- package/dist/chunk-2NMNFUQA.js +475 -0
- package/dist/chunk-2OUAEH67.js +83 -0
- package/dist/chunk-2VLJUXJU.js +115 -0
- package/dist/chunk-2VUEDIUM.js +77 -0
- package/dist/chunk-2Y2IIHPI.js +430 -0
- package/dist/chunk-2YRG3LHZ.js +220 -0
- package/dist/chunk-2Z5Q3SUY.js +65 -0
- package/dist/chunk-32IYXIE5.js +873 -0
- package/dist/chunk-33IGPPUI.js +292 -0
- package/dist/chunk-352PCJLK.js +283 -0
- package/dist/chunk-35J4NE6S.js +226 -0
- package/dist/chunk-3C7WBIVK.js +1016 -0
- package/dist/chunk-3H3EY6U7.js +1225 -0
- package/dist/chunk-3H4MWYIC.js +198 -0
- package/dist/chunk-3HHWQR3N.js +2479 -0
- package/dist/chunk-3JKNRYEE.js +14 -0
- package/dist/chunk-3LECCYZY.js +128 -0
- package/dist/chunk-3LOY6YZI.js +852 -0
- package/dist/chunk-3M57DADF.js +44 -0
- package/dist/chunk-3NOTLVLG.js +3803 -0
- package/dist/chunk-3OPP2OZB.js +1480 -0
- package/dist/chunk-3P5IN5E7.js +9 -0
- package/dist/chunk-3PL22IYZ.js +20 -0
- package/dist/chunk-3REDAJUJ.js +14 -0
- package/dist/chunk-3S2R4XJI.js +203 -0
- package/dist/chunk-3UBZI5DW.js +61 -0
- package/dist/chunk-3VV5OBGG.js +308 -0
- package/dist/chunk-3WY5TU2O.js +823 -0
- package/dist/chunk-43OKHTW4.js +82 -0
- package/dist/chunk-45KUJBDI.js +112 -0
- package/dist/chunk-47X5LM7B.js +224 -0
- package/dist/chunk-4B6FQJ77.js +268 -0
- package/dist/chunk-4BTDUT2S.js +42 -0
- package/dist/chunk-4DJL2VXA.js +24 -0
- package/dist/chunk-4EBSXZ73.js +48 -0
- package/dist/chunk-4QKP6I4C.js +294 -0
- package/dist/chunk-4U6XK2DG.js +300 -0
- package/dist/chunk-4UMRUFBD.js +132 -0
- package/dist/chunk-4US4SYJ4.js +569 -0
- package/dist/chunk-4ZPLWEZO.js +154 -0
- package/dist/chunk-56WPYDJH.js +624 -0
- package/dist/chunk-57WRCJJW.js +50 -0
- package/dist/chunk-5AW4RMNG.js +24 -0
- package/dist/chunk-5EQN56OZ.js +155 -0
- package/dist/chunk-5F43TUIN.js +38 -0
- package/dist/chunk-5FKHIKTS.js +115 -0
- package/dist/chunk-5HDP7XZG.js +91 -0
- package/dist/chunk-5KQETTNS.js +152 -0
- package/dist/chunk-5PDVN2KO.js +498 -0
- package/dist/chunk-5UBIFVRD.js +509 -0
- package/dist/chunk-5YDE3Q62.js +46 -0
- package/dist/chunk-626AJVMU.js +302 -0
- package/dist/chunk-633XZ7UF.js +3583 -0
- package/dist/chunk-63DHNHGA.js +236 -0
- package/dist/chunk-666656AR.js +568 -0
- package/dist/chunk-67YRJPJO.js +19 -0
- package/dist/chunk-6CAU7VBA.js +20 -0
- package/dist/chunk-6CB3KJRY.js +21 -0
- package/dist/chunk-6DBMALXL.js +29 -0
- package/dist/chunk-6E25C4IA.js +269 -0
- package/dist/chunk-6FIBNIQU.js +73 -0
- package/dist/chunk-6G57FYBV.js +189 -0
- package/dist/chunk-6KZKRTG3.js +4885 -0
- package/dist/chunk-6LAH2UV2.js +525 -0
- package/dist/chunk-6PZY2TTU.js +921 -0
- package/dist/chunk-6T6NHXK4.js +230 -0
- package/dist/chunk-6TBEX4R4.js +432 -0
- package/dist/chunk-6TRD7TEE.js +911 -0
- package/dist/chunk-6XCP2RAI.js +47 -0
- package/dist/chunk-726G6WDL.js +351 -0
- package/dist/chunk-75EMT7BF.js +616 -0
- package/dist/chunk-762ACDZJ.js +4696 -0
- package/dist/chunk-77I6G4CO.js +1 -0
- package/dist/chunk-7DJ6SQH3.js +510 -0
- package/dist/chunk-7HPCIOMA.js +1383 -0
- package/dist/chunk-7HYBSRPZ.js +17503 -0
- package/dist/chunk-7KBEOPVB.js +73 -0
- package/dist/chunk-7LHJDJB3.js +2222 -0
- package/dist/chunk-7NVJMH52.js +306 -0
- package/dist/chunk-7RMARDVH.js +33 -0
- package/dist/chunk-7SEWU4QG.js +36 -0
- package/dist/chunk-7TUTZTI2.js +911 -0
- package/dist/chunk-7VBDFPUM.js +340 -0
- package/dist/chunk-7VRJHTGZ.js +6406 -0
- package/dist/chunk-7YAOUUKK.js +493 -0
- package/dist/chunk-AAAODV76.js +860 -0
- package/dist/chunk-AB4HUJVQ.js +339 -0
- package/dist/chunk-AEQWV746.js +611 -0
- package/dist/chunk-AHU3FKPA.js +11639 -0
- package/dist/chunk-AISTV5XU.js +226 -0
- package/dist/chunk-AJBTKGJZ.js +48 -0
- package/dist/chunk-AJJNW7XT.js +248 -0
- package/dist/chunk-AJN5Y5YZ.js +160 -0
- package/dist/chunk-ALDTFNZ3.js +150 -0
- package/dist/chunk-ARARVIZK.js +281 -0
- package/dist/chunk-ATBM6AW5.js +53 -0
- package/dist/chunk-ATKEKM3E.js +206 -0
- package/dist/chunk-AUJLW6JZ.js +92 -0
- package/dist/chunk-AY3MHEFM.js +24 -0
- package/dist/chunk-B7PYTV72.js +236 -0
- package/dist/chunk-B7YRSULE.js +1423 -0
- package/dist/chunk-BAWJNMWF.js +339 -0
- package/dist/chunk-BBPIILO2.js +88 -0
- package/dist/chunk-BD3PGW6A.js +957 -0
- package/dist/chunk-BDPYFAB4.js +44 -0
- package/dist/chunk-BIUV23HH.js +729 -0
- package/dist/chunk-BQ3VAGXH.js +243 -0
- package/dist/chunk-BQJOGAWT.js +31 -0
- package/dist/chunk-BT7EG7CO.js +68 -0
- package/dist/chunk-BV3XQQLU.js +27 -0
- package/dist/chunk-BY6ODHNZ.js +78 -0
- package/dist/chunk-BZRLSZNV.js +79 -0
- package/dist/chunk-C3DH3NCY.js +2773 -0
- package/dist/chunk-C3KCMAJP.js +756 -0
- package/dist/chunk-C7AGUJ5K.js +267 -0
- package/dist/chunk-CBSWKQCX.js +342 -0
- package/dist/chunk-CE5OZBYY.js +21 -0
- package/dist/chunk-CFCVYHSW.js +373 -0
- package/dist/chunk-CHA2HDE5.js +126 -0
- package/dist/chunk-CIHWPGS5.js +146 -0
- package/dist/chunk-CJBSZX3F.js +127 -0
- package/dist/chunk-CLA6QIJM.js +43 -0
- package/dist/chunk-CPSVQR2I.js +365 -0
- package/dist/chunk-CRPRVNQ4.js +254 -0
- package/dist/chunk-CSIE4Y7C.js +1093 -0
- package/dist/chunk-CSOPSYDY.js +142 -0
- package/dist/chunk-CSXLLEGB.js +205 -0
- package/dist/chunk-CTDLERWU.js +293 -0
- package/dist/chunk-CULBXMSK.js +110 -0
- package/dist/chunk-D2M2Y5ID.js +21 -0
- package/dist/chunk-D37WY7SH.js +1060 -0
- package/dist/chunk-D4VJFCGZ.js +89 -0
- package/dist/chunk-D6WTZMZB.js +48 -0
- package/dist/chunk-DBHOWDUH.js +976 -0
- package/dist/chunk-DCACX7BV.js +19364 -0
- package/dist/chunk-DFHX4XYA.js +128 -0
- package/dist/chunk-DIKBRRKE.js +176 -0
- package/dist/chunk-DJG5RIOR.js +9 -0
- package/dist/chunk-DNIOIISW.js +616 -0
- package/dist/chunk-DOA5G7IA.js +315 -0
- package/dist/chunk-DP7FKP6W.js +855 -0
- package/dist/chunk-DS2JZ677.js +79 -0
- package/dist/chunk-DSRLVYBS.js +82 -0
- package/dist/chunk-EAEVKNJA.js +209 -0
- package/dist/chunk-EEUESN3T.js +575 -0
- package/dist/chunk-EJ4LUU5Y.js +73 -0
- package/dist/chunk-EJIWTPSZ.js +1063 -0
- package/dist/chunk-EJVCDTAN.js +116 -0
- package/dist/chunk-EKLUBDBQ.js +627 -0
- package/dist/chunk-EN62WLFD.js +849 -0
- package/dist/chunk-ENYRCL43.js +26 -0
- package/dist/chunk-EP22ZMFO.js +273 -0
- package/dist/chunk-EP4SVAVI.js +87 -0
- package/dist/chunk-EPAMVGI3.js +1562 -0
- package/dist/chunk-EPRMH6HO.js +24 -0
- package/dist/chunk-ES6NWJ36.js +4057 -0
- package/dist/chunk-ETA2K4KI.js +30 -0
- package/dist/chunk-ETAD4NKD.js +31 -0
- package/dist/chunk-EUWIIDQ7.js +93 -0
- package/dist/chunk-EVE3OD2W.js +141 -0
- package/dist/chunk-EXA26FFC.js +459 -0
- package/dist/chunk-EXSPAA35.js +244 -0
- package/dist/chunk-F55YABKV.js +258 -0
- package/dist/chunk-F5DNGU5W.js +27 -0
- package/dist/chunk-F622MJYV.js +103 -0
- package/dist/chunk-F6NIQD74.js +5111 -0
- package/dist/chunk-FAWJTC34.js +43 -0
- package/dist/chunk-FAZBRHGG.js +47 -0
- package/dist/chunk-FIEUSGNJ.js +39 -0
- package/dist/chunk-FKCG7K6H.js +1146 -0
- package/dist/chunk-FOVVXV45.js +229 -0
- package/dist/chunk-FRBPKBFE.js +30 -0
- package/dist/chunk-FSA5BPFI.js +268 -0
- package/dist/chunk-FSJ5TTZ3.js +29 -0
- package/dist/chunk-FT7SGLXT.js +193 -0
- package/dist/chunk-FUUVZZUB.js +62 -0
- package/dist/chunk-FYMRVUNZ.js +1697 -0
- package/dist/chunk-FYTAA5FG.js +162 -0
- package/dist/chunk-G3VB2UCZ.js +3892 -0
- package/dist/chunk-G6OIMVXH.js +405 -0
- package/dist/chunk-G7PQCXVH.js +228 -0
- package/dist/chunk-GAB6UW52.js +1087 -0
- package/dist/chunk-GAFJEYLK.js +29 -0
- package/dist/chunk-GC4CRMTS.js +642 -0
- package/dist/chunk-GFHSIWHL.js +5297 -0
- package/dist/chunk-GI5M67YA.js +735 -0
- package/dist/chunk-GIJWHUWF.js +191 -0
- package/dist/chunk-GO6DRECI.js +1 -0
- package/dist/chunk-GOFVBTMN.js +314 -0
- package/dist/chunk-GQIP72ZJ.js +13 -0
- package/dist/chunk-GQXLXRFA.js +28 -0
- package/dist/chunk-GT6HFKJB.js +48 -0
- package/dist/chunk-GVJGSSKM.js +174 -0
- package/dist/chunk-GWHGTG37.js +36 -0
- package/dist/chunk-GZAJHLKO.js +18 -0
- package/dist/chunk-GZK62I3N.js +314 -0
- package/dist/chunk-H3HGMISG.js +483 -0
- package/dist/chunk-H3ISZJMJ.js +403 -0
- package/dist/chunk-H4HXVWEC.js +9 -0
- package/dist/chunk-H6MJGKAW.js +120 -0
- package/dist/chunk-HBTTGVR5.js +353 -0
- package/dist/chunk-HBZ322WZ.js +35 -0
- package/dist/chunk-HEP3ILP4.js +34 -0
- package/dist/chunk-HGFXODKO.js +106 -0
- package/dist/chunk-HHWDTB6S.js +59 -0
- package/dist/chunk-HKO45NLZ.js +286 -0
- package/dist/chunk-HLVTEA6A.js +89 -0
- package/dist/chunk-HS3SY6HN.js +160 -0
- package/dist/chunk-HT5OCGKN.js +899 -0
- package/dist/chunk-HXIIEMGF.js +78 -0
- package/dist/chunk-I56TH7VM.js +46 -0
- package/dist/chunk-I6FN3R5D.js +352 -0
- package/dist/chunk-I7SCBHJN.js +655 -0
- package/dist/chunk-IJM4GKAT.js +529 -0
- package/dist/chunk-IMEYU36R.js +344 -0
- package/dist/chunk-INJ3SS6A.js +936 -0
- package/dist/chunk-IUKOPCCE.js +441 -0
- package/dist/chunk-IVEPZQJO.js +33 -0
- package/dist/chunk-IVZEONFC.js +43 -0
- package/dist/chunk-IWBHRSG7.js +936 -0
- package/dist/chunk-IYY3HQAD.js +484 -0
- package/dist/chunk-J2ICMYDA.js +48 -0
- package/dist/chunk-J2QCFLUN.js +505 -0
- package/dist/chunk-J5HM6V5P.js +1039 -0
- package/dist/chunk-J6NZX6QH.js +398 -0
- package/dist/chunk-JBBB2Y47.js +432 -0
- package/dist/chunk-JDCZQZU7.js +42 -0
- package/dist/chunk-JEDNXGSS.js +169 -0
- package/dist/chunk-JHP7OT6K.js +89 -0
- package/dist/chunk-JLS65NUQ.js +14 -0
- package/dist/chunk-JNMWYMC6.js +38 -0
- package/dist/chunk-JNSTWNNW.js +25 -0
- package/dist/chunk-JOSK6GEU.js +9564 -0
- package/dist/chunk-JQUMSIGC.js +100 -0
- package/dist/chunk-JVHGMURQ.js +1106 -0
- package/dist/chunk-JYXS47FQ.js +951 -0
- package/dist/chunk-K2ZMW2Z5.js +2147 -0
- package/dist/chunk-K7FAFORM.js +14 -0
- package/dist/chunk-KBJXX3ON.js +333 -0
- package/dist/chunk-KHFKVQWY.js +486 -0
- package/dist/chunk-KHMEI3DQ.js +173 -0
- package/dist/chunk-KHW3UD7B.js +69 -0
- package/dist/chunk-KKQKWAMF.js +365 -0
- package/dist/chunk-KOKXJV2U.js +455 -0
- package/dist/chunk-KQ4NGOJI.js +14 -0
- package/dist/chunk-KQYQOXMS.js +342 -0
- package/dist/chunk-KTMW65UX.js +14 -0
- package/dist/chunk-KUEWV2JH.js +593 -0
- package/dist/chunk-KXYDV3HP.js +1523 -0
- package/dist/chunk-KZ4JMGZ5.js +96 -0
- package/dist/chunk-KZWGBUIO.js +2659 -0
- package/dist/chunk-L2CBG5IX.js +1892 -0
- package/dist/chunk-L2S235CU.js +314 -0
- package/dist/chunk-L32WD57F.js +98 -0
- package/dist/chunk-LDJCKAJP.js +123 -0
- package/dist/chunk-LDWNBEN7.js +541 -0
- package/dist/chunk-LJVH57G2.js +241 -0
- package/dist/chunk-LPQ7NZEN.js +209 -0
- package/dist/chunk-LRGH3CCV.js +148 -0
- package/dist/chunk-LULOGMMM.js +1133 -0
- package/dist/chunk-LWGKN2GY.js +8284 -0
- package/dist/chunk-LX4F24ZH.js +157 -0
- package/dist/chunk-M4BUEXXF.js +839 -0
- package/dist/chunk-M6UHOC4I.js +553 -0
- package/dist/chunk-MCBNWZNO.js +657 -0
- package/dist/chunk-MEMSY6VY.js +223 -0
- package/dist/chunk-MHLEZQQI.js +145 -0
- package/dist/chunk-MJ6WNSIX.js +192 -0
- package/dist/chunk-MKASIKWZ.js +442 -0
- package/dist/chunk-MNOVBYFU.js +60 -0
- package/dist/chunk-MO2BYAAF.js +2896 -0
- package/dist/chunk-MP6P7Y2A.js +180 -0
- package/dist/chunk-MQ4TFJAG.js +3365 -0
- package/dist/chunk-MT2WAIR3.js +131 -0
- package/dist/chunk-MTU7VTNN.js +1122 -0
- package/dist/chunk-MULMXX4V.js +150 -0
- package/dist/chunk-MW2DWWVA.js +147 -0
- package/dist/chunk-MY3ZPUN4.js +151 -0
- package/dist/chunk-MYLH2S4G.js +64 -0
- package/dist/chunk-MZ5WYKNA.js +28 -0
- package/dist/chunk-N3Q2JNPV.js +249 -0
- package/dist/chunk-N5DX4JAK.js +12 -0
- package/dist/chunk-NAINGKHF.js +35 -0
- package/dist/chunk-NEQUQHOX.js +223 -0
- package/dist/chunk-NHNPEZS4.js +1408 -0
- package/dist/chunk-NHTIXJCR.js +17 -0
- package/dist/chunk-NKLPMBNV.js +1154 -0
- package/dist/chunk-NMVZ5YES.js +199 -0
- package/dist/chunk-NRFRY3GE.js +256 -0
- package/dist/chunk-NTD6CSI6.js +1266 -0
- package/dist/chunk-NUO7B3SH.js +318 -0
- package/dist/chunk-NVOHIJKG.js +1319 -0
- package/dist/chunk-NXH3RX7O.js +523 -0
- package/dist/chunk-NXZ3DURF.js +257 -0
- package/dist/chunk-O26L6F7F.js +209 -0
- package/dist/chunk-O5RRIUEP.js +124 -0
- package/dist/chunk-O5X6BKAO.js +10 -0
- package/dist/chunk-O6ZQUVTR.js +31 -0
- package/dist/chunk-O7FE75QZ.js +306 -0
- package/dist/chunk-OC7Z6AJQ.js +81 -0
- package/dist/chunk-OH7IEZ63.js +307 -0
- package/dist/chunk-OI734GRS.js +115 -0
- package/dist/chunk-OJBH62DK.js +684 -0
- package/dist/chunk-OKJLVSTJ.js +247 -0
- package/dist/chunk-OMX5VL43.js +79 -0
- package/dist/chunk-ONHAMBN6.js +12 -0
- package/dist/chunk-ONYPLIVE.js +753 -0
- package/dist/chunk-OSK7QWPD.js +637 -0
- package/dist/chunk-OTXLMJKP.js +438 -0
- package/dist/chunk-OV5PKQMA.js +213 -0
- package/dist/chunk-OXK5HA4B.js +31 -0
- package/dist/chunk-OYDWFQA4.js +272 -0
- package/dist/chunk-OZAUKWHB.js +22 -0
- package/dist/chunk-P5P2EKGH.js +94 -0
- package/dist/chunk-P6SSWAKY.js +29 -0
- package/dist/chunk-P7CQGPLS.js +30 -0
- package/dist/chunk-P7RVCHQV.js +197 -0
- package/dist/chunk-PEBWDYIW.js +726 -0
- package/dist/chunk-PFCXFO7A.js +9193 -0
- package/dist/chunk-PFLDWMX6.js +168 -0
- package/dist/chunk-PHZGLQSK.js +15883 -0
- package/dist/chunk-PNFTPNSR.js +20 -0
- package/dist/chunk-PPHXX4W7.js +175 -0
- package/dist/chunk-PPZESPJT.js +262 -0
- package/dist/chunk-PRDHI2L5.js +296 -0
- package/dist/chunk-PSTKWHHN.js +32 -0
- package/dist/chunk-PV53ODOT.js +555 -0
- package/dist/chunk-PVJBTI7P.js +24 -0
- package/dist/chunk-PXKERBKX.js +100 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-Q3DHEZA5.js +85 -0
- package/dist/chunk-Q5RZDVQK.js +204 -0
- package/dist/chunk-Q64IR2Z2.js +4933 -0
- package/dist/chunk-Q6Z5UGPL.js +398 -0
- package/dist/chunk-QAMAV4DT.js +627 -0
- package/dist/chunk-QBWF4444.js +112 -0
- package/dist/chunk-QDKYT4CI.js +22805 -0
- package/dist/chunk-QFLBRWCJ.js +126 -0
- package/dist/chunk-QILAQACE.js +107 -0
- package/dist/chunk-QJ6OEH4K.js +3683 -0
- package/dist/chunk-QK3NLYTV.js +320 -0
- package/dist/chunk-QOFLUS24.js +535 -0
- package/dist/chunk-QOIASNEJ.js +98 -0
- package/dist/chunk-QP4UTSOV.js +3587 -0
- package/dist/chunk-QP5ST7RI.js +904 -0
- package/dist/chunk-QS5AGRZN.js +167 -0
- package/dist/chunk-QTAOU53N.js +107 -0
- package/dist/chunk-QTCLJHLZ.js +351 -0
- package/dist/chunk-QTOLTG4L.js +119 -0
- package/dist/chunk-QWDV4OSL.js +142 -0
- package/dist/chunk-QWMQ74KD.js +508 -0
- package/dist/chunk-QX6LOMMH.js +158 -0
- package/dist/chunk-QXBKIHY7.js +238 -0
- package/dist/chunk-QXBKTJT6.js +270 -0
- package/dist/chunk-QYQOVOLR.js +196 -0
- package/dist/chunk-R2CKS6WT.js +73 -0
- package/dist/chunk-R2TIYG7U.js +68 -0
- package/dist/chunk-R2W3LESH.js +465 -0
- package/dist/chunk-R5EXHMUN.js +100 -0
- package/dist/chunk-RBBTBCHX.js +289 -0
- package/dist/chunk-RBKLOUXA.js +121 -0
- package/dist/chunk-RCP2Y6DQ.js +86 -0
- package/dist/chunk-RCYEJSD5.js +260 -0
- package/dist/chunk-RFDVSI4N.js +134 -0
- package/dist/chunk-RGJU63FV.js +1717 -0
- package/dist/chunk-RI4EX2QE.js +18 -0
- package/dist/chunk-RIMARPCF.js +152 -0
- package/dist/chunk-RJ6RSNT6.js +42 -0
- package/dist/chunk-RNI2GUIF.js +131 -0
- package/dist/chunk-RPHUWJ3K.js +264 -0
- package/dist/chunk-RPIMAMV7.js +361 -0
- package/dist/chunk-RQFX6YRN.js +49 -0
- package/dist/chunk-RRC5BL7B.js +285 -0
- package/dist/chunk-RSYTSBOO.js +79 -0
- package/dist/chunk-RWQQIKIC.js +35 -0
- package/dist/chunk-RZUBOZH2.js +373 -0
- package/dist/chunk-S2E632FQ.js +380 -0
- package/dist/chunk-S2VQCZO4.js +22 -0
- package/dist/chunk-S2XIMQJQ.js +681 -0
- package/dist/chunk-S47ISY27.js +183 -0
- package/dist/chunk-S6I4KISU.js +142 -0
- package/dist/chunk-S6TAFQI5.js +2403 -0
- package/dist/chunk-SBBNT5ZJ.js +27 -0
- package/dist/chunk-SDJV2DTQ.js +491 -0
- package/dist/chunk-SDPIFNLD.js +33 -0
- package/dist/chunk-SF6YK3JI.js +835 -0
- package/dist/chunk-SK3ZFONO.js +976 -0
- package/dist/chunk-SKTFRFQ7.js +1775 -0
- package/dist/chunk-SNGM452K.js +2002 -0
- package/dist/chunk-STW7OFOA.js +581 -0
- package/dist/chunk-SU6UFUQY.js +1351 -0
- package/dist/chunk-SVJM3LJA.js +27 -0
- package/dist/chunk-SVUNZOPG.js +129 -0
- package/dist/chunk-T5XLUYV3.js +34 -0
- package/dist/chunk-T7E5JS6N.js +57 -0
- package/dist/chunk-TA3N5MMO.js +450 -0
- package/dist/chunk-TAJPCXSB.js +13 -0
- package/dist/chunk-TDEMDRN2.js +1639 -0
- package/dist/chunk-TDSEX5CF.js +24 -0
- package/dist/chunk-TGCVL74Y.js +28 -0
- package/dist/chunk-TGXXYDL4.js +1012 -0
- package/dist/chunk-TIKTYUJO.js +296 -0
- package/dist/chunk-TIZAJD4M.js +6029 -0
- package/dist/chunk-TLSEZZCG.js +5549 -0
- package/dist/chunk-TMBDRHAX.js +19 -0
- package/dist/chunk-TRURQUBP.js +1217 -0
- package/dist/chunk-TSQ256N5.js +152 -0
- package/dist/chunk-TUQMMFEQ.js +2244 -0
- package/dist/chunk-U424MJLC.js +81 -0
- package/dist/chunk-U4DRS6ZW.js +11 -0
- package/dist/chunk-U5KS22IN.js +204 -0
- package/dist/chunk-UAPHFJPN.js +673 -0
- package/dist/chunk-UB7LQITD.js +1040 -0
- package/dist/chunk-UBVRHGAZ.js +237 -0
- package/dist/chunk-UDNNAQN5.js +98 -0
- package/dist/chunk-UJP3XM54.js +342 -0
- package/dist/chunk-UJYDH2MW.js +305 -0
- package/dist/chunk-UKMPASIC.js +399 -0
- package/dist/chunk-UKUL3EHK.js +763 -0
- package/dist/chunk-UPHU64NB.js +1327 -0
- package/dist/chunk-URMSZXAD.js +43 -0
- package/dist/chunk-US3RT6CY.js +525 -0
- package/dist/chunk-UTDEOPKV.js +30 -0
- package/dist/chunk-UUUDKV7N.js +13 -0
- package/dist/chunk-UVKWU3SM.js +39 -0
- package/dist/chunk-V2TVPO3X.js +521 -0
- package/dist/chunk-V3KLVK7B.js +398 -0
- package/dist/chunk-V3YFFHDR.js +17 -0
- package/dist/chunk-VAG6GUBR.js +1162 -0
- package/dist/chunk-VBENAHDA.js +1814 -0
- package/dist/chunk-VBNCKCCI.js +16 -0
- package/dist/chunk-VCGSWN5M.js +1300 -0
- package/dist/chunk-VE2O2I7M.js +115 -0
- package/dist/chunk-VIFHYTI5.js +31 -0
- package/dist/chunk-VJER3FUS.js +5080 -0
- package/dist/chunk-VLMDM56Q.js +268 -0
- package/dist/chunk-VMFZEVVX.js +99 -0
- package/dist/chunk-VNDPQVUZ.js +1853 -0
- package/dist/chunk-VSPJRLGA.js +4783 -0
- package/dist/chunk-VSWC5ZXI.js +103 -0
- package/dist/chunk-VYI4DSZP.js +2017 -0
- package/dist/chunk-W4BAIQ6L.js +1212 -0
- package/dist/chunk-W7VQAL2K.js +2203 -0
- package/dist/chunk-WEI3ZDZH.js +33 -0
- package/dist/chunk-WEIUS5NT.js +26 -0
- package/dist/chunk-WEW7UFWE.js +546 -0
- package/dist/chunk-WGQAXLNA.js +384 -0
- package/dist/chunk-WJAL4JL3.js +206 -0
- package/dist/chunk-WKFOJ5ZG.js +141 -0
- package/dist/chunk-WMWQEFLN.js +2177 -0
- package/dist/chunk-WNECKKO2.js +154 -0
- package/dist/chunk-WPKLYOAM.js +195 -0
- package/dist/chunk-WSH37YQN.js +243 -0
- package/dist/chunk-WV3KQDPE.js +84 -0
- package/dist/chunk-WZFC4V4U.js +389 -0
- package/dist/chunk-XCOIBNET.js +13 -0
- package/dist/chunk-XDM65LBX.js +53 -0
- package/dist/chunk-XGU6PBO5.js +645 -0
- package/dist/chunk-XHOI4V62.js +43 -0
- package/dist/chunk-XIBVFMLQ.js +6858 -0
- package/dist/chunk-XJ2E7YEJ.js +117 -0
- package/dist/chunk-XON4ZCYX.js +69 -0
- package/dist/chunk-XQPEWJPI.js +127 -0
- package/dist/chunk-XSJTIFUY.js +31 -0
- package/dist/chunk-XT7OVWM3.js +64 -0
- package/dist/chunk-XTXYIISX.js +1104 -0
- package/dist/chunk-XV7NZL4B.js +57 -0
- package/dist/chunk-XWIZ6B5S.js +109 -0
- package/dist/chunk-XWLIKOBX.js +240 -0
- package/dist/chunk-XZOXEIN4.js +156 -0
- package/dist/chunk-XZRS7I7W.js +3673 -0
- package/dist/chunk-Y4ZDDHB6.js +44 -0
- package/dist/chunk-Y733RB7T.js +194 -0
- package/dist/chunk-YBHUB4XR.js +14931 -0
- package/dist/chunk-YKC75XK4.js +147 -0
- package/dist/chunk-YKMXFVK7.js +27 -0
- package/dist/chunk-YO5BAJ55.js +225 -0
- package/dist/chunk-YPDCLXNZ.js +568 -0
- package/dist/chunk-YSQPGVFK.js +116 -0
- package/dist/chunk-YTVVTIWJ.js +716 -0
- package/dist/chunk-YVCMDVBB.js +698 -0
- package/dist/chunk-YYTOA6DP.js +114 -0
- package/dist/chunk-Z5WGNULV.js +88 -0
- package/dist/chunk-Z6NGVVXG.js +66 -0
- package/dist/chunk-Z7CDQNH3.js +20 -0
- package/dist/chunk-ZH4G3FU5.js +187 -0
- package/dist/chunk-ZJB6SQPA.js +257 -0
- package/dist/chunk-ZL6E4HMY.js +42 -0
- package/dist/chunk-ZMLOC3DW.js +62 -0
- package/dist/chunk-ZORW64QH.js +101 -0
- package/dist/chunk-ZVVD2XGV.js +1369 -0
- package/dist/cli-utils-ER33ODC5.js +31 -0
- package/dist/cli-validation-6CHPTANV.js +146 -0
- package/dist/commit-utils-3STAY7C7.js +49 -0
- package/dist/compatibility-notice-IHNXR2JR.js +21 -0
- package/dist/compete-config-resolver-V3GDNJMM.js +125 -0
- package/dist/compete-results-XUM3PJHS.js +318 -0
- package/dist/competition-outcome-tracker-NWSMVUPG.js +62 -0
- package/dist/config-4HHE4OIK.js +238 -0
- package/dist/config-D6YAZASH.js +10 -0
- package/dist/config-MIPRDYYV.js +46 -0
- package/dist/config-audit-GA5DCUAI.js +371 -0
- package/dist/config-explain-4LMO556H.js +71 -0
- package/dist/config-loader-RGP634PC.js +51 -0
- package/dist/config-manager-J2UTO635.js +114 -0
- package/dist/config-merger-TVUJBZTS.js +14 -0
- package/dist/config-validator-H4ZVIE56.js +122 -0
- package/dist/cost-HSIV5U2Y.js +85 -0
- package/dist/data-migration-state-OAUL2WPQ.js +35 -0
- package/dist/db-migrator-NUOW5NKR.js +34 -0
- package/dist/default-paths-UILB62BN.js +49 -0
- package/dist/discovery-V6GYUJUC.js +53 -0
- package/dist/doctor-BBSMCDWE.js +271 -0
- package/dist/doctor-context-blocks-LPY75VZA.js +231 -0
- package/dist/doctor-instructions-import-JXHDDOE5.js +70 -0
- package/dist/doctor-purpose-6YJOXPBE.js +30 -0
- package/dist/domain-analyzer-S35ABUNA.js +48 -0
- package/dist/ensure-initialized-Q6PEU55O.js +78 -0
- package/dist/entry.js +922 -0
- package/dist/error-parser-core-MZFMFANN.js +70 -0
- package/dist/evaluation-context-GQBYDAEV.js +63 -0
- package/dist/evidence-plan-resolver-5FUAP3SA.js +111 -0
- package/dist/execution-data-writer-YCG5UH37.js +72 -0
- package/dist/execution-policy-applier-PWZM5LNA.js +63 -0
- package/dist/execution-preflight-DASJWWQF.js +223 -0
- package/dist/execution-roles-KNSNNB2D.js +112 -0
- package/dist/exit-code-error-QIY5DOKF.js +18 -0
- package/dist/external-temp-cleanup-CAW7LQ6R.js +360 -0
- package/dist/factory-YCYCB7AE.js +209 -0
- package/dist/file-utils-ZQYNBQBW.js +45 -0
- package/dist/flywheel-allowlist-revert-H22HA6JE.js +21 -0
- package/dist/flywheel-autoloop-executor-PDOASJEZ.js +316 -0
- package/dist/flywheel-autoloop-unverified-TOKYFCDC.js +36 -0
- package/dist/flywheel-competition-executor-YJUMMEJO.js +320 -0
- package/dist/flywheel-executor-JWU43KAY.js +437 -0
- package/dist/flywheel-git-isolation-FQ2TRWMB.js +56 -0
- package/dist/flywheel-manifest-HDPNMWWF.js +114 -0
- package/dist/flywheel-model-defaults-UHAKTZT3.js +110 -0
- package/dist/flywheel-preflight-III2C7TH.js +163 -0
- package/dist/flywheel-resume-2O45MS7Y.js +31 -0
- package/dist/flywheel-resume-execution-lease-P2BK257J.js +59 -0
- package/dist/flywheel-safety-AVAVFXIJ.js +19 -0
- package/dist/flywheel-scope-decision-ALJUUNGG.js +14 -0
- package/dist/get-telemetry-logger-MPDVO2JA.js +155 -0
- package/dist/git-message-style-KCXGMTDT.js +104 -0
- package/dist/guidance-profile-config-G3K5YQOO.js +113 -0
- package/dist/guidance-profile-renderer-TX4TNDFL.js +23 -0
- package/dist/identity-XLQJ4YJF.js +25 -0
- package/dist/index-query-6NUY4FKX.js +37 -0
- package/dist/index.js +85588 -0
- package/dist/indexer-DL54CM3K.js +44 -0
- package/dist/init-OUZ72344.js +245 -0
- package/dist/instructions-import-offer-NSYXSITC.js +363 -0
- package/dist/instructions-run-NBII7W36.js +114 -0
- package/dist/interrupted-work-E4TLKJLE.js +43 -0
- package/dist/invoke-provider-auth-NEWEIHCI.js +38 -0
- package/dist/judge-scoring.json +64 -0
- package/dist/lab-mode-YXQ2Y3NG.js +44 -0
- package/dist/lab-utils-5QAMDJR5.js +29 -0
- package/dist/linux-host-class-YDWQX65O.js +31 -0
- package/dist/llm-judge-executor-OJSNCTFJ.js +179 -0
- package/dist/local-ci-config-VZ4WWDT5.js +48 -0
- package/dist/local-executor-DCMDDRX2.js +280 -0
- package/dist/logger-5KNKS3O4.js +154 -0
- package/dist/matrix-prompt-builder-4ZBOGZSB.js +527 -0
- package/dist/matrix-result-parser-EZJM4YXP.js +14 -0
- package/dist/merge-batch-RTEEMVDB.js +313 -0
- package/dist/merge-batch-members-VIWGVRHP.js +24 -0
- package/dist/merge-queue-TIIUSOY6.js +126 -0
- package/dist/merge-queue-trust-DUNZ4J65.js +21 -0
- package/dist/metadata-UKSMWM6J.js +29 -0
- package/dist/model-catalog-readiness-R5KJBP5M.js +202 -0
- package/dist/model-invocations-db-XTUPPQ34.js +70 -0
- package/dist/model-resolver-JFZ2MHOJ.js +39 -0
- package/dist/model-resolver-SCQ57KAQ.js +217 -0
- package/dist/model-roles-D3OR4NAH.js +110 -0
- package/dist/monitor-F4SIU5G2.js +96 -0
- package/dist/nested-worktrees-2WUWQ75N.js +23 -0
- package/dist/next-S3IRLVER.js +96 -0
- package/dist/next-UKPFRXOO.js +148 -0
- package/dist/opportunistic-TL4S26VX.js +86 -0
- package/dist/optimization-config-resolver-NAEIYU6A.js +148 -0
- package/dist/package-HJR4QJT4.js +10 -0
- package/dist/parse-git-status-7PIYFPS2.js +21 -0
- package/dist/path-security-5WJSY56G.js +41 -0
- package/dist/paths-JUI7C4KU.js +45 -0
- package/dist/plan-backlog-list-fast-SSTQL5XP.js +89 -0
- package/dist/plan-backlog-show-fast-PFRAQ3JB.js +114 -0
- package/dist/plan-sprint-list-fast-HD2KBZSY.js +110 -0
- package/dist/plan-sprint-status-fast-YFYH7WQF.js +116 -0
- package/dist/plan-task-status-fast-JU5PNLUU.js +114 -0
- package/dist/plan-to-flywheel-PY5MSY2H.js +529 -0
- package/dist/preflight-PJHGTJNZ.js +12 -0
- package/dist/process-registry-B4ZUCN7T.js +28 -0
- package/dist/process-scanner-TU3QHWVB.js +23 -0
- package/dist/processes-6FHVGT72.js +28 -0
- package/dist/processes-json-fast-YWTMUWXB.js +72 -0
- package/dist/profile-HWTC56SG.js +209 -0
- package/dist/project-runtime-paths-2UQNG5Y4.js +41 -0
- package/dist/protected-branches-N36LDBFY.js +71 -0
- package/dist/provider-aware-resource-manager-YTFAHNGJ.js +40 -0
- package/dist/provider-matrix-2KO2V5OM.js +214 -0
- package/dist/provider-matrix-renderer-MEC3PER7.js +139 -0
- package/dist/provider-output-forwarding-2AHL7YMA.js +26 -0
- package/dist/provider-registry-WCZ65QHC.js +136 -0
- package/dist/provider-temp-cleanup-IUNPJCZF.js +14 -0
- package/dist/prune-engine-EOQVWEP6.js +448 -0
- package/dist/publication-turn-S42RZTQF.js +44 -0
- package/dist/quality-gate-JQMVCKOO.js +72 -0
- package/dist/quickstart-3O6FRCFB.js +105 -0
- package/dist/readiness-GW6ABRHB.js +139 -0
- package/dist/readiness-KFZCXDTT.js +215 -0
- package/dist/registry-7XG376SY.js +217 -0
- package/dist/repair-helpers-TTV5FEF4.js +117 -0
- package/dist/repo-root-YG6MQZDW.js +28 -0
- package/dist/resolution-engine-FFEK7HQ2.js +187 -0
- package/dist/resolve-provider-cli-ZEXVZKET.js +44 -0
- package/dist/restore-telemetry-db-E7BR5PO7.js +459 -0
- package/dist/routing-events-AW6SRZ6G.js +13 -0
- package/dist/routing-history-store-FMDDQL6W.js +39 -0
- package/dist/routing-planner-C6OHO3EY.js +221 -0
- package/dist/runner-KHDNQ5KU.js +1194 -0
- package/dist/runner-PIS2BW7Y.js +1801 -0
- package/dist/safety-E3JJVSFL.js +67 -0
- package/dist/safety-stanza-HE6GXP4G.js +49 -0
- package/dist/sandbox-7LBZC5PE.js +72 -0
- package/dist/sandbox-ASWCDYZL.js +80 -0
- package/dist/schema-extensions.sql +234 -0
- package/dist/security-JI22TBEB.js +17 -0
- package/dist/setup-bb-plugin-FQXLA76Y.js +531 -0
- package/dist/setup-claude-code-NF4ZSHVE.js +197 -0
- package/dist/setup-temp-cleanup-2APZ4HMA.js +29 -0
- package/dist/shared-utils-34HJZ6JX.js +40 -0
- package/dist/simple-artifact-goal-MQLDDMMX.js +29 -0
- package/dist/sprint-N7JFTEGL.js +403 -0
- package/dist/sprint-bridge-KJXIBNRJ.js +117 -0
- package/dist/sprint-completion-dependents-34SR7JVL.js +43 -0
- package/dist/sprint-execution-service-A6JPUBWY.js +376 -0
- package/dist/sprint-manager-MU2ZUWN2.js +140 -0
- package/dist/sqlite-timeout-config-U2CT4LKU.js +13 -0
- package/dist/sqlite-wrapper-FSGJ2QEW.js +19 -0
- package/dist/stale-cleanup-orchestrator-4X6324VF.js +71 -0
- package/dist/storage-access-I3V5LER7.js +31 -0
- package/dist/store-XVG64ZR2.js +25 -0
- package/dist/task-classifier-MN2DYE5R.js +558 -0
- package/dist/task-list-fast-7AT6LTTA.js +112 -0
- package/dist/task-manager-LHPBBRRE.js +136 -0
- package/dist/task-report-OLPAWBTK.js +64 -0
- package/dist/task-type-detector-6RG3YNZF.js +27 -0
- package/dist/task-type-resolver-EQHOUIHT.js +64 -0
- package/dist/telemetry-5VYSK772.js +212 -0
- package/dist/telemetry-health-tracker-4GFW2EMP.js +12 -0
- package/dist/telemetry-path-resolver-H3NFHHQY.js +34 -0
- package/dist/telemetry-reliability-URJDTNPZ.js +76 -0
- package/dist/transports-NREZQTJK.js +106 -0
- package/dist/unified-cost-tracker-5MTBJ2CL.js +59 -0
- package/dist/unified-state-cleanup-GGAXLHXF.js +292 -0
- package/dist/universal-cost-calculator-JTFEJVWK.js +70 -0
- package/dist/user-agents-QLIGPLP2.js +30 -0
- package/dist/variant-execution-I4ZZUAWY.js +319 -0
- package/dist/variant-opt-parser-JHCXKY2K.js +251 -0
- package/dist/variant-request-input-PL37N3AN.js +11 -0
- package/dist/variant-state-cleanup-KHMXRBZN.js +287 -0
- package/dist/variant-worker-COB5YTJX.js +4517 -0
- package/dist/variant-worker.js +26 -0
- package/dist/variants-XGDSXYG3.js +267 -0
- package/dist/verification-command-YSPU4VBH.js +66 -0
- package/dist/verify-command-timeout-DQUYH33Z.js +11 -0
- package/dist/verify-commands-LOHMOFKC.js +65 -0
- package/dist/warning-JSKSFKBT.js +13 -0
- package/dist/work-edge-K65NHVWY.js +50 -0
- package/dist/work-item-writer-KY5ZWZWW.js +30 -0
- package/dist/worker-JNXXEIT6.js +1504 -0
- package/dist/worker.js +21 -0
- package/dist/workspace-tree-identity-JO5PSKTW.js +52 -0
- package/dist/worktree-environment-WTVABAQW.js +64 -0
- package/dist/worktree-metrics-VZRQI26T.js +66 -0
- package/dist/writeback-TQFQBJNU.js +50 -0
- package/docs/CLI_REFERENCE.md +8287 -0
- package/docs/PROVIDER_SETUP.md +1737 -0
- package/docs/README.md +96 -0
- package/docs/TROUBLESHOOTING.md +2209 -0
- package/docs/getting-started/QUICK_START.md +260 -0
- package/docs/getting-started/README.md +198 -0
- package/docs/getting-started/SETUP.md +25 -0
- package/docs/reference/AGENT_CONTEXT.md +84 -0
- package/docs/reference/DELIVERY_ONBOARDING.md +198 -0
- package/docs/reference/PROVIDER_RELEASE_TIERS.md +34 -0
- package/docs/reference/SECURITY.md +291 -0
- package/docs/reference/TELEMETRY_PRIVACY.md +259 -0
- package/integrations/bb-plugin-build/README.md +391 -0
- package/integrations/bb-plugin-build/app.css +431 -0
- package/integrations/bb-plugin-build/app.tsx +6210 -0
- package/integrations/bb-plugin-build/package.json +45 -0
- package/integrations/bb-plugin-build/server.ts +488 -0
- package/integrations/bb-plugin-build/src/adapter.ts +3672 -0
- package/integrations/bb-plugin-build/src/backlog-authoring-model.ts +150 -0
- package/integrations/bb-plugin-build/src/backlog-authoring-schema.ts +458 -0
- package/integrations/bb-plugin-build/src/backlog-authoring-service.ts +467 -0
- package/integrations/bb-plugin-build/src/backlog-authoring-view.ts +1025 -0
- package/integrations/bb-plugin-build/src/command-evidence-schema.ts +13 -0
- package/integrations/bb-plugin-build/src/competition-defaults-schema.ts +122 -0
- package/integrations/bb-plugin-build/src/competition-defaults-service.ts +105 -0
- package/integrations/bb-plugin-build/src/competition-defaults-view.ts +138 -0
- package/integrations/bb-plugin-build/src/contract.ts +718 -0
- package/integrations/bb-plugin-build/src/execution-activity-view.ts +98 -0
- package/integrations/bb-plugin-build/src/finalize-model.ts +205 -0
- package/integrations/bb-plugin-build/src/finalize-schema.ts +150 -0
- package/integrations/bb-plugin-build/src/finalize-service.ts +330 -0
- package/integrations/bb-plugin-build/src/finalize-view.ts +159 -0
- package/integrations/bb-plugin-build/src/judge-operations-readback.ts +303 -0
- package/integrations/bb-plugin-build/src/judge-operations-schema.ts +33 -0
- package/integrations/bb-plugin-build/src/judge-operations-view.ts +459 -0
- package/integrations/bb-plugin-build/src/model.ts +1318 -0
- package/integrations/bb-plugin-build/src/monitor-service.ts +233 -0
- package/integrations/bb-plugin-build/src/panel-read-ux.ts +97 -0
- package/integrations/bb-plugin-build/src/patch-preview-schema.ts +166 -0
- package/integrations/bb-plugin-build/src/patch-preview-service.ts +480 -0
- package/integrations/bb-plugin-build/src/patch-preview-view.ts +109 -0
- package/integrations/bb-plugin-build/src/planning-readback.ts +228 -0
- package/integrations/bb-plugin-build/src/planning-service.ts +647 -0
- package/integrations/bb-plugin-build/src/planning-sync-evidence.ts +37 -0
- package/integrations/bb-plugin-build/src/planning-workspace-readback.ts +33 -0
- package/integrations/bb-plugin-build/src/planning-workspace-schema.ts +131 -0
- package/integrations/bb-plugin-build/src/planning-workspace.ts +333 -0
- package/integrations/bb-plugin-build/src/poll-handoff.ts +136 -0
- package/integrations/bb-plugin-build/src/project-target-server.ts +21 -0
- package/integrations/bb-plugin-build/src/project-target.ts +45 -0
- package/integrations/bb-plugin-build/src/reference-index.ts +218 -0
- package/integrations/bb-plugin-build/src/repository-identity.ts +17 -0
- package/integrations/bb-plugin-build/src/repository-schema.ts +30 -0
- package/integrations/bb-plugin-build/src/result-explorer-view.ts +597 -0
- package/integrations/bb-plugin-build/src/result-readback-model.ts +163 -0
- package/integrations/bb-plugin-build/src/result-readback-schema.ts +319 -0
- package/integrations/bb-plugin-build/src/result-readback-service.ts +333 -0
- package/integrations/bb-plugin-build/src/run-page-view.ts +332 -0
- package/integrations/bb-plugin-build/src/setup-config-schema.ts +293 -0
- package/integrations/bb-plugin-build/src/setup-config-service.ts +620 -0
- package/integrations/bb-plugin-build/src/setup-config-view.ts +388 -0
- package/integrations/bb-plugin-build/src/sprint-close-model.ts +150 -0
- package/integrations/bb-plugin-build/src/sprint-close-schema.ts +128 -0
- package/integrations/bb-plugin-build/src/sprint-close-service.ts +293 -0
- package/integrations/bb-plugin-build/src/sprint-close-view.ts +116 -0
- package/integrations/bb-plugin-build/src/sprint-composition-model.ts +709 -0
- package/integrations/bb-plugin-build/src/sprint-composition-readback.ts +231 -0
- package/integrations/bb-plugin-build/src/sprint-composition-schema.ts +597 -0
- package/integrations/bb-plugin-build/src/sprint-composition-service.ts +773 -0
- package/integrations/bb-plugin-build/src/sprint-composition-view.ts +1221 -0
- package/integrations/bb-plugin-build/src/sprint-execution-schema.ts +188 -0
- package/integrations/bb-plugin-build/src/sprint-execution-service.ts +289 -0
- package/integrations/bb-plugin-build/src/sprint-execution-view.ts +54 -0
- package/integrations/bb-plugin-build/src/task-authoring-model.ts +563 -0
- package/integrations/bb-plugin-build/src/task-authoring-schema.ts +629 -0
- package/integrations/bb-plugin-build/src/task-authoring-service.ts +842 -0
- package/integrations/bb-plugin-build/src/task-authoring-view.ts +1227 -0
- package/integrations/bb-plugin-build/src/task-catalog-schema.ts +46 -0
- package/integrations/bb-plugin-build/src/task-catalog-service.ts +44 -0
- package/integrations/bb-plugin-build/src/task-detail-readback.ts +56 -0
- package/integrations/bb-plugin-build/src/task-detail-schema.ts +171 -0
- package/integrations/bb-plugin-build/src/task-navigation.ts +446 -0
- package/integrations/bb-plugin-build/src/workbench-route.ts +74 -0
- package/package.json +306 -4
- package/schemas/README.md +80 -0
- package/schemas/build.config.schema.json +2110 -0
- package/schemas/config-v1.schema.json +136 -0
- package/schemas/execution-config.schema.json +47 -0
- package/schemas/judge-scoring.schema.json +257 -0
- package/schemas/provider-config.schema.json +179 -0
- package/schemas/telemetry-config.schema.json +79 -0
- package/schemas/user-preferences.schema.json +141 -0
- package/scripts/assert-node-runtime.mjs +146 -0
- package/scripts/preflight-native.mjs +49 -0
- package/scripts/setup-git-hooks.mjs +39 -0
- package/scripts/sync.sh +2871 -0
- package/scripts/write-node-launcher.sh +138 -0
- package/src/resources/gemini/slash-packs/default/plan.toml +15 -0
- package/src/resources/gemini/slash-packs/default/summary.toml +16 -0
- package/src/resources/gemini/slash-packs/default/tests.toml +16 -0
- package/templates/.build-project/README.md +41 -0
- package/templates/.build-project/agents/README.md +50 -0
- package/templates/.build-project/agents/architect.md +10 -0
- package/templates/.build-project/agents/code-reviewer.md +10 -0
- package/templates/.build-project/agents/debugger.md +10 -0
- package/templates/.build-project/agents/documenter.md +10 -0
- package/templates/.build-project/agents/test-automator.md +10 -0
- package/templates/.build-project/config/build.config.jsonc +64 -0
- package/templates/.build-project/config/project-context.template.json +6 -0
- package/templates/.build-project/config/task-type-aliases.presets/kanban.yaml +14 -0
- package/templates/.build-project/config/task-type-aliases.presets/scrum.yaml +17 -0
- package/templates/.build-project/config/task-type-aliases.presets/xp.yaml +12 -0
- package/templates/.build-project/config/task-type-aliases.yaml +29 -0
- package/templates/.build-project/gitignore.template +70 -0
- package/templates/.build-project/task-types/analysis.yaml +38 -0
- package/templates/.build-project/task-types/architecture.yaml +35 -0
- package/templates/.build-project/task-types/doc.yaml +34 -0
- package/templates/.build-project/task-types/feature.yaml +22 -0
- package/templates/.build-project/task-types/general.yaml +4 -0
- package/templates/.build-project/task-types/security.yaml +38 -0
- package/templates/AGENTS.template.md +85 -0
- package/templates/CLAUDE.template.md +1 -0
- package/templates/GEMINI.template.md +1 -0
- package/templates/builtin-workflows/code-review.yaml +73 -0
- package/templates/builtin-workflows/skills/code-review/SKILL.md +61 -0
- package/templates/builtin-workflows/skills/execution-contract-analysis/SKILL.md +24 -0
- package/templates/builtin-workflows/skills/execution-contract-code/SKILL.md +19 -0
- package/templates/builtin-workflows/skills/execution-contract-structured/SKILL.md +17 -0
- package/templates/ci/incident-intake.mjs +787 -0
- package/templates/ci/incidents.yml.template +103 -0
- package/templates/ci/node.yml.template +17 -0
- package/templates/ci/python.yml.template +17 -0
- package/templates/guard-kit/GUARD_SETUP.md.template +258 -0
- package/templates/guard-kit/build-guard.yml.template +189 -0
- package/templates/guard-kit/check.mjs.template +932 -0
- package/templates/guard-kit/config.json.template +7 -0
- package/templates/guard-kit/policy.json.template +1 -0
- package/templates/profiles/README.md +57 -0
- package/templates/profiles/frontier-claude.json +23 -0
- package/templates/profiles/frontier-codex.json +23 -0
|
@@ -0,0 +1,3587 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseCitationTrace,
|
|
3
|
+
serializeCitationTrace
|
|
4
|
+
} from "./chunk-OSK7QWPD.js";
|
|
5
|
+
import {
|
|
6
|
+
classifyWinnerSelectionSource,
|
|
7
|
+
formatAnalysisSynthesisArtifactPath,
|
|
8
|
+
formatAnalysisSynthesisPathLine,
|
|
9
|
+
formatVariantKeyForDisplay,
|
|
10
|
+
getCanonicalVariantKeyFromResult,
|
|
11
|
+
getDisplayVerificationVerdict,
|
|
12
|
+
getTop2FromSynthesis,
|
|
13
|
+
inferDecisionOutcome,
|
|
14
|
+
inferDecisionStatus,
|
|
15
|
+
isCompletedVariant,
|
|
16
|
+
isNearTieMargin,
|
|
17
|
+
isVerifiedVariant,
|
|
18
|
+
isWinnerVerifiedForGatePolicy,
|
|
19
|
+
resolveJudgeTop2,
|
|
20
|
+
runAnalysisSynthesis,
|
|
21
|
+
runAnalysisSynthesisProvider,
|
|
22
|
+
sanitizeAnalysisSynthesisContributorError,
|
|
23
|
+
shouldRunAnalysisSynthesisStage,
|
|
24
|
+
stripPreambleBeforeFirstHeading,
|
|
25
|
+
summarizeFusionSections,
|
|
26
|
+
variantHandlesMatchForResults
|
|
27
|
+
} from "./chunk-LWGKN2GY.js";
|
|
28
|
+
import {
|
|
29
|
+
isValidationTargetedCodeOverrideExpected
|
|
30
|
+
} from "./chunk-3PL22IYZ.js";
|
|
31
|
+
import {
|
|
32
|
+
recordCompetitionOutcomeEvent,
|
|
33
|
+
resolveLatestEvaluationId
|
|
34
|
+
} from "./chunk-TSQ256N5.js";
|
|
35
|
+
import {
|
|
36
|
+
buildCompetitionOutcomeEvent,
|
|
37
|
+
persistCompetitionOutcomeEvent
|
|
38
|
+
} from "./chunk-YBHUB4XR.js";
|
|
39
|
+
import {
|
|
40
|
+
updateEvaluationHandleApplicationProvenance
|
|
41
|
+
} from "./chunk-NTD6CSI6.js";
|
|
42
|
+
import {
|
|
43
|
+
formatTokens,
|
|
44
|
+
normalizeProviderRunDiagnostics,
|
|
45
|
+
providerDiagnosticsReportFatalRuntimeIssue
|
|
46
|
+
} from "./chunk-MW2DWWVA.js";
|
|
47
|
+
import {
|
|
48
|
+
detectHostConcurrencyBudget
|
|
49
|
+
} from "./chunk-BZRLSZNV.js";
|
|
50
|
+
import {
|
|
51
|
+
formatDurationMs
|
|
52
|
+
} from "./chunk-2L36U25O.js";
|
|
53
|
+
import {
|
|
54
|
+
isFailoverEnabled
|
|
55
|
+
} from "./chunk-SBBNT5ZJ.js";
|
|
56
|
+
import {
|
|
57
|
+
classifyProviderResultFailure,
|
|
58
|
+
printProviderSwitchNotice,
|
|
59
|
+
runWithProviderFailover
|
|
60
|
+
} from "./chunk-VLMDM56Q.js";
|
|
61
|
+
import {
|
|
62
|
+
applyVariantLabelsToScores,
|
|
63
|
+
computeEscalation,
|
|
64
|
+
extractJudgeConsistencyTelemetry,
|
|
65
|
+
extractJudgeUsageSummary,
|
|
66
|
+
extractPromptTelemetrySummaryFromAudit,
|
|
67
|
+
extractVariantLabelMappingFromAudit,
|
|
68
|
+
formatJudgeCandidateId,
|
|
69
|
+
hasIgnoredPlanningArtifactEvidence,
|
|
70
|
+
isVerificationIntegrityReason
|
|
71
|
+
} from "./chunk-DCACX7BV.js";
|
|
72
|
+
import {
|
|
73
|
+
computeFinalScore
|
|
74
|
+
} from "./chunk-JOSK6GEU.js";
|
|
75
|
+
import {
|
|
76
|
+
registry
|
|
77
|
+
} from "./chunk-7HYBSRPZ.js";
|
|
78
|
+
import {
|
|
79
|
+
withoutNegatedSpans
|
|
80
|
+
} from "./chunk-LDJCKAJP.js";
|
|
81
|
+
import {
|
|
82
|
+
classifyNoWorkFailure
|
|
83
|
+
} from "./chunk-PRDHI2L5.js";
|
|
84
|
+
import {
|
|
85
|
+
infoEvent
|
|
86
|
+
} from "./chunk-GQXLXRFA.js";
|
|
87
|
+
import {
|
|
88
|
+
classifyExplicitNoEdit,
|
|
89
|
+
detectProseResponseOnlyDirective
|
|
90
|
+
} from "./chunk-PPHXX4W7.js";
|
|
91
|
+
import {
|
|
92
|
+
ConfigManager
|
|
93
|
+
} from "./chunk-W4BAIQ6L.js";
|
|
94
|
+
import {
|
|
95
|
+
sanitizeDiagnosticOutput
|
|
96
|
+
} from "./chunk-RBKLOUXA.js";
|
|
97
|
+
import {
|
|
98
|
+
resolveCandidates,
|
|
99
|
+
resolvePreferred,
|
|
100
|
+
resolveSynthesisReasoningEffort
|
|
101
|
+
} from "./chunk-C3DH3NCY.js";
|
|
102
|
+
import {
|
|
103
|
+
formatDurationSeconds
|
|
104
|
+
} from "./chunk-FRBPKBFE.js";
|
|
105
|
+
import {
|
|
106
|
+
filterWorktreeRunSentinelStatusOutput
|
|
107
|
+
} from "./chunk-2NMNFUQA.js";
|
|
108
|
+
import {
|
|
109
|
+
parseSynthesisModelTarget
|
|
110
|
+
} from "./chunk-I7SCBHJN.js";
|
|
111
|
+
import {
|
|
112
|
+
formatVariantIdentifierFromResult
|
|
113
|
+
} from "./chunk-TGXXYDL4.js";
|
|
114
|
+
import {
|
|
115
|
+
atomicWriteJson
|
|
116
|
+
} from "./chunk-RFDVSI4N.js";
|
|
117
|
+
import {
|
|
118
|
+
formatPostApplyUnverifiedLabel,
|
|
119
|
+
judgeWinnerLine,
|
|
120
|
+
resolveBranchApplyBoundary,
|
|
121
|
+
resolveEffectiveCompletionMode
|
|
122
|
+
} from "./chunk-SKTFRFQ7.js";
|
|
123
|
+
import {
|
|
124
|
+
deriveVariantOutcome,
|
|
125
|
+
hasVetoingUnavailableVerificationGateEvidence,
|
|
126
|
+
isIgnoredPlanningArtifactPath,
|
|
127
|
+
readVariantVerification
|
|
128
|
+
} from "./chunk-3OPP2OZB.js";
|
|
129
|
+
import {
|
|
130
|
+
extractScopedSourceFiles,
|
|
131
|
+
hasExplicitFileTargets
|
|
132
|
+
} from "./chunk-KUEWV2JH.js";
|
|
133
|
+
import {
|
|
134
|
+
assertCompeteProtectedBranchForCompletionMode,
|
|
135
|
+
classifyBranchRole,
|
|
136
|
+
getCurrentBranch,
|
|
137
|
+
isDisposableBranchRole,
|
|
138
|
+
needsNewWorkingBranch
|
|
139
|
+
} from "./chunk-XGU6PBO5.js";
|
|
140
|
+
import {
|
|
141
|
+
taskVariantId
|
|
142
|
+
} from "./chunk-F55YABKV.js";
|
|
143
|
+
import {
|
|
144
|
+
getProjectReferencePathExtensions
|
|
145
|
+
} from "./chunk-RPIMAMV7.js";
|
|
146
|
+
import {
|
|
147
|
+
toVariantSlug
|
|
148
|
+
} from "./chunk-2VLJUXJU.js";
|
|
149
|
+
import {
|
|
150
|
+
LabPathResolver
|
|
151
|
+
} from "./chunk-C3KCMAJP.js";
|
|
152
|
+
import {
|
|
153
|
+
resolveLabsRoot
|
|
154
|
+
} from "./chunk-AJN5Y5YZ.js";
|
|
155
|
+
import {
|
|
156
|
+
redactSynthesisDeliverableSecrets,
|
|
157
|
+
sanitizeSynthesisArtifactForPersistence,
|
|
158
|
+
sanitizeSynthesisStringForPersistence
|
|
159
|
+
} from "./chunk-VSWC5ZXI.js";
|
|
160
|
+
import {
|
|
161
|
+
normalizeEngineId
|
|
162
|
+
} from "./chunk-KKQKWAMF.js";
|
|
163
|
+
import {
|
|
164
|
+
rethrowConfigValidityError
|
|
165
|
+
} from "./chunk-QJ6OEH4K.js";
|
|
166
|
+
import {
|
|
167
|
+
emitCustomWarning,
|
|
168
|
+
emitWarning,
|
|
169
|
+
getExecutionContext,
|
|
170
|
+
hasExecutionContext,
|
|
171
|
+
resolveBuildDirFromContext
|
|
172
|
+
} from "./chunk-7VRJHTGZ.js";
|
|
173
|
+
|
|
174
|
+
// src/cli/competition-interruption.ts
|
|
175
|
+
function shouldStopBeforeJudgeOrSynthesis(isShuttingDown, variants) {
|
|
176
|
+
return isShuttingDown || variants.some((variant) => variant.terminationReason === "canceled_user");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/cli/handlers/compete/compete-finalize.ts
|
|
180
|
+
import * as fs2 from "fs/promises";
|
|
181
|
+
import * as path3 from "path";
|
|
182
|
+
|
|
183
|
+
// src/core/compete/completion-eligibility.ts
|
|
184
|
+
function verificationLabel(winnerVerified) {
|
|
185
|
+
return winnerVerified === void 0 ? "has unknown verification status" : "is unverified";
|
|
186
|
+
}
|
|
187
|
+
function resolveCompletionEligibility(input) {
|
|
188
|
+
const sideEffecting = input.effectiveCompletionMode === "pr" || input.effectiveCompletionMode === "branch";
|
|
189
|
+
if (!sideEffecting) {
|
|
190
|
+
return { action: "apply-winner", reason: "non-side-effecting completion mode" };
|
|
191
|
+
}
|
|
192
|
+
if (input.winnerVerified === true) {
|
|
193
|
+
return { action: "apply-winner", reason: "winner verified" };
|
|
194
|
+
}
|
|
195
|
+
const label = verificationLabel(input.winnerVerified);
|
|
196
|
+
if (input.verifiedAlternativeLabels.length === 0) {
|
|
197
|
+
return {
|
|
198
|
+
action: "refuse",
|
|
199
|
+
reason: `judge winner ${label} and no verified variant(s) exist`
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const labelList = input.verifiedAlternativeLabels.join(", ");
|
|
203
|
+
if (input.nearTie) {
|
|
204
|
+
if (input.hasVerifiedAlternativeForApply) {
|
|
205
|
+
return {
|
|
206
|
+
action: "apply-verified-alternative",
|
|
207
|
+
reason: `judge winner ${label}; substituting verified near-tie alternative`
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
action: "refuse",
|
|
212
|
+
reason: `judge winner is provisional/unverified while verified variant(s) exist: ${labelList}`
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
action: "refuse",
|
|
217
|
+
reason: `judge winner ${label} while verified variant(s) exist, but the judge preferred the winner by a wide margin (not a near-tie). Refusing to auto-substitute a lower-ranked variant or ship an unverified winner. Inspect the results and apply manually, or re-run. Verified alternative(s): ${labelList}`
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// src/cli/handlers/compete/results-reference.ts
|
|
222
|
+
import * as path from "path";
|
|
223
|
+
function resolveHandoffPathFromStatePath(statePath) {
|
|
224
|
+
return statePath.endsWith(".json") ? statePath.replace(/\.json$/, ".handoff.md") : `${statePath}.handoff.md`;
|
|
225
|
+
}
|
|
226
|
+
function buildPortableResultsCommand(input) {
|
|
227
|
+
const resultsCommand = input.surface === "fusion" ? `run fusion results ${input.taskId}` : `run competition results ${input.taskId}`;
|
|
228
|
+
const explicitRepoRoot = input.repoRoot?.trim();
|
|
229
|
+
const contextRepoRoot = hasExecutionContext() ? getExecutionContext().repoRoot : void 0;
|
|
230
|
+
const repoRoot = (explicitRepoRoot || String(contextRepoRoot ?? "")).trim();
|
|
231
|
+
if (!repoRoot) {
|
|
232
|
+
return `build ${resultsCommand}`;
|
|
233
|
+
}
|
|
234
|
+
const invoker = resolvePortableResultsInvoker({
|
|
235
|
+
repoRoot,
|
|
236
|
+
currentEntryPath: input.currentEntryPath ?? process.argv[1]
|
|
237
|
+
});
|
|
238
|
+
return `cd ${quoteReplayArg(repoRoot)} && ${invoker} ${resultsCommand}`;
|
|
239
|
+
}
|
|
240
|
+
function buildMatrixEvaluationCommand(input) {
|
|
241
|
+
const labArgs = input.labContext ? ` --lab-id ${quoteReplayArg(input.labContext.labId)} --run-id ${quoteReplayArg(input.labContext.runId)}` : "";
|
|
242
|
+
return `build judge evaluate ${quoteReplayArg(input.taskId)}${labArgs} --judge-profile matrix --json`;
|
|
243
|
+
}
|
|
244
|
+
function resolvePortableResultsInvoker(input) {
|
|
245
|
+
const currentEntryPath = input.currentEntryPath?.trim();
|
|
246
|
+
if (!currentEntryPath) {
|
|
247
|
+
return "build";
|
|
248
|
+
}
|
|
249
|
+
const repoRoot = path.resolve(input.repoRoot);
|
|
250
|
+
const entryPath = path.resolve(currentEntryPath);
|
|
251
|
+
const relativeEntryPath = path.relative(repoRoot, entryPath);
|
|
252
|
+
if (relativeEntryPath === path.join("dist", "entry.js")) {
|
|
253
|
+
return `node ${quoteReplayArg(relativeEntryPath)}`;
|
|
254
|
+
}
|
|
255
|
+
return "build";
|
|
256
|
+
}
|
|
257
|
+
function quoteReplayArg(value) {
|
|
258
|
+
if (/^[A-Za-z0-9_./:=,+@%-]+$/.test(value)) return value;
|
|
259
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/cli/handlers/compete/competition-judge-shared.ts
|
|
263
|
+
function classifyJudgeFailureMessage(message) {
|
|
264
|
+
if (!message || message.trim().length === 0) return "inconclusive";
|
|
265
|
+
const normalized = message.trim();
|
|
266
|
+
if (/sandbox|reason=sandbox|policy blocked|EPERM|Operation not permitted|readonly profile requires/i.test(
|
|
267
|
+
normalized
|
|
268
|
+
)) {
|
|
269
|
+
return "sandbox";
|
|
270
|
+
}
|
|
271
|
+
if (/\btimeout\b/i.test(normalized)) return "timeout";
|
|
272
|
+
if (/parse failure|validation failure|malformed_json|invalid_output/i.test(normalized)) {
|
|
273
|
+
return "invalid_output";
|
|
274
|
+
}
|
|
275
|
+
return "error";
|
|
276
|
+
}
|
|
277
|
+
function formatHeuristicFallbackGuidance() {
|
|
278
|
+
return "Use --allow-heuristic-fallback (or BUILD_ALLOW_HEURISTIC_FALLBACK=1) to promote a heuristic or secondary-judge winner.";
|
|
279
|
+
}
|
|
280
|
+
function formatJudgeSkippedWarning(variantCount) {
|
|
281
|
+
return variantCount === 0 ? "AI judge skipped because no safely attributable canonical variant keys were available." : "No variant produced output; skipping the judge. There is no winner.";
|
|
282
|
+
}
|
|
283
|
+
function formatJudgeNoWinnerWarning(input) {
|
|
284
|
+
if (input.kind === "no_declaration") {
|
|
285
|
+
if (input.allowHeuristicFallback || input.basicMode) {
|
|
286
|
+
return "AI judge did not return a winner in basic mode; no winner selected.";
|
|
287
|
+
}
|
|
288
|
+
return `AI judge did not return a winner; no winner selected. ${formatHeuristicFallbackGuidance()}`;
|
|
289
|
+
}
|
|
290
|
+
const failureClass = classifyJudgeFailureMessage(input.message);
|
|
291
|
+
const detail = failureClass === "sandbox" ? "sandbox blocked judge provider write access" : input.message?.replace(/\s+/g, " ").trim();
|
|
292
|
+
const detailSuffix = detail ? ` (${detail})` : "";
|
|
293
|
+
if (input.allowHeuristicFallback && input.basicMode) {
|
|
294
|
+
return `AI judge evaluation failed in basic mode; no winner selected${detailSuffix}.`;
|
|
295
|
+
}
|
|
296
|
+
if (input.allowHeuristicFallback) {
|
|
297
|
+
return `AI judge evaluation failed; no winner selected${detailSuffix}.`;
|
|
298
|
+
}
|
|
299
|
+
const prefix = failureClass === "sandbox" ? "AI judge unavailable (sandbox blocked provider write access)" : "AI judge evaluation failed";
|
|
300
|
+
return `${prefix}; no winner selected${detailSuffix}. ${formatHeuristicFallbackGuidance()}`;
|
|
301
|
+
}
|
|
302
|
+
function formatSynthesisOutcomeSummary(input) {
|
|
303
|
+
if (input.synthesisApplied === true) {
|
|
304
|
+
return {
|
|
305
|
+
status: "applied",
|
|
306
|
+
winnerPreserved: true,
|
|
307
|
+
humanLine: "Validated synthesis delivery; judged winner preserved as base."
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
if (input.winnerFallback === true) {
|
|
311
|
+
const reason = input.fallbackReason ?? "judged winner retained without donor changes";
|
|
312
|
+
return {
|
|
313
|
+
status: "winner_fallback",
|
|
314
|
+
winnerPreserved: true,
|
|
315
|
+
humanLine: `Synthesis did not apply; winner preserved (${reason}).`
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
if (input.error || input.fallbackReason) {
|
|
319
|
+
const reason = input.error ?? input.fallbackReason ?? "synthesis failed";
|
|
320
|
+
const winnerPreserved = input.hasWinner !== false;
|
|
321
|
+
return {
|
|
322
|
+
status: "rejected",
|
|
323
|
+
winnerPreserved,
|
|
324
|
+
humanLine: winnerPreserved ? `Synthesis failed; judged winner preserved (${reason}).` : `Synthesis failed; no winner preserved (${reason}).`
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
status: "failed",
|
|
329
|
+
winnerPreserved: input.hasWinner !== false,
|
|
330
|
+
humanLine: input.hasWinner === false ? "Synthesis not applied; no judged winner to preserve." : "Synthesis not applied; judged winner unchanged."
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function formatCompetitionApplyNextSteps(taskId, branch) {
|
|
334
|
+
return [
|
|
335
|
+
`Competition ID: ${taskId}`,
|
|
336
|
+
...needsNewWorkingBranch(branch) ? ["Next: git checkout -b fix/<slug>"] : [],
|
|
337
|
+
`Next: build run competition apply ${taskId}`
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
function formatSynthesisFailureNextSteps(taskId) {
|
|
341
|
+
const resultsCommand = buildPortableResultsCommand({ taskId });
|
|
342
|
+
return [
|
|
343
|
+
`Inspect synthesis details: ${resultsCommand}`,
|
|
344
|
+
`Apply judged winner: git checkout -b fix/<slug> && build run competition apply ${taskId}`
|
|
345
|
+
];
|
|
346
|
+
}
|
|
347
|
+
function buildCompeteRunMetadata(input) {
|
|
348
|
+
return {
|
|
349
|
+
runSemantics: input.runSemantics,
|
|
350
|
+
judge: {
|
|
351
|
+
requested: input.judgeRequested,
|
|
352
|
+
status: input.judgeStatus,
|
|
353
|
+
reason: input.judgeReason
|
|
354
|
+
},
|
|
355
|
+
research: {
|
|
356
|
+
requested: input.researchRequested,
|
|
357
|
+
enabled: input.researchEnabled,
|
|
358
|
+
skipReason: input.researchEnabled ? void 0 : input.researchSkipReason,
|
|
359
|
+
mode: input.researchMode,
|
|
360
|
+
packetPath: input.researchPacketPath,
|
|
361
|
+
excludedDomains: input.researchExcludeDomain
|
|
362
|
+
},
|
|
363
|
+
synthesis: input.synthesisExpected !== void 0 || input.synthesisStatus !== void 0 || input.synthesisArtifactPath !== void 0 || input.synthesisJsonPath !== void 0 || input.synthesisContributorCount !== void 0 ? {
|
|
364
|
+
expected: input.synthesisExpected,
|
|
365
|
+
status: input.synthesisStatus,
|
|
366
|
+
artifactPath: input.synthesisArtifactPath,
|
|
367
|
+
jsonPath: input.synthesisJsonPath,
|
|
368
|
+
contributorCount: input.synthesisContributorCount
|
|
369
|
+
} : void 0,
|
|
370
|
+
matrix: input.matrixResult ? {
|
|
371
|
+
autoRun: true,
|
|
372
|
+
evaluatorType: input.matrixResult.matrixEvaluatorType,
|
|
373
|
+
profiles: Object.fromEntries(
|
|
374
|
+
input.matrixResult.profileVerdicts.map((verdict) => [
|
|
375
|
+
verdict.profile,
|
|
376
|
+
formatVariantKeyForDisplay(verdict.winner)
|
|
377
|
+
])
|
|
378
|
+
),
|
|
379
|
+
winnerStatus: input.matrixResult.winnerStatus ?? "accepted",
|
|
380
|
+
winnerCaveats: input.matrixResult.winnerCaveats,
|
|
381
|
+
profilesDisagree: input.matrixResult.disagreements.profilesDisagree,
|
|
382
|
+
profileDecision: formatMatrixProfileDecision(input.matrixResult),
|
|
383
|
+
escalationReasons: input.matrixEscalationReasons
|
|
384
|
+
} : void 0,
|
|
385
|
+
replay: input.replayCommand || input.replayArgv || input.taskLabel || input.executionIntent ? {
|
|
386
|
+
command: input.replayCommand,
|
|
387
|
+
argv: input.replayArgv,
|
|
388
|
+
taskLabel: input.taskLabel,
|
|
389
|
+
executionIntent: input.executionIntent
|
|
390
|
+
} : void 0,
|
|
391
|
+
lab: {
|
|
392
|
+
enabled: Boolean(input.labContext),
|
|
393
|
+
labId: input.labContext?.labId,
|
|
394
|
+
runId: input.labContext?.runId,
|
|
395
|
+
baseline: input.labContext?.baseline
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function resolvePersistedJudgeRunState(input) {
|
|
400
|
+
if (input.isFusionRun) return { status: "skipped", reason: "fusion_no_judge" };
|
|
401
|
+
if (input.judgeOff) return { status: "disabled", reason: "judge_off" };
|
|
402
|
+
if (!input.aiJudgeRequested) return { status: "skipped" };
|
|
403
|
+
if (input.winnerSelectionSource === "algorithmic") {
|
|
404
|
+
return {
|
|
405
|
+
status: "skipped",
|
|
406
|
+
reason: input.winnerSelectionReason ?? input.decisionReason ?? "judge_not_run"
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
if (input.decisionOutcome === "winner_declared") return { status: "completed" };
|
|
410
|
+
if (classifyWinnerSelectionSource(input.winnerSelectionSource).isJudgeDerived) {
|
|
411
|
+
return { status: "completed" };
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
status: "failed",
|
|
415
|
+
reason: input.decisionReason ?? input.decisionOutcome ?? "judge_no_winner"
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function resolveWinnerVerifiedForDecision(input) {
|
|
419
|
+
if (!input.winner || !input.verificationApplicable) return void 0;
|
|
420
|
+
return isWinnerVerifiedForGatePolicy(
|
|
421
|
+
input.winner,
|
|
422
|
+
input.verifiedVariants,
|
|
423
|
+
input.requiredGatePolicy
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
function formatMatrixProfileWinners(matrixResult) {
|
|
427
|
+
return matrixResult.profileVerdicts.map((verdict) => `${verdict.profile}=${formatVariantKeyForDisplay(verdict.winner)}`).join(", ");
|
|
428
|
+
}
|
|
429
|
+
function formatMatrixProfileDecision(matrixResult) {
|
|
430
|
+
if (matrixResult.winnerStatus === "inconclusive") return "inconclusive";
|
|
431
|
+
return matrixResult.disagreements.profilesDisagree ? "split" : "unanimous";
|
|
432
|
+
}
|
|
433
|
+
function isJudgeType(value) {
|
|
434
|
+
return value === "ai" || value === "multi-lens";
|
|
435
|
+
}
|
|
436
|
+
function resolveMatrixDefaultWinnerSource(input) {
|
|
437
|
+
if (isJudgeType(input.synthesisJudgeContext?.selectedJudge)) {
|
|
438
|
+
return input.synthesisJudgeContext.selectedJudge;
|
|
439
|
+
}
|
|
440
|
+
return input.requestedPrimary ?? "ai";
|
|
441
|
+
}
|
|
442
|
+
function hasExecutedTestProvenance(variant) {
|
|
443
|
+
return variant.testsExecuted !== void 0 && variant.testsExecuted.scope !== "none";
|
|
444
|
+
}
|
|
445
|
+
function hasUnavailableTestProvenance(variant) {
|
|
446
|
+
return variant.testsExecuted?.scope === "none" && variant.testsExecuted.skipReason === "verification-unavailable";
|
|
447
|
+
}
|
|
448
|
+
function hasExecutedTestResult(variant) {
|
|
449
|
+
if (variant.testStatus === "passed" || variant.testStatus === "failed") return true;
|
|
450
|
+
if (variant.testStatus === "timeout") return true;
|
|
451
|
+
if ((variant.testMetrics?.failedTests ?? 0) > 0) return true;
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
function mergeJudgeEvaluatedVariantSignals(targetVariants, evaluatedVariants) {
|
|
455
|
+
if (!evaluatedVariants?.length) return;
|
|
456
|
+
const evaluatedByKey = /* @__PURE__ */ new Map();
|
|
457
|
+
for (const evaluated of evaluatedVariants) {
|
|
458
|
+
evaluatedByKey.set(formatJudgeCandidateId(evaluated), evaluated);
|
|
459
|
+
}
|
|
460
|
+
for (const target of targetVariants) {
|
|
461
|
+
const source = evaluatedByKey.get(formatJudgeCandidateId(target));
|
|
462
|
+
if (!source) continue;
|
|
463
|
+
if (source.acceptedWorkspaceTreeSha !== void 0)
|
|
464
|
+
target.acceptedWorkspaceTreeSha = source.acceptedWorkspaceTreeSha;
|
|
465
|
+
const unavailable = source.testsExecuted;
|
|
466
|
+
if (unavailable && hasUnavailableTestProvenance(source)) {
|
|
467
|
+
if (hasExecutedTestResult(target)) continue;
|
|
468
|
+
target.testStatus = "not_run";
|
|
469
|
+
target.testMetrics = void 0;
|
|
470
|
+
target.testsExecuted = {
|
|
471
|
+
...unavailable,
|
|
472
|
+
filesTested: [...unavailable.filesTested]
|
|
473
|
+
};
|
|
474
|
+
target.outcome = deriveVariantOutcome(target);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (!hasExecutedTestProvenance(source)) continue;
|
|
478
|
+
target.testStatus = source.testStatus;
|
|
479
|
+
if (source.testMetrics) {
|
|
480
|
+
target.testMetrics = { ...source.testMetrics };
|
|
481
|
+
}
|
|
482
|
+
if (source.testsExecuted) {
|
|
483
|
+
target.testsExecuted = {
|
|
484
|
+
...source.testsExecuted,
|
|
485
|
+
filesTested: [...source.testsExecuted.filesTested]
|
|
486
|
+
};
|
|
487
|
+
if (source.testsExecuted.sourceFiles) {
|
|
488
|
+
target.testsExecuted.sourceFiles = [...source.testsExecuted.sourceFiles];
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
target.outcome = deriveVariantOutcome(target);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function judgeVerificationStatePatch(variant) {
|
|
495
|
+
return {
|
|
496
|
+
...variant.acceptedWorkspaceTreeSha !== void 0 ? { acceptedWorkspaceTreeSha: variant.acceptedWorkspaceTreeSha } : {},
|
|
497
|
+
...variant.outcome ? { outcome: variant.outcome } : {},
|
|
498
|
+
...variant.testStatus ? { testStatus: variant.testStatus } : {},
|
|
499
|
+
...variant.testMetrics ? { testMetrics: variant.testMetrics } : {},
|
|
500
|
+
...variant.testsExecuted ? { testsExecuted: variant.testsExecuted } : {}
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
var SYNTHESIS_TARGET_TEXT_MAX_CHARS = 400;
|
|
504
|
+
var SYNTHESIS_TARGET_EVIDENCE_MAX_ITEMS = 4;
|
|
505
|
+
var SYNTHESIS_TARGET_EVIDENCE_ITEM_MAX_CHARS = 300;
|
|
506
|
+
function boundSynthesisAdvisoryText(value, maxChars = SYNTHESIS_TARGET_TEXT_MAX_CHARS) {
|
|
507
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
508
|
+
if (normalized.length <= maxChars) return normalized;
|
|
509
|
+
return `${normalized.slice(0, Math.max(0, maxChars - 1)).trimEnd()}\u2026`;
|
|
510
|
+
}
|
|
511
|
+
function boundSynthesisAdvisoryEvidence(evidence) {
|
|
512
|
+
return evidence.slice(0, SYNTHESIS_TARGET_EVIDENCE_MAX_ITEMS).map((item) => boundSynthesisAdvisoryText(item, SYNTHESIS_TARGET_EVIDENCE_ITEM_MAX_CHARS)).filter((item) => item.length > 0);
|
|
513
|
+
}
|
|
514
|
+
function deriveTargetedCriterionGap(matrixResult, selectedWinnerId) {
|
|
515
|
+
const assessments = matrixResult.criterionAssessments;
|
|
516
|
+
const advantages = matrixResult.runnerUpAdvantages;
|
|
517
|
+
if (!assessments || !advantages) return void 0;
|
|
518
|
+
const winnerGaps = assessments.filter(
|
|
519
|
+
(assessment) => assessment.variant === selectedWinnerId && (assessment.status === "partial" || assessment.status === "missing")
|
|
520
|
+
);
|
|
521
|
+
if (winnerGaps.length !== 1) return void 0;
|
|
522
|
+
const gapAssessment = winnerGaps[0];
|
|
523
|
+
if (!gapAssessment) return void 0;
|
|
524
|
+
const gapStatus = gapAssessment.status;
|
|
525
|
+
if (gapStatus !== "partial" && gapStatus !== "missing") return void 0;
|
|
526
|
+
const mappedAdvantages = advantages.filter((advantage) => {
|
|
527
|
+
const gap = advantage.winnerCriterionGap;
|
|
528
|
+
return gap != null && gap.variant === selectedWinnerId && gap.criterionId === gapAssessment.criterionId;
|
|
529
|
+
});
|
|
530
|
+
if (mappedAdvantages.length !== 1) return void 0;
|
|
531
|
+
const donorAdvantage = mappedAdvantages[0];
|
|
532
|
+
if (!donorAdvantage) return void 0;
|
|
533
|
+
const disposition = donorAdvantage.disposition;
|
|
534
|
+
if (disposition !== "adopt" && disposition !== "harvest") return void 0;
|
|
535
|
+
if (donorAdvantage.sourceVariant === selectedWinnerId) return void 0;
|
|
536
|
+
return {
|
|
537
|
+
criterionId: gapAssessment.criterionId,
|
|
538
|
+
status: gapStatus,
|
|
539
|
+
criterionEvidence: boundSynthesisAdvisoryEvidence(gapAssessment.evidence),
|
|
540
|
+
donorVariantId: donorAdvantage.sourceVariant,
|
|
541
|
+
disposition,
|
|
542
|
+
advantage: boundSynthesisAdvisoryText(donorAdvantage.advantage),
|
|
543
|
+
donorEvidence: boundSynthesisAdvisoryEvidence(donorAdvantage.evidence)
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function buildSynthesisMatrixAdvisory(matrixResult, selectedWinnerId) {
|
|
547
|
+
if (!matrixResult || matrixResult.profileVerdicts.length === 0) return void 0;
|
|
548
|
+
const targetedCriterionGap = selectedWinnerId && selectedWinnerId.trim().length > 0 ? deriveTargetedCriterionGap(matrixResult, selectedWinnerId) : void 0;
|
|
549
|
+
return {
|
|
550
|
+
evaluatorType: matrixResult.matrixEvaluatorType,
|
|
551
|
+
winnerStatus: matrixResult.winnerStatus,
|
|
552
|
+
profileDecision: formatMatrixProfileDecision(matrixResult),
|
|
553
|
+
profilesDisagree: matrixResult.disagreements.profilesDisagree,
|
|
554
|
+
profileVerdicts: matrixResult.profileVerdicts.slice(0, 6).map((verdict) => ({
|
|
555
|
+
profile: verdict.profile,
|
|
556
|
+
winner: verdict.winner,
|
|
557
|
+
rationale: verdict.rationale
|
|
558
|
+
})),
|
|
559
|
+
winnerCaveats: matrixResult.winnerCaveats?.slice(0, 5),
|
|
560
|
+
blockingHumanChecks: matrixResult.diagnostics.blockingHumanChecks.slice(0, 5),
|
|
561
|
+
advisoryHumanChecks: matrixResult.diagnostics.advisoryHumanChecks.slice(0, 5),
|
|
562
|
+
...targetedCriterionGap ? { targetedCriterionGap } : {}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function attachMatrixAdvisoryToSynthesisContext(judgeContext, matrixResult, selectedWinnerId) {
|
|
566
|
+
const advisoryMatrix = buildSynthesisMatrixAdvisory(matrixResult, selectedWinnerId);
|
|
567
|
+
if (!advisoryMatrix) return judgeContext;
|
|
568
|
+
if (!judgeContext) return void 0;
|
|
569
|
+
return {
|
|
570
|
+
...judgeContext,
|
|
571
|
+
advisoryMatrix
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function isLowConfidenceBaselineReason(reason) {
|
|
575
|
+
return Boolean(reason?.includes("low_confidence") && reason.includes("baseline_"));
|
|
576
|
+
}
|
|
577
|
+
function resolveEffectiveJudgeDecision(input) {
|
|
578
|
+
const judgeExecutionFailed = input.judgeExecutionFailed === true || isJudgeUnavailableDecision(input.latestDecision);
|
|
579
|
+
const winnerSynthesis = input.winner?.judgeEvaluation;
|
|
580
|
+
const top2 = winnerSynthesis ? resolveJudgeTop2(winnerSynthesis, input.latestDecision) : void 0;
|
|
581
|
+
const inferredStatus = inferDecisionStatus({
|
|
582
|
+
winnerSelectionReason: input.winner?.winnerSelectionReason,
|
|
583
|
+
margin: top2?.margin ?? input.latestDecision?.margin ?? null,
|
|
584
|
+
threshold: input.latestDecision?.closeCallThreshold ?? null
|
|
585
|
+
});
|
|
586
|
+
const decisionStatus = input.latestDecision?.decisionStatus === "declared" && (inferredStatus === "close_call" || inferredStatus === "low_confidence") ? inferredStatus : input.latestDecision?.decisionStatus ?? inferredStatus;
|
|
587
|
+
const inferredEscalation = computeEscalation({
|
|
588
|
+
decisionStatus,
|
|
589
|
+
winner: input.winner ?? void 0,
|
|
590
|
+
margin: top2?.margin ?? input.latestDecision?.margin ?? null,
|
|
591
|
+
winnerConfidence: typeof winnerSynthesis?.metadata?.confidence === "number" ? winnerSynthesis.metadata.confidence : null,
|
|
592
|
+
matrixEscalationThresholds: input.latestDecision?.matrixEscalationThresholds,
|
|
593
|
+
requiredGatePolicy: input.requiredGatePolicy,
|
|
594
|
+
judgeExecutionFailed
|
|
595
|
+
});
|
|
596
|
+
const coordinatorEscalation = input.latestDecision?.escalation;
|
|
597
|
+
if (coordinatorEscalation?.matrixSkipped || coordinatorEscalation?.judgeExecutionFailed) {
|
|
598
|
+
return { decisionStatus, escalation: coordinatorEscalation };
|
|
599
|
+
}
|
|
600
|
+
if (judgeExecutionFailed) {
|
|
601
|
+
return { decisionStatus, escalation: inferredEscalation };
|
|
602
|
+
}
|
|
603
|
+
const selectedEscalation = coordinatorEscalation && coordinatorEscalation.recommended !== "none" ? reconcileEscalationWithPolicy(coordinatorEscalation, inferredEscalation) : inferredEscalation;
|
|
604
|
+
return { decisionStatus, escalation: selectedEscalation };
|
|
605
|
+
}
|
|
606
|
+
function reconcileEscalationWithPolicy(coordinatorEscalation, inferredEscalation) {
|
|
607
|
+
const policyIntegrityReasons = new Set(inferredEscalation.integrityReasons);
|
|
608
|
+
const coordinatorReasons = coordinatorEscalation.reasons.filter(
|
|
609
|
+
(reason) => !isVerificationIntegrityReason(reason) || policyIntegrityReasons.has(reason)
|
|
610
|
+
);
|
|
611
|
+
const mergedReasons = [.../* @__PURE__ */ new Set([...coordinatorReasons, ...inferredEscalation.reasons])];
|
|
612
|
+
if (mergedReasons.length === 0) {
|
|
613
|
+
return {
|
|
614
|
+
recommended: "none",
|
|
615
|
+
reasons: [],
|
|
616
|
+
humanReviewRecommended: false,
|
|
617
|
+
integrityReasons: []
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
const integrityReasons = mergedReasons.filter(isVerificationIntegrityReason);
|
|
621
|
+
return {
|
|
622
|
+
recommended: "matrix",
|
|
623
|
+
reasons: mergedReasons,
|
|
624
|
+
humanReviewRecommended: false,
|
|
625
|
+
integrityReasons
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function formatMatrixAutoRunReason(decision) {
|
|
629
|
+
const reasons = decision?.escalation?.reasons ?? [];
|
|
630
|
+
const margin = typeof decision?.margin === "number" ? decision.margin : void 0;
|
|
631
|
+
const thresholds = decision?.matrixEscalationThresholds;
|
|
632
|
+
const detail = [];
|
|
633
|
+
if (margin !== void 0) {
|
|
634
|
+
detail.push(`margin ${margin.toFixed(1)}`);
|
|
635
|
+
}
|
|
636
|
+
if (thresholds) {
|
|
637
|
+
detail.push(
|
|
638
|
+
`close<=${thresholds.closeCallMargin}, borderline<=${thresholds.borderlineMargin}, confidence<${thresholds.confidenceThreshold}`
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
if (reasons.length > 0) {
|
|
642
|
+
detail.push(`reasons: ${reasons.join(",")}`);
|
|
643
|
+
}
|
|
644
|
+
return detail.length > 0 ? ` (${detail.join("; ")})` : "";
|
|
645
|
+
}
|
|
646
|
+
function resolveWinnerMethodForDisplay(input) {
|
|
647
|
+
if (input.lowConfidenceBaseline) return "algorithmic";
|
|
648
|
+
const info = classifyWinnerSelectionSource(input.source);
|
|
649
|
+
if (info.isMatrixVerdict) return "matrix-verdict";
|
|
650
|
+
if (info.isJudgeDerived) {
|
|
651
|
+
const tier = info.judgeType ?? input.primaryJudge ?? "ai";
|
|
652
|
+
if (tier === "multi-lens") return "multi-lens";
|
|
653
|
+
if (tier === "multi-agent") return "multi-agent";
|
|
654
|
+
return "ai-judge";
|
|
655
|
+
}
|
|
656
|
+
if (input.source === "fallback") return "fallback";
|
|
657
|
+
return "algorithmic";
|
|
658
|
+
}
|
|
659
|
+
function maybePromoteAlgorithmicFallbackWinner(result, fallbackWinner, reason, allowHeuristicFallback) {
|
|
660
|
+
if (!allowHeuristicFallback) {
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
return promoteAlgorithmicFallbackWinner(result, fallbackWinner, reason);
|
|
664
|
+
}
|
|
665
|
+
function promoteAlgorithmicFallbackWinner(result, fallbackWinner, reason, source = "fallback") {
|
|
666
|
+
if (!fallbackWinner) {
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
fallbackWinner.winnerSelectionSource = source;
|
|
670
|
+
fallbackWinner.winnerSelectionReason = fallbackWinner.winnerSelectionReason ? `${fallbackWinner.winnerSelectionReason};${reason}` : reason;
|
|
671
|
+
result.winner = fallbackWinner;
|
|
672
|
+
result.winnerMethod = source;
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
function isJudgeUnavailableDecision(decision) {
|
|
676
|
+
const reason = typeof decision?.reason === "string" ? decision.reason : typeof decision?.decisionOutcome === "string" ? decision.decisionOutcome : "";
|
|
677
|
+
const normalized = reason.toLowerCase();
|
|
678
|
+
return normalized.includes("judge_error") || normalized.includes("timeout") || normalized.includes("abort") || normalized.includes("unavailable");
|
|
679
|
+
}
|
|
680
|
+
function isJudgeInconclusiveDecision(decision) {
|
|
681
|
+
if (!decision || isJudgeUnavailableDecision(decision)) {
|
|
682
|
+
return false;
|
|
683
|
+
}
|
|
684
|
+
const reason = typeof decision.reason === "string" ? decision.reason : typeof decision.decisionOutcome === "string" ? decision.decisionOutcome : "";
|
|
685
|
+
return decision.decisionOutcome === "inconclusive" || /\binconclusive\b/i.test(reason) || /\b(llm[-_]?no[-_]?declaration|no_winner|no-winner)\b/i.test(reason);
|
|
686
|
+
}
|
|
687
|
+
function resolveAlgorithmicFallbackWinner(variantsForJudge, heuristicWinner) {
|
|
688
|
+
if (heuristicWinner && isCompletedVariant(heuristicWinner)) {
|
|
689
|
+
return heuristicWinner;
|
|
690
|
+
}
|
|
691
|
+
if (variantsForJudge.length === 1) {
|
|
692
|
+
const only = variantsForJudge[0];
|
|
693
|
+
return only && isCompletedVariant(only) ? only : null;
|
|
694
|
+
}
|
|
695
|
+
const completed = variantsForJudge.filter((variant) => isCompletedVariant(variant));
|
|
696
|
+
if (completed.length === 0) {
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
if (completed.length === 1) {
|
|
700
|
+
return completed[0] ?? null;
|
|
701
|
+
}
|
|
702
|
+
return completed.sort((a, b) => (b.completeness ?? 0) - (a.completeness ?? 0))[0] ?? null;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// src/cli/handlers/compete/telemetry-winner-verification.ts
|
|
706
|
+
function isWinnerVerifiedByTelemetryResultSet(variants, judgedWinner) {
|
|
707
|
+
const winnerKey = formatJudgeCandidateId(judgedWinner);
|
|
708
|
+
const resultSetWinner = variants.find((variant) => formatJudgeCandidateId(variant) === winnerKey);
|
|
709
|
+
return isVerifiedVariant(resultSetWinner ?? judgedWinner);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// src/cli/handlers/compete/variant-state-file.ts
|
|
713
|
+
import * as fs from "fs/promises";
|
|
714
|
+
import * as path2 from "path";
|
|
715
|
+
var NON_RESULT_SUFFIX = /\.(partial|lifecycle|adaptive-setup)\.json$/;
|
|
716
|
+
function instanceOf(value) {
|
|
717
|
+
return typeof value === "string" ? value.trim() : "";
|
|
718
|
+
}
|
|
719
|
+
async function findVariantStateFile(stateDir, taskId, variant) {
|
|
720
|
+
const prefix = `${taskId.replace(/[^a-zA-Z0-9-_]/g, "")}-`;
|
|
721
|
+
let names;
|
|
722
|
+
try {
|
|
723
|
+
names = await fs.readdir(stateDir);
|
|
724
|
+
} catch {
|
|
725
|
+
return void 0;
|
|
726
|
+
}
|
|
727
|
+
const wanted = formatVariantIdentifierFromResult(variant);
|
|
728
|
+
for (const name of names.filter((n) => n.startsWith(prefix) && n.endsWith(".json")).sort()) {
|
|
729
|
+
if (NON_RESULT_SUFFIX.test(name)) continue;
|
|
730
|
+
const filepath = path2.join(stateDir, name);
|
|
731
|
+
try {
|
|
732
|
+
const stored = JSON.parse(await fs.readFile(filepath, "utf-8"));
|
|
733
|
+
if (stored.provider !== variant.provider) continue;
|
|
734
|
+
if (instanceOf(stored.variantInstanceId) !== instanceOf(variant.variantInstanceId)) continue;
|
|
735
|
+
if (stored.variant === variant.variant || formatVariantIdentifierFromResult(stored) === wanted) {
|
|
736
|
+
return filepath;
|
|
737
|
+
}
|
|
738
|
+
} catch {
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return void 0;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// src/cli/handlers/compete/compete-finalize.ts
|
|
745
|
+
function buildDeliveryArtifactReference(target, synthesisDeliverySelected) {
|
|
746
|
+
if (target.artifactManifest) {
|
|
747
|
+
return {
|
|
748
|
+
kind: "variant-manifest",
|
|
749
|
+
identity: target.artifactManifest,
|
|
750
|
+
variantId: target.variantId,
|
|
751
|
+
manifestPath: target.artifactManifest,
|
|
752
|
+
...target.branchName ? { branch: target.branchName } : {}
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
return {
|
|
756
|
+
kind: synthesisDeliverySelected ? "synthesis-output" : "variant",
|
|
757
|
+
identity: target.variantId,
|
|
758
|
+
variantId: target.variantId,
|
|
759
|
+
...target.branchName ? { branch: target.branchName } : {}
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
function buildAppliedArtifactReference(event) {
|
|
763
|
+
const prNumber = typeof event.prNumber === "number" && Number.isFinite(event.prNumber) ? event.prNumber : void 0;
|
|
764
|
+
if (event.mode === "pr" && prNumber !== void 0) {
|
|
765
|
+
return {
|
|
766
|
+
kind: "pull-request",
|
|
767
|
+
identity: `pr:${prNumber}`,
|
|
768
|
+
variantId: event.variantId,
|
|
769
|
+
prNumber,
|
|
770
|
+
...event.targetPostApplyHeadSha ? { commitSha: event.targetPostApplyHeadSha } : {},
|
|
771
|
+
...event.targetBranch ? { branch: event.targetBranch } : {}
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
return {
|
|
775
|
+
kind: "applied-commit",
|
|
776
|
+
identity: event.targetPostApplyHeadSha ?? event.sourceHeadSha ?? event.variantId,
|
|
777
|
+
variantId: event.variantId,
|
|
778
|
+
...event.targetPostApplyHeadSha ? { commitSha: event.targetPostApplyHeadSha } : {},
|
|
779
|
+
...event.targetBranch ? { branch: event.targetBranch } : {}
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
function buildAppliedCompetitionOutcomeEvent(input) {
|
|
783
|
+
const occurredAt = input.appliedEvent.appliedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
784
|
+
return buildCompetitionOutcomeEvent({
|
|
785
|
+
eventType: "completion_applied",
|
|
786
|
+
competitionId: input.taskId,
|
|
787
|
+
taskId: input.appliedEvent.taskId ?? input.taskId,
|
|
788
|
+
occurredAt,
|
|
789
|
+
...input.judgeVerdictProduced ? {
|
|
790
|
+
finalJudgeWinner: {
|
|
791
|
+
canonicalKey: input.finalJudgeWinner.variantId,
|
|
792
|
+
...input.finalJudgeWinner.executionMode ? { executionMode: input.finalJudgeWinner.executionMode } : {}
|
|
793
|
+
}
|
|
794
|
+
} : {},
|
|
795
|
+
deliveryArtifact: buildDeliveryArtifactReference(
|
|
796
|
+
input.deliveryTarget,
|
|
797
|
+
input.synthesisDeliverySelected
|
|
798
|
+
),
|
|
799
|
+
...input.appliedEvent.reason !== "empty_diff" ? { appliedArtifact: buildAppliedArtifactReference(input.appliedEvent) } : {},
|
|
800
|
+
...input.appliedEvent.postApplyVerification ? { postApplyVerification: input.appliedEvent.postApplyVerification } : {}
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
async function applyWinnerCompletionMode(params) {
|
|
804
|
+
const {
|
|
805
|
+
winnerForApply,
|
|
806
|
+
onApplicationFact,
|
|
807
|
+
synthesisDeliveryForApply,
|
|
808
|
+
verifiedAlternativeForApply,
|
|
809
|
+
winnerVerified,
|
|
810
|
+
verifiedAlternativeLabels = [],
|
|
811
|
+
allowVerifiedAlternativeSubstitution = false,
|
|
812
|
+
resolvedConfig,
|
|
813
|
+
options,
|
|
814
|
+
taskId,
|
|
815
|
+
branchSnapshot,
|
|
816
|
+
telemetry,
|
|
817
|
+
judgeVerdictProduced = false
|
|
818
|
+
} = params;
|
|
819
|
+
const { applyCompletionMode } = await import("./apply-completion-mode-EM37UZHB.js");
|
|
820
|
+
const resolvedCompletionMode = resolvedConfig?.completionMode ?? options.completionMode ?? "auto";
|
|
821
|
+
const completionModeSource = resolvedConfig?.sources.completionMode ?? (options.completionMode ? "flag" : "built-in");
|
|
822
|
+
const requestedEffectiveCompletionMode = resolveEffectiveCompletionMode(resolvedCompletionMode, {
|
|
823
|
+
createPr: options.createPr,
|
|
824
|
+
winner: { executionMode: winnerForApply.executionMode }
|
|
825
|
+
});
|
|
826
|
+
let applyTarget = winnerForApply;
|
|
827
|
+
let synthesisDeliverySelected = false;
|
|
828
|
+
let substitutionReason;
|
|
829
|
+
const synthesisEligibleForDelivery = Boolean(synthesisDeliveryForApply) && synthesisDeliveryForApply?.gatesPassed === true;
|
|
830
|
+
if (synthesisEligibleForDelivery && synthesisDeliveryForApply) {
|
|
831
|
+
telemetry.logCustomEvent({
|
|
832
|
+
event: "completion_mode_synthesis_delivery_selected",
|
|
833
|
+
completion_mode: requestedEffectiveCompletionMode,
|
|
834
|
+
task_id: taskId,
|
|
835
|
+
original_variant_id: winnerForApply.variantId,
|
|
836
|
+
variant_id: synthesisDeliveryForApply.variantId
|
|
837
|
+
});
|
|
838
|
+
applyTarget = synthesisDeliveryForApply;
|
|
839
|
+
synthesisDeliverySelected = true;
|
|
840
|
+
substitutionReason = "gate-validated synthesis selected for delivery";
|
|
841
|
+
} else {
|
|
842
|
+
const eligibility = resolveCompletionEligibility({
|
|
843
|
+
effectiveCompletionMode: requestedEffectiveCompletionMode,
|
|
844
|
+
winnerVerified,
|
|
845
|
+
verifiedAlternativeLabels,
|
|
846
|
+
hasVerifiedAlternativeForApply: Boolean(verifiedAlternativeForApply),
|
|
847
|
+
nearTie: allowVerifiedAlternativeSubstitution
|
|
848
|
+
});
|
|
849
|
+
if (eligibility.action === "refuse") {
|
|
850
|
+
throw new Error(
|
|
851
|
+
`Refusing completion-mode=${requestedEffectiveCompletionMode}: ${eligibility.reason}`
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
if (eligibility.action === "apply-verified-alternative") {
|
|
855
|
+
if (!verifiedAlternativeForApply) {
|
|
856
|
+
throw new Error(
|
|
857
|
+
`Refusing completion-mode=${requestedEffectiveCompletionMode}: judge winner is provisional/unverified while verified variant(s) exist: ${verifiedAlternativeLabels.join(", ")}`
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
telemetry.logCustomEvent({
|
|
861
|
+
event: "completion_mode_verified_alternative_selected",
|
|
862
|
+
completion_mode: requestedEffectiveCompletionMode,
|
|
863
|
+
task_id: taskId,
|
|
864
|
+
original_variant_id: winnerForApply.variantId,
|
|
865
|
+
variant_id: verifiedAlternativeForApply.variantId,
|
|
866
|
+
verified_alternatives: verifiedAlternativeLabels
|
|
867
|
+
});
|
|
868
|
+
applyTarget = verifiedAlternativeForApply;
|
|
869
|
+
substitutionReason = eligibility.reason;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
const effectiveCompletionMode = resolveEffectiveCompletionMode(resolvedCompletionMode, {
|
|
873
|
+
createPr: options.createPr,
|
|
874
|
+
winner: { executionMode: applyTarget.executionMode }
|
|
875
|
+
});
|
|
876
|
+
const applyBoundary = resolveBranchApplyBoundary("compete", options);
|
|
877
|
+
const applyTargetBranch = effectiveCompletionMode === "branch" ? getCurrentBranch(applyBoundary.projectRoot) : branchSnapshot ?? void 0;
|
|
878
|
+
if (effectiveCompletionMode === "branch" && branchSnapshot && applyTargetBranch !== branchSnapshot) {
|
|
879
|
+
throw new Error(
|
|
880
|
+
`Apply target branch changed before completion-mode apply: expected ${branchSnapshot}, found ${applyTargetBranch}`
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
const commingledApply = effectiveCompletionMode === "branch" && Boolean(options.allowCommingleValidationOutput) && applyTargetBranch !== void 0 && isDisposableBranchRole(classifyBranchRole(applyTargetBranch));
|
|
884
|
+
assertCompeteProtectedBranchForCompletionMode({
|
|
885
|
+
allowMain: options.allowMain,
|
|
886
|
+
allowProtected: options.allowProtected,
|
|
887
|
+
allowCommingleValidationOutput: options.allowCommingleValidationOutput,
|
|
888
|
+
command: "compete",
|
|
889
|
+
cwd: applyBoundary.projectRoot,
|
|
890
|
+
currentBranch: applyTargetBranch,
|
|
891
|
+
effectiveCompletionMode
|
|
892
|
+
});
|
|
893
|
+
let appliedEvent;
|
|
894
|
+
let outcomeStreamPersist;
|
|
895
|
+
const applyContext = {
|
|
896
|
+
projectRoot: applyBoundary.projectRoot,
|
|
897
|
+
taskId,
|
|
898
|
+
createPr: options.createPr,
|
|
899
|
+
allowOffScopeRepair: options.allowOffScopeRepair,
|
|
900
|
+
branchApplyAuthority: applyBoundary.authority,
|
|
901
|
+
onApplicationFact,
|
|
902
|
+
deliveryPresentation: {
|
|
903
|
+
judgeWinnerId: judgeVerdictProduced ? winnerForApply.variantId : void 0,
|
|
904
|
+
substitutionReason,
|
|
905
|
+
...judgeWinnerLine.presentation(winnerForApply),
|
|
906
|
+
taskPrompt: params.taskPrompt
|
|
907
|
+
},
|
|
908
|
+
resolvedConfig: resolvedConfig ? {
|
|
909
|
+
variants: resolvedConfig.variants,
|
|
910
|
+
judge: resolvedConfig.judge,
|
|
911
|
+
completionMode: resolvedConfig.completionMode,
|
|
912
|
+
timeout: resolvedConfig.timeout,
|
|
913
|
+
schemaHash: resolvedConfig.schemaHash
|
|
914
|
+
} : void 0,
|
|
915
|
+
onApplied: (event) => {
|
|
916
|
+
appliedEvent = event;
|
|
917
|
+
const isEmptyDiffNoOp = event.reason === "empty_diff";
|
|
918
|
+
const isNonApplyingOutcome = isEmptyDiffNoOp || event.mode === "isolated";
|
|
919
|
+
const postApplyVerificationFailed = event.postApplyVerification?.status === "failed";
|
|
920
|
+
const deliveryStatus = isEmptyDiffNoOp ? "not applied; empty diff" : event.mode === "isolated" ? "retained; no target changes applied" : event.mode === "pr" ? "published" : postApplyVerificationFailed ? "applied; verification failed" : formatPostApplyUnverifiedLabel(event.postApplyVerification, event.changedFiles) ? "applied, unverified" : "applied";
|
|
921
|
+
if (judgeVerdictProduced) console.log(judgeWinnerLine.announce(winnerForApply));
|
|
922
|
+
console.log(`Delivery artifact: ${event.variantId} (${deliveryStatus})`);
|
|
923
|
+
if (substitutionReason) console.log(`Delivery reason: ${substitutionReason}`);
|
|
924
|
+
const competitionOutcomeEvent = isNonApplyingOutcome ? void 0 : buildAppliedCompetitionOutcomeEvent({
|
|
925
|
+
taskId,
|
|
926
|
+
judgeVerdictProduced,
|
|
927
|
+
finalJudgeWinner: winnerForApply,
|
|
928
|
+
deliveryTarget: applyTarget,
|
|
929
|
+
synthesisDeliverySelected,
|
|
930
|
+
appliedEvent: event
|
|
931
|
+
});
|
|
932
|
+
const applyTargetBranchRole = applyTargetBranch ? classifyBranchRole(applyTargetBranch) : void 0;
|
|
933
|
+
const protectedOverride = event.mode === "branch" && applyTargetBranchRole === "protected" ? options.allowProtected ? "--allow-protected" : options.allowMain ? "--allow-main" : null : null;
|
|
934
|
+
telemetry.logCustomEvent({
|
|
935
|
+
event: isNonApplyingOutcome ? "completion_mode_noop" : "completion_mode_applied",
|
|
936
|
+
completion_mode: event.mode,
|
|
937
|
+
variant_id: event.variantId,
|
|
938
|
+
task_id: event.taskId ?? taskId,
|
|
939
|
+
applied_at: event.appliedAt,
|
|
940
|
+
source_branch: event.sourceBranch,
|
|
941
|
+
source_head_sha: event.sourceHeadSha,
|
|
942
|
+
target_branch: event.targetBranch,
|
|
943
|
+
target_pre_apply_head_sha: event.targetPreApplyHeadSha,
|
|
944
|
+
target_post_apply_head_sha: event.targetPostApplyHeadSha,
|
|
945
|
+
diff_source: event.diffSource,
|
|
946
|
+
files_changed: event.filesChanged,
|
|
947
|
+
changed_files: event.changedFiles,
|
|
948
|
+
reason: event.reason,
|
|
949
|
+
post_apply_verification_status: event.postApplyVerification?.status,
|
|
950
|
+
competition_outcome_event: competitionOutcomeEvent,
|
|
951
|
+
...applyTargetBranch ? {
|
|
952
|
+
apply_target_branch: applyTargetBranch,
|
|
953
|
+
apply_target_branch_role: applyTargetBranchRole
|
|
954
|
+
} : {},
|
|
955
|
+
branch_role_action: commingledApply || protectedOverride ? "overridden" : event.mode === "branch" ? "product-fix" : "run-only",
|
|
956
|
+
branch_role_override: commingledApply ? "--allow-commingle-validation-output" : protectedOverride
|
|
957
|
+
});
|
|
958
|
+
updateEvaluationHandleApplicationProvenance(taskId, {
|
|
959
|
+
mode: event.mode,
|
|
960
|
+
// Isolated retention and empty_diff are no-ops: preserve provenance
|
|
961
|
+
// without claiming that target changes were applied.
|
|
962
|
+
status: isNonApplyingOutcome ? "skipped" : postApplyVerificationFailed ? "failed" : "applied",
|
|
963
|
+
variantId: event.variantId,
|
|
964
|
+
taskId: event.taskId ?? taskId,
|
|
965
|
+
appliedAt: event.appliedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
966
|
+
sourceBranch: event.sourceBranch,
|
|
967
|
+
sourceHeadSha: event.sourceHeadSha,
|
|
968
|
+
targetBranch: event.targetBranch ?? applyTargetBranch,
|
|
969
|
+
targetPreApplyHeadSha: event.targetPreApplyHeadSha,
|
|
970
|
+
targetPostApplyHeadSha: event.targetPostApplyHeadSha,
|
|
971
|
+
diffSource: event.diffSource,
|
|
972
|
+
prNumber: event.prNumber,
|
|
973
|
+
changedFiles: event.changedFiles,
|
|
974
|
+
filesChanged: event.filesChanged,
|
|
975
|
+
postApplyVerification: event.postApplyVerification
|
|
976
|
+
});
|
|
977
|
+
if (competitionOutcomeEvent) {
|
|
978
|
+
recordAppliedCompetitionOutcome(
|
|
979
|
+
telemetry,
|
|
980
|
+
event,
|
|
981
|
+
competitionOutcomeEvent,
|
|
982
|
+
judgeVerdictProduced
|
|
983
|
+
);
|
|
984
|
+
if (event.mode === "pr" || event.mode === "branch") {
|
|
985
|
+
outcomeStreamPersist = persistAppliedCompetitionOutcomeEvent(competitionOutcomeEvent);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
try {
|
|
991
|
+
await applyCompletionMode(
|
|
992
|
+
applyTarget,
|
|
993
|
+
resolvedCompletionMode,
|
|
994
|
+
completionModeSource,
|
|
995
|
+
applyContext
|
|
996
|
+
);
|
|
997
|
+
} finally {
|
|
998
|
+
if (outcomeStreamPersist) {
|
|
999
|
+
await outcomeStreamPersist;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return appliedEvent;
|
|
1003
|
+
}
|
|
1004
|
+
function recordAppliedCompetitionOutcome(telemetry, event, competitionOutcomeEvent, judgeVerdictProduced) {
|
|
1005
|
+
try {
|
|
1006
|
+
if (!judgeVerdictProduced) return;
|
|
1007
|
+
if (event.mode !== "pr" && event.mode !== "branch") return;
|
|
1008
|
+
const db = telemetry.getVariantsDb();
|
|
1009
|
+
if (!db) return;
|
|
1010
|
+
const { projectId } = telemetry.getTelemetryContext();
|
|
1011
|
+
const evaluationId = resolveLatestEvaluationId(db, projectId, competitionOutcomeEvent.taskId);
|
|
1012
|
+
const prNumber = typeof event.prNumber === "number" && Number.isFinite(event.prNumber) ? event.prNumber : null;
|
|
1013
|
+
recordCompetitionOutcomeEvent(db, {
|
|
1014
|
+
projectId,
|
|
1015
|
+
evaluationId,
|
|
1016
|
+
outcomeKind: event.mode === "pr" && prNumber !== null ? "pr_opened" : "applied",
|
|
1017
|
+
event: competitionOutcomeEvent,
|
|
1018
|
+
prNumber,
|
|
1019
|
+
commitSha: event.targetPostApplyHeadSha ?? null,
|
|
1020
|
+
validationStatus: event.postApplyVerification?.status ?? null,
|
|
1021
|
+
metadata: {
|
|
1022
|
+
mode: event.mode,
|
|
1023
|
+
targetBranch: event.targetBranch,
|
|
1024
|
+
filesChanged: event.filesChanged
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
} catch (error) {
|
|
1028
|
+
emitCustomWarning(
|
|
1029
|
+
"WARN" /* WARN */,
|
|
1030
|
+
"validation" /* VALIDATION */,
|
|
1031
|
+
"Failed to record competition outcome telemetry",
|
|
1032
|
+
{
|
|
1033
|
+
taskId: competitionOutcomeEvent.taskId,
|
|
1034
|
+
subsystem: "compete-finalize",
|
|
1035
|
+
executionPhase: "cleanup"
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
skipConsole: true,
|
|
1039
|
+
metadata: { error: error instanceof Error ? error.message : String(error) }
|
|
1040
|
+
}
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
async function persistAppliedCompetitionOutcomeEvent(competitionOutcomeEvent) {
|
|
1045
|
+
try {
|
|
1046
|
+
const buildDir = resolveBuildDirFromContext();
|
|
1047
|
+
await persistCompetitionOutcomeEvent(buildDir, competitionOutcomeEvent);
|
|
1048
|
+
} catch (error) {
|
|
1049
|
+
emitCustomWarning(
|
|
1050
|
+
"WARN" /* WARN */,
|
|
1051
|
+
"validation" /* VALIDATION */,
|
|
1052
|
+
"Failed to persist competition outcome event stream",
|
|
1053
|
+
{
|
|
1054
|
+
taskId: competitionOutcomeEvent.taskId,
|
|
1055
|
+
subsystem: "compete-finalize",
|
|
1056
|
+
executionPhase: "cleanup"
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
skipConsole: true,
|
|
1060
|
+
metadata: { error: error instanceof Error ? error.message : String(error) }
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
async function persistJudgeResults(taskId, variants, judgedWinner, buildDir = resolveBuildDirFromContext()) {
|
|
1066
|
+
try {
|
|
1067
|
+
const stateDir = LabPathResolver.getInstance().getVariantStateDir(buildDir);
|
|
1068
|
+
await fs2.mkdir(stateDir, { recursive: true });
|
|
1069
|
+
for (const variant of variants) {
|
|
1070
|
+
if (judgedWinner.judgeEvaluation) {
|
|
1071
|
+
const synthesis = judgedWinner.judgeEvaluation;
|
|
1072
|
+
const candidateId = formatJudgeCandidateId(variant);
|
|
1073
|
+
const evaluation = synthesis.evaluations?.find((e) => e.variant === candidateId);
|
|
1074
|
+
if (evaluation) {
|
|
1075
|
+
variant.judgeEvaluation = synthesis;
|
|
1076
|
+
const bs = evaluation.bucketScores;
|
|
1077
|
+
const rawScore = bs?.delivery != null && bs?.correctness != null && bs?.quality != null ? computeFinalScore({
|
|
1078
|
+
delivery: bs.delivery,
|
|
1079
|
+
correctness: bs.correctness,
|
|
1080
|
+
quality: bs.quality
|
|
1081
|
+
}) : evaluation.qualityScore;
|
|
1082
|
+
variant.judgeScore = typeof rawScore === "number" ? rawScore : Number(rawScore) || void 0;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
const canonicalFilename = `${taskVariantId(
|
|
1086
|
+
taskId,
|
|
1087
|
+
variant.provider,
|
|
1088
|
+
variant.model,
|
|
1089
|
+
variant.executionMode,
|
|
1090
|
+
variant.workspaceMode,
|
|
1091
|
+
{
|
|
1092
|
+
cursorPromptProfile: variant.cursorPromptProfile,
|
|
1093
|
+
variantInstanceId: variant.variantInstanceId
|
|
1094
|
+
},
|
|
1095
|
+
variant.requestedReasoningEffort
|
|
1096
|
+
)}.json`;
|
|
1097
|
+
const legacyFilename = `${taskId}-${variant.provider}-${variant.variant}.json`;
|
|
1098
|
+
const canonicalPath = path3.join(stateDir, canonicalFilename);
|
|
1099
|
+
const legacyPath = path3.join(stateDir, legacyFilename);
|
|
1100
|
+
const canonicalExists = await fileExists(canonicalPath);
|
|
1101
|
+
const legacyExists = await fileExists(legacyPath);
|
|
1102
|
+
const filepath = canonicalExists ? canonicalPath : legacyExists ? legacyPath : await findVariantStateFile(stateDir, taskId, variant);
|
|
1103
|
+
if (!filepath) continue;
|
|
1104
|
+
try {
|
|
1105
|
+
const existing = JSON.parse(await fs2.readFile(filepath, "utf-8"));
|
|
1106
|
+
const merged = {
|
|
1107
|
+
...existing,
|
|
1108
|
+
judgeEvaluation: variant.judgeEvaluation,
|
|
1109
|
+
judgeScore: variant.judgeScore,
|
|
1110
|
+
winnerSelectionSource: variant.winnerSelectionSource,
|
|
1111
|
+
winnerSelectionReason: variant.winnerSelectionReason,
|
|
1112
|
+
...judgeVerificationStatePatch(variant)
|
|
1113
|
+
};
|
|
1114
|
+
await atomicWriteJson(filepath, merged);
|
|
1115
|
+
} catch (error) {
|
|
1116
|
+
const code = error?.code;
|
|
1117
|
+
if (code === "ENOENT") {
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
console.warn(`Failed to persist judge data for ${filepath}:`, error);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
} catch (error) {
|
|
1124
|
+
console.warn("Failed to persist judge results to variant state files:", error);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
function reconcileVariantResultsTelemetry(taskId, variants, telemetry, guidanceMetadata = {}) {
|
|
1128
|
+
const db = telemetry.getVariantsDb();
|
|
1129
|
+
const scope = telemetry.getTelemetryScope();
|
|
1130
|
+
for (const variant of variants) {
|
|
1131
|
+
try {
|
|
1132
|
+
const canonicalKey = getCanonicalVariantKeyFromResult(variant);
|
|
1133
|
+
let artifactManifest;
|
|
1134
|
+
let executionProfileId;
|
|
1135
|
+
let baselineRef;
|
|
1136
|
+
let retainedWorktreePath;
|
|
1137
|
+
let worktreeDiff;
|
|
1138
|
+
let worktreeDiffReplayable = false;
|
|
1139
|
+
if (db) {
|
|
1140
|
+
const existing = db.prepare(
|
|
1141
|
+
`SELECT result_json FROM variant_results WHERE ${scope.where} AND task_id = ? AND variant = ?`
|
|
1142
|
+
).get(...scope.params, taskId, canonicalKey);
|
|
1143
|
+
if (existing?.result_json) {
|
|
1144
|
+
try {
|
|
1145
|
+
const existingJson = JSON.parse(existing.result_json);
|
|
1146
|
+
artifactManifest = typeof existingJson.artifactManifest === "string" ? existingJson.artifactManifest : void 0;
|
|
1147
|
+
executionProfileId = typeof existingJson.executionProfileId === "string" ? existingJson.executionProfileId : void 0;
|
|
1148
|
+
baselineRef = typeof existingJson.baselineRef === "string" ? existingJson.baselineRef : void 0;
|
|
1149
|
+
retainedWorktreePath = typeof existingJson.retainedWorktreePath === "string" ? existingJson.retainedWorktreePath : void 0;
|
|
1150
|
+
worktreeDiffReplayable = existingJson.worktreeDiffReplayable === true;
|
|
1151
|
+
worktreeDiff = typeof existingJson.worktreeDiff === "string" ? existingJson.worktreeDiff : void 0;
|
|
1152
|
+
} catch {
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
const reconciledVariant = {
|
|
1157
|
+
...variant,
|
|
1158
|
+
baselineRef: variant.baselineRef ?? baselineRef,
|
|
1159
|
+
retainedWorktreePath: variant.retainedWorktreePath ?? retainedWorktreePath,
|
|
1160
|
+
worktreeDiff: variant.worktreeDiff ?? worktreeDiff,
|
|
1161
|
+
worktreeDiffReplayable: variant.worktreeDiff != null ? variant.worktreeDiffReplayable : worktreeDiffReplayable,
|
|
1162
|
+
artifactManifest: variant.artifactManifest ?? artifactManifest
|
|
1163
|
+
};
|
|
1164
|
+
telemetry.logVariantResultSnapshot(taskId, canonicalKey, reconciledVariant, {
|
|
1165
|
+
provider: variant.provider,
|
|
1166
|
+
executionMode: variant.executionMode,
|
|
1167
|
+
runMode: "basic-cli-native",
|
|
1168
|
+
executionIntent: variant.executionIntent,
|
|
1169
|
+
reconciledBy: "compete_task_parent",
|
|
1170
|
+
artifactManifest,
|
|
1171
|
+
executionProfileId,
|
|
1172
|
+
executionGuidanceProfile: guidanceMetadata.executionGuidanceProfile,
|
|
1173
|
+
executionGuidanceSource: guidanceMetadata.executionGuidanceSource,
|
|
1174
|
+
placeholdersInRenderedPrompt: guidanceMetadata.placeholdersInRenderedPrompt,
|
|
1175
|
+
renderedPromptHash: guidanceMetadata.renderedPromptHash
|
|
1176
|
+
});
|
|
1177
|
+
} catch (error) {
|
|
1178
|
+
const label = variant.variant || `${variant.provider}:${variant.variant}`;
|
|
1179
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1180
|
+
console.warn(
|
|
1181
|
+
`[telemetry] Failed to reconcile variant_results for ${taskId}/${label}: ${message}`
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
async function fileExists(filepath) {
|
|
1187
|
+
try {
|
|
1188
|
+
await fs2.stat(filepath);
|
|
1189
|
+
return true;
|
|
1190
|
+
} catch {
|
|
1191
|
+
return false;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
function shouldSkipJudgeEvaluationTelemetry(existing) {
|
|
1195
|
+
return Boolean(existing.evaluation);
|
|
1196
|
+
}
|
|
1197
|
+
function buildAiJudgeEvaluationId(taskId) {
|
|
1198
|
+
return `eval-${taskId}-consolidated`;
|
|
1199
|
+
}
|
|
1200
|
+
function buildMultiJudgeEvaluationIds(taskId) {
|
|
1201
|
+
const multiJudgeTypes = ["ai", "multi-lens"];
|
|
1202
|
+
return multiJudgeTypes.map((jt) => `eval-${taskId}-${jt}`);
|
|
1203
|
+
}
|
|
1204
|
+
async function logJudgeEvaluationTelemetry(telemetryLogger, taskId, variants, judgedWinner, closeCallThreshold) {
|
|
1205
|
+
if (!telemetryLogger) return;
|
|
1206
|
+
try {
|
|
1207
|
+
const mappingAudit = judgedWinner?.judgeEvaluation?.metadata?.audit ?? variants.find((variant) => variant.judgeEvaluation?.metadata?.audit)?.judgeEvaluation?.metadata?.audit;
|
|
1208
|
+
const variantLabelMapping = extractVariantLabelMappingFromAudit(mappingAudit);
|
|
1209
|
+
try {
|
|
1210
|
+
const db = telemetryLogger.getVariantsDb?.();
|
|
1211
|
+
if (db) {
|
|
1212
|
+
const checkStmt = db.prepare(`
|
|
1213
|
+
SELECT COUNT(*) as count
|
|
1214
|
+
FROM ai_judge_evaluations
|
|
1215
|
+
WHERE task_id = ? AND evaluation_id IN (?, ?, ?, ?, ?)
|
|
1216
|
+
`);
|
|
1217
|
+
const evalIds = buildMultiJudgeEvaluationIds(taskId);
|
|
1218
|
+
const result = checkStmt.get(taskId, ...evalIds);
|
|
1219
|
+
if (result && result.count >= 2) {
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
} catch {
|
|
1224
|
+
}
|
|
1225
|
+
try {
|
|
1226
|
+
const existing = telemetryLogger.getJudgeEvaluationDetailsWithLabFallback(taskId);
|
|
1227
|
+
if (shouldSkipJudgeEvaluationTelemetry(existing)) return;
|
|
1228
|
+
} catch {
|
|
1229
|
+
}
|
|
1230
|
+
try {
|
|
1231
|
+
const db = telemetryLogger.getVariantsDb?.();
|
|
1232
|
+
if (db) {
|
|
1233
|
+
const consolidatedId = buildAiJudgeEvaluationId(taskId);
|
|
1234
|
+
const row = db.prepare("SELECT 1 FROM ai_judge_evaluations WHERE task_id = ? AND evaluation_id = ?").get(taskId, consolidatedId);
|
|
1235
|
+
if (row) return;
|
|
1236
|
+
}
|
|
1237
|
+
} catch {
|
|
1238
|
+
}
|
|
1239
|
+
if (!judgedWinner || !judgedWinner.judgeEvaluation) return;
|
|
1240
|
+
const synthesis = judgedWinner.judgeEvaluation;
|
|
1241
|
+
const rawWinner = synthesis.winner;
|
|
1242
|
+
const winnerVariant = judgedWinner.variant;
|
|
1243
|
+
const winnerEval = synthesis.evaluations?.find((e) => e.variant === winnerVariant);
|
|
1244
|
+
const winnerScore = Number(winnerEval?.qualityScore) || 0;
|
|
1245
|
+
const overrideApplied = rawWinner !== winnerVariant;
|
|
1246
|
+
const promptTelemetrySummary = extractPromptTelemetrySummaryFromAudit(
|
|
1247
|
+
synthesis.metadata?.audit
|
|
1248
|
+
);
|
|
1249
|
+
const coverageAudit = synthesis.metadata?.audit?.coverage ?? void 0;
|
|
1250
|
+
const winnerPrimaryReason = (!overrideApplied && typeof synthesis.winnerPrimaryReason === "string" ? synthesis.winnerPrimaryReason : typeof winnerEval?.primaryReason === "string" ? winnerEval.primaryReason : overrideApplied ? `Winner adjusted: ${rawWinner} \u2192 ${winnerVariant}.` : void 0) ?? void 0;
|
|
1251
|
+
const winnerReasoning = !overrideApplied ? synthesis.reasoning : [
|
|
1252
|
+
`Winner adjusted: ${rawWinner} \u2192 ${winnerVariant}.`,
|
|
1253
|
+
winnerPrimaryReason ? `Final winner rationale: ${winnerPrimaryReason}` : null,
|
|
1254
|
+
synthesis.reasoning ? `AI reasoning (pre-adjustments): ${synthesis.reasoning}` : null
|
|
1255
|
+
].filter(Boolean).join("\n\n");
|
|
1256
|
+
const winnerReasoningWithPolicy = winnerReasoning;
|
|
1257
|
+
const variantScores = applyVariantLabelsToScores(
|
|
1258
|
+
(synthesis.evaluations || []).reduce((acc, evalEntry) => {
|
|
1259
|
+
acc[evalEntry.variant] = {
|
|
1260
|
+
scores: {
|
|
1261
|
+
quality: Number(evalEntry.qualityScore) || 0
|
|
1262
|
+
},
|
|
1263
|
+
rationale: {
|
|
1264
|
+
strengths: evalEntry.strengths || [],
|
|
1265
|
+
weaknesses: evalEntry.weaknesses || []
|
|
1266
|
+
},
|
|
1267
|
+
confidence: Number(synthesis.metadata?.confidence ?? 0)
|
|
1268
|
+
};
|
|
1269
|
+
return acc;
|
|
1270
|
+
}, {}),
|
|
1271
|
+
variantLabelMapping
|
|
1272
|
+
);
|
|
1273
|
+
const top2Summary = getTop2FromSynthesis(synthesis);
|
|
1274
|
+
const winnerVerified = isWinnerVerifiedByTelemetryResultSet(variants, judgedWinner);
|
|
1275
|
+
const decisionStatus = inferDecisionStatus({
|
|
1276
|
+
winnerSelectionReason: judgedWinner.winnerSelectionReason,
|
|
1277
|
+
margin: top2Summary?.margin ?? null,
|
|
1278
|
+
threshold: closeCallThreshold ?? null
|
|
1279
|
+
});
|
|
1280
|
+
const decisionOutcome = inferDecisionOutcome({
|
|
1281
|
+
winnerSelectionSource: judgedWinner.winnerSelectionSource,
|
|
1282
|
+
winnerSelectionReason: judgedWinner.winnerSelectionReason,
|
|
1283
|
+
decisionStatus,
|
|
1284
|
+
hasWinner: true,
|
|
1285
|
+
winnerVerified
|
|
1286
|
+
});
|
|
1287
|
+
const consistencyTelemetry = extractJudgeConsistencyTelemetry(synthesis);
|
|
1288
|
+
if (consistencyTelemetry.winnerOsBelowRunnerUp === true) {
|
|
1289
|
+
emitWarning(
|
|
1290
|
+
"VAL-001B",
|
|
1291
|
+
{
|
|
1292
|
+
taskId,
|
|
1293
|
+
subsystem: "judge",
|
|
1294
|
+
executionPhase: "validation"
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
severity: "WARN" /* WARN */,
|
|
1298
|
+
metadata: {
|
|
1299
|
+
operation: "aiJudgeConsistencyTelemetry",
|
|
1300
|
+
reason: "winner_os_below_runner_up",
|
|
1301
|
+
winnerVariant
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
telemetryLogger.logJudgeEvaluation(taskId, buildAiJudgeEvaluationId(taskId), {
|
|
1307
|
+
model: synthesis.metadata?.model ?? "ai-judge",
|
|
1308
|
+
reportedModel: synthesis.metadata?.reportedModel,
|
|
1309
|
+
evaluationTimeMs: synthesis.metadata?.evaluationTimeMs ?? 0,
|
|
1310
|
+
totalVariants: variants.length,
|
|
1311
|
+
winnerVariant,
|
|
1312
|
+
winnerScore,
|
|
1313
|
+
winnerConfidence: Number(synthesis.metadata?.confidence ?? 0),
|
|
1314
|
+
winnerRationale: {
|
|
1315
|
+
reasoning: winnerReasoningWithPolicy,
|
|
1316
|
+
decisionStatus,
|
|
1317
|
+
decisionOutcome,
|
|
1318
|
+
winnerSelectionSource: judgedWinner.winnerSelectionSource,
|
|
1319
|
+
winnerSelectionReason: judgedWinner.winnerSelectionReason,
|
|
1320
|
+
margin: top2Summary?.margin,
|
|
1321
|
+
top2: top2Summary?.top2,
|
|
1322
|
+
recommendations: synthesis.recommendations,
|
|
1323
|
+
winnerPrimaryReason,
|
|
1324
|
+
...coverageAudit ? { coverage: coverageAudit } : {},
|
|
1325
|
+
evidenceUsage: synthesis.metadata?.audit?.evidenceUsage ?? void 0,
|
|
1326
|
+
timingMs: synthesis.metadata?.audit?.timingMs && typeof synthesis.metadata.audit.timingMs === "object" ? synthesis.metadata.audit.timingMs : void 0,
|
|
1327
|
+
...promptTelemetrySummary ? { promptTelemetrySummary } : {}
|
|
1328
|
+
},
|
|
1329
|
+
variantLabelMapping,
|
|
1330
|
+
variantScores,
|
|
1331
|
+
rankingScoreInconsistency: consistencyTelemetry.rankingScoreInconsistency,
|
|
1332
|
+
rankingLegacyDiverges: consistencyTelemetry.rankingLegacyDiverges,
|
|
1333
|
+
winnerOsBelowRunnerUp: consistencyTelemetry.winnerOsBelowRunnerUp,
|
|
1334
|
+
synthesisGenerated: false,
|
|
1335
|
+
evaluationDurationMs: synthesis.metadata?.evaluationTimeMs ?? 0,
|
|
1336
|
+
tokensUsed: typeof synthesis.metadata?.audit?.aiTokensUsed === "number" && Number.isFinite(synthesis.metadata.audit.aiTokensUsed) ? synthesis.metadata.audit.aiTokensUsed : typeof synthesis.metadata?.audit?.totalTokensUsed === "number" && Number.isFinite(synthesis.metadata.audit.totalTokensUsed) ? synthesis.metadata.audit.totalTokensUsed : void 0,
|
|
1337
|
+
costUsd: typeof synthesis.metadata?.audit?.aiCostUsd === "number" && Number.isFinite(synthesis.metadata.audit.aiCostUsd) ? synthesis.metadata.audit.aiCostUsd : typeof synthesis.metadata?.audit?.totalCostUsd === "number" && Number.isFinite(synthesis.metadata.audit.totalCostUsd) ? synthesis.metadata.audit.totalCostUsd : void 0,
|
|
1338
|
+
...(() => {
|
|
1339
|
+
const audit = synthesis.metadata?.audit;
|
|
1340
|
+
if (!audit) return {};
|
|
1341
|
+
const extras = {};
|
|
1342
|
+
if (typeof audit.parentTurnsUsed === "number")
|
|
1343
|
+
extras.parentTurnsUsed = audit.parentTurnsUsed;
|
|
1344
|
+
if (typeof audit.parentMaxTurns === "number") extras.parentMaxTurns = audit.parentMaxTurns;
|
|
1345
|
+
if (typeof audit.parentTurnUtilization === "number") {
|
|
1346
|
+
extras.parentTurnUtilization = audit.parentTurnUtilization;
|
|
1347
|
+
}
|
|
1348
|
+
if (audit.parentTurnsSource === "cli_result" || audit.parentTurnsSource === "derived_assistant_messages") {
|
|
1349
|
+
extras.parentTurnsSource = audit.parentTurnsSource;
|
|
1350
|
+
}
|
|
1351
|
+
return extras;
|
|
1352
|
+
})()
|
|
1353
|
+
});
|
|
1354
|
+
} catch (error) {
|
|
1355
|
+
console.warn(
|
|
1356
|
+
`[compete] Failed to log judge evaluation telemetry for ${taskId}: ${error instanceof Error ? error.message : String(error)}`
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
// src/cli/handlers/compete/concurrency-config.ts
|
|
1362
|
+
function asValidConcurrency(value) {
|
|
1363
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
1364
|
+
}
|
|
1365
|
+
async function loadConfiguredConcurrency(explicitRequest) {
|
|
1366
|
+
if (explicitRequest !== void 0) return {};
|
|
1367
|
+
try {
|
|
1368
|
+
const merged = await new ConfigManager().loadConfig();
|
|
1369
|
+
return {
|
|
1370
|
+
maxConcurrent: asValidConcurrency(merged.config.variants?.maxConcurrent),
|
|
1371
|
+
worktreeMax: asValidConcurrency(merged.config.worktree?.maxConcurrent)
|
|
1372
|
+
};
|
|
1373
|
+
} catch (error) {
|
|
1374
|
+
rethrowConfigValidityError(error);
|
|
1375
|
+
return {};
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function concurrencyAdvisoryMessage(effectiveMaxConcurrent) {
|
|
1379
|
+
if (typeof effectiveMaxConcurrent !== "number") return void 0;
|
|
1380
|
+
const legSlots = detectHostConcurrencyBudget().legSlots;
|
|
1381
|
+
if (effectiveMaxConcurrent <= legSlots) return void 0;
|
|
1382
|
+
return `Requested concurrency ${effectiveMaxConcurrent} exceeds this host's recommendation of ${legSlots} legs (see build doctor); running as asked.`;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
// src/cli/handlers/compete/parse-provider-limits.ts
|
|
1386
|
+
function parseProviderLimits(providerLimit) {
|
|
1387
|
+
if (!providerLimit || providerLimit.length === 0) {
|
|
1388
|
+
return void 0;
|
|
1389
|
+
}
|
|
1390
|
+
const limits = {};
|
|
1391
|
+
for (const entry of providerLimit) {
|
|
1392
|
+
const parts = entry.split("=");
|
|
1393
|
+
const providerInput = parts[0]?.trim() ?? "";
|
|
1394
|
+
const limitInput = parts[1]?.trim() ?? "";
|
|
1395
|
+
if (parts.length !== 2 || providerInput.length === 0 || limitInput.length === 0) {
|
|
1396
|
+
throw new Error(`Invalid --provider-limit "${entry}": expected provider=positive-integer`);
|
|
1397
|
+
}
|
|
1398
|
+
if (!/^[1-9]\d*$/.test(limitInput)) {
|
|
1399
|
+
throw new Error(`Invalid --provider-limit "${entry}": limit must be a positive integer`);
|
|
1400
|
+
}
|
|
1401
|
+
const limit = Number(limitInput);
|
|
1402
|
+
if (!Number.isSafeInteger(limit)) {
|
|
1403
|
+
throw new Error(`Invalid --provider-limit "${entry}": limit must be a positive integer`);
|
|
1404
|
+
}
|
|
1405
|
+
const provider = normalizeEngineId(providerInput);
|
|
1406
|
+
if (!registry.has(provider)) {
|
|
1407
|
+
throw new Error(
|
|
1408
|
+
`Unknown provider "${providerInput}" in --provider-limit. Available providers: ${registry.getAllIds().join(", ")}`
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
limits[provider] = limit;
|
|
1412
|
+
}
|
|
1413
|
+
return limits;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
// src/cli/handlers/compete/research-trace-persistence.ts
|
|
1417
|
+
import { mkdir as mkdir2, writeFile } from "fs/promises";
|
|
1418
|
+
import path4 from "path";
|
|
1419
|
+
function resolveNativeResearchTraceDir(buildDir, taskId, resolver = LabPathResolver.getInstance()) {
|
|
1420
|
+
const labContext = resolver.getContext();
|
|
1421
|
+
if (labContext) {
|
|
1422
|
+
return path4.join(
|
|
1423
|
+
buildDir,
|
|
1424
|
+
"labs",
|
|
1425
|
+
labContext.labId,
|
|
1426
|
+
"runs",
|
|
1427
|
+
labContext.runId,
|
|
1428
|
+
"research",
|
|
1429
|
+
taskId
|
|
1430
|
+
);
|
|
1431
|
+
}
|
|
1432
|
+
return path4.join(buildDir, "research", taskId);
|
|
1433
|
+
}
|
|
1434
|
+
async function persistNativeResearchTraces(input) {
|
|
1435
|
+
const traceDir = input.traceDir ?? resolveNativeResearchTraceDir(resolveBuildDirFromContext(input.buildDir), input.taskId);
|
|
1436
|
+
const cleared = new Set(
|
|
1437
|
+
Array.from(input.clearedProviders, (provider) => provider.trim().toLowerCase())
|
|
1438
|
+
);
|
|
1439
|
+
let traceDirReady = false;
|
|
1440
|
+
let tracesPersisted = 0;
|
|
1441
|
+
const failures = [];
|
|
1442
|
+
for (const variant of input.variants) {
|
|
1443
|
+
if (variant.success !== true) continue;
|
|
1444
|
+
if (!cleared.has(variant.provider.trim().toLowerCase())) continue;
|
|
1445
|
+
const variantKey = formatVariantIdentifierFromResult(variant);
|
|
1446
|
+
const trace = parseCitationTrace({
|
|
1447
|
+
variantId: variantKey,
|
|
1448
|
+
provider: variant.provider,
|
|
1449
|
+
mode: "native",
|
|
1450
|
+
output: variant.result?.stdout ?? variant.output ?? "",
|
|
1451
|
+
corroboratedUrls: variant.result?.researchCorroboratedUrls,
|
|
1452
|
+
observedWebToolEvent: variant.result?.researchObservedWebToolEvent,
|
|
1453
|
+
excludedDomains: input.excludedDomains
|
|
1454
|
+
});
|
|
1455
|
+
variant.researchTrace = trace;
|
|
1456
|
+
try {
|
|
1457
|
+
if (!traceDirReady) {
|
|
1458
|
+
await mkdir2(traceDir, { recursive: true });
|
|
1459
|
+
traceDirReady = true;
|
|
1460
|
+
}
|
|
1461
|
+
const tracePath = path4.join(
|
|
1462
|
+
traceDir,
|
|
1463
|
+
`${toVariantSlug(variantKey) || "variant"}-research-trace.json`
|
|
1464
|
+
);
|
|
1465
|
+
trace.artifactPath = tracePath;
|
|
1466
|
+
await writeFile(tracePath, serializeCitationTrace(trace), "utf-8");
|
|
1467
|
+
tracesPersisted++;
|
|
1468
|
+
} catch (error) {
|
|
1469
|
+
failures.push({
|
|
1470
|
+
variantId: variantKey,
|
|
1471
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
const totalCitations = input.variants.reduce(
|
|
1476
|
+
(sum, variant) => sum + (variant.researchTrace?.citations.length ?? 0),
|
|
1477
|
+
0
|
|
1478
|
+
);
|
|
1479
|
+
const excludedDomainViolations = input.variants.reduce(
|
|
1480
|
+
(sum, variant) => sum + (variant.researchTrace?.citations.filter((citation) => citation.excludedDomainViolation).length ?? 0),
|
|
1481
|
+
0
|
|
1482
|
+
);
|
|
1483
|
+
return { traceDir, totalCitations, excludedDomainViolations, tracesPersisted, failures };
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
// src/core/classification/deliverable-contract.ts
|
|
1487
|
+
var SOURCE_FILE_EXTENSION_ALT = getProjectReferencePathExtensions().map((ext) => ext.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
1488
|
+
function parseDeliverableContract(value) {
|
|
1489
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
1490
|
+
const c = value;
|
|
1491
|
+
const isIntent = (v) => v === "code" || v === "analysis" || v === "mixed";
|
|
1492
|
+
const isDeliverable = (v) => v === "analysis" || v === "code" || v === "doc" || v === "mixed";
|
|
1493
|
+
const drift = c.drift;
|
|
1494
|
+
if (!isDeliverable(c.deliverable) || typeof c.editsExpected !== "boolean" || typeof c.editsAllowed !== "boolean" || !isIntent(c.executionIntentEffective) || !isIntent(c.executionIntentOriginal) || typeof c.rationale !== "string" || !Array.isArray(c.requestedVerification) || !c.requestedVerification.every((item) => typeof item === "string") || drift !== void 0 && (typeof drift !== "object" || drift === null || typeof drift.detected !== "boolean" || typeof drift.reason !== "string")) {
|
|
1495
|
+
return void 0;
|
|
1496
|
+
}
|
|
1497
|
+
return value;
|
|
1498
|
+
}
|
|
1499
|
+
function computeDeliverableContract(options) {
|
|
1500
|
+
const {
|
|
1501
|
+
executionIntent: originalIntent,
|
|
1502
|
+
analysisOnly = false,
|
|
1503
|
+
task,
|
|
1504
|
+
analysis,
|
|
1505
|
+
profileRequiresCode = false
|
|
1506
|
+
} = options;
|
|
1507
|
+
const isEvaluationStyleTask = options.isEvaluationStyleTask === true;
|
|
1508
|
+
if (analysisOnly) {
|
|
1509
|
+
return {
|
|
1510
|
+
deliverable: "analysis",
|
|
1511
|
+
editsExpected: false,
|
|
1512
|
+
executionIntentEffective: "analysis",
|
|
1513
|
+
executionIntentOriginal: originalIntent,
|
|
1514
|
+
rationale: "--analysis-only flag explicitly requested analysis-only mode"
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
const hasCodeCues = detectCodeCues(task);
|
|
1518
|
+
const hasExplicitTargets = hasExplicitFileTargets(task, {
|
|
1519
|
+
includeScopedSections: true
|
|
1520
|
+
});
|
|
1521
|
+
const hasStructuredImplementationSpec = detectStructuredImplementationSpec(task, hasCodeCues);
|
|
1522
|
+
const hasExplicitNoEditDirective = classifyExplicitNoEdit(task);
|
|
1523
|
+
const hasGlobalNoEditDirective = hasExplicitNoEditDirective && detectGlobalNoEditDirective(task);
|
|
1524
|
+
const hasActionableEditDirective = detectActionableEditDirective(task) || !hasGlobalNoEditDirective && detectUnlistedFileEditDirective(task);
|
|
1525
|
+
const hasProseResponseOnlyDirective = detectProseResponseOnlyDirective(task);
|
|
1526
|
+
const driftDetected = originalIntent === "analysis" && hasCodeCues && !isEvaluationStyleTask || originalIntent === "mixed" && (hasExplicitTargets || hasStructuredImplementationSpec || hasActionableEditDirective) && !isEvaluationStyleTask;
|
|
1527
|
+
let effectiveIntent = originalIntent;
|
|
1528
|
+
let deliverable = "analysis";
|
|
1529
|
+
let editsExpected = false;
|
|
1530
|
+
let driftReason = "";
|
|
1531
|
+
if ((hasGlobalNoEditDirective || hasProseResponseOnlyDirective) && !hasExplicitTargets && !hasStructuredImplementationSpec && !hasActionableEditDirective) {
|
|
1532
|
+
effectiveIntent = "analysis";
|
|
1533
|
+
deliverable = "analysis";
|
|
1534
|
+
editsExpected = false;
|
|
1535
|
+
driftReason = hasGlobalNoEditDirective ? "Global no-edit directive detected" : "Prose response-only directive detected";
|
|
1536
|
+
} else if (driftDetected) {
|
|
1537
|
+
effectiveIntent = "code";
|
|
1538
|
+
deliverable = "code";
|
|
1539
|
+
editsExpected = true;
|
|
1540
|
+
const expectedValidationArtifactCode = isValidationTargetedCodeOverrideExpected(task) && originalIntent === "mixed" && hasExplicitTargets;
|
|
1541
|
+
if (!expectedValidationArtifactCode) {
|
|
1542
|
+
driftReason = originalIntent === "mixed" ? hasExplicitTargets ? `FILE: markers detected; overriding ${originalIntent} intent to code` : hasStructuredImplementationSpec ? `Structured implementation spec detected; overriding ${originalIntent} intent to code` : `Actionable edit directive detected; overriding ${originalIntent} intent to code` : "Code cues detected in prompt (FILE:, implementation keywords)";
|
|
1543
|
+
}
|
|
1544
|
+
} else {
|
|
1545
|
+
effectiveIntent = originalIntent;
|
|
1546
|
+
if (originalIntent === "code") {
|
|
1547
|
+
deliverable = "code";
|
|
1548
|
+
editsExpected = true;
|
|
1549
|
+
} else if (originalIntent === "analysis") {
|
|
1550
|
+
deliverable = "analysis";
|
|
1551
|
+
editsExpected = false;
|
|
1552
|
+
} else {
|
|
1553
|
+
deliverable = "mixed";
|
|
1554
|
+
editsExpected = true;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
if (!analysisOnly && effectiveIntent !== "analysis" && analysis?.intent === "analysis" && !hasExplicitTargets && !hasStructuredImplementationSpec && !hasActionableEditDirective && !profileRequiresCode && // Files the item's Scope declares outrank the analyzer's wording-based guess. Only this
|
|
1558
|
+
// inferred override reads them: an explicit no-edit directive is decided above and
|
|
1559
|
+
// --analysis-only before that, so a Scope never turns those into code.
|
|
1560
|
+
extractScopedSourceFiles(task).length === 0) {
|
|
1561
|
+
effectiveIntent = "analysis";
|
|
1562
|
+
deliverable = "analysis";
|
|
1563
|
+
editsExpected = false;
|
|
1564
|
+
driftReason = "Analysis intent detected from prompt analysis";
|
|
1565
|
+
}
|
|
1566
|
+
if (!analysisOnly && effectiveIntent !== "analysis" && isEvaluationStyleTask && !profileRequiresCode) {
|
|
1567
|
+
effectiveIntent = "analysis";
|
|
1568
|
+
deliverable = "analysis";
|
|
1569
|
+
editsExpected = false;
|
|
1570
|
+
driftReason = "Evaluation-style task detected";
|
|
1571
|
+
}
|
|
1572
|
+
const rationaleParts = [];
|
|
1573
|
+
if (analysisOnly) {
|
|
1574
|
+
rationaleParts.push("--analysis-only flag");
|
|
1575
|
+
} else if (driftDetected && driftReason) {
|
|
1576
|
+
rationaleParts.push(`Drift detected: ${driftReason}`);
|
|
1577
|
+
rationaleParts.push(`Original intent: ${originalIntent}, Effective: ${effectiveIntent}`);
|
|
1578
|
+
} else {
|
|
1579
|
+
rationaleParts.push(`Intent: ${effectiveIntent}`);
|
|
1580
|
+
}
|
|
1581
|
+
rationaleParts.push(`Deliverable: ${deliverable}, Edits expected: ${editsExpected}`);
|
|
1582
|
+
return {
|
|
1583
|
+
deliverable,
|
|
1584
|
+
editsExpected,
|
|
1585
|
+
executionIntentEffective: effectiveIntent,
|
|
1586
|
+
executionIntentOriginal: originalIntent,
|
|
1587
|
+
...driftReason ? {
|
|
1588
|
+
drift: {
|
|
1589
|
+
detected: true,
|
|
1590
|
+
reason: driftReason
|
|
1591
|
+
}
|
|
1592
|
+
} : {},
|
|
1593
|
+
rationale: rationaleParts.join("; ")
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
function detectCodeCues(task) {
|
|
1597
|
+
if (hasExplicitFileTargets(task, { includeScopedSections: true })) {
|
|
1598
|
+
return true;
|
|
1599
|
+
}
|
|
1600
|
+
const codeKeywords = [
|
|
1601
|
+
/\b(implement|implementation|fix|fixes|add|create|write|edit|update|modify|refactor|refactoring|prevent|secure|enforce|protect|guard)\b/i,
|
|
1602
|
+
/\b(function|class|interface|type|const|let|var)\s+\w+/i,
|
|
1603
|
+
/\b(test|tests|spec|specs)\s+(for|of|that)/i
|
|
1604
|
+
];
|
|
1605
|
+
return codeKeywords.some((pattern) => pattern.test(task));
|
|
1606
|
+
}
|
|
1607
|
+
function detectStructuredImplementationSpec(task, hasCodeCues) {
|
|
1608
|
+
if (!hasCodeCues) return false;
|
|
1609
|
+
const hasAcceptanceCriteria = /^##\s+acceptance criteria\b/im.test(task);
|
|
1610
|
+
const hasVerificationSection = /^##\s+how to verify\b/im.test(task);
|
|
1611
|
+
const hasImplementationSections = /^##\s+scope(?:\s*\/\s*surfaces affected)?\b/im.test(task) || /^##\s+desired behavior\b/im.test(task) || /^##\s+problem\b/im.test(task);
|
|
1612
|
+
return hasAcceptanceCriteria && (hasVerificationSection || hasImplementationSections);
|
|
1613
|
+
}
|
|
1614
|
+
function detectActionableEditDirective(task) {
|
|
1615
|
+
const clauses = withoutNegatedSpans(task).split(/(?<=[.!?])\s+|\n+/).map((clause) => clause.trim()).filter(Boolean);
|
|
1616
|
+
const editThenConcreteTarget = new RegExp(
|
|
1617
|
+
// A qualified test is a concrete target in the singular too ("add a timing
|
|
1618
|
+
// test", "add a micro-benchmark test"): only the bare noun "test" is too
|
|
1619
|
+
// weak to imply a deliverable. An assertion is a test edit ("add one
|
|
1620
|
+
// assertion per runner").
|
|
1621
|
+
`\\b(add|create|write|edit|implement|update|modify|refactor|fix|migrate)\\b[\\s\\S]{0,120}\\b((focused\\s+)?unit\\s+tests?|automated\\s+tests?|regression\\s+tests?|integration\\s+tests?|e2e\\s+tests?|timing\\s+tests?|(?:micro[-\\s])?benchmark\\s+tests?|tests\\b|assertions?\\b|[A-Za-z0-9_./@+-]+\\.(?:${SOURCE_FILE_EXTENSION_ALT}))\\b`,
|
|
1622
|
+
"i"
|
|
1623
|
+
);
|
|
1624
|
+
return clauses.some((clause) => editThenConcreteTarget.test(clause));
|
|
1625
|
+
}
|
|
1626
|
+
function detectUnlistedFileEditDirective(task) {
|
|
1627
|
+
const negatedEditClause = /\b(?:do\s+not|don['']t|without)\s+(?:\w+\s+){0,4}(?:modify|change|edit|update|fix|migrate|touch)\b/i;
|
|
1628
|
+
const fileEditVerbThenFile = /\b(?:edit|update|modify|refactor|fix|migrate)\s+(?:the\s+)?[`'"]?[A-Za-z0-9_./@+-]*[A-Za-z0-9_-]{2}\.[A-Za-z][A-Za-z0-9]{1,9}\b/i;
|
|
1629
|
+
return task.split(/(?<=[.!?])\s+|\n+/).some((clause) => !negatedEditClause.test(clause) && fileEditVerbThenFile.test(clause));
|
|
1630
|
+
}
|
|
1631
|
+
function detectGlobalNoEditDirective(task) {
|
|
1632
|
+
const clauses = task.split(/(?<=[.!?])\s+|\n+/).map((clause) => clause.trim()).filter(Boolean);
|
|
1633
|
+
const noEditDirective = /\b(?:do\s+not|don['']t|without|no)\s+(?:\w+\s+){0,4}(?:modify|change|edit|write|create|add|touch|code\s+changes?|edits?)\b/i;
|
|
1634
|
+
const blanketAnalysisOnly = /\b(?:return|record|provide)\s+(?:findings|analysis|assessment|report)\s+only\b|\b(?:only|just)\s+analy(?:s|z)e\b|\banalysis[- ]only\b|\bread[- ]only\b|\bno\s+code\s+changes?\b/i;
|
|
1635
|
+
const scopedFileToken = new RegExp(
|
|
1636
|
+
`\`[^\`]+\\.[A-Za-z0-9]+\`|[A-Za-z0-9_./@+-]+\\.(?:${SOURCE_FILE_EXTENSION_ALT})\\b|\`\\.[^\`]+\\/\`|\\.[A-Za-z0-9_-]+\\/`,
|
|
1637
|
+
"i"
|
|
1638
|
+
);
|
|
1639
|
+
return clauses.some(
|
|
1640
|
+
(clause) => (noEditDirective.test(clause) || blanketAnalysisOnly.test(clause)) && !scopedFileToken.test(clause)
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
// src/cli/utils/completion-receipt.ts
|
|
1645
|
+
function formatUsage(report) {
|
|
1646
|
+
if (report.usage.status === "partial") {
|
|
1647
|
+
return `tokens partial (${report.coverage.usageReportedInvocations}/${report.coverage.invocations} invocations reported)`;
|
|
1648
|
+
}
|
|
1649
|
+
const total = report.usage.billableTokens === null ? "tokens unavailable" : `${formatTokens(report.usage.billableTokens)} billable tokens`;
|
|
1650
|
+
return report.usage.ambiguousDimensions.length > 0 ? `${total} (ambiguous: ${report.usage.ambiguousDimensions.join(", ")})` : total;
|
|
1651
|
+
}
|
|
1652
|
+
function formatTaskReportCostLabel(report) {
|
|
1653
|
+
const cost = report.cost;
|
|
1654
|
+
switch (cost.status) {
|
|
1655
|
+
case "available":
|
|
1656
|
+
return `$${cost.apiEquivalentUsd.toFixed(4)} (API list price; ${report.coverage.invocations} invocations)`;
|
|
1657
|
+
case "partial":
|
|
1658
|
+
if (cost.estimatedApiEquivalentUsd !== void 0) {
|
|
1659
|
+
return `~$${cost.estimatedApiEquivalentUsd.toFixed(4)} (API list price estimate; pricing partial)`;
|
|
1660
|
+
}
|
|
1661
|
+
if (cost.knownApiEquivalentUsd !== void 0) {
|
|
1662
|
+
return `$${cost.knownApiEquivalentUsd.toFixed(4)} known (API list price; partial, ${cost.pricedInvocations}/${cost.totalInvocations} invocations priced)`;
|
|
1663
|
+
}
|
|
1664
|
+
return `partial (${cost.pricedInvocations}/${cost.totalInvocations} invocations priced)`;
|
|
1665
|
+
case "unavailable":
|
|
1666
|
+
return report.coverage.invocations > 0 ? `unavailable (${cost.reason.replaceAll("_", " ")})` : void 0;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
function formatCost(report) {
|
|
1670
|
+
switch (report.cost.status) {
|
|
1671
|
+
case "available":
|
|
1672
|
+
return `API-equivalent cost $${report.cost.apiEquivalentUsd.toFixed(4)}`;
|
|
1673
|
+
case "partial":
|
|
1674
|
+
if (report.cost.estimatedApiEquivalentUsd !== void 0) {
|
|
1675
|
+
return `API-equivalent cost ~$${report.cost.estimatedApiEquivalentUsd.toFixed(4)} (estimate; pricing partial)`;
|
|
1676
|
+
}
|
|
1677
|
+
if (report.cost.knownApiEquivalentUsd !== void 0) {
|
|
1678
|
+
return `cost partial (${report.cost.pricedInvocations}/${report.cost.totalInvocations} invocations priced; known API-equivalent $${report.cost.knownApiEquivalentUsd.toFixed(4)} across ${report.cost.knownAmountInvocations ?? report.cost.pricedInvocations})`;
|
|
1679
|
+
}
|
|
1680
|
+
return `cost partial (${report.cost.pricedInvocations}/${report.cost.totalInvocations} invocations priced)`;
|
|
1681
|
+
case "unavailable":
|
|
1682
|
+
return `cost unavailable (${report.cost.reason.replaceAll("_", " ")})`;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
var MAX_RECEIPT_MODELS = 3;
|
|
1686
|
+
function formatModels(report) {
|
|
1687
|
+
const models = report.models ?? [];
|
|
1688
|
+
if (models.length === 0) return void 0;
|
|
1689
|
+
const shown = models.slice(0, MAX_RECEIPT_MODELS).map((model) => {
|
|
1690
|
+
const details = [
|
|
1691
|
+
...model.requestedModel ? [`requested ${model.requestedModel}`] : [],
|
|
1692
|
+
...model.contextWindow ? [`context ${formatTokens(model.contextWindow)}`] : []
|
|
1693
|
+
];
|
|
1694
|
+
const name = `${model.provider}/${model.executedModel}`;
|
|
1695
|
+
return details.length > 0 ? `${name} (${details.join(", ")})` : name;
|
|
1696
|
+
});
|
|
1697
|
+
const hidden = models.length - shown.length;
|
|
1698
|
+
return `models ${shown.join("; ")}${hidden > 0 ? `; +${hidden} more` : ""}`;
|
|
1699
|
+
}
|
|
1700
|
+
function formatTaskReportReceipt(report, options = {}) {
|
|
1701
|
+
const wallMs = options.wallMs ?? report.duration.wallMs;
|
|
1702
|
+
const durationLabel = wallMs !== null && wallMs !== void 0 ? `Completed in ${formatDurationMs(wallMs)}` : report.duration.providerBusyMs !== null ? `Provider busy ${formatDurationMs(report.duration.providerBusyMs)}` : "Completed (duration unavailable)";
|
|
1703
|
+
const models = formatModels(report);
|
|
1704
|
+
return `${durationLabel} | ${formatUsage(report)} | ${formatCost(report)}${models ? ` | ${models}` : ""}`;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
// src/orchestrator/judge-completeness-telemetry.ts
|
|
1708
|
+
function isRecord(value) {
|
|
1709
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1710
|
+
}
|
|
1711
|
+
function toJsonValue(value) {
|
|
1712
|
+
if (value === null) return null;
|
|
1713
|
+
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
1714
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
1715
|
+
if (Array.isArray(value)) {
|
|
1716
|
+
return value.map((item) => toJsonValue(item)).filter((item) => item !== void 0);
|
|
1717
|
+
}
|
|
1718
|
+
if (isRecord(value)) {
|
|
1719
|
+
const record = {};
|
|
1720
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1721
|
+
const jsonValue = toJsonValue(item);
|
|
1722
|
+
if (jsonValue !== void 0) {
|
|
1723
|
+
record[key] = jsonValue;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
return record;
|
|
1727
|
+
}
|
|
1728
|
+
return void 0;
|
|
1729
|
+
}
|
|
1730
|
+
function asJsonArray(value) {
|
|
1731
|
+
const jsonValue = toJsonValue(value);
|
|
1732
|
+
return Array.isArray(jsonValue) && jsonValue.length > 0 ? jsonValue : void 0;
|
|
1733
|
+
}
|
|
1734
|
+
function getStringArray(value) {
|
|
1735
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item.trim().length > 0) : [];
|
|
1736
|
+
}
|
|
1737
|
+
function collectNegativeSpace(workerPackets) {
|
|
1738
|
+
if (!Array.isArray(workerPackets)) return void 0;
|
|
1739
|
+
const entries = [];
|
|
1740
|
+
for (const packet of workerPackets) {
|
|
1741
|
+
if (!isRecord(packet) || typeof packet.variantId !== "string") continue;
|
|
1742
|
+
const items = getStringArray(packet.negativeSpace);
|
|
1743
|
+
if (items.length > 0) {
|
|
1744
|
+
entries.push({ variant: packet.variantId, items });
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
return entries.length > 0 ? entries : void 0;
|
|
1748
|
+
}
|
|
1749
|
+
function collectEvidenceConcerns(workerEvidenceMatrix) {
|
|
1750
|
+
if (!isRecord(workerEvidenceMatrix)) return void 0;
|
|
1751
|
+
const concerns = [];
|
|
1752
|
+
const criteriaRows = Array.isArray(workerEvidenceMatrix.criteriaRows) ? workerEvidenceMatrix.criteriaRows : [];
|
|
1753
|
+
for (const row of criteriaRows) {
|
|
1754
|
+
if (!isRecord(row) || !isRecord(row.variants)) continue;
|
|
1755
|
+
const item = typeof row.criterion === "string" ? row.criterion : typeof row.criterionKey === "string" ? row.criterionKey : "acceptance criterion";
|
|
1756
|
+
for (const [variant, cell] of Object.entries(row.variants)) {
|
|
1757
|
+
if (!isRecord(cell)) continue;
|
|
1758
|
+
const evidenceStatus = cell.evidenceStatus === "valid" || cell.evidenceStatus === "invalid" || cell.evidenceStatus === "missing" ? cell.evidenceStatus : void 0;
|
|
1759
|
+
const evidenceKind = typeof cell.evidenceKind === "string" ? cell.evidenceKind : void 0;
|
|
1760
|
+
const category = evidenceKind === "unverifiable" || evidenceStatus === "invalid" ? "unverifiable" : evidenceStatus === "missing" || evidenceKind === "missing" ? "missing" : void 0;
|
|
1761
|
+
if (category) {
|
|
1762
|
+
concerns.push({
|
|
1763
|
+
variant,
|
|
1764
|
+
item,
|
|
1765
|
+
category,
|
|
1766
|
+
...evidenceStatus ? { evidenceStatus } : {},
|
|
1767
|
+
...evidenceKind ? { evidenceKind } : {}
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
const emergentFindings = Array.isArray(workerEvidenceMatrix.emergentFindings) ? workerEvidenceMatrix.emergentFindings : [];
|
|
1773
|
+
for (const finding of emergentFindings) {
|
|
1774
|
+
if (!isRecord(finding) || !isRecord(finding.variants)) continue;
|
|
1775
|
+
const item = typeof finding.finding === "string" ? finding.finding : typeof finding.findingKey === "string" ? finding.findingKey : "emergent finding";
|
|
1776
|
+
for (const [variant, cell] of Object.entries(finding.variants)) {
|
|
1777
|
+
if (!isRecord(cell)) continue;
|
|
1778
|
+
const evidenceStatus = cell.evidenceStatus === "valid" || cell.evidenceStatus === "invalid" || cell.evidenceStatus === "missing" ? cell.evidenceStatus : void 0;
|
|
1779
|
+
const status = typeof cell.status === "string" ? cell.status : void 0;
|
|
1780
|
+
const category = status === "unverifiable" || evidenceStatus === "invalid" ? "unverifiable" : evidenceStatus === "missing" ? "missing" : void 0;
|
|
1781
|
+
if (category) {
|
|
1782
|
+
concerns.push({
|
|
1783
|
+
variant,
|
|
1784
|
+
item,
|
|
1785
|
+
category,
|
|
1786
|
+
...evidenceStatus ? { evidenceStatus } : {}
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
return concerns.length > 0 ? concerns : void 0;
|
|
1792
|
+
}
|
|
1793
|
+
function buildJudgeCompletenessTelemetryFromEvaluation(judgeEvaluation) {
|
|
1794
|
+
const audit = judgeEvaluation?.metadata?.audit;
|
|
1795
|
+
if (!isRecord(audit)) return void 0;
|
|
1796
|
+
const coverageGaps = asJsonArray(audit.coverageGaps);
|
|
1797
|
+
const negativeSpaceByVariant = collectNegativeSpace(audit.workerPackets);
|
|
1798
|
+
const evidenceConcerns = collectEvidenceConcerns(audit.workerEvidenceMatrix);
|
|
1799
|
+
const workerEvidenceMatrix = toJsonValue(audit.workerEvidenceMatrix);
|
|
1800
|
+
if (!coverageGaps && !negativeSpaceByVariant && !evidenceConcerns && workerEvidenceMatrix === void 0) {
|
|
1801
|
+
return void 0;
|
|
1802
|
+
}
|
|
1803
|
+
return {
|
|
1804
|
+
source: "judge-audit",
|
|
1805
|
+
...coverageGaps ? { coverageGaps } : {},
|
|
1806
|
+
...negativeSpaceByVariant ? { negativeSpaceByVariant } : {},
|
|
1807
|
+
...evidenceConcerns ? { evidenceConcerns } : {},
|
|
1808
|
+
...workerEvidenceMatrix !== void 0 ? { workerEvidenceMatrix } : {}
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
function buildJudgeCompletenessTelemetryFromVariants(variants) {
|
|
1812
|
+
for (const variant of variants) {
|
|
1813
|
+
const telemetry = buildJudgeCompletenessTelemetryFromEvaluation(variant.judgeEvaluation);
|
|
1814
|
+
if (telemetry) return telemetry;
|
|
1815
|
+
}
|
|
1816
|
+
return void 0;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
// src/cli/handlers/compete/execute-competition-synthesis.ts
|
|
1820
|
+
import * as path6 from "path";
|
|
1821
|
+
import { execa } from "execa";
|
|
1822
|
+
|
|
1823
|
+
// src/core/synthesis/fusion-synthesizer.ts
|
|
1824
|
+
import { createHash } from "crypto";
|
|
1825
|
+
import { mkdir as mkdir3, rename, unlink, writeFile as writeFile2 } from "fs/promises";
|
|
1826
|
+
import path5 from "path";
|
|
1827
|
+
|
|
1828
|
+
// src/core/synthesis/fusion-synthesis-types.ts
|
|
1829
|
+
var FUSION_SYNTHESIS_MANIFEST_VERSION = 2;
|
|
1830
|
+
var FUSION_SYNTHESIS_COMPLETION_MARKER = "<!-- BUILD_FUSION_COMPLETE -->";
|
|
1831
|
+
|
|
1832
|
+
// src/core/synthesis/fusion-synthesizer.ts
|
|
1833
|
+
var MAX_FUSION_PROMPT_CHARS = 18e4;
|
|
1834
|
+
var MAX_FUSION_RESPONSE_BYTES = 1e6;
|
|
1835
|
+
var DEFAULT_FUSION_SYNTHESIS_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
1836
|
+
var OMITTED_OUTPUT = "[omitted from synthesis artifact; inspect contributor artifacts]";
|
|
1837
|
+
function isSynthesisPin(resolved) {
|
|
1838
|
+
return [resolved.providerSourcePath, resolved.modelSourcePath].some(
|
|
1839
|
+
(sourcePath) => sourcePath.startsWith("cli:") || sourcePath.startsWith("env:BUILD_SYNTHESIS_")
|
|
1840
|
+
);
|
|
1841
|
+
}
|
|
1842
|
+
function resolveFusionSynthesisTarget(synthesisModel, cwd) {
|
|
1843
|
+
const target = synthesisModel ? parseSynthesisModelTarget(synthesisModel) : void 0;
|
|
1844
|
+
const resolved = resolvePreferred("synthesis", {
|
|
1845
|
+
cli: { synthesisProvider: target?.provider, synthesisModel: target?.model },
|
|
1846
|
+
cwd
|
|
1847
|
+
});
|
|
1848
|
+
const reasoningEffort = resolveSynthesisReasoningEffort(
|
|
1849
|
+
target?.effort ? { reasoningEffort: target.effort } : void 0,
|
|
1850
|
+
cwd,
|
|
1851
|
+
resolved.provider
|
|
1852
|
+
)?.value;
|
|
1853
|
+
return { resolved, reasoningEffort };
|
|
1854
|
+
}
|
|
1855
|
+
function synthesisFallbacks(resolved, cwd) {
|
|
1856
|
+
if (!isFailoverEnabled(cwd)) return void 0;
|
|
1857
|
+
return resolveCandidates("synthesis", { cwd, preserveFallbackChain: true }).filter((candidate) => candidate.provider !== resolved.provider).map(({ provider, model }) => ({ provider, model }));
|
|
1858
|
+
}
|
|
1859
|
+
function classifySynthesisRunnerFailure(error) {
|
|
1860
|
+
const category = classifyNoWorkFailure(error);
|
|
1861
|
+
if (category !== "unknown") return category;
|
|
1862
|
+
const { stderr } = error ?? {};
|
|
1863
|
+
return typeof stderr === "string" ? classifyProviderResultFailure({ stdout: "", stderr, exitCode: 1 }) : "unknown";
|
|
1864
|
+
}
|
|
1865
|
+
function buildArtifactPaths(root, taskId) {
|
|
1866
|
+
return {
|
|
1867
|
+
answerPath: path5.join(root, `${taskId}.md`),
|
|
1868
|
+
manifestPath: path5.join(root, `${taskId}.manifest.json`),
|
|
1869
|
+
promptPath: path5.join(root, `${taskId}.prompt.md`),
|
|
1870
|
+
rawResponsePath: path5.join(root, `${taskId}.raw.txt`),
|
|
1871
|
+
replayPath: path5.join(root, `${taskId}.replay.json`)
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
async function atomicWrite(filePath, contents) {
|
|
1875
|
+
await mkdir3(path5.dirname(filePath), { recursive: true });
|
|
1876
|
+
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
1877
|
+
try {
|
|
1878
|
+
await writeFile2(tempPath, contents, "utf8");
|
|
1879
|
+
await rename(tempPath, filePath);
|
|
1880
|
+
} catch (error) {
|
|
1881
|
+
try {
|
|
1882
|
+
await unlink(tempPath);
|
|
1883
|
+
} catch {
|
|
1884
|
+
}
|
|
1885
|
+
throw error;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
function renderFusionPrompt(input) {
|
|
1889
|
+
const variants = input.inputs.variants.map((variant) => {
|
|
1890
|
+
const limit = input.perVariantLimit;
|
|
1891
|
+
const output = limit === void 0 || variant.output.length <= limit ? variant.output : `${variant.output.slice(0, Math.max(0, limit))}
|
|
1892
|
+
[truncated]`;
|
|
1893
|
+
return { ...variant, output };
|
|
1894
|
+
});
|
|
1895
|
+
const metadata = {
|
|
1896
|
+
...input.inputs,
|
|
1897
|
+
variants
|
|
1898
|
+
};
|
|
1899
|
+
return `You are producing Build's final Fusion answer from equal peer contributors.
|
|
1900
|
+
|
|
1901
|
+
Return the complete answer to the Original task as Markdown. Do not return JSON or wrap the
|
|
1902
|
+
answer in an extra code fence unless the task explicitly requests it. Integrate useful agreement,
|
|
1903
|
+
preserve material disagreements and uncertainty in the answer where they affect the recommendation,
|
|
1904
|
+
and obey the task's requested headings, order, audience, and output format. Contributor identifiers
|
|
1905
|
+
are provenance handles, not rankings. Do not declare a winning contributor.
|
|
1906
|
+
|
|
1907
|
+
When a contributor has a researchTrace, use its citations for research-derived claims and do not
|
|
1908
|
+
invent citations. Treat hostState as authoritative for current repository state. Contributor claims
|
|
1909
|
+
that conflict with hostState must be labeled stale, uncorroborated, or provider self-report.
|
|
1910
|
+
|
|
1911
|
+
Do not assert as established fact any load-bearing claim (one a headline, recommendation, or
|
|
1912
|
+
conclusion depends on) that only a single contributor makes or that contributors dispute: attribute
|
|
1913
|
+
it to its source or mark it unverified. Never elevate a single contributor's unverified factual
|
|
1914
|
+
claim to a headline. When contributors conflict on a factual claim, surface the disagreement rather
|
|
1915
|
+
than silently choosing one side.
|
|
1916
|
+
|
|
1917
|
+
End the response with this marker on its own final line:
|
|
1918
|
+
${FUSION_SYNTHESIS_COMPLETION_MARKER}
|
|
1919
|
+
|
|
1920
|
+
Original task:
|
|
1921
|
+
${input.task}
|
|
1922
|
+
|
|
1923
|
+
Host-owned inputs:
|
|
1924
|
+
${JSON.stringify(metadata, null, 2)}
|
|
1925
|
+
`;
|
|
1926
|
+
}
|
|
1927
|
+
function buildBoundedPrompt(task, inputs) {
|
|
1928
|
+
const full = renderFusionPrompt({ task, inputs });
|
|
1929
|
+
if (full.length <= MAX_FUSION_PROMPT_CHARS) {
|
|
1930
|
+
return { prompt: full, truncatedContributorIds: [] };
|
|
1931
|
+
}
|
|
1932
|
+
let low = 0;
|
|
1933
|
+
let high = Math.max(0, ...inputs.variants.map((variant) => variant.output.length));
|
|
1934
|
+
let best = null;
|
|
1935
|
+
let bestLimit = 0;
|
|
1936
|
+
while (low <= high) {
|
|
1937
|
+
const middle = Math.floor((low + high) / 2);
|
|
1938
|
+
const candidate = renderFusionPrompt({ task, inputs, perVariantLimit: middle });
|
|
1939
|
+
if (candidate.length <= MAX_FUSION_PROMPT_CHARS) {
|
|
1940
|
+
best = candidate;
|
|
1941
|
+
bestLimit = middle;
|
|
1942
|
+
low = middle + 1;
|
|
1943
|
+
} else {
|
|
1944
|
+
high = middle - 1;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
if (!best) {
|
|
1948
|
+
throw new Error("Fusion prompt metadata exceeds the bounded prompt budget");
|
|
1949
|
+
}
|
|
1950
|
+
return {
|
|
1951
|
+
prompt: best,
|
|
1952
|
+
truncatedContributorIds: inputs.variants.filter((variant) => variant.output.length > bestLimit).map((variant) => variant.variantId),
|
|
1953
|
+
perContributorChars: bestLimit
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
function stripCompletionMarker(output, providerCompleted) {
|
|
1957
|
+
const normalized = output.replace(/\r\n/g, "\n");
|
|
1958
|
+
const markerPattern = new RegExp(
|
|
1959
|
+
`${providerCompleted ? "" : "(?:^|\\n)"}${FUSION_SYNTHESIS_COMPLETION_MARKER.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`
|
|
1960
|
+
);
|
|
1961
|
+
const observed = markerPattern.test(normalized);
|
|
1962
|
+
const answer = observed ? normalized.replace(markerPattern, "").trimEnd() : normalized.trimEnd();
|
|
1963
|
+
return { answer, observed };
|
|
1964
|
+
}
|
|
1965
|
+
function boundResponse(output) {
|
|
1966
|
+
const bytes = Buffer.from(output, "utf8");
|
|
1967
|
+
if (bytes.length <= MAX_FUSION_RESPONSE_BYTES) return { text: output, exceeded: false };
|
|
1968
|
+
let text = bytes.subarray(0, MAX_FUSION_RESPONSE_BYTES).toString("utf8");
|
|
1969
|
+
while (text.endsWith("\uFFFD")) text = text.slice(0, -1);
|
|
1970
|
+
return { text: `${text.trimEnd()}
|
|
1971
|
+
[truncated]`, exceeded: true };
|
|
1972
|
+
}
|
|
1973
|
+
function summarizeAnswer(answer, answerPath) {
|
|
1974
|
+
return summarizeFusionSections(answer) ?? `Fusion answer has no section headings; read the saved document${answerPath ? ` at ${answerPath}` : ""}.`;
|
|
1975
|
+
}
|
|
1976
|
+
function compatibilityInputs(options) {
|
|
1977
|
+
return {
|
|
1978
|
+
variants: options.variants.map((variant) => ({ ...variant, output: OMITTED_OUTPUT })),
|
|
1979
|
+
selectedTopN: options.variants.length,
|
|
1980
|
+
...options.metadata?.task ? {
|
|
1981
|
+
task: sanitizeSynthesisArtifactForPersistence(
|
|
1982
|
+
options.metadata.task
|
|
1983
|
+
)
|
|
1984
|
+
} : {},
|
|
1985
|
+
...options.metadata?.research ? {
|
|
1986
|
+
research: sanitizeSynthesisArtifactForPersistence(
|
|
1987
|
+
options.metadata.research
|
|
1988
|
+
)
|
|
1989
|
+
} : {},
|
|
1990
|
+
...options.metadata?.contributorHealth ? {
|
|
1991
|
+
contributorHealth: sanitizeSynthesisArtifactForPersistence(
|
|
1992
|
+
options.metadata.contributorHealth
|
|
1993
|
+
)
|
|
1994
|
+
} : {},
|
|
1995
|
+
...options.metadata?.hostState ? {
|
|
1996
|
+
hostState: sanitizeSynthesisArtifactForPersistence(
|
|
1997
|
+
options.metadata.hostState
|
|
1998
|
+
)
|
|
1999
|
+
} : {}
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
function buildCompatibilityResult(input) {
|
|
2003
|
+
const statuses = Object.fromEntries(
|
|
2004
|
+
(input.inputs.contributorHealth ?? []).map((contributor) => [
|
|
2005
|
+
contributor.variantId,
|
|
2006
|
+
contributor.status
|
|
2007
|
+
])
|
|
2008
|
+
);
|
|
2009
|
+
const integrated = Object.values(statuses).filter((status) => status === "included").length;
|
|
2010
|
+
const total = input.inputs.contributorHealth?.length ?? input.inputs.variants.length;
|
|
2011
|
+
return {
|
|
2012
|
+
schemaVersion: 2,
|
|
2013
|
+
status: input.status,
|
|
2014
|
+
crossVariant: {
|
|
2015
|
+
consensus: [],
|
|
2016
|
+
contradictions: [],
|
|
2017
|
+
partialCoverage: [],
|
|
2018
|
+
uniqueInsights: [],
|
|
2019
|
+
blindSpots: []
|
|
2020
|
+
},
|
|
2021
|
+
finalRecommendation: {
|
|
2022
|
+
summary: input.answer ? summarizeAnswer(input.answer, input.answerPath) : "Fusion synthesis unavailable.",
|
|
2023
|
+
recommendation: input.answer,
|
|
2024
|
+
rationale: [],
|
|
2025
|
+
risks: [],
|
|
2026
|
+
nextSteps: []
|
|
2027
|
+
},
|
|
2028
|
+
provenance: input.provenance,
|
|
2029
|
+
inputs: input.inputs,
|
|
2030
|
+
trust: {
|
|
2031
|
+
...integrated >= 2 ? { peerFraming: "equal_peers_no_selection" } : {},
|
|
2032
|
+
contributors: {
|
|
2033
|
+
integrated,
|
|
2034
|
+
total,
|
|
2035
|
+
incomplete: integrated < total,
|
|
2036
|
+
statuses
|
|
2037
|
+
}
|
|
2038
|
+
},
|
|
2039
|
+
...input.inputTruncation ? { inputTruncation: input.inputTruncation } : {},
|
|
2040
|
+
...input.error ? { error: input.error } : {},
|
|
2041
|
+
persistence: input.persistence
|
|
2042
|
+
};
|
|
2043
|
+
}
|
|
2044
|
+
function persistenceFromWritten(written, errors, expected) {
|
|
2045
|
+
const intended = ["prompt", "manifest"];
|
|
2046
|
+
if (expected.rawResponse) intended.push("rawResponse");
|
|
2047
|
+
if (expected.markdown) intended.push("markdown");
|
|
2048
|
+
const count = intended.filter((key) => written[key] === true).length;
|
|
2049
|
+
return {
|
|
2050
|
+
status: count === intended.length ? "written" : count === 0 ? "failed" : "partial",
|
|
2051
|
+
...errors.length > 0 ? { error: sanitizeDiagnosticOutput(errors.join("; "), 1200) ?? "artifact write failed" } : {},
|
|
2052
|
+
written
|
|
2053
|
+
};
|
|
2054
|
+
}
|
|
2055
|
+
async function runFusionSynthesis(options) {
|
|
2056
|
+
const paths = buildArtifactPaths(options.artifactRootDir, options.taskId);
|
|
2057
|
+
const written = {};
|
|
2058
|
+
const writeErrors = [];
|
|
2059
|
+
const startedAt = Date.now();
|
|
2060
|
+
const inputs = compatibilityInputs(options);
|
|
2061
|
+
let status = "succeeded";
|
|
2062
|
+
const degradedReasons = [];
|
|
2063
|
+
let providerCompleted = false;
|
|
2064
|
+
let terminalOutputPresent = false;
|
|
2065
|
+
let completionMarkerObserved = false;
|
|
2066
|
+
let responseBoundExceeded = false;
|
|
2067
|
+
let rawOutput = "";
|
|
2068
|
+
let answer = "";
|
|
2069
|
+
let errorMessage;
|
|
2070
|
+
const persistenceExpected = {
|
|
2071
|
+
rawResponse: options.variants.length >= 2,
|
|
2072
|
+
markdown: false
|
|
2073
|
+
};
|
|
2074
|
+
const providerUsage = {};
|
|
2075
|
+
const provenance = {};
|
|
2076
|
+
let prompt = "";
|
|
2077
|
+
let inputTruncation;
|
|
2078
|
+
try {
|
|
2079
|
+
const { resolved, reasoningEffort } = resolveFusionSynthesisTarget(
|
|
2080
|
+
options.synthesisModel,
|
|
2081
|
+
options.workingDir ?? process.cwd()
|
|
2082
|
+
);
|
|
2083
|
+
Object.assign(provenance, {
|
|
2084
|
+
provider: resolved.provider,
|
|
2085
|
+
model: resolved.model,
|
|
2086
|
+
reasoningEffort
|
|
2087
|
+
});
|
|
2088
|
+
if (options.variants.length < 2) {
|
|
2089
|
+
prompt = options.variants.length === 0 ? "Fusion provider was not invoked because no usable contributors were available." : `Fusion provider was not invoked because the sole contributor ${options.variants[0]?.variantId ?? "unknown"} was returned directly.`;
|
|
2090
|
+
} else {
|
|
2091
|
+
const boundedPrompt = buildBoundedPrompt(options.task, {
|
|
2092
|
+
...inputs,
|
|
2093
|
+
variants: options.variants
|
|
2094
|
+
});
|
|
2095
|
+
prompt = boundedPrompt.prompt;
|
|
2096
|
+
if (boundedPrompt.truncatedContributorIds.length > 0 && boundedPrompt.perContributorChars !== void 0) {
|
|
2097
|
+
const affected = new Set(boundedPrompt.truncatedContributorIds);
|
|
2098
|
+
const perContributorChars = boundedPrompt.perContributorChars;
|
|
2099
|
+
inputTruncation = {
|
|
2100
|
+
affectedContributors: boundedPrompt.truncatedContributorIds,
|
|
2101
|
+
perContributorChars,
|
|
2102
|
+
contributors: options.variants.filter((variant) => affected.has(variant.variantId)).map((variant) => ({
|
|
2103
|
+
variantId: variant.variantId,
|
|
2104
|
+
originalChars: variant.output.length,
|
|
2105
|
+
consumedChars: Math.min(variant.output.length, perContributorChars)
|
|
2106
|
+
}))
|
|
2107
|
+
};
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
await atomicWrite(paths.promptPath, sanitizeSynthesisStringForPersistence(prompt));
|
|
2111
|
+
written.prompt = true;
|
|
2112
|
+
if (options.variants.length === 0) {
|
|
2113
|
+
status = "skipped";
|
|
2114
|
+
degradedReasons.push("no_usable_contributors");
|
|
2115
|
+
} else if (options.variants.length === 1) {
|
|
2116
|
+
status = "degraded";
|
|
2117
|
+
degradedReasons.push("fewer_than_two_contributors");
|
|
2118
|
+
answer = (options.variants[0]?.output ?? "").trimEnd();
|
|
2119
|
+
} else {
|
|
2120
|
+
const runner = options.providerRunner ?? runAnalysisSynthesisProvider;
|
|
2121
|
+
const cwd = options.workingDir ?? process.cwd();
|
|
2122
|
+
try {
|
|
2123
|
+
const { value: attempted } = await runWithProviderFailover({
|
|
2124
|
+
first: { provider: resolved.provider, model: resolved.model },
|
|
2125
|
+
fallbacks: isSynthesisPin(resolved) ? void 0 : () => synthesisFallbacks(resolved, cwd),
|
|
2126
|
+
callSite: "fusion-synthesis",
|
|
2127
|
+
attempt: (candidate) => runner(prompt, {
|
|
2128
|
+
provider: candidate.provider,
|
|
2129
|
+
model: candidate.model,
|
|
2130
|
+
modelReasoningEffort: candidate.provider === resolved.provider ? reasoningEffort : resolveSynthesisReasoningEffort(void 0, cwd, candidate.provider)?.value,
|
|
2131
|
+
taskId: options.taskId,
|
|
2132
|
+
workingDir: cwd,
|
|
2133
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_FUSION_SYNTHESIS_TIMEOUT_MS
|
|
2134
|
+
}).then(
|
|
2135
|
+
(output2) => ({ output: output2 }),
|
|
2136
|
+
(error) => ({ error })
|
|
2137
|
+
),
|
|
2138
|
+
failureOf: (attempted2) => "error" in attempted2 ? classifySynthesisRunnerFailure(attempted2.error) : void 0,
|
|
2139
|
+
onSwitch: options.onProviderSwitch ?? printProviderSwitchNotice
|
|
2140
|
+
});
|
|
2141
|
+
if ("error" in attempted) throw attempted.error;
|
|
2142
|
+
const { output } = attempted;
|
|
2143
|
+
providerCompleted = true;
|
|
2144
|
+
rawOutput = output.stdout;
|
|
2145
|
+
provenance.provider = output.invocation.provider;
|
|
2146
|
+
provenance.model = output.invocation.model;
|
|
2147
|
+
provenance.reasoningEffort = output.invocation.reasoningEffort;
|
|
2148
|
+
if (typeof output.totalCostUsd === "number") {
|
|
2149
|
+
providerUsage.totalCostUsd = output.totalCostUsd;
|
|
2150
|
+
}
|
|
2151
|
+
if (typeof output.tokenUsage?.inputTokens === "number") {
|
|
2152
|
+
providerUsage.inputTokens = output.tokenUsage.inputTokens;
|
|
2153
|
+
}
|
|
2154
|
+
if (typeof output.tokenUsage?.outputTokens === "number") {
|
|
2155
|
+
providerUsage.outputTokens = output.tokenUsage.outputTokens;
|
|
2156
|
+
}
|
|
2157
|
+
} catch (error) {
|
|
2158
|
+
const providerError = error;
|
|
2159
|
+
errorMessage = sanitizeDiagnosticOutput(providerError.message, 1200) ?? "Fusion provider failed";
|
|
2160
|
+
rawOutput = typeof providerError.stdout === "string" ? providerError.stdout : typeof providerError.rawStdout === "string" ? providerError.rawStdout : "";
|
|
2161
|
+
degradedReasons.push("provider_failed");
|
|
2162
|
+
}
|
|
2163
|
+
const bounded = boundResponse(rawOutput);
|
|
2164
|
+
responseBoundExceeded = bounded.exceeded;
|
|
2165
|
+
terminalOutputPresent = bounded.text.trim().length > 0;
|
|
2166
|
+
const stripped = stripCompletionMarker(bounded.text, providerCompleted);
|
|
2167
|
+
completionMarkerObserved = stripped.observed;
|
|
2168
|
+
answer = stripped.answer;
|
|
2169
|
+
if (!providerCompleted && !completionMarkerObserved) answer = "";
|
|
2170
|
+
if (responseBoundExceeded) degradedReasons.push("response_bound_exceeded");
|
|
2171
|
+
if (!completionMarkerObserved) degradedReasons.push("completion_marker_missing");
|
|
2172
|
+
if (!providerCompleted) degradedReasons.push("provider_completion_unconfirmed");
|
|
2173
|
+
if (answer.trim().length === 0) {
|
|
2174
|
+
status = "failed";
|
|
2175
|
+
degradedReasons.push("empty_synthesis_answer");
|
|
2176
|
+
} else if (degradedReasons.length > 0) {
|
|
2177
|
+
status = "degraded";
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
} catch (error) {
|
|
2181
|
+
status = "failed";
|
|
2182
|
+
errorMessage = sanitizeDiagnosticOutput(error instanceof Error ? error.message : String(error), 1200) ?? "Fusion synthesis failed";
|
|
2183
|
+
degradedReasons.push("host_synthesis_failure");
|
|
2184
|
+
}
|
|
2185
|
+
answer = stripPreambleBeforeFirstHeading(answer);
|
|
2186
|
+
const redaction = redactSynthesisDeliverableSecrets(answer);
|
|
2187
|
+
answer = redaction.value;
|
|
2188
|
+
persistenceExpected.markdown = answer.trim().length > 0;
|
|
2189
|
+
if (redaction.redacted) degradedReasons.push("secret_redaction_applied");
|
|
2190
|
+
if (degradedReasons.length > 0 && status === "succeeded") status = "degraded";
|
|
2191
|
+
if (options.variants.length >= 2) {
|
|
2192
|
+
try {
|
|
2193
|
+
await atomicWrite(
|
|
2194
|
+
paths.rawResponsePath,
|
|
2195
|
+
sanitizeSynthesisStringForPersistence(boundResponse(rawOutput).text)
|
|
2196
|
+
);
|
|
2197
|
+
written.rawResponse = true;
|
|
2198
|
+
} catch (error) {
|
|
2199
|
+
writeErrors.push(error instanceof Error ? error.message : String(error));
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
if (answer.trim().length > 0) {
|
|
2203
|
+
try {
|
|
2204
|
+
await atomicWrite(paths.answerPath, answer.endsWith("\n") ? answer : `${answer}
|
|
2205
|
+
`);
|
|
2206
|
+
written.markdown = true;
|
|
2207
|
+
} catch (error) {
|
|
2208
|
+
writeErrors.push(error instanceof Error ? error.message : String(error));
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
if (answer.trim().length > 0 && written.markdown !== true) {
|
|
2212
|
+
status = "failed";
|
|
2213
|
+
degradedReasons.push("answer_persistence_failed");
|
|
2214
|
+
}
|
|
2215
|
+
if (options.isLabRun === true) {
|
|
2216
|
+
try {
|
|
2217
|
+
const replayCorpus = {
|
|
2218
|
+
schemaVersion: 1,
|
|
2219
|
+
kind: "fusion-replay-corpus",
|
|
2220
|
+
taskId: options.taskId,
|
|
2221
|
+
task: options.task,
|
|
2222
|
+
variants: options.variants,
|
|
2223
|
+
...options.metadata ? { metadata: options.metadata } : {}
|
|
2224
|
+
};
|
|
2225
|
+
await atomicWrite(paths.replayPath, `${JSON.stringify(replayCorpus, null, 2)}
|
|
2226
|
+
`);
|
|
2227
|
+
written.replay = true;
|
|
2228
|
+
} catch (error) {
|
|
2229
|
+
writeErrors.push(error instanceof Error ? error.message : String(error));
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
Object.assign(provenance, providerUsage, {
|
|
2233
|
+
rawResponsePath: written.rawResponse ? paths.rawResponsePath : void 0,
|
|
2234
|
+
durationMs: Date.now() - startedAt
|
|
2235
|
+
});
|
|
2236
|
+
const preManifestPersistence = persistenceFromWritten(written, writeErrors, persistenceExpected);
|
|
2237
|
+
const manifest = {
|
|
2238
|
+
schemaVersion: FUSION_SYNTHESIS_MANIFEST_VERSION,
|
|
2239
|
+
kind: "fusion-synthesis-manifest",
|
|
2240
|
+
taskId: options.taskId,
|
|
2241
|
+
status,
|
|
2242
|
+
degradedReasons: [...new Set(degradedReasons)],
|
|
2243
|
+
...inputTruncation ? { inputTruncation } : {},
|
|
2244
|
+
...written.markdown ? {
|
|
2245
|
+
answer: {
|
|
2246
|
+
path: formatAnalysisSynthesisArtifactPath(paths.answerPath),
|
|
2247
|
+
sha256: createHash("sha256").update(answer.endsWith("\n") ? answer : `${answer}
|
|
2248
|
+
`).digest("hex"),
|
|
2249
|
+
bytes: Buffer.byteLength(answer.endsWith("\n") ? answer : `${answer}
|
|
2250
|
+
`, "utf8"),
|
|
2251
|
+
secretRedactionApplied: redaction.redacted
|
|
2252
|
+
}
|
|
2253
|
+
} : {},
|
|
2254
|
+
contributors: inputs.contributorHealth ?? [],
|
|
2255
|
+
provenance: sanitizeSynthesisArtifactForPersistence({
|
|
2256
|
+
...provenance,
|
|
2257
|
+
promptPath: written.prompt ? formatAnalysisSynthesisArtifactPath(paths.promptPath) : void 0,
|
|
2258
|
+
rawResponsePath: written.rawResponse ? formatAnalysisSynthesisArtifactPath(paths.rawResponsePath) : void 0
|
|
2259
|
+
}),
|
|
2260
|
+
completion: {
|
|
2261
|
+
providerCompleted,
|
|
2262
|
+
terminalOutputPresent,
|
|
2263
|
+
completionMarkerObserved,
|
|
2264
|
+
responseBoundExceeded
|
|
2265
|
+
},
|
|
2266
|
+
...inputs.research ? { research: inputs.research } : {},
|
|
2267
|
+
...inputs.hostState ? { hostState: inputs.hostState } : {},
|
|
2268
|
+
artifacts: {
|
|
2269
|
+
...written.prompt ? { promptPath: formatAnalysisSynthesisArtifactPath(paths.promptPath) } : {},
|
|
2270
|
+
...written.rawResponse ? { rawResponsePath: formatAnalysisSynthesisArtifactPath(paths.rawResponsePath) } : {},
|
|
2271
|
+
...written.markdown ? { answerPath: formatAnalysisSynthesisArtifactPath(paths.answerPath) } : {},
|
|
2272
|
+
manifestPath: formatAnalysisSynthesisArtifactPath(paths.manifestPath),
|
|
2273
|
+
...written.replay ? { replayPath: formatAnalysisSynthesisArtifactPath(paths.replayPath) } : {}
|
|
2274
|
+
},
|
|
2275
|
+
persistence: preManifestPersistence,
|
|
2276
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2277
|
+
...errorMessage ? { error: errorMessage } : {}
|
|
2278
|
+
};
|
|
2279
|
+
try {
|
|
2280
|
+
const finalPersistence = {
|
|
2281
|
+
...persistenceFromWritten(
|
|
2282
|
+
{ ...written, manifest: true, json: true },
|
|
2283
|
+
writeErrors,
|
|
2284
|
+
persistenceExpected
|
|
2285
|
+
),
|
|
2286
|
+
written: { ...written, manifest: true, json: true }
|
|
2287
|
+
};
|
|
2288
|
+
manifest.persistence = finalPersistence;
|
|
2289
|
+
await atomicWrite(paths.manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
2290
|
+
`);
|
|
2291
|
+
written.manifest = true;
|
|
2292
|
+
written.json = true;
|
|
2293
|
+
} catch (error) {
|
|
2294
|
+
writeErrors.push(error instanceof Error ? error.message : String(error));
|
|
2295
|
+
}
|
|
2296
|
+
if (written.manifest !== true) {
|
|
2297
|
+
status = written.markdown === true ? "degraded" : "failed";
|
|
2298
|
+
degradedReasons.push("manifest_persistence_failed");
|
|
2299
|
+
manifest.status = status;
|
|
2300
|
+
manifest.degradedReasons = [...new Set(degradedReasons)];
|
|
2301
|
+
}
|
|
2302
|
+
if (options.reconcile === true && options.variants.length >= 2 && answer.trim().length > 0 && written.manifest === true) {
|
|
2303
|
+
const totalBudgetMs = options.timeoutMs ?? DEFAULT_FUSION_SYNTHESIS_TIMEOUT_MS;
|
|
2304
|
+
const remainingBudgetMs = totalBudgetMs - (Date.now() - startedAt);
|
|
2305
|
+
if (remainingBudgetMs <= 0) {
|
|
2306
|
+
manifest.reconciliation = {
|
|
2307
|
+
status: "skipped",
|
|
2308
|
+
reason: "timeout_budget_exhausted"
|
|
2309
|
+
};
|
|
2310
|
+
} else {
|
|
2311
|
+
const reconciliationOutput = await runAnalysisSynthesis({
|
|
2312
|
+
taskId: options.taskId,
|
|
2313
|
+
task: `${options.task}
|
|
2314
|
+
|
|
2315
|
+
Already delivered Fusion answer (audit it; do not replace it):
|
|
2316
|
+
${answer}`,
|
|
2317
|
+
variants: options.variants,
|
|
2318
|
+
judge: {},
|
|
2319
|
+
runSemantics: "fusion",
|
|
2320
|
+
selectedTopN: options.variants.length,
|
|
2321
|
+
synthesisModel: options.synthesisModel,
|
|
2322
|
+
timeoutMs: remainingBudgetMs,
|
|
2323
|
+
metadata: options.metadata,
|
|
2324
|
+
artifactRootDir: path5.join(options.artifactRootDir, "reconciliation"),
|
|
2325
|
+
workingDir: options.workingDir,
|
|
2326
|
+
providerRunner: options.providerRunner
|
|
2327
|
+
});
|
|
2328
|
+
manifest.reconciliation = {
|
|
2329
|
+
status: reconciliationOutput.result.status,
|
|
2330
|
+
...reconciliationOutput.paths.jsonPath ? {
|
|
2331
|
+
jsonPath: formatAnalysisSynthesisArtifactPath(reconciliationOutput.paths.jsonPath)
|
|
2332
|
+
} : {},
|
|
2333
|
+
...reconciliationOutput.paths.markdownPath ? {
|
|
2334
|
+
markdownPath: formatAnalysisSynthesisArtifactPath(
|
|
2335
|
+
reconciliationOutput.paths.markdownPath
|
|
2336
|
+
)
|
|
2337
|
+
} : {}
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2340
|
+
manifest.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2341
|
+
try {
|
|
2342
|
+
await atomicWrite(paths.manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
2343
|
+
`);
|
|
2344
|
+
} catch (error) {
|
|
2345
|
+
writeErrors.push(error instanceof Error ? error.message : String(error));
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
const persistence = persistenceFromWritten(written, writeErrors, persistenceExpected);
|
|
2349
|
+
manifest.persistence = persistence;
|
|
2350
|
+
const result = buildCompatibilityResult({
|
|
2351
|
+
status,
|
|
2352
|
+
answer,
|
|
2353
|
+
inputs,
|
|
2354
|
+
provenance,
|
|
2355
|
+
persistence,
|
|
2356
|
+
...inputTruncation ? { inputTruncation } : {},
|
|
2357
|
+
...written.markdown ? { answerPath: formatAnalysisSynthesisArtifactPath(paths.answerPath) } : {},
|
|
2358
|
+
...errorMessage ? { error: errorMessage } : {}
|
|
2359
|
+
});
|
|
2360
|
+
return {
|
|
2361
|
+
result,
|
|
2362
|
+
manifest,
|
|
2363
|
+
paths: {
|
|
2364
|
+
...written.markdown ? { answerPath: paths.answerPath } : {},
|
|
2365
|
+
...written.manifest ? { manifestPath: paths.manifestPath } : {},
|
|
2366
|
+
...written.prompt ? { promptPath: paths.promptPath } : {},
|
|
2367
|
+
...written.rawResponse ? { rawResponsePath: paths.rawResponsePath } : {}
|
|
2368
|
+
},
|
|
2369
|
+
persistence
|
|
2370
|
+
};
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
// src/cli/handlers/compete/execute-competition-synthesis.ts
|
|
2374
|
+
function resolveAnalysisSynthesisArtifactRoot(buildDir, resolver = LabPathResolver.getInstance()) {
|
|
2375
|
+
const labContext = resolver.getContext();
|
|
2376
|
+
if (labContext) {
|
|
2377
|
+
return path6.join(
|
|
2378
|
+
resolveLabsRoot(buildDir),
|
|
2379
|
+
labContext.labId,
|
|
2380
|
+
"runs",
|
|
2381
|
+
labContext.runId,
|
|
2382
|
+
"analysis-synthesis"
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2385
|
+
return path6.join(buildDir, "analysis-synthesis");
|
|
2386
|
+
}
|
|
2387
|
+
var HOST_STATE_STATUS_TIMEOUT_MS = 5e3;
|
|
2388
|
+
var HOST_STATE_MAX_LINES = 80;
|
|
2389
|
+
var HOST_STATE_MAX_CHARS = 8e3;
|
|
2390
|
+
function sanitizeHostStateCwd(cwd) {
|
|
2391
|
+
const basename2 = path6.basename(path6.resolve(cwd));
|
|
2392
|
+
return basename2.length > 0 ? basename2 : ".";
|
|
2393
|
+
}
|
|
2394
|
+
function boundHostGitStatus(stdout) {
|
|
2395
|
+
const normalized = filterWorktreeRunSentinelStatusOutput(stdout ?? "").replace(/\r\n/g, "\n").trimEnd();
|
|
2396
|
+
if (normalized.length === 0) return { text: "", truncated: false };
|
|
2397
|
+
let truncated = false;
|
|
2398
|
+
const lines = normalized.split("\n");
|
|
2399
|
+
let selected = lines;
|
|
2400
|
+
if (lines.length > HOST_STATE_MAX_LINES) {
|
|
2401
|
+
selected = lines.slice(0, HOST_STATE_MAX_LINES);
|
|
2402
|
+
truncated = true;
|
|
2403
|
+
}
|
|
2404
|
+
let text = selected.join("\n");
|
|
2405
|
+
if (text.length > HOST_STATE_MAX_CHARS) {
|
|
2406
|
+
text = text.slice(0, HOST_STATE_MAX_CHARS);
|
|
2407
|
+
truncated = true;
|
|
2408
|
+
}
|
|
2409
|
+
return {
|
|
2410
|
+
text: truncated ? `${text}
|
|
2411
|
+
[truncated]` : text,
|
|
2412
|
+
truncated
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
async function defaultGitStatusRunner(cwd) {
|
|
2416
|
+
return execa("git", ["status", "--porcelain=v1", "--branch"], {
|
|
2417
|
+
cwd,
|
|
2418
|
+
reject: false,
|
|
2419
|
+
timeout: HOST_STATE_STATUS_TIMEOUT_MS
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
async function captureAnalysisSynthesisHostState(cwd, runner = defaultGitStatusRunner) {
|
|
2423
|
+
const base = {
|
|
2424
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2425
|
+
cwd: sanitizeHostStateCwd(cwd),
|
|
2426
|
+
statusSource: "git-status-porcelain-branch"
|
|
2427
|
+
};
|
|
2428
|
+
try {
|
|
2429
|
+
const result = await runner(cwd);
|
|
2430
|
+
if (typeof result.exitCode === "number" && result.exitCode !== 0) {
|
|
2431
|
+
return {
|
|
2432
|
+
...base,
|
|
2433
|
+
captureError: sanitizeDiagnosticOutput(result.stderr || result.stdout, 600) ?? `git status exited ${result.exitCode}`
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
const bounded = boundHostGitStatus(result.stdout);
|
|
2437
|
+
return {
|
|
2438
|
+
...base,
|
|
2439
|
+
gitStatusPorcelainBranch: bounded.text,
|
|
2440
|
+
...bounded.truncated ? { gitStatusTruncated: true } : {}
|
|
2441
|
+
};
|
|
2442
|
+
} catch (error) {
|
|
2443
|
+
return {
|
|
2444
|
+
...base,
|
|
2445
|
+
captureError: sanitizeDiagnosticOutput(error instanceof Error ? error.message : String(error), 600) ?? "git status capture failed"
|
|
2446
|
+
};
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
function hostStateHasUncommittedTrackedChanges(hostState) {
|
|
2450
|
+
const status = hostState?.gitStatusPorcelainBranch;
|
|
2451
|
+
if (!status) return false;
|
|
2452
|
+
return status.split("\n").some((line) => {
|
|
2453
|
+
if (line.length < 3 || line.startsWith("##") || line === "[truncated]") return false;
|
|
2454
|
+
const code = line.slice(0, 2);
|
|
2455
|
+
return code !== "??" && code !== "!!";
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
var FUSION_UNCOMMITTED_CHANGES_WARNING = "Warning: uncommitted changes to tracked files are not visible to peers, which analyze committed code only; the synthesizer reads the working tree.";
|
|
2459
|
+
function collectAnalysisSynthesisVariantInputs(variants) {
|
|
2460
|
+
return variants.flatMap((variant) => {
|
|
2461
|
+
if (variant.success !== true) return [];
|
|
2462
|
+
const outputText = resolveVariantContributedText(variant);
|
|
2463
|
+
if (outputText.trim().length === 0) return [];
|
|
2464
|
+
const input = {
|
|
2465
|
+
variantId: getCanonicalVariantKeyFromResultWithInstance(variant),
|
|
2466
|
+
provider: variant.provider,
|
|
2467
|
+
output: outputText
|
|
2468
|
+
};
|
|
2469
|
+
const resolvedModel = variant.resolvedModel ?? variant.model;
|
|
2470
|
+
if (resolvedModel !== void 0) {
|
|
2471
|
+
input.model = resolvedModel;
|
|
2472
|
+
}
|
|
2473
|
+
if (variant.researchTrace) {
|
|
2474
|
+
input.researchTrace = variant.researchTrace;
|
|
2475
|
+
}
|
|
2476
|
+
return [input];
|
|
2477
|
+
});
|
|
2478
|
+
}
|
|
2479
|
+
function coerceAnalysisSynthesisContributorError(value) {
|
|
2480
|
+
if (typeof value === "string") return value;
|
|
2481
|
+
if (value instanceof Error) return value.message;
|
|
2482
|
+
if (!value || typeof value !== "object") return void 0;
|
|
2483
|
+
const record = value;
|
|
2484
|
+
for (const key of ["message", "error", "stderr", "reason"]) {
|
|
2485
|
+
const candidate = record[key];
|
|
2486
|
+
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
2487
|
+
return candidate;
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
return void 0;
|
|
2491
|
+
}
|
|
2492
|
+
function getCanonicalVariantKeyFromResultWithInstance(variant) {
|
|
2493
|
+
const canonicalKey = getCanonicalVariantKeyFromResult(variant);
|
|
2494
|
+
return variant.variantInstanceId ? `${canonicalKey}:${variant.variantInstanceId}` : canonicalKey;
|
|
2495
|
+
}
|
|
2496
|
+
function resolveVariantContributedText(variant) {
|
|
2497
|
+
return variant.result?.stdout ?? variant.output ?? "";
|
|
2498
|
+
}
|
|
2499
|
+
function hasUsableAnalysisOutput(variant) {
|
|
2500
|
+
return variant.success === true && resolveVariantContributedText(variant).trim().length > 0;
|
|
2501
|
+
}
|
|
2502
|
+
function collectAnalysisSynthesisContributorHealth(variants) {
|
|
2503
|
+
return variants.map((variant) => {
|
|
2504
|
+
const outputText = resolveVariantContributedText(variant);
|
|
2505
|
+
const variantId = getCanonicalVariantKeyFromResultWithInstance(variant);
|
|
2506
|
+
const variantDiagnostics = variant;
|
|
2507
|
+
const status = variant.success !== true ? "failed" : outputText.trim().length === 0 ? "empty_output" : "included";
|
|
2508
|
+
const providerDiagnostics = normalizeProviderRunDiagnostics(
|
|
2509
|
+
variant.providerDiagnostics ?? variantDiagnostics.result?.providerDiagnostics
|
|
2510
|
+
);
|
|
2511
|
+
const stderrSeverity = providerDiagnostics?.stderrSeverity;
|
|
2512
|
+
const stderrIsExplicitlyNonFatal = stderrSeverity === "none" || stderrSeverity === "info" || stderrSeverity === "warning";
|
|
2513
|
+
const includeStderrAsError = providerDiagnosticsReportFatalRuntimeIssue(providerDiagnostics) || status !== "included" && !stderrIsExplicitlyNonFatal;
|
|
2514
|
+
const researchCitationCount = variant.researchTrace?.citations.length;
|
|
2515
|
+
const researchTraceStatus = variant.researchTrace?.status;
|
|
2516
|
+
const researchExcludedDomainViolations = variant.researchTrace?.citations.filter(
|
|
2517
|
+
(citation) => citation.excludedDomainViolation === true
|
|
2518
|
+
).length;
|
|
2519
|
+
const error = [
|
|
2520
|
+
variantDiagnostics.error,
|
|
2521
|
+
variantDiagnostics.errorMessage,
|
|
2522
|
+
variantDiagnostics.result?.error,
|
|
2523
|
+
includeStderrAsError ? variantDiagnostics.result?.stderr : void 0
|
|
2524
|
+
].map(coerceAnalysisSynthesisContributorError).find((candidate) => candidate && candidate.trim().length > 0);
|
|
2525
|
+
const renderedError = sanitizeAnalysisSynthesisContributorError(error);
|
|
2526
|
+
return {
|
|
2527
|
+
variantId,
|
|
2528
|
+
provider: variant.provider,
|
|
2529
|
+
...variant.resolvedModel ?? variant.model ? { model: variant.resolvedModel ?? variant.model } : {},
|
|
2530
|
+
status,
|
|
2531
|
+
success: variant.success,
|
|
2532
|
+
outputChars: outputText.length,
|
|
2533
|
+
...renderedError ? { error: renderedError } : {},
|
|
2534
|
+
...researchCitationCount !== void 0 ? { researchCitationCount } : {},
|
|
2535
|
+
...researchTraceStatus !== void 0 ? { researchTraceStatus } : {},
|
|
2536
|
+
...variant.researchTrace?.observedWebToolEvent !== void 0 ? { researchObservedWebToolEvent: variant.researchTrace.observedWebToolEvent } : {},
|
|
2537
|
+
...researchExcludedDomainViolations !== void 0 ? { researchExcludedDomainViolations } : {},
|
|
2538
|
+
...variant.researchTrace?.artifactPath ? { researchTracePath: variant.researchTrace.artifactPath } : {}
|
|
2539
|
+
};
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
function maybeNumber(value) {
|
|
2543
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
2544
|
+
}
|
|
2545
|
+
function deriveResearchGroundingDegraded(variants, researchEnabled, researchMode) {
|
|
2546
|
+
if (!researchEnabled || researchMode !== "native") return false;
|
|
2547
|
+
const clearedPeers = variants.filter((v) => v.researchTrace != null);
|
|
2548
|
+
if (clearedPeers.length === 0) return false;
|
|
2549
|
+
return clearedPeers.some((v) => v.researchTrace?.observedWebToolEvent !== true);
|
|
2550
|
+
}
|
|
2551
|
+
function buildAnalysisSynthesisJudgeSummary(input) {
|
|
2552
|
+
if (input.omitWinnerFraming) {
|
|
2553
|
+
return {};
|
|
2554
|
+
}
|
|
2555
|
+
const summary = {
|
|
2556
|
+
winner: input.winner ? getCanonicalVariantKeyFromResult(input.winner) : null
|
|
2557
|
+
};
|
|
2558
|
+
const confidence = maybeNumber(input.winner?.judgeEvaluation?.confidence);
|
|
2559
|
+
if (confidence !== void 0) summary.confidence = confidence;
|
|
2560
|
+
const rankings = input.judgeContext?.rankedVariants.map((variant) => {
|
|
2561
|
+
const ranking = {
|
|
2562
|
+
variantId: variant.variantId,
|
|
2563
|
+
provider: variant.provider
|
|
2564
|
+
};
|
|
2565
|
+
if (variant.selectedJudgeRank !== void 0) ranking.rank = variant.selectedJudgeRank;
|
|
2566
|
+
if (variant.selectedJudgeScore !== void 0) ranking.score = variant.selectedJudgeScore;
|
|
2567
|
+
return ranking;
|
|
2568
|
+
});
|
|
2569
|
+
if (rankings && rankings.length > 0) summary.rankings = rankings;
|
|
2570
|
+
const reasoning = input.winner?.winnerSelectionReason ?? input.judgeContext?.rationale?.selectedJudgeReason ?? input.judgeContext?.rationale?.baseSelectionReason;
|
|
2571
|
+
if (reasoning) summary.reasoning = reasoning;
|
|
2572
|
+
return summary;
|
|
2573
|
+
}
|
|
2574
|
+
function formatFusionReconciliationLine(reconciliation) {
|
|
2575
|
+
if (reconciliation.markdownPath) return `Fusion reconciliation: ${reconciliation.markdownPath}`;
|
|
2576
|
+
const reason = reconciliation.reason ? ` (${reconciliation.reason.replaceAll("_", " ")})` : "";
|
|
2577
|
+
return `Fusion reconciliation: ${reconciliation.status}${reason}; no report written`;
|
|
2578
|
+
}
|
|
2579
|
+
async function executeCompetitionSynthesis(params) {
|
|
2580
|
+
const {
|
|
2581
|
+
winner,
|
|
2582
|
+
variants,
|
|
2583
|
+
synthesisJudgeContext,
|
|
2584
|
+
aiJudgeRequested,
|
|
2585
|
+
isFusionRun,
|
|
2586
|
+
executionIntentEffective,
|
|
2587
|
+
taskId,
|
|
2588
|
+
task,
|
|
2589
|
+
taskLabelSource,
|
|
2590
|
+
analysisSynthesis,
|
|
2591
|
+
synthesisTopN,
|
|
2592
|
+
synthesisModel,
|
|
2593
|
+
fusionReconcile,
|
|
2594
|
+
timeoutMs,
|
|
2595
|
+
researchRequested,
|
|
2596
|
+
researchEnabled,
|
|
2597
|
+
researchMode,
|
|
2598
|
+
researchPacketPath,
|
|
2599
|
+
researchExcludeDomain,
|
|
2600
|
+
hostStateCapturer,
|
|
2601
|
+
output
|
|
2602
|
+
} = params;
|
|
2603
|
+
const analysisSynthesisExpected = shouldRunAnalysisSynthesisStage({
|
|
2604
|
+
analysisSynthesis,
|
|
2605
|
+
executionIntentEffective
|
|
2606
|
+
}) && (aiJudgeRequested || isFusionRun);
|
|
2607
|
+
if (!analysisSynthesisExpected) {
|
|
2608
|
+
return { analysisSynthesisExpected };
|
|
2609
|
+
}
|
|
2610
|
+
const analysisSynthesisInputs = collectAnalysisSynthesisVariantInputs(variants);
|
|
2611
|
+
const contributorHealth = collectAnalysisSynthesisContributorHealth(variants);
|
|
2612
|
+
const synthesisWorkingDir = process.cwd();
|
|
2613
|
+
const hostState = await (hostStateCapturer ?? captureAnalysisSynthesisHostState)(
|
|
2614
|
+
synthesisWorkingDir
|
|
2615
|
+
);
|
|
2616
|
+
const researchGroundingDegraded = deriveResearchGroundingDegraded(
|
|
2617
|
+
variants,
|
|
2618
|
+
researchEnabled,
|
|
2619
|
+
researchMode
|
|
2620
|
+
);
|
|
2621
|
+
if (researchGroundingDegraded) {
|
|
2622
|
+
const countResearchClearedPeers = variants.filter((v) => v.researchTrace != null).length;
|
|
2623
|
+
const countGrounded = variants.filter(
|
|
2624
|
+
(v) => v.researchTrace?.observedWebToolEvent === true
|
|
2625
|
+
).length;
|
|
2626
|
+
const ungrounded = countResearchClearedPeers - countGrounded;
|
|
2627
|
+
output.line(
|
|
2628
|
+
`Warning: research requested but ${ungrounded} of ${countResearchClearedPeers} peers produced no observed web/MCP tool events (grounding degraded).`
|
|
2629
|
+
);
|
|
2630
|
+
}
|
|
2631
|
+
if (isFusionRun && hostStateHasUncommittedTrackedChanges(hostState)) {
|
|
2632
|
+
output.line(FUSION_UNCOMMITTED_CHANGES_WARNING);
|
|
2633
|
+
}
|
|
2634
|
+
if (isFusionRun) {
|
|
2635
|
+
output.event(infoEvent("Fusion synthesis: integrating contributor outputs"));
|
|
2636
|
+
}
|
|
2637
|
+
const metadata = {
|
|
2638
|
+
task: {
|
|
2639
|
+
label: taskLabelSource,
|
|
2640
|
+
intent: executionIntentEffective,
|
|
2641
|
+
runSemantics: isFusionRun ? "fusion" : "analysis"
|
|
2642
|
+
},
|
|
2643
|
+
research: {
|
|
2644
|
+
requested: researchRequested,
|
|
2645
|
+
enabled: researchEnabled,
|
|
2646
|
+
mode: researchEnabled && researchMode ? researchMode : void 0,
|
|
2647
|
+
packetPath: researchPacketPath,
|
|
2648
|
+
excludedDomains: researchExcludeDomain
|
|
2649
|
+
},
|
|
2650
|
+
contributorHealth,
|
|
2651
|
+
hostState
|
|
2652
|
+
};
|
|
2653
|
+
const labResolver = LabPathResolver.getInstance();
|
|
2654
|
+
const isLabRun = labResolver.getContext() !== null;
|
|
2655
|
+
const artifactRootDir = resolveAnalysisSynthesisArtifactRoot(
|
|
2656
|
+
getExecutionContext().buildDir,
|
|
2657
|
+
labResolver
|
|
2658
|
+
);
|
|
2659
|
+
const analysisSynthesis_ = isFusionRun ? await runFusionSynthesis({
|
|
2660
|
+
taskId,
|
|
2661
|
+
task,
|
|
2662
|
+
variants: analysisSynthesisInputs,
|
|
2663
|
+
synthesisModel,
|
|
2664
|
+
reconcile: fusionReconcile === true,
|
|
2665
|
+
isLabRun,
|
|
2666
|
+
timeoutMs,
|
|
2667
|
+
metadata,
|
|
2668
|
+
artifactRootDir,
|
|
2669
|
+
workingDir: synthesisWorkingDir
|
|
2670
|
+
}) : await runAnalysisSynthesis({
|
|
2671
|
+
taskId,
|
|
2672
|
+
task,
|
|
2673
|
+
variants: analysisSynthesisInputs,
|
|
2674
|
+
judge: buildAnalysisSynthesisJudgeSummary({
|
|
2675
|
+
winner,
|
|
2676
|
+
judgeContext: synthesisJudgeContext
|
|
2677
|
+
}),
|
|
2678
|
+
runSemantics: "analysis",
|
|
2679
|
+
selectedTopN: synthesisTopN ?? 3,
|
|
2680
|
+
synthesisModel,
|
|
2681
|
+
timeoutMs,
|
|
2682
|
+
metadata,
|
|
2683
|
+
artifactRootDir,
|
|
2684
|
+
workingDir: synthesisWorkingDir
|
|
2685
|
+
});
|
|
2686
|
+
const analysisSynthesisContributors = (analysisSynthesis_.result.inputs?.variants ?? analysisSynthesisInputs).map((variant) => variant.variantId);
|
|
2687
|
+
const deliveredMarkdownPath = isFusionRun ? "answerPath" in analysisSynthesis_.paths ? analysisSynthesis_.paths.answerPath : void 0 : "markdownPath" in analysisSynthesis_.paths ? analysisSynthesis_.paths.markdownPath : void 0;
|
|
2688
|
+
const deliveredJsonPath = isFusionRun ? "manifestPath" in analysisSynthesis_.paths ? analysisSynthesis_.paths.manifestPath : void 0 : "jsonPath" in analysisSynthesis_.paths ? analysisSynthesis_.paths.jsonPath : void 0;
|
|
2689
|
+
const fusionReconciliationLine = "manifest" in analysisSynthesis_ && analysisSynthesis_.manifest.reconciliation ? formatFusionReconciliationLine(analysisSynthesis_.manifest.reconciliation) : void 0;
|
|
2690
|
+
if (!isFusionRun && deliveredMarkdownPath) {
|
|
2691
|
+
output.line(formatAnalysisSynthesisPathLine(deliveredMarkdownPath));
|
|
2692
|
+
}
|
|
2693
|
+
return {
|
|
2694
|
+
analysisSynthesisExpected,
|
|
2695
|
+
analysisSynthesisMarkdownPath: deliveredMarkdownPath,
|
|
2696
|
+
analysisSynthesisJsonPath: deliveredJsonPath,
|
|
2697
|
+
...fusionReconciliationLine ? { fusionReconciliationLine } : {},
|
|
2698
|
+
analysisSynthesisStatus: analysisSynthesis_.result.status,
|
|
2699
|
+
analysisSynthesisResult: analysisSynthesis_.result,
|
|
2700
|
+
analysisSynthesisContributors,
|
|
2701
|
+
...researchGroundingDegraded ? { researchGroundingDegraded: true } : {}
|
|
2702
|
+
};
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
// src/cli/handlers/compete/compete-terminal-exit.ts
|
|
2706
|
+
function formatSucceededVariants(successCount, totalVariantCount) {
|
|
2707
|
+
return `${successCount} of ${totalVariantCount} variant${totalVariantCount === 1 ? "" : "s"} succeeded`;
|
|
2708
|
+
}
|
|
2709
|
+
function noWinnerExit(successCount, totalVariantCount, reason) {
|
|
2710
|
+
if (reason === "all_variants_failed") {
|
|
2711
|
+
return { code: 1, message: "No variants succeeded", noWinnerReason: reason };
|
|
2712
|
+
}
|
|
2713
|
+
const why = reason === "judge_picked_none" ? "the judge picked no winner" : "none was verification-backed";
|
|
2714
|
+
return {
|
|
2715
|
+
code: 1,
|
|
2716
|
+
message: `${formatSucceededVariants(successCount, totalVariantCount)}; ${why}; nothing was applied.`,
|
|
2717
|
+
noWinnerReason: reason
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
2720
|
+
var DEFAULT_BEST_EFFORT_REQUIRED_GATE_POLICY = "build-only";
|
|
2721
|
+
function resolveEffectiveRequiredGatePolicy(requiredGatePolicy) {
|
|
2722
|
+
return requiredGatePolicy ?? DEFAULT_BEST_EFFORT_REQUIRED_GATE_POLICY;
|
|
2723
|
+
}
|
|
2724
|
+
var COMPETE_DELIVERY_ROUTE_TERMINAL_SEMANTICS = Object.freeze({
|
|
2725
|
+
basic: Object.freeze({
|
|
2726
|
+
route: "basic",
|
|
2727
|
+
finishLine: "local",
|
|
2728
|
+
summary: "local",
|
|
2729
|
+
handoff: "local",
|
|
2730
|
+
statePersistence: "local",
|
|
2731
|
+
apply: "local",
|
|
2732
|
+
terminalExit: "delivery-aware",
|
|
2733
|
+
finalOutcomeSource: "basic-finalization"
|
|
2734
|
+
}),
|
|
2735
|
+
background: Object.freeze({
|
|
2736
|
+
route: "background",
|
|
2737
|
+
finishLine: "worker",
|
|
2738
|
+
summary: "none",
|
|
2739
|
+
handoff: "none",
|
|
2740
|
+
statePersistence: "worker",
|
|
2741
|
+
apply: "none",
|
|
2742
|
+
terminalExit: "accepted",
|
|
2743
|
+
finalOutcomeSource: "background-worker"
|
|
2744
|
+
})
|
|
2745
|
+
});
|
|
2746
|
+
function isFailedOrUnavailableVerificationStatus(value) {
|
|
2747
|
+
return value === "failed" || value === "error" || value === "timeout" || value === "unavailable";
|
|
2748
|
+
}
|
|
2749
|
+
function hasExplicitVerificationFailureEvidence(variant) {
|
|
2750
|
+
if (!variant) return false;
|
|
2751
|
+
const outcomeVerification = variant.outcome?.verification;
|
|
2752
|
+
const nonLintGateStatuses = [
|
|
2753
|
+
outcomeVerification?.buildStatus,
|
|
2754
|
+
outcomeVerification?.buildOutcome,
|
|
2755
|
+
outcomeVerification?.testStatus,
|
|
2756
|
+
outcomeVerification?.testOutcome,
|
|
2757
|
+
variant.buildStatus,
|
|
2758
|
+
variant.testStatus
|
|
2759
|
+
];
|
|
2760
|
+
const hasNonLintGateFailure = nonLintGateStatuses.some(isFailedOrUnavailableVerificationStatus);
|
|
2761
|
+
if (hasNonLintGateFailure) {
|
|
2762
|
+
return true;
|
|
2763
|
+
}
|
|
2764
|
+
if (hasVetoingUnavailableVerificationGateEvidence({
|
|
2765
|
+
testStatus: variant.testStatus,
|
|
2766
|
+
testsExecuted: variant.testsExecuted,
|
|
2767
|
+
verificationLoop: variant.verificationLoop
|
|
2768
|
+
})) {
|
|
2769
|
+
return true;
|
|
2770
|
+
}
|
|
2771
|
+
const lintFailed = outcomeVerification?.lintStatus === "failed" || variant.lintStatus === "failed";
|
|
2772
|
+
if (!lintFailed && (outcomeVerification?.status === "failed" || outcomeVerification?.deterministicGatesPassed === false)) {
|
|
2773
|
+
return true;
|
|
2774
|
+
}
|
|
2775
|
+
if (variant.verification?.passed === false) {
|
|
2776
|
+
const findings = variant.verification.findings ?? [];
|
|
2777
|
+
if (findings.length > 0 && findings.some((finding) => finding.kind !== "lint")) {
|
|
2778
|
+
return true;
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
const testExitCode = variant.testsExecuted?.exitCode;
|
|
2782
|
+
return typeof testExitCode === "number" && testExitCode !== 0;
|
|
2783
|
+
}
|
|
2784
|
+
function hasNonEmptyEditEvidence(variant) {
|
|
2785
|
+
if (variant.emptyChanges === false) return true;
|
|
2786
|
+
if (typeof variant.worktreeDiff === "string" && variant.worktreeDiff.trim().length > 0) {
|
|
2787
|
+
return true;
|
|
2788
|
+
}
|
|
2789
|
+
return (variant.filesChanged ?? 0) > 0 || (variant.linesAdded ?? 0) > 0 || (variant.linesRemoved ?? 0) > 0 || (variant.workspaceEditsApplied ?? 0) > 0 || (variant.gitMetrics?.filesChanged ?? 0) > 0 || (variant.gitMetrics?.linesAdded ?? 0) > 0 || (variant.gitMetrics?.linesDeleted ?? 0) > 0 || (variant.worktreeSummary?.filesChanged ?? 0) > 0 || (variant.worktreeSummary?.insertions ?? 0) > 0 || (variant.worktreeSummary?.deletions ?? 0) > 0 || hasIgnoredPlanningArtifactEvidence(variant);
|
|
2790
|
+
}
|
|
2791
|
+
function getIgnoredPlanningArtifactCount(variant) {
|
|
2792
|
+
const paths = variant.ignoredPathEvidence?.paths;
|
|
2793
|
+
if (!Array.isArray(paths)) return 0;
|
|
2794
|
+
return paths.filter(isIgnoredPlanningArtifactPath).length;
|
|
2795
|
+
}
|
|
2796
|
+
function countVariantFilesChanged(variant) {
|
|
2797
|
+
return Math.max(
|
|
2798
|
+
variant.filesChanged ?? 0,
|
|
2799
|
+
variant.gitMetrics?.filesChanged ?? 0,
|
|
2800
|
+
variant.worktreeSummary?.filesChanged ?? 0
|
|
2801
|
+
);
|
|
2802
|
+
}
|
|
2803
|
+
function formatVariantChangeSummary(variant, options = {}) {
|
|
2804
|
+
const filesChanged = countVariantFilesChanged(variant);
|
|
2805
|
+
if (options.editsExpected === false) {
|
|
2806
|
+
return filesChanged > 0 ? `${filesChanged} file${filesChanged !== 1 ? "s" : ""} changed` : "no edits";
|
|
2807
|
+
}
|
|
2808
|
+
const edits = variant.workspaceEditsApplied ?? 0;
|
|
2809
|
+
if (edits > 0) return `${edits} edit${edits !== 1 ? "s" : ""}`;
|
|
2810
|
+
if (filesChanged > 0) {
|
|
2811
|
+
return `${filesChanged} file${filesChanged !== 1 ? "s" : ""} changed`;
|
|
2812
|
+
}
|
|
2813
|
+
const ignoredPlanningArtifacts = getIgnoredPlanningArtifactCount(variant);
|
|
2814
|
+
return ignoredPlanningArtifacts > 0 ? `${ignoredPlanningArtifacts} planning artifact${ignoredPlanningArtifacts !== 1 ? "s" : ""}` : "no edits";
|
|
2815
|
+
}
|
|
2816
|
+
function hasNonEmptyEditDelivery(variant) {
|
|
2817
|
+
return variant.success === true && hasNonEmptyEditEvidence(variant);
|
|
2818
|
+
}
|
|
2819
|
+
function hasSuccessfulCompetitionDelivery(result) {
|
|
2820
|
+
return Boolean(result.winner) || result.variants?.some((variant) => variant.success) === true;
|
|
2821
|
+
}
|
|
2822
|
+
function shouldFailForEmptyEditDelivery(result) {
|
|
2823
|
+
if (result.editsExpected !== true || !Array.isArray(result.variants)) return false;
|
|
2824
|
+
const completedVariants = result.variants.filter((variant) => variant.success === true);
|
|
2825
|
+
if (completedVariants.length > 0) {
|
|
2826
|
+
return !completedVariants.some(hasNonEmptyEditDelivery);
|
|
2827
|
+
}
|
|
2828
|
+
return result.variants.length > 0;
|
|
2829
|
+
}
|
|
2830
|
+
function formatEmptyEditDeliveryWarning(result) {
|
|
2831
|
+
return result.variants?.some((variant) => variant.success === true) ? "Delivery failed: completed variants produced no edits; judge winner retained." : "Delivery failed: no variant completed, so there is no winner and nothing was applied.";
|
|
2832
|
+
}
|
|
2833
|
+
function resolveCompetitionDeliveryExit(result) {
|
|
2834
|
+
const variants = Array.isArray(result.variants) ? result.variants : [];
|
|
2835
|
+
const totalVariantCount = variants.length;
|
|
2836
|
+
const verifiedVariantCount = Math.max(0, result.verifiedVariantCount);
|
|
2837
|
+
const successCount = variants.filter((v) => v.success === true).length;
|
|
2838
|
+
const hasFailure = variants.some((v) => v.success !== true);
|
|
2839
|
+
if (shouldFailForEmptyEditDelivery(result)) {
|
|
2840
|
+
const noWinnerReason = successCount === 0 ? "all_variants_failed" : "no_edits";
|
|
2841
|
+
return {
|
|
2842
|
+
code: 1,
|
|
2843
|
+
message: successCount === 0 ? "No variants succeeded" : "No variants produced edits",
|
|
2844
|
+
...result.winner ? {} : { noWinnerReason }
|
|
2845
|
+
};
|
|
2846
|
+
}
|
|
2847
|
+
if (result.winner) {
|
|
2848
|
+
const explicitlyFailedWinnerVerification = result.winnerVerified === false && (result.deliveryVerificationMode === "required" || result.deliveryVerificationMode === "best_effort" && hasExplicitVerificationFailureEvidence(result.winner));
|
|
2849
|
+
if (explicitlyFailedWinnerVerification) {
|
|
2850
|
+
return {
|
|
2851
|
+
code: 3,
|
|
2852
|
+
message: "Competition degraded: selected winner was not verification-backed"
|
|
2853
|
+
};
|
|
2854
|
+
}
|
|
2855
|
+
if (hasFailure) {
|
|
2856
|
+
return {
|
|
2857
|
+
code: 3,
|
|
2858
|
+
message: `Competition degraded: ${successCount}/${totalVariantCount} variants completed`
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
return { code: 0, message: "Competition completed successfully" };
|
|
2862
|
+
}
|
|
2863
|
+
if (result.deliveryVerificationMode === "not_applicable" || result.deliveryVerificationMode === "best_effort") {
|
|
2864
|
+
if (successCount === 0) {
|
|
2865
|
+
return noWinnerExit(successCount, totalVariantCount, "all_variants_failed");
|
|
2866
|
+
}
|
|
2867
|
+
if (successCount < totalVariantCount) {
|
|
2868
|
+
return {
|
|
2869
|
+
code: 2,
|
|
2870
|
+
message: "Competition completed with partial variant failures"
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2873
|
+
return { code: 0, message: "Competition completed successfully" };
|
|
2874
|
+
}
|
|
2875
|
+
if (totalVariantCount > 0 && verifiedVariantCount >= totalVariantCount && hasSuccessfulCompetitionDelivery(result)) {
|
|
2876
|
+
return { code: 0, message: "Competition completed successfully" };
|
|
2877
|
+
}
|
|
2878
|
+
if (verifiedVariantCount > 0) {
|
|
2879
|
+
return {
|
|
2880
|
+
code: 2,
|
|
2881
|
+
message: "Competition completed with partial variant failures"
|
|
2882
|
+
};
|
|
2883
|
+
}
|
|
2884
|
+
return noWinnerExit(
|
|
2885
|
+
successCount,
|
|
2886
|
+
totalVariantCount,
|
|
2887
|
+
successCount === 0 ? "all_variants_failed" : "no_verified_variant"
|
|
2888
|
+
);
|
|
2889
|
+
}
|
|
2890
|
+
var SYNTHESIS_STATUS_SEVERITY = {
|
|
2891
|
+
succeeded: 0,
|
|
2892
|
+
applied: 0,
|
|
2893
|
+
skipped: 0,
|
|
2894
|
+
no_pick: 0,
|
|
2895
|
+
winner_carry_forward: 0,
|
|
2896
|
+
partial: 1,
|
|
2897
|
+
degraded: 1,
|
|
2898
|
+
failed: 2,
|
|
2899
|
+
generation_failed: 2,
|
|
2900
|
+
gate_failed: 2,
|
|
2901
|
+
timed_out: 2,
|
|
2902
|
+
editable_workspace_unavailable: 2,
|
|
2903
|
+
not_attempted: 2
|
|
2904
|
+
};
|
|
2905
|
+
function pickWorseSynthesisStatus(left, right) {
|
|
2906
|
+
if (left == null || left === "") return right;
|
|
2907
|
+
if (right == null || right === "") return left;
|
|
2908
|
+
const leftSeverity = SYNTHESIS_STATUS_SEVERITY[left] ?? 2;
|
|
2909
|
+
const rightSeverity = SYNTHESIS_STATUS_SEVERITY[right] ?? 2;
|
|
2910
|
+
return rightSeverity > leftSeverity ? right : left;
|
|
2911
|
+
}
|
|
2912
|
+
function resolveAnalysisSynthesisDeliveryExit(deliveryExit, options) {
|
|
2913
|
+
if (options.synthesisExpected !== true) {
|
|
2914
|
+
return deliveryExit;
|
|
2915
|
+
}
|
|
2916
|
+
const status = options.analysisSynthesisStatus;
|
|
2917
|
+
if (status === "succeeded") {
|
|
2918
|
+
return deliveryExit;
|
|
2919
|
+
}
|
|
2920
|
+
if (status === "partial" || status === "degraded") {
|
|
2921
|
+
if (deliveryExit.code === 0) {
|
|
2922
|
+
return {
|
|
2923
|
+
code: 3,
|
|
2924
|
+
message: status === "degraded" ? "Competition degraded: analysis synthesis completed with degraded output" : "Competition degraded: analysis synthesis completed with partial inputs"
|
|
2925
|
+
};
|
|
2926
|
+
}
|
|
2927
|
+
return deliveryExit;
|
|
2928
|
+
}
|
|
2929
|
+
if (status === "failed" || status === "generation_failed" || status === "gate_failed" || status === "timed_out" || status === "editable_workspace_unavailable" || status === "not_attempted" || options.fusionRun === true && !status) {
|
|
2930
|
+
if (options.fusionRun === true) {
|
|
2931
|
+
return { code: 1, message: "Fusion synthesis failed" };
|
|
2932
|
+
}
|
|
2933
|
+
if (deliveryExit.code === 0) {
|
|
2934
|
+
return {
|
|
2935
|
+
code: 3,
|
|
2936
|
+
message: "Competition degraded: synthesis failed"
|
|
2937
|
+
};
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
return deliveryExit;
|
|
2941
|
+
}
|
|
2942
|
+
function formatCompetitionDeliveryResultLabel(deliveryExit, options) {
|
|
2943
|
+
if (options?.judgeOffMultiVariant && deliveryExit.code !== 0) return "incomplete";
|
|
2944
|
+
if (deliveryExit.code === 0) return "success";
|
|
2945
|
+
if (deliveryExit.code === 3) return "degraded";
|
|
2946
|
+
if (deliveryExit.code === 2) return "partial";
|
|
2947
|
+
return "failed";
|
|
2948
|
+
}
|
|
2949
|
+
function formatJudgeOffVariantStatus(input) {
|
|
2950
|
+
return input.success ? "completed, ungraded" : "failed";
|
|
2951
|
+
}
|
|
2952
|
+
function isJudgeOffMultiVariantWithoutWinner(input) {
|
|
2953
|
+
return input.judge === "off" && input.variantCount > 1 && !input.winner;
|
|
2954
|
+
}
|
|
2955
|
+
function resolveJudgeOffMultiVariantDeliveryExit(result) {
|
|
2956
|
+
const code = result !== void 0 ? resolveCompetitionDeliveryExit({
|
|
2957
|
+
winner: null,
|
|
2958
|
+
variants: result.variants,
|
|
2959
|
+
verifiedVariantCount: result.variants?.filter((variant) => variant.success === true).length ?? 0,
|
|
2960
|
+
deliveryVerificationMode: result.deliveryVerificationMode ?? "best_effort",
|
|
2961
|
+
editsExpected: result.editsExpected
|
|
2962
|
+
}).code : 0;
|
|
2963
|
+
const message = code === 0 ? "Comparison completed without winner (--judge off); inspect variants or rerun with one --variant / enable judge" : "Comparison incomplete without winner (--judge off); inspect failed variants or rerun with one --variant / enable judge";
|
|
2964
|
+
return {
|
|
2965
|
+
code,
|
|
2966
|
+
message
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
function resolveFusionDeliveryExit(input) {
|
|
2970
|
+
if (input.fusionRun !== true) return null;
|
|
2971
|
+
const status = input.analysisSynthesisStatus ?? "not_produced";
|
|
2972
|
+
if (input.synthesisContributorCount === 0) {
|
|
2973
|
+
return {
|
|
2974
|
+
code: 1,
|
|
2975
|
+
message: "Fusion failed: no contributors produced usable analysis"
|
|
2976
|
+
};
|
|
2977
|
+
}
|
|
2978
|
+
if (input.synthesisContributorCount < 2) {
|
|
2979
|
+
return {
|
|
2980
|
+
code: 3,
|
|
2981
|
+
message: `Fusion degraded: only ${input.synthesisContributorCount}/${input.totalVariantCount} contributors produced usable analysis; no multi-source fusion was produced`
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
if (status === "partial") {
|
|
2985
|
+
return {
|
|
2986
|
+
code: 3,
|
|
2987
|
+
message: "Fusion degraded: synthesis completed with partial contributor coverage"
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
if (status === "degraded") {
|
|
2991
|
+
return {
|
|
2992
|
+
code: 3,
|
|
2993
|
+
message: "Fusion degraded: synthesis completed with degraded output"
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
if (status !== "succeeded") {
|
|
2997
|
+
return {
|
|
2998
|
+
code: 1,
|
|
2999
|
+
message: `Fusion failed: synthesis status ${status}`
|
|
3000
|
+
};
|
|
3001
|
+
}
|
|
3002
|
+
return null;
|
|
3003
|
+
}
|
|
3004
|
+
function computeCompetitionTerminalExit(input) {
|
|
3005
|
+
const variants = input.fusionRun === true && Array.isArray(input.variants) ? input.variants.map(
|
|
3006
|
+
(variant) => variant.success === true && !hasUsableAnalysisOutput(variant) ? { ...variant, success: false } : variant
|
|
3007
|
+
) : input.variants;
|
|
3008
|
+
let deliveryExit = resolveCompetitionDeliveryExit({
|
|
3009
|
+
winner: input.winner,
|
|
3010
|
+
variants,
|
|
3011
|
+
verifiedVariantCount: input.verifiedVariantCount,
|
|
3012
|
+
winnerVerified: input.winnerVerified,
|
|
3013
|
+
deliveryVerificationMode: input.deliveryVerificationMode,
|
|
3014
|
+
editsExpected: input.editsExpected
|
|
3015
|
+
});
|
|
3016
|
+
if (input.judgeOffMultiVariant) {
|
|
3017
|
+
deliveryExit = resolveJudgeOffMultiVariantDeliveryExit({
|
|
3018
|
+
variants,
|
|
3019
|
+
deliveryVerificationMode: input.deliveryVerificationMode,
|
|
3020
|
+
editsExpected: input.editsExpected
|
|
3021
|
+
});
|
|
3022
|
+
}
|
|
3023
|
+
if (input.judgedNoWinner === true && !input.winner) {
|
|
3024
|
+
const total = Array.isArray(variants) ? variants.length : 0;
|
|
3025
|
+
const completed = Array.isArray(variants) ? variants.filter((variant) => variant.success === true).length : 0;
|
|
3026
|
+
if (completed > 0 && (deliveryExit.code !== 1 || deliveryExit.noWinnerReason === "no_verified_variant")) {
|
|
3027
|
+
deliveryExit = noWinnerExit(completed, total, "judge_picked_none");
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
if (input.fusionRun === true) {
|
|
3031
|
+
const fusionDeliveryExit = resolveFusionDeliveryExit({
|
|
3032
|
+
fusionRun: true,
|
|
3033
|
+
synthesisContributorCount: input.synthesisContributorCount ?? 0,
|
|
3034
|
+
totalVariantCount: Array.isArray(variants) ? variants.length : 0,
|
|
3035
|
+
analysisSynthesisStatus: input.analysisSynthesisStatus
|
|
3036
|
+
});
|
|
3037
|
+
if (fusionDeliveryExit) {
|
|
3038
|
+
deliveryExit = fusionDeliveryExit;
|
|
3039
|
+
}
|
|
3040
|
+
} else {
|
|
3041
|
+
deliveryExit = resolveAnalysisSynthesisDeliveryExit(deliveryExit, {
|
|
3042
|
+
synthesisExpected: input.synthesisExpected,
|
|
3043
|
+
fusionRun: input.fusionRun,
|
|
3044
|
+
analysisSynthesisStatus: input.analysisSynthesisStatus
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
return deliveryExit;
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
// src/cli/handlers/compete/run-summary-display.ts
|
|
3051
|
+
function getRequiredGateAwareDisplayVerdict(variant, options = {}) {
|
|
3052
|
+
return getDisplayVerificationVerdict(variant, {
|
|
3053
|
+
requiredGatePolicy: resolveEffectiveRequiredGatePolicy(options.requiredGatePolicy)
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
function getUnanimousMatrixWinner(matrixResult) {
|
|
3057
|
+
if (matrixResult?.winnerStatus === "inconclusive") return null;
|
|
3058
|
+
const winners = matrixResult?.profileVerdicts.map((verdict) => verdict.winner.trim());
|
|
3059
|
+
if (!winners || winners.length < 2 || winners.some((winner) => winner.length === 0)) {
|
|
3060
|
+
return null;
|
|
3061
|
+
}
|
|
3062
|
+
const [firstWinner, ...remainingWinners] = winners;
|
|
3063
|
+
if (!firstWinner || remainingWinners.some((winner) => winner !== firstWinner)) {
|
|
3064
|
+
return null;
|
|
3065
|
+
}
|
|
3066
|
+
return firstWinner;
|
|
3067
|
+
}
|
|
3068
|
+
function formatMatrixPrimaryDisagreementSummary(input) {
|
|
3069
|
+
const matrixWinner = getUnanimousMatrixWinner(input.matrixResult);
|
|
3070
|
+
const primaryWinnerDisplay = formatVariantKeyForDisplay(input.primaryWinner);
|
|
3071
|
+
const matrixWinnerDisplay = matrixWinner ? formatVariantKeyForDisplay(matrixWinner) : null;
|
|
3072
|
+
if (!matrixWinnerDisplay || matrixWinnerDisplay === primaryWinnerDisplay) return null;
|
|
3073
|
+
if (!isNearTieMargin({ margin: input.margin, threshold: input.threshold })) return null;
|
|
3074
|
+
const marginLabel = typeof input.margin === "number" && Number.isFinite(input.margin) ? input.margin.toFixed(1) : "n/a";
|
|
3075
|
+
return `matrixPrimaryDisagreement: primary=${primaryWinnerDisplay} matrix=${matrixWinnerDisplay} margin=${marginLabel}`;
|
|
3076
|
+
}
|
|
3077
|
+
function resolveMatrixDisagreementPrimary(input) {
|
|
3078
|
+
if (input.winnerSelectionSource !== "matrix-verdict") return input.winnerLabel;
|
|
3079
|
+
const original = input.aiRankedFirst?.trim() || input.multiJudgePrimaryWinner?.trim();
|
|
3080
|
+
return original ? original : input.winnerLabel;
|
|
3081
|
+
}
|
|
3082
|
+
function resolveJudgeRequestedLabel(input) {
|
|
3083
|
+
if (input.effectiveJudge === "off") return "off";
|
|
3084
|
+
if (input.aiJudgePrimary) return input.aiJudgePrimary;
|
|
3085
|
+
if (input.effectiveJudge && input.effectiveJudge !== "auto") return input.effectiveJudge;
|
|
3086
|
+
return input.aiJudgeRequested ? "ai" : void 0;
|
|
3087
|
+
}
|
|
3088
|
+
function renderRepairOutcomeRunSummary(winner) {
|
|
3089
|
+
const repairOutcome = winner?.repairOutcome;
|
|
3090
|
+
if (!repairOutcome) return [];
|
|
3091
|
+
const lines = [
|
|
3092
|
+
`repairAttempted: ${repairOutcome.attempted}`,
|
|
3093
|
+
`repairClassification: ${repairOutcome.classification ?? "unknown"}`,
|
|
3094
|
+
`judgeVerdictApplicability: ${repairOutcome.judgeVerdictApplicability ?? "unknown"}`,
|
|
3095
|
+
`finalArtifactTrust: ${repairOutcome.finalArtifactTrust ?? "unknown"}`
|
|
3096
|
+
];
|
|
3097
|
+
if (repairOutcome.repairTrigger?.type) {
|
|
3098
|
+
lines.push(`repairTrigger: ${repairOutcome.repairTrigger.type}`);
|
|
3099
|
+
}
|
|
3100
|
+
const delta = repairOutcome.repairDelta;
|
|
3101
|
+
if (delta) {
|
|
3102
|
+
lines.push(`repairFilesOutsidePreRepairDiff: ${delta.filesOutsidePreRepairDiff.length}`);
|
|
3103
|
+
lines.push(`repairLineDeltaRatio: ${delta.lineDeltaRatio.toFixed(3)}`);
|
|
3104
|
+
}
|
|
3105
|
+
if (repairOutcome.judgeVerdictApplicability === "does_not_apply") {
|
|
3106
|
+
lines.push("judgeVerdictAppliesToFinalArtifact: false");
|
|
3107
|
+
}
|
|
3108
|
+
return lines;
|
|
3109
|
+
}
|
|
3110
|
+
function scoreForVariantFromTop2(top2Summary, variant) {
|
|
3111
|
+
if (!top2Summary || typeof variant !== "string" || variant.trim().length === 0) {
|
|
3112
|
+
return null;
|
|
3113
|
+
}
|
|
3114
|
+
const target = formatVariantKeyForDisplay(variant);
|
|
3115
|
+
const entry = top2Summary.top2.find(
|
|
3116
|
+
(candidate) => formatVariantKeyForDisplay(candidate.variant) === target
|
|
3117
|
+
);
|
|
3118
|
+
return entry ? entry.score : null;
|
|
3119
|
+
}
|
|
3120
|
+
function scoreForRunSummaryPrimary(input) {
|
|
3121
|
+
if (typeof input.multiJudgeRun?.primary_winner_score === "number" && Number.isFinite(input.multiJudgeRun.primary_winner_score) && typeof input.multiJudgeRun.primary_winner === "string" && typeof input.primaryWinner === "string" && variantHandlesMatchForResults(input.multiJudgeRun.primary_winner, input.primaryWinner)) {
|
|
3122
|
+
return input.multiJudgeRun.primary_winner_score;
|
|
3123
|
+
}
|
|
3124
|
+
return scoreForVariantFromTop2(input.top2Summary, input.primaryWinner);
|
|
3125
|
+
}
|
|
3126
|
+
function formatRunSummaryScoreCalibration(input) {
|
|
3127
|
+
const lines = [];
|
|
3128
|
+
const primaryWinner = typeof input.primaryWinner === "string" && input.primaryWinner.trim().length > 0 ? input.primaryWinner : null;
|
|
3129
|
+
const finalWinner = input.finalWinner;
|
|
3130
|
+
const primaryWinnerDisplay = primaryWinner ? formatVariantKeyForDisplay(primaryWinner) : null;
|
|
3131
|
+
const finalWinnerDisplay = formatVariantKeyForDisplay(finalWinner);
|
|
3132
|
+
const winnersDiffer = primaryWinnerDisplay != null && primaryWinnerDisplay !== finalWinnerDisplay;
|
|
3133
|
+
const scoreDelta = typeof input.primaryScore === "number" && Number.isFinite(input.primaryScore) && typeof input.finalScore === "number" && Number.isFinite(input.finalScore) ? input.primaryScore - input.finalScore : null;
|
|
3134
|
+
if (primaryWinnerDisplay && (winnersDiffer || scoreDelta != null && Math.abs(scoreDelta) >= 0.1)) {
|
|
3135
|
+
lines.push(`judgePrimaryWinner: ${primaryWinnerDisplay}`);
|
|
3136
|
+
if (typeof input.primaryScore === "number" && Number.isFinite(input.primaryScore)) {
|
|
3137
|
+
lines.push(`judgePrimaryScore: ${input.primaryScore.toFixed(1)}`);
|
|
3138
|
+
}
|
|
3139
|
+
lines.push(`finalRetainedWinner: ${finalWinnerDisplay}`);
|
|
3140
|
+
if (typeof input.finalScore === "number" && Number.isFinite(input.finalScore)) {
|
|
3141
|
+
lines.push(`finalRetainedScore: ${input.finalScore.toFixed(1)}`);
|
|
3142
|
+
}
|
|
3143
|
+
if (scoreDelta != null) {
|
|
3144
|
+
lines.push(`scoreDeltaPrimaryFinal: ${scoreDelta.toFixed(1)}`);
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
return lines;
|
|
3148
|
+
}
|
|
3149
|
+
function isPricedRunSummaryCost(metrics) {
|
|
3150
|
+
if (!metrics) return false;
|
|
3151
|
+
if (metrics.usageUnavailableReason === "provider_not_reported") return false;
|
|
3152
|
+
if (metrics.pricingStatus === "unavailable" || metrics.pricingStatus === "error") return false;
|
|
3153
|
+
return typeof metrics.totalCost === "number" && Number.isFinite(metrics.totalCost);
|
|
3154
|
+
}
|
|
3155
|
+
function formatKnownUsd(amount) {
|
|
3156
|
+
const cents = Math.round(amount * 100) / 100;
|
|
3157
|
+
if (Math.abs(amount - cents) < 1e-9) {
|
|
3158
|
+
return `$${cents.toFixed(2)}`;
|
|
3159
|
+
}
|
|
3160
|
+
const tenThousandths = Math.round(amount * 1e4) / 1e4;
|
|
3161
|
+
return `$${tenThousandths.toFixed(4)}`;
|
|
3162
|
+
}
|
|
3163
|
+
function resolveRunSummaryJudgeCostUsd(input) {
|
|
3164
|
+
if (typeof input.judgeCostUsd === "number" && Number.isFinite(input.judgeCostUsd)) {
|
|
3165
|
+
return input.judgeCostUsd;
|
|
3166
|
+
}
|
|
3167
|
+
const raw = input.latestMultiJudgeRun?.resultsJson ?? input.latestMultiJudgeRun?.results_json;
|
|
3168
|
+
let entries = [];
|
|
3169
|
+
if (typeof raw === "string" && raw.trim().length > 0) {
|
|
3170
|
+
try {
|
|
3171
|
+
const parsed = JSON.parse(raw);
|
|
3172
|
+
if (parsed && typeof parsed === "object") {
|
|
3173
|
+
entries = Object.values(parsed);
|
|
3174
|
+
}
|
|
3175
|
+
} catch {
|
|
3176
|
+
entries = [];
|
|
3177
|
+
}
|
|
3178
|
+
} else if (raw && typeof raw === "object") {
|
|
3179
|
+
entries = Object.values(raw);
|
|
3180
|
+
}
|
|
3181
|
+
const costs = entries.map((entry) => entry?.costUsd).filter((value) => typeof value === "number" && Number.isFinite(value));
|
|
3182
|
+
if (costs.length === 0) {
|
|
3183
|
+
return void 0;
|
|
3184
|
+
}
|
|
3185
|
+
return costs.reduce((sum, value) => sum + value, 0);
|
|
3186
|
+
}
|
|
3187
|
+
function formatRunSummaryCostLabel(input) {
|
|
3188
|
+
const judgeCostUsd = resolveRunSummaryJudgeCostUsd(input);
|
|
3189
|
+
const members = input.variants;
|
|
3190
|
+
const priced = members.filter((variant) => isPricedRunSummaryCost(variant.costMetrics));
|
|
3191
|
+
const unpricedCount = members.length - priced.length;
|
|
3192
|
+
const pricedSum = priced.reduce((sum, variant) => {
|
|
3193
|
+
const metrics = variant.costMetrics;
|
|
3194
|
+
return sum + (isPricedRunSummaryCost(metrics) ? metrics.totalCost : 0);
|
|
3195
|
+
}, 0);
|
|
3196
|
+
const judgeCost = judgeCostUsd;
|
|
3197
|
+
if (members.length === 0 && judgeCost === void 0) {
|
|
3198
|
+
return "n/a";
|
|
3199
|
+
}
|
|
3200
|
+
const parts = [];
|
|
3201
|
+
if (members.length > 0) {
|
|
3202
|
+
parts.push(`${unpricedCount}/${members.length} variants unpriced`);
|
|
3203
|
+
}
|
|
3204
|
+
if (priced.length > 0) {
|
|
3205
|
+
parts.push(`priced ${formatKnownUsd(pricedSum)} (${describeAggregateBasis(priced)})`);
|
|
3206
|
+
}
|
|
3207
|
+
if (input.analysisSynthesisResult) {
|
|
3208
|
+
const cost = input.analysisSynthesisResult.provenance?.totalCostUsd;
|
|
3209
|
+
parts.push(
|
|
3210
|
+
typeof cost === "number" && Number.isFinite(cost) ? `synthesis ${formatKnownUsd(cost)}` : "synthesis unpriced"
|
|
3211
|
+
);
|
|
3212
|
+
}
|
|
3213
|
+
if (judgeCost !== void 0) {
|
|
3214
|
+
parts.push(`judge ${formatKnownUsd(judgeCost)}`);
|
|
3215
|
+
}
|
|
3216
|
+
if (parts.length === 0) {
|
|
3217
|
+
return "n/a";
|
|
3218
|
+
}
|
|
3219
|
+
return `unavailable (${parts.join("; ")})`;
|
|
3220
|
+
}
|
|
3221
|
+
function describeAggregateBasis(variants, options = {}) {
|
|
3222
|
+
const reported = variants.filter(
|
|
3223
|
+
(variant) => variant.costMetrics?.costBasis === "provider_reported"
|
|
3224
|
+
).length;
|
|
3225
|
+
return [
|
|
3226
|
+
"API list price",
|
|
3227
|
+
...reported > 0 ? [`${reported}/${variants.length} variants provider-reported, no list price`] : [],
|
|
3228
|
+
...options.includesSynthesis ? ["synthesis provider-reported"] : []
|
|
3229
|
+
].join("; ");
|
|
3230
|
+
}
|
|
3231
|
+
function formatCompetitionRunSummaryCostLabel(input) {
|
|
3232
|
+
const receiptLabel = input.receipt ? formatTaskReportCostLabel(input.receipt) : void 0;
|
|
3233
|
+
if (receiptLabel) return receiptLabel;
|
|
3234
|
+
if (input.costAggregate.status === "available" && typeof input.costAggregate.totalCost === "number") {
|
|
3235
|
+
return `$${input.costAggregate.totalCost.toFixed(4)} (${describeAggregateBasis(input.variants, { includesSynthesis: input.analysisSynthesisResult != null })})`;
|
|
3236
|
+
}
|
|
3237
|
+
return formatRunSummaryCostLabel({
|
|
3238
|
+
variants: input.variants,
|
|
3239
|
+
analysisSynthesisResult: input.analysisSynthesisResult,
|
|
3240
|
+
judgeCostUsd: extractJudgeUsageSummary(
|
|
3241
|
+
input.synthesisResult
|
|
3242
|
+
).costUsd,
|
|
3243
|
+
latestMultiJudgeRun: input.latestMultiJudgeRun
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
function formatRunSummaryConfidence(winner) {
|
|
3247
|
+
const confidence = typeof winner?.judgeEvaluation?.confidence === "number" ? winner.judgeEvaluation.confidence : typeof winner?.judgeEvaluation?.metadata?.confidence === "number" ? winner.judgeEvaluation.metadata.confidence : void 0;
|
|
3248
|
+
if (typeof confidence !== "number" || !Number.isFinite(confidence)) {
|
|
3249
|
+
return "n/a";
|
|
3250
|
+
}
|
|
3251
|
+
const percent = confidence <= 1 ? confidence * 100 : confidence;
|
|
3252
|
+
return `${percent.toFixed(0)}%`;
|
|
3253
|
+
}
|
|
3254
|
+
var SLOW_POST_PROVIDER_PHASE_MS = 3e4;
|
|
3255
|
+
function formatDurationMsForSummary(durationMs) {
|
|
3256
|
+
return formatDurationSeconds(durationMs / 1e3);
|
|
3257
|
+
}
|
|
3258
|
+
function formatSlowPostProviderPhases(variant) {
|
|
3259
|
+
const phases = variant.postProviderPhaseDurationsMs;
|
|
3260
|
+
if (!phases) return null;
|
|
3261
|
+
const slowPhases = Object.entries(phases).filter(
|
|
3262
|
+
([, durationMs]) => Number.isFinite(durationMs) && durationMs >= SLOW_POST_PROVIDER_PHASE_MS
|
|
3263
|
+
).sort(([, left], [, right]) => right - left).slice(0, 4);
|
|
3264
|
+
if (slowPhases.length === 0) return null;
|
|
3265
|
+
return slowPhases.map(([phase, durationMs]) => `${phase}=${formatDurationMsForSummary(durationMs)}`).join(" ");
|
|
3266
|
+
}
|
|
3267
|
+
function hasJudgeSynthesisSignal(input) {
|
|
3268
|
+
return Boolean(input.top2Summary) || Boolean(input.winner?.judgeEvaluation);
|
|
3269
|
+
}
|
|
3270
|
+
function formatWinnerJudgeSignal(input) {
|
|
3271
|
+
const confidence = formatRunSummaryConfidence(input.winner);
|
|
3272
|
+
const parts = [`confidence=${confidence}`];
|
|
3273
|
+
const top2Summary = input.top2Summary;
|
|
3274
|
+
if (top2Summary) {
|
|
3275
|
+
parts.push(`margin=${top2Summary.margin.toFixed(1)}`);
|
|
3276
|
+
const entries = top2Summary.top2.slice(0, 2).map((entry) => {
|
|
3277
|
+
const label = formatVariantKeyForDisplay(entry.variant);
|
|
3278
|
+
const score = Number.isFinite(entry.score) ? entry.score.toFixed(1) : "n/a";
|
|
3279
|
+
return `${label}(${score})`;
|
|
3280
|
+
});
|
|
3281
|
+
if (entries.length === 2) {
|
|
3282
|
+
parts.push(`top2=${entries[0]} vs ${entries[1]}`);
|
|
3283
|
+
} else if (entries.length === 1) {
|
|
3284
|
+
parts.push(`top2=${entries[0]}`);
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
return parts.join(" ");
|
|
3288
|
+
}
|
|
3289
|
+
function normalizeSynthesisOutcomeStatus(synthesisResult) {
|
|
3290
|
+
if (typeof synthesisResult?.synthesisOutcomeStatus === "string") {
|
|
3291
|
+
return synthesisResult.synthesisOutcomeStatus;
|
|
3292
|
+
}
|
|
3293
|
+
if (synthesisResult?.synthesisApplied === true) return "applied";
|
|
3294
|
+
if (synthesisResult?.winnerFallback === true) return "winner_carry_forward";
|
|
3295
|
+
if (synthesisResult) return "not_attempted";
|
|
3296
|
+
return "not_attempted";
|
|
3297
|
+
}
|
|
3298
|
+
function formatTracePick(variant) {
|
|
3299
|
+
return variant && variant.trim().length > 0 ? formatVariantKeyForDisplay(variant) : "no_pick";
|
|
3300
|
+
}
|
|
3301
|
+
function unwrapTruncatedMultiJudgeResults(parsed) {
|
|
3302
|
+
if (parsed.truncated === true && parsed.summary && typeof parsed.summary === "object" && !Array.isArray(parsed.summary)) {
|
|
3303
|
+
return parsed.summary;
|
|
3304
|
+
}
|
|
3305
|
+
return parsed;
|
|
3306
|
+
}
|
|
3307
|
+
function parseMultiJudgeResultsJson(run) {
|
|
3308
|
+
if (run?.resultsJson && typeof run.resultsJson === "object" && !Array.isArray(run.resultsJson)) {
|
|
3309
|
+
return unwrapTruncatedMultiJudgeResults(run.resultsJson);
|
|
3310
|
+
}
|
|
3311
|
+
const resultsJson = run?.results_json ?? run?.resultsJson;
|
|
3312
|
+
if (typeof resultsJson !== "string" || resultsJson.trim().length === 0) {
|
|
3313
|
+
return null;
|
|
3314
|
+
}
|
|
3315
|
+
try {
|
|
3316
|
+
const parsed = JSON.parse(resultsJson);
|
|
3317
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
3318
|
+
return unwrapTruncatedMultiJudgeResults(parsed);
|
|
3319
|
+
} catch {
|
|
3320
|
+
return null;
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
function getMultiJudgePrimaryJudge(run) {
|
|
3324
|
+
return run?.primary_judge ?? run?.primaryJudge ?? null;
|
|
3325
|
+
}
|
|
3326
|
+
function getMultiJudgePrimaryWinner(run) {
|
|
3327
|
+
return run?.primary_winner ?? run?.primaryWinner ?? null;
|
|
3328
|
+
}
|
|
3329
|
+
function getMultiJudgeExecutedJudges(run) {
|
|
3330
|
+
if (!run) return [];
|
|
3331
|
+
if (Array.isArray(run.judgesExecuted)) return run.judgesExecuted;
|
|
3332
|
+
const raw = run.judges_executed ?? run.judgesExecuted;
|
|
3333
|
+
if (typeof raw !== "string" || raw.trim().length === 0) return [];
|
|
3334
|
+
try {
|
|
3335
|
+
const parsed = JSON.parse(raw);
|
|
3336
|
+
if (Array.isArray(parsed)) return parsed.filter((judge) => typeof judge === "string");
|
|
3337
|
+
} catch {
|
|
3338
|
+
return raw.split(",").map((judge) => judge.trim()).filter(Boolean);
|
|
3339
|
+
}
|
|
3340
|
+
return [];
|
|
3341
|
+
}
|
|
3342
|
+
function multiJudgeExecuted(run, judge) {
|
|
3343
|
+
if (!run) return false;
|
|
3344
|
+
const results = parseMultiJudgeResultsJson(run);
|
|
3345
|
+
const result = results?.[judge];
|
|
3346
|
+
if (result) return result.status !== "skipped";
|
|
3347
|
+
if (getMultiJudgePrimaryJudge(run) === judge) return true;
|
|
3348
|
+
return getMultiJudgeExecutedJudges(run).includes(judge);
|
|
3349
|
+
}
|
|
3350
|
+
function multiJudgeWinner(run, judge) {
|
|
3351
|
+
const results = parseMultiJudgeResultsJson(run);
|
|
3352
|
+
const winner = results?.[judge]?.winner;
|
|
3353
|
+
if (typeof winner === "string") return winner;
|
|
3354
|
+
if (results && Object.hasOwn(results, judge)) return null;
|
|
3355
|
+
if (getMultiJudgePrimaryJudge(run) === judge) return getMultiJudgePrimaryWinner(run);
|
|
3356
|
+
return void 0;
|
|
3357
|
+
}
|
|
3358
|
+
function multiJudgeSkipReason(run, judge) {
|
|
3359
|
+
const entry = parseMultiJudgeResultsJson(run)?.[judge];
|
|
3360
|
+
if (!entry || entry.status !== "skipped") return null;
|
|
3361
|
+
if (typeof entry.skippedReason === "string" && entry.skippedReason.trim().length > 0) {
|
|
3362
|
+
return entry.skippedReason.trim();
|
|
3363
|
+
}
|
|
3364
|
+
if (typeof entry.error === "string" && entry.error.trim().length > 0) {
|
|
3365
|
+
return entry.error.trim().replace(/\s+/g, "_").slice(0, 80);
|
|
3366
|
+
}
|
|
3367
|
+
return "unspecified";
|
|
3368
|
+
}
|
|
3369
|
+
function formatJudgeTraceLine(input) {
|
|
3370
|
+
const skipReason = multiJudgeSkipReason(input.run, input.judge);
|
|
3371
|
+
if (skipReason) return `skipped:${skipReason}`;
|
|
3372
|
+
if (input.fallbackExecuted || multiJudgeExecuted(input.run, input.judge)) {
|
|
3373
|
+
return formatTracePick(input.pick);
|
|
3374
|
+
}
|
|
3375
|
+
return "not_run";
|
|
3376
|
+
}
|
|
3377
|
+
function formatFinalCompetitionDecisionTraceLines(input) {
|
|
3378
|
+
const lines = ["decisionTrace:"];
|
|
3379
|
+
const winnerSource = input.winner?.winnerSelectionSource;
|
|
3380
|
+
const aiMultiJudgeWinner = multiJudgeWinner(input.latestMultiJudgeRun, "ai");
|
|
3381
|
+
const aiPick = input.latestJudgeDecision?.aiRankedFirst ?? aiMultiJudgeWinner ?? (winnerSource === "ai-judge" || winnerSource === "ai-judge-ranking" ? input.latestJudgeDecision?.selectedVariant ?? input.winner?.variant : void 0);
|
|
3382
|
+
const aiLine = formatJudgeTraceLine({
|
|
3383
|
+
run: input.latestMultiJudgeRun,
|
|
3384
|
+
judge: "ai",
|
|
3385
|
+
pick: aiPick,
|
|
3386
|
+
fallbackExecuted: Boolean(input.latestJudgeDecision)
|
|
3387
|
+
});
|
|
3388
|
+
lines.push(`decisionTrace.aiJudge: ${aiLine}`);
|
|
3389
|
+
const multiLensWinner = multiJudgeWinner(input.latestMultiJudgeRun, "multi-lens") ?? (winnerSource === "multi-lens" || winnerSource === "multi-lens-ranking" ? input.latestJudgeDecision?.selectedVariant ?? input.winner?.variant : void 0);
|
|
3390
|
+
const multiLensLine = formatJudgeTraceLine({
|
|
3391
|
+
run: input.latestMultiJudgeRun,
|
|
3392
|
+
judge: "multi-lens",
|
|
3393
|
+
pick: multiLensWinner,
|
|
3394
|
+
fallbackExecuted: winnerSource === "multi-lens" || winnerSource === "multi-lens-ranking"
|
|
3395
|
+
});
|
|
3396
|
+
lines.push(`decisionTrace.multiLens: ${multiLensLine}`);
|
|
3397
|
+
if (input.autoMatrixResult) {
|
|
3398
|
+
const matrixWinner = getUnanimousMatrixWinner(input.autoMatrixResult);
|
|
3399
|
+
const matrixStatus = input.autoMatrixResult.winnerStatus ?? "accepted";
|
|
3400
|
+
lines.push(
|
|
3401
|
+
`decisionTrace.matrix: ${matrixWinner ? formatVariantKeyForDisplay(matrixWinner) : "no_recommendation"} (${matrixStatus})`
|
|
3402
|
+
);
|
|
3403
|
+
} else if (input.latestJudgeDecision?.matrixAutoRunFailure) {
|
|
3404
|
+
lines.push(`decisionTrace.matrix: failed (${input.latestJudgeDecision.matrixAutoRunFailure})`);
|
|
3405
|
+
} else {
|
|
3406
|
+
lines.push("decisionTrace.matrix: not_run");
|
|
3407
|
+
}
|
|
3408
|
+
lines.push(`decisionTrace.synthesis: ${normalizeSynthesisOutcomeStatus(input.synthesisResult)}`);
|
|
3409
|
+
return lines;
|
|
3410
|
+
}
|
|
3411
|
+
function gateSnapshotFromSynthesis(synthesisResult) {
|
|
3412
|
+
if (synthesisResult?.synthesisGateResults) {
|
|
3413
|
+
return synthesisResult.synthesisGateResults;
|
|
3414
|
+
}
|
|
3415
|
+
const legacy = synthesisResult?.gateResults;
|
|
3416
|
+
return isSynthesisGateResultSnapshot(legacy) ? legacy : void 0;
|
|
3417
|
+
}
|
|
3418
|
+
function isSynthesisGateResultSnapshot(value) {
|
|
3419
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
3420
|
+
return false;
|
|
3421
|
+
}
|
|
3422
|
+
const candidate = value;
|
|
3423
|
+
return typeof candidate.isEligible === "boolean" && typeof candidate.buildPassed === "boolean" && typeof candidate.lintPassed === "boolean" && typeof candidate.formatPassed === "boolean" && typeof candidate.buildStatus === "string" && typeof candidate.lintStatus === "string" && typeof candidate.testStatus === "string" && typeof candidate.formatStatus === "string";
|
|
3424
|
+
}
|
|
3425
|
+
function coverageLabel(coverageStatus) {
|
|
3426
|
+
switch (coverageStatus) {
|
|
3427
|
+
case "verified":
|
|
3428
|
+
return "verified";
|
|
3429
|
+
case "partially_verified":
|
|
3430
|
+
return "partial";
|
|
3431
|
+
case "skipped_no_command":
|
|
3432
|
+
return "not_configured";
|
|
3433
|
+
case "skipped_tool_unavailable":
|
|
3434
|
+
return "unavailable";
|
|
3435
|
+
case "skipped_not_relevant":
|
|
3436
|
+
return "not_relevant";
|
|
3437
|
+
case "unverified":
|
|
3438
|
+
return "unverified";
|
|
3439
|
+
default:
|
|
3440
|
+
return "unknown";
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
function appendCoverageReason(parts, reason) {
|
|
3444
|
+
if (reason && reason.trim().length > 0) {
|
|
3445
|
+
parts.push(`reason=${reason.trim().replace(/\s+/g, " ")}`);
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
function formatSnapshotGateLine(input) {
|
|
3449
|
+
const parts = [
|
|
3450
|
+
`status=${input.status ?? "not_run"}`,
|
|
3451
|
+
`coverage=${coverageLabel(input.coverageStatus)}`
|
|
3452
|
+
];
|
|
3453
|
+
appendCoverageReason(parts, input.reason);
|
|
3454
|
+
return `synthesisGate.${input.gate}: ${parts.join(" ")}`;
|
|
3455
|
+
}
|
|
3456
|
+
function variantGateStatus(winner, gate) {
|
|
3457
|
+
return winner ? readVariantVerification(winner).gates[gate].status : "not_run";
|
|
3458
|
+
}
|
|
3459
|
+
function formatSynthesisGateTraceLines(input) {
|
|
3460
|
+
const synthesisResult = input.synthesisResult;
|
|
3461
|
+
const outcomeStatus = normalizeSynthesisOutcomeStatus(synthesisResult);
|
|
3462
|
+
const snapshot = gateSnapshotFromSynthesis(synthesisResult);
|
|
3463
|
+
if (outcomeStatus === "winner_carry_forward" || synthesisResult?.winnerFallback === true) {
|
|
3464
|
+
const lines = [
|
|
3465
|
+
"synthesisGateSource: carried_forward_winner",
|
|
3466
|
+
`synthesisGate.buildTypecheck: status=${variantGateStatus(input.winner, "build")} coverage=carried_forward`,
|
|
3467
|
+
`synthesisGate.lint: status=${variantGateStatus(input.winner, "lint")} coverage=carried_forward`,
|
|
3468
|
+
`synthesisGate.test: status=${variantGateStatus(input.winner, "test")} coverage=carried_forward`
|
|
3469
|
+
];
|
|
3470
|
+
if (input.winner?.outcome?.verification?.status === "baseline_clean") {
|
|
3471
|
+
lines.push("synthesisGateWinnerVerification: baseline_clean");
|
|
3472
|
+
}
|
|
3473
|
+
return lines;
|
|
3474
|
+
}
|
|
3475
|
+
if (!snapshot) {
|
|
3476
|
+
const reason = synthesisResult ? "post-synthesis gate snapshot unavailable" : "synthesis not attempted";
|
|
3477
|
+
return [
|
|
3478
|
+
"synthesisGateSource: not_run",
|
|
3479
|
+
`synthesisGate.buildTypecheck: status=not_run coverage=unknown reason=${reason}`,
|
|
3480
|
+
`synthesisGate.lint: status=not_run coverage=unknown reason=${reason}`,
|
|
3481
|
+
`synthesisGate.test: status=not_run coverage=unknown reason=${reason}`
|
|
3482
|
+
];
|
|
3483
|
+
}
|
|
3484
|
+
return [
|
|
3485
|
+
"synthesisGateSource: synthesis_worktree",
|
|
3486
|
+
formatSnapshotGateLine({
|
|
3487
|
+
gate: "buildTypecheck",
|
|
3488
|
+
status: snapshot.buildStatus,
|
|
3489
|
+
coverageStatus: snapshot.buildCoverage?.status,
|
|
3490
|
+
reason: snapshot.buildCoverage?.reason
|
|
3491
|
+
}),
|
|
3492
|
+
formatSnapshotGateLine({
|
|
3493
|
+
gate: "lint",
|
|
3494
|
+
status: snapshot.lintStatus,
|
|
3495
|
+
coverageStatus: snapshot.lintCoverage?.status,
|
|
3496
|
+
reason: snapshot.lintCoverage?.reason
|
|
3497
|
+
}),
|
|
3498
|
+
formatSnapshotGateLine({
|
|
3499
|
+
gate: "test",
|
|
3500
|
+
status: snapshot.testStatus,
|
|
3501
|
+
coverageStatus: snapshot.testCoverage?.status,
|
|
3502
|
+
reason: snapshot.testCoverage?.reason
|
|
3503
|
+
}),
|
|
3504
|
+
formatSnapshotGateLine({
|
|
3505
|
+
gate: "format",
|
|
3506
|
+
status: snapshot.formatPassed ? "passed" : snapshot.formatStatus === "verified" ? "failed" : "not_run",
|
|
3507
|
+
coverageStatus: snapshot.formatCoverage?.status ?? snapshot.formatStatus,
|
|
3508
|
+
reason: snapshot.formatCoverage?.reason
|
|
3509
|
+
})
|
|
3510
|
+
];
|
|
3511
|
+
}
|
|
3512
|
+
|
|
3513
|
+
export {
|
|
3514
|
+
formatTaskReportReceipt,
|
|
3515
|
+
FUSION_SYNTHESIS_MANIFEST_VERSION,
|
|
3516
|
+
resolveFusionSynthesisTarget,
|
|
3517
|
+
runFusionSynthesis,
|
|
3518
|
+
buildJudgeCompletenessTelemetryFromVariants,
|
|
3519
|
+
shouldStopBeforeJudgeOrSynthesis,
|
|
3520
|
+
resolveHandoffPathFromStatePath,
|
|
3521
|
+
buildPortableResultsCommand,
|
|
3522
|
+
buildMatrixEvaluationCommand,
|
|
3523
|
+
quoteReplayArg,
|
|
3524
|
+
formatJudgeSkippedWarning,
|
|
3525
|
+
formatJudgeNoWinnerWarning,
|
|
3526
|
+
formatSynthesisOutcomeSummary,
|
|
3527
|
+
formatCompetitionApplyNextSteps,
|
|
3528
|
+
formatSynthesisFailureNextSteps,
|
|
3529
|
+
buildCompeteRunMetadata,
|
|
3530
|
+
resolvePersistedJudgeRunState,
|
|
3531
|
+
resolveWinnerVerifiedForDecision,
|
|
3532
|
+
formatMatrixProfileWinners,
|
|
3533
|
+
formatMatrixProfileDecision,
|
|
3534
|
+
resolveMatrixDefaultWinnerSource,
|
|
3535
|
+
mergeJudgeEvaluatedVariantSignals,
|
|
3536
|
+
attachMatrixAdvisoryToSynthesisContext,
|
|
3537
|
+
isLowConfidenceBaselineReason,
|
|
3538
|
+
resolveEffectiveJudgeDecision,
|
|
3539
|
+
formatMatrixAutoRunReason,
|
|
3540
|
+
resolveWinnerMethodForDisplay,
|
|
3541
|
+
maybePromoteAlgorithmicFallbackWinner,
|
|
3542
|
+
isJudgeUnavailableDecision,
|
|
3543
|
+
isJudgeInconclusiveDecision,
|
|
3544
|
+
resolveAlgorithmicFallbackWinner,
|
|
3545
|
+
findVariantStateFile,
|
|
3546
|
+
applyWinnerCompletionMode,
|
|
3547
|
+
persistJudgeResults,
|
|
3548
|
+
reconcileVariantResultsTelemetry,
|
|
3549
|
+
logJudgeEvaluationTelemetry,
|
|
3550
|
+
loadConfiguredConcurrency,
|
|
3551
|
+
concurrencyAdvisoryMessage,
|
|
3552
|
+
hasUsableAnalysisOutput,
|
|
3553
|
+
executeCompetitionSynthesis,
|
|
3554
|
+
hasNonEmptyEditEvidence,
|
|
3555
|
+
countVariantFilesChanged,
|
|
3556
|
+
formatVariantChangeSummary,
|
|
3557
|
+
shouldFailForEmptyEditDelivery,
|
|
3558
|
+
formatEmptyEditDeliveryWarning,
|
|
3559
|
+
pickWorseSynthesisStatus,
|
|
3560
|
+
formatCompetitionDeliveryResultLabel,
|
|
3561
|
+
formatJudgeOffVariantStatus,
|
|
3562
|
+
isJudgeOffMultiVariantWithoutWinner,
|
|
3563
|
+
resolveFusionDeliveryExit,
|
|
3564
|
+
computeCompetitionTerminalExit,
|
|
3565
|
+
getRequiredGateAwareDisplayVerdict,
|
|
3566
|
+
formatMatrixPrimaryDisagreementSummary,
|
|
3567
|
+
resolveMatrixDisagreementPrimary,
|
|
3568
|
+
resolveJudgeRequestedLabel,
|
|
3569
|
+
renderRepairOutcomeRunSummary,
|
|
3570
|
+
scoreForVariantFromTop2,
|
|
3571
|
+
scoreForRunSummaryPrimary,
|
|
3572
|
+
formatRunSummaryScoreCalibration,
|
|
3573
|
+
describeAggregateBasis,
|
|
3574
|
+
formatCompetitionRunSummaryCostLabel,
|
|
3575
|
+
formatRunSummaryConfidence,
|
|
3576
|
+
formatSlowPostProviderPhases,
|
|
3577
|
+
hasJudgeSynthesisSignal,
|
|
3578
|
+
formatWinnerJudgeSignal,
|
|
3579
|
+
formatFinalCompetitionDecisionTraceLines,
|
|
3580
|
+
formatSynthesisGateTraceLines,
|
|
3581
|
+
parseProviderLimits,
|
|
3582
|
+
resolveNativeResearchTraceDir,
|
|
3583
|
+
persistNativeResearchTraces,
|
|
3584
|
+
parseDeliverableContract,
|
|
3585
|
+
computeDeliverableContract
|
|
3586
|
+
};
|
|
3587
|
+
//# sourceMappingURL=chunk-QP4UTSOV.js.map
|