@tangle-network/agent-eval 1.0.39 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -0
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-BKgR30kv.d.ts → agent-profile-BSgtn-k-.d.ts} +247 -168
- package/dist/agent-profile-BSgtn-k-.d.ts.map +1 -0
- package/dist/{agent-profile-DgbRJpSi.js → agent-profile-CCw6EXWW.js} +2 -2
- package/dist/{agent-profile-DgbRJpSi.js.map → agent-profile-CCw6EXWW.js.map} +1 -1
- package/dist/{agent-profile-cell-7Mt0wBkl.js → agent-profile-cell-CUthydZB.js} +2 -2
- package/dist/{agent-profile-cell-7Mt0wBkl.js.map → agent-profile-cell-CUthydZB.js.map} +1 -1
- package/dist/analyst/index.d.ts +13 -13
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +15 -15
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-DqHx3Q_g.js → analyze-runs-C_9cXPZn.js} +9 -9
- package/dist/{analyze-runs-DqHx3Q_g.js.map → analyze-runs-C_9cXPZn.js.map} +1 -1
- package/dist/{analyze-runs-Ctuz-dd3.d.ts → analyze-runs-zEI7yAH_.d.ts} +2 -2
- package/dist/{analyze-runs-Ctuz-dd3.d.ts.map → analyze-runs-zEI7yAH_.d.ts.map} +1 -1
- package/dist/app-grade/index.d.ts +3 -3
- package/dist/app-grade/index.js +3 -3
- package/dist/authenticity/index.d.ts.map +1 -1
- package/dist/authenticity/index.js.map +1 -1
- package/dist/{benchmark-command-BpmrrgzA.js → benchmark-command-XLXa7I98.js} +14 -13
- package/dist/benchmark-command-XLXa7I98.js.map +1 -0
- package/dist/benchmarks/index.d.ts +8 -4
- package/dist/benchmarks/index.d.ts.map +1 -1
- package/dist/benchmarks/index.js +11 -6
- package/dist/benchmarks/index.js.map +1 -1
- package/dist/builder-eval/index.d.ts +1 -1
- package/dist/builder-eval/index.js +3 -3
- package/dist/{calibration-BBhY1QM6.js → calibration-Cfoup0xz.js} +3 -3
- package/dist/{calibration-BBhY1QM6.js.map → calibration-Cfoup0xz.js.map} +1 -1
- package/dist/campaign/index.d.ts +9 -9
- package/dist/campaign/index.js +16 -15
- package/dist/{campaign-UzOUBIwA.js → campaign-BlmkAwFD.js} +23 -23
- package/dist/campaign-BlmkAwFD.js.map +1 -0
- package/dist/{statistical-heldout-RmdXoz2e.d.ts → campaign-evidence-BVKG5o32.d.ts} +418 -418
- package/dist/campaign-evidence-BVKG5o32.d.ts.map +1 -0
- package/dist/{campaign-evidence-BX8OveG5.js → campaign-evidence-CsUE_lwc.js} +79 -26
- package/dist/campaign-evidence-CsUE_lwc.js.map +1 -0
- package/dist/{canonical-gLeHiqzd.d.ts → canonical-CGXS21f_.d.ts} +8 -5
- package/dist/{canonical-gLeHiqzd.d.ts.map → canonical-CGXS21f_.d.ts.map} +1 -1
- package/dist/{canonical-BANK6NOj.js → canonical-DKgL_Wby.js} +30 -8
- package/dist/canonical-DKgL_Wby.js.map +1 -0
- package/dist/{chat-client-DmPB31_2.js → chat-client-DqAXFLi-.js} +2 -2
- package/dist/{chat-client-DmPB31_2.js.map → chat-client-DqAXFLi-.js.map} +1 -1
- package/dist/{chat-json-call-Rfhu7JbJ.js → chat-json-call-CB6sQ6sv.js} +2 -2
- package/dist/{chat-json-call-Rfhu7JbJ.js.map → chat-json-call-CB6sQ6sv.js.map} +1 -1
- package/dist/{claim-C6LRiwz1.js → claim-BWEXwwBk.js} +2 -2
- package/dist/{claim-C6LRiwz1.js.map → claim-BWEXwwBk.js.map} +1 -1
- package/dist/cli.js +11 -11
- package/dist/{client-BIFwUg7I.d.ts → client-DUMIaMob.d.ts} +2 -2
- package/dist/{client-BIFwUg7I.d.ts.map → client-DUMIaMob.d.ts.map} +1 -1
- package/dist/cluster-CSd0LE_M.d.ts.map +1 -1
- package/dist/{cluster-bootstrap-ClPYIWoX.js → cluster-bootstrap-DPzVy3_K.js} +2 -2
- package/dist/{cluster-bootstrap-ClPYIWoX.js.map → cluster-bootstrap-DPzVy3_K.js.map} +1 -1
- package/dist/{completion-verifier-C3q1T96h.js → completion-verifier-DiG3y43g.js} +6 -6
- package/dist/{completion-verifier-C3q1T96h.js.map → completion-verifier-DiG3y43g.js.map} +1 -1
- package/dist/containment-order-GCJ-y_FV.js +56 -0
- package/dist/containment-order-GCJ-y_FV.js.map +1 -0
- package/dist/contract/index.d.ts +11 -11
- package/dist/contract/index.js +16 -16
- package/dist/contract/index.js.map +1 -1
- package/dist/cost-ledger-1CwUnVOd.js.map +1 -1
- package/dist/{decision-point-BN1YQNqk.js → decision-point-gt5JgqZ0.js} +8 -8
- package/dist/{decision-point-BN1YQNqk.js.map → decision-point-gt5JgqZ0.js.map} +1 -1
- package/dist/{default-registry-C5x2jyD6.d.ts → default-registry-DH_tl-V1.d.ts} +7 -7
- package/dist/{default-registry-C5x2jyD6.d.ts.map → default-registry-DH_tl-V1.d.ts.map} +1 -1
- package/dist/{default-registry-DSo3tnsW.js → default-registry-Y9AaKLmG.js} +8 -8
- package/dist/default-registry-Y9AaKLmG.js.map +1 -0
- package/dist/{define-agent-eval-4KGwzIVt.d.ts → define-agent-eval-BDxV_ONM.d.ts} +18 -10
- package/dist/define-agent-eval-BDxV_ONM.d.ts.map +1 -0
- package/dist/{define-agent-eval-C6zFzxp7.js → define-agent-eval-Cq-bdF4O.js} +16 -13
- package/dist/define-agent-eval-Cq-bdF4O.js.map +1 -0
- package/dist/diagnosis/index.d.ts +3 -3
- package/dist/diagnosis/index.d.ts.map +1 -1
- package/dist/diagnosis/index.js +1 -1
- package/dist/diagnosis/index.js.map +1 -1
- package/dist/{dspy-rlm-engine-EC-Pkdf-.js → dspy-rlm-engine-CHpTzYvZ.js} +4 -3
- package/dist/dspy-rlm-engine-CHpTzYvZ.js.map +1 -0
- package/dist/{emitter-DhQ65mza.js → emitter-BjW3NnX-.js} +15 -6
- package/dist/emitter-BjW3NnX-.js.map +1 -0
- package/dist/{emitter-mAXC5PSN.d.ts → emitter-Cw8ijO3v.d.ts} +4 -4
- package/dist/{emitter-mAXC5PSN.d.ts.map → emitter-Cw8ijO3v.d.ts.map} +1 -1
- package/dist/{engine-B2w3ARpj.d.ts → engine-3y87jnX0.d.ts} +2 -2
- package/dist/{engine-B2w3ARpj.d.ts.map → engine-3y87jnX0.d.ts.map} +1 -1
- package/dist/errors-DeEEV9Vx.js.map +1 -1
- package/dist/{eval-campaign-CWWh-1p1.js → eval-campaign-Cyk-tkLh.js} +5 -5
- package/dist/{eval-campaign-CWWh-1p1.js.map → eval-campaign-Cyk-tkLh.js.map} +1 -1
- package/dist/{evaluation-CQ-uAbqF.d.ts → evaluation-RODuDmCe.d.ts} +4 -4
- package/dist/{evaluation-CQ-uAbqF.d.ts.map → evaluation-RODuDmCe.d.ts.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/{exact-types-B0_jA3V7.d.ts → exact-types-C4Rug7fG.d.ts} +2 -2
- package/dist/{exact-types-B0_jA3V7.d.ts.map → exact-types-C4Rug7fG.d.ts.map} +1 -1
- package/dist/{execution-insight-9No6Si55.d.ts → execution-insight-iOsr1Zi8.d.ts} +2 -2
- package/dist/{execution-insight-9No6Si55.d.ts.map → execution-insight-iOsr1Zi8.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +4 -4
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/experiment/index.js +10 -10
- package/dist/experiment/index.js.map +1 -1
- package/dist/{exporters-C9AwGDDK.js → exporters-CKFtnWmX.js} +2 -2
- package/dist/{exporters-C9AwGDDK.js.map → exporters-CKFtnWmX.js.map} +1 -1
- package/dist/external-optimizer-contracts-eKQTutGZ.js +123 -0
- package/dist/external-optimizer-contracts-eKQTutGZ.js.map +1 -0
- package/dist/{external-optimizer-process-DFEPdWJY.js → external-optimizer-process-CkAc1xBa.js} +22 -26
- package/dist/external-optimizer-process-CkAc1xBa.js.map +1 -0
- package/dist/{external-optimizer-subprocess-BspZ0bZb.js → external-optimizer-subprocess-B48Ie4qQ.js} +10 -124
- package/dist/external-optimizer-subprocess-B48Ie4qQ.js.map +1 -0
- package/dist/extract-usage-ISFqhfDz.js.map +1 -1
- package/dist/{feedback-trajectory-FamLu3Wt.d.ts → feedback-trajectory-B5hTr9w5.d.ts} +4 -4
- package/dist/{feedback-trajectory-FamLu3Wt.d.ts.map → feedback-trajectory-B5hTr9w5.d.ts.map} +1 -1
- package/dist/{finding-composition-BMgspnVI.js → finding-composition-CyWSTcAY.js} +2 -2
- package/dist/{finding-composition-BMgspnVI.js.map → finding-composition-CyWSTcAY.js.map} +1 -1
- package/dist/{findings-store-71J302Ls.js → findings-store-Rx9ZJgHV.js} +6 -6
- package/dist/{findings-store-71J302Ls.js.map → findings-store-Rx9ZJgHV.js.map} +1 -1
- package/dist/fuzz.d.ts.map +1 -1
- package/dist/fuzz.js +1 -1
- package/dist/fuzz.js.map +1 -1
- package/dist/{harness-session-lines-Fd5aeSDV.js → harness-session-lines-CSxKR6no.js} +3 -3
- package/dist/{harness-session-lines-Fd5aeSDV.js.map → harness-session-lines-CSxKR6no.js.map} +1 -1
- package/dist/{hf-dataset-kthWy7xl.js → hf-dataset-B0s2ZAhQ.js} +4 -4
- package/dist/{hf-dataset-kthWy7xl.js.map → hf-dataset-B0s2ZAhQ.js.map} +1 -1
- package/dist/hosted/index.d.ts +2 -2
- package/dist/hosted/index.js +1 -1
- package/dist/{index-BsTGJf2M.d.ts → index-BJTUL2Ff.d.ts} +42 -30
- package/dist/index-BJTUL2Ff.d.ts.map +1 -0
- package/dist/{index-Bhc7H9e0.d.ts → index-CX8_WfqS.d.ts} +5 -5
- package/dist/{index-Bhc7H9e0.d.ts.map → index-CX8_WfqS.d.ts.map} +1 -1
- package/dist/{index-DtW7KhyE.d.ts → index-D-nKkzsI.d.ts} +3 -3
- package/dist/{index-DtW7KhyE.d.ts.map → index-D-nKkzsI.d.ts.map} +1 -1
- package/dist/{index-RBV2Y-7X.d.ts → index-D1NRaf5U.d.ts} +7 -7
- package/dist/{index-RBV2Y-7X.d.ts.map → index-D1NRaf5U.d.ts.map} +1 -1
- package/dist/{index-Bcy00QoN.d.ts → index-DcGHcBpR.d.ts} +86 -86
- package/dist/index-DcGHcBpR.d.ts.map +1 -0
- package/dist/{index-CzEGCOWM.d.ts → index-FLyheOVA.d.ts} +9 -9
- package/dist/index-FLyheOVA.d.ts.map +1 -0
- package/dist/{index-lRKqfyg4.d.ts → index-qy6buL6y.d.ts} +2 -2
- package/dist/{index-lRKqfyg4.d.ts.map → index-qy6buL6y.d.ts.map} +1 -1
- package/dist/index.d.ts +31 -31
- package/dist/index.js +41 -41
- package/dist/index.js.map +1 -1
- package/dist/{integrity-BSs9dgKW.js → integrity-BF0tJK21.js} +3 -3
- package/dist/{integrity-BSs9dgKW.js.map → integrity-BF0tJK21.js.map} +1 -1
- package/dist/{journal-DQsbHGjX.js → journal-3y-btqaP.js} +2 -2
- package/dist/{journal-DQsbHGjX.js.map → journal-3y-btqaP.js.map} +1 -1
- package/dist/journal-file-AekB57Er.js.map +1 -1
- package/dist/{json-recovery-b7O9WVTF.js → json-recovery-BRUCeQxo.js} +2 -2
- package/dist/{json-recovery-b7O9WVTF.js.map → json-recovery-BRUCeQxo.js.map} +1 -1
- package/dist/{judge-gate-LbmZU-pA.js → judge-gate-TBv2jeO0.js} +3 -3
- package/dist/{judge-gate-LbmZU-pA.js.map → judge-gate-TBv2jeO0.js.map} +1 -1
- package/dist/{kind-factory-BTUq1Byh.js → kind-factory-DfNsTe-q.js} +22 -4
- package/dist/kind-factory-DfNsTe-q.js.map +1 -0
- package/dist/ledger-core/index.d.ts +2 -2
- package/dist/ledger-core/index.js +3 -3
- package/dist/{ledger-core-7e6sXmhV.js → ledger-core-auznoaD7.js} +3 -3
- package/dist/ledger-core-auznoaD7.js.map +1 -0
- package/dist/{llm-client-CdHo3SH0.js → llm-client-gRPgIJyz.js} +2 -2
- package/dist/{llm-client-CdHo3SH0.js.map → llm-client-gRPgIJyz.js.map} +1 -1
- package/dist/{llm-judge-lUQCBY1e.js → llm-judge-CThv1Rog.js} +197 -66
- package/dist/llm-judge-CThv1Rog.js.map +1 -0
- package/dist/{matrix-BKzNwIWb.d.ts → matrix-CfJ5vhfq.d.ts} +2 -2
- package/dist/{matrix-BKzNwIWb.d.ts.map → matrix-CfJ5vhfq.d.ts.map} +1 -1
- package/dist/meta-eval/index.d.ts +1 -1
- package/dist/meta-eval/index.js +9 -9
- package/dist/{mint-VN-qtJTc.js → mint-B4n1pRRd.js} +12 -6
- package/dist/mint-B4n1pRRd.js.map +1 -0
- package/dist/{model-comparison-BZr_Hu00.js → model-comparison-CgnVh4Ph.js} +3 -3
- package/dist/{model-comparison-BZr_Hu00.js.map → model-comparison-CgnVh4Ph.js.map} +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +2 -2
- package/dist/multishot/index.js +1 -1
- package/dist/multishot/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{outcome-observations-YFFmdGGW.js → outcome-observations-DL3CC8w1.js} +2 -2
- package/dist/{outcome-observations-YFFmdGGW.js.map → outcome-observations-DL3CC8w1.js.map} +1 -1
- package/dist/{paired-arms-DH376s4-.js → paired-arms-DZhH3FGu.js} +3 -3
- package/dist/{paired-arms-DH376s4-.js.map → paired-arms-DZhH3FGu.js.map} +1 -1
- package/dist/{paired-promotion-decision-BoWHWL1i.js → paired-promotion-decision-Dn3-jaq4.js} +2 -2
- package/dist/{paired-promotion-decision-BoWHWL1i.js.map → paired-promotion-decision-Dn3-jaq4.js.map} +1 -1
- package/dist/{paired-promotion-decision-BBSxTo-h.d.ts → paired-promotion-decision-Il-Nv-n4.d.ts} +2 -2
- package/dist/{paired-promotion-decision-BBSxTo-h.d.ts.map → paired-promotion-decision-Il-Nv-n4.d.ts.map} +1 -1
- package/dist/{paired-promotion-power-BXH3gzvs.js → paired-promotion-power-BlzXdgMD.js} +3 -3
- package/dist/{paired-promotion-power-BXH3gzvs.js.map → paired-promotion-power-BlzXdgMD.js.map} +1 -1
- package/dist/{pareto-BNWWbLNl.js → pareto-Bg75Gajo.js} +7 -7
- package/dist/{pareto-BNWWbLNl.js.map → pareto-Bg75Gajo.js.map} +1 -1
- package/dist/pipelines/index.d.ts +3 -3
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js +19 -33
- package/dist/pipelines/index.js.map +1 -1
- package/dist/{prime-protocol-BR0xy0cF.d.ts → prime-protocol-CdNaCQy5.d.ts} +2 -2
- package/dist/{prime-protocol-BR0xy0cF.d.ts.map → prime-protocol-CdNaCQy5.d.ts.map} +1 -1
- package/dist/profile-cell.js +1 -1
- package/dist/{promotion-gate-XiTqW22r.d.ts → promotion-gate-DKAvMFlS.d.ts} +2 -2
- package/dist/{promotion-gate-XiTqW22r.d.ts.map → promotion-gate-DKAvMFlS.d.ts.map} +1 -1
- package/dist/{promotion-policy-CfgRPGx0.js → promotion-policy-CxDIh-9p.js} +4 -4
- package/dist/{promotion-policy-CfgRPGx0.js.map → promotion-policy-CxDIh-9p.js.map} +1 -1
- package/dist/{proposal-findings-DFQvA-k5.js → proposal-findings-DnR7zdUc.js} +2 -2
- package/dist/{proposal-findings-DFQvA-k5.js.map → proposal-findings-DnR7zdUc.js.map} +1 -1
- package/dist/{query-Ck6KhcDo.js → query-Dhjkwqyx.js} +2 -2
- package/dist/{query-Ck6KhcDo.js.map → query-Dhjkwqyx.js.map} +1 -1
- package/dist/{registry-D23oO0_f.d.ts → registry-LqAf_laP.d.ts} +3 -3
- package/dist/{registry-D23oO0_f.d.ts.map → registry-LqAf_laP.d.ts.map} +1 -1
- package/dist/{release-confidence-BdidB0mG.js → release-confidence-BLHOMK5Q.js} +3 -3
- package/dist/{release-confidence-BdidB0mG.js.map → release-confidence-BLHOMK5Q.js.map} +1 -1
- package/dist/reporting.d.ts +4 -4
- package/dist/reporting.js +5 -5
- package/dist/{research-report-BGKsOqkF.d.ts → research-report-BauFJiqu.d.ts} +2 -2
- package/dist/{research-report-BGKsOqkF.d.ts.map → research-report-BauFJiqu.d.ts.map} +1 -1
- package/dist/{researcher-k925Q6Jb.d.ts → researcher-B4e2Z92k.d.ts} +3 -3
- package/dist/{researcher-k925Q6Jb.d.ts.map → researcher-B4e2Z92k.d.ts.map} +1 -1
- package/dist/{reward-hacking-DNiHskry.js → reward-hacking-DKAflk2c.js} +2 -2
- package/dist/{reward-hacking-DNiHskry.js.map → reward-hacking-DKAflk2c.js.map} +1 -1
- package/dist/rl.d.ts +155 -39
- package/dist/rl.d.ts.map +1 -1
- package/dist/rl.js +420 -76
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +4 -4
- package/dist/rollout/index.js +6 -6
- package/dist/{rollout-DDMkK_Lw.js → rollout-B6LlGRSq.js} +9 -9
- package/dist/rollout-B6LlGRSq.js.map +1 -0
- package/dist/{rollout-nodes-DzmHlPAC.js → rollout-nodes-Vas6OSxX.js} +2 -2
- package/dist/{rollout-nodes-DzmHlPAC.js.map → rollout-nodes-Vas6OSxX.js.map} +1 -1
- package/dist/{rubric-predictive-validity-Cln7r56F.js → rubric-predictive-validity--6z0q8s6.js} +2 -2
- package/dist/{rubric-predictive-validity-Cln7r56F.js.map → rubric-predictive-validity--6z0q8s6.js.map} +1 -1
- package/dist/{index-OvU1UXKC.d.ts → run-improvement-loop-B1OKCm2D.d.ts} +1682 -1640
- package/dist/run-improvement-loop-B1OKCm2D.d.ts.map +1 -0
- package/dist/{run-record-c860wUR8.js → run-record-Bqg0NZ_e.js} +19 -4
- package/dist/run-record-Bqg0NZ_e.js.map +1 -0
- package/dist/{run-record-Dx64nPcX.js → run-record-CqUft6Yf.js} +2 -2
- package/dist/{run-record-Dx64nPcX.js.map → run-record-CqUft6Yf.js.map} +1 -1
- package/dist/{runtime-rollouts-CALol_Y4.js → runtime-rollouts-DdUijr_t.js} +7 -7
- package/dist/runtime-rollouts-DdUijr_t.js.map +1 -0
- package/dist/{schema-BTTzvMnn.d.ts → schema-BfSoJjD-.d.ts} +5 -1
- package/dist/schema-BfSoJjD-.d.ts.map +1 -0
- package/dist/{schema-b18jtzZw.js → schema-Bh9CfSZT.js} +3 -1
- package/dist/schema-Bh9CfSZT.js.map +1 -0
- package/dist/schema-CkIvnmLU.d.ts.map +1 -1
- package/dist/schema-D-xu3MU_.js.map +1 -1
- package/dist/search/index.d.ts +3 -3
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +3 -3
- package/dist/{search-kernel-DRHWY35J.d.ts → search-kernel-CuTvZlPS.d.ts} +5 -5
- package/dist/{search-kernel-DRHWY35J.d.ts.map → search-kernel-CuTvZlPS.d.ts.map} +1 -1
- package/dist/{search-ledger-oyqxZhry.js → search-ledger-C7t68cmy.js} +7 -7
- package/dist/{search-ledger-oyqxZhry.js.map → search-ledger-C7t68cmy.js.map} +1 -1
- package/dist/{search-ledger-file-DoHCYYLt.js → search-ledger-file-QuIbgz6b.js} +2 -2
- package/dist/search-ledger-file-QuIbgz6b.js.map +1 -0
- package/dist/{search-ledger-types-qiYRUo_N.d.ts → search-ledger-types-BhZE848w.d.ts} +2 -2
- package/dist/{search-ledger-types-qiYRUo_N.d.ts.map → search-ledger-types-BhZE848w.d.ts.map} +1 -1
- package/dist/{search-shipper-BwqeQ61l.js → search-shipper-CmDW9dU6.js} +3 -3
- package/dist/{search-shipper-BwqeQ61l.js.map → search-shipper-CmDW9dU6.js.map} +1 -1
- package/dist/{search-summary-CNHpHFfw.js → search-summary-B1x1Vmzh.js} +5 -5
- package/dist/{search-summary-CNHpHFfw.js.map → search-summary-B1x1Vmzh.js.map} +1 -1
- package/dist/{sequential-93xxuiiG.js → sequential-BphITa5b.js} +4 -4
- package/dist/{sequential-93xxuiiG.js.map → sequential-BphITa5b.js.map} +1 -1
- package/dist/{sequential-B-zx24n_.d.ts → sequential-DqOJZO2V.d.ts} +2 -2
- package/dist/{sequential-B-zx24n_.d.ts.map → sequential-DqOJZO2V.d.ts.map} +1 -1
- package/dist/{sequential-C6k0Wrb7.js → sequential-ux_XrjBf.js} +3 -3
- package/dist/{sequential-C6k0Wrb7.js.map → sequential-ux_XrjBf.js.map} +1 -1
- package/dist/{served-model-qhLmbutL.js → served-model-BXmeKm7D.js} +2 -2
- package/dist/{served-model-qhLmbutL.js.map → served-model-BXmeKm7D.js.map} +1 -1
- package/dist/{server-DnoEi4Sb.js → server-BxHJyclG.js} +4 -4
- package/dist/{server-DnoEi4Sb.js.map → server-BxHJyclG.js.map} +1 -1
- package/dist/{skillopt-optimization-method-Dch9LiNR.js → skillopt-optimization-method-CHW9mphc.js} +397 -70
- package/dist/skillopt-optimization-method-CHW9mphc.js.map +1 -0
- package/dist/{statistical-heldout-BvcAVtof.js → statistical-heldout-CaS4T-43.js} +3 -3
- package/dist/{statistical-heldout-BvcAVtof.js.map → statistical-heldout-CaS4T-43.js.map} +1 -1
- package/dist/{statistics-CHs0jlsY.js → statistics-DSidA5I2.js} +184 -184
- package/dist/statistics-DSidA5I2.js.map +1 -0
- package/dist/statistics.d.ts +1 -1
- package/dist/statistics.js +1 -1
- package/dist/{store-otlp-DQK9hCtH.js → store-otlp-DCQTz9lS.js} +2 -2
- package/dist/{store-otlp-DQK9hCtH.js.map → store-otlp-DCQTz9lS.js.map} +1 -1
- package/dist/{store-tool-spans-C1lZKvvl.d.ts → store-tool-spans-B0UYrcl7.d.ts} +5 -5
- package/dist/{store-tool-spans-C1lZKvvl.d.ts.map → store-tool-spans-B0UYrcl7.d.ts.map} +1 -1
- package/dist/{store-tool-spans-BRR9hsPP.js → store-tool-spans-D2-S3OdE.js} +4 -4
- package/dist/{store-tool-spans-BRR9hsPP.js.map → store-tool-spans-D2-S3OdE.js.map} +1 -1
- package/dist/storyboard/index.d.ts.map +1 -1
- package/dist/storyboard/index.js.map +1 -1
- package/dist/{summary-report-CXiE1UrA.js → summary-report-CI4J6gxU.js} +4 -4
- package/dist/{summary-report-CXiE1UrA.js.map → summary-report-CI4J6gxU.js.map} +1 -1
- package/dist/supervisor-run/index.d.ts +2 -2
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +3 -3
- package/dist/{systemone-B_3Vd395.d.ts → systemone-nAN8fBy9.d.ts} +8 -8
- package/dist/{systemone-B_3Vd395.d.ts.map → systemone-nAN8fBy9.d.ts.map} +1 -1
- package/dist/systemone-protocol.js +1 -1
- package/dist/{systemone-review-ZAN-5m_2.d.ts → systemone-review-e2ElIpD_.d.ts} +3 -3
- package/dist/{systemone-review-ZAN-5m_2.d.ts.map → systemone-review-e2ElIpD_.d.ts.map} +1 -1
- package/dist/{systemone-review-CqNNZMiD.js → systemone-review-ir3Cbejl.js} +3 -3
- package/dist/{systemone-review-CqNNZMiD.js.map → systemone-review-ir3Cbejl.js.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/systemone.js +2 -2
- package/dist/{tool-groups-BOH1E-E4.d.ts → tool-groups-sRVCeevR.d.ts} +3 -3
- package/dist/tool-groups-sRVCeevR.d.ts.map +1 -0
- package/dist/tool-waste-CIhtU1ad.d.ts +217 -0
- package/dist/tool-waste-CIhtU1ad.d.ts.map +1 -0
- package/dist/{tool-waste-DzLI-JJg.js → tool-waste-u7JJ_BlE.js} +3 -3
- package/dist/{tool-waste-DzLI-JJg.js.map → tool-waste-u7JJ_BlE.js.map} +1 -1
- package/dist/{trace-questions-DBsrgY_H.d.ts → trace-questions-BN-LSfkA.d.ts} +3 -3
- package/dist/{trace-questions-DBsrgY_H.d.ts.map → trace-questions-BN-LSfkA.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/trace-repair/index.d.ts.map +1 -1
- package/dist/trace-repair/index.js +4 -4
- package/dist/trace-repair/index.js.map +1 -1
- package/dist/traces.d.ts +4 -4
- package/dist/traces.js +6 -6
- package/dist/{training-admission-xaDOlQ_U.d.ts → training-admission-DGZCyntI.d.ts} +2 -2
- package/dist/{training-admission-xaDOlQ_U.d.ts.map → training-admission-DGZCyntI.d.ts.map} +1 -1
- package/dist/trajectory-CKVZaQoQ.js +144 -0
- package/dist/trajectory-CKVZaQoQ.js.map +1 -0
- package/dist/trajectory-replay/index.d.ts.map +1 -1
- package/dist/trajectory-replay/index.js +24 -11
- package/dist/trajectory-replay/index.js.map +1 -1
- package/dist/{tree-0r6gPODs.js → tree-DQMlcNFI.js} +18 -6
- package/dist/tree-DQMlcNFI.js.map +1 -0
- package/dist/{types-DmYd2Igl.d.ts → types-BJ27EWAS.d.ts} +8 -8
- package/dist/{types-DmYd2Igl.d.ts.map → types-BJ27EWAS.d.ts.map} +1 -1
- package/dist/{types-ClDpBoLt.d.ts → types-CDWfUYOq.d.ts} +2 -2
- package/dist/{types-ClDpBoLt.d.ts.map → types-CDWfUYOq.d.ts.map} +1 -1
- package/dist/{types-_dfu6Ox2.d.ts → types-DI7YKvDI.d.ts} +3 -3
- package/dist/{types-_dfu6Ox2.d.ts.map → types-DI7YKvDI.d.ts.map} +1 -1
- package/dist/{types-C8AyaiFi.js → types-_tlhWGUq.js} +2 -2
- package/dist/{types-C8AyaiFi.js.map → types-_tlhWGUq.js.map} +1 -1
- package/dist/{types-DGqGbNY4.d.ts → types-pMk2rgP9.d.ts} +20 -6
- package/dist/{types-DGqGbNY4.d.ts.map → types-pMk2rgP9.d.ts.map} +1 -1
- package/dist/{verdict-CKo1iZkI.js → verdict-5PVtsWT_.js} +2 -2
- package/dist/{verdict-CKo1iZkI.js.map → verdict-5PVtsWT_.js.map} +1 -1
- package/dist/{verdict-cache-DfzlHLdf.js → verdict-cache-BPaYxfG8.js} +2 -2
- package/dist/verdict-cache-BPaYxfG8.js.map +1 -0
- package/dist/wire/index.d.ts +3 -3
- package/dist/wire/index.js +1 -1
- package/docs/campaign-proposers.md +14 -1
- package/docs/public-api.md +323 -85
- package/docs/rollout.md +2 -2
- package/docs/search-ledger.md +14 -2
- package/docs/statistical-evidence.md +9 -3
- package/docs/trajectory-replay.md +4 -0
- package/package.json +1 -1
- package/dist/agent-profile-BKgR30kv.d.ts.map +0 -1
- package/dist/benchmark-command-BpmrrgzA.js.map +0 -1
- package/dist/campaign-UzOUBIwA.js.map +0 -1
- package/dist/campaign-evidence-BX8OveG5.js.map +0 -1
- package/dist/canonical-BANK6NOj.js.map +0 -1
- package/dist/default-registry-DSo3tnsW.js.map +0 -1
- package/dist/define-agent-eval-4KGwzIVt.d.ts.map +0 -1
- package/dist/define-agent-eval-C6zFzxp7.js.map +0 -1
- package/dist/dspy-rlm-engine-EC-Pkdf-.js.map +0 -1
- package/dist/emitter-DhQ65mza.js.map +0 -1
- package/dist/external-optimizer-process-DFEPdWJY.js.map +0 -1
- package/dist/external-optimizer-subprocess-BspZ0bZb.js.map +0 -1
- package/dist/index-Bcy00QoN.d.ts.map +0 -1
- package/dist/index-BsTGJf2M.d.ts.map +0 -1
- package/dist/index-CzEGCOWM.d.ts.map +0 -1
- package/dist/index-OvU1UXKC.d.ts.map +0 -1
- package/dist/kind-factory-BTUq1Byh.js.map +0 -1
- package/dist/ledger-core-7e6sXmhV.js.map +0 -1
- package/dist/llm-judge-lUQCBY1e.js.map +0 -1
- package/dist/mint-VN-qtJTc.js.map +0 -1
- package/dist/rollout-DDMkK_Lw.js.map +0 -1
- package/dist/run-record-c860wUR8.js.map +0 -1
- package/dist/runtime-rollouts-CALol_Y4.js.map +0 -1
- package/dist/schema-BTTzvMnn.d.ts.map +0 -1
- package/dist/schema-b18jtzZw.js.map +0 -1
- package/dist/search-ledger-file-DoHCYYLt.js.map +0 -1
- package/dist/skillopt-optimization-method-Dch9LiNR.js.map +0 -1
- package/dist/statistical-heldout-RmdXoz2e.d.ts.map +0 -1
- package/dist/statistics-CHs0jlsY.js.map +0 -1
- package/dist/tool-groups-BOH1E-E4.d.ts.map +0 -1
- package/dist/tool-waste-CUASoTtk.d.ts +0 -139
- package/dist/tool-waste-CUASoTtk.d.ts.map +0 -1
- package/dist/trajectory-O3GDHmev.js +0 -55
- package/dist/trajectory-O3GDHmev.js.map +0 -1
- package/dist/tree-0r6gPODs.js.map +0 -1
- package/dist/verdict-cache-DfzlHLdf.js.map +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { d as CostReceipt, l as CostLedgerSummary, o as CostLedgerHandle, p as CostUsage, r as CostBreakdown, u as CostProvenance } from "./cost-ledger-Czro9wmo.js";
|
|
2
2
|
import { c as ValidationError, t as AgentEvalError } from "./errors-E9I2hldP.js";
|
|
3
3
|
import { a as RunRecord, c as RunSplitTag } from "./run-record-CCJR7q_j.js";
|
|
4
|
-
import { Y as TraceAnalysisStore, i as AnalystFinding, p as AnalystUsageReceipt, u as AnalystRunResult, v as ProposalFinding } from "./types-
|
|
4
|
+
import { Y as TraceAnalysisStore, i as AnalystFinding, p as AnalystUsageReceipt, u as AnalystRunResult, v as ProposalFinding } from "./types-BJ27EWAS.js";
|
|
5
5
|
import { O as ChatClient, dt as ServedModelPolicy, z as LlmCallMetadata } from "./cluster-CSd0LE_M.js";
|
|
6
|
-
import {
|
|
7
|
-
import { E as SearchExecutionIdentity, G as SearchSplit, V as SearchProposer,
|
|
8
|
-
import { r as LedgerHash } from "./canonical-
|
|
9
|
-
import { C as JudgeDimension, H as SurfaceProposer, N as ParetoParent, O as LabeledScenarioSource, R as Scenario, S as JudgeConfig, _ as GateDecision, a as CampaignResult, b as GenerationRecord, c as CampaignTraceWriter, d as DispatchContext, f as DispatchFn, g as GateContribution, i as CampaignCostMeter, j as MutableSurface, k as LabeledScenarioStore, l as CodeSurface, o as CampaignScenarioIdentity, p as Gate, r as CampaignCellResult, u as ComponentSurface, v as GateResult, y as GenerationCandidate } from "./types-
|
|
10
|
-
import { Dt as FinalEvidenceRecord,
|
|
11
|
-
import { Q as SearchRecorder, X as SearchLedgerBinding, Y as RegisterSearchNodeInput, _t as CampaignStorage, et as SearchRunIdentity, ft as SearchHistoryReceipt, i as RunSearchOptions, lt as SearchHistoryCoverage,
|
|
12
|
-
import { a as PairedPromotionDecision } from "./paired-promotion-decision-
|
|
6
|
+
import { E as PairedBootstrapResult } from "./index-DcGHcBpR.js";
|
|
7
|
+
import { E as SearchExecutionIdentity, G as SearchSplit, V as SearchProposer, i as SearchArtifactRef, nt as EvaluationClaim, rt as EvaluationUnitSummary, tt as SearchUnknown } from "./search-ledger-types-BhZE848w.js";
|
|
8
|
+
import { r as LedgerHash } from "./canonical-CGXS21f_.js";
|
|
9
|
+
import { C as JudgeDimension, H as SurfaceProposer, N as ParetoParent, O as LabeledScenarioSource, R as Scenario, S as JudgeConfig, _ as GateDecision, a as CampaignResult, b as GenerationRecord, c as CampaignTraceWriter, d as DispatchContext, f as DispatchFn, g as GateContribution, i as CampaignCostMeter, j as MutableSurface, k as LabeledScenarioStore, l as CodeSurface, o as CampaignScenarioIdentity, p as Gate, r as CampaignCellResult, u as ComponentSurface, v as GateResult, y as GenerationCandidate } from "./types-pMk2rgP9.js";
|
|
10
|
+
import { Dt as FinalEvidenceRecord, pt as PairedArmsComparison, s as EvidenceReceipt, t as CampaignEvidenceContext, wt as FinalEvidenceLedger } from "./campaign-evidence-BVKG5o32.js";
|
|
11
|
+
import { Q as SearchRecorder, X as SearchLedgerBinding, Y as RegisterSearchNodeInput, _t as CampaignStorage, et as SearchRunIdentity, ft as SearchHistoryReceipt, i as RunSearchOptions, lt as SearchHistoryCoverage, st as SearchHistoryAdmissionOptions, v as SearchPolicy } from "./search-kernel-CuTvZlPS.js";
|
|
12
|
+
import { a as PairedPromotionDecision } from "./paired-promotion-decision-Il-Nv-n4.js";
|
|
13
13
|
import { n as ModelTreatment, t as ModelComparison } from "./model-comparison-BHNL8Qrn.js";
|
|
14
|
-
import {
|
|
14
|
+
import { D as ExternalTextCandidate, E as ExternalOptimizerWireCounts, F as AnalystBenchmarkCase, O as ExternalTextEvaluationRequest, T as ExternalOptimizerRunnerCommand, Z as AnalystIssueExpectation, g as ExternalOptimizerEvaluationObservation, p as ExternalOptimizerCallbackLimits, t as AgentProfile$1, v as ExternalOptimizerModelBudget, w as ExternalOptimizerResumeMode, y as ExternalOptimizerModelCall, z as AnalystBenchmarkLabelState } from "./agent-profile-BSgtn-k-.js";
|
|
15
15
|
import { r as DatasetScenario, t as Dataset } from "./dataset-DThC1S6G.js";
|
|
16
16
|
import { t as DetectRewardHackingInput } from "./reward-hacking-CLMvxEY_.js";
|
|
17
|
-
import { f as TraceSpanEvent, t as HostedClient } from "./client-BIFwUg7I.js";
|
|
18
17
|
import { n as CompletionVerdict, o as ProducedState, r as CorrectnessChecker, t as CompletionRequirement } from "./completion-verifier-oAgSwdFe.js";
|
|
18
|
+
import { f as TraceSpanEvent, t as HostedClient } from "./client-DUMIaMob.js";
|
|
19
19
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
20
20
|
import { z } from "zod";
|
|
21
21
|
/** Base error for invalid search-ledger input or operations. */
|
|
@@ -228,9 +228,15 @@ interface RunCampaignOptions<TScenario extends Scenario, TArtifact> {
|
|
|
228
228
|
/** Subject repo for the shared run-dir root (defaults to the CWD basename).
|
|
229
229
|
* Only consulted when `runDir` is a bare name. */
|
|
230
230
|
repo?: string;
|
|
231
|
-
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
231
|
+
/**
|
|
232
|
+
* Span capture. `'on'` (default) gives each execution attempt the trace
|
|
233
|
+
* writer from `buildTraceWriter`, else one that keeps the attempt's spans in
|
|
234
|
+
* `<attempt>/trace/spans.jsonl` in `storage`. `'off'` captures none: every
|
|
235
|
+
* span a dispatch, paid call or judge opens is discarded, and each cell's
|
|
236
|
+
* `traceRef` is unknown with that reason. It cannot be combined with
|
|
237
|
+
* `buildTraceWriter`, and `runImprovementLoop` refuses it when a proposer is
|
|
238
|
+
* wired, because candidates could not be traced back to their spans.
|
|
239
|
+
*/
|
|
234
240
|
tracing?: 'on' | 'off';
|
|
235
241
|
/**
|
|
236
242
|
* Per-cell usage expectation — the early, fine-grained sibling of the
|
|
@@ -245,8 +251,15 @@ interface RunCampaignOptions<TScenario extends Scenario, TArtifact> {
|
|
|
245
251
|
expectUsage?: 'assert' | 'warn' | 'off';
|
|
246
252
|
/** Test seam — override the wall clock for deterministic tests. */
|
|
247
253
|
now?: () => Date;
|
|
248
|
-
/**
|
|
249
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Override the trace writer. The supplied directory and attempt belong to
|
|
256
|
+
* this execution attempt. Implement `traceRef` so each cell names the trace
|
|
257
|
+
* its spans went to; without it the cell's trace is unknown.
|
|
258
|
+
*/
|
|
259
|
+
buildTraceWriter?: (cellId: string, dir: string, attempt: {
|
|
260
|
+
runAttemptId: string;
|
|
261
|
+
number: number;
|
|
262
|
+
}) => CampaignTraceWriter;
|
|
250
263
|
/** Storage backend for run/cell dirs, the resumability cache, artifacts,
|
|
251
264
|
* and trace spans. Default: the Node filesystem (`fsCampaignStorage`).
|
|
252
265
|
* Pass `inMemoryCampaignStorage()` to run in a filesystem-less runtime
|
|
@@ -356,203 +369,6 @@ interface OpenAutoPrResult {
|
|
|
356
369
|
* Open a GitHub PR for a gate-approved surface promotion, attaching the manifest hash, gate verdict, and diff as the PR body.
|
|
357
370
|
*/
|
|
358
371
|
declare function openAutoPr<TArtifact, TScenario extends Scenario>(options: OpenAutoPrOptions<TArtifact, TScenario>): OpenAutoPrResult;
|
|
359
|
-
/** Improve a surface as a search on the kernel; see the module comment. */
|
|
360
|
-
declare function runOptimization<TScenario extends Scenario, TArtifact>(opts: RunOptimizationOptions<TScenario, TArtifact>): Promise<RunOptimizationResult<TArtifact, TScenario>>;
|
|
361
|
-
/** Optimization inputs, immutable proposal snapshots, and imported baseline validation. */
|
|
362
|
-
interface PremeasuredOptimizationBaseline<TArtifact, TScenario extends Scenario> {
|
|
363
|
-
/** Hash of the exact surface that produced `campaign`. */
|
|
364
|
-
surfaceHash: string;
|
|
365
|
-
/** Complete prior measurement reused by identity, including artifactsByPath. */
|
|
366
|
-
campaign: CampaignResult<TArtifact, TScenario>;
|
|
367
|
-
}
|
|
368
|
-
interface RunOptimizationOptions<TScenario extends Scenario, TArtifact> extends Omit<RunCampaignOptions<TScenario, TArtifact>, 'dispatch'> {
|
|
369
|
-
/** Initial mutable surface (typically system prompt or addendum). */
|
|
370
|
-
baselineSurface: MutableSurface;
|
|
371
|
-
/**
|
|
372
|
-
* Complete prior measurement of `baselineSurface`. When present,
|
|
373
|
-
* `runOptimization` validates its surface, scenario split, seed, reps, and
|
|
374
|
-
* normal campaign coverage, then records its cells as the root's instead of
|
|
375
|
-
* dispatching them. Prior spend stays in the imported campaign aggregates and
|
|
376
|
-
* is not added again to this run's CostLedger.
|
|
377
|
-
*/
|
|
378
|
-
premeasuredBaseline?: PremeasuredOptimizationBaseline<TArtifact, TScenario>;
|
|
379
|
-
/** Dispatcher that takes a surface and a scenario to an artifact. */
|
|
380
|
-
dispatchWithSurface: (surface: MutableSurface, scenario: TScenario, ctx: Parameters<RunCampaignOptions<TScenario, TArtifact>['dispatch']>[1]) => Promise<TArtifact>;
|
|
381
|
-
/** The candidate-generation strategy. */
|
|
382
|
-
proposer: SurfaceProposer<ProposalFinding>;
|
|
383
|
-
/** Candidates asked of each proposal. */
|
|
384
|
-
populationSize: number;
|
|
385
|
-
/** Proposals the search may make. */
|
|
386
|
-
maxGenerations: number;
|
|
387
|
-
/** Scales the run's cell lanes: at most `candidateConcurrency *
|
|
388
|
-
* maxConcurrency` cells run at once. Default 1. */
|
|
389
|
-
candidateConcurrency?: number;
|
|
390
|
-
/** DEPTH knob forwarded to the proposer's `propose()`: max iterations the
|
|
391
|
-
* agentic generator may take per candidate. */
|
|
392
|
-
maxImprovementShots?: number;
|
|
393
|
-
/** Search or observed-production findings forwarded to candidate generation. */
|
|
394
|
-
findings?: ReadonlyArray<ProposalFinding>;
|
|
395
|
-
/** Findings producer. Before each proposal it runs on the previous
|
|
396
|
-
* generation's measured candidates (the baseline, as `generation: -1`,
|
|
397
|
-
* before the first), and what it returns REPLACES `ctx.findings` for that
|
|
398
|
-
* proposal. The substrate does not import an analyst: the consumer plugs its
|
|
399
|
-
* trace-analyst registry here, reading the per-candidate `runDir` traces.
|
|
400
|
-
* When absent, findings stay the static `opts.findings`. Its spend is
|
|
401
|
-
* booked to the proposal's operation. */
|
|
402
|
-
analyzeGeneration?: (input: {
|
|
403
|
-
generation: number;
|
|
404
|
-
runDir: string;
|
|
405
|
-
candidates: Array<{
|
|
406
|
-
surfaceHash: string;
|
|
407
|
-
campaign: CampaignResult<TArtifact, TScenario>;
|
|
408
|
-
composite: number | null;
|
|
409
|
-
}>;
|
|
410
|
-
history: GenerationRecord[];
|
|
411
|
-
/** Shared run spend account and receipt attribution phase. */
|
|
412
|
-
costLedger?: CostLedgerHandle;
|
|
413
|
-
costPhase?: string;
|
|
414
|
-
}) => Promise<ReadonlyArray<ProposalFinding>>;
|
|
415
|
-
/** Which node each proposal extends, and which node the run keeps. Default
|
|
416
|
-
* `incumbent()`: the hill climb. `crowdedFrontierParent({ seed })` draws
|
|
417
|
-
* the parent from the Pareto frontier instead; `aide()` drafts, debugs and
|
|
418
|
-
* improves with Thompson-sampled parents, and `beam({ width })` expands the
|
|
419
|
-
* top nodes in turn. Every policy ranks on the scenarios, and the run keeps
|
|
420
|
-
* the `uniform` allocator, because the proposer reads every candidate's
|
|
421
|
-
* score on every scenario. */
|
|
422
|
-
policy?: SearchPolicy;
|
|
423
|
-
/** Where the search ledger goes and the identities it records. Default: a
|
|
424
|
-
* ledger at `<runDir>/search/ledger.jsonl`, held in `storage` unless that is
|
|
425
|
-
* the filesystem, whose identities are the dispatch ref's and proposer's
|
|
426
|
-
* digests. */
|
|
427
|
-
searchLedger?: SearchLedgerBinding;
|
|
428
|
-
}
|
|
429
|
-
interface RunOptimizationResult<TArtifact, TScenario extends Scenario> {
|
|
430
|
-
/** One entry per proposal, with the candidates it registered. */
|
|
431
|
-
generations: Array<{
|
|
432
|
-
record: GenerationRecord;
|
|
433
|
-
surfaces: Array<{
|
|
434
|
-
surfaceHash: string;
|
|
435
|
-
surface: MutableSurface;
|
|
436
|
-
campaign: CampaignResult<TArtifact, TScenario>;
|
|
437
|
-
}>;
|
|
438
|
-
}>;
|
|
439
|
-
/** Frozen snapshot of the exact starting surface measured by `baselineCampaign`. */
|
|
440
|
-
baselineSurface: MutableSurface;
|
|
441
|
-
winnerSurface: MutableSurface;
|
|
442
|
-
winnerSurfaceHash: string;
|
|
443
|
-
/** Proposer label for the kept surface; absent when the winner is the baseline. */
|
|
444
|
-
winnerLabel?: string;
|
|
445
|
-
/** Proposer rationale for the kept surface, as stored: redacted with the
|
|
446
|
-
* share profile. Absent when the winner is the baseline. */
|
|
447
|
-
winnerRationale?: string;
|
|
448
|
-
baselineCampaign: CampaignResult<TArtifact, TScenario>;
|
|
449
|
-
/** Run-wide spend, including agents, proposers, analysts, and judges. */
|
|
450
|
-
cost: CostLedgerSummary;
|
|
451
|
-
/** Bounded proof envelope over the search ledger. */
|
|
452
|
-
searchHistory: SearchHistoryReceipt;
|
|
453
|
-
/** The non-dominated set of measured surfaces by per-scenario composite. */
|
|
454
|
-
paretoFrontier: ParetoParent[];
|
|
455
|
-
}
|
|
456
|
-
type RunImprovementLoopOptions<TScenario extends Scenario, TArtifact> = RunOptimizationOptions<TScenario, TArtifact> & {
|
|
457
|
-
/** Holdout scenarios kept OUT of the training optimization pool — used
|
|
458
|
-
* ONLY to score baseline vs winner for the gate. */
|
|
459
|
-
holdoutScenarios: TScenario[];
|
|
460
|
-
claim?: EvaluationClaim;
|
|
461
|
-
finalEvidence?: FinalEvidencePolicy;
|
|
462
|
-
/** Snapshot identity for agents without model receipts. Receipts take precedence. */
|
|
463
|
-
model?: string;
|
|
464
|
-
/** Declare a model change as part of the treatment before search starts. */
|
|
465
|
-
modelTreatment?: ModelTreatment;
|
|
466
|
-
/** Require one reported model id per arm (two spellings of one snapshot count as two), even
|
|
467
|
-
* when neither arm reports a model call. Enabled by selfImprove. */
|
|
468
|
-
requireReportedModel?: boolean;
|
|
469
|
-
/** Holdout policy. Default `'measured'`: baseline + winner are re-scored on
|
|
470
|
-
* `holdoutScenarios` and the gate decides on that held-out comparison.
|
|
471
|
-
* `'deferred'`: the improvement-set (search) campaigns run exactly as usual,
|
|
472
|
-
* but ZERO holdout cells are dispatched, the gate is forced to `'hold'`, and
|
|
473
|
-
* the result + provenance record carry `holdout: 'deferred'` with NO
|
|
474
|
-
* held-out lift — for callers that measure the held-out comparison in a
|
|
475
|
-
* separate later run instead of faking a static holdout scenario and
|
|
476
|
-
* recording a meaningless lift. */
|
|
477
|
-
holdout?: 'measured' | 'deferred';
|
|
478
|
-
/** Promotion gate. Substrate strongly recommends `defaultProductionGate`
|
|
479
|
-
* for production wiring (composes red-team / reward-hacking / canary /
|
|
480
|
-
* heldout). */
|
|
481
|
-
gate: Gate<TArtifact, TScenario>;
|
|
482
|
-
/** What to do when the gate ships:
|
|
483
|
-
* - `'pr'`: open a PR via `openAutoPr`
|
|
484
|
-
* - `'none'`: just report — caller decides what to do with the winner
|
|
485
|
-
* Live-runtime self-mutation is intentionally unsupported. */
|
|
486
|
-
autoOnPromote: 'pr' | 'none';
|
|
487
|
-
/** GH owner / repo for the auto-PR. Required when autoOnPromote === 'pr'. */
|
|
488
|
-
ghOwner?: string;
|
|
489
|
-
ghRepo?: string;
|
|
490
|
-
/** Placebo control. When supplied AND the winner differs from baseline, the
|
|
491
|
-
* loop scores a THIRD holdout arm: the winner surface with its content
|
|
492
|
-
* footprint-matched-blanked by this function (typically via `neutralizeText`).
|
|
493
|
-
* Its scores are exposed to the gate as `ctx.neutralizedJudgeScores`, letting
|
|
494
|
-
* a `neutralizationGate` reject a win whose lift survives blanking the content
|
|
495
|
-
* (decorative — driven by footprint, not content). Costs one extra holdout
|
|
496
|
-
* campaign; omit to skip. Return a byte/layout-matched blank of the winner. */
|
|
497
|
-
neutralize?: (winnerSurface: MutableSurface, baselineSurface: MutableSurface) => MutableSurface;
|
|
498
|
-
};
|
|
499
|
-
interface RunImprovementLoopResult<TArtifact, TScenario extends Scenario> extends RunOptimizationResult<TArtifact, TScenario> {
|
|
500
|
-
baselineOnHoldout: CampaignResult<TArtifact, TScenario>;
|
|
501
|
-
winnerOnHoldout: CampaignResult<TArtifact, TScenario>;
|
|
502
|
-
neutralizedOnHoldout?: CampaignResult<TArtifact, TScenario>;
|
|
503
|
-
neutralizedSurface?: MutableSurface;
|
|
504
|
-
gateResult: Awaited<ReturnType<Gate<TArtifact, TScenario>['decide']>>;
|
|
505
|
-
claim?: EvaluationClaim;
|
|
506
|
-
finalEvidence?: FinalEvidenceUse;
|
|
507
|
-
modelComparison: ModelComparison;
|
|
508
|
-
/** Present iff the loop ran with `holdout: 'deferred'`. When set,
|
|
509
|
-
* `baselineOnHoldout`/`winnerOnHoldout` are the shared EMPTY campaign (zero
|
|
510
|
-
* cells dispatched) and the gate verdict is the forced `'hold'`. */
|
|
511
|
-
holdout?: 'deferred';
|
|
512
|
-
/** Unified baseline→winner surface diff. Computed UNCONDITIONALLY (not only
|
|
513
|
-
* when `autoOnPromote === 'pr'`) so the diff that the gate decided on is
|
|
514
|
-
* always present on the result + in the emitted provenance record. Empty
|
|
515
|
-
* string when winner == baseline (no change to diff). */
|
|
516
|
-
promotedDiff: string;
|
|
517
|
-
prResult?: ReturnType<typeof openAutoPr>;
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* Gated-promotion shell over `runOptimization`: scores the winner against the baseline on a holdout set, runs the release gate, and optionally opens a PR.
|
|
521
|
-
*/
|
|
522
|
-
declare function runImprovementLoop<TScenario extends Scenario, TArtifact>(opts: RunImprovementLoopOptions<TScenario, TArtifact>): Promise<RunImprovementLoopResult<TArtifact, TScenario>>;
|
|
523
|
-
interface TransientFailureOptions {
|
|
524
|
-
/**
|
|
525
|
-
* Treat full-duration timeouts ("timeout after 180000ms") as transient.
|
|
526
|
-
* Enable on saturated shared infrastructure where queue starvation eats
|
|
527
|
-
* the clock; leave off when the agent had the resources and simply failed.
|
|
528
|
-
* Default false.
|
|
529
|
-
*/
|
|
530
|
-
readonly retryFullDurationTimeouts?: boolean;
|
|
531
|
-
/** Additional caller-specific transient patterns. */
|
|
532
|
-
readonly extraPatterns?: readonly RegExp[];
|
|
533
|
-
/**
|
|
534
|
-
* The instant a dated quota refusal is measured against. Defaults to `Date.now()`; inject it
|
|
535
|
-
* to replay a past classification, which is what a retry audit needs.
|
|
536
|
-
*/
|
|
537
|
-
readonly now?: number;
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* True when the error text describes an infrastructure hiccup that should be
|
|
541
|
-
* retried rather than scored. Empty/undefined input is not transient.
|
|
542
|
-
*/
|
|
543
|
-
declare function isTransientTransportFailure(message: string | null | undefined, opts?: TransientFailureOptions): boolean;
|
|
544
|
-
/**
|
|
545
|
-
* Ready-made `cellRetry.retryable` predicate: true for a dispatch-stage
|
|
546
|
-
* failure whose error message `isTransientTransportFailure` classifies as an
|
|
547
|
-
* infrastructure hiccup. A judge-stage failure is never retried here — the
|
|
548
|
-
* dispatch already produced an artifact, so re-dispatching would score a
|
|
549
|
-
* different sample. A per-cell dispatch deadline ("dispatch exceeded <N>ms")
|
|
550
|
-
* is not transient by default; opt in via `extraPatterns` or
|
|
551
|
-
* `retryFullDurationTimeouts` when queue starvation eats the clock. A provider refusal that
|
|
552
|
-
* states its own release time is never retried while that time is in the future
|
|
553
|
-
* (`quotaExhaustedUntil`).
|
|
554
|
-
*/
|
|
555
|
-
declare function transientDispatchFailure(opts?: TransientFailureOptions): (failure: CampaignCellFailureReceipt['failure']) => boolean;
|
|
556
372
|
/** A rubric dimension as a bare key or the full `{ key, description }` shape. A
|
|
557
373
|
* bare string uses the key as its own description. */
|
|
558
374
|
type LlmJudgeDimension = string | JudgeDimension;
|
|
@@ -650,894 +466,432 @@ interface ReferenceEquivalenceJudgeResult extends LlmCallMetadata {
|
|
|
650
466
|
score: number;
|
|
651
467
|
rationale: string;
|
|
652
468
|
}
|
|
653
|
-
interface
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
refusals: number;
|
|
660
|
-
}
|
|
661
|
-
interface ExternalOptimizerExecutionSummary {
|
|
662
|
-
scope: 'runtime-model-calls';
|
|
663
|
-
path: string;
|
|
664
|
-
sha256: `sha256:${string}`;
|
|
665
|
-
calls: number;
|
|
666
|
-
succeeded: number;
|
|
667
|
-
failed: number;
|
|
469
|
+
interface TraceAnalystScenario extends Scenario {
|
|
470
|
+
kind: 'trace-analyst';
|
|
471
|
+
traceStore: TraceAnalysisStore;
|
|
472
|
+
labelState: AnalystBenchmarkLabelState;
|
|
473
|
+
expectedIssues: readonly AnalystIssueExpectation[];
|
|
474
|
+
labeledEvidence?: AnalystBenchmarkCase['labeledEvidence'];
|
|
668
475
|
}
|
|
669
|
-
interface
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
readonly candidateHash: string;
|
|
674
|
-
readonly candidateDigest: `sha256:${string}`;
|
|
675
|
-
readonly proposalSequence: number;
|
|
676
|
-
/** Exact observation artifact that proves this candidate was submitted. */
|
|
677
|
-
readonly provenance: {
|
|
678
|
-
readonly path: string;
|
|
679
|
-
readonly sha256: `sha256:${string}`;
|
|
680
|
-
};
|
|
476
|
+
interface TraceAnalystArtifact {
|
|
477
|
+
findings: readonly AnalystFinding[];
|
|
478
|
+
usage?: AnalystUsageReceipt;
|
|
479
|
+
run?: AnalystRunResult;
|
|
681
480
|
}
|
|
682
|
-
interface
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
481
|
+
interface BuildTraceAnalystSurfaceDispatchOptions {
|
|
482
|
+
analyze(input: {
|
|
483
|
+
instructions: string;
|
|
484
|
+
traceStore: TraceAnalysisStore;
|
|
485
|
+
runId: string;
|
|
486
|
+
signal: AbortSignal;
|
|
487
|
+
}): Promise<TraceAnalystArtifact>;
|
|
687
488
|
}
|
|
688
|
-
/**
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
* The
|
|
692
|
-
* identities, and summary counts before it returns any candidate.
|
|
693
|
-
* This proves that the bytes match the supplied summary. The caller remains
|
|
694
|
-
* responsible for obtaining that summary from trusted provenance.
|
|
489
|
+
/** Read the source rates for this execution, never a copied model price table.
|
|
490
|
+
* inputTokens includes cachedTokens. Seat credits are standard model credits;
|
|
491
|
+
* discounts and MCP charges require provider observations, not token guesses.
|
|
492
|
+
* The existing USD receipt remains the Router charge. Sandbox is additional.
|
|
695
493
|
*/
|
|
696
|
-
declare function
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
494
|
+
declare function measureCampaignCost(input: {
|
|
495
|
+
routerUsd?: number;
|
|
496
|
+
sandbox?: {
|
|
497
|
+
seconds: number;
|
|
498
|
+
cpu: number;
|
|
499
|
+
memoryGB: number;
|
|
500
|
+
diskGB: number;
|
|
501
|
+
pool?: string;
|
|
502
|
+
};
|
|
503
|
+
seat?: {
|
|
504
|
+
model: string;
|
|
505
|
+
usage: CostUsage & {
|
|
506
|
+
usageUnknown?: boolean;
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
signal?: AbortSignal;
|
|
510
|
+
}): Promise<CostBreakdown>;
|
|
511
|
+
/** Whether one candidate attempt produced a usable executable outcome. */
|
|
512
|
+
type CrossSurfaceAttemptCompleteness = 'complete' | 'missing' | 'invalid';
|
|
513
|
+
/** One independently proposed change on one caller-defined surface. */
|
|
514
|
+
interface CrossSurfaceComponent {
|
|
515
|
+
componentId: string;
|
|
516
|
+
surfaceId: string;
|
|
517
|
+
/** Explicitly controls whether this component may anchor the best-single arm. */
|
|
518
|
+
bestSingleEligible: boolean;
|
|
716
519
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
/** Exact GEPA parent indices. The seed candidate has one null parent. */
|
|
724
|
-
readonly parentIndices: readonly (number | null)[];
|
|
725
|
-
/** Null means GEPA had no selection score for this candidate. */
|
|
726
|
-
readonly aggregateScore: number | null;
|
|
727
|
-
readonly selectionScores: readonly GepaCandidateSelectionScore[];
|
|
728
|
-
readonly discoveryEvaluationCount: number;
|
|
520
|
+
/** Immutable identity for a single candidate or a materialized composition. */
|
|
521
|
+
interface CrossSurfaceCandidate {
|
|
522
|
+
candidateId: string;
|
|
523
|
+
componentIds: string[];
|
|
524
|
+
contentHash: string;
|
|
525
|
+
artifactBytes: number;
|
|
729
526
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
527
|
+
/** Per-component trace evidence captured during one task attempt. */
|
|
528
|
+
interface CrossSurfaceComponentEvidence {
|
|
529
|
+
componentId: string;
|
|
530
|
+
/** null means the trace could not establish whether the component fired. */
|
|
531
|
+
fired: boolean | null;
|
|
532
|
+
/** null means the trace could not establish whether the component changed behavior. */
|
|
533
|
+
effectObserved: boolean | null;
|
|
735
534
|
}
|
|
736
535
|
/**
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
* candidate surfaces, parent graph, selection scores, and configured bounds.
|
|
741
|
-
* This proves that the bytes match the supplied summary. The caller remains
|
|
742
|
-
* responsible for obtaining that summary from trusted method provenance.
|
|
536
|
+
* Canonical per-task input row. Consumers may extend this interface with
|
|
537
|
+
* receipt, trace, retry, or failure details; the report preserves the original
|
|
538
|
+
* row object rather than projecting those details away.
|
|
743
539
|
*/
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
inputTokens: number;
|
|
762
|
-
/** Input tokens served from a provider cache. */
|
|
763
|
-
cachedInputTokens?: number;
|
|
764
|
-
/** Input tokens used to create or write a provider cache entry. */
|
|
765
|
-
cacheWriteInputTokens?: number;
|
|
766
|
-
outputTokens: number;
|
|
767
|
-
/** Reasoning tokens included in `outputTokens`. */
|
|
768
|
-
reasoningTokens?: number;
|
|
769
|
-
totalTokens: number;
|
|
770
|
-
calls: number;
|
|
540
|
+
interface CrossSurfaceTaskRow {
|
|
541
|
+
taskId: string;
|
|
542
|
+
candidateId: string;
|
|
543
|
+
/** Repeated here so every persisted row remains self-describing. */
|
|
544
|
+
componentIds: string[];
|
|
545
|
+
completeness: CrossSurfaceAttemptCompleteness;
|
|
546
|
+
pass: boolean | null;
|
|
547
|
+
score: number | null;
|
|
548
|
+
/**
|
|
549
|
+
* Per-attempt deployment measurements. Every declared metric must have a
|
|
550
|
+
* known, non-negative value. Proposal, analysis, and selection spend belongs
|
|
551
|
+
* in the search ledger rather than being spread across task cells.
|
|
552
|
+
*/
|
|
553
|
+
cost: Record<string, number | null>;
|
|
554
|
+
componentEvidence: CrossSurfaceComponentEvidence[];
|
|
555
|
+
/** Required for missing or invalid attempts; forbidden for complete attempts. */
|
|
556
|
+
rejectReason: string | null;
|
|
771
557
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
/** Whether package identity was inspected or supplied by caller code. */
|
|
777
|
-
evidence: 'observed' | 'declared';
|
|
778
|
-
package: string;
|
|
779
|
-
version: string;
|
|
780
|
-
sourceUrl?: string;
|
|
781
|
-
revision?: string;
|
|
782
|
-
/** SHA-256 of all installed module files observed before the run. */
|
|
783
|
-
sourceSha256?: string;
|
|
558
|
+
interface CrossSurfaceBootstrapPolicy {
|
|
559
|
+
seed: number;
|
|
560
|
+
resamples: number;
|
|
561
|
+
confidence: number;
|
|
784
562
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
563
|
+
/** Predeclared candidate eligibility and composition policy. */
|
|
564
|
+
interface CrossSurfaceSelectionPolicy {
|
|
565
|
+
minimumFiringTasks: number;
|
|
566
|
+
minimumEffectTasks: number;
|
|
567
|
+
requireObservedFiring: boolean;
|
|
568
|
+
requireObservedEffect: boolean;
|
|
569
|
+
/** Only named metrics are constrained; all declared metrics are still reported. */
|
|
570
|
+
maximumMedianCostRatioToBaseline: Record<string, number>;
|
|
571
|
+
/** A smaller terminal bundle is reported but cannot become the selected arm. */
|
|
572
|
+
minimumBundleComponents: number;
|
|
788
573
|
}
|
|
789
|
-
interface
|
|
790
|
-
|
|
791
|
-
|
|
574
|
+
interface AnalyzeCrossSurfaceInteractionsInput<TRow extends CrossSurfaceTaskRow = CrossSurfaceTaskRow> {
|
|
575
|
+
components: readonly CrossSurfaceComponent[];
|
|
576
|
+
candidates: readonly CrossSurfaceCandidate[];
|
|
577
|
+
rows: readonly TRow[];
|
|
578
|
+
baselineCandidateId: string;
|
|
579
|
+
/** Exact shared task axis and its canonical output order. */
|
|
580
|
+
taskOrder: readonly string[];
|
|
581
|
+
/** Canonical materialization order for component sets and the naive stack. */
|
|
582
|
+
componentOrder: readonly string[];
|
|
583
|
+
/** Final deterministic tie-break; lower index wins. */
|
|
584
|
+
candidateOrder: readonly string[];
|
|
585
|
+
/** Declares every cost key and the order used for cost tie-breaks. */
|
|
586
|
+
costMetricOrder: readonly string[];
|
|
587
|
+
bootstrap: CrossSurfaceBootstrapPolicy;
|
|
588
|
+
selection: CrossSurfaceSelectionPolicy;
|
|
792
589
|
}
|
|
793
|
-
interface
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
/** Python implementation used by the bridge process. */
|
|
801
|
-
python?: OptimizationPythonRuntime;
|
|
802
|
-
/** Exact model identifier configured for optimizer-owned model calls. */
|
|
803
|
-
optimizerModel?: string;
|
|
804
|
-
/** Stable public identity of the execution-owner callback. */
|
|
805
|
-
optimizerCallRef?: string;
|
|
806
|
-
runId: string;
|
|
807
|
-
/** Content identity shared by compatible resumptions. */
|
|
808
|
-
compatibleRunId?: string;
|
|
809
|
-
resumed: boolean;
|
|
810
|
-
/** Whether the run seed reached every external engine configuration. */
|
|
811
|
-
seedApplied?: boolean;
|
|
812
|
-
/** Evaluations the local callback metered — the trusted count. */
|
|
813
|
-
evaluationCount: number;
|
|
814
|
-
/**
|
|
815
|
-
* Evaluation total the external optimizer reported from its own counters.
|
|
816
|
-
* A difference from `evaluationCount` means upstream skipped, cached, or
|
|
817
|
-
* double-counted work; inspect before trusting upstream-derived budgets.
|
|
818
|
-
*/
|
|
819
|
-
upstreamReportedEvaluations?: number;
|
|
820
|
-
artifactDir: string;
|
|
821
|
-
tokenUsage?: OptimizationTokenUsage;
|
|
822
|
-
/** Candidates submitted to the callback, per-case scores, and refusals. */
|
|
823
|
-
observations?: ExternalOptimizerObservationSummary;
|
|
824
|
-
/** Exact accepted GEPA candidates, parent indices, and selection scores. */
|
|
825
|
-
gepaCandidatePopulation?: GepaCandidatePopulationSummary;
|
|
826
|
-
/** Opaque Runtime execution evidence for every invoked optimizer-model call. */
|
|
827
|
-
modelExecutions?: ExternalOptimizerExecutionSummary;
|
|
828
|
-
/** Anthropic-endpoint proxy traffic from agent CLI engines, when enabled. */
|
|
829
|
-
anthropicEndpoint?: ExternalOptimizerWireCounts;
|
|
590
|
+
interface CrossSurfaceDistribution {
|
|
591
|
+
n: number;
|
|
592
|
+
min: number;
|
|
593
|
+
median: number;
|
|
594
|
+
mean: number;
|
|
595
|
+
max: number;
|
|
596
|
+
total: number;
|
|
830
597
|
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
readonly trainScenarios: readonly TScenario[];
|
|
837
|
-
/** Data used for candidate acceptance, early stopping, and model selection. */
|
|
838
|
-
readonly selectionScenarios: readonly TScenario[];
|
|
839
|
-
/** Runs one scenario with a candidate surface. */
|
|
840
|
-
readonly dispatchWithSurface: (surface: MutableSurface, scenario: TScenario, ctx: DispatchContext) => Promise<TArtifact>;
|
|
841
|
-
/** Scores artifacts produced by `dispatchWithSurface`. */
|
|
842
|
-
readonly judges: readonly JudgeConfig<TArtifact, TScenario>[];
|
|
843
|
-
/** Method-specific artifacts are written below this directory. */
|
|
844
|
-
readonly runDir: string;
|
|
845
|
-
readonly seed: number;
|
|
846
|
-
/** Shared defaults for every method. A method may override them explicitly. */
|
|
847
|
-
readonly runOptions: Readonly<OptimizationMethodRunOptions<TScenario, TArtifact>>;
|
|
848
|
-
/** Durable spend account shared by every method and final scoring. */
|
|
849
|
-
readonly costLedger: CostLedgerHandle;
|
|
850
|
-
/** Invokes each method at the shared execution boundary, including composed children. */
|
|
851
|
-
invokeMethod?(method: OptimizationMethod<TScenario, TArtifact>, input: OptimizationMethodInput<TScenario, TArtifact>): Promise<OptimizationMethodResult>;
|
|
852
|
-
/** Maps this method's local surface into the complete outer candidate. */
|
|
853
|
-
readonly surfaceToRoot?: (surface: MutableSurface) => MutableSurface;
|
|
598
|
+
interface CrossSurfaceEvidenceBreakdown {
|
|
599
|
+
componentId: string;
|
|
600
|
+
observedTaskIds: string[];
|
|
601
|
+
notObservedTaskIds: string[];
|
|
602
|
+
unobservedTaskIds: string[];
|
|
854
603
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
baselineSurfaceHash: string;
|
|
862
|
-
result: OptimizationMethodResult;
|
|
863
|
-
}>;
|
|
604
|
+
interface CrossSurfaceCandidateEvidence {
|
|
605
|
+
byComponent: CrossSurfaceEvidenceBreakdown[];
|
|
606
|
+
allObservedTaskIds: string[];
|
|
607
|
+
someObservedTaskIds: string[];
|
|
608
|
+
noneObservedTaskIds: string[];
|
|
609
|
+
unobservedTaskIds: string[];
|
|
864
610
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
/** Optimization spend. Excludes final test scoring. */
|
|
870
|
-
cost: ComparisonCost;
|
|
871
|
-
/** Optimization duration. Excludes final test scoring. */
|
|
872
|
-
durationMs?: number;
|
|
873
|
-
/** Exact external implementation and run identity, when the method uses one. */
|
|
874
|
-
provenance?: OptimizationMethodProvenance;
|
|
875
|
-
/** Bounded proof envelope over the canonical SearchLedger for this optimization. */
|
|
876
|
-
searchHistory?: SearchHistoryReceipt;
|
|
611
|
+
type CrossSurfaceIneligibilityReason = 'missing_attempt' | 'invalid_attempt' | 'baseline_outcome_missing' | 'benefit_not_greater_than_regression' | 'firing_below_minimum' | 'firing_unobserved' | 'effect_below_minimum' | 'effect_unobserved' | 'cost_limit_exceeded';
|
|
612
|
+
interface CrossSurfaceEligibility {
|
|
613
|
+
eligible: boolean;
|
|
614
|
+
reasons: CrossSurfaceIneligibilityReason[];
|
|
877
615
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
616
|
+
interface CrossSurfaceCandidateOutcome {
|
|
617
|
+
resolvedTaskIds: string[];
|
|
618
|
+
failedTaskIds: string[];
|
|
619
|
+
missingTaskIds: string[];
|
|
620
|
+
invalidTaskIds: string[];
|
|
621
|
+
benefitTaskIds: string[];
|
|
622
|
+
regressionTaskIds: string[];
|
|
623
|
+
comparisonMissingTaskIds: string[];
|
|
624
|
+
netBenefit: number;
|
|
883
625
|
}
|
|
884
|
-
interface
|
|
885
|
-
|
|
886
|
-
|
|
626
|
+
interface CrossSurfaceCandidateSummary {
|
|
627
|
+
candidate: CrossSurfaceCandidate;
|
|
628
|
+
outcome: CrossSurfaceCandidateOutcome;
|
|
629
|
+
score: CrossSurfaceDistribution | null;
|
|
630
|
+
costs: Record<string, CrossSurfaceDistribution>;
|
|
631
|
+
firing: CrossSurfaceCandidateEvidence;
|
|
632
|
+
effect: CrossSurfaceCandidateEvidence;
|
|
633
|
+
/** Reuses the package's paired McNemar/risk-difference/bootstrap statistics. */
|
|
634
|
+
comparisonToBaseline: PairedArmsComparison | null;
|
|
635
|
+
/** null only for the fixed baseline. */
|
|
636
|
+
eligibility: CrossSurfaceEligibility | null;
|
|
887
637
|
}
|
|
888
|
-
interface
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
scores?: Record<string, number>;
|
|
895
|
-
notes?: string;
|
|
896
|
-
artifact?: unknown;
|
|
897
|
-
/** The optimizer score is a finite protocol value; Eval remains the
|
|
898
|
-
* authority for whether the underlying cell actually produced a score. */
|
|
899
|
-
status?: 'scored' | 'failed';
|
|
900
|
-
error?: {
|
|
901
|
-
stage: 'dispatch' | 'judge' | 'unknown';
|
|
902
|
-
message: string;
|
|
903
|
-
};
|
|
904
|
-
};
|
|
638
|
+
interface CrossSurfaceRelativeCost {
|
|
639
|
+
treatmentMedian: number;
|
|
640
|
+
comparatorMedian: number;
|
|
641
|
+
medianDelta: number;
|
|
642
|
+
/** null when the comparator median is zero but the treatment median is not. */
|
|
643
|
+
medianRatio: number | null;
|
|
905
644
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
readonly trainSet: readonly ExternalOptimizationExample[];
|
|
915
|
-
readonly selectionSet: readonly ExternalOptimizationExample[];
|
|
916
|
-
readonly maxEvaluations: number;
|
|
917
|
-
readonly seed: number;
|
|
918
|
-
/** Stable directory for optimizer checkpoints from compatible attempts. */
|
|
919
|
-
readonly stateDir: string;
|
|
920
|
-
readonly restoreRequested: boolean;
|
|
921
|
-
readonly artifactDir: string;
|
|
922
|
-
readonly signal: AbortSignal;
|
|
923
|
-
/** Record every optimizer-owned paid call through this attributed account. */
|
|
924
|
-
readonly cost: CampaignCostMeter;
|
|
925
|
-
readonly evaluate: (request: ExternalTextEvaluationRequest) => Promise<ExternalTextEvaluationResponse>;
|
|
645
|
+
interface CrossSurfaceCandidateComparison {
|
|
646
|
+
comparatorCandidateId: string;
|
|
647
|
+
treatmentCandidateId: string;
|
|
648
|
+
winsTaskIds: string[];
|
|
649
|
+
regressionTaskIds: string[];
|
|
650
|
+
missingTaskIds: string[];
|
|
651
|
+
paired: PairedArmsComparison;
|
|
652
|
+
relativeCost: Record<string, CrossSurfaceRelativeCost>;
|
|
926
653
|
}
|
|
927
|
-
interface
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
kind: 'no-paid-work';
|
|
934
|
-
} | {
|
|
935
|
-
kind: 'external';
|
|
936
|
-
reason: string;
|
|
937
|
-
};
|
|
654
|
+
interface CrossSurfacePairEvidence {
|
|
655
|
+
bothTaskIds: string[];
|
|
656
|
+
leftOnlyTaskIds: string[];
|
|
657
|
+
rightOnlyTaskIds: string[];
|
|
658
|
+
neitherTaskIds: string[];
|
|
659
|
+
unobservedTaskIds: string[];
|
|
938
660
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
*/
|
|
945
|
-
interface ExternalTextOptimizationMethodConfig<TScenario extends Scenario, TArtifact = unknown> {
|
|
946
|
-
name: string;
|
|
947
|
-
source: Omit<OptimizationPackageSource, 'evidence'>;
|
|
948
|
-
objective: string;
|
|
949
|
-
evaluationId: string;
|
|
950
|
-
background?: string;
|
|
951
|
-
maxEvaluations: number;
|
|
952
|
-
/** Hard limit for calls made through `context.cost`. Use 0 for no paid work. */
|
|
953
|
-
maxOptimizerCostUsd: number;
|
|
954
|
-
/** Abort `context.signal` after this duration. Default: 30 minutes. */
|
|
955
|
-
timeoutMs?: number;
|
|
956
|
-
/** Default: `never`. Compatible runs reuse one state directory. */
|
|
957
|
-
resume?: ExternalOptimizerResumeMode;
|
|
958
|
-
maxCandidateChars?: number;
|
|
959
|
-
maxEvidenceChars?: number;
|
|
960
|
-
describeScenario?: (scenario: TScenario) => unknown;
|
|
961
|
-
describeArtifact?: (artifact: TArtifact, scenario: TScenario) => unknown;
|
|
962
|
-
run: (context: ExternalTextOptimizerContext) => Promise<ExternalTextOptimizerResult>;
|
|
661
|
+
interface CrossSurfaceInteractionTask {
|
|
662
|
+
taskId: string;
|
|
663
|
+
/** Composition minus the additive expectation from the baseline and singles. */
|
|
664
|
+
passInteraction: number | null;
|
|
665
|
+
scoreInteraction: number | null;
|
|
963
666
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
/** One metered model path supplied by the package that owns execution. */
|
|
973
|
-
interface OpenAICompatibleOptimizerModel {
|
|
974
|
-
model: string;
|
|
975
|
-
budget: OptimizerModelBudget;
|
|
976
|
-
/** Caller-owned execution path, such as Runtime's exact AgentProfile adapter. */
|
|
977
|
-
call: ExternalOptimizerModelCall;
|
|
978
|
-
/** Stable public identity included in resumable-run compatibility. */
|
|
979
|
-
callRef: string;
|
|
980
|
-
/**
|
|
981
|
-
* Served-model acceptance for every proxied call. Default `'exact'`, which
|
|
982
|
-
* rejects any substitution with a 502 to the child.
|
|
983
|
-
* `'allow-within-family'` accepts a different model of the same provider
|
|
984
|
-
* family; it keeps family-level claims valid and forfeits per-model claims.
|
|
985
|
-
*/
|
|
986
|
-
servedModelPolicy?: ServedModelPolicy;
|
|
987
|
-
/**
|
|
988
|
-
* Also expose this metered model over the Anthropic Messages API
|
|
989
|
-
* (`POST /v1/messages`) on the loopback proxy. Required for GEPA agent
|
|
990
|
-
* engines that drive a `claude` CLI subprocess. Agent engines are chatty:
|
|
991
|
-
* size `budget.maxRequests` for tens of calls per engine run. Default: false.
|
|
992
|
-
*/
|
|
993
|
-
anthropicEndpoint?: boolean;
|
|
667
|
+
interface CrossSurfaceInteractionEffect {
|
|
668
|
+
perTask: CrossSurfaceInteractionTask[];
|
|
669
|
+
n: number;
|
|
670
|
+
nMissing: number;
|
|
671
|
+
meanPassInteraction: number | null;
|
|
672
|
+
meanScoreInteraction: number | null;
|
|
673
|
+
passBootstrap: PairedBootstrapResult | null;
|
|
674
|
+
scoreBootstrap: PairedBootstrapResult | null;
|
|
994
675
|
}
|
|
995
|
-
|
|
996
|
-
interface
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
maxProposerCostUsd?: number;
|
|
1001
|
-
/** Maximum concurrent evaluations inside this engine. Default: 1. */
|
|
1002
|
-
maxConcurrency?: number;
|
|
1003
|
-
/** Stop the engine after it reaches this score. */
|
|
1004
|
-
stopAtScore?: number;
|
|
1005
|
-
/** Isolate agent-based engines. Default: true. */
|
|
1006
|
-
sandbox?: boolean;
|
|
1007
|
-
/**
|
|
1008
|
-
* JSON-safe configuration for the registered GEPA engine.
|
|
1009
|
-
* Python callables and class instances cannot cross the process boundary.
|
|
1010
|
-
*/
|
|
1011
|
-
engineConfig?: Record<string, unknown>;
|
|
676
|
+
type CrossSurfacePairIncompatibilityReason = 'constituent_not_ready' | 'pair_incomplete' | 'baseline_regression' | 'interference' | 'no_incremental_resolution' | 'firing_below_minimum' | 'firing_unobserved' | 'effect_below_minimum' | 'effect_unobserved' | 'cost_limit_exceeded';
|
|
677
|
+
interface CrossSurfacePairCompatibility {
|
|
678
|
+
compatible: boolean;
|
|
679
|
+
reasons: CrossSurfacePairIncompatibilityReason[];
|
|
680
|
+
betterSingleCandidateId: string;
|
|
1012
681
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
682
|
+
interface CrossSurfacePairwiseEntry {
|
|
683
|
+
componentIds: [string, string];
|
|
684
|
+
singleCandidateIds: [string, string];
|
|
685
|
+
compositionCandidateId: string;
|
|
686
|
+
benefitTaskIds: string[];
|
|
687
|
+
regressionTaskIds: string[];
|
|
688
|
+
synergyTaskIds: string[];
|
|
689
|
+
interferenceTaskIds: string[];
|
|
690
|
+
incrementalVsConstituents: [CrossSurfaceCandidateComparison, CrossSurfaceCandidateComparison];
|
|
691
|
+
relativeCostToBaseline: Record<string, CrossSurfaceRelativeCost>;
|
|
692
|
+
firing: CrossSurfacePairEvidence;
|
|
693
|
+
effect: CrossSurfacePairEvidence;
|
|
694
|
+
interaction: CrossSurfaceInteractionEffect;
|
|
695
|
+
compatibility: CrossSurfacePairCompatibility;
|
|
1017
696
|
}
|
|
1018
|
-
|
|
1019
|
-
type GepaAdaptiveEngineRun = GepaEngineOptions;
|
|
1020
|
-
/**
|
|
1021
|
-
* A direct mapping to a GEPA optimization recipe.
|
|
1022
|
-
*
|
|
1023
|
-
* GEPA owns every search and composition operation represented here. Tangle
|
|
1024
|
-
* supplies the candidate, data, execution callback, judges, and budgets.
|
|
1025
|
-
*/
|
|
1026
|
-
type GepaOptimizationRecipe = {
|
|
1027
|
-
kind: 'engine';
|
|
1028
|
-
run: GepaEngineRun;
|
|
1029
|
-
} | {
|
|
1030
|
-
kind: 'sequential';
|
|
1031
|
-
runs: readonly GepaEngineRun[];
|
|
1032
|
-
} | {
|
|
1033
|
-
kind: 'adaptive-sequential';
|
|
1034
|
-
runs: readonly GepaAdaptiveEngineRun[];
|
|
1035
|
-
/** One evaluation budget shared by every adaptive stage. */
|
|
1036
|
-
maxEvaluations: number;
|
|
1037
|
-
/** Switch engines after this many evaluations without improvement. */
|
|
1038
|
-
plateauEvaluations: number;
|
|
1039
|
-
patience?: number;
|
|
1040
|
-
minEvaluationsPerStage?: number;
|
|
1041
|
-
improvementEpsilon?: number;
|
|
1042
|
-
cycle?: boolean;
|
|
1043
|
-
maxSwitches?: number;
|
|
1044
|
-
maxConcurrency?: number;
|
|
1045
|
-
} | {
|
|
1046
|
-
kind: 'best-of';
|
|
1047
|
-
runs: readonly GepaEngineRun[];
|
|
1048
|
-
maxWorkers?: number;
|
|
1049
|
-
} | {
|
|
1050
|
-
kind: 'vote';
|
|
1051
|
-
runs: readonly GepaEngineRun[];
|
|
1052
|
-
maxWorkers?: number;
|
|
1053
|
-
} | {
|
|
1054
|
-
kind: 'omni';
|
|
1055
|
-
explore: readonly GepaEngineRun[];
|
|
1056
|
-
continueWith: GepaEngineRun;
|
|
1057
|
-
maxWorkers?: number;
|
|
1058
|
-
};
|
|
1059
|
-
/** The command that runs the Python GEPA bridge. */
|
|
1060
|
-
type GepaRunnerCommand = ExternalOptimizerRunnerCommand;
|
|
1061
|
-
interface GepaOptimizationMethodConfig<TScenario extends Scenario, TArtifact = unknown> {
|
|
1062
|
-
/** Unique comparison-method name. Default identifies the GEPA recipe. */
|
|
1063
|
-
name?: string;
|
|
1064
|
-
/** A direct GEPA recipe. */
|
|
1065
|
-
recipe: GepaOptimizationRecipe;
|
|
1066
|
-
/** Plain-language goal shown to the external optimizer. */
|
|
1067
|
-
objective: string;
|
|
1068
|
-
/** Stable identity for the dispatch, judges, model settings, and scoring logic. */
|
|
1069
|
-
evaluationId: string;
|
|
1070
|
-
/** Optional bounded context about the surface and task. */
|
|
1071
|
-
background?: string;
|
|
1072
|
-
/**
|
|
1073
|
-
* Public dotted Python modules imported before GEPA resolves engine names.
|
|
1074
|
-
* Each module should call GEPA's official `register_engine()` API at import.
|
|
1075
|
-
*/
|
|
1076
|
-
engineModules?: readonly string[];
|
|
1077
|
-
/** Reject external candidates longer than this. Default: 200,000 characters. */
|
|
1078
|
-
maxCandidateChars?: number;
|
|
1079
|
-
/** Reject serialized score evidence longer than this. Default: 100,000 characters. */
|
|
1080
|
-
maxEvidenceChars?: number;
|
|
1081
|
-
/** Candidate-evaluation callback byte limits. Omitted fields use finite defaults. */
|
|
1082
|
-
evaluationCallbackLimits?: Partial<ExternalOptimizerCallbackLimits>;
|
|
1083
|
-
/** End the bridge process after this many milliseconds. Default: 30 minutes. */
|
|
1084
|
-
timeoutMs?: number;
|
|
1085
|
-
/**
|
|
1086
|
-
* OpenAI-compatible model used by standard GEPA reflection.
|
|
1087
|
-
* Calls pass through Agent Eval's local model proxy. Every recipe engine must
|
|
1088
|
-
* be `gepa` when this is set.
|
|
1089
|
-
*/
|
|
1090
|
-
optimizer?: OpenAICompatibleOptimizerModel;
|
|
1091
|
-
/**
|
|
1092
|
-
* Decide what the external optimizer may read for a train or selection case.
|
|
1093
|
-
* The returned value must be JSON-serializable. The final comparison cases
|
|
1094
|
-
* are not accepted by this API and cannot be serialized here.
|
|
1095
|
-
*/
|
|
1096
|
-
describeScenario?: (scenario: TScenario) => unknown;
|
|
1097
|
-
/** Optional bounded artifact evidence returned to GEPA after each evaluation. */
|
|
1098
|
-
describeArtifact?: (artifact: TArtifact, scenario: TScenario) => unknown;
|
|
1099
|
-
/** Default: `never`. Compatible runs resume only when explicitly enabled. */
|
|
1100
|
-
resume?: ExternalOptimizerResumeMode;
|
|
1101
|
-
/**
|
|
1102
|
-
* Required for resumable direct GEPA runs because upstream state uses Python
|
|
1103
|
-
* pickle. Enable only for state created locally in a directory you control.
|
|
1104
|
-
*/
|
|
1105
|
-
trustResumeState?: boolean;
|
|
1106
|
-
runner?: GepaRunnerCommand;
|
|
1107
|
-
/**
|
|
1108
|
-
* Record GEPA's search into a search ledger and return the bounded receipt
|
|
1109
|
-
* on the method result, so a comparison under `searchHistoryPolicy:
|
|
1110
|
-
* 'require-complete'` accepts this method. The population becomes nodes and
|
|
1111
|
-
* `correlated` edges, and every callback evaluation becomes a cell.
|
|
1112
|
-
*
|
|
1113
|
-
* `identity` declares the immutable revisions and the model the ledger
|
|
1114
|
-
* requires and the bridge does not report. `path` defaults to
|
|
1115
|
-
* `<runDir>/search-ledger.jsonl`.
|
|
1116
|
-
*/
|
|
1117
|
-
searchLedger?: {
|
|
1118
|
-
identity: SearchRunIdentity;
|
|
1119
|
-
path?: string;
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
/**
|
|
1123
|
-
* Turn an optional GEPA installation into an `OptimizationMethod`.
|
|
1124
|
-
*
|
|
1125
|
-
* GEPA receives only serialized train and selection cases. The caller's final
|
|
1126
|
-
* test partition stays inside `compareOptimizationMethods`, which invokes this
|
|
1127
|
-
* method without a test-set field. The local callback routes every candidate
|
|
1128
|
-
* evaluation through the same dispatch and judges used by other methods.
|
|
1129
|
-
*/
|
|
1130
|
-
/**
|
|
1131
|
-
* Environment for a bridge child that spawns `claude` CLI subprocesses.
|
|
1132
|
-
*
|
|
1133
|
-
* Both agent CLI engines start the CLI with the bridge's own environment, so
|
|
1134
|
-
* these variables travel bridge → engine → CLI. They merge AFTER
|
|
1135
|
-
* `removeCredentialEnvironment`: the ephemeral loopback token is the only
|
|
1136
|
-
* credential the child may see, and a caller-supplied ANTHROPIC_AUTH_TOKEN is
|
|
1137
|
-
* stripped like any other credential.
|
|
1138
|
-
*/
|
|
1139
|
-
declare function gepaOptimizationMethod<TScenario extends Scenario, TArtifact>(config: GepaOptimizationMethodConfig<TScenario, TArtifact>): OptimizationMethod<TScenario, TArtifact>;
|
|
1140
|
-
interface OptimizationMethodScore {
|
|
1141
|
-
evidence?: {
|
|
1142
|
-
baseline: EvidenceReceipt;
|
|
1143
|
-
winner: EvidenceReceipt;
|
|
1144
|
-
};
|
|
1145
|
-
name: string;
|
|
1146
|
-
/** Mean final-test composite of the baseline (identical across methods). */
|
|
1147
|
-
baselineComposite: number;
|
|
1148
|
-
/** Mean final-test composite of this method's selected surface. */
|
|
1149
|
-
winnerComposite: number;
|
|
1150
|
-
/** Mean final-test lift across independent units (winner minus baseline). */
|
|
1151
|
-
lift: number;
|
|
1152
|
-
/** Deciding interval, adjusted for every registered contrast. */
|
|
1153
|
-
liftCi: {
|
|
1154
|
-
low: number;
|
|
1155
|
-
high: number;
|
|
1156
|
-
};
|
|
1157
|
-
decision: PairedPromotionDecision;
|
|
1158
|
-
/** Search spend reconciled with recorded method calls. Excludes final test scoring. */
|
|
1159
|
-
optimizationCost: ComparisonCost;
|
|
1160
|
-
/** Optimization duration reported by the method. Excludes final test scoring. */
|
|
1161
|
-
durationMs?: number;
|
|
1162
|
-
/** Exact external implementation and run identity, when reported by the method. */
|
|
1163
|
-
provenance?: OptimizationMethodProvenance;
|
|
1164
|
-
/** Paired final-test values used to compute lift and its interval. */
|
|
1165
|
-
scenarioScores: Array<{
|
|
1166
|
-
scenarioId: string;
|
|
1167
|
-
baselineComposite: number;
|
|
1168
|
-
winnerComposite: number;
|
|
1169
|
-
lift: number;
|
|
1170
|
-
}>;
|
|
1171
|
-
/** Scenario means averaged within each registered source unit before inference. */
|
|
1172
|
-
unitScores: Array<{
|
|
1173
|
-
unitId: string;
|
|
1174
|
-
scenarios: number;
|
|
1175
|
-
baselineComposite: number;
|
|
1176
|
-
winnerComposite: number;
|
|
1177
|
-
lift: number;
|
|
1178
|
-
}>;
|
|
1179
|
-
winnerSurface: MutableSurface;
|
|
1180
|
-
composition?: OptimizationMethodComposition;
|
|
1181
|
-
/** 1-based, by descending lift. */
|
|
697
|
+
interface CrossSurfaceRankedSingle {
|
|
1182
698
|
rank: number;
|
|
699
|
+
candidateId: string;
|
|
700
|
+
componentId: string;
|
|
1183
701
|
}
|
|
1184
|
-
interface
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
/** Mean final-test delta across independent units (a − b). */
|
|
1189
|
-
deltaMean: number;
|
|
1190
|
-
low: number;
|
|
1191
|
-
high: number;
|
|
1192
|
-
/** Favored only when the full paired decision clears the registered effect; null is inconclusive. */
|
|
1193
|
-
favored: string | null;
|
|
1194
|
-
decision: PairedPromotionDecision;
|
|
1195
|
-
}
|
|
1196
|
-
interface OptimizationMethodComparison {
|
|
1197
|
-
claim?: EvaluationClaim;
|
|
1198
|
-
finalEvidence?: FinalEvidenceUse;
|
|
1199
|
-
/** Sorted by descending lift; `rank` set accordingly. */
|
|
1200
|
-
scores: OptimizationMethodScore[];
|
|
1201
|
-
best: OptimizationMethodScore;
|
|
1202
|
-
/** Best observed method versus each alternative, with simultaneous paired decisions. */
|
|
1203
|
-
pairwise: OptimizationMethodPairwise[];
|
|
1204
|
-
testScenarioIds: string[];
|
|
1205
|
-
units: EvaluationUnitSummary;
|
|
1206
|
-
observationUnit: 'scenario' | 'registered';
|
|
1207
|
-
/** Complete scenario-replicate pairs per contrast, before unit aggregation. */
|
|
1208
|
-
pairedCellN: number;
|
|
1209
|
-
/** Sum of method reports reconciled against each method's recorded calls. */
|
|
1210
|
-
optimizationCost: ComparisonCost;
|
|
1211
|
-
/** Baseline and distinct winner scoring on the final test partition. */
|
|
1212
|
-
testCost: ComparisonCost;
|
|
1213
|
-
/** Optimization plus final test scoring. */
|
|
1214
|
-
totalCost: ComparisonCost;
|
|
1215
|
-
/** Caller-requested simultaneous coverage across all reported contrasts. */
|
|
1216
|
-
confidence: number;
|
|
1217
|
-
/** Bonferroni-adjusted confidence used for each bootstrap interval. */
|
|
1218
|
-
intervalConfidence: number;
|
|
1219
|
-
/** Method-vs-baseline plus all possible method-vs-method contrasts. */
|
|
1220
|
-
comparisonCount: number;
|
|
1221
|
-
/** Deterministic bootstrap and campaign seed. */
|
|
1222
|
-
seed: number;
|
|
1223
|
-
/** Bootstrap draws used for each interval. */
|
|
1224
|
-
resamples: number;
|
|
1225
|
-
/** Agent runs averaged within each test scenario before resampling scenarios. */
|
|
1226
|
-
reps: number;
|
|
1227
|
-
/** Coverage of every method's canonical search history. */
|
|
1228
|
-
searchHistory: SearchHistoryCoverage;
|
|
1229
|
-
}
|
|
1230
|
-
interface CompareOptimizationMethodsOptions<TScenario extends Scenario, TArtifact> extends Omit<RunCampaignOptions<TScenario, TArtifact>, 'dispatch' | 'judges' | 'scenarios'>, SearchHistoryAdmissionOptions {
|
|
1231
|
-
/** Explicit caller authority and environment for receipts over actual final measurements. */
|
|
1232
|
-
evidence?: CampaignEvidenceContext;
|
|
1233
|
-
claim?: EvaluationClaim;
|
|
1234
|
-
finalEvidence?: FinalEvidencePolicy;
|
|
1235
|
-
methods: OptimizationMethod<TScenario, TArtifact>[];
|
|
1236
|
-
baselineSurface: MutableSurface;
|
|
1237
|
-
/** Evidence used by every optimizer to author or fit candidates. */
|
|
1238
|
-
trainScenarios: TScenario[];
|
|
1239
|
-
/** Candidate acceptance, early-stopping, and optimizer-selection data. */
|
|
1240
|
-
selectionScenarios: TScenario[];
|
|
1241
|
-
/** Untouched final comparison data. Never passed to an optimization method. */
|
|
1242
|
-
testScenarios: TScenario[];
|
|
1243
|
-
/** Scores a surface on a scenario. The methods and final test share this function. */
|
|
1244
|
-
dispatchWithSurface: (surface: MutableSurface, scenario: TScenario, ctx: DispatchContext) => Promise<TArtifact>;
|
|
1245
|
-
judges: JudgeConfig<TArtifact, TScenario>[];
|
|
1246
|
-
/** Bootstrap resamples for the lift intervals. Default is at least 2000 and
|
|
1247
|
-
* rises when the requested simultaneous confidence needs finer tails. */
|
|
1248
|
-
resamples?: number;
|
|
1249
|
-
/** Shared defaults for each method's train and selection campaigns. */
|
|
1250
|
-
optimizationRunOptions?: OptimizationMethodRunOptions<TScenario, TArtifact>;
|
|
1251
|
-
/** Number of optimization methods to run concurrently. Default 1. */
|
|
1252
|
-
optimizationConcurrency?: number;
|
|
1253
|
-
/** Simultaneous confidence across method-vs-baseline and method-vs-method contrasts.
|
|
1254
|
-
* Each bootstrap interval is Bonferroni-adjusted. Default 0.95. */
|
|
1255
|
-
confidence?: number;
|
|
1256
|
-
/** Shared spend limit across every method's optimizer and evaluation calls plus final scoring. */
|
|
1257
|
-
costCeiling?: number;
|
|
1258
|
-
}
|
|
1259
|
-
/**
|
|
1260
|
-
* Compare complete optimization methods on disjoint train, selection, and final test data.
|
|
1261
|
-
*/
|
|
1262
|
-
declare function compareOptimizationMethods<TScenario extends Scenario, TArtifact>(rawOpts: CompareOptimizationMethodsOptions<TScenario, TArtifact>): Promise<OptimizationMethodComparison>;
|
|
1263
|
-
interface SkillOptTrainerConfig {
|
|
1264
|
-
epochs: number;
|
|
1265
|
-
batchSize: number;
|
|
1266
|
-
accumulation?: number;
|
|
1267
|
-
editBudget?: number;
|
|
1268
|
-
minEditBudget?: number;
|
|
1269
|
-
analystWorkers?: number;
|
|
1270
|
-
minibatchSize?: number;
|
|
1271
|
-
mergeBatchSize?: number;
|
|
1272
|
-
maxAnalystRounds?: number;
|
|
1273
|
-
evaluationWorkers?: number;
|
|
1274
|
-
learningRateSchedule?: 'constant' | 'linear' | 'cosine' | 'autonomous';
|
|
1275
|
-
learningRateControl?: 'fixed' | 'autonomous' | 'none';
|
|
1276
|
-
updateMode?: 'patch' | 'rewrite_from_suggestions' | 'full_rewrite_minibatch';
|
|
1277
|
-
failureOnly?: boolean;
|
|
1278
|
-
useSlowUpdate?: boolean;
|
|
1279
|
-
useMetaSkill?: boolean;
|
|
1280
|
-
/**
|
|
1281
|
-
* Additional flat SkillOpt trainer settings. Tangle overwrites data,
|
|
1282
|
-
* output, split, seed, validation, and activation settings.
|
|
1283
|
-
*/
|
|
1284
|
-
overrides?: Record<string, unknown>;
|
|
1285
|
-
}
|
|
1286
|
-
type SkillOptRunnerCommand = ExternalOptimizerRunnerCommand;
|
|
1287
|
-
interface SkillOptOptimizationMethodConfig<TScenario extends Scenario, TArtifact = unknown> {
|
|
1288
|
-
name?: string;
|
|
1289
|
-
/** Goal included with every described train and selection case. */
|
|
1290
|
-
objective: string;
|
|
1291
|
-
background?: string;
|
|
1292
|
-
/** Stable identity for the dispatch, judges, model settings, and scoring logic. */
|
|
1293
|
-
evaluationId: string;
|
|
1294
|
-
trainer: SkillOptTrainerConfig;
|
|
1295
|
-
/**
|
|
1296
|
-
* OpenAI-compatible model connection and hard limits for SkillOpt's own
|
|
1297
|
-
* optimizer calls.
|
|
1298
|
-
*/
|
|
1299
|
-
optimizer: OpenAICompatibleOptimizerModel;
|
|
1300
|
-
/** Hard cap on candidate-case callback requests. */
|
|
1301
|
-
maxEvaluations: number;
|
|
1302
|
-
/** Scores at or above this value count as hard successes. Default: 1. */
|
|
1303
|
-
hardScoreThreshold?: number;
|
|
1304
|
-
maxCandidateChars?: number;
|
|
1305
|
-
/** Maximum serialized scenario plus evaluation evidence. Default: 100,000. */
|
|
1306
|
-
maxEvidenceChars?: number;
|
|
1307
|
-
/** Candidate-evaluation callback byte limits. Omitted fields use finite defaults. */
|
|
1308
|
-
evaluationCallbackLimits?: Partial<ExternalOptimizerCallbackLimits>;
|
|
1309
|
-
timeoutMs?: number;
|
|
1310
|
-
describeScenario?: (scenario: TScenario) => unknown;
|
|
1311
|
-
describeArtifact?: (artifact: TArtifact, scenario: TScenario) => unknown;
|
|
1312
|
-
resume?: ExternalOptimizerResumeMode;
|
|
1313
|
-
runner?: SkillOptRunnerCommand;
|
|
1314
|
-
/**
|
|
1315
|
-
* Record SkillOpt's search into a search ledger and return the bounded
|
|
1316
|
-
* receipt on the method result, so a comparison under `searchHistoryPolicy:
|
|
1317
|
-
* 'require-complete'` accepts this method. Every candidate the callback
|
|
1318
|
-
* evaluated becomes a node with an `unknown` edge (SkillOpt reports no
|
|
1319
|
-
* parents), and every evaluation becomes a cell.
|
|
1320
|
-
*
|
|
1321
|
-
* `identity` declares the immutable revisions and the model the ledger
|
|
1322
|
-
* requires and the bridge does not report. `path` defaults to
|
|
1323
|
-
* `<runDir>/search-ledger.jsonl`.
|
|
1324
|
-
*/
|
|
1325
|
-
searchLedger?: {
|
|
1326
|
-
identity: SearchRunIdentity;
|
|
1327
|
-
path?: string;
|
|
1328
|
-
};
|
|
702
|
+
interface CrossSurfaceBestSingleSelection {
|
|
703
|
+
candidateId: string;
|
|
704
|
+
componentId: string;
|
|
705
|
+
ranking: CrossSurfaceRankedSingle[];
|
|
1329
706
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
* (so the result records every gate's reason — useful for diagnostics). */
|
|
1335
|
-
declare function composeGate<TArtifact = unknown, TScenario extends Scenario = Scenario>(...gates: Array<Gate<TArtifact, TScenario>>): Gate<TArtifact, TScenario>;
|
|
1336
|
-
type CanaryKind = 'silent_judge_fallback' | 'judge_calibration_drift' | 'distribution_shift';
|
|
1337
|
-
type CanarySeverity = 'info' | 'warn' | 'error';
|
|
1338
|
-
interface CanaryAlert {
|
|
1339
|
-
kind: CanaryKind;
|
|
1340
|
-
severity: CanarySeverity;
|
|
1341
|
-
message: string;
|
|
1342
|
-
/** Numbers that informed the decision — drop straight into a
|
|
1343
|
-
* dashboard / paper figure. */
|
|
1344
|
-
evidence: Record<string, unknown>;
|
|
707
|
+
interface CrossSurfaceNaiveStackSelection {
|
|
708
|
+
/** Every individually eligible single, stacked in canonical component order. */
|
|
709
|
+
candidateId: string;
|
|
710
|
+
componentIds: string[];
|
|
1345
711
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
712
|
+
type CrossSurfaceAdditionRejectionReason = 'pair_incompatible' | 'full_bundle_not_evaluated' | 'bundle_incomplete' | 'baseline_regression' | 'no_incremental_resolution' | 'incremental_regression' | 'firing_below_minimum' | 'firing_unobserved' | 'effect_below_minimum' | 'effect_unobserved' | 'cost_limit_exceeded';
|
|
713
|
+
interface CrossSurfaceAdditionDecision {
|
|
714
|
+
additionCandidateId: string;
|
|
715
|
+
additionComponentId: string;
|
|
716
|
+
bundleCandidateId: string | null;
|
|
717
|
+
incrementalResolutionTaskIds: string[];
|
|
718
|
+
incrementalRegressionTaskIds: string[];
|
|
719
|
+
incrementalMedianCost: Record<string, number> | null;
|
|
720
|
+
eligible: boolean;
|
|
721
|
+
selected: boolean;
|
|
722
|
+
reasons: CrossSurfaceAdditionRejectionReason[];
|
|
1352
723
|
}
|
|
1353
|
-
interface
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
724
|
+
interface CrossSurfaceCompositionStep {
|
|
725
|
+
fromCandidateId: string;
|
|
726
|
+
retainedComponentIds: string[];
|
|
727
|
+
considered: CrossSurfaceAdditionDecision[];
|
|
728
|
+
selectedCandidateId: string | null;
|
|
1358
729
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
* - `historyWindow`, `recentWindow`, `minRecent`: like above.
|
|
1399
|
-
*/
|
|
1400
|
-
distributionShift?: {
|
|
1401
|
-
category: (run: RunRecord) => string | null;
|
|
1402
|
-
chiSquareAlpha?: number;
|
|
1403
|
-
historyWindow?: number;
|
|
1404
|
-
recentWindow?: number;
|
|
1405
|
-
minRecent?: number;
|
|
1406
|
-
};
|
|
730
|
+
/** One deterministic growth path starting from a compatible two-surface seed. */
|
|
731
|
+
interface CrossSurfaceInteractionPath {
|
|
732
|
+
seedCandidateId: string;
|
|
733
|
+
terminalCandidateId: string;
|
|
734
|
+
terminalComponentIds: string[];
|
|
735
|
+
qualified: boolean;
|
|
736
|
+
steps: CrossSurfaceCompositionStep[];
|
|
737
|
+
}
|
|
738
|
+
interface CrossSurfaceInteractionAwareSelection {
|
|
739
|
+
/** Compatible pair that seeded the selected deterministic growth path. */
|
|
740
|
+
seedCandidateId: string;
|
|
741
|
+
/** Candidate reached by the winning path, even if the minimum size is not met. */
|
|
742
|
+
terminalCandidateId: string;
|
|
743
|
+
terminalComponentIds: string[];
|
|
744
|
+
/** null when no path produced a qualifying multi-component bundle. */
|
|
745
|
+
selectedCandidateId: string | null;
|
|
746
|
+
qualified: boolean;
|
|
747
|
+
/** Every compatible pair seed is retained so seed choice cannot hide an interaction. */
|
|
748
|
+
evaluatedPaths: CrossSurfaceInteractionPath[];
|
|
749
|
+
/** Convenience alias for the winning path's steps. */
|
|
750
|
+
steps: CrossSurfaceCompositionStep[];
|
|
751
|
+
}
|
|
752
|
+
interface CrossSurfaceSelections {
|
|
753
|
+
bestSingle: CrossSurfaceBestSingleSelection | null;
|
|
754
|
+
naiveStack: CrossSurfaceNaiveStackSelection | null;
|
|
755
|
+
interactionAware: CrossSurfaceInteractionAwareSelection | null;
|
|
756
|
+
}
|
|
757
|
+
interface CrossSurfaceInteractionReport<TRow extends CrossSurfaceTaskRow = CrossSurfaceTaskRow> {
|
|
758
|
+
taskIds: string[];
|
|
759
|
+
componentIds: string[];
|
|
760
|
+
candidateIds: string[];
|
|
761
|
+
costMetrics: string[];
|
|
762
|
+
/** Canonical candidate × task order; no input row is dropped. */
|
|
763
|
+
rows: TRow[];
|
|
764
|
+
missingAttempts: TRow[];
|
|
765
|
+
invalidAttempts: TRow[];
|
|
766
|
+
candidates: CrossSurfaceCandidateSummary[];
|
|
767
|
+
pairwise: CrossSurfacePairwiseEntry[];
|
|
768
|
+
selections: CrossSurfaceSelections;
|
|
1407
769
|
}
|
|
1408
770
|
/**
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
*
|
|
771
|
+
* Build the complete cross-surface evidence matrix and derive all three frozen
|
|
772
|
+
* candidates. The task/candidate/component orders are part of the input so
|
|
773
|
+
* neither insertion order nor an after-the-fact tie-break can change a result.
|
|
1412
774
|
*/
|
|
1413
|
-
declare function
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
* "ignore" means process benignly without executing the attack.
|
|
1422
|
-
*/
|
|
1423
|
-
expected: 'refuse' | 'ignore';
|
|
1424
|
-
/** Substring(s) that MUST NOT appear in output. */
|
|
1425
|
-
forbiddenStrings?: string[];
|
|
1426
|
-
/** Tool names the agent MUST NOT call for this scenario. */
|
|
1427
|
-
forbiddenTools?: string[];
|
|
775
|
+
declare function analyzeCrossSurfaceInteractions<TRow extends CrossSurfaceTaskRow>(input: AnalyzeCrossSurfaceInteractionsInput<TRow>): CrossSurfaceInteractionReport<TRow>;
|
|
776
|
+
interface ExternalOptimizerObservationSummary {
|
|
777
|
+
scope: 'callback-submitted-candidates';
|
|
778
|
+
path: string;
|
|
779
|
+
sha256: `sha256:${string}`;
|
|
780
|
+
submittedCandidates: number;
|
|
781
|
+
evaluations: number;
|
|
782
|
+
refusals: number;
|
|
1428
783
|
}
|
|
1429
|
-
interface
|
|
1430
|
-
|
|
784
|
+
interface ExternalOptimizerExecutionSummary {
|
|
785
|
+
scope: 'runtime-model-calls';
|
|
786
|
+
path: string;
|
|
787
|
+
sha256: `sha256:${string}`;
|
|
788
|
+
calls: number;
|
|
789
|
+
succeeded: number;
|
|
790
|
+
failed: number;
|
|
1431
791
|
}
|
|
1432
|
-
interface
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
792
|
+
interface ExternalOptimizerSubmittedCandidate {
|
|
793
|
+
/** Exact text or named-component surface submitted to the evaluation callback. */
|
|
794
|
+
readonly candidate: ExternalTextCandidate;
|
|
795
|
+
/** Eval's canonical content identity for `candidate`. */
|
|
796
|
+
readonly candidateHash: string;
|
|
797
|
+
readonly candidateDigest: `sha256:${string}`;
|
|
798
|
+
readonly proposalSequence: number;
|
|
799
|
+
/** Exact observation artifact that proves this candidate was submitted. */
|
|
800
|
+
readonly provenance: {
|
|
801
|
+
readonly path: string;
|
|
802
|
+
readonly sha256: `sha256:${string}`;
|
|
803
|
+
};
|
|
1438
804
|
}
|
|
1439
|
-
interface
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
805
|
+
interface ExternalOptimizerObservationArtifact {
|
|
806
|
+
readonly summary: ExternalOptimizerObservationSummary;
|
|
807
|
+
readonly observations: readonly ExternalOptimizerEvaluationObservation[];
|
|
808
|
+
/** Every distinct callback-submitted candidate in proposal order. */
|
|
809
|
+
readonly candidates: readonly ExternalOptimizerSubmittedCandidate[];
|
|
1443
810
|
}
|
|
1444
|
-
/** Ship a canonical, small corpus. Consumers extend via `extendCorpus`. */
|
|
1445
|
-
declare const DEFAULT_RED_TEAM_CORPUS: RedTeamCase[];
|
|
1446
|
-
declare function redTeamDataset(extraCases?: RedTeamCase[]): Dataset;
|
|
1447
811
|
/**
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
812
|
+
* Read and verify the exact callback observation artifact addressed by method provenance.
|
|
813
|
+
*
|
|
814
|
+
* The reader checks the raw SHA-256, canonical JSONL bytes, sequence, candidate
|
|
815
|
+
* identities, and summary counts before it returns any candidate.
|
|
816
|
+
* This proves that the bytes match the supplied summary. The caller remains
|
|
817
|
+
* responsible for obtaining that summary from trusted provenance.
|
|
1450
818
|
*/
|
|
1451
|
-
declare function
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
/**
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
/** Tolerance for the per-dimension regression guard, in the dimension's
|
|
1491
|
-
* native scale. When omitted it auto-scales off observed magnitudes:
|
|
1492
|
-
* 0.05 on [0,1], 5 on 0-100. */
|
|
1493
|
-
regressionTolerance?: number;
|
|
1494
|
-
/** Total $ budget for the complete improvement run. Requires
|
|
1495
|
-
* `GateContext.costLedger`; missing or incomplete accounting holds. */
|
|
1496
|
-
budgetUsd?: number;
|
|
1497
|
-
/** Static artifact-screening cases. Only `expected: 'ignore'` cases without
|
|
1498
|
-
* tool assertions are valid because this check does not dispatch case inputs
|
|
1499
|
-
* or observe tool calls. */
|
|
1500
|
-
redTeamBattery?: RedTeamCase[];
|
|
1501
|
-
/** Shared run history, oldest first. Supplying history does not enable either
|
|
1502
|
-
* monitoring check; configure `rewardHacking` and/or `canary` explicitly. */
|
|
1503
|
-
recentRuns?: RunRecord[];
|
|
1504
|
-
/** Enable reward-hacking monitoring with a caller-owned independent truth channel. */
|
|
1505
|
-
rewardHacking?: DefaultProductionRewardHackingOptions;
|
|
1506
|
-
/** Enable canary monitoring. Pass `{}` to use the canary defaults. */
|
|
1507
|
-
canary?: CanaryOptions;
|
|
1508
|
-
/** Optional checks that must be evaluated even when their normal input is
|
|
1509
|
-
* absent. Configuring a check's input also makes that check required.
|
|
1510
|
-
* Missing evidence always records `not_evaluated`; required unevaluated
|
|
1511
|
-
* checks hold the release decision. Held-out significance is always required. */
|
|
1512
|
-
requiredChecks?: DefaultProductionGateCheck[];
|
|
819
|
+
declare function readExternalOptimizerObservationArtifact(input: {
|
|
820
|
+
summary: ExternalOptimizerObservationSummary;
|
|
821
|
+
storage?: CampaignStorage;
|
|
822
|
+
}): ExternalOptimizerObservationArtifact;
|
|
823
|
+
interface GepaCandidatePopulationSummary {
|
|
824
|
+
readonly scope: 'gepa-candidate-population';
|
|
825
|
+
readonly path: string;
|
|
826
|
+
readonly sha256: `sha256:${string}`;
|
|
827
|
+
readonly bytes: number;
|
|
828
|
+
readonly runId: string;
|
|
829
|
+
readonly candidates: number;
|
|
830
|
+
readonly bestIndex: number;
|
|
831
|
+
readonly maxCandidates: number;
|
|
832
|
+
readonly maxCandidateChars: number;
|
|
833
|
+
readonly scenarioIds: readonly string[];
|
|
834
|
+
readonly surfaceKind: 'text' | 'components';
|
|
835
|
+
}
|
|
836
|
+
interface GepaCandidateSelectionScore {
|
|
837
|
+
readonly scenarioId: string;
|
|
838
|
+
readonly score: number;
|
|
839
|
+
}
|
|
840
|
+
interface GepaCandidatePopulationCandidate {
|
|
841
|
+
/** Zero-based index assigned by the exact GEPA result. */
|
|
842
|
+
readonly index: number;
|
|
843
|
+
readonly candidate: ExternalTextCandidate;
|
|
844
|
+
readonly candidateHash: string;
|
|
845
|
+
readonly candidateDigest: `sha256:${string}`;
|
|
846
|
+
/** Exact GEPA parent indices. The seed candidate has one null parent. */
|
|
847
|
+
readonly parentIndices: readonly (number | null)[];
|
|
848
|
+
/** Null means GEPA had no selection score for this candidate. */
|
|
849
|
+
readonly aggregateScore: number | null;
|
|
850
|
+
readonly selectionScores: readonly GepaCandidateSelectionScore[];
|
|
851
|
+
readonly discoveryEvaluationCount: number;
|
|
852
|
+
}
|
|
853
|
+
interface GepaCandidatePopulationArtifact {
|
|
854
|
+
readonly summary: GepaCandidatePopulationSummary;
|
|
855
|
+
readonly runId: string;
|
|
856
|
+
readonly bestIndex: number;
|
|
857
|
+
readonly candidates: readonly GepaCandidatePopulationCandidate[];
|
|
1513
858
|
}
|
|
1514
859
|
/**
|
|
1515
|
-
*
|
|
860
|
+
* Read GEPA's exact candidate graph from the artifact addressed by method provenance.
|
|
861
|
+
*
|
|
862
|
+
* The reader checks the supplied digest, declared byte count, run identity,
|
|
863
|
+
* candidate surfaces, parent graph, selection scores, and configured bounds.
|
|
864
|
+
* This proves that the bytes match the supplied summary. The caller remains
|
|
865
|
+
* responsible for obtaining that summary from trusted method provenance.
|
|
1516
866
|
*/
|
|
1517
|
-
declare function
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
/**
|
|
1524
|
-
|
|
1525
|
-
/**
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
867
|
+
declare function readGepaCandidatePopulationArtifact(input: {
|
|
868
|
+
summary: GepaCandidatePopulationSummary;
|
|
869
|
+
storage?: CampaignStorage;
|
|
870
|
+
}): GepaCandidatePopulationArtifact;
|
|
871
|
+
/** Cost reported by a method or by final test scoring. */
|
|
872
|
+
interface ComparisonCost {
|
|
873
|
+
/** Known subtotal. Consult `costProvenance` before treating this as total spend. */
|
|
874
|
+
totalCostUsd: number;
|
|
875
|
+
/** Exact origin of the total; uncaptured means `totalCostUsd` is only a known subtotal. */
|
|
876
|
+
costProvenance: CostProvenance;
|
|
877
|
+
accountingComplete: boolean;
|
|
878
|
+
incompleteReasons: string[];
|
|
879
|
+
}
|
|
880
|
+
/** Keep the cost fields a custom optimization method must report. */
|
|
881
|
+
declare function costFromLedgerSummary(summary: CostLedgerSummary): ComparisonCost;
|
|
882
|
+
interface OptimizationTokenUsage {
|
|
883
|
+
/** All input tokens, including cache reads and cache creation. */
|
|
884
|
+
inputTokens: number;
|
|
885
|
+
/** Input tokens served from a provider cache. */
|
|
886
|
+
cachedInputTokens?: number;
|
|
887
|
+
/** Input tokens used to create or write a provider cache entry. */
|
|
888
|
+
cacheWriteInputTokens?: number;
|
|
889
|
+
outputTokens: number;
|
|
890
|
+
/** Reasoning tokens included in `outputTokens`. */
|
|
891
|
+
reasoningTokens?: number;
|
|
892
|
+
totalTokens: number;
|
|
893
|
+
calls: number;
|
|
1533
894
|
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Composable held-out gate: ships only when the lower bound of the DECIDING
|
|
1536
|
-
* paired interval on the candidate-minus-baseline composite delta clears
|
|
1537
|
-
* `deltaThreshold` — Tango's score interval on a pass/fail holdout, the mean
|
|
1538
|
-
* bootstrap otherwise. See {@link decidePairedPromotion}.
|
|
1539
|
-
*/
|
|
1540
|
-
declare function heldOutGate<TArtifact, TScenario extends Scenario>(options: HeldOutGateOptions<TScenario>): Gate<TArtifact, TScenario>;
|
|
1541
895
|
interface CampaignComparisonUnits {
|
|
1542
896
|
pairedCellN: number;
|
|
1543
897
|
unitIds: string[];
|
|
@@ -1564,583 +918,683 @@ interface CampaignBreakdown {
|
|
|
1564
918
|
emitted?: string;
|
|
1565
919
|
}>;
|
|
1566
920
|
}
|
|
1567
|
-
/**
|
|
1568
|
-
*
|
|
1569
|
-
|
|
1570
|
-
interface
|
|
1571
|
-
/**
|
|
1572
|
-
|
|
1573
|
-
/**
|
|
1574
|
-
|
|
1575
|
-
/** Full sha256 content hash — byte-identical-verifiable. */
|
|
1576
|
-
contentHash: string;
|
|
1577
|
-
/** Exact scored rows that produced this candidate's search result. */
|
|
1578
|
-
campaignDigest: `sha256:${string}`;
|
|
1579
|
-
/** Proposer label, when the proposer returned a `ProposedCandidate`. */
|
|
1580
|
-
label?: string;
|
|
1581
|
-
/** Proposer rationale — the "because Z". When the proposer returned a bare
|
|
1582
|
-
* surface (blind mutator) this is absent. */
|
|
1583
|
-
rationale?: string;
|
|
1584
|
-
/** Proposer-supplied typed attribution, carried unchanged from
|
|
1585
|
-
* `GenerationCandidate.attribution`. Opaque here; the producer's schema tag
|
|
1586
|
-
* governs interpretation. */
|
|
1587
|
-
attribution?: Readonly<Record<string, unknown>>;
|
|
1588
|
-
/** Whether the candidate completed every designed cell and could be selected. */
|
|
1589
|
-
eligibleForPromotion: boolean;
|
|
1590
|
-
/** Designed-denominator receipt retained even for incomplete candidates. */
|
|
1591
|
-
coverage: NonNullable<GenerationCandidate['coverage']>;
|
|
1592
|
-
/** Mean composite this candidate scored on the search split, or null when unscorable. */
|
|
1593
|
-
composite: number | null;
|
|
1594
|
-
/** Whether this candidate was promoted out of its generation. */
|
|
1595
|
-
promoted: boolean;
|
|
1596
|
-
}
|
|
1597
|
-
interface LoopProvenanceBackend {
|
|
1598
|
-
/** `assertRealBackend`-grade verdict over the worker call records. */
|
|
1599
|
-
verdict: 'real' | 'mixed' | 'stub';
|
|
1600
|
-
/** Number of worker LLM calls captured (the audit's "worker call count"). */
|
|
1601
|
-
workerCallCount: number;
|
|
1602
|
-
/** Distinct model ids observed across worker calls. */
|
|
1603
|
-
models: string[];
|
|
1604
|
-
totalInputTokens: number;
|
|
1605
|
-
totalOutputTokens: number;
|
|
1606
|
-
totalCostUsd: number;
|
|
1607
|
-
}
|
|
1608
|
-
interface LoopProvenanceEvidence {
|
|
1609
|
-
search: {
|
|
1610
|
-
splitDigest: `sha256:${string}`;
|
|
1611
|
-
baselineCampaignDigest: `sha256:${string}`;
|
|
1612
|
-
};
|
|
1613
|
-
holdout: {
|
|
1614
|
-
splitDigest: `sha256:${string}`;
|
|
1615
|
-
baselineCampaignDigest: `sha256:${string}`;
|
|
1616
|
-
winnerCampaignDigest: `sha256:${string}`;
|
|
1617
|
-
observations?: CampaignComparisonUnits;
|
|
1618
|
-
neutralized?: {
|
|
1619
|
-
contentHash: `sha256:${string}`;
|
|
1620
|
-
campaignDigest: `sha256:${string}`;
|
|
1621
|
-
composite: number;
|
|
1622
|
-
lift: number;
|
|
1623
|
-
};
|
|
1624
|
-
};
|
|
1625
|
-
costReceiptsDigest: `sha256:${string}`;
|
|
1626
|
-
}
|
|
1627
|
-
interface LoopProvenanceOptimizationMethod {
|
|
1628
|
-
name: string;
|
|
1629
|
-
cost: ComparisonCost;
|
|
1630
|
-
durationMs?: number;
|
|
1631
|
-
provenance?: OptimizationMethodProvenance;
|
|
1632
|
-
}
|
|
1633
|
-
/**
|
|
1634
|
-
* The durable provenance record: the baseline and winner measurements, the
|
|
1635
|
-
* rationale, the explicit baseline→candidate diff, and backend provenance.
|
|
1636
|
-
*/
|
|
1637
|
-
interface LoopProvenanceRecord {
|
|
1638
|
-
schema: 'tangle.loop-provenance';
|
|
1639
|
-
/** SHA-256 over the canonical record with this field omitted. */
|
|
1640
|
-
recordDigest: `sha256:${string}`;
|
|
1641
|
-
runId: string;
|
|
1642
|
-
runDir: string;
|
|
1643
|
-
timestamp: string;
|
|
1644
|
-
/** Baseline + winner surface content hashes — distinguishable, byte-verifiable. */
|
|
1645
|
-
baselineContentHash: string;
|
|
1646
|
-
winnerContentHash: string;
|
|
1647
|
-
/** Proposer label/rationale for the promoted change. Absent ⇒ winner == baseline. */
|
|
1648
|
-
winnerLabel?: string;
|
|
1649
|
-
winnerRationale?: string;
|
|
1650
|
-
/** The explicit baseline→winner unified diff the gate decided on. */
|
|
1651
|
-
diff: string;
|
|
1652
|
-
/** Every candidate across every generation, with its rationale and structured cause. */
|
|
1653
|
-
candidates: LoopProvenanceCandidate[];
|
|
1654
|
-
/** Complete external method identity and spend, when one authored the candidate. */
|
|
1655
|
-
optimizationMethod?: LoopProvenanceOptimizationMethod;
|
|
1656
|
-
/** Exact campaign, split, surface, and receipt identities behind every summary. */
|
|
1657
|
-
evidence: LoopProvenanceEvidence;
|
|
1658
|
-
/** Baseline composite on the search split that generated the candidates. */
|
|
1659
|
-
baselineSearchComposite: number;
|
|
1660
|
-
claim?: EvaluationClaim;
|
|
1661
|
-
/** The gate verdict — decision + reasons + contributing gates + delta. */
|
|
1662
|
-
gate: {
|
|
1663
|
-
decision: GateDecision;
|
|
1664
|
-
reasons: string[];
|
|
1665
|
-
delta?: number;
|
|
1666
|
-
contributingGates: GateContribution[];
|
|
1667
|
-
};
|
|
1668
|
-
/** Present iff the loop ran with `holdout: 'deferred'` — the held-out
|
|
1669
|
-
* comparison was intentionally not measured in this run, so the holdout
|
|
1670
|
-
* composites and `heldOutLift` are ABSENT rather than recorded as a
|
|
1671
|
-
* meaningless 0. */
|
|
1672
|
-
holdout?: 'deferred';
|
|
1673
|
-
/** baseline-on-holdout composite mean. Absent when `holdout === 'deferred'`. */
|
|
1674
|
-
baselineHoldoutComposite?: number;
|
|
1675
|
-
/** winner-on-holdout composite mean. Absent when `holdout === 'deferred'`. */
|
|
1676
|
-
winnerHoldoutComposite?: number;
|
|
1677
|
-
/** winnerHoldout - baselineHoldout — RECOMPUTABLE from this record. Absent
|
|
1678
|
-
* when `holdout === 'deferred'` (no held-out measurement ran). */
|
|
1679
|
-
heldOutLift?: number;
|
|
1680
|
-
/** Backend provenance: stub-vs-real verdict + worker call count + models. */
|
|
1681
|
-
backend: LoopProvenanceBackend;
|
|
1682
|
-
totalCostUsd: number;
|
|
1683
|
-
totalDurationMs: number;
|
|
1684
|
-
}
|
|
1685
|
-
interface BuildLoopProvenanceArgs<TArtifact, TScenario extends Scenario> {
|
|
1686
|
-
runId: string;
|
|
1687
|
-
runDir: string;
|
|
1688
|
-
timestamp: string;
|
|
1689
|
-
baselineSurface: MutableSurface;
|
|
1690
|
-
winnerSurface: MutableSurface;
|
|
1691
|
-
winnerLabel?: string;
|
|
1692
|
-
winnerRationale?: string;
|
|
1693
|
-
/** Exact baseline campaign on the search split. */
|
|
1694
|
-
baselineSearchCampaign: CampaignResult<TArtifact, TScenario>;
|
|
1695
|
-
/** Per-generation candidate records straight off the loop result. */
|
|
1696
|
-
generations: Array<{
|
|
1697
|
-
generationIndex: number;
|
|
1698
|
-
candidates: GenerationCandidate[];
|
|
1699
|
-
promoted: string[];
|
|
1700
|
-
/** Surfaces measured this generation, keyed by surface hash so the content
|
|
1701
|
-
* hash can be computed and the loop identity rechecked from real bytes. */
|
|
1702
|
-
surfaces: Array<{
|
|
1703
|
-
surfaceHash: string;
|
|
1704
|
-
surface: MutableSurface;
|
|
1705
|
-
campaign: CampaignResult<TArtifact, TScenario>;
|
|
1706
|
-
}>;
|
|
1707
|
-
}>;
|
|
1708
|
-
gate: GateResult;
|
|
1709
|
-
/** Holdout policy the loop ran with. `'deferred'` ⇒ the holdout campaigns
|
|
1710
|
-
* below are the shared empty campaign and the record omits the holdout
|
|
1711
|
-
* composites + `heldOutLift`. Default `'measured'`. */
|
|
1712
|
-
holdout?: 'measured' | 'deferred';
|
|
1713
|
-
baselineOnHoldout: CampaignResult<TArtifact, TScenario>;
|
|
1714
|
-
winnerOnHoldout: CampaignResult<TArtifact, TScenario>;
|
|
1715
|
-
claim?: EvaluationClaim;
|
|
1716
|
-
/** Required with a measured claim because campaign identities redact source fields. */
|
|
1717
|
-
independentUnitByScenarioId?: ReadonlyMap<string, string>;
|
|
1718
|
-
neutralizedSurface?: MutableSurface;
|
|
1719
|
-
neutralizedOnHoldout?: CampaignResult<TArtifact, TScenario>;
|
|
1720
|
-
/** Settled run-wide receipts — agent calls are the source for backend provenance. */
|
|
1721
|
-
costReceipts: ReadonlyArray<CostReceipt>;
|
|
1722
|
-
totalCostUsd: number;
|
|
1723
|
-
totalDurationMs: number;
|
|
1724
|
-
optimizationMethod?: LoopProvenanceOptimizationMethod;
|
|
1725
|
-
}
|
|
1726
|
-
interface LoopProvenanceArgsFromResult<TArtifact, TScenario extends Scenario> {
|
|
1727
|
-
runId: string;
|
|
1728
|
-
runDir: string;
|
|
1729
|
-
timestamp: string;
|
|
1730
|
-
baselineSurface: MutableSurface;
|
|
1731
|
-
result: RunImprovementLoopResult<TArtifact, TScenario>;
|
|
1732
|
-
costReceipts: ReadonlyArray<CostReceipt>;
|
|
1733
|
-
totalCostUsd: number;
|
|
1734
|
-
totalDurationMs: number;
|
|
1735
|
-
independentUnitByScenarioId?: ReadonlyMap<string, string>;
|
|
1736
|
-
}
|
|
1737
|
-
/** SHA-256 over the RFC 8785 canonical JSON of `value`. Throws
|
|
1738
|
-
* `LedgerCanonicalizationError` for a value with no canonical form. */
|
|
1739
|
-
declare function canonicalDigest(value: unknown): `sha256:${string}`;
|
|
1740
|
-
interface EmitLoopProvenanceResult {
|
|
1741
|
-
record: LoopProvenanceRecord;
|
|
1742
|
-
spans: TraceSpanEvent[];
|
|
1743
|
-
/** Absolute paths the record + spans were written to, when storage persists. */
|
|
1744
|
-
recordPath: string;
|
|
1745
|
-
spansPath: string;
|
|
1746
|
-
}
|
|
1747
|
-
interface EmitLoopProvenanceArgs<TArtifact, TScenario extends Scenario> extends BuildLoopProvenanceArgs<TArtifact, TScenario> {
|
|
1748
|
-
/** Storage the record + spans are written through. */
|
|
1749
|
-
storage: CampaignStorage;
|
|
1750
|
-
/** When set, the spans are also shipped to the hosted `/v1/ingest/traces`
|
|
1751
|
-
* endpoint so the collector receives the full loop, not just `cost.*`. */
|
|
1752
|
-
hostedClient?: HostedClient;
|
|
1753
|
-
}
|
|
1754
|
-
/**
|
|
1755
|
-
* Build the provenance record + OTel spans and persist them durably under the
|
|
1756
|
-
* run dir (and ship spans to a hosted collector when one is wired). Returns
|
|
1757
|
-
* both artifacts so the caller can assert on / re-derive from them.
|
|
1758
|
-
*
|
|
1759
|
-
* Fail-loud: the durable write throws on storage failure (a swallowed write is
|
|
1760
|
-
* exactly the "emitted but lost" failure this closes). The hosted span ship is
|
|
1761
|
-
* the one best-effort leg — its failure is logged, not thrown, so an offline
|
|
1762
|
-
* collector never fails the loop (the durable artifact is the source of truth).
|
|
1763
|
-
*/
|
|
1764
|
-
declare function emitLoopProvenance<TArtifact, TScenario extends Scenario>(args: EmitLoopProvenanceArgs<TArtifact, TScenario>): Promise<EmitLoopProvenanceResult>;
|
|
1765
|
-
interface TraceAnalystScenario extends Scenario {
|
|
1766
|
-
kind: 'trace-analyst';
|
|
1767
|
-
traceStore: TraceAnalysisStore;
|
|
1768
|
-
labelState: AnalystBenchmarkLabelState;
|
|
1769
|
-
expectedIssues: readonly AnalystIssueExpectation[];
|
|
1770
|
-
labeledEvidence?: AnalystBenchmarkCase['labeledEvidence'];
|
|
1771
|
-
}
|
|
1772
|
-
interface TraceAnalystArtifact {
|
|
1773
|
-
findings: readonly AnalystFinding[];
|
|
1774
|
-
usage?: AnalystUsageReceipt;
|
|
1775
|
-
run?: AnalystRunResult;
|
|
1776
|
-
}
|
|
1777
|
-
interface BuildTraceAnalystSurfaceDispatchOptions {
|
|
1778
|
-
analyze(input: {
|
|
1779
|
-
instructions: string;
|
|
1780
|
-
traceStore: TraceAnalysisStore;
|
|
1781
|
-
runId: string;
|
|
1782
|
-
signal: AbortSignal;
|
|
1783
|
-
}): Promise<TraceAnalystArtifact>;
|
|
921
|
+
/** How a caller describes a non-string artifact to an optimizer. The same hook
|
|
922
|
+
* serves the native reflective path and the GEPA and SkillOpt callbacks. */
|
|
923
|
+
type DescribeArtifact<TArtifact, TScenario extends Scenario> = (artifact: TArtifact, scenario: TScenario) => unknown;
|
|
924
|
+
interface ArtifactEvidenceOptions<TArtifact, TScenario extends Scenario> {
|
|
925
|
+
/** Describes a non-string artifact. Without it, a non-string artifact shows nothing. */
|
|
926
|
+
describeArtifact?: DescribeArtifact<TArtifact, TScenario>;
|
|
927
|
+
/** The scenarios the campaign ran, which `describeArtifact` receives. Required with it. */
|
|
928
|
+
scenarios?: readonly TScenario[];
|
|
1784
929
|
}
|
|
1785
|
-
/**
|
|
1786
|
-
*
|
|
1787
|
-
*
|
|
1788
|
-
|
|
1789
|
-
*/
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
usage: CostUsage & {
|
|
1802
|
-
usageUnknown?: boolean;
|
|
1803
|
-
};
|
|
1804
|
-
};
|
|
1805
|
-
signal?: AbortSignal;
|
|
1806
|
-
}): Promise<CostBreakdown>;
|
|
1807
|
-
/** Whether one candidate attempt produced a usable executable outcome. */
|
|
1808
|
-
type CrossSurfaceAttemptCompleteness = 'complete' | 'missing' | 'invalid';
|
|
1809
|
-
/** One independently proposed change on one caller-defined surface. */
|
|
1810
|
-
interface CrossSurfaceComponent {
|
|
1811
|
-
componentId: string;
|
|
1812
|
-
surfaceId: string;
|
|
1813
|
-
/** Explicitly controls whether this component may anchor the best-single arm. */
|
|
1814
|
-
bestSingleEligible: boolean;
|
|
930
|
+
/** Per-candidate evidence a reflective/patch proposer grounds its next proposal
|
|
931
|
+
* on: mean score per judge dimension + per-scenario composite, notes and the
|
|
932
|
+
* scenario's evidence (`campaignEvidence`) as text. */
|
|
933
|
+
declare function campaignBreakdown<TArtifact, TScenario extends Scenario>(campaign: CampaignResult<TArtifact, TScenario>, options?: ArtifactEvidenceOptions<TArtifact, TScenario>): CampaignBreakdown;
|
|
934
|
+
/** Shared campaign settings applied to every optimization method. */
|
|
935
|
+
type OptimizationMethodRunOptions<TScenario extends Scenario, TArtifact> = Omit<RunCampaignOptions<TScenario, TArtifact>, 'costCeiling' | 'costLedger' | 'dispatch' | 'judges' | 'runDir' | 'scenarios' | 'seed'>;
|
|
936
|
+
interface OptimizationPackageSource {
|
|
937
|
+
kind: 'package';
|
|
938
|
+
/** Whether package identity was inspected or supplied by caller code. */
|
|
939
|
+
evidence: 'observed' | 'declared';
|
|
940
|
+
package: string;
|
|
941
|
+
version: string;
|
|
942
|
+
sourceUrl?: string;
|
|
943
|
+
revision?: string;
|
|
944
|
+
/** SHA-256 of all installed module files observed before the run. */
|
|
945
|
+
sourceSha256?: string;
|
|
1815
946
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
componentIds: string[];
|
|
1820
|
-
contentHash: string;
|
|
1821
|
-
artifactBytes: number;
|
|
947
|
+
interface OptimizationModuleSource {
|
|
948
|
+
module: string;
|
|
949
|
+
sourceSha256: string;
|
|
1822
950
|
}
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
/** null means the trace could not establish whether the component fired. */
|
|
1827
|
-
fired: boolean | null;
|
|
1828
|
-
/** null means the trace could not establish whether the component changed behavior. */
|
|
1829
|
-
effectObserved: boolean | null;
|
|
951
|
+
interface OptimizationPythonRuntime {
|
|
952
|
+
implementation: string;
|
|
953
|
+
version: string;
|
|
1830
954
|
}
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
955
|
+
interface OptimizationMethodProvenance {
|
|
956
|
+
/** External optimizer package. */
|
|
957
|
+
source: OptimizationPackageSource;
|
|
958
|
+
/** Python bridge package that invoked the optimizer. */
|
|
959
|
+
bridge?: OptimizationPackageSource;
|
|
960
|
+
/** Custom engine modules imported by the optimizer. */
|
|
961
|
+
modules?: OptimizationModuleSource[];
|
|
962
|
+
/** Python implementation used by the bridge process. */
|
|
963
|
+
python?: OptimizationPythonRuntime;
|
|
964
|
+
/** Exact model identifier configured for optimizer-owned model calls. */
|
|
965
|
+
optimizerModel?: string;
|
|
966
|
+
/** Stable public identity of the execution-owner callback. */
|
|
967
|
+
optimizerCallRef?: string;
|
|
968
|
+
runId: string;
|
|
969
|
+
/** Content identity shared by compatible resumptions. */
|
|
970
|
+
compatibleRunId?: string;
|
|
971
|
+
resumed: boolean;
|
|
972
|
+
/** Whether the run seed reached every external engine configuration. */
|
|
973
|
+
seedApplied?: boolean;
|
|
974
|
+
/** Evaluations the local callback metered — the trusted count. */
|
|
975
|
+
evaluationCount: number;
|
|
1844
976
|
/**
|
|
1845
|
-
*
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
977
|
+
* Evaluation total the external optimizer reported from its own counters.
|
|
978
|
+
* A difference from `evaluationCount` means upstream skipped, cached, or
|
|
979
|
+
* double-counted work; inspect before trusting upstream-derived budgets.
|
|
1848
980
|
*/
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
interface CrossSurfaceSelectionPolicy {
|
|
1861
|
-
minimumFiringTasks: number;
|
|
1862
|
-
minimumEffectTasks: number;
|
|
1863
|
-
requireObservedFiring: boolean;
|
|
1864
|
-
requireObservedEffect: boolean;
|
|
1865
|
-
/** Only named metrics are constrained; all declared metrics are still reported. */
|
|
1866
|
-
maximumMedianCostRatioToBaseline: Record<string, number>;
|
|
1867
|
-
/** A smaller terminal bundle is reported but cannot become the selected arm. */
|
|
1868
|
-
minimumBundleComponents: number;
|
|
981
|
+
upstreamReportedEvaluations?: number;
|
|
982
|
+
artifactDir: string;
|
|
983
|
+
tokenUsage?: OptimizationTokenUsage;
|
|
984
|
+
/** Candidates submitted to the callback, per-case scores, and refusals. */
|
|
985
|
+
observations?: ExternalOptimizerObservationSummary;
|
|
986
|
+
/** Exact accepted GEPA candidates, parent indices, and selection scores. */
|
|
987
|
+
gepaCandidatePopulation?: GepaCandidatePopulationSummary;
|
|
988
|
+
/** Opaque Runtime execution evidence for every invoked optimizer-model call. */
|
|
989
|
+
modelExecutions?: ExternalOptimizerExecutionSummary;
|
|
990
|
+
/** Anthropic-endpoint proxy traffic from agent CLI engines, when enabled. */
|
|
991
|
+
anthropicEndpoint?: ExternalOptimizerWireCounts;
|
|
1869
992
|
}
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
993
|
+
/** Shared inputs for one optimization method. Final test data is absent. */
|
|
994
|
+
interface OptimizationMethodInput<TScenario extends Scenario, TArtifact> {
|
|
995
|
+
/** Surface every method starts from. */
|
|
996
|
+
readonly baselineSurface: MutableSurface;
|
|
997
|
+
/** Evidence used to author or fit candidates. */
|
|
998
|
+
readonly trainScenarios: readonly TScenario[];
|
|
999
|
+
/** Data used for candidate acceptance, early stopping, and model selection. */
|
|
1000
|
+
readonly selectionScenarios: readonly TScenario[];
|
|
1001
|
+
/** Runs one scenario with a candidate surface. */
|
|
1002
|
+
readonly dispatchWithSurface: (surface: MutableSurface, scenario: TScenario, ctx: DispatchContext) => Promise<TArtifact>;
|
|
1003
|
+
/** Scores artifacts produced by `dispatchWithSurface`. */
|
|
1004
|
+
readonly judges: readonly JudgeConfig<TArtifact, TScenario>[];
|
|
1005
|
+
/**
|
|
1006
|
+
* How the caller shows a non-string artifact to the method's optimizer, the
|
|
1007
|
+
* same for every method. The GEPA, SkillOpt and external-text methods send
|
|
1008
|
+
* it as each evaluation's evidence and refuse a different hook configured on
|
|
1009
|
+
* the method itself; a custom method forwards it to `runOptimization`.
|
|
1010
|
+
*/
|
|
1011
|
+
readonly describeArtifact?: DescribeArtifact<TArtifact, TScenario>;
|
|
1012
|
+
/** Method-specific artifacts are written below this directory. */
|
|
1013
|
+
readonly runDir: string;
|
|
1014
|
+
readonly seed: number;
|
|
1015
|
+
/** Shared defaults for every method. A method may override them explicitly. */
|
|
1016
|
+
readonly runOptions: Readonly<OptimizationMethodRunOptions<TScenario, TArtifact>>;
|
|
1017
|
+
/** Durable spend account shared by every method and final scoring. */
|
|
1018
|
+
readonly costLedger: CostLedgerHandle;
|
|
1019
|
+
/** Invokes each method at the shared execution boundary, including composed children. */
|
|
1020
|
+
invokeMethod?(method: OptimizationMethod<TScenario, TArtifact>, input: OptimizationMethodInput<TScenario, TArtifact>): Promise<OptimizationMethodResult>;
|
|
1021
|
+
/** Maps this method's local surface into the complete outer candidate. */
|
|
1022
|
+
readonly surfaceToRoot?: (surface: MutableSurface) => MutableSurface;
|
|
1885
1023
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1024
|
+
/** Exact child results; costs and usage remain attributable to their owning methods. */
|
|
1025
|
+
interface OptimizationMethodComposition {
|
|
1026
|
+
kind: 'scoped' | 'sequential';
|
|
1027
|
+
baselineSurfaceHash: string;
|
|
1028
|
+
stages: Array<{
|
|
1029
|
+
name: string;
|
|
1030
|
+
baselineSurfaceHash: string;
|
|
1031
|
+
result: OptimizationMethodResult;
|
|
1032
|
+
}>;
|
|
1893
1033
|
}
|
|
1894
|
-
interface
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1034
|
+
interface OptimizationMethodResult {
|
|
1035
|
+
/** Surface selected without using the final test partition. */
|
|
1036
|
+
winnerSurface: MutableSurface;
|
|
1037
|
+
composition?: OptimizationMethodComposition;
|
|
1038
|
+
/** Optimization spend. Excludes final test scoring. */
|
|
1039
|
+
cost: ComparisonCost;
|
|
1040
|
+
/** Optimization duration. Excludes final test scoring. */
|
|
1041
|
+
durationMs?: number;
|
|
1042
|
+
/** Exact external implementation and run identity, when the method uses one. */
|
|
1043
|
+
provenance?: OptimizationMethodProvenance;
|
|
1044
|
+
/** Bounded proof envelope over the canonical SearchLedger for this optimization. */
|
|
1045
|
+
searchHistory?: SearchHistoryReceipt;
|
|
1899
1046
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
unobservedTaskIds: string[];
|
|
1047
|
+
/** A complete optimization method, including candidate generation and selection. */
|
|
1048
|
+
interface OptimizationMethod<TScenario extends Scenario = Scenario, TArtifact = unknown> {
|
|
1049
|
+
/** Unique, trimmed display name. Its normalized form must also be unique. */
|
|
1050
|
+
name: string;
|
|
1051
|
+
optimize: (input: OptimizationMethodInput<TScenario, TArtifact>) => Promise<OptimizationMethodResult>;
|
|
1906
1052
|
}
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
reasons: CrossSurfaceIneligibilityReason[];
|
|
1053
|
+
interface ExternalOptimizationExample {
|
|
1054
|
+
id: string;
|
|
1055
|
+
data: unknown;
|
|
1911
1056
|
}
|
|
1912
|
-
interface
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1057
|
+
interface ExternalTextEvaluationResponse {
|
|
1058
|
+
score: number;
|
|
1059
|
+
info: {
|
|
1060
|
+
scenarioId: string;
|
|
1061
|
+
dimensions: Record<string, number>;
|
|
1062
|
+
/** Higher-is-better objectives consumed by GEPA hybrid/Pareto selection. */
|
|
1063
|
+
scores?: Record<string, number>;
|
|
1064
|
+
notes?: string;
|
|
1065
|
+
artifact?: unknown;
|
|
1066
|
+
/** The optimizer score is a finite protocol value; Eval remains the
|
|
1067
|
+
* authority for whether the underlying cell actually produced a score. */
|
|
1068
|
+
status?: 'scored' | 'failed';
|
|
1069
|
+
error?: {
|
|
1070
|
+
stage: 'dispatch' | 'judge' | 'unknown';
|
|
1071
|
+
message: string;
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1921
1074
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1075
|
+
declare function decodeExternalTextCandidate(candidate: ExternalTextCandidate): MutableSurface;
|
|
1076
|
+
interface ExternalTextOptimizerContext {
|
|
1077
|
+
readonly runId: string;
|
|
1078
|
+
readonly name: string;
|
|
1079
|
+
readonly objective: string;
|
|
1080
|
+
readonly evaluationId: string;
|
|
1081
|
+
readonly background?: string;
|
|
1082
|
+
readonly seedCandidate: ExternalTextCandidate;
|
|
1083
|
+
readonly trainSet: readonly ExternalOptimizationExample[];
|
|
1084
|
+
readonly selectionSet: readonly ExternalOptimizationExample[];
|
|
1085
|
+
readonly maxEvaluations: number;
|
|
1086
|
+
readonly seed: number;
|
|
1087
|
+
/** Stable directory for optimizer checkpoints from compatible attempts. */
|
|
1088
|
+
readonly stateDir: string;
|
|
1089
|
+
readonly restoreRequested: boolean;
|
|
1090
|
+
readonly artifactDir: string;
|
|
1091
|
+
readonly signal: AbortSignal;
|
|
1092
|
+
/** Record every optimizer-owned paid call through this attributed account. */
|
|
1093
|
+
readonly cost: CampaignCostMeter;
|
|
1094
|
+
readonly evaluate: (request: ExternalTextEvaluationRequest) => Promise<ExternalTextEvaluationResponse>;
|
|
1933
1095
|
}
|
|
1934
|
-
interface
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1096
|
+
interface ExternalTextOptimizerResult {
|
|
1097
|
+
bestCandidate: ExternalTextCandidate;
|
|
1098
|
+
resumed: boolean;
|
|
1099
|
+
costAccounting: {
|
|
1100
|
+
kind: 'metered';
|
|
1101
|
+
} | {
|
|
1102
|
+
kind: 'no-paid-work';
|
|
1103
|
+
} | {
|
|
1104
|
+
kind: 'external';
|
|
1105
|
+
reason: string;
|
|
1106
|
+
};
|
|
1940
1107
|
}
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1108
|
+
/**
|
|
1109
|
+
* Configuration for adapting another text optimizer.
|
|
1110
|
+
*
|
|
1111
|
+
* `run` owns search. Agent Eval owns split isolation, bounded candidate
|
|
1112
|
+
* evaluation, exact cost collection, provenance, and final comparison.
|
|
1113
|
+
*/
|
|
1114
|
+
interface ExternalTextOptimizationMethodConfig<TScenario extends Scenario, TArtifact = unknown> {
|
|
1115
|
+
name: string;
|
|
1116
|
+
source: Omit<OptimizationPackageSource, 'evidence'>;
|
|
1117
|
+
objective: string;
|
|
1118
|
+
evaluationId: string;
|
|
1119
|
+
background?: string;
|
|
1120
|
+
maxEvaluations: number;
|
|
1121
|
+
/** Hard limit for calls made through `context.cost`. Use 0 for no paid work. */
|
|
1122
|
+
maxOptimizerCostUsd: number;
|
|
1123
|
+
/** Abort `context.signal` after this duration. Default: 30 minutes. */
|
|
1124
|
+
timeoutMs?: number;
|
|
1125
|
+
/** Default: `never`. Compatible runs reuse one state directory. */
|
|
1126
|
+
resume?: ExternalOptimizerResumeMode;
|
|
1127
|
+
maxCandidateChars?: number;
|
|
1128
|
+
maxEvidenceChars?: number;
|
|
1129
|
+
describeScenario?: (scenario: TScenario) => unknown;
|
|
1130
|
+
describeArtifact?: (artifact: TArtifact, scenario: TScenario) => unknown;
|
|
1131
|
+
run: (context: ExternalTextOptimizerContext) => Promise<ExternalTextOptimizerResult>;
|
|
1949
1132
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1133
|
+
/**
|
|
1134
|
+
* Adapt a third-party text optimizer without reimplementing its search.
|
|
1135
|
+
*
|
|
1136
|
+
* The callback never receives final test cases. Calls to `evaluate` are
|
|
1137
|
+
* counted before execution and stop at `maxEvaluations`.
|
|
1138
|
+
*/
|
|
1139
|
+
declare function externalTextOptimizationMethod<TScenario extends Scenario, TArtifact>(config: ExternalTextOptimizationMethodConfig<TScenario, TArtifact>): OptimizationMethod<TScenario, TArtifact>;
|
|
1140
|
+
type EvalFixtureValidationMode = 'vitest' | 'none';
|
|
1141
|
+
interface EvalFixtureFile {
|
|
1142
|
+
path: string;
|
|
1143
|
+
sha256: string;
|
|
1144
|
+
bytes: number;
|
|
1956
1145
|
}
|
|
1957
|
-
interface
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1146
|
+
interface EvalFixture {
|
|
1147
|
+
name: string;
|
|
1148
|
+
path: string;
|
|
1149
|
+
promptPath: string;
|
|
1150
|
+
evalPath?: string;
|
|
1151
|
+
packageJsonPath?: string;
|
|
1152
|
+
prompt: string;
|
|
1153
|
+
files: EvalFixtureFile[];
|
|
1154
|
+
fingerprint: string;
|
|
1962
1155
|
}
|
|
1963
|
-
interface
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1156
|
+
interface EvalFixtureScenario extends Scenario {
|
|
1157
|
+
kind: 'eval-fixture';
|
|
1158
|
+
fixtureName: string;
|
|
1159
|
+
fixturePath: string;
|
|
1160
|
+
promptPath: string;
|
|
1161
|
+
evalPath?: string;
|
|
1162
|
+
packageJsonPath?: string;
|
|
1163
|
+
prompt: string;
|
|
1164
|
+
fingerprint: string;
|
|
1971
1165
|
}
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1166
|
+
interface EvalFixtureLoadOptions {
|
|
1167
|
+
/** `vitest` requires EVAL.ts/EVAL.tsx and package.json type=module. `none` only requires PROMPT.md. */
|
|
1168
|
+
validation?: EvalFixtureValidationMode;
|
|
1169
|
+
/** Extra caller-owned knobs that affect fixture behavior, folded into the fingerprint. */
|
|
1170
|
+
fingerprintConfig?: unknown;
|
|
1977
1171
|
}
|
|
1978
|
-
interface
|
|
1979
|
-
|
|
1980
|
-
singleCandidateIds: [string, string];
|
|
1981
|
-
compositionCandidateId: string;
|
|
1982
|
-
benefitTaskIds: string[];
|
|
1983
|
-
regressionTaskIds: string[];
|
|
1984
|
-
synergyTaskIds: string[];
|
|
1985
|
-
interferenceTaskIds: string[];
|
|
1986
|
-
incrementalVsConstituents: [CrossSurfaceCandidateComparison, CrossSurfaceCandidateComparison];
|
|
1987
|
-
relativeCostToBaseline: Record<string, CrossSurfaceRelativeCost>;
|
|
1988
|
-
firing: CrossSurfacePairEvidence;
|
|
1989
|
-
effect: CrossSurfacePairEvidence;
|
|
1990
|
-
interaction: CrossSurfaceInteractionEffect;
|
|
1991
|
-
compatibility: CrossSurfacePairCompatibility;
|
|
1172
|
+
interface LoadEvalFixtureScenariosOptions extends EvalFixtureLoadOptions {
|
|
1173
|
+
names?: string[];
|
|
1992
1174
|
}
|
|
1993
|
-
interface
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1175
|
+
interface PlanEvalFixtureRunOptions<TArtifact = unknown> extends Pick<PlanCampaignRunOptions<EvalFixtureScenario, TArtifact>, 'dispatchRef' | 'judges' | 'seed' | 'reps' | 'resumable' | 'runDir'> {
|
|
1176
|
+
evalsDir: string;
|
|
1177
|
+
validation?: EvalFixtureValidationMode;
|
|
1178
|
+
fingerprintConfig?: unknown;
|
|
1179
|
+
names?: string[];
|
|
1180
|
+
storage?: CampaignStorage;
|
|
1997
1181
|
}
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
1182
|
+
type EvalFixtureRunPlan = CampaignRunPlan & {
|
|
1183
|
+
fixtures: Array<Pick<EvalFixtureScenario, 'fixtureName' | 'fixturePath' | 'fingerprint'>>;
|
|
1184
|
+
};
|
|
1185
|
+
/** Walk `evalsDir` and return the relative name of every fixture directory (one containing an exact-case `PROMPT.md`). */
|
|
1186
|
+
declare function discoverEvalFixtures(evalsDir: string): string[];
|
|
1187
|
+
/**
|
|
1188
|
+
* Load ONE fixture by name: reads `PROMPT.md` (plus `EVAL.ts`/`EVAL.tsx` and `package.json` under
|
|
1189
|
+
* `vitest` validation) and content-fingerprints the full file set for cache identity.
|
|
1190
|
+
*/
|
|
1191
|
+
declare function loadEvalFixture(evalsDir: string, name: string, options?: EvalFixtureLoadOptions): EvalFixture;
|
|
1192
|
+
/** Load fixtures (all discovered, or just `names`) as campaign `Scenario`s tagged `eval-fixture`. */
|
|
1193
|
+
declare function loadEvalFixtureScenarios(evalsDir: string, options?: LoadEvalFixtureScenariosOptions): EvalFixtureScenario[];
|
|
1194
|
+
/**
|
|
1195
|
+
* Dry-run planner for a fixture campaign: loads the scenarios, delegates to `planCampaignRun`,
|
|
1196
|
+
* and returns the plan plus each fixture's name/path/fingerprint.
|
|
1197
|
+
*/
|
|
1198
|
+
declare function planEvalFixtureRun<TArtifact = unknown>(options: PlanEvalFixtureRunOptions<TArtifact>): EvalFixtureRunPlan;
|
|
1199
|
+
/** Compose gates — all must `ship` for the composite to `ship`. First
|
|
1200
|
+
* non-ship verdict short-circuits the composite verdict, but ALL gates run
|
|
1201
|
+
* (so the result records every gate's reason — useful for diagnostics). */
|
|
1202
|
+
declare function composeGate<TArtifact = unknown, TScenario extends Scenario = Scenario>(...gates: Array<Gate<TArtifact, TScenario>>): Gate<TArtifact, TScenario>;
|
|
1203
|
+
type CanaryKind = 'silent_judge_fallback' | 'judge_calibration_drift' | 'distribution_shift';
|
|
1204
|
+
type CanarySeverity = 'info' | 'warn' | 'error';
|
|
1205
|
+
interface CanaryAlert {
|
|
1206
|
+
kind: CanaryKind;
|
|
1207
|
+
severity: CanarySeverity;
|
|
1208
|
+
message: string;
|
|
1209
|
+
/** Numbers that informed the decision — drop straight into a
|
|
1210
|
+
* dashboard / paper figure. */
|
|
1211
|
+
evidence: Record<string, unknown>;
|
|
2002
1212
|
}
|
|
2003
|
-
interface
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
1213
|
+
interface CanaryReport {
|
|
1214
|
+
alerts: CanaryAlert[];
|
|
1215
|
+
/** Per-kind summary count. */
|
|
1216
|
+
counts: Record<CanaryKind, number>;
|
|
1217
|
+
/** Whether each enabled detector had enough observations to run. */
|
|
1218
|
+
evaluations: CanaryEvaluation[];
|
|
2007
1219
|
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
incrementalResolutionTaskIds: string[];
|
|
2014
|
-
incrementalRegressionTaskIds: string[];
|
|
2015
|
-
incrementalMedianCost: Record<string, number> | null;
|
|
2016
|
-
eligible: boolean;
|
|
2017
|
-
selected: boolean;
|
|
2018
|
-
reasons: CrossSurfaceAdditionRejectionReason[];
|
|
1220
|
+
interface CanaryEvaluation {
|
|
1221
|
+
kind: CanaryKind;
|
|
1222
|
+
status: 'evaluated' | 'not_evaluated';
|
|
1223
|
+
observations: number;
|
|
1224
|
+
reason?: string;
|
|
2019
1225
|
}
|
|
2020
|
-
interface
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
1226
|
+
interface CanaryOptions {
|
|
1227
|
+
/**
|
|
1228
|
+
* Silent-fallback detection.
|
|
1229
|
+
* - `constant`: confidence value treated as the fallback signal.
|
|
1230
|
+
* Default 0.30 (matches the soft-fail default in
|
|
1231
|
+
* `propose-review.ts`).
|
|
1232
|
+
* - `consecutiveThreshold`: trip the alert after this many
|
|
1233
|
+
* consecutive runs at `constant` (or `fallback === true`).
|
|
1234
|
+
* Default 3.
|
|
1235
|
+
*/
|
|
1236
|
+
silentFallback?: {
|
|
1237
|
+
constant?: number;
|
|
1238
|
+
consecutiveThreshold?: number;
|
|
1239
|
+
/** Floating-point tolerance when comparing against `constant`. */
|
|
1240
|
+
epsilon?: number;
|
|
1241
|
+
};
|
|
1242
|
+
/**
|
|
1243
|
+
* Calibration-drift detection.
|
|
1244
|
+
* - `historyWindow`: number of past runs (oldest-first) treated as
|
|
1245
|
+
* the historical baseline. Default 50.
|
|
1246
|
+
* - `recentWindow`: number of recent runs (newest-first) compared
|
|
1247
|
+
* against history. Default 20.
|
|
1248
|
+
* - `ksAlpha`: alpha for the KS statistic vs critical value.
|
|
1249
|
+
* Default 0.05.
|
|
1250
|
+
* - `minRecent`: minimum recent runs required to even attempt the
|
|
1251
|
+
* check. Default 10.
|
|
1252
|
+
*/
|
|
1253
|
+
calibrationDrift?: {
|
|
1254
|
+
historyWindow?: number;
|
|
1255
|
+
recentWindow?: number;
|
|
1256
|
+
ksAlpha?: number;
|
|
1257
|
+
minRecent?: number;
|
|
1258
|
+
};
|
|
1259
|
+
/**
|
|
1260
|
+
* Distribution-shift detection.
|
|
1261
|
+
* - `category`: function that maps a run to a categorical bucket.
|
|
1262
|
+
* Required to enable this canary; if omitted the chi-square check
|
|
1263
|
+
* is skipped entirely.
|
|
1264
|
+
* - `chiSquareAlpha`: alpha. Default 0.05.
|
|
1265
|
+
* - `historyWindow`, `recentWindow`, `minRecent`: like above.
|
|
1266
|
+
*/
|
|
1267
|
+
distributionShift?: {
|
|
1268
|
+
category: (run: RunRecord) => string | null;
|
|
1269
|
+
chiSquareAlpha?: number;
|
|
1270
|
+
historyWindow?: number;
|
|
1271
|
+
recentWindow?: number;
|
|
1272
|
+
minRecent?: number;
|
|
1273
|
+
};
|
|
2025
1274
|
}
|
|
2026
|
-
/**
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
1275
|
+
/**
|
|
1276
|
+
* Run all configured canaries against a chronological run list.
|
|
1277
|
+
* Runs MUST be sorted oldest-to-newest by the caller — the order of
|
|
1278
|
+
* the input is used to define "recent" vs "historical" windows.
|
|
1279
|
+
*/
|
|
1280
|
+
declare function runCanaries(runs: RunRecord[], opts?: CanaryOptions): CanaryReport;
|
|
1281
|
+
type RedTeamCategory = 'prompt_injection_direct' | 'prompt_injection_indirect' | 'jailbreak_persona' | 'jailbreak_dan' | 'pii_leak' | 'permission_escalation' | 'data_exfil' | 'policy_override';
|
|
1282
|
+
interface RedTeamPayload {
|
|
1283
|
+
category: RedTeamCategory;
|
|
1284
|
+
/** The hostile input the agent sees. */
|
|
1285
|
+
input: string;
|
|
1286
|
+
/**
|
|
1287
|
+
* What a safe agent should do: "refuse" means explicit refusal,
|
|
1288
|
+
* "ignore" means process benignly without executing the attack.
|
|
1289
|
+
*/
|
|
1290
|
+
expected: 'refuse' | 'ignore';
|
|
1291
|
+
/** Substring(s) that MUST NOT appear in output. */
|
|
1292
|
+
forbiddenStrings?: string[];
|
|
1293
|
+
/** Tool names the agent MUST NOT call for this scenario. */
|
|
1294
|
+
forbiddenTools?: string[];
|
|
2033
1295
|
}
|
|
2034
|
-
interface
|
|
2035
|
-
|
|
2036
|
-
seedCandidateId: string;
|
|
2037
|
-
/** Candidate reached by the winning path, even if the minimum size is not met. */
|
|
2038
|
-
terminalCandidateId: string;
|
|
2039
|
-
terminalComponentIds: string[];
|
|
2040
|
-
/** null when no path produced a qualifying multi-component bundle. */
|
|
2041
|
-
selectedCandidateId: string | null;
|
|
2042
|
-
qualified: boolean;
|
|
2043
|
-
/** Every compatible pair seed is retained so seed choice cannot hide an interaction. */
|
|
2044
|
-
evaluatedPaths: CrossSurfaceInteractionPath[];
|
|
2045
|
-
/** Convenience alias for the winning path's steps. */
|
|
2046
|
-
steps: CrossSurfaceCompositionStep[];
|
|
1296
|
+
interface RedTeamCase extends DatasetScenario {
|
|
1297
|
+
payload: RedTeamPayload;
|
|
2047
1298
|
}
|
|
2048
|
-
interface
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
1299
|
+
interface RedTeamFinding {
|
|
1300
|
+
scenarioId: string;
|
|
1301
|
+
category: RedTeamCategory;
|
|
1302
|
+
passed: boolean;
|
|
1303
|
+
reason: string;
|
|
1304
|
+
evidence?: string;
|
|
2052
1305
|
}
|
|
2053
|
-
interface
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
costMetrics: string[];
|
|
2058
|
-
/** Canonical candidate × task order; no input row is dropped. */
|
|
2059
|
-
rows: TRow[];
|
|
2060
|
-
missingAttempts: TRow[];
|
|
2061
|
-
invalidAttempts: TRow[];
|
|
2062
|
-
candidates: CrossSurfaceCandidateSummary[];
|
|
2063
|
-
pairwise: CrossSurfacePairwiseEntry[];
|
|
2064
|
-
selections: CrossSurfaceSelections;
|
|
1306
|
+
interface RedTeamReport {
|
|
1307
|
+
findings: RedTeamFinding[];
|
|
1308
|
+
passRateByCategory: Record<RedTeamCategory, number>;
|
|
1309
|
+
overallPassRate: number;
|
|
2065
1310
|
}
|
|
1311
|
+
/** Ship a canonical, small corpus. Consumers extend via `extendCorpus`. */
|
|
1312
|
+
declare const DEFAULT_RED_TEAM_CORPUS: RedTeamCase[];
|
|
1313
|
+
declare function redTeamDataset(extraCases?: RedTeamCase[]): Dataset;
|
|
2066
1314
|
/**
|
|
2067
|
-
*
|
|
2068
|
-
*
|
|
2069
|
-
* neither insertion order nor an after-the-fact tie-break can change a result.
|
|
1315
|
+
* Score a single agent response against the red-team case.
|
|
1316
|
+
* `toolCalls` should be the names of tools the agent invoked during the run.
|
|
2070
1317
|
*/
|
|
2071
|
-
declare function
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
1318
|
+
declare function scoreRedTeamOutput(output: string, toolCalls: string[], rtCase: RedTeamCase): RedTeamFinding;
|
|
1319
|
+
/** Aggregate red-team findings into per-category pass rates. */
|
|
1320
|
+
declare function redTeamReport(findings: RedTeamFinding[]): RedTeamReport;
|
|
1321
|
+
type DefaultProductionGateCheck = 'dimension-regression' | 'budget' | 'red-team' | 'reward-hacking' | 'canary';
|
|
1322
|
+
type DefaultProductionRewardHackingOptions = Omit<DetectRewardHackingInput, 'runs' | 'truthOf'> & {
|
|
1323
|
+
truthOf: NonNullable<DetectRewardHackingInput['truthOf']>;
|
|
1324
|
+
};
|
|
1325
|
+
interface DefaultProductionGateOptions {
|
|
1326
|
+
/** Required: scenarios held out from training; substrate compares
|
|
1327
|
+
* candidate-on-holdout vs baseline-on-holdout. */
|
|
1328
|
+
holdoutScenarios: Scenario[];
|
|
1329
|
+
/**
|
|
1330
|
+
* Independent sampling unit for every held-out scenario. Pair cells first,
|
|
1331
|
+
* then average scores within each unit and give units equal weight.
|
|
1332
|
+
* Omit only when execution cells on a fixed roster are the observation units.
|
|
1333
|
+
*/
|
|
1334
|
+
independentUnitByScenarioId?: ReadonlyMap<string, string>;
|
|
1335
|
+
/** Minimum held-out improvement under the shared paired decision rule.
|
|
1336
|
+
* Default 0. The outcome shape and sample count determine the statistical
|
|
1337
|
+
* test. Use native composite units, such as 2 for a 0-100 rubric. */
|
|
1338
|
+
deltaThreshold?: number;
|
|
1339
|
+
/** Confidence level for the held-out + dimension bootstraps. Default 0.95. */
|
|
1340
|
+
confidence?: number;
|
|
1341
|
+
/** Bootstrap resamples. Default 2000. */
|
|
1342
|
+
bootstrapResamples?: number;
|
|
1343
|
+
/** Fixed bootstrap seed for a deterministic verdict. Default 1337. */
|
|
1344
|
+
bootstrapSeed?: number;
|
|
1345
|
+
/** Minimum paired independent units (or cells when unconfigured) before a
|
|
1346
|
+
* significance claim is allowed. The exact small-sample test may require
|
|
1347
|
+
* more observations at the selected confidence. Default 3. */
|
|
1348
|
+
minProductiveRuns?: number;
|
|
1349
|
+
/** Ship statistic for the held-out significance test. Default `'mean'`
|
|
1350
|
+
* (tie-robust — see `heldoutSignificance`). Pass `'median'` for
|
|
1351
|
+
* outlier-robustness at the cost of tie-blindness. */
|
|
1352
|
+
heldoutStatistic?: 'mean' | 'median';
|
|
1353
|
+
/** Required judge dimensions checked for regression and complete evidence.
|
|
1354
|
+
* A bootstrap lower bound below negative tolerance or a paired test proving
|
|
1355
|
+
* a drop holds the gate. Thin or incomplete coverage is not_evaluated. */
|
|
1356
|
+
criticalDimensions?: string[];
|
|
1357
|
+
/** Tolerance for the per-dimension regression guard, in the dimension's
|
|
1358
|
+
* native scale. When omitted it auto-scales off observed magnitudes:
|
|
1359
|
+
* 0.05 on [0,1], 5 on 0-100. */
|
|
1360
|
+
regressionTolerance?: number;
|
|
1361
|
+
/** Total $ budget for the complete improvement run. Requires
|
|
1362
|
+
* `GateContext.costLedger`; missing or incomplete accounting holds. */
|
|
1363
|
+
budgetUsd?: number;
|
|
1364
|
+
/** Static artifact-screening cases. Only `expected: 'ignore'` cases without
|
|
1365
|
+
* tool assertions are valid because this check does not dispatch case inputs
|
|
1366
|
+
* or observe tool calls. */
|
|
1367
|
+
redTeamBattery?: RedTeamCase[];
|
|
1368
|
+
/** Shared run history, oldest first. Supplying history does not enable either
|
|
1369
|
+
* monitoring check; configure `rewardHacking` and/or `canary` explicitly. */
|
|
1370
|
+
recentRuns?: RunRecord[];
|
|
1371
|
+
/** Enable reward-hacking monitoring with a caller-owned independent truth channel. */
|
|
1372
|
+
rewardHacking?: DefaultProductionRewardHackingOptions;
|
|
1373
|
+
/** Enable canary monitoring. Pass `{}` to use the canary defaults. */
|
|
1374
|
+
canary?: CanaryOptions;
|
|
1375
|
+
/** Optional checks that must be evaluated even when their normal input is
|
|
1376
|
+
* absent. Configuring a check's input also makes that check required.
|
|
1377
|
+
* Missing evidence always records `not_evaluated`; required unevaluated
|
|
1378
|
+
* checks hold the release decision. Held-out significance is always required. */
|
|
1379
|
+
requiredChecks?: DefaultProductionGateCheck[];
|
|
2077
1380
|
}
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
1381
|
+
/**
|
|
1382
|
+
* Opinionated production gate composing held-out significance, red-team, reward-hacking, and canary checks into a single `Gate.decide` decision.
|
|
1383
|
+
*/
|
|
1384
|
+
declare function defaultProductionGate<TArtifact, TScenario extends Scenario>(options: DefaultProductionGateOptions): Gate<TArtifact, TScenario>;
|
|
1385
|
+
interface HeldOutGateOptions<TScenario extends Scenario = Scenario> {
|
|
1386
|
+
scenarios: TScenario[];
|
|
1387
|
+
/**
|
|
1388
|
+
* Independent unit for every held-out scenario, such as the historical run
|
|
1389
|
+
* a decision point was taken from. Cells pair first, then their scores are
|
|
1390
|
+
* averaged within each unit and every unit counts once. Omit only when each
|
|
1391
|
+
* execution cell is an independent observation. The gate copies the map
|
|
1392
|
+
* when it is built.
|
|
1393
|
+
*/
|
|
1394
|
+
independentUnitByScenarioId?: ReadonlyMap<string, string>;
|
|
1395
|
+
/** Effect-size threshold the CI lower bound must clear, in the judge's native
|
|
1396
|
+
* scale. Default 0.5. Equality holds; CI.low must be greater than this value. */
|
|
1397
|
+
deltaThreshold?: number;
|
|
1398
|
+
/** Bootstrap CI confidence. Default 0.95. */
|
|
1399
|
+
confidence?: number;
|
|
1400
|
+
/** Minimum paired independent units (or paired cells when no unit map is
|
|
1401
|
+
* supplied) to claim significance. The exact small-sample test may require
|
|
1402
|
+
* more observations at the selected confidence. Default 3. */
|
|
1403
|
+
minProductiveRuns?: number;
|
|
1404
|
+
/** Bootstrap resamples. Default 2000. */
|
|
1405
|
+
resamples?: number;
|
|
1406
|
+
/** Fixed bootstrap seed for deterministic verdicts. Default 1337. */
|
|
1407
|
+
bootstrapSeed?: number;
|
|
2087
1408
|
}
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
1409
|
+
/**
|
|
1410
|
+
* Composable held-out gate: ships only when the lower bound of the DECIDING
|
|
1411
|
+
* paired interval on the candidate-minus-baseline composite delta clears
|
|
1412
|
+
* `deltaThreshold` — Tango's score interval on a pass/fail holdout, the mean
|
|
1413
|
+
* bootstrap otherwise. See {@link decidePairedPromotion}.
|
|
1414
|
+
*/
|
|
1415
|
+
declare function heldOutGate<TArtifact, TScenario extends Scenario>(options: HeldOutGateOptions<TScenario>): Gate<TArtifact, TScenario>;
|
|
1416
|
+
interface NeutralizationGateOptions<TScenario extends Scenario = Scenario> {
|
|
1417
|
+
scenarios: TScenario[];
|
|
1418
|
+
/** Reject when the neutralized (content-blanked, footprint-matched) variant
|
|
1419
|
+
* reproduces at least this fraction of the candidate's held-out lift. Default
|
|
1420
|
+
* 0.5 — if blanking the content keeps half the lift, the content is decorative.
|
|
1421
|
+
* Equality rejects: a neutralized lift == threshold·candidateLift is decorative. */
|
|
1422
|
+
maxDecorativeFraction?: number;
|
|
2097
1423
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
1424
|
+
/**
|
|
1425
|
+
* Composable placebo gate: ships only when the candidate's held-out lift is NOT
|
|
1426
|
+
* mostly reproduced by a footprint-matched neutralized variant.
|
|
1427
|
+
*/
|
|
1428
|
+
declare function neutralizationGate<TArtifact, TScenario extends Scenario>(options: NeutralizationGateOptions<TScenario>): Gate<TArtifact, TScenario>;
|
|
1429
|
+
type OptimizerModelBudget = ExternalOptimizerModelBudget;
|
|
1430
|
+
/** One metered model path supplied by the package that owns execution. */
|
|
1431
|
+
interface OpenAICompatibleOptimizerModel {
|
|
1432
|
+
model: string;
|
|
1433
|
+
budget: OptimizerModelBudget;
|
|
1434
|
+
/** Caller-owned execution path, such as Runtime's exact AgentProfile adapter. */
|
|
1435
|
+
call: ExternalOptimizerModelCall;
|
|
1436
|
+
/** Stable public identity included in resumable-run compatibility. */
|
|
1437
|
+
callRef: string;
|
|
1438
|
+
/**
|
|
1439
|
+
* Served-model acceptance for every proxied call. Default `'exact'`, which
|
|
1440
|
+
* rejects any substitution with a 502 to the child.
|
|
1441
|
+
* `'allow-within-family'` accepts a different model of the same provider
|
|
1442
|
+
* family; it keeps family-level claims valid and forfeits per-model claims.
|
|
1443
|
+
*/
|
|
1444
|
+
servedModelPolicy?: ServedModelPolicy;
|
|
1445
|
+
/**
|
|
1446
|
+
* Also expose this metered model over the Anthropic Messages API
|
|
1447
|
+
* (`POST /v1/messages`) on the loopback proxy. Required for GEPA agent
|
|
1448
|
+
* engines that drive a `claude` CLI subprocess. Agent engines are chatty:
|
|
1449
|
+
* size `budget.maxRequests` for tens of calls per engine run. Default: false.
|
|
1450
|
+
*/
|
|
1451
|
+
anthropicEndpoint?: boolean;
|
|
2103
1452
|
}
|
|
2104
|
-
|
|
2105
|
-
|
|
1453
|
+
/** Shared settings for one bounded GEPA engine invocation. */
|
|
1454
|
+
interface GepaEngineOptions {
|
|
1455
|
+
/** GEPA engine name. GEPA validates names available in its Python runtime. */
|
|
1456
|
+
engine: string;
|
|
1457
|
+
/** Optional billed-USD stop. Omit when the execution owner reports USD as unknown. */
|
|
1458
|
+
maxProposerCostUsd?: number;
|
|
1459
|
+
/** Maximum concurrent evaluations inside this engine. Default: 1. */
|
|
1460
|
+
maxConcurrency?: number;
|
|
1461
|
+
/** Stop the engine after it reaches this score. */
|
|
1462
|
+
stopAtScore?: number;
|
|
1463
|
+
/** Isolate agent-based engines. Default: true. */
|
|
1464
|
+
sandbox?: boolean;
|
|
1465
|
+
/**
|
|
1466
|
+
* JSON-safe configuration for the registered GEPA engine.
|
|
1467
|
+
* Python callables and class instances cannot cross the process boundary.
|
|
1468
|
+
*/
|
|
1469
|
+
engineConfig?: Record<string, unknown>;
|
|
2106
1470
|
}
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
names?: string[];
|
|
2112
|
-
storage?: CampaignStorage;
|
|
1471
|
+
/** One independently budgeted GEPA engine invocation. */
|
|
1472
|
+
interface GepaEngineRun extends GepaEngineOptions {
|
|
1473
|
+
/** Maximum callback evaluations this engine may consume. */
|
|
1474
|
+
maxEvaluations: number;
|
|
2113
1475
|
}
|
|
2114
|
-
|
|
2115
|
-
|
|
1476
|
+
/** An engine in an adaptive run. All engines share the recipe evaluation limit. */
|
|
1477
|
+
type GepaAdaptiveEngineRun = GepaEngineOptions;
|
|
1478
|
+
/**
|
|
1479
|
+
* A direct mapping to a GEPA optimization recipe.
|
|
1480
|
+
*
|
|
1481
|
+
* GEPA owns every search and composition operation represented here. Tangle
|
|
1482
|
+
* supplies the candidate, data, execution callback, judges, and budgets.
|
|
1483
|
+
*/
|
|
1484
|
+
type GepaOptimizationRecipe = {
|
|
1485
|
+
kind: 'engine';
|
|
1486
|
+
run: GepaEngineRun;
|
|
1487
|
+
} | {
|
|
1488
|
+
kind: 'sequential';
|
|
1489
|
+
runs: readonly GepaEngineRun[];
|
|
1490
|
+
} | {
|
|
1491
|
+
kind: 'adaptive-sequential';
|
|
1492
|
+
runs: readonly GepaAdaptiveEngineRun[];
|
|
1493
|
+
/** One evaluation budget shared by every adaptive stage. */
|
|
1494
|
+
maxEvaluations: number;
|
|
1495
|
+
/** Switch engines after this many evaluations without improvement. */
|
|
1496
|
+
plateauEvaluations: number;
|
|
1497
|
+
patience?: number;
|
|
1498
|
+
minEvaluationsPerStage?: number;
|
|
1499
|
+
improvementEpsilon?: number;
|
|
1500
|
+
cycle?: boolean;
|
|
1501
|
+
maxSwitches?: number;
|
|
1502
|
+
maxConcurrency?: number;
|
|
1503
|
+
} | {
|
|
1504
|
+
kind: 'best-of';
|
|
1505
|
+
runs: readonly GepaEngineRun[];
|
|
1506
|
+
maxWorkers?: number;
|
|
1507
|
+
} | {
|
|
1508
|
+
kind: 'vote';
|
|
1509
|
+
runs: readonly GepaEngineRun[];
|
|
1510
|
+
maxWorkers?: number;
|
|
1511
|
+
} | {
|
|
1512
|
+
kind: 'omni';
|
|
1513
|
+
explore: readonly GepaEngineRun[];
|
|
1514
|
+
continueWith: GepaEngineRun;
|
|
1515
|
+
maxWorkers?: number;
|
|
2116
1516
|
};
|
|
2117
|
-
/**
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
*/
|
|
2123
|
-
|
|
2124
|
-
/**
|
|
2125
|
-
|
|
1517
|
+
/** The command that runs the Python GEPA bridge. */
|
|
1518
|
+
type GepaRunnerCommand = ExternalOptimizerRunnerCommand;
|
|
1519
|
+
interface GepaOptimizationMethodConfig<TScenario extends Scenario, TArtifact = unknown> {
|
|
1520
|
+
/** Unique comparison-method name. Default identifies the GEPA recipe. */
|
|
1521
|
+
name?: string;
|
|
1522
|
+
/** A direct GEPA recipe. */
|
|
1523
|
+
recipe: GepaOptimizationRecipe;
|
|
1524
|
+
/** Plain-language goal shown to the external optimizer. */
|
|
1525
|
+
objective: string;
|
|
1526
|
+
/** Stable identity for the dispatch, judges, model settings, and scoring logic. */
|
|
1527
|
+
evaluationId: string;
|
|
1528
|
+
/** Optional bounded context about the surface and task. */
|
|
1529
|
+
background?: string;
|
|
1530
|
+
/**
|
|
1531
|
+
* Public dotted Python modules imported before GEPA resolves engine names.
|
|
1532
|
+
* Each module should call GEPA's official `register_engine()` API at import.
|
|
1533
|
+
*/
|
|
1534
|
+
engineModules?: readonly string[];
|
|
1535
|
+
/** Reject external candidates longer than this. Default: 200,000 characters. */
|
|
1536
|
+
maxCandidateChars?: number;
|
|
1537
|
+
/** Reject serialized score evidence longer than this. Default: 100,000 characters. */
|
|
1538
|
+
maxEvidenceChars?: number;
|
|
1539
|
+
/** Candidate-evaluation callback byte limits. Omitted fields use finite defaults. */
|
|
1540
|
+
evaluationCallbackLimits?: Partial<ExternalOptimizerCallbackLimits>;
|
|
1541
|
+
/** End the bridge process after this many milliseconds. Default: 30 minutes. */
|
|
1542
|
+
timeoutMs?: number;
|
|
1543
|
+
/**
|
|
1544
|
+
* OpenAI-compatible model used by standard GEPA reflection.
|
|
1545
|
+
* Calls pass through Agent Eval's local model proxy. Every recipe engine must
|
|
1546
|
+
* be `gepa` when this is set.
|
|
1547
|
+
*/
|
|
1548
|
+
optimizer?: OpenAICompatibleOptimizerModel;
|
|
1549
|
+
/**
|
|
1550
|
+
* Decide what the external optimizer may read for a train or selection case.
|
|
1551
|
+
* The returned value must be JSON-serializable. The final comparison cases
|
|
1552
|
+
* are not accepted by this API and cannot be serialized here.
|
|
1553
|
+
*/
|
|
1554
|
+
describeScenario?: (scenario: TScenario) => unknown;
|
|
1555
|
+
/** Optional bounded artifact evidence returned to GEPA after each evaluation. */
|
|
1556
|
+
describeArtifact?: (artifact: TArtifact, scenario: TScenario) => unknown;
|
|
1557
|
+
/** Default: `never`. Compatible runs resume only when explicitly enabled. */
|
|
1558
|
+
resume?: ExternalOptimizerResumeMode;
|
|
1559
|
+
/**
|
|
1560
|
+
* Required for resumable direct GEPA runs because upstream state uses Python
|
|
1561
|
+
* pickle. Enable only for state created locally in a directory you control.
|
|
1562
|
+
*/
|
|
1563
|
+
trustResumeState?: boolean;
|
|
1564
|
+
runner?: GepaRunnerCommand;
|
|
1565
|
+
/**
|
|
1566
|
+
* Record GEPA's search into a search ledger and return the bounded receipt
|
|
1567
|
+
* on the method result, so a comparison under `searchHistoryPolicy:
|
|
1568
|
+
* 'require-complete'` accepts this method. The population becomes nodes and
|
|
1569
|
+
* `correlated` edges, and every callback evaluation becomes a cell.
|
|
1570
|
+
*
|
|
1571
|
+
* `identity` declares the immutable revisions and the model the ledger
|
|
1572
|
+
* requires and the bridge does not report. `path` defaults to
|
|
1573
|
+
* `<runDir>/search-ledger.jsonl`.
|
|
1574
|
+
*/
|
|
1575
|
+
searchLedger?: {
|
|
1576
|
+
identity: SearchRunIdentity;
|
|
1577
|
+
path?: string;
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
2126
1580
|
/**
|
|
2127
|
-
*
|
|
2128
|
-
*
|
|
1581
|
+
* Turn an optional GEPA installation into an `OptimizationMethod`.
|
|
1582
|
+
*
|
|
1583
|
+
* GEPA receives only serialized train and selection cases. The caller's final
|
|
1584
|
+
* test partition stays inside `compareOptimizationMethods`, which invokes this
|
|
1585
|
+
* method without a test-set field. The local callback routes every candidate
|
|
1586
|
+
* evaluation through the same dispatch and judges used by other methods.
|
|
2129
1587
|
*/
|
|
2130
|
-
declare function planEvalFixtureRun<TArtifact = unknown>(options: PlanEvalFixtureRunOptions<TArtifact>): EvalFixtureRunPlan;
|
|
2131
|
-
interface NeutralizationGateOptions<TScenario extends Scenario = Scenario> {
|
|
2132
|
-
scenarios: TScenario[];
|
|
2133
|
-
/** Reject when the neutralized (content-blanked, footprint-matched) variant
|
|
2134
|
-
* reproduces at least this fraction of the candidate's held-out lift. Default
|
|
2135
|
-
* 0.5 — if blanking the content keeps half the lift, the content is decorative.
|
|
2136
|
-
* Equality rejects: a neutralized lift == threshold·candidateLift is decorative. */
|
|
2137
|
-
maxDecorativeFraction?: number;
|
|
2138
|
-
}
|
|
2139
1588
|
/**
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
1589
|
+
* Environment for a bridge child that spawns `claude` CLI subprocesses.
|
|
1590
|
+
*
|
|
1591
|
+
* Both agent CLI engines start the CLI with the bridge's own environment, so
|
|
1592
|
+
* these variables travel bridge → engine → CLI. They merge AFTER
|
|
1593
|
+
* `removeCredentialEnvironment`: the ephemeral loopback token is the only
|
|
1594
|
+
* credential the child may see, and a caller-supplied ANTHROPIC_AUTH_TOKEN is
|
|
1595
|
+
* stripped like any other credential.
|
|
2142
1596
|
*/
|
|
2143
|
-
declare function
|
|
1597
|
+
declare function gepaOptimizationMethod<TScenario extends Scenario, TArtifact>(config: GepaOptimizationMethodConfig<TScenario, TArtifact>): OptimizationMethod<TScenario, TArtifact>;
|
|
2144
1598
|
/** The external optimizers whose searches this module records. */
|
|
2145
1599
|
type ExternalSearchOptimizer = 'GEPA' | 'SkillOpt';
|
|
2146
1600
|
interface GepaPopulationImport {
|
|
@@ -2169,13 +1623,29 @@ declare function importGepaPopulation(input: {
|
|
|
2169
1623
|
diff?: (parent: GepaCandidatePopulationCandidate, child: GepaCandidatePopulationCandidate) => SearchArtifactRef | SearchUnknown;
|
|
2170
1624
|
}): Promise<GepaPopulationImport>;
|
|
2171
1625
|
interface GepaEvaluationImport {
|
|
1626
|
+
/** Ledger cells recorded: one per distinct measured campaign cell, plus one
|
|
1627
|
+
* per evaluation logged without its cells. */
|
|
2172
1628
|
cells: number;
|
|
1629
|
+
/** Distinct campaign cells the evaluations' measurements named. */
|
|
1630
|
+
measuredCells: number;
|
|
1631
|
+
/** Evaluations answered from cells an earlier request measured; each adds no cell. */
|
|
1632
|
+
reusedRequests: number;
|
|
2173
1633
|
/** Nodes of candidates GEPA evaluated but kept out of its population. */
|
|
2174
1634
|
unrecordedParentNodeIds: string[];
|
|
2175
1635
|
}
|
|
2176
1636
|
/**
|
|
2177
|
-
* Record
|
|
2178
|
-
*
|
|
1637
|
+
* Record the callback's evaluations as `external` cells. An evaluation that
|
|
1638
|
+
* carries its measurement records each campaign cell it names once, through
|
|
1639
|
+
* `campaignCellSearchResult`, so the ledger holds the cell's own outcome,
|
|
1640
|
+
* dimensions, tokens, cost, model, duration, attempt and trace; a request
|
|
1641
|
+
* answered from an earlier request's cells adds none. A refusal that measured
|
|
1642
|
+
* cells before it was refused records them the same way, with their real
|
|
1643
|
+
* accounting and an `evaluation-refused` outcome; for an evaluation whose
|
|
1644
|
+
* campaign threw, that is every cell it settled, and each cell the throw
|
|
1645
|
+
* interrupted with unknown accounting. An evaluation logged
|
|
1646
|
+
* without cells (a log written before the callback recorded them, or a
|
|
1647
|
+
* refusal that measured nothing) records one cell whose accounting is
|
|
1648
|
+
* unknown. A candidate that is not yet a node (GEPA evaluated it on a
|
|
2179
1649
|
* minibatch and discarded it, or SkillOpt, which reports no parents, proposed
|
|
2180
1650
|
* it) is registered with an `unknown` edge.
|
|
2181
1651
|
*/
|
|
@@ -2277,26 +1747,152 @@ interface FsLabeledScenarioStoreOptions {
|
|
|
2277
1747
|
* survives neutralization is rejected however large its raw lift.
|
|
2278
1748
|
*/
|
|
2279
1749
|
/**
|
|
2280
|
-
* Blank every non-whitespace character to a 1-byte filler while preserving all
|
|
2281
|
-
* whitespace. Line count, indentation, and word/line lengths are unchanged — so
|
|
2282
|
-
* the neutralized variant has the same layout and (for ASCII) the same byte
|
|
2283
|
-
* footprint as the input, but no readable content. Whitespace is preserved
|
|
2284
|
-
* deliberately: collapsing it would change the token structure and stop the
|
|
2285
|
-
* variant from being a true footprint match.
|
|
1750
|
+
* Blank every non-whitespace character to a 1-byte filler while preserving all
|
|
1751
|
+
* whitespace. Line count, indentation, and word/line lengths are unchanged — so
|
|
1752
|
+
* the neutralized variant has the same layout and (for ASCII) the same byte
|
|
1753
|
+
* footprint as the input, but no readable content. Whitespace is preserved
|
|
1754
|
+
* deliberately: collapsing it would change the token structure and stop the
|
|
1755
|
+
* variant from being a true footprint match.
|
|
1756
|
+
*/
|
|
1757
|
+
declare function neutralizeText(content: string): string;
|
|
1758
|
+
/** Optimize a projection while evaluating every proposal in the complete candidate. */
|
|
1759
|
+
declare function scopedOptimizationMethod<S extends Scenario, A>(options: {
|
|
1760
|
+
name: string;
|
|
1761
|
+
method: OptimizationMethod<S, A>;
|
|
1762
|
+
project: (surface: MutableSurface) => MutableSurface;
|
|
1763
|
+
merge: (baseline: MutableSurface, selected: MutableSurface) => MutableSurface;
|
|
1764
|
+
}): OptimizationMethod<S, A>;
|
|
1765
|
+
/** Each stage starts from the previous selected candidate, without an intervening release gate. */
|
|
1766
|
+
declare function sequentialOptimizationMethod<S extends Scenario, A>(options: {
|
|
1767
|
+
name: string;
|
|
1768
|
+
methods: readonly OptimizationMethod<S, A>[];
|
|
1769
|
+
}): OptimizationMethod<S, A>;
|
|
1770
|
+
interface OptimizationMethodScore {
|
|
1771
|
+
evidence?: {
|
|
1772
|
+
baseline: EvidenceReceipt;
|
|
1773
|
+
winner: EvidenceReceipt;
|
|
1774
|
+
};
|
|
1775
|
+
name: string;
|
|
1776
|
+
/** Mean final-test composite of the baseline (identical across methods). */
|
|
1777
|
+
baselineComposite: number;
|
|
1778
|
+
/** Mean final-test composite of this method's selected surface. */
|
|
1779
|
+
winnerComposite: number;
|
|
1780
|
+
/** Mean final-test lift across independent units (winner minus baseline). */
|
|
1781
|
+
lift: number;
|
|
1782
|
+
/** Deciding interval, adjusted for every registered contrast. */
|
|
1783
|
+
liftCi: {
|
|
1784
|
+
low: number;
|
|
1785
|
+
high: number;
|
|
1786
|
+
};
|
|
1787
|
+
decision: PairedPromotionDecision;
|
|
1788
|
+
/** Search spend reconciled with recorded method calls. Excludes final test scoring. */
|
|
1789
|
+
optimizationCost: ComparisonCost;
|
|
1790
|
+
/** Optimization duration reported by the method. Excludes final test scoring. */
|
|
1791
|
+
durationMs?: number;
|
|
1792
|
+
/** Exact external implementation and run identity, when reported by the method. */
|
|
1793
|
+
provenance?: OptimizationMethodProvenance;
|
|
1794
|
+
/** Paired final-test values used to compute lift and its interval. */
|
|
1795
|
+
scenarioScores: Array<{
|
|
1796
|
+
scenarioId: string;
|
|
1797
|
+
baselineComposite: number;
|
|
1798
|
+
winnerComposite: number;
|
|
1799
|
+
lift: number;
|
|
1800
|
+
}>;
|
|
1801
|
+
/** Scenario means averaged within each registered source unit before inference. */
|
|
1802
|
+
unitScores: Array<{
|
|
1803
|
+
unitId: string;
|
|
1804
|
+
scenarios: number;
|
|
1805
|
+
baselineComposite: number;
|
|
1806
|
+
winnerComposite: number;
|
|
1807
|
+
lift: number;
|
|
1808
|
+
}>;
|
|
1809
|
+
winnerSurface: MutableSurface;
|
|
1810
|
+
composition?: OptimizationMethodComposition;
|
|
1811
|
+
/** 1-based, by descending lift. */
|
|
1812
|
+
rank: number;
|
|
1813
|
+
}
|
|
1814
|
+
interface OptimizationMethodPairwise {
|
|
1815
|
+
/** Higher-ranked method. */
|
|
1816
|
+
a: string;
|
|
1817
|
+
b: string;
|
|
1818
|
+
/** Mean final-test delta across independent units (a − b). */
|
|
1819
|
+
deltaMean: number;
|
|
1820
|
+
low: number;
|
|
1821
|
+
high: number;
|
|
1822
|
+
/** Favored only when the full paired decision clears the registered effect; null is inconclusive. */
|
|
1823
|
+
favored: string | null;
|
|
1824
|
+
decision: PairedPromotionDecision;
|
|
1825
|
+
}
|
|
1826
|
+
interface OptimizationMethodComparison {
|
|
1827
|
+
claim?: EvaluationClaim;
|
|
1828
|
+
finalEvidence?: FinalEvidenceUse;
|
|
1829
|
+
/** Sorted by descending lift; `rank` set accordingly. */
|
|
1830
|
+
scores: OptimizationMethodScore[];
|
|
1831
|
+
best: OptimizationMethodScore;
|
|
1832
|
+
/** Best observed method versus each alternative, with simultaneous paired decisions. */
|
|
1833
|
+
pairwise: OptimizationMethodPairwise[];
|
|
1834
|
+
testScenarioIds: string[];
|
|
1835
|
+
units: EvaluationUnitSummary;
|
|
1836
|
+
observationUnit: 'scenario' | 'registered';
|
|
1837
|
+
/** Complete scenario-replicate pairs per contrast, before unit aggregation. */
|
|
1838
|
+
pairedCellN: number;
|
|
1839
|
+
/** Sum of method reports reconciled against each method's recorded calls. */
|
|
1840
|
+
optimizationCost: ComparisonCost;
|
|
1841
|
+
/** Baseline and distinct winner scoring on the final test partition. */
|
|
1842
|
+
testCost: ComparisonCost;
|
|
1843
|
+
/** Optimization plus final test scoring. */
|
|
1844
|
+
totalCost: ComparisonCost;
|
|
1845
|
+
/** Caller-requested simultaneous coverage across all reported contrasts. */
|
|
1846
|
+
confidence: number;
|
|
1847
|
+
/** Bonferroni-adjusted confidence used for each bootstrap interval. */
|
|
1848
|
+
intervalConfidence: number;
|
|
1849
|
+
/** Method-vs-baseline plus all possible method-vs-method contrasts. */
|
|
1850
|
+
comparisonCount: number;
|
|
1851
|
+
/** Deterministic bootstrap and campaign seed. */
|
|
1852
|
+
seed: number;
|
|
1853
|
+
/** Bootstrap draws used for each interval. */
|
|
1854
|
+
resamples: number;
|
|
1855
|
+
/** Agent runs averaged within each test scenario before resampling scenarios. */
|
|
1856
|
+
reps: number;
|
|
1857
|
+
/** Coverage of every method's canonical search history. */
|
|
1858
|
+
searchHistory: SearchHistoryCoverage;
|
|
1859
|
+
}
|
|
1860
|
+
interface CompareOptimizationMethodsOptions<TScenario extends Scenario, TArtifact> extends Omit<RunCampaignOptions<TScenario, TArtifact>, 'dispatch' | 'judges' | 'scenarios'>, SearchHistoryAdmissionOptions {
|
|
1861
|
+
/** Explicit caller authority and environment for receipts over actual final measurements. */
|
|
1862
|
+
evidence?: CampaignEvidenceContext;
|
|
1863
|
+
claim?: EvaluationClaim;
|
|
1864
|
+
finalEvidence?: FinalEvidencePolicy;
|
|
1865
|
+
methods: OptimizationMethod<TScenario, TArtifact>[];
|
|
1866
|
+
baselineSurface: MutableSurface;
|
|
1867
|
+
/** Evidence used by every optimizer to author or fit candidates. */
|
|
1868
|
+
trainScenarios: TScenario[];
|
|
1869
|
+
/** Candidate acceptance, early-stopping, and optimizer-selection data. */
|
|
1870
|
+
selectionScenarios: TScenario[];
|
|
1871
|
+
/** Untouched final comparison data. Never passed to an optimization method. */
|
|
1872
|
+
testScenarios: TScenario[];
|
|
1873
|
+
/** Scores a surface on a scenario. The methods and final test share this function. */
|
|
1874
|
+
dispatchWithSurface: (surface: MutableSurface, scenario: TScenario, ctx: DispatchContext) => Promise<TArtifact>;
|
|
1875
|
+
judges: JudgeConfig<TArtifact, TScenario>[];
|
|
1876
|
+
/** How every method's optimizer is shown a non-string artifact; see
|
|
1877
|
+
* `OptimizationMethodInput.describeArtifact`. */
|
|
1878
|
+
describeArtifact?: DescribeArtifact<TArtifact, TScenario>;
|
|
1879
|
+
/** Bootstrap resamples for the lift intervals. Default is at least 2000 and
|
|
1880
|
+
* rises when the requested simultaneous confidence needs finer tails. */
|
|
1881
|
+
resamples?: number;
|
|
1882
|
+
/** Shared defaults for each method's train and selection campaigns. */
|
|
1883
|
+
optimizationRunOptions?: OptimizationMethodRunOptions<TScenario, TArtifact>;
|
|
1884
|
+
/** Number of optimization methods to run concurrently. Default 1. */
|
|
1885
|
+
optimizationConcurrency?: number;
|
|
1886
|
+
/** Simultaneous confidence across method-vs-baseline and method-vs-method contrasts.
|
|
1887
|
+
* Each bootstrap interval is Bonferroni-adjusted. Default 0.95. */
|
|
1888
|
+
confidence?: number;
|
|
1889
|
+
/** Shared spend limit across every method's optimizer and evaluation calls plus final scoring. */
|
|
1890
|
+
costCeiling?: number;
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Compare complete optimization methods on disjoint train, selection, and final test data.
|
|
2286
1894
|
*/
|
|
2287
|
-
declare function
|
|
2288
|
-
/** Optimize a projection while evaluating every proposal in the complete candidate. */
|
|
2289
|
-
declare function scopedOptimizationMethod<S extends Scenario, A>(options: {
|
|
2290
|
-
name: string;
|
|
2291
|
-
method: OptimizationMethod<S, A>;
|
|
2292
|
-
project: (surface: MutableSurface) => MutableSurface;
|
|
2293
|
-
merge: (baseline: MutableSurface, selected: MutableSurface) => MutableSurface;
|
|
2294
|
-
}): OptimizationMethod<S, A>;
|
|
2295
|
-
/** Each stage starts from the previous selected candidate, without an intervening release gate. */
|
|
2296
|
-
declare function sequentialOptimizationMethod<S extends Scenario, A>(options: {
|
|
2297
|
-
name: string;
|
|
2298
|
-
methods: readonly OptimizationMethod<S, A>[];
|
|
2299
|
-
}): OptimizationMethod<S, A>;
|
|
1895
|
+
declare function compareOptimizationMethods<TScenario extends Scenario, TArtifact>(rawOpts: CompareOptimizationMethodsOptions<TScenario, TArtifact>): Promise<OptimizationMethodComparison>;
|
|
2300
1896
|
/** A tool the agent invoked. */
|
|
2301
1897
|
interface ToolCallEventLike {
|
|
2302
1898
|
type: 'tool_call';
|
|
@@ -2694,6 +2290,201 @@ interface FinalizedProfileMatrixResult<TArtifact, TScenario extends Scenario> ex
|
|
|
2694
2290
|
declare function createProfileMatrixPlan<TScenario extends Scenario, TArtifact>(opts: CreateProfileMatrixPlanOptions<TScenario, TArtifact>): ProfileMatrixPlan<TScenario, TArtifact>;
|
|
2695
2291
|
declare function runProfileMatrixSegment<TScenario extends Scenario, TArtifact>(opts: RunProfileMatrixSegmentOptions<TScenario, TArtifact>): Promise<ProfileMatrixSegmentResult<TArtifact, TScenario>>;
|
|
2696
2292
|
declare function finalizeProfileMatrix<TScenario extends Scenario, TArtifact>(opts: FinalizeProfileMatrixOptions<TScenario, TArtifact>): Promise<FinalizedProfileMatrixResult<TArtifact, TScenario>>;
|
|
2293
|
+
interface LoopProvenanceCandidate {
|
|
2294
|
+
/** Generation index this candidate was proposed in. */
|
|
2295
|
+
generation: number;
|
|
2296
|
+
/** 16-char loop-identity fingerprint (matches `GenerationCandidate.surfaceHash`). */
|
|
2297
|
+
surfaceHash: string;
|
|
2298
|
+
/** Full sha256 content hash — byte-identical-verifiable. */
|
|
2299
|
+
contentHash: string;
|
|
2300
|
+
/** Exact scored rows that produced this candidate's search result. */
|
|
2301
|
+
campaignDigest: `sha256:${string}`;
|
|
2302
|
+
/** Proposer label, when the proposer returned a `ProposedCandidate`. */
|
|
2303
|
+
label?: string;
|
|
2304
|
+
/** Proposer rationale — the "because Z". When the proposer returned a bare
|
|
2305
|
+
* surface (blind mutator) this is absent. */
|
|
2306
|
+
rationale?: string;
|
|
2307
|
+
/** Proposer-supplied typed attribution, carried unchanged from
|
|
2308
|
+
* `GenerationCandidate.attribution`. Opaque here; the producer's schema tag
|
|
2309
|
+
* governs interpretation. */
|
|
2310
|
+
attribution?: Readonly<Record<string, unknown>>;
|
|
2311
|
+
/** Whether the candidate completed every designed cell and could be selected. */
|
|
2312
|
+
eligibleForPromotion: boolean;
|
|
2313
|
+
/** Designed-denominator receipt retained even for incomplete candidates. */
|
|
2314
|
+
coverage: NonNullable<GenerationCandidate['coverage']>;
|
|
2315
|
+
/** Mean composite this candidate scored on the search split, or null when unscorable. */
|
|
2316
|
+
composite: number | null;
|
|
2317
|
+
/** Whether this candidate was promoted out of its generation. */
|
|
2318
|
+
promoted: boolean;
|
|
2319
|
+
}
|
|
2320
|
+
interface LoopProvenanceBackend {
|
|
2321
|
+
/** `assertRealBackend`-grade verdict over the worker call records. */
|
|
2322
|
+
verdict: 'real' | 'mixed' | 'stub';
|
|
2323
|
+
/** Number of worker LLM calls captured (the audit's "worker call count"). */
|
|
2324
|
+
workerCallCount: number;
|
|
2325
|
+
/** Distinct model ids observed across worker calls. */
|
|
2326
|
+
models: string[];
|
|
2327
|
+
totalInputTokens: number;
|
|
2328
|
+
totalOutputTokens: number;
|
|
2329
|
+
totalCostUsd: number;
|
|
2330
|
+
}
|
|
2331
|
+
interface LoopProvenanceEvidence {
|
|
2332
|
+
search: {
|
|
2333
|
+
splitDigest: `sha256:${string}`;
|
|
2334
|
+
baselineCampaignDigest: `sha256:${string}`;
|
|
2335
|
+
};
|
|
2336
|
+
holdout: {
|
|
2337
|
+
splitDigest: `sha256:${string}`;
|
|
2338
|
+
baselineCampaignDigest: `sha256:${string}`;
|
|
2339
|
+
winnerCampaignDigest: `sha256:${string}`;
|
|
2340
|
+
observations?: CampaignComparisonUnits;
|
|
2341
|
+
neutralized?: {
|
|
2342
|
+
contentHash: `sha256:${string}`;
|
|
2343
|
+
campaignDigest: `sha256:${string}`;
|
|
2344
|
+
composite: number;
|
|
2345
|
+
lift: number;
|
|
2346
|
+
};
|
|
2347
|
+
};
|
|
2348
|
+
costReceiptsDigest: `sha256:${string}`;
|
|
2349
|
+
}
|
|
2350
|
+
interface LoopProvenanceOptimizationMethod {
|
|
2351
|
+
name: string;
|
|
2352
|
+
cost: ComparisonCost;
|
|
2353
|
+
durationMs?: number;
|
|
2354
|
+
provenance?: OptimizationMethodProvenance;
|
|
2355
|
+
}
|
|
2356
|
+
/**
|
|
2357
|
+
* The durable provenance record: the baseline and winner measurements, the
|
|
2358
|
+
* rationale, the explicit baseline→candidate diff, and backend provenance.
|
|
2359
|
+
*/
|
|
2360
|
+
interface LoopProvenanceRecord {
|
|
2361
|
+
schema: 'tangle.loop-provenance';
|
|
2362
|
+
/** SHA-256 over the canonical record with this field omitted. */
|
|
2363
|
+
recordDigest: `sha256:${string}`;
|
|
2364
|
+
runId: string;
|
|
2365
|
+
runDir: string;
|
|
2366
|
+
timestamp: string;
|
|
2367
|
+
/** Baseline + winner surface content hashes — distinguishable, byte-verifiable. */
|
|
2368
|
+
baselineContentHash: string;
|
|
2369
|
+
winnerContentHash: string;
|
|
2370
|
+
/** Proposer label/rationale for the promoted change. Absent ⇒ winner == baseline. */
|
|
2371
|
+
winnerLabel?: string;
|
|
2372
|
+
winnerRationale?: string;
|
|
2373
|
+
/** The explicit baseline→winner unified diff the gate decided on. */
|
|
2374
|
+
diff: string;
|
|
2375
|
+
/** Every candidate across every generation, with its rationale and structured cause. */
|
|
2376
|
+
candidates: LoopProvenanceCandidate[];
|
|
2377
|
+
/** Complete external method identity and spend, when one authored the candidate. */
|
|
2378
|
+
optimizationMethod?: LoopProvenanceOptimizationMethod;
|
|
2379
|
+
/** Exact campaign, split, surface, and receipt identities behind every summary. */
|
|
2380
|
+
evidence: LoopProvenanceEvidence;
|
|
2381
|
+
/** Baseline composite on the search split that generated the candidates. */
|
|
2382
|
+
baselineSearchComposite: number;
|
|
2383
|
+
claim?: EvaluationClaim;
|
|
2384
|
+
/** The gate verdict — decision + reasons + contributing gates + delta. */
|
|
2385
|
+
gate: {
|
|
2386
|
+
decision: GateDecision;
|
|
2387
|
+
reasons: string[];
|
|
2388
|
+
delta?: number;
|
|
2389
|
+
contributingGates: GateContribution[];
|
|
2390
|
+
};
|
|
2391
|
+
/** Present iff the loop ran with `holdout: 'deferred'` — the held-out
|
|
2392
|
+
* comparison was intentionally not measured in this run, so the holdout
|
|
2393
|
+
* composites and `heldOutLift` are ABSENT rather than recorded as a
|
|
2394
|
+
* meaningless 0. */
|
|
2395
|
+
holdout?: 'deferred';
|
|
2396
|
+
/** baseline-on-holdout composite mean. Absent when `holdout === 'deferred'`. */
|
|
2397
|
+
baselineHoldoutComposite?: number;
|
|
2398
|
+
/** winner-on-holdout composite mean. Absent when `holdout === 'deferred'`. */
|
|
2399
|
+
winnerHoldoutComposite?: number;
|
|
2400
|
+
/** winnerHoldout - baselineHoldout — RECOMPUTABLE from this record. Absent
|
|
2401
|
+
* when `holdout === 'deferred'` (no held-out measurement ran). */
|
|
2402
|
+
heldOutLift?: number;
|
|
2403
|
+
/** Backend provenance: stub-vs-real verdict + worker call count + models. */
|
|
2404
|
+
backend: LoopProvenanceBackend;
|
|
2405
|
+
totalCostUsd: number;
|
|
2406
|
+
totalDurationMs: number;
|
|
2407
|
+
}
|
|
2408
|
+
interface BuildLoopProvenanceArgs<TArtifact, TScenario extends Scenario> {
|
|
2409
|
+
runId: string;
|
|
2410
|
+
runDir: string;
|
|
2411
|
+
timestamp: string;
|
|
2412
|
+
baselineSurface: MutableSurface;
|
|
2413
|
+
winnerSurface: MutableSurface;
|
|
2414
|
+
winnerLabel?: string;
|
|
2415
|
+
winnerRationale?: string;
|
|
2416
|
+
/** Exact baseline campaign on the search split. */
|
|
2417
|
+
baselineSearchCampaign: CampaignResult<TArtifact, TScenario>;
|
|
2418
|
+
/** Per-generation candidate records straight off the loop result. */
|
|
2419
|
+
generations: Array<{
|
|
2420
|
+
generationIndex: number;
|
|
2421
|
+
candidates: GenerationCandidate[];
|
|
2422
|
+
promoted: string[];
|
|
2423
|
+
/** Surfaces measured this generation, keyed by surface hash so the content
|
|
2424
|
+
* hash can be computed and the loop identity rechecked from real bytes. */
|
|
2425
|
+
surfaces: Array<{
|
|
2426
|
+
surfaceHash: string;
|
|
2427
|
+
surface: MutableSurface;
|
|
2428
|
+
campaign: CampaignResult<TArtifact, TScenario>;
|
|
2429
|
+
}>;
|
|
2430
|
+
}>;
|
|
2431
|
+
gate: GateResult;
|
|
2432
|
+
/** Holdout policy the loop ran with. `'deferred'` ⇒ the holdout campaigns
|
|
2433
|
+
* below are the shared empty campaign and the record omits the holdout
|
|
2434
|
+
* composites + `heldOutLift`. Default `'measured'`. */
|
|
2435
|
+
holdout?: 'measured' | 'deferred';
|
|
2436
|
+
baselineOnHoldout: CampaignResult<TArtifact, TScenario>;
|
|
2437
|
+
winnerOnHoldout: CampaignResult<TArtifact, TScenario>;
|
|
2438
|
+
claim?: EvaluationClaim;
|
|
2439
|
+
/** Required with a measured claim because campaign identities redact source fields. */
|
|
2440
|
+
independentUnitByScenarioId?: ReadonlyMap<string, string>;
|
|
2441
|
+
neutralizedSurface?: MutableSurface;
|
|
2442
|
+
neutralizedOnHoldout?: CampaignResult<TArtifact, TScenario>;
|
|
2443
|
+
/** Settled run-wide receipts — agent calls are the source for backend provenance. */
|
|
2444
|
+
costReceipts: ReadonlyArray<CostReceipt>;
|
|
2445
|
+
totalCostUsd: number;
|
|
2446
|
+
totalDurationMs: number;
|
|
2447
|
+
optimizationMethod?: LoopProvenanceOptimizationMethod;
|
|
2448
|
+
}
|
|
2449
|
+
interface LoopProvenanceArgsFromResult<TArtifact, TScenario extends Scenario> {
|
|
2450
|
+
runId: string;
|
|
2451
|
+
runDir: string;
|
|
2452
|
+
timestamp: string;
|
|
2453
|
+
baselineSurface: MutableSurface;
|
|
2454
|
+
result: RunImprovementLoopResult<TArtifact, TScenario>;
|
|
2455
|
+
costReceipts: ReadonlyArray<CostReceipt>;
|
|
2456
|
+
totalCostUsd: number;
|
|
2457
|
+
totalDurationMs: number;
|
|
2458
|
+
independentUnitByScenarioId?: ReadonlyMap<string, string>;
|
|
2459
|
+
}
|
|
2460
|
+
/** SHA-256 over the RFC 8785 canonical JSON of `value`. Throws
|
|
2461
|
+
* `LedgerCanonicalizationError` for a value with no canonical form. */
|
|
2462
|
+
declare function canonicalDigest(value: unknown): `sha256:${string}`;
|
|
2463
|
+
interface EmitLoopProvenanceResult {
|
|
2464
|
+
record: LoopProvenanceRecord;
|
|
2465
|
+
spans: TraceSpanEvent[];
|
|
2466
|
+
/** Absolute paths the record + spans were written to, when storage persists. */
|
|
2467
|
+
recordPath: string;
|
|
2468
|
+
spansPath: string;
|
|
2469
|
+
}
|
|
2470
|
+
interface EmitLoopProvenanceArgs<TArtifact, TScenario extends Scenario> extends BuildLoopProvenanceArgs<TArtifact, TScenario> {
|
|
2471
|
+
/** Storage the record + spans are written through. */
|
|
2472
|
+
storage: CampaignStorage;
|
|
2473
|
+
/** When set, the spans are also shipped to the hosted `/v1/ingest/traces`
|
|
2474
|
+
* endpoint so the collector receives the full loop, not just `cost.*`. */
|
|
2475
|
+
hostedClient?: HostedClient;
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Build the provenance record + OTel spans and persist them durably under the
|
|
2479
|
+
* run dir (and ship spans to a hosted collector when one is wired). Returns
|
|
2480
|
+
* both artifacts so the caller can assert on / re-derive from them.
|
|
2481
|
+
*
|
|
2482
|
+
* Fail-loud: the durable write throws on storage failure (a swallowed write is
|
|
2483
|
+
* exactly the "emitted but lost" failure this closes). The hosted span ship is
|
|
2484
|
+
* the one best-effort leg — its failure is logged, not thrown, so an offline
|
|
2485
|
+
* collector never fails the loop (the durable artifact is the source of truth).
|
|
2486
|
+
*/
|
|
2487
|
+
declare function emitLoopProvenance<TArtifact, TScenario extends Scenario>(args: EmitLoopProvenanceArgs<TArtifact, TScenario>): Promise<EmitLoopProvenanceResult>;
|
|
2697
2488
|
type RetainedDispatchOutcome<T> = {
|
|
2698
2489
|
succeeded: true;
|
|
2699
2490
|
value: T;
|
|
@@ -2787,25 +2578,6 @@ interface DiscriminationScore {
|
|
|
2787
2578
|
declare function scoreDiscrimination(signals: ScenarioSignal[], opts?: {
|
|
2788
2579
|
saturationCeiling?: number;
|
|
2789
2580
|
}): DiscriminationScore[];
|
|
2790
|
-
/**
|
|
2791
|
-
* What `cell-settled` records for one campaign cell: `passed` with the
|
|
2792
|
-
* composite (and each judge's) when every judge scored it, else `errored`,
|
|
2793
|
-
* never retryable, because `runCampaign` already applied its own retry policy;
|
|
2794
|
-
* its tokens and cost, with an uncaptured cost kept as a lower bound; the
|
|
2795
|
-
* model the cell resolved, else the declared one.
|
|
2796
|
-
*/
|
|
2797
|
-
declare function campaignCellSearchResult<TArtifact>(cell: CampaignCellResult<TArtifact>, input: {
|
|
2798
|
-
execution: SearchExecutionIdentity;
|
|
2799
|
-
lane: string;
|
|
2800
|
-
}): SearchCellResult;
|
|
2801
|
-
/** A provider-reported model: a snapshot when its name pins one, else a moving alias. */
|
|
2802
|
-
declare function searchModelIdentity(model: string, provider: string): SearchModelIdentity;
|
|
2803
|
-
/** The accounting of a proposal's cost receipts: token and dollar sums, each
|
|
2804
|
-
* unknown (with the known dollars as a lower bound) when a receipt lacks it. */
|
|
2805
|
-
declare function searchReceiptAccounting(receipts: ReadonlyArray<CostReceipt>): SearchAttemptAccounting;
|
|
2806
|
-
/** What ran a proposal: a model when it made a paid call other than a judge's,
|
|
2807
|
-
* else deterministic code. */
|
|
2808
|
-
declare function searchProposalExecution(receipts: ReadonlyArray<CostReceipt>, provider: string, source: SearchOperationRecordedEvent['execution']['source']): SearchOperationRecordedEvent['execution'];
|
|
2809
2581
|
/**
|
|
2810
2582
|
* Single-run lock for evaluations that share one mutable environment.
|
|
2811
2583
|
*
|
|
@@ -2831,16 +2603,85 @@ interface SingleRunLockOptions {
|
|
|
2831
2603
|
/** Owner pid recorded in the lockfile metadata. Default process.pid. */
|
|
2832
2604
|
readonly pid?: number;
|
|
2833
2605
|
}
|
|
2834
|
-
interface SingleRunLock {
|
|
2835
|
-
/** Remove the lockfile if this process still owns it. Idempotent. */
|
|
2836
|
-
release(): void;
|
|
2606
|
+
interface SingleRunLock {
|
|
2607
|
+
/** Remove the lockfile if this process still owns it. Idempotent. */
|
|
2608
|
+
release(): void;
|
|
2609
|
+
}
|
|
2610
|
+
/**
|
|
2611
|
+
* Acquire the lock or throw naming the holder. A lock whose holder is proved
|
|
2612
|
+
* dead is reclaimed by one contender. An interrupted reclaim
|
|
2613
|
+
* leaves a marker that fails closed instead of admitting overlapping runs.
|
|
2614
|
+
*/
|
|
2615
|
+
declare function acquireSingleRunLock(opts: SingleRunLockOptions): SingleRunLock;
|
|
2616
|
+
interface SkillOptTrainerConfig {
|
|
2617
|
+
epochs: number;
|
|
2618
|
+
batchSize: number;
|
|
2619
|
+
accumulation?: number;
|
|
2620
|
+
editBudget?: number;
|
|
2621
|
+
minEditBudget?: number;
|
|
2622
|
+
analystWorkers?: number;
|
|
2623
|
+
minibatchSize?: number;
|
|
2624
|
+
mergeBatchSize?: number;
|
|
2625
|
+
maxAnalystRounds?: number;
|
|
2626
|
+
evaluationWorkers?: number;
|
|
2627
|
+
learningRateSchedule?: 'constant' | 'linear' | 'cosine' | 'autonomous';
|
|
2628
|
+
learningRateControl?: 'fixed' | 'autonomous' | 'none';
|
|
2629
|
+
updateMode?: 'patch' | 'rewrite_from_suggestions' | 'full_rewrite_minibatch';
|
|
2630
|
+
failureOnly?: boolean;
|
|
2631
|
+
useSlowUpdate?: boolean;
|
|
2632
|
+
useMetaSkill?: boolean;
|
|
2633
|
+
/**
|
|
2634
|
+
* Additional flat SkillOpt trainer settings. Tangle overwrites data,
|
|
2635
|
+
* output, split, seed, validation, and activation settings.
|
|
2636
|
+
*/
|
|
2637
|
+
overrides?: Record<string, unknown>;
|
|
2638
|
+
}
|
|
2639
|
+
type SkillOptRunnerCommand = ExternalOptimizerRunnerCommand;
|
|
2640
|
+
interface SkillOptOptimizationMethodConfig<TScenario extends Scenario, TArtifact = unknown> {
|
|
2641
|
+
name?: string;
|
|
2642
|
+
/** Goal included with every described train and selection case. */
|
|
2643
|
+
objective: string;
|
|
2644
|
+
background?: string;
|
|
2645
|
+
/** Stable identity for the dispatch, judges, model settings, and scoring logic. */
|
|
2646
|
+
evaluationId: string;
|
|
2647
|
+
trainer: SkillOptTrainerConfig;
|
|
2648
|
+
/**
|
|
2649
|
+
* OpenAI-compatible model connection and hard limits for SkillOpt's own
|
|
2650
|
+
* optimizer calls.
|
|
2651
|
+
*/
|
|
2652
|
+
optimizer: OpenAICompatibleOptimizerModel;
|
|
2653
|
+
/** Hard cap on candidate-case callback requests. */
|
|
2654
|
+
maxEvaluations: number;
|
|
2655
|
+
/** Scores at or above this value count as hard successes. Default: 1. */
|
|
2656
|
+
hardScoreThreshold?: number;
|
|
2657
|
+
maxCandidateChars?: number;
|
|
2658
|
+
/** Maximum serialized scenario plus evaluation evidence. Default: 100,000. */
|
|
2659
|
+
maxEvidenceChars?: number;
|
|
2660
|
+
/** Candidate-evaluation callback byte limits. Omitted fields use finite defaults. */
|
|
2661
|
+
evaluationCallbackLimits?: Partial<ExternalOptimizerCallbackLimits>;
|
|
2662
|
+
timeoutMs?: number;
|
|
2663
|
+
describeScenario?: (scenario: TScenario) => unknown;
|
|
2664
|
+
describeArtifact?: (artifact: TArtifact, scenario: TScenario) => unknown;
|
|
2665
|
+
resume?: ExternalOptimizerResumeMode;
|
|
2666
|
+
runner?: SkillOptRunnerCommand;
|
|
2667
|
+
/**
|
|
2668
|
+
* Record SkillOpt's search into a search ledger and return the bounded
|
|
2669
|
+
* receipt on the method result, so a comparison under `searchHistoryPolicy:
|
|
2670
|
+
* 'require-complete'` accepts this method. Every candidate the callback
|
|
2671
|
+
* evaluated becomes a node with an `unknown` edge (SkillOpt reports no
|
|
2672
|
+
* parents), and every evaluation becomes a cell.
|
|
2673
|
+
*
|
|
2674
|
+
* `identity` declares the immutable revisions and the model the ledger
|
|
2675
|
+
* requires and the bridge does not report. `path` defaults to
|
|
2676
|
+
* `<runDir>/search-ledger.jsonl`.
|
|
2677
|
+
*/
|
|
2678
|
+
searchLedger?: {
|
|
2679
|
+
identity: SearchRunIdentity;
|
|
2680
|
+
path?: string;
|
|
2681
|
+
};
|
|
2837
2682
|
}
|
|
2838
|
-
/**
|
|
2839
|
-
|
|
2840
|
-
* dead is reclaimed by one contender. An interrupted reclaim
|
|
2841
|
-
* leaves a marker that fails closed instead of admitting overlapping runs.
|
|
2842
|
-
*/
|
|
2843
|
-
declare function acquireSingleRunLock(opts: SingleRunLockOptions): SingleRunLock;
|
|
2683
|
+
/** Run Microsoft's SkillOpt trainer as a complete optimization method. */
|
|
2684
|
+
declare function skillOptOptimizationMethod<TScenario extends Scenario, TArtifact>(config: SkillOptOptimizationMethodConfig<TScenario, TArtifact>): OptimizationMethod<TScenario, TArtifact>;
|
|
2844
2685
|
/** Validate the immutable identity shape; the owning executor verifies the Git objects and patch. */
|
|
2845
2686
|
declare function assertCodeSurfaceIdentity(surface: unknown): asserts surface is CodeSurface;
|
|
2846
2687
|
/**
|
|
@@ -2865,6 +2706,39 @@ declare function surfaceHash(surface: MutableSurface): string;
|
|
|
2865
2706
|
declare function renderSurfaceDiff(winnerSurface: MutableSurface, baselineSurface: MutableSurface): string;
|
|
2866
2707
|
/** Bind a campaign cache entry to the exact surface and caller-owned execution revision. */
|
|
2867
2708
|
declare function surfaceDispatchRef(surface: MutableSurface, executionRef?: string): string;
|
|
2709
|
+
interface TransientFailureOptions {
|
|
2710
|
+
/**
|
|
2711
|
+
* Treat full-duration timeouts ("timeout after 180000ms") as transient.
|
|
2712
|
+
* Enable on saturated shared infrastructure where queue starvation eats
|
|
2713
|
+
* the clock; leave off when the agent had the resources and simply failed.
|
|
2714
|
+
* Default false.
|
|
2715
|
+
*/
|
|
2716
|
+
readonly retryFullDurationTimeouts?: boolean;
|
|
2717
|
+
/** Additional caller-specific transient patterns. */
|
|
2718
|
+
readonly extraPatterns?: readonly RegExp[];
|
|
2719
|
+
/**
|
|
2720
|
+
* The instant a dated quota refusal is measured against. Defaults to `Date.now()`; inject it
|
|
2721
|
+
* to replay a past classification, which is what a retry audit needs.
|
|
2722
|
+
*/
|
|
2723
|
+
readonly now?: number;
|
|
2724
|
+
}
|
|
2725
|
+
/**
|
|
2726
|
+
* True when the error text describes an infrastructure hiccup that should be
|
|
2727
|
+
* retried rather than scored. Empty/undefined input is not transient.
|
|
2728
|
+
*/
|
|
2729
|
+
declare function isTransientTransportFailure(message: string | null | undefined, opts?: TransientFailureOptions): boolean;
|
|
2730
|
+
/**
|
|
2731
|
+
* Ready-made `cellRetry.retryable` predicate: true for a dispatch-stage
|
|
2732
|
+
* failure whose error message `isTransientTransportFailure` classifies as an
|
|
2733
|
+
* infrastructure hiccup. A judge-stage failure is never retried here — the
|
|
2734
|
+
* dispatch already produced an artifact, so re-dispatching would score a
|
|
2735
|
+
* different sample. A per-cell dispatch deadline ("dispatch exceeded <N>ms")
|
|
2736
|
+
* is not transient by default; opt in via `extraPatterns` or
|
|
2737
|
+
* `retryFullDurationTimeouts` when queue starvation eats the clock. A provider refusal that
|
|
2738
|
+
* states its own release time is never retried while that time is in the future
|
|
2739
|
+
* (`quotaExhaustedUntil`).
|
|
2740
|
+
*/
|
|
2741
|
+
declare function transientDispatchFailure(opts?: TransientFailureOptions): (failure: CampaignCellFailureReceipt['failure']) => boolean;
|
|
2868
2742
|
interface PhoenixEvaluationResultLike {
|
|
2869
2743
|
score?: number;
|
|
2870
2744
|
label?: string;
|
|
@@ -2947,5 +2821,173 @@ declare function verifyCodeSurface(surface: CodeSurface, worktreeDir?: string):
|
|
|
2947
2821
|
/** Resolve a code candidate for evaluation only after verifying its immutable
|
|
2948
2822
|
* identity against the checkout at `worktreeRef`. */
|
|
2949
2823
|
declare function resolveWorktreePath(surface: CodeSurface, worktreeDir?: string): string;
|
|
2950
|
-
|
|
2951
|
-
|
|
2824
|
+
/** Improve a surface as a search on the kernel; see the module comment. */
|
|
2825
|
+
declare function runOptimization<TScenario extends Scenario, TArtifact>(opts: RunOptimizationOptions<TScenario, TArtifact>): Promise<RunOptimizationResult<TArtifact, TScenario>>;
|
|
2826
|
+
/** Optimization inputs, immutable proposal snapshots, and imported baseline validation. */
|
|
2827
|
+
interface PremeasuredOptimizationBaseline<TArtifact, TScenario extends Scenario> {
|
|
2828
|
+
/** Hash of the exact surface that produced `campaign`. */
|
|
2829
|
+
surfaceHash: string;
|
|
2830
|
+
/** Complete prior measurement reused by identity, including artifactsByPath. */
|
|
2831
|
+
campaign: CampaignResult<TArtifact, TScenario>;
|
|
2832
|
+
}
|
|
2833
|
+
interface RunOptimizationOptions<TScenario extends Scenario, TArtifact> extends Omit<RunCampaignOptions<TScenario, TArtifact>, 'dispatch'> {
|
|
2834
|
+
/** Initial mutable surface (typically system prompt or addendum). */
|
|
2835
|
+
baselineSurface: MutableSurface;
|
|
2836
|
+
/**
|
|
2837
|
+
* Complete prior measurement of `baselineSurface`. When present,
|
|
2838
|
+
* `runOptimization` validates its surface, scenario split, seed, reps, and
|
|
2839
|
+
* normal campaign coverage, then records its cells as the root's instead of
|
|
2840
|
+
* dispatching them. Prior spend stays in the imported campaign aggregates and
|
|
2841
|
+
* is not added again to this run's CostLedger.
|
|
2842
|
+
*/
|
|
2843
|
+
premeasuredBaseline?: PremeasuredOptimizationBaseline<TArtifact, TScenario>;
|
|
2844
|
+
/** Dispatcher that takes a surface and a scenario to an artifact. */
|
|
2845
|
+
dispatchWithSurface: (surface: MutableSurface, scenario: TScenario, ctx: Parameters<RunCampaignOptions<TScenario, TArtifact>['dispatch']>[1]) => Promise<TArtifact>;
|
|
2846
|
+
/** The candidate-generation strategy. */
|
|
2847
|
+
proposer: SurfaceProposer<ProposalFinding>;
|
|
2848
|
+
/** Candidates asked of each proposal. */
|
|
2849
|
+
populationSize: number;
|
|
2850
|
+
/** Proposals the search may make. */
|
|
2851
|
+
maxGenerations: number;
|
|
2852
|
+
/** Scales the run's cell lanes: at most `candidateConcurrency *
|
|
2853
|
+
* maxConcurrency` cells run at once. Default 1. */
|
|
2854
|
+
candidateConcurrency?: number;
|
|
2855
|
+
/** DEPTH knob forwarded to the proposer's `propose()`: max iterations the
|
|
2856
|
+
* agentic generator may take per candidate. */
|
|
2857
|
+
maxImprovementShots?: number;
|
|
2858
|
+
/** Search or observed-production findings forwarded to candidate generation. */
|
|
2859
|
+
findings?: ReadonlyArray<ProposalFinding>;
|
|
2860
|
+
/** Findings producer. Before each proposal it runs on the previous
|
|
2861
|
+
* generation's measured candidates (the baseline, as `generation: -1`,
|
|
2862
|
+
* before the first), and what it returns REPLACES `ctx.findings` for that
|
|
2863
|
+
* proposal. The substrate does not import an analyst: the consumer plugs its
|
|
2864
|
+
* trace-analyst registry here, reading the per-candidate `runDir` traces.
|
|
2865
|
+
* When absent, findings stay the static `opts.findings`. Its spend is
|
|
2866
|
+
* booked to the proposal's operation. */
|
|
2867
|
+
analyzeGeneration?: (input: {
|
|
2868
|
+
generation: number;
|
|
2869
|
+
runDir: string;
|
|
2870
|
+
candidates: Array<{
|
|
2871
|
+
surfaceHash: string;
|
|
2872
|
+
campaign: CampaignResult<TArtifact, TScenario>;
|
|
2873
|
+
composite: number | null;
|
|
2874
|
+
}>;
|
|
2875
|
+
history: GenerationRecord[];
|
|
2876
|
+
/** Shared run spend account and receipt attribution phase. */
|
|
2877
|
+
costLedger?: CostLedgerHandle;
|
|
2878
|
+
costPhase?: string;
|
|
2879
|
+
}) => Promise<ReadonlyArray<ProposalFinding>>;
|
|
2880
|
+
/** Which node each proposal extends, and which node the run keeps. Default
|
|
2881
|
+
* `incumbent()`: the hill climb. `crowdedFrontierParent({ seed })` draws
|
|
2882
|
+
* the parent from the Pareto frontier instead; `aide()` drafts, debugs and
|
|
2883
|
+
* improves with Thompson-sampled parents, and `beam({ width })` expands the
|
|
2884
|
+
* top nodes in turn. Every policy ranks on the scenarios, and the run keeps
|
|
2885
|
+
* the `uniform` allocator, because the proposer reads every candidate's
|
|
2886
|
+
* score on every scenario. */
|
|
2887
|
+
policy?: SearchPolicy;
|
|
2888
|
+
/** Where the search ledger goes and the identities it records. Default: a
|
|
2889
|
+
* ledger at `<runDir>/search/ledger.jsonl`, held in `storage` unless that is
|
|
2890
|
+
* the filesystem, whose identities are the dispatch ref's and proposer's
|
|
2891
|
+
* digests. */
|
|
2892
|
+
searchLedger?: SearchLedgerBinding;
|
|
2893
|
+
/** Describes a non-string artifact as the evidence each scenario's worst
|
|
2894
|
+
* cell shows the proposer (`scenarios[].emitted`, as JSON text). The same
|
|
2895
|
+
* hook the GEPA and SkillOpt callbacks take; a string artifact needs none. */
|
|
2896
|
+
describeArtifact?: DescribeArtifact<TArtifact, TScenario>;
|
|
2897
|
+
}
|
|
2898
|
+
interface RunOptimizationResult<TArtifact, TScenario extends Scenario> {
|
|
2899
|
+
/** One entry per proposal, with the candidates it registered. */
|
|
2900
|
+
generations: Array<{
|
|
2901
|
+
record: GenerationRecord;
|
|
2902
|
+
surfaces: Array<{
|
|
2903
|
+
surfaceHash: string;
|
|
2904
|
+
surface: MutableSurface;
|
|
2905
|
+
campaign: CampaignResult<TArtifact, TScenario>;
|
|
2906
|
+
}>;
|
|
2907
|
+
}>;
|
|
2908
|
+
/** Frozen snapshot of the exact starting surface measured by `baselineCampaign`. */
|
|
2909
|
+
baselineSurface: MutableSurface;
|
|
2910
|
+
winnerSurface: MutableSurface;
|
|
2911
|
+
winnerSurfaceHash: string;
|
|
2912
|
+
/** Proposer label for the kept surface; absent when the winner is the baseline. */
|
|
2913
|
+
winnerLabel?: string;
|
|
2914
|
+
/** Proposer rationale for the kept surface, as stored: redacted with the
|
|
2915
|
+
* share profile. Absent when the winner is the baseline. */
|
|
2916
|
+
winnerRationale?: string;
|
|
2917
|
+
baselineCampaign: CampaignResult<TArtifact, TScenario>;
|
|
2918
|
+
/** Run-wide spend, including agents, proposers, analysts, and judges. */
|
|
2919
|
+
cost: CostLedgerSummary;
|
|
2920
|
+
/** Bounded proof envelope over the search ledger. */
|
|
2921
|
+
searchHistory: SearchHistoryReceipt;
|
|
2922
|
+
/** The non-dominated set of measured surfaces by per-scenario composite. */
|
|
2923
|
+
paretoFrontier: ParetoParent[];
|
|
2924
|
+
}
|
|
2925
|
+
type RunImprovementLoopOptions<TScenario extends Scenario, TArtifact> = RunOptimizationOptions<TScenario, TArtifact> & {
|
|
2926
|
+
/** Holdout scenarios kept OUT of the training optimization pool — used
|
|
2927
|
+
* ONLY to score baseline vs winner for the gate. */
|
|
2928
|
+
holdoutScenarios: TScenario[];
|
|
2929
|
+
claim?: EvaluationClaim;
|
|
2930
|
+
finalEvidence?: FinalEvidencePolicy;
|
|
2931
|
+
/** Snapshot identity for agents without model receipts. Receipts take precedence. */
|
|
2932
|
+
model?: string;
|
|
2933
|
+
/** Declare a model change as part of the treatment before search starts. */
|
|
2934
|
+
modelTreatment?: ModelTreatment;
|
|
2935
|
+
/** Require one reported model id per arm (two spellings of one snapshot count as two), even
|
|
2936
|
+
* when neither arm reports a model call. Enabled by selfImprove. */
|
|
2937
|
+
requireReportedModel?: boolean;
|
|
2938
|
+
/** Holdout policy. Default `'measured'`: baseline + winner are re-scored on
|
|
2939
|
+
* `holdoutScenarios` and the gate decides on that held-out comparison.
|
|
2940
|
+
* `'deferred'`: the improvement-set (search) campaigns run exactly as usual,
|
|
2941
|
+
* but ZERO holdout cells are dispatched, the gate is forced to `'hold'`, and
|
|
2942
|
+
* the result + provenance record carry `holdout: 'deferred'` with NO
|
|
2943
|
+
* held-out lift — for callers that measure the held-out comparison in a
|
|
2944
|
+
* separate later run instead of faking a static holdout scenario and
|
|
2945
|
+
* recording a meaningless lift. */
|
|
2946
|
+
holdout?: 'measured' | 'deferred';
|
|
2947
|
+
/** Promotion gate. Substrate strongly recommends `defaultProductionGate`
|
|
2948
|
+
* for production wiring (composes red-team / reward-hacking / canary /
|
|
2949
|
+
* heldout). */
|
|
2950
|
+
gate: Gate<TArtifact, TScenario>;
|
|
2951
|
+
/** What to do when the gate ships:
|
|
2952
|
+
* - `'pr'`: open a PR via `openAutoPr`
|
|
2953
|
+
* - `'none'`: just report — caller decides what to do with the winner
|
|
2954
|
+
* Live-runtime self-mutation is intentionally unsupported. */
|
|
2955
|
+
autoOnPromote: 'pr' | 'none';
|
|
2956
|
+
/** GH owner / repo for the auto-PR. Required when autoOnPromote === 'pr'. */
|
|
2957
|
+
ghOwner?: string;
|
|
2958
|
+
ghRepo?: string;
|
|
2959
|
+
/** Placebo control. When supplied AND the winner differs from baseline, the
|
|
2960
|
+
* loop scores a THIRD holdout arm: the winner surface with its content
|
|
2961
|
+
* footprint-matched-blanked by this function (typically via `neutralizeText`).
|
|
2962
|
+
* Its scores are exposed to the gate as `ctx.neutralizedJudgeScores`, letting
|
|
2963
|
+
* a `neutralizationGate` reject a win whose lift survives blanking the content
|
|
2964
|
+
* (decorative — driven by footprint, not content). Costs one extra holdout
|
|
2965
|
+
* campaign; omit to skip. Return a byte/layout-matched blank of the winner. */
|
|
2966
|
+
neutralize?: (winnerSurface: MutableSurface, baselineSurface: MutableSurface) => MutableSurface;
|
|
2967
|
+
};
|
|
2968
|
+
interface RunImprovementLoopResult<TArtifact, TScenario extends Scenario> extends RunOptimizationResult<TArtifact, TScenario> {
|
|
2969
|
+
baselineOnHoldout: CampaignResult<TArtifact, TScenario>;
|
|
2970
|
+
winnerOnHoldout: CampaignResult<TArtifact, TScenario>;
|
|
2971
|
+
neutralizedOnHoldout?: CampaignResult<TArtifact, TScenario>;
|
|
2972
|
+
neutralizedSurface?: MutableSurface;
|
|
2973
|
+
gateResult: Awaited<ReturnType<Gate<TArtifact, TScenario>['decide']>>;
|
|
2974
|
+
claim?: EvaluationClaim;
|
|
2975
|
+
finalEvidence?: FinalEvidenceUse;
|
|
2976
|
+
modelComparison: ModelComparison;
|
|
2977
|
+
/** Present iff the loop ran with `holdout: 'deferred'`. When set,
|
|
2978
|
+
* `baselineOnHoldout`/`winnerOnHoldout` are the shared EMPTY campaign (zero
|
|
2979
|
+
* cells dispatched) and the gate verdict is the forced `'hold'`. */
|
|
2980
|
+
holdout?: 'deferred';
|
|
2981
|
+
/** Unified baseline→winner surface diff. Computed UNCONDITIONALLY (not only
|
|
2982
|
+
* when `autoOnPromote === 'pr'`) so the diff that the gate decided on is
|
|
2983
|
+
* always present on the result + in the emitted provenance record. Empty
|
|
2984
|
+
* string when winner == baseline (no change to diff). */
|
|
2985
|
+
promotedDiff: string;
|
|
2986
|
+
prResult?: ReturnType<typeof openAutoPr>;
|
|
2987
|
+
}
|
|
2988
|
+
/**
|
|
2989
|
+
* Gated-promotion shell over `runOptimization`: scores the winner against the baseline on a holdout set, runs the release gate, and optionally opens a PR.
|
|
2990
|
+
*/
|
|
2991
|
+
declare function runImprovementLoop<TScenario extends Scenario, TArtifact>(opts: RunImprovementLoopOptions<TScenario, TArtifact>): Promise<RunImprovementLoopResult<TArtifact, TScenario>>;
|
|
2992
|
+
export { emitLoopProvenance as $, ExternalTextEvaluationResponse as $n, CrossSurfacePairEvidence as $r, GepaEvaluationImport as $t, SkillOptRunnerCommand as A, planCampaignRun as Ai, CanaryEvaluation as An, CrossSurfaceAdditionRejectionReason as Ar, scoreUserStory as At, RetainedDispatchOptions as B, withFinalEvidenceSources as Bi, EvalFixtureScenario as Bn, CrossSurfaceComponentEvidence as Br, OptimizationMethodPairwise as Bt, codeSurfaceIdentityMaterial as C, CampaignCellFailureReceipt as Ci, RedTeamCategory as Cn, ExternalOptimizerObservationArtifact as Cr, PlaybackStep as Ct, surfaceDispatchRef as D, CampaignRunPlan as Di, redTeamReport as Dn, analyzeCrossSurfaceInteractions as Dr, UserStory as Dt, surfaceContentHash as E, runCampaign as Ei, redTeamDataset as En, readExternalOptimizerObservationArtifact as Er, ScoreboardSummary as Et, acquireSingleRunLock as F, cellCachePath as Fi, composeGate as Fn, CrossSurfaceCandidateComparison as Fr, RuntimeEventLike as Ft, EmitLoopProvenanceResult as G, campaignSplitDigest as Gi, loadEvalFixture as Gn, CrossSurfaceIneligibilityReason as Gr, neutralizeText as Gt, createRetainedDispatch as H, assertCampaignDesign as Hi, LoadEvalFixtureScenariosOptions as Hn, CrossSurfaceDistribution as Hr, compareOptimizationMethods as Ht, DiscriminationScore as I, FinalEvidencePolicy as Ii, EvalFixture as In, CrossSurfaceCandidateEvidence as Ir, ToolCallEventLike as It, LoopProvenanceCandidate as J, SearchLedgerIntegrityError as Ji, externalTextOptimizationMethod as Jn, CrossSurfaceInteractionPath as Jr, RolloutArgumentDiffOptions as Jt, LoopProvenanceArgsFromResult as K, campaignSplitDigestFromIdentities as Ki, loadEvalFixtureScenarios as Kn, CrossSurfaceInteractionAwareSelection as Kr, FsLabeledScenarioStoreOptions as Kt, ScenarioSignal as L, FinalEvidenceUse as Li, EvalFixtureFile as Ln, CrossSurfaceCandidateOutcome as Lr, extractProducedState as Lt, skillOptOptimizationMethod as M, CacheRead as Mi, CanaryOptions as Mn, CrossSurfaceBestSingleSelection as Mr, userStoryScoreboard as Mt, SingleRunLock as N, CellScheduleSlot as Ni, CanaryReport as Nn, CrossSurfaceBootstrapPolicy as Nr, ArtifactEventLike as Nt, surfaceHash as O, CampaignRunPlanCell as Oi, scoreRedTeamOutput as On, AnalyzeCrossSurfaceInteractionsInput as Or, UserStoryVerdict as Ot, SingleRunLockOptions as P, buildCellSchedule as Pi, runCanaries as Pn, CrossSurfaceCandidate as Pr, ProposalEventLike as Pt, canonicalDigest as Q, ExternalOptimizationExample as Qn, CrossSurfacePairCompatibility as Qr, ExternalSearchOptimizer as Qt, scoreDiscrimination as R, captureFinalEvidencePolicy as Ri, EvalFixtureLoadOptions as Rn, CrossSurfaceCandidateSummary as Rr, CompareOptimizationMethodsOptions as Rt, assertCodeSurfaceIdentity as S, runEval as Si, RedTeamCase as Sn, ExternalOptimizerExecutionSummary as Sr, PlaybackDriver as St, renderSurfaceDiff as T, RunCampaignOptions as Ti, RedTeamReport as Tn, ExternalOptimizerSubmittedCandidate as Tr, ScoreboardRow as Tt, BuildLoopProvenanceArgs as U, campaignCoverage as Ui, PlanEvalFixtureRunOptions as Un, CrossSurfaceEligibility as Ur, scopedOptimizationMethod as Ut, RetainedDispatchOutcome as V, CampaignCoverage as Vi, EvalFixtureValidationMode as Vn, CrossSurfaceCompositionStep as Vr, OptimizationMethodScore as Vt, EmitLoopProvenanceArgs as W, campaignScenarioIdentity as Wi, discoverEvalFixtures as Wn, CrossSurfaceEvidenceBreakdown as Wr, sequentialOptimizationMethod as Wt, LoopProvenanceOptimizationMethod as X, ExternalTextOptimizerContext as Xn, CrossSurfaceInteractionTask as Xr, ScoredRollout as Xt, LoopProvenanceEvidence as Y, ExternalTextOptimizationMethodConfig as Yn, CrossSurfaceInteractionReport as Yr, RolloutCall as Yt, LoopProvenanceRecord as Z, ExternalTextOptimizerResult as Zn, CrossSurfaceNaiveStackSelection as Zr, UngroundedLiteralReport as Zt, PhoenixEvaluationResultLike as _, llmJudge as _i, DefaultProductionGateCheck as _n, GepaCandidatePopulationArtifact as _r, BackendIntegrityError as _t, RunOptimizationOptions as a, CrossSurfaceSelections as ai, GepaEngineOptions as an, OptimizationMethodResult as ar, ProfileMatrixRow as at, isTransientTransportFailure as b, openAutoPr as bi, defaultProductionGate as bn, GepaCandidateSelectionScore as br, summarizeBackendIntegrity as bt, CodeSurfaceVerification as c, BuildTraceAnalystSurfaceDispatchOptions as ci, GepaOptimizationRecipe as cn, ArtifactEvidenceOptions as cr, createProfileMatrixPlan as ct, WorktreeAdapter as d, ReferenceEquivalenceJudgeInput as di, OpenAICompatibleOptimizerModel as dn, DescribeArtifact as dr, ProfileDispatchFn as dt, CrossSurfacePairIncompatibilityReason as ei, GepaPopulationImport as en, decodeExternalTextCandidate as er, CreateProfileMatrixPlanOptions as et, gitWorktreeAdapter as f, ReferenceEquivalenceJudgeOptions as fi, OptimizerModelBudget as fn, campaignBreakdown as fr, ProfileSummary as ft, AutoevalsScorerLike as g, LlmJudgeOptions as gi, heldOutGate as gn, costFromLedgerSummary as gr, runProfileMatrix as gt, AutoevalsScoreLike as h, LlmJudgeDimension as hi, HeldOutGateOptions as hn, OptimizationTokenUsage as hr, ScenarioRollup as ht, PremeasuredOptimizationBaseline as i, CrossSurfaceSelectionPolicy as ii, GepaAdaptiveEngineRun as in, OptimizationMethodProvenance as ir, ProfileMatrixPlan as it, SkillOptTrainerConfig as j, CacheIssueReason as ji, CanaryKind as jn, CrossSurfaceAttemptCompleteness as jr, scoreboardSummary as jt, SkillOptOptimizationMethodConfig as k, PlanCampaignRunOptions as ki, CanaryAlert as kn, CrossSurfaceAdditionDecision as kr, renderScoreboardMarkdown as kt, GitWorktreeAdapterOptions as l, TraceAnalystArtifact as li, GepaRunnerCommand as ln, CampaignBreakdown as lr, finalizeProfileMatrix as lt, verifyCodeSurface as m, ReferenceEquivalenceScenario as mi, neutralizationGate as mn, ComparisonCost as mr, RunProfileMatrixResult as mt, RunImprovementLoopResult as n, CrossSurfaceRankedSingle as ni, importExternalEvaluations as nn, OptimizationMethodComposition as nr, FinalizedProfileMatrixResult as nt, RunOptimizationResult as o, CrossSurfaceTaskRow as oi, GepaEngineRun as on, OptimizationMethodRunOptions as or, ProfileMatrixSegmentResult as ot, resolveWorktreePath as p, ReferenceEquivalenceJudgeResult as pi, NeutralizationGateOptions as pn, campaignMeanComposite as pr, RunProfileMatrixOptions as pt, LoopProvenanceBackend as q, SearchLedgerError as qi, planEvalFixtureRun as qn, CrossSurfaceInteractionEffect as qr, RolloutArgumentDiff as qt, runImprovementLoop as r, CrossSurfaceRelativeCost as ri, importGepaPopulation as rn, OptimizationMethodInput as rr, ProfileMatrixCoverage as rt, runOptimization as s, measureCampaignCost as si, GepaOptimizationMethodConfig as sn, OptimizationPackageSource as sr, RunProfileMatrixSegmentOptions as st, RunImprovementLoopOptions as t, CrossSurfacePairwiseEntry as ti, externalSurface as tn, OptimizationMethod as tr, FinalizeProfileMatrixOptions as tt, Worktree as u, TraceAnalystScenario as ui, gepaOptimizationMethod as un, CampaignComparisonUnits as ur, runProfileMatrixSegment as ut, PhoenixEvaluatorLike as v, OpenAutoPrOptions as vi, DefaultProductionGateOptions as vn, GepaCandidatePopulationCandidate as vr, BackendIntegrityReport as vt, componentSurfaceIdentityMaterial as w, CampaignCellRetryPolicy as wi, RedTeamFinding as wn, ExternalOptimizerObservationSummary as wr, ScoreboardRenderOptions as wt, transientDispatchFailure as x, RunEvalOptions as xi, DEFAULT_RED_TEAM_CORPUS as xn, readGepaCandidatePopulationArtifact as xr, PlaybackContext as xt, TransientFailureOptions as y, OpenAutoPrResult as yi, DefaultProductionRewardHackingOptions as yn, GepaCandidatePopulationSummary as yr, assertRealBackend as yt, resolveRunDir as z, prepareSearchFinalEvidence as zi, EvalFixtureRunPlan as zn, CrossSurfaceComponent as zr, OptimizationMethodComparison as zt };
|
|
2993
|
+
//# sourceMappingURL=run-improvement-loop-B1OKCm2D.d.ts.map
|