@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
package/dist/meta-eval/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { n as CaptureIntegrityError, s as ValidationError } from "../errors-DeEEV9Vx.js";
|
|
2
2
|
import { a as hashCanonical, i as compareCodeUnits } from "../canonical-DKgL_Wby.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t as interpolatedQuantile } from "../quantile-CncXP-Ss.js";
|
|
4
|
+
import { f as spearmanR } from "../paired-tests-CXcD_B80.js";
|
|
4
5
|
import { t as mulberry32 } from "../random-DrzcgC7F.js";
|
|
6
|
+
import { $ as selfPreference, H as clusteredAssociation, Q as positionalBias, V as associationEstimate, X as calibrateJudgeContinuous, Y as calibrateJudge, Z as continuousAgreement, b as benjaminiHochberg, et as verbosityBias, n as sampleMedian } from "../statistics-AKnVFnK-.js";
|
|
5
7
|
import { s as runMetricExtractor } from "../query-Dhjkwqyx.js";
|
|
6
|
-
import { n as callLlmJson } from "../llm-client-
|
|
7
|
-
import { a as
|
|
8
|
-
import { a as rankedProbabilityScore, i as multiclassBrierScore, n as calibrationCurve, r as calibrationFromPairs, t as brierScore } from "../calibration-
|
|
9
|
-
import { a as judgeGateDecision, c as snapshotFromJudgeAgreement, d as judgeSentinelReport, f as snapshotFromAgreement, g as withJudgeRetry, h as validateSentinelSnapshot, i as assertJudgeMayGate, l as evalHealthStamp, m as snapshotFromSentinelSet, n as JudgeGateRefusedError, o as measureJudgeAgreement, p as snapshotFromCalibration, r as addCalibrationVerdicts, s as registerCalibrationSet, t as DEFAULT_JUDGE_GATE_POLICY, u as fileSentinelStore } from "../judge-gate-
|
|
8
|
+
import { n as callLlmJson } from "../llm-client-Dk8lBnMh.js";
|
|
9
|
+
import { a as reduceOutcomeMetric, i as hasVariation, n as correlationSummary, o as reduceOutcomeObservation, r as groupOutcomesByRun, s as validateObservationOptions, t as assertUniqueObservationIds } from "../outcome-observations-DEh8_V_P.js";
|
|
10
|
+
import { a as rankedProbabilityScore, i as multiclassBrierScore, n as calibrationCurve, r as calibrationFromPairs, t as brierScore } from "../calibration-Dz8mQb5P.js";
|
|
11
|
+
import { a as judgeGateDecision, c as snapshotFromJudgeAgreement, d as judgeSentinelReport, f as snapshotFromAgreement, g as withJudgeRetry, h as validateSentinelSnapshot, i as assertJudgeMayGate, l as evalHealthStamp, m as snapshotFromSentinelSet, n as JudgeGateRefusedError, o as measureJudgeAgreement, p as snapshotFromCalibration, r as addCalibrationVerdicts, s as registerCalibrationSet, t as DEFAULT_JUDGE_GATE_POLICY, u as fileSentinelStore } from "../judge-gate-CpD3wmcf.js";
|
|
10
12
|
import { t as computeInterval } from "../interval-Bd2f4CRT.js";
|
|
11
|
-
import { t as clusterBootstrapMean } from "../cluster-bootstrap-
|
|
12
|
-
import { t as rubricPredictiveValidity } from "../rubric-predictive-validity
|
|
13
|
+
import { t as clusterBootstrapMean } from "../cluster-bootstrap-CTC8Dd30.js";
|
|
14
|
+
import { t as rubricPredictiveValidity } from "../rubric-predictive-validity-BXJ92Jp_.js";
|
|
13
15
|
import { n as InMemoryOutcomeStore, r as OutcomeStoreError, t as FileSystemOutcomeStore } from "../outcome-store-TarrcfHG.js";
|
|
16
|
+
import { n as verifyMeasureValidityPlan } from "../measure-validity-plan-CJkBNzX_.js";
|
|
14
17
|
import { z } from "zod";
|
|
15
18
|
// src/meta-eval/correlation-study.ts
|
|
16
19
|
/**
|
|
@@ -36,13 +39,7 @@ async function correlationStudy(traceStore, outcomeStore, evalMetrics, outcomeMe
|
|
|
36
39
|
const metricNames = [...outcomeMetricNames];
|
|
37
40
|
const runs = await traceStore.listRuns();
|
|
38
41
|
assertUniqueObservationIds(runs.map((run) => run.runId), "runId");
|
|
39
|
-
const
|
|
40
|
-
const outcomesByRun = /* @__PURE__ */ new Map();
|
|
41
|
-
for (const o of outcomes) {
|
|
42
|
-
const arr = outcomesByRun.get(o.runId) ?? [];
|
|
43
|
-
arr.push(o);
|
|
44
|
-
outcomesByRun.set(o.runId, arr);
|
|
45
|
-
}
|
|
42
|
+
const outcomesByRun = groupOutcomesByRun(await outcomeStore.list(options.outcomeFilter));
|
|
46
43
|
const pairs = [];
|
|
47
44
|
for (const em of extractors) for (const om of metricNames) pairs.push({
|
|
48
45
|
evalMetric: em.id,
|
|
@@ -584,6 +581,802 @@ function gateJudgeCalibration(perJudge, config) {
|
|
|
584
581
|
cells
|
|
585
582
|
};
|
|
586
583
|
}
|
|
584
|
+
// src/meta-eval/measure-records.ts
|
|
585
|
+
/**
|
|
586
|
+
* Changes and the outcomes joined to them, shared by the measure validity
|
|
587
|
+
* study and the guard drift check. Internal to `meta-eval`; `MeasuredChange`
|
|
588
|
+
* is public through the barrel.
|
|
589
|
+
*/
|
|
590
|
+
function validateChanges(changes, plan, requireUniqueIds) {
|
|
591
|
+
const ids = /* @__PURE__ */ new Set();
|
|
592
|
+
for (const [index, change] of changes.entries()) {
|
|
593
|
+
const where = `change ${index}${typeof change?.id === "string" ? ` (${change.id})` : ""}`;
|
|
594
|
+
if (typeof change?.id !== "string" || change.id.trim().length === 0) throw new ValidationError(`${where}: id must be a nonempty string`);
|
|
595
|
+
if (requireUniqueIds && ids.has(change.id)) throw new ValidationError(`${where}: duplicate change id`);
|
|
596
|
+
ids.add(change.id);
|
|
597
|
+
if (!Number.isFinite(change.at)) throw new ValidationError(`${where}: at must be finite`);
|
|
598
|
+
if (typeof change.unit !== "string" || change.unit.length === 0) throw new ValidationError(`${where}: unit must be a nonempty string`);
|
|
599
|
+
for (const measure of plan.measures) {
|
|
600
|
+
const value = change.measures?.[measure.id];
|
|
601
|
+
if (value !== void 0 && !Number.isFinite(value)) throw new ValidationError(`${where}: measure ${measure.id} must be finite; omit it when unmeasured`);
|
|
602
|
+
const movement = change.movements?.[measure.id];
|
|
603
|
+
if (movement === void 0) continue;
|
|
604
|
+
if (!Number.isFinite(movement.before) || !Number.isFinite(movement.after)) throw new ValidationError(`${where}: movement of ${measure.id} must be finite`);
|
|
605
|
+
if (measure.noise === void 0) throw new ValidationError(`${where}: records a movement of ${measure.id} but the plan declares no noise for it`);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* The observations a change may join, each excluded one counted under the
|
|
611
|
+
* first reason that applies. `asOf` is when the outcomes were read: nothing
|
|
612
|
+
* captured after it can have been known.
|
|
613
|
+
*/
|
|
614
|
+
function eligibleObservations(observations, change, plan, preCut, asOf) {
|
|
615
|
+
const counts = {
|
|
616
|
+
capturedBeforeChange: 0,
|
|
617
|
+
capturedAfterAsOf: 0,
|
|
618
|
+
capturedAfterCutForPreCutChange: 0,
|
|
619
|
+
beyondMaxCaptureLag: 0
|
|
620
|
+
};
|
|
621
|
+
const eligible = [];
|
|
622
|
+
for (const observation of observations) if (observation.capturedAt < change.at) counts.capturedBeforeChange++;
|
|
623
|
+
else if (asOf !== void 0 && observation.capturedAt > asOf) counts.capturedAfterAsOf++;
|
|
624
|
+
else if (plan.maxCaptureLagMs !== void 0 && observation.capturedAt - change.at > plan.maxCaptureLagMs) counts.beyondMaxCaptureLag++;
|
|
625
|
+
else if (preCut && observation.capturedAt > plan.cut) counts.capturedAfterCutForPreCutChange++;
|
|
626
|
+
else eligible.push(observation);
|
|
627
|
+
return {
|
|
628
|
+
eligible,
|
|
629
|
+
...counts
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function joinOutcomes(eligible, change, outcomes, reduction) {
|
|
633
|
+
const joined = /* @__PURE__ */ new Map();
|
|
634
|
+
for (const outcome of outcomes) {
|
|
635
|
+
const reduced = reduceOutcomeObservation(eligible, outcome.id, reduction);
|
|
636
|
+
if (reduced === null) continue;
|
|
637
|
+
if (outcome.kind === "binary" && reduced.value !== 0 && reduced.value !== 1) throw new ValidationError(`change ${change.id}: binary outcome ${outcome.id} reduced to ${reduced.value}; record 0 or 1`);
|
|
638
|
+
const higher = outcome.direction === "higher-is-better";
|
|
639
|
+
joined.set(outcome.id, {
|
|
640
|
+
better: outcome.kind === "binary" ? higher ? reduced.value : 1 - reduced.value : higher ? reduced.value : -reduced.value,
|
|
641
|
+
capturedAt: reduced.capturedAt
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
return joined;
|
|
645
|
+
}
|
|
646
|
+
function statisticOf(outcome) {
|
|
647
|
+
return outcome.kind === "binary" ? "auc" : "spearman";
|
|
648
|
+
}
|
|
649
|
+
// src/meta-eval/measure-selection.ts
|
|
650
|
+
/**
|
|
651
|
+
* The subset of admitted measures to climb, the guards kept unoptimized beside
|
|
652
|
+
* it, and the check that a climbed measure has not drifted away from them.
|
|
653
|
+
*
|
|
654
|
+
* Selection reads only changes before the cut: each candidate is standardized
|
|
655
|
+
* by its before-cut median and robust scale and aligned to its direction, and
|
|
656
|
+
* greedy forward selection adds the measure that most raises the equal-weight
|
|
657
|
+
* composite's statistic, skipping a candidate redundant with one already
|
|
658
|
+
* climbed. Equal weights are deliberate: fitted weights on a few hundred
|
|
659
|
+
* changes overfit, and unit weights lose little when measures share a cause.
|
|
660
|
+
*/
|
|
661
|
+
/**
|
|
662
|
+
* Whether a climbed measure rose while its guards did not, in a batch of
|
|
663
|
+
* later changes. Guards are measured at change time, so this reads before the
|
|
664
|
+
* outcome arrives; the outcome shift is reported when the batch has outcomes.
|
|
665
|
+
*/
|
|
666
|
+
async function guardDrift(input) {
|
|
667
|
+
const { report, tolerance } = input;
|
|
668
|
+
if (!Number.isFinite(tolerance) || tolerance < 0) throw new ValidationError("guardDrift: tolerance must be finite and nonnegative");
|
|
669
|
+
const selection = report.selections.find((row) => row.outcome === input.outcome);
|
|
670
|
+
if (!selection) throw new ValidationError(`guardDrift: the report has no selection for outcome ${input.outcome}`);
|
|
671
|
+
const plan = report.plan;
|
|
672
|
+
validateChanges(input.batch, plan, false);
|
|
673
|
+
const guards = selection.guards;
|
|
674
|
+
const interval = (rows) => {
|
|
675
|
+
const units = new Set(rows.map((row) => row.unit)).size;
|
|
676
|
+
if (rows.length === 0 || units < plan.minUnits) return null;
|
|
677
|
+
const result = clusterBootstrapMean(rows.map((row) => ({
|
|
678
|
+
cluster: row.unit,
|
|
679
|
+
value: row.value
|
|
680
|
+
})), {
|
|
681
|
+
confidence: plan.confidence,
|
|
682
|
+
resamples: plan.resamples,
|
|
683
|
+
...plan.seed === void 0 ? {} : { seed: plan.seed }
|
|
684
|
+
});
|
|
685
|
+
return {
|
|
686
|
+
n: rows.length,
|
|
687
|
+
units,
|
|
688
|
+
estimate: result.mean,
|
|
689
|
+
low: result.low,
|
|
690
|
+
high: result.high
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
const centered = (change, measure, direction, reference) => {
|
|
694
|
+
const value = change.measures[measure];
|
|
695
|
+
return value === void 0 ? null : alignedZ(value, direction, reference) - reference.meanZ;
|
|
696
|
+
};
|
|
697
|
+
const measures = selection.climb.map((climbed) => {
|
|
698
|
+
const shiftRows = [];
|
|
699
|
+
const guardRows = [];
|
|
700
|
+
const divergenceRows = [];
|
|
701
|
+
for (const change of input.batch) {
|
|
702
|
+
const own = centered(change, climbed.measure, climbed.direction, climbed.reference);
|
|
703
|
+
const guardValues = guards.map((guard) => centered(change, guard.measure, guard.direction, guard.reference)).filter((value) => value !== null);
|
|
704
|
+
if (own !== null) shiftRows.push({
|
|
705
|
+
unit: change.unit,
|
|
706
|
+
value: own
|
|
707
|
+
});
|
|
708
|
+
if (guardValues.length === 0) continue;
|
|
709
|
+
const guardMean = guardValues.reduce((sum, value) => sum + value, 0) / guardValues.length;
|
|
710
|
+
guardRows.push({
|
|
711
|
+
unit: change.unit,
|
|
712
|
+
value: guardMean
|
|
713
|
+
});
|
|
714
|
+
if (own !== null) divergenceRows.push({
|
|
715
|
+
unit: change.unit,
|
|
716
|
+
value: own - guardMean
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
const divergence = guards.length === 0 ? null : interval(divergenceRows);
|
|
720
|
+
return {
|
|
721
|
+
measure: climbed.measure,
|
|
722
|
+
status: divergence === null ? "insufficient" : divergence.low > tolerance ? "drift" : "within-tolerance",
|
|
723
|
+
shift: interval(shiftRows),
|
|
724
|
+
guardShift: guards.length === 0 ? null : interval(guardRows),
|
|
725
|
+
divergence
|
|
726
|
+
};
|
|
727
|
+
});
|
|
728
|
+
let outcomeShift = null;
|
|
729
|
+
const outcomeSpec = plan.outcomes.find((row) => row.id === input.outcome);
|
|
730
|
+
const reference = selection.outcomeReference;
|
|
731
|
+
if (input.outcomes && reference) {
|
|
732
|
+
const byRun = groupOutcomesByRun(await input.outcomes.list());
|
|
733
|
+
const rows = [];
|
|
734
|
+
for (const change of input.batch) {
|
|
735
|
+
const { eligible } = eligibleObservations(byRun.get(change.id) ?? [], change, plan, false);
|
|
736
|
+
const joined = joinOutcomes(eligible, change, [outcomeSpec], plan.reduction).get(outcomeSpec.id);
|
|
737
|
+
if (!joined) continue;
|
|
738
|
+
rows.push({
|
|
739
|
+
unit: change.unit,
|
|
740
|
+
value: reference.kind === "binary" ? joined.better - reference.betterRate : (joined.better - reference.center) / reference.scale - reference.meanZ
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
outcomeShift = interval(rows);
|
|
744
|
+
}
|
|
745
|
+
return {
|
|
746
|
+
outcome: input.outcome,
|
|
747
|
+
guards: guards.map((guard) => guard.measure),
|
|
748
|
+
status: selection.climb.length === 0 || guards.length === 0 ? "no-guards" : measures.some((row) => row.status === "drift") ? "drift" : measures.every((row) => row.status === "insufficient") ? "insufficient" : "no-drift",
|
|
749
|
+
measures,
|
|
750
|
+
outcomeShift
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function outcomeReference(outcome, pre) {
|
|
754
|
+
const values = pre.flatMap((row) => {
|
|
755
|
+
const joined = row.outcomes.get(outcome.id);
|
|
756
|
+
return joined === void 0 ? [] : [joined.better];
|
|
757
|
+
});
|
|
758
|
+
if (values.length === 0) return null;
|
|
759
|
+
if (outcome.kind === "binary") return {
|
|
760
|
+
kind: "binary",
|
|
761
|
+
betterRate: values.reduce((sum, value) => sum + value, 0) / values.length
|
|
762
|
+
};
|
|
763
|
+
const scaled = robustScale(values);
|
|
764
|
+
if (scaled === null) return null;
|
|
765
|
+
const meanZ = values.reduce((sum, value) => sum + (value - scaled.center) / scaled.scale, 0) / values.length;
|
|
766
|
+
return {
|
|
767
|
+
kind: "continuous",
|
|
768
|
+
...scaled,
|
|
769
|
+
meanZ
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
function robustScale(values) {
|
|
773
|
+
const center = sampleMedian(values);
|
|
774
|
+
if (center === null) return null;
|
|
775
|
+
const mad = sampleMedian(values.map((value) => Math.abs(value - center))) * 1.4826;
|
|
776
|
+
if (mad > 0) return {
|
|
777
|
+
center,
|
|
778
|
+
scale: mad
|
|
779
|
+
};
|
|
780
|
+
if (values.length < 2) return null;
|
|
781
|
+
const mean = values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
782
|
+
const sd = Math.sqrt(values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / (values.length - 1));
|
|
783
|
+
return sd > 0 ? {
|
|
784
|
+
center,
|
|
785
|
+
scale: sd
|
|
786
|
+
} : null;
|
|
787
|
+
}
|
|
788
|
+
function alignedZ(value, direction, reference) {
|
|
789
|
+
return (direction === "higher" ? 1 : -1) * (value - reference.center) / reference.scale;
|
|
790
|
+
}
|
|
791
|
+
function selectMeasures(outcome, pairs, pre, post, plan, outcomeRef) {
|
|
792
|
+
const statistic = statisticOf(outcome);
|
|
793
|
+
const nullValue = statistic === "auc" ? .5 : 0;
|
|
794
|
+
const admitted = pairs.filter((pair) => pair.outcome === outcome.id && (pair.label === "predicts" || pair.label === "predicts-through-exposure" || pair.label === "predicts-pooled-only"));
|
|
795
|
+
const excluded = [];
|
|
796
|
+
const references = /* @__PURE__ */ new Map();
|
|
797
|
+
const candidates = [];
|
|
798
|
+
for (const pair of admitted) {
|
|
799
|
+
if (pair.measure === pair.exposure) {
|
|
800
|
+
excluded.push({
|
|
801
|
+
measure: pair.measure,
|
|
802
|
+
reason: "exposure"
|
|
803
|
+
});
|
|
804
|
+
continue;
|
|
805
|
+
}
|
|
806
|
+
if (pair.label === "predicts-through-exposure") {
|
|
807
|
+
excluded.push({
|
|
808
|
+
measure: pair.measure,
|
|
809
|
+
reason: "through-exposure"
|
|
810
|
+
});
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
if (pair.label === "predicts-pooled-only") {
|
|
814
|
+
excluded.push({
|
|
815
|
+
measure: pair.measure,
|
|
816
|
+
reason: "pooled-only"
|
|
817
|
+
});
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
const movement = pair.movement?.label;
|
|
821
|
+
if (movement === "insensitive" || movement === "moves-against-outcome") {
|
|
822
|
+
excluded.push({
|
|
823
|
+
measure: pair.measure,
|
|
824
|
+
reason: movement
|
|
825
|
+
});
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
828
|
+
const floor = plan.selection.minEffect?.[statistic];
|
|
829
|
+
const effect = pair.exposure === null ? pair.postCut.association : pair.postCut.withinExposure;
|
|
830
|
+
if (floor !== void 0 && (effect === null || effect.estimate - effect.null < floor)) {
|
|
831
|
+
excluded.push({
|
|
832
|
+
measure: pair.measure,
|
|
833
|
+
reason: "below-minimum-effect"
|
|
834
|
+
});
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
const values = pre.flatMap((row) => {
|
|
838
|
+
const value = row.change.measures[pair.measure];
|
|
839
|
+
return value === void 0 ? [] : [value];
|
|
840
|
+
});
|
|
841
|
+
const scaled = robustScale(values);
|
|
842
|
+
if (scaled === null) continue;
|
|
843
|
+
const z = values.map((value) => alignedZ(value, pair.direction, scaled));
|
|
844
|
+
references.set(pair.measure, {
|
|
845
|
+
...scaled,
|
|
846
|
+
meanZ: z.reduce((sum, value) => sum + value, 0) / z.length
|
|
847
|
+
});
|
|
848
|
+
candidates.push(pair);
|
|
849
|
+
}
|
|
850
|
+
const pairOf = new Map(candidates.map((pair) => [pair.measure, pair]));
|
|
851
|
+
const compositeRows = (rows, set) => rows.flatMap((row) => {
|
|
852
|
+
const joined = row.outcomes.get(outcome.id);
|
|
853
|
+
if (joined === void 0) return [];
|
|
854
|
+
let sum = 0;
|
|
855
|
+
for (const measure of set) {
|
|
856
|
+
const value = row.change.measures[measure];
|
|
857
|
+
if (value === void 0) return [];
|
|
858
|
+
sum += alignedZ(value, pairOf.get(measure).direction, references.get(measure));
|
|
859
|
+
}
|
|
860
|
+
return [{
|
|
861
|
+
x: sum / set.length,
|
|
862
|
+
y: joined.better,
|
|
863
|
+
unit: row.change.unit
|
|
864
|
+
}];
|
|
865
|
+
});
|
|
866
|
+
const objective = (set) => {
|
|
867
|
+
const rows = compositeRows(pre, set);
|
|
868
|
+
return rows.length < 3 ? NaN : associationEstimate(statistic, rows);
|
|
869
|
+
};
|
|
870
|
+
const redundancy = (measure, climbed) => {
|
|
871
|
+
let best = null;
|
|
872
|
+
for (const other of climbed) {
|
|
873
|
+
const xs = [];
|
|
874
|
+
const ys = [];
|
|
875
|
+
for (const row of pre) {
|
|
876
|
+
const x = row.change.measures[measure];
|
|
877
|
+
const y = row.change.measures[other];
|
|
878
|
+
if (x === void 0 || y === void 0) continue;
|
|
879
|
+
xs.push(x);
|
|
880
|
+
ys.push(y);
|
|
881
|
+
}
|
|
882
|
+
if (xs.length < 3) continue;
|
|
883
|
+
const correlation = Math.abs(spearmanR(xs, ys));
|
|
884
|
+
if (Number.isFinite(correlation) && (best === null || correlation > best.correlation)) best = {
|
|
885
|
+
with: other,
|
|
886
|
+
correlation
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
return best;
|
|
890
|
+
};
|
|
891
|
+
const climb = [];
|
|
892
|
+
const guards = [];
|
|
893
|
+
let remaining = candidates.map((pair) => pair.measure);
|
|
894
|
+
let current = nullValue;
|
|
895
|
+
const guard = (measure, reason) => {
|
|
896
|
+
const nearest = redundancy(measure, climb.map((row) => row.measure));
|
|
897
|
+
return {
|
|
898
|
+
measure,
|
|
899
|
+
direction: pairOf.get(measure).direction,
|
|
900
|
+
reason,
|
|
901
|
+
redundantWith: reason === "redundant" ? nearest?.with ?? null : null,
|
|
902
|
+
correlation: nearest?.correlation ?? null,
|
|
903
|
+
reference: references.get(measure)
|
|
904
|
+
};
|
|
905
|
+
};
|
|
906
|
+
while (remaining.length > 0) {
|
|
907
|
+
const climbed = climb.map((row) => row.measure);
|
|
908
|
+
remaining = remaining.filter((measure) => {
|
|
909
|
+
const nearest = redundancy(measure, climbed);
|
|
910
|
+
if (nearest === null || nearest.correlation < plan.selection.maxRedundancy) return true;
|
|
911
|
+
guards.push(guard(measure, "redundant"));
|
|
912
|
+
return false;
|
|
913
|
+
});
|
|
914
|
+
if (remaining.length === 0 || climb.length >= plan.selection.maxMeasures) break;
|
|
915
|
+
let best = null;
|
|
916
|
+
for (const measure of remaining) {
|
|
917
|
+
const value = objective([...climbed, measure]);
|
|
918
|
+
if (Number.isFinite(value) && (best === null || value > best.value)) best = {
|
|
919
|
+
measure,
|
|
920
|
+
value
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
if (best === null) break;
|
|
924
|
+
const gain = best.value - current;
|
|
925
|
+
if (climb.length === 0 ? !(gain > 0) : !(gain >= plan.selection.minGain)) break;
|
|
926
|
+
climb.push({
|
|
927
|
+
measure: best.measure,
|
|
928
|
+
gain
|
|
929
|
+
});
|
|
930
|
+
current = best.value;
|
|
931
|
+
remaining = remaining.filter((measure) => measure !== best.measure);
|
|
932
|
+
}
|
|
933
|
+
const sizeLimited = climb.length >= plan.selection.maxMeasures;
|
|
934
|
+
for (const measure of remaining) guards.push(guard(measure, sizeLimited ? "size-limit" : "no-gain"));
|
|
935
|
+
const climbedIds = climb.map((row) => row.measure);
|
|
936
|
+
const postRows = climbedIds.length === 0 ? [] : compositeRows(post, climbedIds);
|
|
937
|
+
const postUnits = new Set(postRows.map((row) => row.unit)).size;
|
|
938
|
+
const composite = {
|
|
939
|
+
preCut: climbedIds.length === 0 ? null : {
|
|
940
|
+
n: compositeRows(pre, climbedIds).length,
|
|
941
|
+
estimate: current
|
|
942
|
+
},
|
|
943
|
+
postCut: postRows.length >= plan.minJoined && postUnits >= plan.minUnits && Number.isFinite(associationEstimate(statistic, postRows)) ? clusteredAssociation(postRows, {
|
|
944
|
+
statistic,
|
|
945
|
+
alternative: "greater",
|
|
946
|
+
resamples: plan.resamples,
|
|
947
|
+
confidence: plan.confidence,
|
|
948
|
+
...plan.seed === void 0 ? {} : { seed: plan.seed }
|
|
949
|
+
}) : null
|
|
950
|
+
};
|
|
951
|
+
return {
|
|
952
|
+
outcome: outcome.id,
|
|
953
|
+
climb: climb.map(({ measure, gain }) => {
|
|
954
|
+
const pair = pairOf.get(measure);
|
|
955
|
+
return {
|
|
956
|
+
measure,
|
|
957
|
+
direction: pair.direction,
|
|
958
|
+
preCutGain: gain,
|
|
959
|
+
postCutEstimate: pair.postCut.association.estimate,
|
|
960
|
+
leadTimeMs: pair.leadTimeMs,
|
|
961
|
+
cost: plan.measures.find((row) => row.id === measure).cost ?? null,
|
|
962
|
+
reference: references.get(measure)
|
|
963
|
+
};
|
|
964
|
+
}),
|
|
965
|
+
guards,
|
|
966
|
+
excluded,
|
|
967
|
+
composite,
|
|
968
|
+
outcomeReference: outcomeRef
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
// src/meta-eval/measure-validity.ts
|
|
972
|
+
/**
|
|
973
|
+
* Which recorded numbers predict a result decided later, on changes they were
|
|
974
|
+
* not chosen on, and which few of them to climb.
|
|
975
|
+
*
|
|
976
|
+
* A change has an id, a time, an independent unit and numbers known when it
|
|
977
|
+
* was made. Outcomes join to it through `DeploymentOutcome.runId` and carry
|
|
978
|
+
* their own capture time. The sealed plan's cut splits the changes: changes
|
|
979
|
+
* before it, with outcomes known by it, fix each measure's direction, the
|
|
980
|
+
* standardization and the selected subset; every reported statistic comes from
|
|
981
|
+
* changes at or after it with those choices fixed. Intervals resample whole
|
|
982
|
+
* units. Each test is one-sided, in the direction fixed before the cut, and
|
|
983
|
+
* Benjamini-Hochberg at the plan's level runs across every pair tested, again
|
|
984
|
+
* across every tested pair whose within-unit statistic is tested, and again
|
|
985
|
+
* across every tested pair with a within-exposure statistic, whatever its
|
|
986
|
+
* pooled result. A
|
|
987
|
+
* pooled statistic compares changes across units; a within-unit statistic
|
|
988
|
+
* compares changes of the same unit, so a measure that only tells units apart
|
|
989
|
+
* is visible as `predicts-pooled-only`. An outcome may name an exposure, a
|
|
990
|
+
* measure it grows with for another reason (a bigger change has more to fix);
|
|
991
|
+
* every other measure is then also tested inside bins of the exposure, and one
|
|
992
|
+
* that predicts only by tracking it is `predicts-through-exposure`.
|
|
993
|
+
*
|
|
994
|
+
* Prediction is not causation. An admitted measure forecasts the outcome of
|
|
995
|
+
* changes like these; it does not show that raising the measure raises the
|
|
996
|
+
* outcome. Records that show cause assign changes at random or interleave
|
|
997
|
+
* them, so the measure moves for reasons unrelated to the outcome.
|
|
998
|
+
*/
|
|
999
|
+
const HYPOTHESIS = "one-sided: the measure, aligned to the direction fixed before the cut, is above the null for the better outcome; Benjamini-Hochberg per family at the plan level";
|
|
1000
|
+
const CLAIM = {
|
|
1001
|
+
causal: false,
|
|
1002
|
+
scope: "held-out prediction: the measure forecasts the outcome of changes after the cut",
|
|
1003
|
+
causeRequires: "randomized or interleaved assignment of changes, so the measure moves for reasons unrelated to the outcome"
|
|
1004
|
+
};
|
|
1005
|
+
/** Rank every planned measure against every planned outcome on changes after the cut. */
|
|
1006
|
+
async function measureValidityStudy(input) {
|
|
1007
|
+
const sealed = structuredClone(input.plan);
|
|
1008
|
+
if (!verifyMeasureValidityPlan(sealed)) throw new ValidationError("measureValidityStudy: the plan seal does not verify; seal it with sealMeasureValidityPlan before reading changes after the cut");
|
|
1009
|
+
const plan = sealed.plan;
|
|
1010
|
+
const asOf = input.asOf;
|
|
1011
|
+
if (asOf !== void 0 && !(Number.isFinite(asOf) && asOf >= plan.cut)) throw new ValidationError("measureValidityStudy: asOf must be finite epoch milliseconds at or after the cut");
|
|
1012
|
+
const windowed = plan.outcomes.filter((outcome) => outcome.windowMs !== void 0);
|
|
1013
|
+
if (asOf === void 0 && windowed.length > 0) throw new ValidationError(`measureValidityStudy: outcome ${windowed[0].id} declares windowMs, so asOf, the time the outcomes were read, is required`);
|
|
1014
|
+
validateChanges(input.changes, plan, true);
|
|
1015
|
+
const byRun = groupOutcomesByRun(await input.outcomes.list());
|
|
1016
|
+
const excluded = {
|
|
1017
|
+
capturedBeforeChange: 0,
|
|
1018
|
+
capturedAfterAsOf: 0,
|
|
1019
|
+
capturedAfterCutForPreCutChange: 0,
|
|
1020
|
+
beyondMaxCaptureLag: 0,
|
|
1021
|
+
windowOpenAtCut: 0,
|
|
1022
|
+
windowOpenAtEnd: 0
|
|
1023
|
+
};
|
|
1024
|
+
const prepared = input.changes.map((change) => {
|
|
1025
|
+
const preCut = change.at < plan.cut;
|
|
1026
|
+
const { eligible, ...counts } = eligibleObservations(byRun.get(change.id) ?? [], change, plan, preCut, asOf);
|
|
1027
|
+
excluded.capturedBeforeChange += counts.capturedBeforeChange;
|
|
1028
|
+
excluded.capturedAfterAsOf += counts.capturedAfterAsOf;
|
|
1029
|
+
excluded.capturedAfterCutForPreCutChange += counts.capturedAfterCutForPreCutChange;
|
|
1030
|
+
excluded.beyondMaxCaptureLag += counts.beyondMaxCaptureLag;
|
|
1031
|
+
const outcomes = joinOutcomes(eligible, change, plan.outcomes, plan.reduction);
|
|
1032
|
+
for (const outcome of windowed) {
|
|
1033
|
+
const closesBy = preCut ? plan.cut : asOf;
|
|
1034
|
+
if (change.at + outcome.windowMs > closesBy && outcomes.delete(outcome.id)) {
|
|
1035
|
+
if (preCut) excluded.windowOpenAtCut++;
|
|
1036
|
+
else excluded.windowOpenAtEnd++;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return {
|
|
1040
|
+
change,
|
|
1041
|
+
preCut,
|
|
1042
|
+
outcomes
|
|
1043
|
+
};
|
|
1044
|
+
});
|
|
1045
|
+
const pre = prepared.filter((row) => row.preCut);
|
|
1046
|
+
const post = prepared.filter((row) => !row.preCut);
|
|
1047
|
+
const preUnits = new Set(pre.map((row) => row.change.unit));
|
|
1048
|
+
const postUnits = new Set(post.map((row) => row.change.unit));
|
|
1049
|
+
const exposures = plan.outcomes.flatMap((outcome) => outcome.exposure === void 0 ? [] : [exposureBins(outcome, pre)]);
|
|
1050
|
+
const pairs = [];
|
|
1051
|
+
for (const measure of plan.measures) for (const outcome of plan.outcomes) {
|
|
1052
|
+
const bins = exposures.find((row) => row.outcome === outcome.id) ?? null;
|
|
1053
|
+
pairs.push(assessPair(measure.id, outcome, bins, pre, post, plan));
|
|
1054
|
+
}
|
|
1055
|
+
const tested = pairs.filter((pair) => pair.postCut.association !== null);
|
|
1056
|
+
const { qValues } = benjaminiHochberg(tested.map((pair) => pair.postCut.association.pValue), plan.level);
|
|
1057
|
+
tested.forEach((pair, index) => {
|
|
1058
|
+
pair.postCut.qValue = qValues[index];
|
|
1059
|
+
});
|
|
1060
|
+
const withinTested = tested.filter((pair) => pair.postCut.withinUnit !== null && pair.postCut.withinUnit.units >= plan.minUnits);
|
|
1061
|
+
const withinQ = benjaminiHochberg(withinTested.map((pair) => pair.postCut.withinUnit.pValue), plan.level).qValues;
|
|
1062
|
+
withinTested.forEach((pair, index) => {
|
|
1063
|
+
pair.postCut.withinUnitQValue = withinQ[index];
|
|
1064
|
+
});
|
|
1065
|
+
const exposureTested = tested.filter((pair) => pair.postCut.withinExposure !== null);
|
|
1066
|
+
const exposureQ = benjaminiHochberg(exposureTested.map((pair) => pair.postCut.withinExposure.pValue), plan.level).qValues;
|
|
1067
|
+
exposureTested.forEach((pair, index) => {
|
|
1068
|
+
pair.postCut.withinExposureQValue = exposureQ[index];
|
|
1069
|
+
});
|
|
1070
|
+
for (const pair of tested) labelPair(pair, plan.level);
|
|
1071
|
+
const outcomeReferences = new Map(plan.outcomes.map((outcome) => [outcome.id, outcomeReference(outcome, pre)]));
|
|
1072
|
+
for (const pair of pairs) {
|
|
1073
|
+
const outcome = plan.outcomes.find((row) => row.id === pair.outcome);
|
|
1074
|
+
pair.movement = assessMovement(pair, outcome, post, plan, outcomeReferences.get(outcome.id));
|
|
1075
|
+
}
|
|
1076
|
+
const movementTested = pairs.filter((pair) => pair.movement?.agreement);
|
|
1077
|
+
const movementQ = benjaminiHochberg(movementTested.map((pair) => pair.movement.agreement.pValue), plan.level).qValues;
|
|
1078
|
+
movementTested.forEach((pair, index) => {
|
|
1079
|
+
const movement = pair.movement;
|
|
1080
|
+
const agreement = movement.agreement;
|
|
1081
|
+
const q = movementQ[index];
|
|
1082
|
+
movement.qValue = q;
|
|
1083
|
+
movement.label = q <= plan.level ? "moves-with-outcome" : agreement.high < agreement.null ? "moves-against-outcome" : "agreement-not-shown";
|
|
1084
|
+
});
|
|
1085
|
+
const selections = plan.outcomes.map((outcome) => selectMeasures(outcome, pairs, pre, post, plan, outcomeReferences.get(outcome.id)));
|
|
1086
|
+
return {
|
|
1087
|
+
planDigest: sealed.digest,
|
|
1088
|
+
plan,
|
|
1089
|
+
asOf: asOf ?? null,
|
|
1090
|
+
claim: { ...CLAIM },
|
|
1091
|
+
hypothesis: HYPOTHESIS,
|
|
1092
|
+
changes: {
|
|
1093
|
+
total: prepared.length,
|
|
1094
|
+
preCut: pre.length,
|
|
1095
|
+
postCut: post.length
|
|
1096
|
+
},
|
|
1097
|
+
units: {
|
|
1098
|
+
preCut: preUnits.size,
|
|
1099
|
+
postCut: postUnits.size,
|
|
1100
|
+
both: [...postUnits].filter((unit) => preUnits.has(unit)).length
|
|
1101
|
+
},
|
|
1102
|
+
excludedObservations: excluded,
|
|
1103
|
+
exposures,
|
|
1104
|
+
coverage: plan.measures.map((measure) => coverageOf(measure.id, pre, post)),
|
|
1105
|
+
pairs,
|
|
1106
|
+
tested: tested.length,
|
|
1107
|
+
withinUnitTested: withinTested.length,
|
|
1108
|
+
withinExposureTested: exposureTested.length,
|
|
1109
|
+
admitted: pairs.filter((pair) => pair.label === "predicts").length,
|
|
1110
|
+
movementTested: movementTested.length,
|
|
1111
|
+
selections
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* The pooled test admits; the test inside exposure bins and then the tested
|
|
1116
|
+
* within-unit test can only narrow the label.
|
|
1117
|
+
*/
|
|
1118
|
+
function labelPair(pair, level) {
|
|
1119
|
+
const association = pair.postCut.association;
|
|
1120
|
+
if (pair.postCut.qValue > level) {
|
|
1121
|
+
pair.label = "not-shown";
|
|
1122
|
+
pair.reason = association.high < association.null ? "direction-reversed" : "not-significant";
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
if (pair.exposure !== null && pair.exposure !== pair.measure) {
|
|
1126
|
+
if (pair.postCut.withinExposure === null) {
|
|
1127
|
+
pair.label = "predicts-through-exposure";
|
|
1128
|
+
pair.reason = "within-exposure-untested";
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
if (pair.withinExposureDirection !== pair.direction || pair.postCut.withinExposureQValue > level) {
|
|
1132
|
+
pair.label = "predicts-through-exposure";
|
|
1133
|
+
pair.reason = "within-exposure-not-shown";
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
if (pair.postCut.withinUnitQValue === null) {
|
|
1138
|
+
pair.label = "predicts";
|
|
1139
|
+
pair.reason = "within-unit-untested";
|
|
1140
|
+
} else if (pair.postCut.withinUnitQValue > level) {
|
|
1141
|
+
pair.label = "predicts-pooled-only";
|
|
1142
|
+
pair.reason = "within-unit-not-shown";
|
|
1143
|
+
} else {
|
|
1144
|
+
pair.label = "predicts";
|
|
1145
|
+
pair.reason = null;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
/** Bin edges at the exposure's quantiles over changes before the cut joined to the outcome. */
|
|
1149
|
+
function exposureBins(outcome, pre) {
|
|
1150
|
+
const { measure, bins } = outcome.exposure;
|
|
1151
|
+
const values = pre.flatMap((row) => {
|
|
1152
|
+
const value = row.change.measures[measure];
|
|
1153
|
+
return value === void 0 || !row.outcomes.has(outcome.id) ? [] : [value];
|
|
1154
|
+
}).sort((a, b) => a - b);
|
|
1155
|
+
const edges = [];
|
|
1156
|
+
if (values.length > 0) for (let k = 1; k < bins; k++) {
|
|
1157
|
+
const edge = interpolatedQuantile(values, k / bins);
|
|
1158
|
+
if (edge !== edges[edges.length - 1]) edges.push(edge);
|
|
1159
|
+
}
|
|
1160
|
+
return {
|
|
1161
|
+
outcome: outcome.id,
|
|
1162
|
+
measure,
|
|
1163
|
+
bins,
|
|
1164
|
+
edges
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
/** The bin of a value: the number of edges below it. */
|
|
1168
|
+
function binOf(value, edges) {
|
|
1169
|
+
let bin = 0;
|
|
1170
|
+
while (bin < edges.length && value > edges[bin]) bin++;
|
|
1171
|
+
return String(bin);
|
|
1172
|
+
}
|
|
1173
|
+
function coverageOf(measure, pre, post) {
|
|
1174
|
+
const measured = (rows) => rows.filter((row) => row.change.measures[measure] !== void 0).length;
|
|
1175
|
+
const changes = pre.length + post.length;
|
|
1176
|
+
const total = measured(pre) + measured(post);
|
|
1177
|
+
return {
|
|
1178
|
+
measure,
|
|
1179
|
+
changes,
|
|
1180
|
+
measured: total,
|
|
1181
|
+
share: changes === 0 ? 0 : total / changes,
|
|
1182
|
+
preCut: {
|
|
1183
|
+
changes: pre.length,
|
|
1184
|
+
measured: measured(pre)
|
|
1185
|
+
},
|
|
1186
|
+
postCut: {
|
|
1187
|
+
changes: post.length,
|
|
1188
|
+
measured: measured(post)
|
|
1189
|
+
},
|
|
1190
|
+
movements: [...pre, ...post].filter((row) => row.change.movements?.[measure] !== void 0).length
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
/** Joined changes for one pair; `stratum` is the exposure bin when the exposure was measured. */
|
|
1194
|
+
function joinedRows(rows, measure, outcome, exposure) {
|
|
1195
|
+
return rows.flatMap((row) => {
|
|
1196
|
+
const x = row.change.measures[measure];
|
|
1197
|
+
const joined = row.outcomes.get(outcome);
|
|
1198
|
+
if (x === void 0 || joined === void 0) return [];
|
|
1199
|
+
const exposed = exposure === null ? void 0 : row.change.measures[exposure.measure];
|
|
1200
|
+
return [{
|
|
1201
|
+
x,
|
|
1202
|
+
y: joined.better,
|
|
1203
|
+
unit: row.change.unit,
|
|
1204
|
+
lag: joined.capturedAt - row.change.at,
|
|
1205
|
+
...exposed === void 0 ? {} : { stratum: binOf(exposed, exposure.edges) }
|
|
1206
|
+
}];
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
function assessPair(measure, outcome, exposure, pre, post, plan) {
|
|
1210
|
+
const statistic = statisticOf(outcome);
|
|
1211
|
+
const nullValue = statistic === "auc" ? .5 : 0;
|
|
1212
|
+
const preRows = joinedRows(pre, measure, outcome.id, exposure);
|
|
1213
|
+
const postRows = joinedRows(post, measure, outcome.id, exposure);
|
|
1214
|
+
const preEstimate = preRows.length >= 3 ? associationEstimate(statistic, preRows) : NaN;
|
|
1215
|
+
const direction = directionOf(preEstimate, nullValue);
|
|
1216
|
+
const testsExposure = exposure !== null && exposure.measure !== measure;
|
|
1217
|
+
const preBinned = preRows.filter((row) => row.stratum !== void 0);
|
|
1218
|
+
const preWithinExposure = testsExposure && preBinned.length >= 3 ? associationEstimate(statistic, preBinned, "stratified") : NaN;
|
|
1219
|
+
const exposureDirection = directionOf(preWithinExposure, nullValue);
|
|
1220
|
+
const postUnits = new Set(postRows.map((row) => row.unit)).size;
|
|
1221
|
+
const lags = postRows.map((row) => row.lag);
|
|
1222
|
+
const result = {
|
|
1223
|
+
measure,
|
|
1224
|
+
outcome: outcome.id,
|
|
1225
|
+
statistic,
|
|
1226
|
+
label: "insufficient",
|
|
1227
|
+
reason: null,
|
|
1228
|
+
direction,
|
|
1229
|
+
exposure: exposure?.measure ?? null,
|
|
1230
|
+
withinExposureDirection: exposureDirection,
|
|
1231
|
+
preCut: {
|
|
1232
|
+
n: preRows.length,
|
|
1233
|
+
units: new Set(preRows.map((row) => row.unit)).size,
|
|
1234
|
+
estimate: Number.isFinite(preEstimate) ? preEstimate : null,
|
|
1235
|
+
withinExposure: Number.isFinite(preWithinExposure) ? preWithinExposure : null
|
|
1236
|
+
},
|
|
1237
|
+
postCut: {
|
|
1238
|
+
n: postRows.length,
|
|
1239
|
+
units: postUnits,
|
|
1240
|
+
minority: minorityCount(postRows.map((row) => row.x)),
|
|
1241
|
+
association: null,
|
|
1242
|
+
qValue: null,
|
|
1243
|
+
withinUnit: null,
|
|
1244
|
+
withinUnitQValue: null,
|
|
1245
|
+
withinExposure: null,
|
|
1246
|
+
withinExposureQValue: null
|
|
1247
|
+
},
|
|
1248
|
+
leadTimeMs: lags.length === 0 ? null : {
|
|
1249
|
+
median: sampleMedian(lags),
|
|
1250
|
+
min: lags.reduce((a, b) => Math.min(a, b)),
|
|
1251
|
+
max: lags.reduce((a, b) => Math.max(a, b))
|
|
1252
|
+
},
|
|
1253
|
+
movement: null
|
|
1254
|
+
};
|
|
1255
|
+
const aligned = postRows.map((row) => ({
|
|
1256
|
+
x: direction === "lower" ? -row.x : row.x,
|
|
1257
|
+
y: row.y,
|
|
1258
|
+
unit: row.unit
|
|
1259
|
+
}));
|
|
1260
|
+
if (postRows.length < plan.minJoined) result.reason = "below-minimum-count";
|
|
1261
|
+
else if (postUnits < plan.minUnits) result.reason = "too-few-units";
|
|
1262
|
+
else if (result.postCut.minority < plan.minMinority) result.reason = "too-little-variation";
|
|
1263
|
+
else if (direction === null) result.reason = "no-pre-cut-direction";
|
|
1264
|
+
else if (!Number.isFinite(associationEstimate(statistic, aligned))) result.reason = "constant-after-cut";
|
|
1265
|
+
if (result.reason !== null) return result;
|
|
1266
|
+
const options = {
|
|
1267
|
+
statistic,
|
|
1268
|
+
alternative: "greater",
|
|
1269
|
+
resamples: plan.resamples,
|
|
1270
|
+
confidence: plan.confidence,
|
|
1271
|
+
...plan.seed === void 0 ? {} : { seed: plan.seed }
|
|
1272
|
+
};
|
|
1273
|
+
result.postCut.association = clusteredAssociation(aligned, options);
|
|
1274
|
+
if (comparableUnits(aligned) >= 2 && Number.isFinite(associationEstimate(statistic, aligned, "within-unit"))) result.postCut.withinUnit = clusteredAssociation(aligned, {
|
|
1275
|
+
...options,
|
|
1276
|
+
scope: "within-unit"
|
|
1277
|
+
});
|
|
1278
|
+
if (testsExposure && exposureDirection !== null) {
|
|
1279
|
+
const binned = postRows.flatMap((row) => row.stratum === void 0 ? [] : [{
|
|
1280
|
+
x: exposureDirection === "lower" ? -row.x : row.x,
|
|
1281
|
+
y: row.y,
|
|
1282
|
+
unit: row.unit,
|
|
1283
|
+
stratum: row.stratum
|
|
1284
|
+
}]);
|
|
1285
|
+
if (new Set(binned.map((row) => row.unit)).size >= 2 && Number.isFinite(associationEstimate(statistic, binned, "stratified"))) result.postCut.withinExposure = clusteredAssociation(binned, {
|
|
1286
|
+
...options,
|
|
1287
|
+
scope: "stratified"
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
return result;
|
|
1291
|
+
}
|
|
1292
|
+
function directionOf(estimate, nullValue) {
|
|
1293
|
+
if (!Number.isFinite(estimate)) return null;
|
|
1294
|
+
return estimate > nullValue ? "higher" : estimate < nullValue ? "lower" : null;
|
|
1295
|
+
}
|
|
1296
|
+
/** Values that differ from the most common value: the smaller class of a two-valued measure. */
|
|
1297
|
+
function minorityCount(values) {
|
|
1298
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1299
|
+
let largest = 0;
|
|
1300
|
+
for (const value of values) {
|
|
1301
|
+
const count = (counts.get(value) ?? 0) + 1;
|
|
1302
|
+
counts.set(value, count);
|
|
1303
|
+
largest = Math.max(largest, count);
|
|
1304
|
+
}
|
|
1305
|
+
return values.length - largest;
|
|
1306
|
+
}
|
|
1307
|
+
/** Units holding a comparable pair: two changes with different outcomes. */
|
|
1308
|
+
function comparableUnits(rows) {
|
|
1309
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1310
|
+
const comparable = /* @__PURE__ */ new Set();
|
|
1311
|
+
for (const row of rows) {
|
|
1312
|
+
const first = seen.get(row.unit);
|
|
1313
|
+
if (first === void 0) seen.set(row.unit, row.y);
|
|
1314
|
+
else if (first !== row.y) comparable.add(row.unit);
|
|
1315
|
+
}
|
|
1316
|
+
return comparable.size;
|
|
1317
|
+
}
|
|
1318
|
+
function assessMovement(pair, outcome, post, plan, reference) {
|
|
1319
|
+
const noise = plan.measures.find((row) => row.id === pair.measure).noise;
|
|
1320
|
+
const rows = post.flatMap((row) => {
|
|
1321
|
+
const movement = row.change.movements?.[pair.measure];
|
|
1322
|
+
return movement === void 0 ? [] : [{
|
|
1323
|
+
row,
|
|
1324
|
+
delta: movement.after - movement.before
|
|
1325
|
+
}];
|
|
1326
|
+
});
|
|
1327
|
+
if (noise === void 0 || rows.length === 0) return null;
|
|
1328
|
+
const units = new Set(rows.map(({ row }) => row.change.unit)).size;
|
|
1329
|
+
const moved = rows.filter(({ delta }) => Math.abs(delta) > noise);
|
|
1330
|
+
const result = {
|
|
1331
|
+
label: "insufficient",
|
|
1332
|
+
changes: rows.length,
|
|
1333
|
+
units,
|
|
1334
|
+
moved: moved.length,
|
|
1335
|
+
sensitivity: null,
|
|
1336
|
+
agreement: null,
|
|
1337
|
+
qValue: null
|
|
1338
|
+
};
|
|
1339
|
+
if (rows.length < plan.minJoined || units < plan.minUnits) return result;
|
|
1340
|
+
const sensitivity = clusterBootstrapMean(rows.map(({ row, delta }) => ({
|
|
1341
|
+
cluster: row.change.unit,
|
|
1342
|
+
value: Math.abs(delta) > noise ? 1 : 0
|
|
1343
|
+
})), {
|
|
1344
|
+
confidence: plan.confidence,
|
|
1345
|
+
resamples: plan.resamples,
|
|
1346
|
+
...plan.seed === void 0 ? {} : { seed: plan.seed }
|
|
1347
|
+
});
|
|
1348
|
+
result.sensitivity = {
|
|
1349
|
+
estimate: sensitivity.mean,
|
|
1350
|
+
low: sensitivity.low,
|
|
1351
|
+
high: sensitivity.high
|
|
1352
|
+
};
|
|
1353
|
+
if (sensitivity.high < plan.minSensitivity) {
|
|
1354
|
+
result.label = "insensitive";
|
|
1355
|
+
return result;
|
|
1356
|
+
}
|
|
1357
|
+
if (pair.direction === null || reference === null) return result;
|
|
1358
|
+
const sign = pair.direction === "higher" ? 1 : -1;
|
|
1359
|
+
const agreementRows = moved.flatMap(({ row, delta }) => {
|
|
1360
|
+
const joined = row.outcomes.get(outcome.id);
|
|
1361
|
+
if (joined === void 0) return [];
|
|
1362
|
+
const better = reference.kind === "binary" ? joined.better : joined.better > reference.center ? 1 : joined.better < reference.center ? 0 : null;
|
|
1363
|
+
return better === null ? [] : [{
|
|
1364
|
+
x: Math.sign(sign * delta),
|
|
1365
|
+
y: better,
|
|
1366
|
+
unit: row.change.unit
|
|
1367
|
+
}];
|
|
1368
|
+
});
|
|
1369
|
+
const agreementUnits = new Set(agreementRows.map((row) => row.unit)).size;
|
|
1370
|
+
if (agreementRows.length < plan.minJoined || agreementUnits < plan.minUnits || !Number.isFinite(associationEstimate("auc", agreementRows))) return result;
|
|
1371
|
+
result.agreement = clusteredAssociation(agreementRows, {
|
|
1372
|
+
statistic: "auc",
|
|
1373
|
+
alternative: "greater",
|
|
1374
|
+
resamples: plan.resamples,
|
|
1375
|
+
confidence: plan.confidence,
|
|
1376
|
+
...plan.seed === void 0 ? {} : { seed: plan.seed }
|
|
1377
|
+
});
|
|
1378
|
+
return result;
|
|
1379
|
+
}
|
|
587
1380
|
// src/meta-eval/plants.ts
|
|
588
1381
|
/**
|
|
589
1382
|
* Plants — seeded known-wrong items that measure the grader, not the work.
|
|
@@ -1064,6 +1857,6 @@ function unseededRejection(manifest, scoreByItemId) {
|
|
|
1064
1857
|
rejectionRate: decided === 0 ? null : rejected / decided
|
|
1065
1858
|
};
|
|
1066
1859
|
}
|
|
1067
|
-
export { DEFAULT_JUDGE_GATE_POLICY, FileSystemOutcomeStore, InMemoryOutcomeStore, JudgeGateRefusedError, OutcomeStoreError, addCalibrationVerdicts, assertJudgeMayGate, auditEvaluator, auditProbabilityPolicy, brierScore, calibrateJudge, calibrateJudgeContinuous, calibrateJudgePanel, calibrationCurve, calibrationFromPairs, catchRate, clusterBootstrapMean, continuousAgreement, correlationStudy, definePlant, evalHealthStamp, evaluatorAdmissionPolicySchema, evaluatorAuditObservationSchema, fileSentinelStore, gateJudgeCalibration, judgeGateDecision, judgeSentinelReport, measureJudgeAgreement, multiclassBrierScore, perturbEvidence, planEvaluatorAudit, plantByPerturbation, positionalBias, rankedProbabilityScore, registerCalibrationSet, rubricPredictiveValidity, seedPlants, selfPreference, snapshotFromAgreement, snapshotFromCalibration, snapshotFromJudgeAgreement, snapshotFromSentinelSet, validateSentinelSnapshot, verbosityBias };
|
|
1860
|
+
export { DEFAULT_JUDGE_GATE_POLICY, FileSystemOutcomeStore, InMemoryOutcomeStore, JudgeGateRefusedError, OutcomeStoreError, addCalibrationVerdicts, assertJudgeMayGate, auditEvaluator, auditProbabilityPolicy, brierScore, calibrateJudge, calibrateJudgeContinuous, calibrateJudgePanel, calibrationCurve, calibrationFromPairs, catchRate, clusterBootstrapMean, continuousAgreement, correlationStudy, definePlant, evalHealthStamp, evaluatorAdmissionPolicySchema, evaluatorAuditObservationSchema, fileSentinelStore, gateJudgeCalibration, guardDrift, judgeGateDecision, judgeSentinelReport, measureJudgeAgreement, measureValidityStudy, multiclassBrierScore, perturbEvidence, planEvaluatorAudit, plantByPerturbation, positionalBias, rankedProbabilityScore, registerCalibrationSet, rubricPredictiveValidity, seedPlants, selfPreference, snapshotFromAgreement, snapshotFromCalibration, snapshotFromJudgeAgreement, snapshotFromSentinelSet, validateSentinelSnapshot, verbosityBias };
|
|
1068
1861
|
|
|
1069
1862
|
//# sourceMappingURL=index.js.map
|