@tangle-network/agent-eval 2.0.7 → 2.0.10
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 +80 -16
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-CRdalpZv.d.ts → agent-profile-_JzxgLDM.d.ts} +11 -5
- package/dist/{agent-profile-CRdalpZv.d.ts.map → agent-profile-_JzxgLDM.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +14 -13
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +34 -13
- package/dist/analyst/index.js.map +1 -1
- package/dist/analyze-runs-Izz_ZeWg.d.ts +65 -0
- package/dist/analyze-runs-Izz_ZeWg.d.ts.map +1 -0
- package/dist/{analyze-runs-C_9cXPZn.js → analyze-runs-xhH2Qxoc.js} +6 -5
- package/dist/{analyze-runs-C_9cXPZn.js.map → analyze-runs-xhH2Qxoc.js.map} +1 -1
- package/dist/app-grade/index.d.ts +4 -4
- package/dist/app-grade/index.js +1 -1
- package/dist/{benchmark-command-DkBMUDwy.js → benchmark-command-CGQXNFj7.js} +12 -8
- package/dist/benchmark-command-CGQXNFj7.js.map +1 -0
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +4 -4
- package/dist/builder-eval/index.js +2 -2
- package/dist/calibration-CrORXMWx.d.ts +128 -0
- package/dist/calibration-CrORXMWx.d.ts.map +1 -0
- package/dist/{calibration-Cfoup0xz.js → calibration-Dz8mQb5P.js} +2 -2
- package/dist/{calibration-Cfoup0xz.js.map → calibration-Dz8mQb5P.js.map} +1 -1
- package/dist/campaign/index.d.ts +8 -8
- package/dist/campaign/index.js +13 -12
- package/dist/{campaign-DfSWSreo.js → campaign-eus7YRs2.js} +1590 -15
- package/dist/campaign-eus7YRs2.js.map +1 -0
- package/dist/{campaign-evidence-BojANgU7.d.ts → campaign-evidence-BOcX4w0r.d.ts} +5 -5
- package/dist/{campaign-evidence-BojANgU7.d.ts.map → campaign-evidence-BOcX4w0r.d.ts.map} +1 -1
- package/dist/{campaign-evidence-D_oBFfLc.js → campaign-evidence-KM5GTsHG.js} +5 -5
- package/dist/{campaign-evidence-D_oBFfLc.js.map → campaign-evidence-KM5GTsHG.js.map} +1 -1
- package/dist/{cluster-Bj90LK-1.d.ts → chat-client-BlTooBDA.d.ts} +9 -241
- package/dist/chat-client-BlTooBDA.d.ts.map +1 -0
- package/dist/{chat-client-CvyDOQBv.js → chat-client-Oyot5tyo.js} +2 -2
- package/dist/{chat-client-CvyDOQBv.js.map → chat-client-Oyot5tyo.js.map} +1 -1
- package/dist/{chat-json-call-DMrwmB-k.js → chat-json-call-DTmv2uNY.js} +2 -2
- package/dist/{chat-json-call-DMrwmB-k.js.map → chat-json-call-DTmv2uNY.js.map} +1 -1
- package/dist/cli.js +7 -7
- package/dist/cluster-BJ0nW3P7.d.ts +241 -0
- package/dist/cluster-BJ0nW3P7.d.ts.map +1 -0
- package/dist/{cluster-bootstrap-DPzVy3_K.js → cluster-bootstrap-CTC8Dd30.js} +3 -2
- package/dist/{cluster-bootstrap-DPzVy3_K.js.map → cluster-bootstrap-CTC8Dd30.js.map} +1 -1
- package/dist/{completion-verifier-DsotH2l3.js → completion-verifier-CCPG2Yc0.js} +3 -3
- package/dist/{completion-verifier-DsotH2l3.js.map → completion-verifier-CCPG2Yc0.js.map} +1 -1
- package/dist/{completion-verifier-Cy38EpGE.d.ts → completion-verifier-CQOC3_bm.d.ts} +2 -2
- package/dist/{completion-verifier-Cy38EpGE.d.ts.map → completion-verifier-CQOC3_bm.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +14 -12
- package/dist/contract/index.js +14 -12
- package/dist/contract/index.js.map +1 -1
- package/dist/{decision-point-C46p-p9v.js → decision-point-CfqtnGop.js} +3 -3
- package/dist/{decision-point-C46p-p9v.js.map → decision-point-CfqtnGop.js.map} +1 -1
- package/dist/{default-registry-BWFPtmuI.js → default-registry-Rs5uzlfJ.js} +4 -4
- package/dist/{default-registry-BWFPtmuI.js.map → default-registry-Rs5uzlfJ.js.map} +1 -1
- package/dist/{default-registry-xoX0PMCb.d.ts → default-registry-X8McMoUV.d.ts} +6 -6
- package/dist/{default-registry-xoX0PMCb.d.ts.map → default-registry-X8McMoUV.d.ts.map} +1 -1
- package/dist/define-agent-eval-D8ntOXqV.js +96 -0
- package/dist/define-agent-eval-D8ntOXqV.js.map +1 -0
- package/dist/define-agent-eval-DH5-xi-F.d.ts +52 -0
- package/dist/define-agent-eval-DH5-xi-F.d.ts.map +1 -0
- package/dist/diagnosis/index.d.ts +3 -3
- package/dist/diagnosis/index.js +1 -1
- package/dist/{dspy-rlm-engine-r7YpKLhS.js → dspy-rlm-engine-ChE1PUM5.js} +3 -3
- package/dist/{dspy-rlm-engine-r7YpKLhS.js.map → dspy-rlm-engine-ChE1PUM5.js.map} +1 -1
- package/dist/{emitter-BjW3NnX-.js → emitter-xN9wGTVw.js} +9 -2
- package/dist/{emitter-BjW3NnX-.js.map → emitter-xN9wGTVw.js.map} +1 -1
- package/dist/{eval-campaign-Cyk-tkLh.js → eval-campaign-BciGnrGy.js} +3 -3
- package/dist/{eval-campaign-Cyk-tkLh.js.map → eval-campaign-BciGnrGy.js.map} +1 -1
- package/dist/{evaluation-X5E22NQK.d.ts → evaluation-CjZH6gW0.d.ts} +4 -4
- package/dist/{evaluation-X5E22NQK.d.ts.map → evaluation-CjZH6gW0.d.ts.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/{exact-types-DjuabhUV.d.ts → exact-types-BIHqYBYf.d.ts} +2 -2
- package/dist/{exact-types-DjuabhUV.d.ts.map → exact-types-BIHqYBYf.d.ts.map} +1 -1
- package/dist/{execution-insight-CE20Bxq0.d.ts → execution-insight-YihQrSqd.d.ts} +2 -2
- package/dist/{execution-insight-CE20Bxq0.d.ts.map → execution-insight-YihQrSqd.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +5 -5
- package/dist/experiment/index.js +10 -184
- package/dist/experiment/index.js.map +1 -1
- package/dist/{external-optimizer-contracts-ZDBfbZ_s.js → external-optimizer-contracts-BFV8lnhl.js} +7 -2
- package/dist/{external-optimizer-contracts-ZDBfbZ_s.js.map → external-optimizer-contracts-BFV8lnhl.js.map} +1 -1
- package/dist/{external-optimizer-process-4QdcF7Kd.js → external-optimizer-process-B6emPodQ.js} +3 -3
- package/dist/{external-optimizer-process-4QdcF7Kd.js.map → external-optimizer-process-B6emPodQ.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-BW0ZWUUr.js → external-optimizer-subprocess-_O06eDVA.js} +35 -376
- package/dist/external-optimizer-subprocess-_O06eDVA.js.map +1 -0
- package/dist/{feedback-trajectory-BMkJezPc.d.ts → feedback-trajectory-CoQPmSJV.d.ts} +3 -3
- package/dist/{feedback-trajectory-BMkJezPc.d.ts.map → feedback-trajectory-CoQPmSJV.d.ts.map} +1 -1
- package/dist/finding-scope-B_As3F_v.js +359 -0
- package/dist/finding-scope-B_As3F_v.js.map +1 -0
- package/dist/{findings-store-DV8WA5nD.js → findings-store-CvYUzQBR.js} +4 -4
- package/dist/{findings-store-DV8WA5nD.js.map → findings-store-CvYUzQBR.js.map} +1 -1
- package/dist/fuzz.js +1 -1
- package/dist/{index-C6TG1LwA.d.ts → index-BSb3fJyZ.d.ts} +318 -131
- package/dist/index-BSb3fJyZ.d.ts.map +1 -0
- package/dist/{index-CKjqN9_U.d.ts → index-Bk1XEkP7.d.ts} +99 -3
- package/dist/index-Bk1XEkP7.d.ts.map +1 -0
- package/dist/{index-DAFZRMlF.d.ts → index-BmWw8zN6.d.ts} +10 -8
- package/dist/index-BmWw8zN6.d.ts.map +1 -0
- package/dist/{index-DKpMyD_Z.d.ts → index-CCOaNmh2.d.ts} +7 -7
- package/dist/{index-DKpMyD_Z.d.ts.map → index-CCOaNmh2.d.ts.map} +1 -1
- package/dist/{index-xEM_SoCl.d.ts → index-ZffK_5sD.d.ts} +22 -20
- package/dist/index-ZffK_5sD.d.ts.map +1 -0
- package/dist/{index-BqAPIToS.d.ts → index-aRalB_Ma.d.ts} +3 -3
- package/dist/{index-BqAPIToS.d.ts.map → index-aRalB_Ma.d.ts.map} +1 -1
- package/dist/index.d.ts +33 -29
- package/dist/index.js +28 -25
- package/dist/index.js.map +1 -1
- package/dist/{analyze-runs-xjKBBqIB.d.ts → insight-report-DYofCMLx.d.ts} +4 -64
- package/dist/insight-report-DYofCMLx.d.ts.map +1 -0
- package/dist/{integrity-BF0tJK21.js → integrity-DacT3oJ1.js} +2 -2
- package/dist/{integrity-BF0tJK21.js.map → integrity-DacT3oJ1.js.map} +1 -1
- package/dist/{integrity-B9320cw1.d.ts → integrity-DotDLWtj.d.ts} +2 -2
- package/dist/{integrity-B9320cw1.d.ts.map → integrity-DotDLWtj.d.ts.map} +1 -1
- package/dist/{judge-gate-DqlzOBOm.js → judge-gate-CpD3wmcf.js} +3 -3
- package/dist/{judge-gate-DqlzOBOm.js.map → judge-gate-CpD3wmcf.js.map} +1 -1
- package/dist/{llm-client-Dw4x6EdE.js → llm-client-Dk8lBnMh.js} +15 -2
- package/dist/{llm-client-Dw4x6EdE.js.map → llm-client-Dk8lBnMh.js.map} +1 -1
- package/dist/llm-judge-DYmEdo3M.js +476 -0
- package/dist/llm-judge-DYmEdo3M.js.map +1 -0
- package/dist/{matrix-CqZSpwgN.d.ts → matrix-BDl7hoBr.d.ts} +6 -2
- package/dist/matrix-BDl7hoBr.d.ts.map +1 -0
- package/dist/measure-validity-plan-BReXzcVh.d.ts +201 -0
- package/dist/measure-validity-plan-BReXzcVh.d.ts.map +1 -0
- package/dist/measure-validity-plan-CJkBNzX_.js +154 -0
- package/dist/measure-validity-plan-CJkBNzX_.js.map +1 -0
- package/dist/meta-eval/index.d.ts +5 -3
- package/dist/meta-eval/index.js +808 -15
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +497 -4
- package/dist/multishot/index.d.ts.map +1 -1
- package/dist/multishot/index.js +1000 -48
- package/dist/multishot/index.js.map +1 -1
- package/dist/node-transport-DJno8V46.js +62 -0
- package/dist/node-transport-DJno8V46.js.map +1 -0
- package/dist/openapi.json +1 -1
- package/dist/{llm-judge-DQJTQx01.js → optimization-method-4JlbMxd2.js} +38 -513
- package/dist/optimization-method-4JlbMxd2.js.map +1 -0
- package/dist/{outcome-observations-DL3CC8w1.js → outcome-observations-DEh8_V_P.js} +31 -6
- package/dist/outcome-observations-DEh8_V_P.js.map +1 -0
- package/dist/outcome-store-CHtuvstd.d.ts +56 -0
- package/dist/outcome-store-CHtuvstd.d.ts.map +1 -0
- package/dist/{paired-arms-DZhH3FGu.js → paired-arms-CJH5Q0wx.js} +3 -2
- package/dist/{paired-arms-DZhH3FGu.js.map → paired-arms-CJH5Q0wx.js.map} +1 -1
- package/dist/{paired-promotion-decision-Dn3-jaq4.js → paired-promotion-decision-BtfVwEAk.js} +3 -2
- package/dist/{paired-promotion-decision-Dn3-jaq4.js.map → paired-promotion-decision-BtfVwEAk.js.map} +1 -1
- package/dist/{paired-promotion-decision-ChHBuuHV.d.ts → paired-promotion-decision-DJlI4z_k.d.ts} +2 -2
- package/dist/{paired-promotion-decision-ChHBuuHV.d.ts.map → paired-promotion-decision-DJlI4z_k.d.ts.map} +1 -1
- package/dist/{paired-promotion-power-BlzXdgMD.js → paired-promotion-power-DG1avBKf.js} +3 -3
- package/dist/{paired-promotion-power-BlzXdgMD.js.map → paired-promotion-power-DG1avBKf.js.map} +1 -1
- package/dist/paired-tests-CXcD_B80.js +688 -0
- package/dist/paired-tests-CXcD_B80.js.map +1 -0
- package/dist/pareto-DIVE5D0T.js +81 -0
- package/dist/pareto-DIVE5D0T.js.map +1 -0
- package/dist/pipelines/index.d.ts +2 -1
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js +1 -1
- package/dist/{sequential-BphITa5b.js → power-COie_o6E.js} +181 -4
- package/dist/power-COie_o6E.js.map +1 -0
- package/dist/{prime-protocol-Cv6_47rh.d.ts → prime-protocol-BRMk6dGI.d.ts} +2 -2
- package/dist/{prime-protocol-Cv6_47rh.d.ts.map → prime-protocol-BRMk6dGI.d.ts.map} +1 -1
- package/dist/{promotion-gate-CGkxh36r.d.ts → promotion-gate-B0VTBoXg.d.ts} +2 -2
- package/dist/{promotion-gate-CGkxh36r.d.ts.map → promotion-gate-B0VTBoXg.d.ts.map} +1 -1
- package/dist/{promotion-policy-CxDIh-9p.js → promotion-policy-BgI7PsQn.js} +4 -4
- package/dist/{promotion-policy-CxDIh-9p.js.map → promotion-policy-BgI7PsQn.js.map} +1 -1
- package/dist/{proposal-findings-DedMih-u.js → proposal-findings-CfRFCFXS.js} +2 -2
- package/dist/{proposal-findings-DedMih-u.js.map → proposal-findings-CfRFCFXS.js.map} +1 -1
- package/dist/{registry-CIjC6SdV.d.ts → registry-BeInzotS.d.ts} +4 -4
- package/dist/{registry-CIjC6SdV.d.ts.map → registry-BeInzotS.d.ts.map} +1 -1
- package/dist/{release-confidence-BLHOMK5Q.js → release-confidence-Cndq1hwi.js} +2 -2
- package/dist/{release-confidence-BLHOMK5Q.js.map → release-confidence-Cndq1hwi.js.map} +1 -1
- package/dist/reporting.d.ts +5 -5
- package/dist/reporting.js +6 -5
- package/dist/reporting.js.map +1 -1
- package/dist/{research-report-D6XIK0eK.d.ts → research-report-CL5_UqCX.d.ts} +2 -2
- package/dist/{research-report-D6XIK0eK.d.ts.map → research-report-CL5_UqCX.d.ts.map} +1 -1
- package/dist/{researcher---DhHG4J.d.ts → researcher-BOpZP_Ja.d.ts} +4 -4
- package/dist/{researcher---DhHG4J.d.ts.map → researcher-BOpZP_Ja.d.ts.map} +1 -1
- package/dist/{reward-hacking-DKAflk2c.js → reward-hacking-DMTm1OBd.js} +2 -2
- package/dist/{reward-hacking-DKAflk2c.js.map → reward-hacking-DMTm1OBd.js.map} +1 -1
- package/dist/rl.d.ts +9 -8
- package/dist/rl.d.ts.map +1 -1
- package/dist/rl.js +11 -10
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +2 -2
- package/dist/rollout/index.js +1 -1
- package/dist/{rollout-B_lrpd9a.js → rollout--rSr43Pd.js} +2 -2
- package/dist/{rollout-B_lrpd9a.js.map → rollout--rSr43Pd.js.map} +1 -1
- package/dist/{rollout-nodes-Vas6OSxX.js → rollout-nodes-DFxKpIr2.js} +39 -10
- package/dist/rollout-nodes-DFxKpIr2.js.map +1 -0
- package/dist/{rubric-predictive-validity--6z0q8s6.js → rubric-predictive-validity-BXJ92Jp_.js} +3 -9
- package/dist/rubric-predictive-validity-BXJ92Jp_.js.map +1 -0
- package/dist/{rubric-predictive-validity-C9wc7f_D.d.ts → rubric-predictive-validity-DH94_0Q1.d.ts} +3 -56
- package/dist/rubric-predictive-validity-DH94_0Q1.d.ts.map +1 -0
- package/dist/{run-improvement-loop-BfwOUudy.d.ts → run-improvement-loop-BeHu5D9Z.d.ts} +396 -11
- package/dist/run-improvement-loop-BeHu5D9Z.d.ts.map +1 -0
- package/dist/{run-record-Bqg0NZ_e.js → run-record-CuO8ErrI.js} +3 -2
- package/dist/run-record-CuO8ErrI.js.map +1 -0
- package/dist/{runtime-rollouts-drQynu3t.js → runtime-rollouts-CE0MbQPq.js} +55 -8
- package/dist/runtime-rollouts-CE0MbQPq.js.map +1 -0
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-DJq9bUDU.d.ts → search-kernel-CJZ-ZSV1.d.ts} +3 -3
- package/dist/{search-kernel-DJq9bUDU.d.ts.map → search-kernel-CJZ-ZSV1.d.ts.map} +1 -1
- package/dist/{pareto-Bg75Gajo.js → search-kernel-mZc79S6N.js} +6 -88
- package/dist/search-kernel-mZc79S6N.js.map +1 -0
- package/dist/{search-summary-B1x1Vmzh.js → search-summary-CCgP2qXz.js} +4 -4
- package/dist/{search-summary-B1x1Vmzh.js.map → search-summary-CCgP2qXz.js.map} +1 -1
- package/dist/{define-agent-eval-Cjc0wWnO.d.ts → self-improve-B1fsNejr.d.ts} +8 -54
- package/dist/self-improve-B1fsNejr.d.ts.map +1 -0
- package/dist/{define-agent-eval-B6uE3gNu.js → self-improve-C_Bcdmv8.js} +9 -97
- package/dist/self-improve-C_Bcdmv8.js.map +1 -0
- package/dist/{sequential-BhbTSxpt.d.ts → sequential-CHplorpC.d.ts} +2 -2
- package/dist/{sequential-BhbTSxpt.d.ts.map → sequential-CHplorpC.d.ts.map} +1 -1
- package/dist/{sequential-ux_XrjBf.js → sequential-DR-pnYQ7.js} +3 -3
- package/dist/{sequential-ux_XrjBf.js.map → sequential-DR-pnYQ7.js.map} +1 -1
- package/dist/{server-1fzBCxMh.js → server-aZFmRucn.js} +3 -3
- package/dist/{server-1fzBCxMh.js.map → server-aZFmRucn.js.map} +1 -1
- package/dist/{skillopt-optimization-method-D_swD0Cy.js → skillopt-optimization-method-DHk1K757.js} +95 -40
- package/dist/skillopt-optimization-method-DHk1K757.js.map +1 -0
- package/dist/{statistical-heldout-CaS4T-43.js → statistical-heldout-CL_7mI5C.js} +3 -3
- package/dist/{statistical-heldout-CaS4T-43.js.map → statistical-heldout-CL_7mI5C.js.map} +1 -1
- package/dist/{statistics-DSidA5I2.js → statistics-AKnVFnK-.js} +233 -700
- package/dist/statistics-AKnVFnK-.js.map +1 -0
- package/dist/statistics.d.ts +3 -3
- package/dist/statistics.js +3 -2
- package/dist/{store-tool-spans-DniaFwjM.d.ts → store-tool-spans-M3WxeRrG.d.ts} +4 -4
- package/dist/{store-tool-spans-DniaFwjM.d.ts.map → store-tool-spans-M3WxeRrG.d.ts.map} +1 -1
- package/dist/{summary-report-CI4J6gxU.js → summary-report-DyBkOC6V.js} +15 -7
- package/dist/summary-report-DyBkOC6V.js.map +1 -0
- package/dist/summary-report-figures-CJHygLgw.d.ts.map +1 -1
- package/dist/supervisor-run/index.d.ts +12 -2
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +3 -3
- package/dist/{systemone-DzY-2Zri.d.ts → systemone-4PadCE4C.d.ts} +8 -7
- package/dist/systemone-4PadCE4C.d.ts.map +1 -0
- package/dist/{systemone-review-CXecR_m-.d.ts → systemone-review-DpAXWDkL.d.ts} +2 -2
- package/dist/{systemone-review-CXecR_m-.d.ts.map → systemone-review-DpAXWDkL.d.ts.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/systemone.js +1 -1
- package/dist/{tool-groups-DF6OqhoG.d.ts → tool-groups-SlnoQNyT.d.ts} +2 -2
- package/dist/tool-groups-SlnoQNyT.d.ts.map +1 -0
- package/dist/tool-waste-B01AMpID.d.ts +121 -0
- package/dist/tool-waste-B01AMpID.d.ts.map +1 -0
- package/dist/{tool-waste-u7JJ_BlE.js → tool-waste-BZnYSa6J.js} +3 -2
- package/dist/{tool-waste-u7JJ_BlE.js.map → tool-waste-BZnYSa6J.js.map} +1 -1
- package/dist/{trace-questions-DO8y3J-E.d.ts → trace-questions-ybyF0B6N.d.ts} +2 -2
- package/dist/{trace-questions-DO8y3J-E.d.ts.map → trace-questions-ybyF0B6N.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/trace-repair/index.js +1 -1
- package/dist/traces.d.ts +4 -4
- package/dist/traces.js +1 -1
- package/dist/trajectory-B3o6Ald_.d.ts +100 -0
- package/dist/trajectory-B3o6Ald_.d.ts.map +1 -0
- package/dist/trajectory-replay/index.js +1 -1
- package/dist/{tree-DQMlcNFI.js → tree-CiIe-f3f.js} +6 -4
- package/dist/{tree-DQMlcNFI.js.map → tree-CiIe-f3f.js.map} +1 -1
- package/dist/{types-fuOwNq1C.d.ts → types-B1W3v8dT.d.ts} +3 -2
- package/dist/types-B1W3v8dT.d.ts.map +1 -0
- package/dist/{types-BMSDkS8l.d.ts → types-D5XtEH9Q.d.ts} +11 -4
- package/dist/{types-BMSDkS8l.d.ts.map → types-D5XtEH9Q.d.ts.map} +1 -1
- package/dist/types-DK4vNv5q.js.map +1 -1
- package/dist/{types-D_PfKC59.d.ts → types-an-CUndX.d.ts} +2 -2
- package/dist/{types-D_PfKC59.d.ts.map → types-an-CUndX.d.ts.map} +1 -1
- package/dist/{types-BLv2Ngla.d.ts → types-xVtEOBhO.d.ts} +31 -8
- package/dist/types-xVtEOBhO.d.ts.map +1 -0
- package/dist/wire/index.d.ts +2 -2
- package/dist/wire/index.js +1 -1
- package/dist/world/index.d.ts +529 -0
- package/dist/world/index.d.ts.map +1 -0
- package/dist/world/index.js +1356 -0
- package/dist/world/index.js.map +1 -0
- package/docs/campaign-proposers.md +7 -0
- package/docs/concepts.md +2 -0
- package/docs/design/statistics-decisions.md +48 -0
- package/docs/eval-surface-map.md +5 -2
- package/docs/feature-guide.md +3 -1
- package/docs/multi-turn-optimization.md +84 -0
- package/docs/outcome-validity.md +108 -0
- package/docs/public-api.md +89 -34
- package/docs/{multi-shot-optimization.md → trajectory-optimization.md} +1 -1
- package/docs/world.md +104 -0
- package/package.json +6 -1
- package/dist/analyze-runs-xjKBBqIB.d.ts.map +0 -1
- package/dist/benchmark-command-DkBMUDwy.js.map +0 -1
- package/dist/campaign-DfSWSreo.js.map +0 -1
- package/dist/cluster-Bj90LK-1.d.ts.map +0 -1
- package/dist/define-agent-eval-B6uE3gNu.js.map +0 -1
- package/dist/define-agent-eval-Cjc0wWnO.d.ts.map +0 -1
- package/dist/external-optimizer-subprocess-BW0ZWUUr.js.map +0 -1
- package/dist/index-C6TG1LwA.d.ts.map +0 -1
- package/dist/index-CKjqN9_U.d.ts.map +0 -1
- package/dist/index-DAFZRMlF.d.ts.map +0 -1
- package/dist/index-xEM_SoCl.d.ts.map +0 -1
- package/dist/interval-CWyxqDpE.d.ts +0 -43
- package/dist/interval-CWyxqDpE.d.ts.map +0 -1
- package/dist/llm-judge-DQJTQx01.js.map +0 -1
- package/dist/matrix-CqZSpwgN.d.ts.map +0 -1
- package/dist/outcome-observations-DL3CC8w1.js.map +0 -1
- package/dist/pareto-Bg75Gajo.js.map +0 -1
- package/dist/rollout-nodes-Vas6OSxX.js.map +0 -1
- package/dist/rubric-predictive-validity--6z0q8s6.js.map +0 -1
- package/dist/rubric-predictive-validity-C9wc7f_D.d.ts.map +0 -1
- package/dist/run-improvement-loop-BfwOUudy.d.ts.map +0 -1
- package/dist/run-record-Bqg0NZ_e.js.map +0 -1
- package/dist/runtime-rollouts-drQynu3t.js.map +0 -1
- package/dist/sequential-BphITa5b.js.map +0 -1
- package/dist/skillopt-optimization-method-D_swD0Cy.js.map +0 -1
- package/dist/statistics-DSidA5I2.js.map +0 -1
- package/dist/summary-report-CI4J6gxU.js.map +0 -1
- package/dist/systemone-DzY-2Zri.d.ts.map +0 -1
- package/dist/tool-groups-DF6OqhoG.d.ts.map +0 -1
- package/dist/tool-waste-CIhtU1ad.d.ts +0 -217
- package/dist/tool-waste-CIhtU1ad.d.ts.map +0 -1
- package/dist/types-BLv2Ngla.d.ts.map +0 -1
- package/dist/types-fuOwNq1C.d.ts.map +0 -1
|
@@ -3,24 +3,29 @@ import { a as hashCanonical, i as compareCodeUnits, r as canonicalString } from
|
|
|
3
3
|
import { a as agentProfileModelId, i as agentProfileId, r as agentProfileHash, s as harnessAxisOf } from "./agent-profile-CCw6EXWW.js";
|
|
4
4
|
import { i as buildAgentProfileCell } from "./agent-profile-cell-CUthydZB.js";
|
|
5
5
|
import { a as modelSnapshot, i as modelHasSnapshot, l as validateRunRecord, n as UNKNOWN_MODEL, s as runTaskScore } from "./run-record-CqUft6Yf.js";
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { t as escapeHtml } from "./reporting-html-DMXIjATy.js";
|
|
7
|
+
import { t as comparePairedArms } from "./paired-arms-CJH5Q0wx.js";
|
|
8
|
+
import { E as zQuantile, S as makeRng, _ as mean, r as pairedBootstrap, v as meanOrNull } from "./paired-tests-CXcD_B80.js";
|
|
9
|
+
import { I as clusterJackknife, P as percentileNearestRank, S as holm, l as requiredPairedSampleSize, s as mcnemarRequiredN, v as passHatK, y as wilson, z as clusteredPairedContrast } from "./statistics-AKnVFnK-.js";
|
|
10
|
+
import { n as paretoFrontier } from "./pareto-DIVE5D0T.js";
|
|
11
|
+
import { o as pairHoldout } from "./statistical-heldout-CL_7mI5C.js";
|
|
9
12
|
import { a as mapConcurrent } from "./journal-3y-btqaP.js";
|
|
10
13
|
import { n as contentHash, t as canonicalJson } from "./verdict-cache-BPaYxfG8.js";
|
|
11
|
-
import {
|
|
12
|
-
import { n as campaignCellToRunRecord, r as projectCampaignCellQuality, t as campaignCellCostProvenance } from "./run-record-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
14
|
+
import { $ as planCampaignRun, Q as runCampaign, a as combineComparisonCosts, at as computeManifestHash, et as resolveRunDir, n as executeOptimizationMethod, rt as cellCachePath, tt as cellReceiptModels } from "./optimization-method-4JlbMxd2.js";
|
|
15
|
+
import { n as campaignCellToRunRecord, r as projectCampaignCellQuality, t as campaignCellCostProvenance } from "./run-record-CuO8ErrI.js";
|
|
16
|
+
import { E as assertRealBackend, N as campaignScenarioIdentity, O as summarizeBackendIntegrity, k as assertCampaignDesign } from "./campaign-evidence-KM5GTsHG.js";
|
|
17
|
+
import { p as fsCampaignStorage } from "./finding-scope-B_As3F_v.js";
|
|
18
|
+
import "./llm-judge-DYmEdo3M.js";
|
|
15
19
|
import { r as assertCodeSurfaceIdentity, s as surfaceContentHash } from "./json-recovery-BRUCeQxo.js";
|
|
16
20
|
import "./search-ledger-C7t68cmy.js";
|
|
17
|
-
import "./
|
|
21
|
+
import "./search-kernel-mZc79S6N.js";
|
|
18
22
|
import "./types-_tlhWGUq.js";
|
|
19
|
-
import "./search-summary-
|
|
20
|
-
import { r as verifyCompletion } from "./completion-verifier-
|
|
21
|
-
import "./
|
|
22
|
-
import "./
|
|
23
|
-
import "./
|
|
23
|
+
import "./search-summary-CCgP2qXz.js";
|
|
24
|
+
import { r as verifyCompletion } from "./completion-verifier-CCPG2Yc0.js";
|
|
25
|
+
import { r as calibrationFromPairs, t as brierScore } from "./calibration-Dz8mQb5P.js";
|
|
26
|
+
import "./external-optimizer-process-B6emPodQ.js";
|
|
27
|
+
import "./skillopt-optimization-method-DHk1K757.js";
|
|
28
|
+
import { n as clusteredPower } from "./power-COie_o6E.js";
|
|
24
29
|
import { createHash } from "node:crypto";
|
|
25
30
|
import { z } from "zod";
|
|
26
31
|
import { closeSync, constants, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync } from "node:fs";
|
|
@@ -1353,6 +1358,1325 @@ function renderScoreboardMarkdown(rows, opts = {}) {
|
|
|
1353
1358
|
}
|
|
1354
1359
|
return out.join("\n");
|
|
1355
1360
|
}
|
|
1361
|
+
// src/campaign/presets/profile-matrix-stability.ts
|
|
1362
|
+
/**
|
|
1363
|
+
* How far a profile-matrix verdict can be trusted: the familywise adjustment that turns each
|
|
1364
|
+
* profile's paired difference from the baseline into a verdict, and the run-to-run noise of a
|
|
1365
|
+
* profile run more than once. `analyzeProfileMatrix` calls both and re-exports these types.
|
|
1366
|
+
*/
|
|
1367
|
+
/** Whether an interval lies wholly above zero, wholly below it, or includes it. */
|
|
1368
|
+
function intervalSide(i) {
|
|
1369
|
+
if (i.low !== null && i.low > 0) return "up";
|
|
1370
|
+
if (i.high !== null && i.high < 0) return "down";
|
|
1371
|
+
return "flat";
|
|
1372
|
+
}
|
|
1373
|
+
/** The run a record belongs to: the campaign's `outcome.raw.rep`, or run 0 when absent. */
|
|
1374
|
+
function runOf(record) {
|
|
1375
|
+
const rep = record.outcome.raw.rep;
|
|
1376
|
+
return Number.isFinite(rep) ? rep : 0;
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* Holm over every profile-against-baseline p-value on the page, so the better and worse verdicts
|
|
1380
|
+
* together keep the familywise error at `alpha`. A comparison without a p-value cannot pass, so
|
|
1381
|
+
* it stays out of the family instead of raising everyone else's bar.
|
|
1382
|
+
*/
|
|
1383
|
+
function withVerdicts(stats, baseline, alpha) {
|
|
1384
|
+
const tested = stats.filter((p) => typeof p.vsBaseline?.pValue === "number");
|
|
1385
|
+
const { adjusted } = holm(tested.map((p) => p.vsBaseline.pValue), alpha);
|
|
1386
|
+
const adjustedOf = new Map(tested.map((p, index) => [p.profileId, adjusted[index]]));
|
|
1387
|
+
return {
|
|
1388
|
+
profiles: stats.map((p) => {
|
|
1389
|
+
if (p.profileId === baseline) return p;
|
|
1390
|
+
const adjustedPValue = adjustedOf.get(p.profileId) ?? null;
|
|
1391
|
+
const side = p.vsBaseline ? intervalSide(p.vsBaseline) : "flat";
|
|
1392
|
+
const verdict = side === "flat" ? "unresolved" : adjustedPValue !== null && adjustedPValue <= alpha ? side === "up" ? "better" : "worse" : "candidate";
|
|
1393
|
+
return {
|
|
1394
|
+
...p,
|
|
1395
|
+
adjustedPValue,
|
|
1396
|
+
verdict
|
|
1397
|
+
};
|
|
1398
|
+
}),
|
|
1399
|
+
family: {
|
|
1400
|
+
method: "holm",
|
|
1401
|
+
alpha,
|
|
1402
|
+
comparisons: tested.length
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Each profile with two or more runs, on the cases every one of its runs scored. A run's score
|
|
1408
|
+
* on a case is the mean of its records there, and its answer the last one `answerOf` returned.
|
|
1409
|
+
*/
|
|
1410
|
+
function runStability(input) {
|
|
1411
|
+
const z = zQuantile(1 - (1 - input.level) / 2);
|
|
1412
|
+
const panelN = input.commonCases;
|
|
1413
|
+
const right = (score) => score >= input.passScore;
|
|
1414
|
+
const share = (values) => values.length ? {
|
|
1415
|
+
mean: mean(values),
|
|
1416
|
+
min: Math.min(...values),
|
|
1417
|
+
max: Math.max(...values)
|
|
1418
|
+
} : null;
|
|
1419
|
+
return input.profileIds.flatMap((profileId) => {
|
|
1420
|
+
const scores = /* @__PURE__ */ new Map();
|
|
1421
|
+
const answers = /* @__PURE__ */ new Map();
|
|
1422
|
+
for (const record of input.recordsByProfile.get(profileId)) {
|
|
1423
|
+
const run = runOf(record);
|
|
1424
|
+
const own = scores.get(run) ?? /* @__PURE__ */ new Map();
|
|
1425
|
+
scores.set(run, own);
|
|
1426
|
+
const score = runTaskScore(record);
|
|
1427
|
+
if (score === void 0) continue;
|
|
1428
|
+
own.set(record.scenarioId, [...own.get(record.scenarioId) ?? [], score]);
|
|
1429
|
+
const answer = input.answerOf?.(record);
|
|
1430
|
+
if (answer === void 0) continue;
|
|
1431
|
+
const given = answers.get(run) ?? /* @__PURE__ */ new Map();
|
|
1432
|
+
given.set(record.scenarioId, answer);
|
|
1433
|
+
answers.set(run, given);
|
|
1434
|
+
}
|
|
1435
|
+
if (scores.size < 2) return [];
|
|
1436
|
+
const runs = [...scores.keys()].sort((a, b) => a - b);
|
|
1437
|
+
const scoreIn = (run, caseId) => mean(scores.get(run).get(caseId));
|
|
1438
|
+
const cases = [...scores.get(runs[0]).keys()].filter((caseId) => runs.every((run) => scores.get(run).has(caseId))).sort();
|
|
1439
|
+
const n = cases.length;
|
|
1440
|
+
const pairs = runs.flatMap((a, index) => runs.slice(index + 1).map((b) => [a, b]));
|
|
1441
|
+
const runQuality = runs.map((run) => ({
|
|
1442
|
+
run,
|
|
1443
|
+
quality: n ? mean(cases.map((caseId) => scoreIn(run, caseId))) : null
|
|
1444
|
+
}));
|
|
1445
|
+
const qualities = runQuality.flatMap((r) => r.quality === null ? [] : [r.quality]);
|
|
1446
|
+
const correctness = n ? pairs.map(([a, b]) => cases.filter((c) => right(scoreIn(a, c)) !== right(scoreIn(b, c))).length / n) : [];
|
|
1447
|
+
const answered = pairs.flatMap(([a, b]) => {
|
|
1448
|
+
const both = cases.filter((c) => answers.get(a)?.has(c) && answers.get(b)?.has(c));
|
|
1449
|
+
const differ = both.filter((c) => answers.get(a).get(c) !== answers.get(b).get(c));
|
|
1450
|
+
return both.length ? [differ.length / both.length] : [];
|
|
1451
|
+
});
|
|
1452
|
+
const squared = n ? mean(pairs.map(([a, b]) => mean(cases.map((c) => (scoreIn(a, c) - scoreIn(b, c)) ** 2)))) : null;
|
|
1453
|
+
return [{
|
|
1454
|
+
profileId,
|
|
1455
|
+
runs: runs.length,
|
|
1456
|
+
n,
|
|
1457
|
+
runQuality,
|
|
1458
|
+
spread: qualities.length ? Math.max(...qualities) - Math.min(...qualities) : null,
|
|
1459
|
+
correctnessDisagreement: share(correctness),
|
|
1460
|
+
answerDisagreement: share(answered),
|
|
1461
|
+
rerunMargin: squared !== null && panelN > 0 ? z * Math.sqrt(squared / panelN) : null
|
|
1462
|
+
}];
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
// src/campaign/presets/profile-matrix-analysis.ts
|
|
1466
|
+
/**
|
|
1467
|
+
* The numbers behind a profile-matrix decision page, computed once from the
|
|
1468
|
+
* matrix's RunRecords so the page and any caller read the same analysis.
|
|
1469
|
+
*
|
|
1470
|
+
* Cells often run on different numbers of cases, so the analysis keeps two
|
|
1471
|
+
* case sets apart. Every paired difference (from the baseline, inside a factor
|
|
1472
|
+
* effect, in a race) is measured on the cases both profiles scored, so each
|
|
1473
|
+
* comparison uses all the evidence it has and carries its own n. The panels
|
|
1474
|
+
* that need one case set for every profile (the frontiers, error overlap, item
|
|
1475
|
+
* difficulty, slices and power) use the common set of the panel profiles: the
|
|
1476
|
+
* profiles that scored at least `minCoverage` of the baseline's scored cases. A
|
|
1477
|
+
* profile under that line is reported in its own partial-coverage rows instead
|
|
1478
|
+
* of shrinking the common set for everyone.
|
|
1479
|
+
*
|
|
1480
|
+
* A case a profile failed has no score, so it leaves that profile's cases
|
|
1481
|
+
* instead of counting as wrong, and the failure shows as its failure rate.
|
|
1482
|
+
* Cases drawn from one source (a docket, a repository, a user) are not
|
|
1483
|
+
* independent, so intervals resample whole clusters when the caller names them.
|
|
1484
|
+
*/
|
|
1485
|
+
const PROFILE_MATRIX_COST_AXES = [
|
|
1486
|
+
"usd",
|
|
1487
|
+
"tokens",
|
|
1488
|
+
"seconds"
|
|
1489
|
+
];
|
|
1490
|
+
const TARGET_POWER = .8;
|
|
1491
|
+
const UNLABELLED_SLICE = "unlabelled";
|
|
1492
|
+
/**
|
|
1493
|
+
* Compare profile-matrix cells against one baseline: quality with clustered
|
|
1494
|
+
* intervals, paired differences, the cost and latency frontiers, factor main
|
|
1495
|
+
* effects, slices, error overlap, item difficulty, calibration and power.
|
|
1496
|
+
*
|
|
1497
|
+
* A profile run more than once (its records carry `outcome.raw.rep`, as campaign
|
|
1498
|
+
* records do) scores each case at its mean over the runs, and `stability` measures
|
|
1499
|
+
* how far its runs differ with nothing changed. Each verdict against the baseline
|
|
1500
|
+
* is Holm-adjusted over every profile-against-baseline comparison, so with dozens
|
|
1501
|
+
* of profiles one lucky interval reads as a candidate, not a win.
|
|
1502
|
+
*/
|
|
1503
|
+
function analyzeProfileMatrix(options) {
|
|
1504
|
+
const ctx = buildContext(options);
|
|
1505
|
+
const { profiles, family } = withVerdicts(ctx.profileIds.map((profileId) => profileStats(ctx, profileId)), options.baseline, 1 - ctx.rule.level);
|
|
1506
|
+
const panel = profiles.filter((stats) => stats.panel);
|
|
1507
|
+
const slices = sliceNames(ctx);
|
|
1508
|
+
return {
|
|
1509
|
+
title: options.title ?? "Profile matrix",
|
|
1510
|
+
baseline: options.baseline,
|
|
1511
|
+
level: ctx.rule.level,
|
|
1512
|
+
passScore: ctx.rule.passScore,
|
|
1513
|
+
passFail: ctx.rule.passFail,
|
|
1514
|
+
minCoverage: ctx.minCoverage,
|
|
1515
|
+
panelRule: ctx.panelRule,
|
|
1516
|
+
panelProfiles: ctx.panel,
|
|
1517
|
+
commonCases: ctx.common,
|
|
1518
|
+
commonClusters: new Set(ctx.common.map((caseId) => ctx.rule.clusterOf(caseId))).size,
|
|
1519
|
+
axes: axisSummaries(ctx, panel),
|
|
1520
|
+
profiles,
|
|
1521
|
+
family,
|
|
1522
|
+
stability: runStability({
|
|
1523
|
+
profileIds: ctx.profileIds,
|
|
1524
|
+
recordsByProfile: ctx.recordsByProfile,
|
|
1525
|
+
answerOf: options.answerOf,
|
|
1526
|
+
level: ctx.rule.level,
|
|
1527
|
+
passScore: ctx.rule.passScore,
|
|
1528
|
+
commonCases: ctx.common.length
|
|
1529
|
+
}),
|
|
1530
|
+
factorEffects: factorEffects(ctx),
|
|
1531
|
+
slices,
|
|
1532
|
+
sliceCells: sliceCells(ctx, slices),
|
|
1533
|
+
...errorOverlap(ctx),
|
|
1534
|
+
difficulty: difficulty$1(ctx),
|
|
1535
|
+
calibration: calibration$1(ctx),
|
|
1536
|
+
power: power(ctx, panel)
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
/** Mean score per profile and case over its scored reps; a case without a scored rep is absent. */
|
|
1540
|
+
function scoresByProfile(records) {
|
|
1541
|
+
const scored = /* @__PURE__ */ new Map();
|
|
1542
|
+
for (const record of records) {
|
|
1543
|
+
const score = runTaskScore(record);
|
|
1544
|
+
if (score === void 0) continue;
|
|
1545
|
+
const cases = scored.get(record.candidateId) ?? /* @__PURE__ */ new Map();
|
|
1546
|
+
cases.set(record.scenarioId, [...cases.get(record.scenarioId) ?? [], score]);
|
|
1547
|
+
scored.set(record.candidateId, cases);
|
|
1548
|
+
}
|
|
1549
|
+
return new Map([...scored].map(([id, cases]) => [id, new Map([...cases].map(([c, xs]) => [c, mean(xs)]))]));
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Profile `a` against profile `b` on the cases both scored, restricted to `cases` when
|
|
1553
|
+
* given. Every paired number on the page and in the race comes from here.
|
|
1554
|
+
*/
|
|
1555
|
+
function pairProfiles(a, b, rule, cases) {
|
|
1556
|
+
const both = (cases ?? [...a.keys()]).filter((c) => a.has(c) && b.has(c)).sort();
|
|
1557
|
+
if (both.length === 0) return void 0;
|
|
1558
|
+
const deltas = both.map((caseId) => ({
|
|
1559
|
+
caseId,
|
|
1560
|
+
delta: a.get(caseId) - b.get(caseId)
|
|
1561
|
+
}));
|
|
1562
|
+
const right = (score) => score >= rule.passScore;
|
|
1563
|
+
const wins = both.filter((c) => right(a.get(c)) && !right(b.get(c))).length;
|
|
1564
|
+
const losses = both.filter((c) => !right(a.get(c)) && right(b.get(c))).length;
|
|
1565
|
+
return {
|
|
1566
|
+
...clusteredDifference(deltas, rule.clusterOf, rule.level),
|
|
1567
|
+
discordance: (wins + losses) / both.length,
|
|
1568
|
+
casesToResolve: casesToResolve(rule, deltas.map((d) => d.delta), wins / both.length, losses / both.length)
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
/** True when every score is 0 or 1. */
|
|
1572
|
+
function allPassFail(scores) {
|
|
1573
|
+
return [...scores.values()].every((cases) => [...cases.values()].every((score) => score === 0 || score === 1));
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Each case's independent unit, one per case when no clusters are given. A case missing from
|
|
1577
|
+
* a given cluster map is refused rather than counted as its own unit. Shared with the race.
|
|
1578
|
+
*/
|
|
1579
|
+
function clusterResolver(clusters, owner) {
|
|
1580
|
+
return (caseId) => {
|
|
1581
|
+
if (!clusters) return caseId;
|
|
1582
|
+
const cluster = clusters[caseId];
|
|
1583
|
+
if (typeof cluster !== "string" || cluster.length === 0) throw new ValidationError(`${owner}: case '${caseId}' has no cluster`);
|
|
1584
|
+
return cluster;
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
/** Mean of per-case differences with its cluster-jackknife interval and exact sign-flip p. */
|
|
1588
|
+
function clusteredDifference(deltas, clusterOf, level) {
|
|
1589
|
+
const units = deltas.map(({ caseId, delta }) => ({
|
|
1590
|
+
cluster: clusterOf(caseId),
|
|
1591
|
+
delta
|
|
1592
|
+
}));
|
|
1593
|
+
const result = clusteredPairedContrast(units, {
|
|
1594
|
+
level,
|
|
1595
|
+
seed: 1
|
|
1596
|
+
});
|
|
1597
|
+
return {
|
|
1598
|
+
estimate: mean(deltas.map((d) => d.delta)),
|
|
1599
|
+
low: result.low,
|
|
1600
|
+
high: result.high,
|
|
1601
|
+
pValue: result.pValue,
|
|
1602
|
+
n: deltas.length,
|
|
1603
|
+
clusters: new Set(units.map((unit) => unit.cluster)).size
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
function casesToResolve(rule, deltas, p10, p01) {
|
|
1607
|
+
const alpha = 1 - rule.level;
|
|
1608
|
+
if (rule.passFail) {
|
|
1609
|
+
const needed = mcnemarRequiredN({
|
|
1610
|
+
p10,
|
|
1611
|
+
p01,
|
|
1612
|
+
alpha,
|
|
1613
|
+
power: TARGET_POWER
|
|
1614
|
+
});
|
|
1615
|
+
return Number.isFinite(needed) ? needed : null;
|
|
1616
|
+
}
|
|
1617
|
+
if (deltas.length < 2) return null;
|
|
1618
|
+
const average = mean(deltas);
|
|
1619
|
+
const sd = Math.sqrt(deltas.reduce((sum, d) => sum + (d - average) ** 2, 0) / (deltas.length - 1));
|
|
1620
|
+
if (sd === 0 || average === 0) return null;
|
|
1621
|
+
const needed = requiredPairedSampleSize({
|
|
1622
|
+
effect: Math.abs(average) / sd,
|
|
1623
|
+
alpha,
|
|
1624
|
+
power: TARGET_POWER
|
|
1625
|
+
});
|
|
1626
|
+
return Number.isFinite(needed) ? needed : null;
|
|
1627
|
+
}
|
|
1628
|
+
/** True when the source is a `raceProfileMatrix` result. */
|
|
1629
|
+
function isRaceResult(source) {
|
|
1630
|
+
return "survivors" in source && "log" in source;
|
|
1631
|
+
}
|
|
1632
|
+
function buildContext(options) {
|
|
1633
|
+
const level = options.level ?? .95;
|
|
1634
|
+
if (!(level > 0 && level < 1)) throw new ValidationError("profile matrix: level must be in (0, 1)");
|
|
1635
|
+
const passScore = options.passScore ?? .5;
|
|
1636
|
+
if (!Number.isFinite(passScore)) throw new ValidationError("profile matrix: passScore must be finite");
|
|
1637
|
+
const minCoverage = options.minCoverage ?? .9;
|
|
1638
|
+
if (!(minCoverage > 0 && minCoverage <= 1)) throw new ValidationError("profile matrix: minCoverage must be in (0, 1]");
|
|
1639
|
+
const raceSource = isRaceResult(options.source) ? options.source : void 0;
|
|
1640
|
+
const records = "records" in options.source ? options.source.records : options.source;
|
|
1641
|
+
const recordsByProfile = /* @__PURE__ */ new Map();
|
|
1642
|
+
for (const record of records) {
|
|
1643
|
+
const list = recordsByProfile.get(record.candidateId) ?? [];
|
|
1644
|
+
list.push(record);
|
|
1645
|
+
recordsByProfile.set(record.candidateId, list);
|
|
1646
|
+
}
|
|
1647
|
+
const listed = options.profiles ? [...options.profiles] : [...recordsByProfile.keys()];
|
|
1648
|
+
if (new Set(listed).size !== listed.length) throw new ValidationError("profile matrix: profiles must be distinct");
|
|
1649
|
+
const baseline = options.baseline;
|
|
1650
|
+
const profileIds = [baseline, ...listed.filter((id) => id !== baseline)];
|
|
1651
|
+
for (const profileId of profileIds) if (!recordsByProfile.has(profileId)) throw new ValidationError(`profile matrix: profile '${profileId}' has no records`);
|
|
1652
|
+
const scored = scoresByProfile(records);
|
|
1653
|
+
const scores = new Map(profileIds.map((id) => [id, scored.get(id) ?? /* @__PURE__ */ new Map()]));
|
|
1654
|
+
const baselineCases = [...scores.get(baseline).keys()].sort();
|
|
1655
|
+
if (baselineCases.length === 0) throw new ValidationError(`profile matrix: baseline '${baseline}' scored no case`);
|
|
1656
|
+
const clusterOf = clusterResolver(options.clusters, "profile matrix");
|
|
1657
|
+
for (const cases of scores.values()) for (const caseId of cases.keys()) clusterOf(caseId);
|
|
1658
|
+
const covers = (id) => coverageOf(scores, baselineCases, id) >= minCoverage;
|
|
1659
|
+
const panel = raceSource ? profileIds.filter((id) => id === baseline || raceSource.survivors.includes(id)) : profileIds.filter((id) => id === baseline || covers(id));
|
|
1660
|
+
return {
|
|
1661
|
+
options,
|
|
1662
|
+
rule: {
|
|
1663
|
+
clusterOf,
|
|
1664
|
+
level,
|
|
1665
|
+
passScore,
|
|
1666
|
+
passFail: allPassFail(scores)
|
|
1667
|
+
},
|
|
1668
|
+
minCoverage,
|
|
1669
|
+
race: options.race ?? raceSource,
|
|
1670
|
+
panelRule: raceSource ? "race-survivors" : "coverage",
|
|
1671
|
+
profileIds,
|
|
1672
|
+
panel,
|
|
1673
|
+
scores,
|
|
1674
|
+
costs: new Map(profileIds.map((id) => [id, caseCosts(recordsByProfile.get(id))])),
|
|
1675
|
+
recordsByProfile,
|
|
1676
|
+
baselineCases,
|
|
1677
|
+
common: baselineCases.filter((caseId) => panel.every((id) => scores.get(id).has(caseId)))
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
function coverageOf(scores, baselineCases, profileId) {
|
|
1681
|
+
const own = scores.get(profileId);
|
|
1682
|
+
return baselineCases.filter((caseId) => own.has(caseId)).length / baselineCases.length;
|
|
1683
|
+
}
|
|
1684
|
+
function caseCosts(records) {
|
|
1685
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
1686
|
+
for (const record of records) {
|
|
1687
|
+
const list = grouped.get(record.scenarioId) ?? [];
|
|
1688
|
+
list.push(record);
|
|
1689
|
+
grouped.set(record.scenarioId, list);
|
|
1690
|
+
}
|
|
1691
|
+
const costs = /* @__PURE__ */ new Map();
|
|
1692
|
+
for (const [caseId, reps] of grouped) costs.set(caseId, {
|
|
1693
|
+
usd: reps.every((r) => r.costUsd !== null) ? mean(reps.map((r) => r.costUsd)) : null,
|
|
1694
|
+
tokens: reps.every((r) => r.tokenUsage.tokensKnown !== false) ? mean(reps.map(tokenTotal)) : null,
|
|
1695
|
+
seconds: mean(reps.map(latencySeconds))
|
|
1696
|
+
});
|
|
1697
|
+
return costs;
|
|
1698
|
+
}
|
|
1699
|
+
/** Every prompt token (fresh, cached and cache-write) plus output; reasoning is counted inside output. */
|
|
1700
|
+
function tokenTotal(record) {
|
|
1701
|
+
const usage = record.tokenUsage;
|
|
1702
|
+
return usage.input + (usage.cached ?? 0) + (usage.cacheWrite ?? 0) + usage.output;
|
|
1703
|
+
}
|
|
1704
|
+
/** Dispatch time when the cell recorded it, so judging does not count as latency; else the wall clock. */
|
|
1705
|
+
function latencySeconds(record) {
|
|
1706
|
+
const dispatchMs = record.outcome.raw.dispatch_ms;
|
|
1707
|
+
return (Number.isFinite(dispatchMs) ? dispatchMs : record.wallMs) / 1e3;
|
|
1708
|
+
}
|
|
1709
|
+
function scoreOf$1(ctx, profileId, caseId) {
|
|
1710
|
+
return ctx.scores.get(profileId).get(caseId);
|
|
1711
|
+
}
|
|
1712
|
+
function correct(ctx, profileId, caseId) {
|
|
1713
|
+
return scoreOf$1(ctx, profileId, caseId) >= ctx.rule.passScore;
|
|
1714
|
+
}
|
|
1715
|
+
const NO_COST = {
|
|
1716
|
+
usd: null,
|
|
1717
|
+
tokens: null,
|
|
1718
|
+
seconds: null
|
|
1719
|
+
};
|
|
1720
|
+
function profileStats(ctx, profileId) {
|
|
1721
|
+
const own = [...ctx.scores.get(profileId).keys()];
|
|
1722
|
+
const records = ctx.recordsByProfile.get(profileId);
|
|
1723
|
+
const isBaseline = profileId === ctx.options.baseline;
|
|
1724
|
+
const vsBaseline = isBaseline ? void 0 : pairProfiles(ctx.scores.get(profileId), ctx.scores.get(ctx.options.baseline), ctx.rule);
|
|
1725
|
+
const droppedAtBatch = ctx.race?.log.find((batch) => batch.standings.some((s) => s.profileId === profileId && s.dropped))?.batch;
|
|
1726
|
+
const base = {
|
|
1727
|
+
profileId,
|
|
1728
|
+
factors: ctx.options.factors?.[profileId] ?? {},
|
|
1729
|
+
runs: new Set(records.map(runOf)).size,
|
|
1730
|
+
casesAttempted: ctx.costs.get(profileId).size,
|
|
1731
|
+
casesScored: own.length,
|
|
1732
|
+
failureRate: records.filter((r) => runTaskScore(r) === void 0).length / records.length,
|
|
1733
|
+
coverage: coverageOf(ctx.scores, ctx.baselineCases, profileId),
|
|
1734
|
+
panel: ctx.panel.includes(profileId),
|
|
1735
|
+
pairedN: isBaseline ? own.length : vsBaseline?.n ?? 0,
|
|
1736
|
+
...droppedAtBatch === void 0 ? {} : { droppedAtBatch },
|
|
1737
|
+
ownQuality: qualityOn(ctx, profileId, own),
|
|
1738
|
+
...vsBaseline ? { vsBaseline } : {}
|
|
1739
|
+
};
|
|
1740
|
+
if (!base.panel) return {
|
|
1741
|
+
...base,
|
|
1742
|
+
quality: null,
|
|
1743
|
+
costPerCase: NO_COST,
|
|
1744
|
+
costPerCorrect: NO_COST,
|
|
1745
|
+
latency: null
|
|
1746
|
+
};
|
|
1747
|
+
const costs = ctx.common.map((caseId) => ctx.costs.get(profileId).get(caseId));
|
|
1748
|
+
const correctCount = ctx.common.filter((caseId) => correct(ctx, profileId, caseId)).length;
|
|
1749
|
+
const costPerCase = {};
|
|
1750
|
+
const costPerCorrect = {};
|
|
1751
|
+
for (const axis of PROFILE_MATRIX_COST_AXES) {
|
|
1752
|
+
const values = costs.map((cost) => cost[axis]);
|
|
1753
|
+
const known = values.length > 0 && values.every((value) => value !== null);
|
|
1754
|
+
costPerCase[axis] = known ? mean(values) : null;
|
|
1755
|
+
costPerCorrect[axis] = known && correctCount > 0 ? values.reduce((a, b) => a + b, 0) / correctCount : null;
|
|
1756
|
+
}
|
|
1757
|
+
const seconds = costs.map((cost) => cost.seconds);
|
|
1758
|
+
return {
|
|
1759
|
+
...base,
|
|
1760
|
+
quality: qualityOn(ctx, profileId, ctx.common),
|
|
1761
|
+
costPerCase,
|
|
1762
|
+
costPerCorrect,
|
|
1763
|
+
latency: seconds.length > 0 ? {
|
|
1764
|
+
p50: percentileNearestRank(seconds, 50),
|
|
1765
|
+
p90: percentileNearestRank(seconds, 90)
|
|
1766
|
+
} : null
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
/** Mean score on `cases`: Wilson for unclustered pass/fail scores, the cluster jackknife otherwise. */
|
|
1770
|
+
function qualityOn(ctx, profileId, cases) {
|
|
1771
|
+
const items = cases.map((caseId) => ({
|
|
1772
|
+
caseId,
|
|
1773
|
+
score: scoreOf$1(ctx, profileId, caseId)
|
|
1774
|
+
}));
|
|
1775
|
+
if (items.length === 0) return null;
|
|
1776
|
+
const estimate = mean(items.map((item) => item.score));
|
|
1777
|
+
if (ctx.rule.passFail && !ctx.options.clusters) {
|
|
1778
|
+
const successes = items.filter((item) => item.score === 1).length;
|
|
1779
|
+
const interval = wilson(successes, items.length, ctx.rule.level);
|
|
1780
|
+
return {
|
|
1781
|
+
estimate,
|
|
1782
|
+
low: interval.lower,
|
|
1783
|
+
high: interval.upper
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
const interval = clusterJackknife(items, (item) => ctx.rule.clusterOf(item.caseId), (sample) => mean(sample.map((item) => item.score)), { level: ctx.rule.level });
|
|
1787
|
+
return {
|
|
1788
|
+
estimate,
|
|
1789
|
+
low: interval.low,
|
|
1790
|
+
high: interval.high
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
function axisSummaries(ctx, panel) {
|
|
1794
|
+
return (ctx.options.costAxes ?? PROFILE_MATRIX_COST_AXES).map((axis) => {
|
|
1795
|
+
const x = (stats) => axis === "seconds" ? stats.latency?.p50 ?? null : stats.costPerCase[axis];
|
|
1796
|
+
const unmeasured = panel.filter((stats) => x(stats) === null);
|
|
1797
|
+
const reason = ctx.common.length === 0 ? "no case was scored by every panel profile" : unmeasured.length > 0 ? `${unmeasured.length} of ${panel.length} panel profiles did not measure it on every common case` : axis === "usd" && panel.every((stats) => x(stats) === 0) ? "every profile costs $0 at the margin, as on flat-rate seats" : null;
|
|
1798
|
+
if (reason !== null) return {
|
|
1799
|
+
axis,
|
|
1800
|
+
drawn: false,
|
|
1801
|
+
note: reason,
|
|
1802
|
+
frontier: []
|
|
1803
|
+
};
|
|
1804
|
+
const { frontier } = paretoFrontier([...panel], [{
|
|
1805
|
+
name: "quality",
|
|
1806
|
+
direction: "maximize",
|
|
1807
|
+
value: (stats) => stats.quality.estimate
|
|
1808
|
+
}, {
|
|
1809
|
+
name: axis,
|
|
1810
|
+
direction: "minimize",
|
|
1811
|
+
value: (stats) => x(stats)
|
|
1812
|
+
}]);
|
|
1813
|
+
return {
|
|
1814
|
+
axis,
|
|
1815
|
+
drawn: true,
|
|
1816
|
+
note: AXIS_NOTES[axis],
|
|
1817
|
+
frontier: frontier.sort((a, b) => x(a) - x(b)).map((stats) => stats.profileId)
|
|
1818
|
+
};
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
const AXIS_NOTES = {
|
|
1822
|
+
usd: "mean dollars per common case",
|
|
1823
|
+
tokens: "mean tokens per common case: every prompt token, cached included, plus output with reasoning counted once",
|
|
1824
|
+
seconds: "median seconds per common case: dispatch time, or the cell wall clock where dispatch time was not recorded"
|
|
1825
|
+
};
|
|
1826
|
+
/**
|
|
1827
|
+
* Each level against the reference over matched pairs: profiles that differ only in this
|
|
1828
|
+
* factor. Each pair is compared on the cases it shares; a case's delta is the mean over the
|
|
1829
|
+
* pairs that share it, so a case counts once and the clusters stay independent.
|
|
1830
|
+
*/
|
|
1831
|
+
function factorEffects(ctx) {
|
|
1832
|
+
const factors = ctx.options.factors;
|
|
1833
|
+
if (!factors) return [];
|
|
1834
|
+
const levelOf = (profileId, factor) => factors[profileId]?.[factor];
|
|
1835
|
+
const names = [...new Set(ctx.profileIds.flatMap((id) => Object.keys(factors[id] ?? {})))].sort();
|
|
1836
|
+
const effects = [];
|
|
1837
|
+
for (const factor of names) {
|
|
1838
|
+
const defined = ctx.profileIds.filter((id) => levelOf(id, factor) !== void 0);
|
|
1839
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1840
|
+
for (const id of defined) counts.set(levelOf(id, factor), (counts.get(levelOf(id, factor)) ?? 0) + 1);
|
|
1841
|
+
const reference = levelOf(ctx.options.baseline, factor) ?? [...counts].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0][0];
|
|
1842
|
+
for (const level of [...counts.keys()].filter((l) => l !== reference).sort()) {
|
|
1843
|
+
const matched = defined.flatMap((p) => levelOf(p, factor) !== level ? [] : defined.filter((q) => levelOf(q, factor) === reference && differOnlyIn(factors, p, q, factor)).map((q) => [p, q]));
|
|
1844
|
+
const perCase = /* @__PURE__ */ new Map();
|
|
1845
|
+
const pairSizes = matched.map(([p, q]) => {
|
|
1846
|
+
const [a, b] = [ctx.scores.get(p), ctx.scores.get(q)];
|
|
1847
|
+
const both = [...a.keys()].filter((caseId) => b.has(caseId));
|
|
1848
|
+
for (const caseId of both) perCase.set(caseId, [...perCase.get(caseId) ?? [], a.get(caseId) - b.get(caseId)]);
|
|
1849
|
+
return both.length;
|
|
1850
|
+
});
|
|
1851
|
+
const base = {
|
|
1852
|
+
factor,
|
|
1853
|
+
level,
|
|
1854
|
+
reference,
|
|
1855
|
+
matchedPairs: matched.length,
|
|
1856
|
+
n: perCase.size,
|
|
1857
|
+
pairCases: matched.length ? {
|
|
1858
|
+
min: Math.min(...pairSizes),
|
|
1859
|
+
max: Math.max(...pairSizes)
|
|
1860
|
+
} : null
|
|
1861
|
+
};
|
|
1862
|
+
if (perCase.size === 0) {
|
|
1863
|
+
effects.push({
|
|
1864
|
+
...base,
|
|
1865
|
+
effect: null,
|
|
1866
|
+
pValue: null
|
|
1867
|
+
});
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
const { pValue, estimate, low, high } = clusteredDifference([...perCase].sort(([a], [b]) => a.localeCompare(b)).map(([caseId, values]) => ({
|
|
1871
|
+
caseId,
|
|
1872
|
+
delta: mean(values)
|
|
1873
|
+
})), ctx.rule.clusterOf, ctx.rule.level);
|
|
1874
|
+
effects.push({
|
|
1875
|
+
...base,
|
|
1876
|
+
effect: {
|
|
1877
|
+
estimate,
|
|
1878
|
+
low,
|
|
1879
|
+
high
|
|
1880
|
+
},
|
|
1881
|
+
pValue
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
return effects;
|
|
1886
|
+
}
|
|
1887
|
+
function differOnlyIn(factors, p, q, factor) {
|
|
1888
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(factors[p] ?? {}), ...Object.keys(factors[q] ?? {})])].every((key) => key === factor || factors[p]?.[key] === factors[q]?.[key]);
|
|
1889
|
+
}
|
|
1890
|
+
function sliceOf(ctx, caseId) {
|
|
1891
|
+
const slices = ctx.options.slices;
|
|
1892
|
+
return slices ? slices[caseId] ?? UNLABELLED_SLICE : void 0;
|
|
1893
|
+
}
|
|
1894
|
+
/** Slices with the most common cases first, so the columns that carry evidence lead. */
|
|
1895
|
+
function sliceNames(ctx) {
|
|
1896
|
+
if (!ctx.options.slices) return [];
|
|
1897
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1898
|
+
for (const caseId of ctx.common) {
|
|
1899
|
+
const slice = sliceOf(ctx, caseId);
|
|
1900
|
+
counts.set(slice, (counts.get(slice) ?? 0) + 1);
|
|
1901
|
+
}
|
|
1902
|
+
return [...counts].sort(([a, x], [b, y]) => y - x || a.localeCompare(b)).map(([slice]) => slice);
|
|
1903
|
+
}
|
|
1904
|
+
function sliceCells(ctx, slices) {
|
|
1905
|
+
return ctx.panel.flatMap((profileId) => slices.map((slice) => {
|
|
1906
|
+
const scores = ctx.common.filter((caseId) => sliceOf(ctx, caseId) === slice).map((caseId) => scoreOf$1(ctx, profileId, caseId));
|
|
1907
|
+
return {
|
|
1908
|
+
profileId,
|
|
1909
|
+
slice,
|
|
1910
|
+
n: scores.length,
|
|
1911
|
+
quality: scores.length ? mean(scores) : null
|
|
1912
|
+
};
|
|
1913
|
+
}));
|
|
1914
|
+
}
|
|
1915
|
+
function errorOverlap(ctx) {
|
|
1916
|
+
const n = ctx.common.length;
|
|
1917
|
+
const pairs = [];
|
|
1918
|
+
ctx.panel.forEach((a, index) => {
|
|
1919
|
+
for (const b of ctx.panel.slice(index + 1)) {
|
|
1920
|
+
const right = ctx.common.map((c) => [correct(ctx, a, c), correct(ctx, b, c)]);
|
|
1921
|
+
pairs.push({
|
|
1922
|
+
a,
|
|
1923
|
+
b,
|
|
1924
|
+
bothWrong: n ? right.filter(([x, y]) => !x && !y).length / n : 0,
|
|
1925
|
+
disagree: n ? right.filter(([x, y]) => x !== y).length / n : 0
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
});
|
|
1929
|
+
const solved = ctx.common.filter((c) => ctx.panel.some((p) => correct(ctx, p, c))).length;
|
|
1930
|
+
return {
|
|
1931
|
+
errorOverlap: pairs,
|
|
1932
|
+
oracle: n ? solved / n : null
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
function difficulty$1(ctx) {
|
|
1936
|
+
return ctx.common.map((caseId) => {
|
|
1937
|
+
const solved = ctx.panel.filter((p) => correct(ctx, p, caseId)).length;
|
|
1938
|
+
const slice = sliceOf(ctx, caseId);
|
|
1939
|
+
return {
|
|
1940
|
+
caseId,
|
|
1941
|
+
...slice === void 0 ? {} : { slice },
|
|
1942
|
+
solved,
|
|
1943
|
+
scored: ctx.panel.length,
|
|
1944
|
+
share: solved / ctx.panel.length
|
|
1945
|
+
};
|
|
1946
|
+
}).sort((a, b) => a.share - b.share || a.caseId.localeCompare(b.caseId));
|
|
1947
|
+
}
|
|
1948
|
+
function calibration$1(ctx) {
|
|
1949
|
+
const probabilityOf = ctx.options.probabilityOf;
|
|
1950
|
+
if (!probabilityOf) return [];
|
|
1951
|
+
return ctx.profileIds.flatMap((profileId) => {
|
|
1952
|
+
const pairs = ctx.recordsByProfile.get(profileId).flatMap((record) => {
|
|
1953
|
+
const score = runTaskScore(record);
|
|
1954
|
+
const probability = probabilityOf(record);
|
|
1955
|
+
if (score === void 0 || probability === void 0) return [];
|
|
1956
|
+
if (!(probability >= 0 && probability <= 1)) throw new ValidationError(`profile matrix: profile '${profileId}' returned probability ${probability} outside [0, 1]`);
|
|
1957
|
+
return [{
|
|
1958
|
+
evalScore: probability,
|
|
1959
|
+
outcome: score >= ctx.rule.passScore ? 1 : 0
|
|
1960
|
+
}];
|
|
1961
|
+
});
|
|
1962
|
+
const report = calibrationFromPairs(pairs, "probability", "correct", {
|
|
1963
|
+
bins: 10,
|
|
1964
|
+
range: {
|
|
1965
|
+
lo: 0,
|
|
1966
|
+
hi: 1
|
|
1967
|
+
}
|
|
1968
|
+
});
|
|
1969
|
+
if (report === null) return [];
|
|
1970
|
+
return [{
|
|
1971
|
+
profileId,
|
|
1972
|
+
n: report.n,
|
|
1973
|
+
ece: report.ece,
|
|
1974
|
+
brier: brierScore(pairs),
|
|
1975
|
+
bins: report.bins
|
|
1976
|
+
}];
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
function power(ctx, panel) {
|
|
1980
|
+
const baselineScores = ctx.scores.get(ctx.options.baseline);
|
|
1981
|
+
const discordances = panel.filter((stats) => stats.profileId !== ctx.options.baseline).map((stats) => pairProfiles(ctx.scores.get(stats.profileId), baselineScores, ctx.rule, ctx.common)?.discordance).filter((value) => value !== void 0).sort((a, b) => a - b);
|
|
1982
|
+
if (ctx.common.length < 2 || discordances.length === 0) return null;
|
|
1983
|
+
const discordance = discordances[Math.floor((discordances.length - 1) / 2)];
|
|
1984
|
+
const sizes = /* @__PURE__ */ new Map();
|
|
1985
|
+
for (const caseId of ctx.common) {
|
|
1986
|
+
const cluster = ctx.rule.clusterOf(caseId);
|
|
1987
|
+
sizes.set(cluster, (sizes.get(cluster) ?? 0) + 1);
|
|
1988
|
+
}
|
|
1989
|
+
const clusterSizes = [...sizes.values()];
|
|
1990
|
+
const powerAt = (effect) => clusteredPower({
|
|
1991
|
+
clusterSizes,
|
|
1992
|
+
effects: [effect],
|
|
1993
|
+
minimumEffect: effect,
|
|
1994
|
+
seed: 1,
|
|
1995
|
+
trials: 400,
|
|
1996
|
+
resamples: 800,
|
|
1997
|
+
confidence: ctx.rule.level,
|
|
1998
|
+
alpha: 1 - ctx.rule.level,
|
|
1999
|
+
targetPower: TARGET_POWER,
|
|
2000
|
+
baseWinRate: discordance / 2,
|
|
2001
|
+
baseLossRate: discordance / 2
|
|
2002
|
+
});
|
|
2003
|
+
const largest = powerAt(1);
|
|
2004
|
+
let detectable = null;
|
|
2005
|
+
if (largest.powerAtMinimumEffect >= TARGET_POWER) {
|
|
2006
|
+
let [low, high] = [0, 1];
|
|
2007
|
+
for (let step = 0; step < 7; step++) {
|
|
2008
|
+
const middle = (low + high) / 2;
|
|
2009
|
+
if (powerAt(middle).powerAtMinimumEffect >= TARGET_POWER) high = middle;
|
|
2010
|
+
else low = middle;
|
|
2011
|
+
}
|
|
2012
|
+
detectable = high;
|
|
2013
|
+
}
|
|
2014
|
+
return {
|
|
2015
|
+
n: ctx.common.length,
|
|
2016
|
+
clusters: clusterSizes.length,
|
|
2017
|
+
discordance,
|
|
2018
|
+
detectable,
|
|
2019
|
+
certifiable: largest.signFlipFloor.certifiableAtAlpha,
|
|
2020
|
+
minClusters: largest.signFlipFloor.minClustersForAlpha
|
|
2021
|
+
};
|
|
2022
|
+
}
|
|
2023
|
+
// src/campaign/presets/profile-matrix-report.ts
|
|
2024
|
+
/**
|
|
2025
|
+
* The profile-matrix decision page: one self-contained HTML string (inline
|
|
2026
|
+
* SVG and CSS, no network, light and dark) rendered from
|
|
2027
|
+
* `analyzeProfileMatrix`, so the page shows exactly the numbers a caller reads.
|
|
2028
|
+
*/
|
|
2029
|
+
/** Render the decision page for a profile matrix or a race over one. */
|
|
2030
|
+
function renderProfileMatrixReport(options) {
|
|
2031
|
+
const a = analyzeProfileMatrix(options);
|
|
2032
|
+
const race = options.race ?? (isRaceResult(options.source) ? options.source : void 0);
|
|
2033
|
+
const sections = [
|
|
2034
|
+
section("Frontier", frontier(a)),
|
|
2035
|
+
section("Profiles", profileTable(a)),
|
|
2036
|
+
...a.profiles.some((p) => !p.panel) ? [section("Partial coverage", partialTable(a))] : [],
|
|
2037
|
+
section("Run-to-run stability", stability(a)),
|
|
2038
|
+
section("Factor main effects", factorTable(a)),
|
|
2039
|
+
section("Slices", sliceHeatmap(a)),
|
|
2040
|
+
section("Error overlap", overlap(a)),
|
|
2041
|
+
section("Item difficulty", difficulty(a)),
|
|
2042
|
+
section("Calibration", calibration(a)),
|
|
2043
|
+
section("Power", `<p>${powerSentence(a)}</p>`),
|
|
2044
|
+
...race ? [section("Race", raceSection(race))] : []
|
|
2045
|
+
];
|
|
2046
|
+
return [
|
|
2047
|
+
"<!doctype html>",
|
|
2048
|
+
"<html lang=\"en\">",
|
|
2049
|
+
"<head>",
|
|
2050
|
+
"<meta charset=\"utf-8\">",
|
|
2051
|
+
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">",
|
|
2052
|
+
`<title>${escapeHtml(a.title)}</title>`,
|
|
2053
|
+
`<meta name="description" content="${escapeHtml(description(a))}">`,
|
|
2054
|
+
`<style>${STYLE}</style>`,
|
|
2055
|
+
"</head>",
|
|
2056
|
+
"<body><main>",
|
|
2057
|
+
`<h1>${escapeHtml(a.title)}</h1>`,
|
|
2058
|
+
`<div class="decision">${decision(a, race)}</div>`,
|
|
2059
|
+
...sections,
|
|
2060
|
+
"</main></body></html>"
|
|
2061
|
+
].join("\n");
|
|
2062
|
+
}
|
|
2063
|
+
const STYLE = `
|
|
2064
|
+
:root{color-scheme:light;--surface:#fcfcfb;--panel:#ffffff;--border:#e4e3de;--grid:#ecebe7;
|
|
2065
|
+
--text:#0b0b0b;--text-2:#52514e;--text-3:#7a7974;--accent:#2a78d6;--base:#eb6834;--better:#2a78d6;
|
|
2066
|
+
--worse:#e34948;--flat:#9b9a95;--seq:#1c5cab;--seq-2:#eb6834;--on-seq:#ffffff;--thin:#efeeea}
|
|
2067
|
+
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){color-scheme:dark;--surface:#1a1a19;
|
|
2068
|
+
--panel:#222221;--border:#383835;--grid:#2c2c2a;--text:#f0efec;--text-2:#c3c2b7;--text-3:#8f8e86;
|
|
2069
|
+
--accent:#3987e5;--base:#d95926;--better:#3987e5;--worse:#e66767;--flat:#77766f;--seq:#6da7ec;
|
|
2070
|
+
--seq-2:#d95926;--on-seq:#0b0b0b;--thin:#2a2a28}}
|
|
2071
|
+
:root[data-theme="dark"]{color-scheme:dark;--surface:#1a1a19;--panel:#222221;--border:#383835;
|
|
2072
|
+
--grid:#2c2c2a;--text:#f0efec;--text-2:#c3c2b7;--text-3:#8f8e86;--accent:#3987e5;--base:#d95926;
|
|
2073
|
+
--better:#3987e5;--worse:#e66767;--flat:#77766f;--seq:#6da7ec;--seq-2:#d95926;--on-seq:#0b0b0b;--thin:#2a2a28}
|
|
2074
|
+
*{box-sizing:border-box}
|
|
2075
|
+
body{margin:0;background:var(--surface);color:var(--text);
|
|
2076
|
+
font:15px/1.5 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif}
|
|
2077
|
+
main{max-width:1120px;margin:0 auto;padding:32px 16px 64px}
|
|
2078
|
+
h1{font-size:28px;line-height:1.2;margin:0 0 16px}
|
|
2079
|
+
h2{font-size:19px;margin:40px 0 8px;padding-top:20px;border-top:1px solid var(--border)}
|
|
2080
|
+
p{margin:8px 0}.muted{color:var(--text-3)}.note{color:var(--text-2);font-size:13px}
|
|
2081
|
+
.decision{background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:12px 16px}
|
|
2082
|
+
.decision p{margin:6px 0}
|
|
2083
|
+
.scroll{overflow-x:auto;margin:12px 0}
|
|
2084
|
+
table{border-collapse:collapse;font-size:13px;font-variant-numeric:tabular-nums}
|
|
2085
|
+
th,td{padding:6px 8px;border-bottom:1px solid var(--border);text-align:right;white-space:nowrap}
|
|
2086
|
+
th{color:var(--text-2);font-weight:600}th:first-child,td:first-child{text-align:left}
|
|
2087
|
+
td .sub{display:block;color:var(--text-3);font-size:11px}
|
|
2088
|
+
td.cell{text-align:center;min-width:64px}td.cell .sub{color:inherit;opacity:.75}
|
|
2089
|
+
td.tight{min-width:40px;padding:6px 3px}td.thin{background:var(--thin);color:var(--text-3)}
|
|
2090
|
+
td.diag{color:var(--text-3)}
|
|
2091
|
+
.charts{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,460px),1fr));gap:16px}
|
|
2092
|
+
figure{margin:12px 0;background:var(--panel);border:1px solid var(--border);border-radius:8px;padding:8px}
|
|
2093
|
+
figcaption{font-size:12px;color:var(--text-2);padding:4px 6px}
|
|
2094
|
+
svg{display:block;width:100%;height:auto}svg text{fill:var(--text-2);font-size:11px}
|
|
2095
|
+
svg .title{fill:var(--text);font-size:12px;font-weight:600}
|
|
2096
|
+
.grid{stroke:var(--grid);stroke-width:1}.zero{stroke:var(--text-3);stroke-width:1}
|
|
2097
|
+
.whisker{stroke:var(--flat);stroke-width:1.5;stroke-opacity:.45}
|
|
2098
|
+
.leader{stroke:var(--text-2);stroke-width:.75;stroke-opacity:.6}.step{fill:none;stroke:var(--accent);stroke-width:2;stroke-dasharray:4 3}
|
|
2099
|
+
.pt{fill:var(--flat);stroke:var(--panel);stroke-width:2}.pt.front{fill:var(--accent)}
|
|
2100
|
+
.ring{fill:none;stroke:var(--base);stroke-width:2}.pt:hover{stroke:var(--text)}
|
|
2101
|
+
.forest{width:120px;height:16px;display:inline-block;vertical-align:middle}
|
|
2102
|
+
.ci{stroke-width:2}.ci.up,.up{stroke:var(--better);fill:var(--better)}
|
|
2103
|
+
.ci.down,.down{stroke:var(--worse);fill:var(--worse)}.ci.flat,.flat{stroke:var(--flat);fill:var(--flat)}
|
|
2104
|
+
.ci.cand{stroke-dasharray:3 2}circle.cand{fill:var(--panel);stroke-width:1.5}
|
|
2105
|
+
.bar{fill:var(--accent)}.bar:hover{fill:var(--text-2)}.diagonal{stroke:var(--text-3);stroke-dasharray:3 3}
|
|
2106
|
+
.cal{fill:none;stroke:var(--accent);stroke-width:2}.calpt{fill:var(--accent);stroke:var(--panel);stroke-width:2}
|
|
2107
|
+
.callout{border-left:3px solid var(--base);padding:6px 12px;background:var(--panel)}
|
|
2108
|
+
.small-multiples{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px}
|
|
2109
|
+
`;
|
|
2110
|
+
function section(title, body) {
|
|
2111
|
+
return `<section><h2>${escapeHtml(title)}</h2>\n${body}\n</section>`;
|
|
2112
|
+
}
|
|
2113
|
+
function num(value, digits = 3) {
|
|
2114
|
+
return value === null || value === void 0 || !Number.isFinite(value) ? "—" : value.toFixed(digits);
|
|
2115
|
+
}
|
|
2116
|
+
function signed(value, digits = 3) {
|
|
2117
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) return "—";
|
|
2118
|
+
return `${value > 0 ? "+" : value < 0 ? "-" : "±"}${Math.abs(value).toFixed(digits)}`;
|
|
2119
|
+
}
|
|
2120
|
+
function pct(value) {
|
|
2121
|
+
return value === null || value === void 0 ? "—" : `${Math.round(value * 100)}%`;
|
|
2122
|
+
}
|
|
2123
|
+
/** An interval as text; a zero-width one says so, since it means no spread to measure, not certainty. */
|
|
2124
|
+
function bounds(i, f = signed) {
|
|
2125
|
+
if (i.low === null || i.high === null) return "no interval";
|
|
2126
|
+
return i.low === i.high ? "no spread across clusters" : `[${f(i.low)}, ${f(i.high)}]`;
|
|
2127
|
+
}
|
|
2128
|
+
function grouped(value) {
|
|
2129
|
+
return Math.round(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
2130
|
+
}
|
|
2131
|
+
function cost(axis, value) {
|
|
2132
|
+
if (value === null) return "—";
|
|
2133
|
+
if (axis === "usd") return `$${value < .1 ? value.toFixed(4) : value.toFixed(2)}`;
|
|
2134
|
+
if (axis === "tokens") return grouped(value);
|
|
2135
|
+
return `${value < 10 ? value.toFixed(1) : grouped(value)} s`;
|
|
2136
|
+
}
|
|
2137
|
+
function pct1(value) {
|
|
2138
|
+
return `${(value * 100).toFixed(1)}%`;
|
|
2139
|
+
}
|
|
2140
|
+
function plural(count, noun) {
|
|
2141
|
+
return `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
2142
|
+
}
|
|
2143
|
+
/** One value, or the lowest to the highest of several. */
|
|
2144
|
+
function lowToHigh(values, f) {
|
|
2145
|
+
const [low, high] = [Math.min(...values), Math.max(...values)];
|
|
2146
|
+
return f(low) === f(high) ? f(low) : `${f(low)} to ${f(high)}`;
|
|
2147
|
+
}
|
|
2148
|
+
const DIRECTION_WORD = {
|
|
2149
|
+
up: "better",
|
|
2150
|
+
down: "worse",
|
|
2151
|
+
flat: "unresolved"
|
|
2152
|
+
};
|
|
2153
|
+
const P_NOTE = "Better and worse follow the interval. p is the exact sign-flip test over clusters, which stays high when few clusters disagree even if the interval excludes zero: read both.";
|
|
2154
|
+
function common(a) {
|
|
2155
|
+
return `${a.commonCases.length} common case${a.commonCases.length === 1 ? "" : "s"}`;
|
|
2156
|
+
}
|
|
2157
|
+
function panelOf(a) {
|
|
2158
|
+
return a.profiles.filter((p) => p.panel);
|
|
2159
|
+
}
|
|
2160
|
+
function withVerdict(a, verdict) {
|
|
2161
|
+
return a.profiles.filter((p) => p.verdict === verdict);
|
|
2162
|
+
}
|
|
2163
|
+
/** The family the verdicts are adjusted over, as the page names it everywhere. */
|
|
2164
|
+
function familyName(a) {
|
|
2165
|
+
const { alpha, comparisons } = a.family;
|
|
2166
|
+
return `familywise ${pct(alpha)} (Holm) over ${plural(comparisons, "comparison")}`;
|
|
2167
|
+
}
|
|
2168
|
+
function description(a) {
|
|
2169
|
+
const count = (verdict) => withVerdict(a, verdict).length;
|
|
2170
|
+
return `${a.profiles.length} profiles against ${a.baseline}, each paired on the cases it shares with it: ${count("better")} better and ${count("worse")} worse at ${familyName(a)}, ${plural(count("candidate"), "candidate")} whose nominal ${pct(a.level)} interval excludes zero, ${count("unresolved")} unresolved; ${a.panelProfiles.length} panel profiles on ${common(a)}; ${plural(a.stability.length, "profile")} run more than once.`;
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* A paired difference as two cells: its own n with clusters, then the estimate with a word, the
|
|
2174
|
+
* interval and p. The word is the nominal interval's side unless a standing replaces it.
|
|
2175
|
+
*/
|
|
2176
|
+
function pairedCells(vs, standing) {
|
|
2177
|
+
if (!vs) return ["—", "—"];
|
|
2178
|
+
return [`${vs.n}<span class="sub">${vs.clusters} cluster${vs.clusters === 1 ? "" : "s"}</span>`, `${signed(vs.estimate)} ${standing?.word ?? DIRECTION_WORD[intervalSide(vs)]}<span class="sub">${bounds(vs)}, p ${num(vs.pValue)}${standing?.sub ?? ""}</span>`];
|
|
2179
|
+
}
|
|
2180
|
+
/** A profile's paired difference from the baseline with its family-adjusted verdict. */
|
|
2181
|
+
function verdictCells(p) {
|
|
2182
|
+
const oneRun = p.verdict !== "unresolved" && p.runs === 1;
|
|
2183
|
+
return pairedCells(p.vsBaseline, {
|
|
2184
|
+
word: `${p.verdict}${oneRun ? " <span class=\"muted\">1 run</span>" : ""}`,
|
|
2185
|
+
sub: `, Holm p ${num(p.adjustedPValue)}`
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
function verdictNote(a) {
|
|
2189
|
+
return `Better and worse are at ${familyName(a)}: the nominal ${pct(a.level)} interval excludes zero and the Holm-adjusted p (Holm p) is at most ${num(a.family.alpha, 2)}. A candidate’s interval excludes zero but its Holm p does not pass, drawn hollow; a verdict other than unresolved that rests on one run of the profile is marked 1 run. p is the sign-flip test over clusters, which stays high when few clusters disagree even if the interval excludes zero.`;
|
|
2190
|
+
}
|
|
2191
|
+
function scoredCell(p) {
|
|
2192
|
+
return `${p.casesScored} / ${p.casesAttempted}<span class="sub">${pct(p.failureRate)} failed</span>`;
|
|
2193
|
+
}
|
|
2194
|
+
function profileCell(a, p) {
|
|
2195
|
+
const levels = Object.values(p.factors).join(" · ");
|
|
2196
|
+
const named = Object.entries(p.factors).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
2197
|
+
return `${escapeHtml(p.profileId)}${p.profileId === a.baseline ? " <span class=\"muted\">(baseline)</span>" : ""}` + (levels ? `<span class="sub" title="${escapeHtml(named)}">${escapeHtml(levels)}</span>` : "");
|
|
2198
|
+
}
|
|
2199
|
+
function panelRuleText(a) {
|
|
2200
|
+
return a.panelRule === "race-survivors" ? "the race survivors" : `the profiles that scored at least ${pct(a.minCoverage)} of the baseline’s ${a.profiles[0].casesScored} cases`;
|
|
2201
|
+
}
|
|
2202
|
+
function decision(a, race) {
|
|
2203
|
+
const base = a.profiles[0];
|
|
2204
|
+
const partial = a.profiles.length - a.panelProfiles.length;
|
|
2205
|
+
const lines = [`Every profile is paired with the baseline <strong>${escapeHtml(a.baseline)}</strong> on the cases the two both scored. The panel (${a.panelProfiles.length} of ${a.profiles.length} profiles: ${panelRuleText(a)}) shares ${common(a)} in ${a.commonClusters} independent cluster${a.commonClusters === 1 ? "" : "s"}, where the baseline scores ${num(base.quality?.estimate)} ${base.quality ? bounds(base.quality, num) : ""}${partial ? `; ${partial} partial-coverage profile${partial === 1 ? "" : "s"} sit outside the frontier` : ""}.`];
|
|
2206
|
+
if (a.panelProfiles.length === 1 && partial > 0) lines.push(a.panelRule === "race-survivors" ? "The race left the baseline alone, so the frontier, overlap and power have nothing to compare." : `No other profile scored ${pct(a.minCoverage)} of the baseline’s cases, so the frontier, overlap and power have nothing to compare; a lower <code>minCoverage</code> widens the panel.`);
|
|
2207
|
+
const list = (verdict) => {
|
|
2208
|
+
const named = withVerdict(a, verdict).map((p) => {
|
|
2209
|
+
const vs = p.vsBaseline;
|
|
2210
|
+
return `${escapeHtml(p.profileId)} (${signed(vs.estimate)}, n ${vs.n}, ${plural(p.runs, "run")})`;
|
|
2211
|
+
});
|
|
2212
|
+
return named.length ? named.join(", ") : "none";
|
|
2213
|
+
};
|
|
2214
|
+
lines.push(`Better than the baseline at ${familyName(a)}: ${list("better")}. Worse: ${list("worse")}. Candidates, whose nominal ${pct(a.level)} interval excludes zero but which do not pass the adjustment: ${list("candidate")}. Unresolved: ${withVerdict(a, "unresolved").length}.`, familySentence(a));
|
|
2215
|
+
for (const axis of a.axes.filter((x) => x.drawn)) lines.push(`Pareto set on ${AXIS_NAME[axis.axis]}: ${axis.frontier.map(escapeHtml).join(", ")}.`);
|
|
2216
|
+
const top = Math.max(...panelOf(a).map((p) => p.quality?.estimate ?? 0));
|
|
2217
|
+
const leaders = panelOf(a).filter((p) => p.quality?.estimate === top);
|
|
2218
|
+
if (a.oracle !== null && leaders.length > 0) {
|
|
2219
|
+
const named = leaders.length === 1 ? escapeHtml(leaders[0].profileId) : `${escapeHtml(leaders[0].profileId)} and ${leaders.length - 1} tied`;
|
|
2220
|
+
lines.push(`On the common cases, choosing the right panel profile per case would score ${num(a.oracle)}; the best single one (${named}) scores ${num(top)}.`);
|
|
2221
|
+
}
|
|
2222
|
+
if (typeof a.power?.detectable === "number") lines.push(`Differences below about ${num(a.power.detectable, 2)} are beyond what this n resolves.`);
|
|
2223
|
+
if (race) lines.push(`Raced: ${race.cellsRun} of ${race.plannedCells} planned cells run; leader <strong>${escapeHtml(race.leader)}</strong>. ${escapeHtml(race.selectionBias)}`);
|
|
2224
|
+
return lines.map((line) => `<p>${line}</p>`).join("\n");
|
|
2225
|
+
}
|
|
2226
|
+
/** How many comparisons the family holds and what a candidate needs to pass it. */
|
|
2227
|
+
function familySentence(a) {
|
|
2228
|
+
const { alpha, comparisons } = a.family;
|
|
2229
|
+
if (comparisons === 0) return "No profile has a p-value against the baseline, so none can read as better or worse.";
|
|
2230
|
+
return `The family holds ${plural(comparisons, "comparison")}, one per profile compared with the baseline, so Holm passes the smallest p only at ${num(alpha / comparisons, 4)} (${pct(alpha)} ÷ ${comparisons}) or below; a candidate needs more cases or repeated runs before it reads as better or worse.`;
|
|
2231
|
+
}
|
|
2232
|
+
const AXIS_NAME = {
|
|
2233
|
+
usd: "dollars",
|
|
2234
|
+
tokens: "tokens",
|
|
2235
|
+
seconds: "latency"
|
|
2236
|
+
};
|
|
2237
|
+
const AXIS_TITLE = {
|
|
2238
|
+
usd: "Dollars per case",
|
|
2239
|
+
tokens: "Tokens per case",
|
|
2240
|
+
seconds: "Median seconds per case"
|
|
2241
|
+
};
|
|
2242
|
+
function ticks(min, max, count = 5) {
|
|
2243
|
+
const span = max - min;
|
|
2244
|
+
const raw = span / count;
|
|
2245
|
+
const power = 10 ** Math.floor(Math.log10(raw));
|
|
2246
|
+
const step = [
|
|
2247
|
+
1,
|
|
2248
|
+
2,
|
|
2249
|
+
2.5,
|
|
2250
|
+
5,
|
|
2251
|
+
10
|
|
2252
|
+
].map((m) => m * power).find((s) => span / s <= count);
|
|
2253
|
+
const out = [];
|
|
2254
|
+
for (let v = Math.ceil(min / step) * step; v <= max + step * 1e-9; v += step) out.push(Number(v.toFixed(10)));
|
|
2255
|
+
return out;
|
|
2256
|
+
}
|
|
2257
|
+
function extent(values, clamp) {
|
|
2258
|
+
let low = Math.min(...values);
|
|
2259
|
+
let high = Math.max(...values);
|
|
2260
|
+
if (low === high) {
|
|
2261
|
+
low -= Math.abs(low) * .1 || .5;
|
|
2262
|
+
high += Math.abs(high) * .1 || .5;
|
|
2263
|
+
}
|
|
2264
|
+
const pad = (high - low) * .08;
|
|
2265
|
+
low -= pad;
|
|
2266
|
+
high += pad;
|
|
2267
|
+
return clamp ? [Math.max(clamp[0], low), Math.min(clamp[1], high)] : [low, high];
|
|
2268
|
+
}
|
|
2269
|
+
function tickLabel(axis, value) {
|
|
2270
|
+
const short = (v) => Number(v.toPrecision(3)).toString();
|
|
2271
|
+
if (axis === "tokens" && Math.abs(value) >= 1e3) return `${short(value / 1e3)}k`;
|
|
2272
|
+
if (axis === "usd") return `$${short(value)}`;
|
|
2273
|
+
return short(value);
|
|
2274
|
+
}
|
|
2275
|
+
function frontier(a) {
|
|
2276
|
+
const drawn = a.axes.filter((axis) => axis.drawn);
|
|
2277
|
+
const skipped = a.axes.filter((axis) => !axis.drawn).map((axis) => `<p class="note">${escapeHtml(AXIS_TITLE[axis.axis])} not drawn: ${escapeHtml(axis.note)}.</p>`);
|
|
2278
|
+
return [
|
|
2279
|
+
`<p class="note">Panel profiles’ quality on the ${common(a)} against each cost; whiskers are ${pct(a.level)} intervals. Filled blue points form the Pareto set (no other profile is both better and cheaper), joined by the dashed staircase; the orange ring marks the baseline.</p>`,
|
|
2280
|
+
`<div class="charts">${drawn.map((axis) => scatter(a, axis)).join("")}</div>`,
|
|
2281
|
+
...skipped
|
|
2282
|
+
].join("\n");
|
|
2283
|
+
}
|
|
2284
|
+
function scatter(a, axis) {
|
|
2285
|
+
const [W, H, L, R, T, B] = [
|
|
2286
|
+
560,
|
|
2287
|
+
330,
|
|
2288
|
+
52,
|
|
2289
|
+
16,
|
|
2290
|
+
14,
|
|
2291
|
+
46
|
|
2292
|
+
];
|
|
2293
|
+
const xOf = (p) => axis.axis === "seconds" ? p.latency.p50 : p.costPerCase[axis.axis];
|
|
2294
|
+
const points = panelOf(a).map((p) => ({
|
|
2295
|
+
p,
|
|
2296
|
+
x: xOf(p),
|
|
2297
|
+
q: p.quality
|
|
2298
|
+
}));
|
|
2299
|
+
const ys = points.flatMap(({ q }) => [
|
|
2300
|
+
q.estimate,
|
|
2301
|
+
q.low ?? q.estimate,
|
|
2302
|
+
q.high ?? q.estimate
|
|
2303
|
+
]);
|
|
2304
|
+
const [x0, x1] = extent(points.map((pt) => pt.x));
|
|
2305
|
+
const [y0, y1] = extent(ys, ys.every((y) => y >= 0 && y <= 1) ? [0, 1] : void 0);
|
|
2306
|
+
const sx = (v) => L + (v - x0) / (x1 - x0) * (W - L - R);
|
|
2307
|
+
const sy = (v) => H - B - (v - y0) / (y1 - y0) * (H - T - B);
|
|
2308
|
+
const parts = [];
|
|
2309
|
+
for (const t of ticks(y0, y1)) {
|
|
2310
|
+
parts.push(`<line class="grid" x1="${L}" x2="${W - R}" y1="${sy(t)}" y2="${sy(t)}"/>`);
|
|
2311
|
+
parts.push(`<text x="${L - 6}" y="${sy(t) + 4}" text-anchor="end">${tickLabel("quality", t)}</text>`);
|
|
2312
|
+
}
|
|
2313
|
+
for (const t of ticks(x0, x1)) parts.push(`<text x="${sx(t)}" y="${H - B + 16}" text-anchor="middle">${tickLabel(axis.axis, t)}</text>`);
|
|
2314
|
+
const front = axis.frontier.map((id) => points.find((pt) => pt.p.profileId === id));
|
|
2315
|
+
if (front.length > 1) {
|
|
2316
|
+
const path = front.map((pt, i) => i === 0 ? `M${sx(pt.x)} ${sy(pt.q.estimate)}` : `H${sx(pt.x)} V${sy(pt.q.estimate)}`).join(" ");
|
|
2317
|
+
parts.push(`<path class="step" d="${path}"/>`);
|
|
2318
|
+
}
|
|
2319
|
+
for (const { x, q } of points) {
|
|
2320
|
+
if (q.low === null || q.high === null) continue;
|
|
2321
|
+
const cx = sx(x);
|
|
2322
|
+
parts.push(`<line class="whisker" x1="${cx}" x2="${cx}" y1="${sy(q.low)}" y2="${sy(q.high)}"/>`);
|
|
2323
|
+
}
|
|
2324
|
+
const placed = points.map(({ x, q }) => {
|
|
2325
|
+
const [cx, cy] = [sx(x), sy(q.estimate)];
|
|
2326
|
+
return [
|
|
2327
|
+
cx - 6,
|
|
2328
|
+
cx + 6,
|
|
2329
|
+
cy - 6,
|
|
2330
|
+
cy + 6
|
|
2331
|
+
];
|
|
2332
|
+
});
|
|
2333
|
+
for (const { p, x, q } of points) {
|
|
2334
|
+
const onFront = axis.frontier.includes(p.profileId);
|
|
2335
|
+
const [cx, cy] = [sx(x), sy(q.estimate)];
|
|
2336
|
+
const tip = `${p.profileId}: quality ${num(q.estimate)} ${bounds(q, num)}, ${cost(axis.axis, x)}`;
|
|
2337
|
+
parts.push(`<circle class="pt${onFront ? " front" : ""}" cx="${cx}" cy="${cy}" r="5.5"><title>${escapeHtml(tip)}</title></circle>`);
|
|
2338
|
+
if (p.profileId === a.baseline) parts.push(`<circle class="ring" cx="${cx}" cy="${cy}" r="9"/>`);
|
|
2339
|
+
if (onFront || p.profileId === a.baseline) {
|
|
2340
|
+
const at = placeLabel(cx, cy, p.profileId, placed, [
|
|
2341
|
+
L,
|
|
2342
|
+
W - R,
|
|
2343
|
+
T,
|
|
2344
|
+
H - B
|
|
2345
|
+
]);
|
|
2346
|
+
if (Math.abs(at.y - cy) > 16) {
|
|
2347
|
+
const edge = at.anchor === "start" ? at.x - 2 : at.x + 2;
|
|
2348
|
+
parts.push(`<line class="leader" x1="${cx}" y1="${cy}" x2="${edge}" y2="${at.y - 4}"/>`);
|
|
2349
|
+
}
|
|
2350
|
+
parts.push(`<text x="${at.x}" y="${at.y}" text-anchor="${at.anchor}">${escapeHtml(p.profileId)}</text>`);
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
parts.push(`<text class="title" x="${(L + W - R) / 2}" y="${H - 8}" text-anchor="middle">${AXIS_TITLE[axis.axis]}</text>`);
|
|
2354
|
+
parts.push(`<text class="title" transform="translate(14 ${(T + H - B) / 2}) rotate(-90)" text-anchor="middle">Quality</text>`);
|
|
2355
|
+
const label = `Quality against ${AXIS_NAME[axis.axis]} for ${points.length} profiles`;
|
|
2356
|
+
return `<figure><svg viewBox="0 0 ${W} ${H}" role="img" aria-label="${escapeHtml(label)}">${parts.join("")}</svg><figcaption>${escapeHtml(AXIS_TITLE[axis.axis])}: ${escapeHtml(axis.note)}.</figcaption></figure>`;
|
|
2357
|
+
}
|
|
2358
|
+
/**
|
|
2359
|
+
* Place a point label beside its point where it overlaps no label or point already placed and
|
|
2360
|
+
* stays inside the plot, trying right then left at widening vertical offsets across the plot's
|
|
2361
|
+
* height; a label set far from its point gets a leader line. Width is estimated from the 11px
|
|
2362
|
+
* label font.
|
|
2363
|
+
*/
|
|
2364
|
+
function placeLabel(cx, cy, text, placed, [left, right, top, bottom]) {
|
|
2365
|
+
const width = text.length * 6.2;
|
|
2366
|
+
const candidates = Array.from({ length: 2 * Math.ceil((bottom - top) / 7) }, (_, k) => k % 2 ? 8 + 7 * k : -(8 + 7 * k)).flatMap((dy) => ["start", "end"].map((anchor) => {
|
|
2367
|
+
const x = anchor === "start" ? cx + 11 : cx - 11;
|
|
2368
|
+
const box = [
|
|
2369
|
+
anchor === "start" ? x : x - width,
|
|
2370
|
+
anchor === "start" ? x + width : x,
|
|
2371
|
+
cy + dy - 10,
|
|
2372
|
+
cy + dy + 2
|
|
2373
|
+
];
|
|
2374
|
+
return {
|
|
2375
|
+
x,
|
|
2376
|
+
y: cy + dy,
|
|
2377
|
+
anchor,
|
|
2378
|
+
box
|
|
2379
|
+
};
|
|
2380
|
+
}));
|
|
2381
|
+
const inside = ({ box }) => box[0] >= left && box[1] <= right && box[2] >= top && box[3] <= bottom;
|
|
2382
|
+
const free = ({ box }) => placed.every((o) => box[1] <= o[0] || box[0] >= o[1] || box[3] <= o[2] || box[2] >= o[3]);
|
|
2383
|
+
const at = candidates.find((c) => inside(c) && free(c)) ?? candidates.find(inside) ?? candidates[0];
|
|
2384
|
+
placed.push(at.box);
|
|
2385
|
+
return at;
|
|
2386
|
+
}
|
|
2387
|
+
/** An interval against zero; a candidate is drawn dashed and hollow. */
|
|
2388
|
+
function forest(i, span, candidate = false) {
|
|
2389
|
+
if (!i) return "";
|
|
2390
|
+
const W = 120;
|
|
2391
|
+
const sx = (v) => Math.max(1, Math.min(119, (v + span) / (2 * span) * W));
|
|
2392
|
+
const d = `${intervalSide(i)}${candidate ? " cand" : ""}`;
|
|
2393
|
+
const ci = i.low !== null && i.high !== null ? `<line class="ci ${d}" x1="${sx(i.low)}" x2="${sx(i.high)}" y1="8" y2="8"/>` : "";
|
|
2394
|
+
return `<svg class="forest" viewBox="0 0 ${W} 16" aria-hidden="true"><line class="zero" x1="${W / 2}" x2="${W / 2}" y1="1" y2="15"/>${ci}<circle class="${d}" cx="${sx(i.estimate)}" cy="8" r="4"/></svg>`;
|
|
2395
|
+
}
|
|
2396
|
+
function forestSpan(intervals) {
|
|
2397
|
+
const values = intervals.flatMap((i) => i ? [
|
|
2398
|
+
i.estimate,
|
|
2399
|
+
i.low ?? 0,
|
|
2400
|
+
i.high ?? 0
|
|
2401
|
+
] : []);
|
|
2402
|
+
return Math.max(.05, ...values.map(Math.abs)) * 1.05;
|
|
2403
|
+
}
|
|
2404
|
+
function profileTable(a) {
|
|
2405
|
+
const usd = a.axes.some((axis) => axis.axis === "usd" && axis.drawn);
|
|
2406
|
+
const panel = panelOf(a);
|
|
2407
|
+
const span = forestSpan(a.profiles.map((p) => p.vsBaseline));
|
|
2408
|
+
const head = [
|
|
2409
|
+
"Profile",
|
|
2410
|
+
"Scored",
|
|
2411
|
+
"Runs",
|
|
2412
|
+
`Quality [${pct(a.level)}]`,
|
|
2413
|
+
"Paired n",
|
|
2414
|
+
"Δ vs baseline",
|
|
2415
|
+
"",
|
|
2416
|
+
"To resolve",
|
|
2417
|
+
"Tokens / correct",
|
|
2418
|
+
...usd ? ["$ / correct"] : [],
|
|
2419
|
+
"Seconds p50 · p90"
|
|
2420
|
+
];
|
|
2421
|
+
const rows = panel.map((p) => {
|
|
2422
|
+
return `<tr>${[
|
|
2423
|
+
profileCell(a, p),
|
|
2424
|
+
scoredCell(p),
|
|
2425
|
+
`${p.runs}`,
|
|
2426
|
+
p.quality ? `${num(p.quality.estimate)} <span class="sub">${bounds(p.quality, num)}</span>` : "—",
|
|
2427
|
+
...verdictCells(p),
|
|
2428
|
+
forest(p.vsBaseline, span, p.verdict === "candidate"),
|
|
2429
|
+
resolveCell(p.vsBaseline),
|
|
2430
|
+
cost("tokens", p.costPerCorrect.tokens),
|
|
2431
|
+
...usd ? [cost("usd", p.costPerCorrect.usd)] : [],
|
|
2432
|
+
`${num(p.latency?.p50, 1)} · ${num(p.latency?.p90, 1)}`
|
|
2433
|
+
].map((c) => `<td>${c}</td>`).join("")}</tr>`;
|
|
2434
|
+
});
|
|
2435
|
+
return [`<p class="note">The panel: ${panelRuleText(a)}. Scored is each profile’s own cases with a score out of those it attempted, with the share of attempts that failed beneath. Runs is how many times the profile ran the cases; with several, a case scores its mean over them. Quality, tokens and seconds are on the ${common(a)}, so the panel compares like with like. Δ is paired with the baseline on every case the two both scored, so each row carries its own paired n and clusters. A case counts as correct at a score of ${a.passScore} or more. To resolve is the number of paired cases a two-sided test needs for 80% power at the observed difference and discordance (unclustered). Seconds are dispatch time where the cell recorded it. ${verdictNote(a)}</p>`, table(head, rows)].join("\n");
|
|
2436
|
+
}
|
|
2437
|
+
function resolveCell(vs) {
|
|
2438
|
+
return vs?.casesToResolve == null ? "—" : grouped(vs.casesToResolve);
|
|
2439
|
+
}
|
|
2440
|
+
function partialTable(a) {
|
|
2441
|
+
const partial = a.profiles.filter((p) => !p.panel);
|
|
2442
|
+
const raced = partial.some((p) => p.droppedAtBatch !== void 0);
|
|
2443
|
+
const span = forestSpan(a.profiles.map((p) => p.vsBaseline));
|
|
2444
|
+
const head = [
|
|
2445
|
+
"Profile",
|
|
2446
|
+
"Scored",
|
|
2447
|
+
"Runs",
|
|
2448
|
+
"Coverage",
|
|
2449
|
+
`Own accuracy [${pct(a.level)}]`,
|
|
2450
|
+
"Paired n",
|
|
2451
|
+
"Δ vs baseline",
|
|
2452
|
+
"",
|
|
2453
|
+
"To resolve",
|
|
2454
|
+
...raced ? ["Dropped after batch"] : []
|
|
2455
|
+
];
|
|
2456
|
+
const rows = partial.map((p) => {
|
|
2457
|
+
return `<tr>${[
|
|
2458
|
+
profileCell(a, p),
|
|
2459
|
+
scoredCell(p),
|
|
2460
|
+
`${p.runs}`,
|
|
2461
|
+
pct(p.coverage),
|
|
2462
|
+
p.ownQuality ? `${num(p.ownQuality.estimate)} <span class="sub">${bounds(p.ownQuality, num)}</span>` : "—",
|
|
2463
|
+
...verdictCells(p),
|
|
2464
|
+
forest(p.vsBaseline, span, p.verdict === "candidate"),
|
|
2465
|
+
resolveCell(p.vsBaseline),
|
|
2466
|
+
...raced ? [p.droppedAtBatch === void 0 ? "—" : `${p.droppedAtBatch}`] : []
|
|
2467
|
+
].map((c) => `<td>${c}</td>`).join("")}</tr>`;
|
|
2468
|
+
});
|
|
2469
|
+
return [`<p class="note">${(a.panelRule === "race-survivors" ? "The race dropped these profiles, so they stopped running cases" : `These profiles scored fewer than ${pct(a.minCoverage)} of the baseline’s cases`) + "; in the frontier they would cut every common-set panel down to the cases they ran."} Each is paired with the baseline on the cases the two both scored instead. Coverage is the share of the baseline’s scored cases this profile also scored; own accuracy is on its own cases, which can be easier or harder than the panel’s, so read Δ, not own accuracy, against the panel. Runs and the verdict read as in the profiles table, in the same family.</p>`, table(head, rows)].join("\n");
|
|
2470
|
+
}
|
|
2471
|
+
function shareCell(share) {
|
|
2472
|
+
if (!share) return "—";
|
|
2473
|
+
const pairs = share.min === share.max ? "" : `<span class="sub">pairs ${lowToHigh([share.min, share.max], pct1)}</span>`;
|
|
2474
|
+
return `${pct1(share.mean)}${pairs}`;
|
|
2475
|
+
}
|
|
2476
|
+
/** Each profile run more than once, and the reading rule its rerun noise gives at the panel's n. */
|
|
2477
|
+
function stability(a) {
|
|
2478
|
+
if (a.stability.length === 0) return "<p class=\"note\">No profile was run more than once, so this page cannot measure rerun noise: every difference above rests on one run of each profile and carries noise the page does not show.</p>";
|
|
2479
|
+
const answers = a.stability.some((s) => s.answerDisagreement !== null);
|
|
2480
|
+
const n = a.commonCases.length;
|
|
2481
|
+
const head = [
|
|
2482
|
+
"Profile",
|
|
2483
|
+
"Runs",
|
|
2484
|
+
"Cases",
|
|
2485
|
+
"Quality per run",
|
|
2486
|
+
"Spread",
|
|
2487
|
+
"Correctness differs",
|
|
2488
|
+
...answers ? ["Answers differ"] : [],
|
|
2489
|
+
`Rerun margin at n ${n}`
|
|
2490
|
+
];
|
|
2491
|
+
const rows = a.stability.map((s) => {
|
|
2492
|
+
return `<tr>${[
|
|
2493
|
+
profileCell(a, a.profiles.find((p) => p.profileId === s.profileId)),
|
|
2494
|
+
`${s.runs}`,
|
|
2495
|
+
`${s.n}`,
|
|
2496
|
+
s.runQuality.map((r) => num(r.quality)).join(" · "),
|
|
2497
|
+
num(s.spread),
|
|
2498
|
+
shareCell(s.correctnessDisagreement),
|
|
2499
|
+
...answers ? [shareCell(s.answerDisagreement)] : [],
|
|
2500
|
+
s.rerunMargin === null ? "—" : `±${num(s.rerunMargin)}`
|
|
2501
|
+
].map((c) => `<td>${c}</td>`).join("")}</tr>`;
|
|
2502
|
+
});
|
|
2503
|
+
const margins = a.stability.flatMap((s) => s.rerunMargin === null ? [] : [s.rerunMargin]);
|
|
2504
|
+
const differ = a.stability.flatMap((s) => s.correctnessDisagreement ? [s.correctnessDisagreement.mean] : []);
|
|
2505
|
+
const rule = margins.length && differ.length ? `<p><strong>Reading rule:</strong> two runs of one profile disagree on correctness on ${lowToHigh(differ, pct1)} of cases, so on the panel’s ${common(a)} two runs with nothing changed differ in quality by up to about ${lowToHigh(margins, (m) => num(m))} in ${pct(a.level)} of reruns; a single-run difference from the baseline smaller than that can be rerun noise alone.</p>` : "<p>The panel has no common case, so the page cannot turn this noise into a margin.</p>";
|
|
2506
|
+
return [
|
|
2507
|
+
"<p class=\"note\">Every profile run more than once, on the cases every one of its runs scored. Quality per run is each run’s mean score there, in run order, and spread is the highest minus the lowest. Correctness differs is the share of those cases one run got right and the other did not" + (answers ? "; answers differ, the share where the two runs gave different answers" : "") + "; each is the mean over pairs of runs, with the range over pairs beneath. " + (answers ? "" : "Answers are not compared: pass <code>answerOf</code> to read them. ") + `Rerun margin is z·√(m/n) at the panel’s ${common(a)}, where m is the mean squared per-case score difference between two runs (for right/wrong scores, the correctness disagreement) and each case’s change is taken as independent.</p>`,
|
|
2508
|
+
table(head, rows),
|
|
2509
|
+
rule
|
|
2510
|
+
].join("\n");
|
|
2511
|
+
}
|
|
2512
|
+
function table(head, rows) {
|
|
2513
|
+
return `<div class="scroll"><table><thead><tr>${head.map((h) => `<th>${escapeHtml(h)}</th>`).join("")}</tr></thead><tbody>${rows.join("\n")}</tbody></table></div>`;
|
|
2514
|
+
}
|
|
2515
|
+
function pairCases({ pairCases: range }) {
|
|
2516
|
+
if (!range) return "—";
|
|
2517
|
+
return range.min === range.max ? `${range.min}` : `${range.min}–${range.max}`;
|
|
2518
|
+
}
|
|
2519
|
+
function factorTable(a) {
|
|
2520
|
+
if (a.factorEffects.length === 0) return "<p class=\"note\">No factor levels were given.</p>";
|
|
2521
|
+
const span = forestSpan(a.factorEffects.map((e) => e.effect));
|
|
2522
|
+
const rows = a.factorEffects.map((e) => [
|
|
2523
|
+
`<tr><td>${escapeHtml(e.factor)}</td>`,
|
|
2524
|
+
`<td>${escapeHtml(e.level)} <span class="muted">vs ${escapeHtml(e.reference)}</span></td>`,
|
|
2525
|
+
`<td>${e.matchedPairs}</td>`,
|
|
2526
|
+
`<td>${pairCases(e)}</td>`,
|
|
2527
|
+
e.effect ? `<td>${signed(e.effect.estimate)} ${DIRECTION_WORD[intervalSide(e.effect)]}<span class="sub">${bounds(e.effect)}, p ${num(e.pValue)}, n ${e.n}</span></td>` : `<td class="muted">${e.matchedPairs ? "no case scored by both sides of a pair" : "confounded: no profile pair differs only here"}</td>`,
|
|
2528
|
+
`<td>${forest(e.effect, span)}</td></tr>`
|
|
2529
|
+
].join(""));
|
|
2530
|
+
return [`<p class="note">The effect of moving one factor from the reference level, all else equal. Each matched pair (two profiles that differ only in that factor) is compared on the cases it shares; the effect is the mean, over the cases any pair shares, of the pairs’ difference on that case, with a clustered ${pct(a.level)} interval. Pair cases is the fewest and most cases one pair shares. ${P_NOTE}</p>`, table([
|
|
2531
|
+
"Factor",
|
|
2532
|
+
"Level",
|
|
2533
|
+
"Matched pairs",
|
|
2534
|
+
"Pair cases",
|
|
2535
|
+
"Effect",
|
|
2536
|
+
""
|
|
2537
|
+
], rows)].join("\n");
|
|
2538
|
+
}
|
|
2539
|
+
function shade(value, variable) {
|
|
2540
|
+
if (value === null) return "";
|
|
2541
|
+
const share = Math.round(Math.max(0, Math.min(1, value)) * 85);
|
|
2542
|
+
return ` style="${share > 50 ? "color:var(--on-seq);" : ""}background:color-mix(in oklab,var(${variable}) ${share}%,var(--panel))"`;
|
|
2543
|
+
}
|
|
2544
|
+
function sliceHeatmap(a) {
|
|
2545
|
+
if (a.slices.length === 0) return "<p class=\"note\">No slices were given.</p>";
|
|
2546
|
+
const rows = panelOf(a).map((p) => {
|
|
2547
|
+
const cells = a.slices.map((slice) => {
|
|
2548
|
+
const cell = a.sliceCells.find((c) => c.profileId === p.profileId && c.slice === slice);
|
|
2549
|
+
const tip = `${p.profileId} on ${slice}: ${num(cell.quality)} over ${cell.n} cases`;
|
|
2550
|
+
if (cell.n === 0) return `<td class="cell thin" title="${escapeHtml(tip)}"></td>`;
|
|
2551
|
+
if (cell.n < 5) return `<td class="cell thin" title="${escapeHtml(tip)}">${num(cell.quality, 2)}<span class="sub">n ${cell.n}</span></td>`;
|
|
2552
|
+
return `<td class="cell"${shade(cell.quality, "--seq")} title="${escapeHtml(tip)}">${num(cell.quality, 2)}<span class="sub">n ${cell.n}</span></td>`;
|
|
2553
|
+
});
|
|
2554
|
+
return `<tr><td>${escapeHtml(p.profileId)}</td>${cells.join("")}</tr>`;
|
|
2555
|
+
});
|
|
2556
|
+
return [`<p class="note">Each panel profile’s mean score on the ${common(a)} in each slice, the largest slice first. Cells with fewer than five cases are greyed: too few to read.</p>`, table(["Profile", ...a.slices], rows)].join("\n");
|
|
2557
|
+
}
|
|
2558
|
+
function overlap(a) {
|
|
2559
|
+
if (a.commonCases.length === 0) return "<p class=\"note\">No case was scored by every panel profile.</p>";
|
|
2560
|
+
const ids = a.panelProfiles;
|
|
2561
|
+
const pair = (x, y) => a.errorOverlap.find((o) => o.a === x && o.b === y || o.a === y && o.b === x);
|
|
2562
|
+
const rows = ids.map((row, i) => {
|
|
2563
|
+
const cells = ids.map((col, j) => {
|
|
2564
|
+
if (i === j) {
|
|
2565
|
+
const wrong = 1 - (a.profiles.find((p) => p.profileId === row).quality?.estimate ?? 0);
|
|
2566
|
+
return `<td class="cell tight diag" title="${escapeHtml(row)} error rate">${pct(wrong)}</td>`;
|
|
2567
|
+
}
|
|
2568
|
+
const o = pair(row, col);
|
|
2569
|
+
const [value, variable, what] = j > i ? [
|
|
2570
|
+
o.bothWrong,
|
|
2571
|
+
"--seq-2",
|
|
2572
|
+
"both wrong"
|
|
2573
|
+
] : [
|
|
2574
|
+
o.disagree,
|
|
2575
|
+
"--seq",
|
|
2576
|
+
"disagree"
|
|
2577
|
+
];
|
|
2578
|
+
return `<td class="cell tight"${shade(value, variable)} title="${escapeHtml(`${row} and ${col}: ${what} ${pct(value)}`)}">${pct(value)}</td>`;
|
|
2579
|
+
});
|
|
2580
|
+
return `<tr><td>${i + 1}. ${escapeHtml(row)}</td>${cells.join("")}</tr>`;
|
|
2581
|
+
});
|
|
2582
|
+
const best = Math.max(...panelOf(a).map((p) => p.quality?.estimate ?? 0));
|
|
2583
|
+
return [
|
|
2584
|
+
`<p class="note">Panel profiles on the ${common(a)}, numbered as in the rows. Above the diagonal (orange): share both profiles got wrong. Below it (blue): share exactly one got right. The diagonal is each profile’s error rate. Profiles that disagree often and rarely fail together are candidates to route between.</p>`,
|
|
2585
|
+
table(["", ...ids.map((_, i) => `${i + 1}`)], rows),
|
|
2586
|
+
`<p>Oracle ceiling: ${num(a.oracle)} (a case counts when any panel profile got it right), against ${num(best)} for the best single one.</p>`
|
|
2587
|
+
].join("\n");
|
|
2588
|
+
}
|
|
2589
|
+
function difficulty(a) {
|
|
2590
|
+
const items = a.difficulty;
|
|
2591
|
+
if (items.length === 0) return "<p class=\"note\">No case was scored.</p>";
|
|
2592
|
+
const [H, L, T, B] = [
|
|
2593
|
+
160,
|
|
2594
|
+
36,
|
|
2595
|
+
8,
|
|
2596
|
+
22
|
|
2597
|
+
];
|
|
2598
|
+
const barW = Math.max(2, Math.min(14, Math.floor(860 / items.length)));
|
|
2599
|
+
const W = L + items.length * barW + 8;
|
|
2600
|
+
const sy = (v) => H - B - v * (H - T - B);
|
|
2601
|
+
const parts = [
|
|
2602
|
+
0,
|
|
2603
|
+
.5,
|
|
2604
|
+
1
|
|
2605
|
+
].map((t) => `<line class="grid" x1="${L}" x2="${W - 8}" y1="${sy(t)}" y2="${sy(t)}"/><text x="${L - 6}" y="${sy(t) + 4}" text-anchor="end">${t}</text>`);
|
|
2606
|
+
items.forEach((item, i) => {
|
|
2607
|
+
const tip = `${item.caseId}${item.slice ? ` (${item.slice})` : ""}: ${item.solved} of ${item.scored} profiles right`;
|
|
2608
|
+
const h = Math.max(1, item.share * (H - T - B));
|
|
2609
|
+
const y = sy(item.share) - (item.share === 0 ? 1 : 0);
|
|
2610
|
+
parts.push(`<rect class="bar" x="${L + i * barW + 1}" y="${y}" width="${barW - 2}" height="${h}" rx="1"><title>${escapeHtml(tip)}</title></rect>`);
|
|
2611
|
+
});
|
|
2612
|
+
parts.push(`<text x="${L}" y="${H - 6}">hardest</text><text x="${W - 8}" y="${H - 6}" text-anchor="end">easiest</text>`);
|
|
2613
|
+
const none = items.filter((item) => item.solved === 0);
|
|
2614
|
+
const all = items.filter((item) => item.solved === item.scored);
|
|
2615
|
+
const listed = none.slice(0, 24).map((item) => escapeHtml(item.caseId));
|
|
2616
|
+
const more = none.length > listed.length ? ` and ${none.length - listed.length} more` : "";
|
|
2617
|
+
return [
|
|
2618
|
+
`<p class="note">Each bar is one of the ${common(a)}: the share of the ${a.panelProfiles.length} panel profiles that got it right, hardest first.</p>`,
|
|
2619
|
+
`<figure><svg viewBox="0 0 ${W} ${H}" role="img" aria-label="Share of panel profiles right per case">${parts.join("")}</svg></figure>`,
|
|
2620
|
+
`<p>Of the ${common(a)}, ${none.length} were missed by every panel profile${none.length ? ` (${listed.join(", ")}${more})` : ""} and ${all.length} were solved by every one. Cases nobody solves are worth reading for label errors before they are read as hard.</p>`
|
|
2621
|
+
].join("\n");
|
|
2622
|
+
}
|
|
2623
|
+
function calibration(a) {
|
|
2624
|
+
if (a.calibration.length === 0) return "<p class=\"note\">No profile returned a probability (pass <code>probabilityOf</code> to read one).</p>";
|
|
2625
|
+
const S = 200;
|
|
2626
|
+
const pad = 26;
|
|
2627
|
+
const sc = (v) => pad + v * 148;
|
|
2628
|
+
return ["<p class=\"note\">Forecast probability of being right against the share actually right, in ten bins; the dashed diagonal is perfect calibration and dot area follows the bin count.</p>", `<div class="small-multiples">${a.calibration.map((c) => {
|
|
2629
|
+
const maxN = Math.max(...c.bins.map((b) => b.n));
|
|
2630
|
+
const pts = c.bins.map((b) => ({
|
|
2631
|
+
x: sc(b.evalMean),
|
|
2632
|
+
y: S - sc(b.outcomeMean),
|
|
2633
|
+
b
|
|
2634
|
+
}));
|
|
2635
|
+
const line = pts.map((p, i) => `${i ? "L" : "M"}${p.x} ${p.y}`).join(" ");
|
|
2636
|
+
const dots = pts.map((p) => `<circle class="calpt" cx="${p.x}" cy="${p.y}" r="${3 + 4 * Math.sqrt(p.b.n / maxN)}"><title>${escapeHtml(`forecast ${num(p.b.evalMean, 2)}, right ${num(p.b.outcomeMean, 2)}, n ${p.b.n}`)}</title></circle>`).join("");
|
|
2637
|
+
return `<figure><svg viewBox="0 0 ${S} ${S}" role="img" aria-label="${escapeHtml(`Calibration of ${c.profileId}`)}"><line class="grid" x1="${pad}" x2="174" y1="174" y2="174"/><line class="diagonal" x1="${sc(0)}" y1="${S - sc(0)}" x2="${sc(1)}" y2="${S - sc(1)}"/><path class="cal" d="${line}"/>${dots}<text x="${pad}" y="192">forecast</text><text x="4" y="18">right</text></svg><figcaption>${escapeHtml(c.profileId)}: n ${c.n}, ECE ${num(c.ece)}, Brier ${num(c.brier)}</figcaption></figure>`;
|
|
2638
|
+
}).join("")}</div>`].join("\n");
|
|
2639
|
+
}
|
|
2640
|
+
function powerSentence(a) {
|
|
2641
|
+
const p = a.power;
|
|
2642
|
+
if (!p) return "Power is not computed: it needs at least two common cases and one panel profile besides the baseline.";
|
|
2643
|
+
const base = `With ${p.n} common cases in ${p.clusters} independent cluster${p.clusters === 1 ? "" : "s"} and a median discordance of ${pct(p.discordance)} against the baseline, `;
|
|
2644
|
+
const finding = p.detectable === null ? "no paired difference up to 1.0 reaches 80% power at this n." : `the smallest paired difference this design detects with 80% power is about ${num(p.detectable, 2)} (whole-cluster bootstrap, ${pct(a.level)} interval); a smaller difference in the table is not resolvable here.`;
|
|
2645
|
+
const floor = p.certifiable ? "" : ` With ${p.clusters} clusters an exact sign-flip test cannot reach the ${pct(1 - a.level)} level at any effect; it needs at least ${p.minClusters}.`;
|
|
2646
|
+
return base + finding + floor;
|
|
2647
|
+
}
|
|
2648
|
+
function raceSection(race) {
|
|
2649
|
+
const reason = {
|
|
2650
|
+
"one-left": "one profile was left",
|
|
2651
|
+
"cell-budget": "the next batch would have passed the cell budget",
|
|
2652
|
+
"batches-ended": "the batch list ended"
|
|
2653
|
+
}[race.stoppedBecause];
|
|
2654
|
+
const saved = race.plannedCells ? 1 - race.cellsRun / race.plannedCells : 0;
|
|
2655
|
+
const log = race.log.flatMap((batch) => batch.standings.map((s) => `<tr><td>${batch.batch}</td><td>${batch.casesSeen}</td><td>${escapeHtml(batch.leader)}</td><td>${escapeHtml(s.profileId)}</td><td>${s.n}</td><td>${signed(s.difference)}</td><td>${bounds(s)}<span class="sub">p ${num(s.pValue)}, ${s.clusters} clusters</span></td><td>${s.dropped ? "<strong>dropped</strong>" : "kept"}${s.reason ? `<span class="sub">${escapeHtml(s.reason)}</span>` : ""}</td></tr>`));
|
|
2656
|
+
const final = race.final.rows.map((row) => `<tr><td>${escapeHtml(row.profileId)}${row.profileId === race.leader ? " <span class=\"muted\">(leader)</span>" : ""}</td><td>${num(row.quality)}</td>${pairedCells(row.vsBaseline).map((cell) => `<td>${cell}</td>`).join("")}</tr>`);
|
|
2657
|
+
return [
|
|
2658
|
+
`<p>Stopped because ${reason}, after ${race.casesRaced.length} cases: ${race.cellsRun} of ${race.plannedCells} planned cells run (${pct(saved)} not spent). Survivors: ${race.survivors.map(escapeHtml).join(", ")}.</p>`,
|
|
2659
|
+
"<h3>Elimination log</h3>",
|
|
2660
|
+
table([
|
|
2661
|
+
"Batch",
|
|
2662
|
+
"Cases seen",
|
|
2663
|
+
"Leader",
|
|
2664
|
+
"Profile",
|
|
2665
|
+
"Paired n",
|
|
2666
|
+
"Δ vs leader",
|
|
2667
|
+
"Interval",
|
|
2668
|
+
"Decision"
|
|
2669
|
+
], log),
|
|
2670
|
+
`<h3>Final comparison on ${race.final.cases} cases every survivor scored</h3>`,
|
|
2671
|
+
table([
|
|
2672
|
+
"Profile",
|
|
2673
|
+
"Quality",
|
|
2674
|
+
"Paired n",
|
|
2675
|
+
"Δ vs baseline, nominal"
|
|
2676
|
+
], final),
|
|
2677
|
+
`<p class="callout">${escapeHtml(race.selectionBias)}</p>`
|
|
2678
|
+
].join("\n");
|
|
2679
|
+
}
|
|
1356
2680
|
// src/campaign/presets/run-profile-matrix.ts
|
|
1357
2681
|
/**
|
|
1358
2682
|
* `runProfileMatrix` — the missing keystone between `runAgentMatrix` and the
|
|
@@ -2128,6 +3452,257 @@ function requireIdentifier(value, name) {
|
|
|
2128
3452
|
function byteLength(value) {
|
|
2129
3453
|
return new TextEncoder().encode(value).byteLength;
|
|
2130
3454
|
}
|
|
3455
|
+
// src/campaign/presets/race-profile-matrix.ts
|
|
3456
|
+
/**
|
|
3457
|
+
* Race a profile matrix: run the surviving profiles on doubling case batches
|
|
3458
|
+
* and stop paying for a profile once it is clearly worse than the leader.
|
|
3459
|
+
*
|
|
3460
|
+
* The race is a sampling policy over a segmented plan. Each batch is one
|
|
3461
|
+
* `runProfileMatrixSegment` with a stable segment id, so a race interrupted
|
|
3462
|
+
* mid-batch resumes from the campaign cell cache and replays the same
|
|
3463
|
+
* decisions. Rows the race never ran stay unclaimed: running them later and
|
|
3464
|
+
* calling `finalizeProfileMatrix` completes the full matrix.
|
|
3465
|
+
*/
|
|
3466
|
+
/**
|
|
3467
|
+
* Successive halving over a profile-matrix plan. After each batch a profile
|
|
3468
|
+
* whose paired interval against the current leader lies wholly below zero is
|
|
3469
|
+
* dropped, as is one whose cells in the batch produced no score; the baseline
|
|
3470
|
+
* is always kept. The race stops when one profile is left, the next batch
|
|
3471
|
+
* would pass `cellBudget`, or the batch list ends.
|
|
3472
|
+
*/
|
|
3473
|
+
async function raceProfileMatrix(opts) {
|
|
3474
|
+
const { baseline, batches: requestedBatches, firstBatch, cellBudget, clusters, level = .95, caseOrder = "shuffled", ...segment } = opts;
|
|
3475
|
+
const { plan } = segment;
|
|
3476
|
+
const planned = [...new Set(plan.rows.map((row) => row.profileId))];
|
|
3477
|
+
if (!planned.includes(baseline)) throw new ValidationError(`raceProfileMatrix: baseline '${baseline}' is not a planned profile`);
|
|
3478
|
+
if (!(level > 0 && level < 1)) throw new ValidationError("raceProfileMatrix: level must be in (0, 1)");
|
|
3479
|
+
if (cellBudget !== void 0 && !(Number.isSafeInteger(cellBudget) && cellBudget > 0)) throw new ValidationError("raceProfileMatrix: cellBudget must be a positive integer");
|
|
3480
|
+
const ctx = {
|
|
3481
|
+
baseline,
|
|
3482
|
+
rule: {
|
|
3483
|
+
clusterOf: clusterResolver(clusters, "raceProfileMatrix"),
|
|
3484
|
+
level,
|
|
3485
|
+
passScore: .5,
|
|
3486
|
+
passFail: true
|
|
3487
|
+
},
|
|
3488
|
+
profileIds: [baseline, ...planned.filter((id) => id !== baseline)]
|
|
3489
|
+
};
|
|
3490
|
+
const order = orderCases(plan, caseOrder);
|
|
3491
|
+
const batches = batchSizes(requestedBatches, firstBatch, order.length);
|
|
3492
|
+
let survivors = [...ctx.profileIds];
|
|
3493
|
+
const records = /* @__PURE__ */ new Map();
|
|
3494
|
+
const log = [];
|
|
3495
|
+
let cellsRun = 0;
|
|
3496
|
+
let seen = 0;
|
|
3497
|
+
let stoppedBecause = "batches-ended";
|
|
3498
|
+
for (const [index, total] of batches.entries()) {
|
|
3499
|
+
if (survivors.length === 1) break;
|
|
3500
|
+
const batchCases = order.slice(seen, total);
|
|
3501
|
+
const inBatch = new Set(batchCases);
|
|
3502
|
+
const rows = plan.rows.filter((row) => survivors.includes(row.profileId) && inBatch.has(row.scenarioId));
|
|
3503
|
+
if (cellBudget !== void 0 && cellsRun + rows.length > cellBudget) {
|
|
3504
|
+
if (index === 0) throw new ValidationError(`raceProfileMatrix: cellBudget ${cellBudget} is below the first batch's ${rows.length} cells`);
|
|
3505
|
+
stoppedBecause = "cell-budget";
|
|
3506
|
+
break;
|
|
3507
|
+
}
|
|
3508
|
+
const result = await runProfileMatrixSegment({
|
|
3509
|
+
...segment,
|
|
3510
|
+
segmentId: `race-batch-${index + 1}`,
|
|
3511
|
+
rows: rows.map((row) => row.rowId)
|
|
3512
|
+
});
|
|
3513
|
+
enforceIntegrity(plan, result.matrix.records);
|
|
3514
|
+
for (const record of result.matrix.records) records.set(record.runId, record);
|
|
3515
|
+
cellsRun += rows.length;
|
|
3516
|
+
seen = total;
|
|
3517
|
+
const entry = standings(ctx, scoresByProfile([...records.values()]), survivors, order.slice(0, seen), batchCases);
|
|
3518
|
+
log.push({
|
|
3519
|
+
batch: index + 1,
|
|
3520
|
+
casesSeen: seen,
|
|
3521
|
+
cellsRun: rows.length,
|
|
3522
|
+
...entry
|
|
3523
|
+
});
|
|
3524
|
+
const dropped = new Set(entry.standings.filter((s) => s.dropped).map((s) => s.profileId));
|
|
3525
|
+
survivors = survivors.filter((id) => !dropped.has(id));
|
|
3526
|
+
}
|
|
3527
|
+
if (survivors.length === 1) stoppedBecause = "one-left";
|
|
3528
|
+
const casesRaced = order.slice(0, seen);
|
|
3529
|
+
const final = finalComparison(ctx, scoresByProfile([...records.values()]), survivors, casesRaced);
|
|
3530
|
+
return {
|
|
3531
|
+
matrixId: plan.matrixId,
|
|
3532
|
+
planDigest: plan.planDigest,
|
|
3533
|
+
baseline,
|
|
3534
|
+
leader: final.leader,
|
|
3535
|
+
survivors,
|
|
3536
|
+
stoppedBecause,
|
|
3537
|
+
casesRaced,
|
|
3538
|
+
cellsRun,
|
|
3539
|
+
plannedCells: plan.rows.length,
|
|
3540
|
+
log,
|
|
3541
|
+
final: {
|
|
3542
|
+
cases: final.cases,
|
|
3543
|
+
rows: final.rows
|
|
3544
|
+
},
|
|
3545
|
+
records: [...records.values()],
|
|
3546
|
+
selectionBias: `${final.leader} leads on the ${casesRaced.length} raced cases, which the race also used to choose it, so its score there is biased upward; confirm it on fresh held-out cases before acting on it.`
|
|
3547
|
+
};
|
|
3548
|
+
}
|
|
3549
|
+
function orderCases(plan, caseOrder) {
|
|
3550
|
+
const ids = plan.scenarios.map((scenario) => scenario.id);
|
|
3551
|
+
if (caseOrder === "plan") return ids;
|
|
3552
|
+
const rng = makeRng(plan.seed);
|
|
3553
|
+
for (let i = ids.length - 1; i > 0; i -= 1) {
|
|
3554
|
+
const j = Math.floor(rng() * (i + 1));
|
|
3555
|
+
[ids[i], ids[j]] = [ids[j], ids[i]];
|
|
3556
|
+
}
|
|
3557
|
+
return ids;
|
|
3558
|
+
}
|
|
3559
|
+
function batchSizes(requested, firstBatch, caseCount) {
|
|
3560
|
+
if (requested !== void 0) {
|
|
3561
|
+
if (!(requested.length > 0 && requested.every((total, i) => Number.isSafeInteger(total) && total > (i === 0 ? 0 : requested[i - 1]) && total <= caseCount))) throw new ValidationError(`raceProfileMatrix: batches must be strictly increasing case counts within 1..${caseCount}`);
|
|
3562
|
+
return [...requested];
|
|
3563
|
+
}
|
|
3564
|
+
const first = firstBatch ?? Math.min(8, caseCount);
|
|
3565
|
+
if (!(Number.isSafeInteger(first) && first > 0 && first <= caseCount)) throw new ValidationError(`raceProfileMatrix: firstBatch must be an integer within 1..${caseCount}`);
|
|
3566
|
+
const sizes = [];
|
|
3567
|
+
for (let total = first; total < caseCount; total *= 2) sizes.push(total);
|
|
3568
|
+
sizes.push(caseCount);
|
|
3569
|
+
return sizes;
|
|
3570
|
+
}
|
|
3571
|
+
function enforceIntegrity(plan, records) {
|
|
3572
|
+
if (plan.integrity === "assert") assertRealBackend(records, { allowMixed: plan.allowMixed });
|
|
3573
|
+
if (plan.integrity !== "warn") return;
|
|
3574
|
+
const report = summarizeBackendIntegrity(records);
|
|
3575
|
+
if (report.verdict !== "real") console.warn(`[raceProfileMatrix] backend integrity: ${report.verdict} — ${report.diagnosis}`);
|
|
3576
|
+
}
|
|
3577
|
+
/** The highest mean on the cases every candidate scored; ties go to the earlier profile. */
|
|
3578
|
+
function leaderOf(ctx, scores, candidates, cases) {
|
|
3579
|
+
const shared = cases.filter((c) => candidates.every((p) => scores.get(p)?.has(c)));
|
|
3580
|
+
let leader = candidates.includes(ctx.baseline) ? ctx.baseline : candidates[0];
|
|
3581
|
+
if (shared.length === 0) return {
|
|
3582
|
+
leader,
|
|
3583
|
+
shared
|
|
3584
|
+
};
|
|
3585
|
+
const quality = (p) => mean(shared.map((c) => scores.get(p).get(c)));
|
|
3586
|
+
for (const p of ctx.profileIds) if (candidates.includes(p) && quality(p) > quality(leader)) leader = p;
|
|
3587
|
+
return {
|
|
3588
|
+
leader,
|
|
3589
|
+
shared
|
|
3590
|
+
};
|
|
3591
|
+
}
|
|
3592
|
+
/** `p` against `q` on the cases both scored within `cases`, through the page's pairing helper. */
|
|
3593
|
+
function pairedAgainst(ctx, scores, p, q, cases) {
|
|
3594
|
+
const rule = {
|
|
3595
|
+
...ctx.rule,
|
|
3596
|
+
passFail: allPassFail(scores)
|
|
3597
|
+
};
|
|
3598
|
+
return pairProfiles(scores.get(p) ?? /* @__PURE__ */ new Map(), scores.get(q) ?? /* @__PURE__ */ new Map(), rule, cases);
|
|
3599
|
+
}
|
|
3600
|
+
function standings(ctx, scores, survivors, seen, batchCases) {
|
|
3601
|
+
const { leader } = leaderOf(ctx, scores, survivors, seen);
|
|
3602
|
+
return {
|
|
3603
|
+
leader,
|
|
3604
|
+
standings: survivors.map((profileId) => {
|
|
3605
|
+
const paired = pairedAgainst(ctx, scores, profileId, leader, seen);
|
|
3606
|
+
const base = {
|
|
3607
|
+
profileId,
|
|
3608
|
+
n: paired?.n ?? 0,
|
|
3609
|
+
clusters: paired?.clusters ?? 0,
|
|
3610
|
+
difference: paired?.estimate ?? null,
|
|
3611
|
+
low: paired?.low ?? null,
|
|
3612
|
+
high: paired?.high ?? null,
|
|
3613
|
+
pValue: paired?.pValue ?? null,
|
|
3614
|
+
casesToResolve: paired?.casesToResolve ?? null
|
|
3615
|
+
};
|
|
3616
|
+
const protectedProfile = profileId === ctx.baseline || profileId === leader;
|
|
3617
|
+
if (!batchCases.some((c) => scores.get(profileId)?.has(c))) return protectedProfile ? {
|
|
3618
|
+
...base,
|
|
3619
|
+
dropped: false,
|
|
3620
|
+
reason: "kept: no cell in this batch produced a score"
|
|
3621
|
+
} : {
|
|
3622
|
+
...base,
|
|
3623
|
+
dropped: true,
|
|
3624
|
+
reason: "no cell in this batch produced a score"
|
|
3625
|
+
};
|
|
3626
|
+
if (base.high === null || base.high >= 0) return {
|
|
3627
|
+
...base,
|
|
3628
|
+
dropped: false
|
|
3629
|
+
};
|
|
3630
|
+
const interval = `[${base.low.toFixed(3)}, ${base.high.toFixed(3)}]`;
|
|
3631
|
+
return protectedProfile ? {
|
|
3632
|
+
...base,
|
|
3633
|
+
dropped: false,
|
|
3634
|
+
reason: `kept as the baseline: interval ${interval} lies below zero`
|
|
3635
|
+
} : {
|
|
3636
|
+
...base,
|
|
3637
|
+
dropped: true,
|
|
3638
|
+
reason: `interval ${interval} against ${leader} lies below zero`
|
|
3639
|
+
};
|
|
3640
|
+
})
|
|
3641
|
+
};
|
|
3642
|
+
}
|
|
3643
|
+
function finalComparison(ctx, scores, survivors, casesRaced) {
|
|
3644
|
+
const { leader, shared } = leaderOf(ctx, scores, survivors, casesRaced);
|
|
3645
|
+
const rows = survivors.map((profileId) => ({
|
|
3646
|
+
profileId,
|
|
3647
|
+
quality: shared.length ? mean(shared.map((c) => scores.get(profileId).get(c))) : null,
|
|
3648
|
+
vsBaseline: profileId === ctx.baseline ? null : pairedAgainst(ctx, scores, profileId, ctx.baseline, shared) ?? null
|
|
3649
|
+
}));
|
|
3650
|
+
return {
|
|
3651
|
+
leader,
|
|
3652
|
+
cases: shared.length,
|
|
3653
|
+
rows
|
|
3654
|
+
};
|
|
3655
|
+
}
|
|
3656
|
+
// src/campaign/repeat-reliability.ts
|
|
3657
|
+
/** pass^k beside mean success over a campaign's seeded repeats. */
|
|
3658
|
+
function repeatReliability(cells, opts) {
|
|
3659
|
+
if (!Number.isSafeInteger(opts.k) || opts.k < 1) throw new RangeError(`repeatReliability: k must be a positive integer, got ${opts.k}`);
|
|
3660
|
+
const byScenario = /* @__PURE__ */ new Map();
|
|
3661
|
+
let failedCells = 0;
|
|
3662
|
+
for (const cell of cells) {
|
|
3663
|
+
if (cell.error !== void 0) {
|
|
3664
|
+
failedCells += 1;
|
|
3665
|
+
continue;
|
|
3666
|
+
}
|
|
3667
|
+
const row = byScenario.get(cell.scenarioId) ?? {
|
|
3668
|
+
repeats: 0,
|
|
3669
|
+
successes: 0
|
|
3670
|
+
};
|
|
3671
|
+
const passed = opts.success(cell.artifact);
|
|
3672
|
+
if (typeof passed !== "boolean") throw new TypeError(`repeatReliability: success must return a boolean for '${cell.scenarioId}'`);
|
|
3673
|
+
row.repeats += 1;
|
|
3674
|
+
if (passed) row.successes += 1;
|
|
3675
|
+
byScenario.set(cell.scenarioId, row);
|
|
3676
|
+
}
|
|
3677
|
+
const scenarios = [...byScenario].map(([scenarioId, row]) => ({
|
|
3678
|
+
scenarioId,
|
|
3679
|
+
unit: opts.independentUnitByScenarioId?.get(scenarioId) ?? scenarioId,
|
|
3680
|
+
repeats: row.repeats,
|
|
3681
|
+
successes: row.successes,
|
|
3682
|
+
meanSuccess: row.successes / row.repeats,
|
|
3683
|
+
passAllK: row.repeats >= opts.k ? passHatK(row.repeats, row.successes, opts.k) : null
|
|
3684
|
+
}));
|
|
3685
|
+
const unitMean = (values) => {
|
|
3686
|
+
const units = /* @__PURE__ */ new Map();
|
|
3687
|
+
for (const row of scenarios) {
|
|
3688
|
+
const value = values(row);
|
|
3689
|
+
if (value === null) continue;
|
|
3690
|
+
units.set(row.unit, [...units.get(row.unit) ?? [], value]);
|
|
3691
|
+
}
|
|
3692
|
+
if (units.size === 0) return null;
|
|
3693
|
+
const means = [...units.values()].map((list) => list.reduce((a, b) => a + b, 0) / list.length);
|
|
3694
|
+
return means.reduce((a, b) => a + b, 0) / means.length;
|
|
3695
|
+
};
|
|
3696
|
+
return {
|
|
3697
|
+
k: opts.k,
|
|
3698
|
+
scenarios,
|
|
3699
|
+
units: new Set(scenarios.map((row) => row.unit)).size,
|
|
3700
|
+
meanSuccess: unitMean((row) => row.meanSuccess),
|
|
3701
|
+
passAllK: unitMean((row) => row.passAllK),
|
|
3702
|
+
incompleteScenarios: scenarios.filter((row) => row.passAllK === null).map((r) => r.scenarioId),
|
|
3703
|
+
failedCells
|
|
3704
|
+
};
|
|
3705
|
+
}
|
|
2131
3706
|
// src/campaign/retained-dispatch.ts
|
|
2132
3707
|
const digest = z.string().regex(/^sha256:[a-f0-9]{64}$/);
|
|
2133
3708
|
const headerSchema = z.object({
|
|
@@ -3074,6 +4649,6 @@ function verifyCodeSurface(surface, worktreeDir) {
|
|
|
3074
4649
|
function resolveWorktreePath(surface, worktreeDir) {
|
|
3075
4650
|
return verifyCodeSurface(surface, worktreeDir).path;
|
|
3076
4651
|
}
|
|
3077
|
-
export {
|
|
4652
|
+
export { loadEvalFixture as C, measureCampaignCost as D, analyzeCrossSurfaceInteractions as E, discoverEvalFixtures as S, planEvalFixtureRun as T, userStoryScoreboard as _, createRetainedDispatch as a, neutralizeText as b, createProfileMatrixPlan as c, runProfileMatrix as d, renderProfileMatrixReport as f, scoreboardSummary as g, scoreUserStory as h, scoreDiscrimination as i, finalizeProfileMatrix as l, renderScoreboardMarkdown as m, resolveWorktreePath as n, repeatReliability as o, analyzeProfileMatrix as p, verifyCodeSurface as r, raceProfileMatrix as s, gitWorktreeAdapter as t, runProfileMatrixSegment as u, scopedOptimizationMethod as v, loadEvalFixtureScenarios as w, neutralizationGate as x, sequentialOptimizationMethod as y };
|
|
3078
4653
|
|
|
3079
|
-
//# sourceMappingURL=campaign-
|
|
4654
|
+
//# sourceMappingURL=campaign-eus7YRs2.js.map
|