@tangle-network/agent-eval 2.0.5 → 2.0.9
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 +24 -0
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-CcOq7bOO.d.ts → agent-profile-ORN4aArD.d.ts} +5 -5
- package/dist/{agent-profile-CcOq7bOO.d.ts.map → agent-profile-ORN4aArD.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +15 -15
- package/dist/analyst/index.js +18 -14
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-C_9cXPZn.js → analyze-runs-CE_5VKh2.js} +6 -5
- package/dist/{analyze-runs-C_9cXPZn.js.map → analyze-runs-CE_5VKh2.js.map} +1 -1
- package/dist/analyze-runs-DT693FJ7.d.ts +65 -0
- package/dist/analyze-runs-DT693FJ7.d.ts.map +1 -0
- package/dist/app-grade/index.d.ts +4 -4
- package/dist/app-grade/index.js +1 -1
- package/dist/{benchmark-command-MfXRocwZ.js → benchmark-command-DLg8E4y8.js} +16 -9
- package/dist/benchmark-command-DLg8E4y8.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 +12 -11
- package/dist/{campaign-DfSWSreo.js → campaign-C_S3MOYa.js} +1589 -14
- package/dist/campaign-C_S3MOYa.js.map +1 -0
- package/dist/{campaign-evidence-D_oBFfLc.js → campaign-evidence-BTfzZo1u.js} +4 -4
- package/dist/{campaign-evidence-D_oBFfLc.js.map → campaign-evidence-BTfzZo1u.js.map} +1 -1
- package/dist/{campaign-evidence-BmMs8YJt.d.ts → campaign-evidence-CM4FBOkX.d.ts} +5 -5
- package/dist/{campaign-evidence-BmMs8YJt.d.ts.map → campaign-evidence-CM4FBOkX.d.ts.map} +1 -1
- package/dist/{cluster-Bj90LK-1.d.ts → chat-client-uQNXGuO4.d.ts} +3 -240
- package/dist/chat-client-uQNXGuO4.d.ts.map +1 -0
- package/dist/cli.js +6 -6
- package/dist/cluster-C-K0N2br.d.ts +241 -0
- package/dist/cluster-C-K0N2br.d.ts.map +1 -0
- package/dist/{cluster-bootstrap-DPzVy3_K.js → cluster-bootstrap-DXbnIdm8.js} +3 -2
- package/dist/{cluster-bootstrap-DPzVy3_K.js.map → cluster-bootstrap-DXbnIdm8.js.map} +1 -1
- package/dist/{completion-verifier-Cy38EpGE.d.ts → completion-verifier-C7wipJOK.d.ts} +2 -2
- package/dist/{completion-verifier-Cy38EpGE.d.ts.map → completion-verifier-C7wipJOK.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +14 -12
- package/dist/contract/index.js +13 -11
- 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-CUuorCWZ.d.ts → default-registry-Bskl2HzV.d.ts} +6 -7
- package/dist/default-registry-Bskl2HzV.d.ts.map +1 -0
- package/dist/{default-registry-IkE3byrA.js → default-registry-kps1SOaD.js} +27 -15
- package/dist/default-registry-kps1SOaD.js.map +1 -0
- package/dist/define-agent-eval-Dnh4jXLX.js +96 -0
- package/dist/define-agent-eval-Dnh4jXLX.js.map +1 -0
- package/dist/define-agent-eval-tu3anVlk.d.ts +52 -0
- package/dist/define-agent-eval-tu3anVlk.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-DE11iBcC.js → dspy-rlm-engine-DQbPdT_o.js} +8 -4
- package/dist/{dspy-rlm-engine-DE11iBcC.js.map → dspy-rlm-engine-DQbPdT_o.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-DswSn7Gm.js} +3 -3
- package/dist/{eval-campaign-Cyk-tkLh.js.map → eval-campaign-DswSn7Gm.js.map} +1 -1
- package/dist/{evaluation-DfyLPVL1.d.ts → evaluation-C4-tf3Z_.d.ts} +4 -4
- package/dist/{evaluation-DfyLPVL1.d.ts.map → evaluation-C4-tf3Z_.d.ts.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/{exact-types-CiCXYhNK.d.ts → exact-types-CUsSMW3n.d.ts} +2 -2
- package/dist/{exact-types-CiCXYhNK.d.ts.map → exact-types-CUsSMW3n.d.ts.map} +1 -1
- package/dist/{execution-insight-wUNXxo5Y.d.ts → execution-insight-YihQrSqd.d.ts} +2 -2
- package/dist/{execution-insight-wUNXxo5Y.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-process-4QdcF7Kd.js → external-optimizer-process-CVi1x2nb.js} +2 -2
- package/dist/{external-optimizer-process-4QdcF7Kd.js.map → external-optimizer-process-CVi1x2nb.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-BW0ZWUUr.js → external-optimizer-subprocess-mV-2swJI.js} +3 -357
- package/dist/external-optimizer-subprocess-mV-2swJI.js.map +1 -0
- package/dist/{feedback-trajectory-HJticMDz.d.ts → feedback-trajectory-D7hgL6y5.d.ts} +3 -3
- package/dist/{feedback-trajectory-HJticMDz.d.ts.map → feedback-trajectory-D7hgL6y5.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-BxpV-hfH.js → findings-store-CZy5kUDo.js} +26 -19
- package/dist/findings-store-CZy5kUDo.js.map +1 -0
- package/dist/fuzz.js +1 -1
- package/dist/{harness-session-lines-CSxKR6no.js → harness-session-lines-CTh1-uOb.js} +21 -19
- package/dist/harness-session-lines-CTh1-uOb.js.map +1 -0
- package/dist/{index-Ucp54Pcl.d.ts → index--vDCtdaj.d.ts} +7 -8
- package/dist/index--vDCtdaj.d.ts.map +1 -0
- package/dist/{index-CKjqN9_U.d.ts → index-CIqYaySd.d.ts} +89 -3
- package/dist/index-CIqYaySd.d.ts.map +1 -0
- package/dist/{index-C6TG1LwA.d.ts → index-Cav3abKy.d.ts} +256 -131
- package/dist/index-Cav3abKy.d.ts.map +1 -0
- package/dist/{index-CR-guIiZ.d.ts → index-DmMHTDjT.d.ts} +10 -8
- package/dist/index-DmMHTDjT.d.ts.map +1 -0
- package/dist/{index-oX0TuJFv.d.ts → index-Er8TKQ3q.d.ts} +4 -4
- package/dist/{index-oX0TuJFv.d.ts.map → index-Er8TKQ3q.d.ts.map} +1 -1
- package/dist/{index-B_k8aY9k.d.ts → index-moZnazVj.d.ts} +22 -21
- package/dist/index-moZnazVj.d.ts.map +1 -0
- package/dist/index.d.ts +33 -30
- package/dist/index.js +27 -24
- package/dist/index.js.map +1 -1
- package/dist/{analyze-runs-Ke0WbAf6.d.ts → insight-report-DYofCMLx.d.ts} +4 -64
- package/dist/insight-report-DYofCMLx.d.ts.map +1 -0
- package/dist/{integrity-B9320cw1.d.ts → integrity-BJGstiCh.d.ts} +2 -2
- package/dist/{integrity-B9320cw1.d.ts.map → integrity-BJGstiCh.d.ts.map} +1 -1
- package/dist/{judge-gate-DqlzOBOm.js → judge-gate-DANg5FLq.js} +2 -2
- package/dist/{judge-gate-DqlzOBOm.js.map → judge-gate-DANg5FLq.js.map} +1 -1
- package/dist/{kind-factory-BDd4rhML.js → kind-factory-B-xCxG7p.js} +33 -5
- package/dist/kind-factory-B-xCxG7p.js.map +1 -0
- package/dist/llm-judge-DFoSy4Qn.js +476 -0
- package/dist/llm-judge-DFoSy4Qn.js.map +1 -0
- package/dist/{matrix-DlSrRl_v.d.ts → matrix-OgdWQBQa.d.ts} +6 -2
- package/dist/matrix-OgdWQBQa.d.ts.map +1 -0
- package/dist/measure-validity-plan-B1_qYlsk.d.ts +143 -0
- package/dist/measure-validity-plan-B1_qYlsk.d.ts.map +1 -0
- package/dist/measure-validity-plan-t0YQRzJQ.js +117 -0
- package/dist/measure-validity-plan-t0YQRzJQ.js.map +1 -0
- package/dist/meta-eval/index.d.ts +5 -3
- package/dist/meta-eval/index.js +664 -14
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +458 -4
- package/dist/multishot/index.d.ts.map +1 -1
- package/dist/multishot/index.js +926 -47
- package/dist/multishot/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{llm-judge-DQJTQx01.js → optimization-method-D4CpYsVA.js} +18 -482
- package/dist/optimization-method-D4CpYsVA.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-B6EXnI47.js} +3 -2
- package/dist/{paired-arms-DZhH3FGu.js.map → paired-arms-B6EXnI47.js.map} +1 -1
- package/dist/{paired-promotion-decision-ChHBuuHV.d.ts → paired-promotion-decision-DuvRdnsW.d.ts} +2 -2
- package/dist/{paired-promotion-decision-ChHBuuHV.d.ts.map → paired-promotion-decision-DuvRdnsW.d.ts.map} +1 -1
- package/dist/{paired-promotion-decision-Dn3-jaq4.js → paired-promotion-decision-xYe881cD.js} +3 -2
- package/dist/{paired-promotion-decision-Dn3-jaq4.js.map → paired-promotion-decision-xYe881cD.js.map} +1 -1
- package/dist/{paired-promotion-power-BlzXdgMD.js → paired-promotion-power-DirShsIs.js} +3 -3
- package/dist/{paired-promotion-power-BlzXdgMD.js.map → paired-promotion-power-DirShsIs.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-DTg6u30w.js} +181 -4
- package/dist/power-DTg6u30w.js.map +1 -0
- package/dist/{prime-protocol-iEaSEGZB.d.ts → prime-protocol-Jm2pWh--.d.ts} +2 -2
- package/dist/{prime-protocol-iEaSEGZB.d.ts.map → prime-protocol-Jm2pWh--.d.ts.map} +1 -1
- package/dist/{promotion-gate-CGkxh36r.d.ts → promotion-gate-BXgcORnM.d.ts} +2 -2
- package/dist/{promotion-gate-CGkxh36r.d.ts.map → promotion-gate-BXgcORnM.d.ts.map} +1 -1
- package/dist/{promotion-policy-CxDIh-9p.js → promotion-policy-Z5E-C32U.js} +4 -4
- package/dist/{promotion-policy-CxDIh-9p.js.map → promotion-policy-Z5E-C32U.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-V8o2kZtn.d.ts → registry-DEZDECdr.d.ts} +4 -4
- package/dist/{registry-V8o2kZtn.d.ts.map → registry-DEZDECdr.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-CIgUe1lv.d.ts} +2 -2
- package/dist/{research-report-D6XIK0eK.d.ts.map → research-report-CIgUe1lv.d.ts.map} +1 -1
- package/dist/{researcher---DhHG4J.d.ts → researcher-CY_byuZl.d.ts} +4 -4
- package/dist/{researcher---DhHG4J.d.ts.map → researcher-CY_byuZl.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 +2 -2
- package/dist/{rollout-DVwpCHBC.js → rollout-B_lrpd9a.js} +2 -2
- package/dist/{rollout-DVwpCHBC.js.map → rollout-B_lrpd9a.js.map} +1 -1
- 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-CtLyPb5-.d.ts → run-improvement-loop-BaPDVbW8.d.ts} +384 -11
- package/dist/run-improvement-loop-BaPDVbW8.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-DdUijr_t.js → runtime-rollouts-Vv-BAqmq.js} +3 -3
- package/dist/{runtime-rollouts-DdUijr_t.js.map → runtime-rollouts-Vv-BAqmq.js.map} +1 -1
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-DXA1EhnN.d.ts → search-kernel-BzTeb89p.d.ts} +3 -3
- package/dist/{search-kernel-DXA1EhnN.d.ts.map → search-kernel-BzTeb89p.d.ts.map} +1 -1
- package/dist/{pareto-Bg75Gajo.js → search-kernel-DOPW08Hx.js} +6 -88
- package/dist/search-kernel-DOPW08Hx.js.map +1 -0
- package/dist/{search-summary-B1x1Vmzh.js → search-summary-CYOHZAAy.js} +4 -4
- package/dist/{search-summary-B1x1Vmzh.js.map → search-summary-CYOHZAAy.js.map} +1 -1
- package/dist/{define-agent-eval-B6uE3gNu.js → self-improve-CIFqccHV.js} +8 -97
- package/dist/self-improve-CIFqccHV.js.map +1 -0
- package/dist/{define-agent-eval-D17XsdAt.d.ts → self-improve-DY8ZY4lY.d.ts} +8 -54
- package/dist/self-improve-DY8ZY4lY.d.ts.map +1 -0
- package/dist/{sequential-BhbTSxpt.d.ts → sequential-B9iROM1S.d.ts} +2 -2
- package/dist/{sequential-BhbTSxpt.d.ts.map → sequential-B9iROM1S.d.ts.map} +1 -1
- package/dist/{sequential-ux_XrjBf.js → sequential-tZjGysXY.js} +3 -3
- package/dist/{sequential-ux_XrjBf.js.map → sequential-tZjGysXY.js.map} +1 -1
- package/dist/{skillopt-optimization-method-D_swD0Cy.js → skillopt-optimization-method-CbHBkopM.js} +9 -8
- package/dist/{skillopt-optimization-method-D_swD0Cy.js.map → skillopt-optimization-method-CbHBkopM.js.map} +1 -1
- package/dist/{statistical-heldout-CaS4T-43.js → statistical-heldout-C7Jjo5nP.js} +3 -3
- package/dist/{statistical-heldout-CaS4T-43.js.map → statistical-heldout-C7Jjo5nP.js.map} +1 -1
- package/dist/{statistics-DSidA5I2.js → statistics-BPl13X3G.js} +208 -700
- package/dist/statistics-BPl13X3G.js.map +1 -0
- package/dist/statistics.d.ts +3 -3
- package/dist/statistics.js +3 -2
- package/dist/{store-otlp-CR9fWum6.js → store-otlp-CdeW7NWq.js} +2 -2
- package/dist/{store-otlp-CR9fWum6.js.map → store-otlp-CdeW7NWq.js.map} +1 -1
- package/dist/{store-tool-spans-tkdUJWup.js → store-tool-spans-CVX-jfkk.js} +3 -3
- package/dist/{store-tool-spans-tkdUJWup.js.map → store-tool-spans-CVX-jfkk.js.map} +1 -1
- package/dist/{store-tool-spans-C47hUUVM.d.ts → store-tool-spans-Dq8r0PbJ.d.ts} +4 -5
- package/dist/store-tool-spans-Dq8r0PbJ.d.ts.map +1 -0
- package/dist/{summary-report-CI4J6gxU.js → summary-report-DzbnK81K.js} +15 -7
- package/dist/summary-report-DzbnK81K.js.map +1 -0
- package/dist/summary-report-figures-CJHygLgw.d.ts.map +1 -1
- package/dist/supervisor-run/index.d.ts +1 -1
- package/dist/supervisor-run/index.js +1 -1
- package/dist/{systemone-MXhFSYdy.d.ts → systemone-BuSZTI88.d.ts} +8 -7
- package/dist/systemone-BuSZTI88.d.ts.map +1 -0
- package/dist/{systemone-review-C9kbs3zD.d.ts → systemone-review-mlfxWdLz.d.ts} +2 -2
- package/dist/{systemone-review-C9kbs3zD.d.ts.map → systemone-review-mlfxWdLz.d.ts.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/systemone.js +1 -1
- package/dist/{tool-groups-BSd08M7B.d.ts → tool-groups-PNDX8fd-.d.ts} +2 -3
- package/dist/tool-groups-PNDX8fd-.d.ts.map +1 -0
- package/dist/{tool-waste-u7JJ_BlE.js → tool-waste-783VCo1y.js} +3 -2
- package/dist/{tool-waste-u7JJ_BlE.js.map → tool-waste-783VCo1y.js.map} +1 -1
- package/dist/tool-waste-B01AMpID.d.ts +121 -0
- package/dist/tool-waste-B01AMpID.d.ts.map +1 -0
- package/dist/{trace-questions-CJANeK9P.d.ts → trace-questions-DBtr4jWi.d.ts} +2 -3
- package/dist/trace-questions-DBtr4jWi.d.ts.map +1 -0
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/trace-repair/index.js +1 -1
- package/dist/traces.d.ts +4 -5
- package/dist/traces.d.ts.map +1 -1
- package/dist/traces.js +4 -4
- 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-CtlQQL1w.js} +6 -4
- package/dist/{tree-DQMlcNFI.js.map → tree-CtlQQL1w.js.map} +1 -1
- package/dist/{types-DD1eUTLn.d.ts → types-BO948H-U.d.ts} +7 -4
- package/dist/{types-DD1eUTLn.d.ts.map → types-BO948H-U.d.ts.map} +1 -1
- package/dist/{types-AGUuvnae.d.ts → types-CKNAzCSA.d.ts} +158 -3
- package/dist/types-CKNAzCSA.d.ts.map +1 -0
- package/dist/{types-BLv2Ngla.d.ts → types-D-WF1KM3.d.ts} +2 -2
- package/dist/{types-BLv2Ngla.d.ts.map → types-D-WF1KM3.d.ts.map} +1 -1
- package/dist/types-DK4vNv5q.js.map +1 -1
- package/dist/{types-CE9JMZhk.d.ts → types-DbeIGi73.d.ts} +2 -2
- package/dist/{types-CE9JMZhk.d.ts.map → types-DbeIGi73.d.ts.map} +1 -1
- package/dist/types-_tlhWGUq.js.map +1 -1
- package/dist/wire/index.d.ts +4 -4
- 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 +31 -0
- package/docs/eval-surface-map.md +4 -1
- package/docs/feature-guide.md +2 -0
- package/docs/multi-turn-optimization.md +80 -0
- package/docs/outcome-validity.md +69 -0
- package/docs/public-api.md +86 -31
- package/docs/trace-analysis.md +1 -0
- package/docs/world.md +104 -0
- package/package.json +7 -2
- package/dist/analyze-runs-Ke0WbAf6.d.ts.map +0 -1
- package/dist/benchmark-command-MfXRocwZ.js.map +0 -1
- package/dist/campaign-DfSWSreo.js.map +0 -1
- package/dist/cluster-Bj90LK-1.d.ts.map +0 -1
- package/dist/default-registry-CUuorCWZ.d.ts.map +0 -1
- package/dist/default-registry-IkE3byrA.js.map +0 -1
- package/dist/define-agent-eval-B6uE3gNu.js.map +0 -1
- package/dist/define-agent-eval-D17XsdAt.d.ts.map +0 -1
- package/dist/engine-BZVXOc6n.d.ts +0 -152
- package/dist/engine-BZVXOc6n.d.ts.map +0 -1
- package/dist/external-optimizer-subprocess-BW0ZWUUr.js.map +0 -1
- package/dist/findings-store-BxpV-hfH.js.map +0 -1
- package/dist/harness-session-lines-CSxKR6no.js.map +0 -1
- package/dist/index-B_k8aY9k.d.ts.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-CR-guIiZ.d.ts.map +0 -1
- package/dist/index-Ucp54Pcl.d.ts.map +0 -1
- package/dist/interval-CWyxqDpE.d.ts +0 -43
- package/dist/interval-CWyxqDpE.d.ts.map +0 -1
- package/dist/kind-factory-BDd4rhML.js.map +0 -1
- package/dist/llm-judge-DQJTQx01.js.map +0 -1
- package/dist/matrix-DlSrRl_v.d.ts.map +0 -1
- package/dist/outcome-observations-DL3CC8w1.js.map +0 -1
- package/dist/pareto-Bg75Gajo.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-CtLyPb5-.d.ts.map +0 -1
- package/dist/run-record-Bqg0NZ_e.js.map +0 -1
- package/dist/sequential-BphITa5b.js.map +0 -1
- package/dist/statistics-DSidA5I2.js.map +0 -1
- package/dist/store-tool-spans-C47hUUVM.d.ts.map +0 -1
- package/dist/summary-report-CI4J6gxU.js.map +0 -1
- package/dist/systemone-MXhFSYdy.d.ts.map +0 -1
- package/dist/tool-groups-BSd08M7B.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/trace-questions-CJANeK9P.d.ts.map +0 -1
- package/dist/types-AGUuvnae.d.ts.map +0 -1
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
import { s as ValidationError } from "./errors-DeEEV9Vx.js";
|
|
2
|
+
import { t as interpolatedQuantile } from "./quantile-CncXP-Ss.js";
|
|
3
|
+
import { t as mulberry32 } from "./random-DrzcgC7F.js";
|
|
4
|
+
// src/math/special-functions.ts
|
|
5
|
+
/** Lanczos approximation to ln Gamma(z). */
|
|
6
|
+
function lnGamma(z) {
|
|
7
|
+
const g = 7;
|
|
8
|
+
const coefficients = [
|
|
9
|
+
.9999999999998099,
|
|
10
|
+
676.5203681218851,
|
|
11
|
+
-1259.1392167224028,
|
|
12
|
+
771.3234287776531,
|
|
13
|
+
-176.6150291621406,
|
|
14
|
+
12.507343278686905,
|
|
15
|
+
-.13857109526572012,
|
|
16
|
+
9984369578019572e-21,
|
|
17
|
+
1.5056327351493116e-7
|
|
18
|
+
];
|
|
19
|
+
if (z < .5) return Math.log(Math.PI / Math.sin(Math.PI * z)) - lnGamma(1 - z);
|
|
20
|
+
z -= 1;
|
|
21
|
+
let x = coefficients[0];
|
|
22
|
+
for (let i = 1; i < 9; i++) x += coefficients[i] / (z + i);
|
|
23
|
+
const t = z + g + .5;
|
|
24
|
+
return .5 * Math.log(2 * Math.PI) + (z + .5) * Math.log(t) - t + Math.log(x);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Regularized incomplete beta function I_x(a, b).
|
|
28
|
+
*
|
|
29
|
+
* The Lentz continued fraction converges only for `x < (a+1)/(a+b+2)`; outside
|
|
30
|
+
* that domain it must be reached through the symmetry `I_x(a,b) = 1 −
|
|
31
|
+
* I_{1−x}(b,a)`. `studentTCdf` drives `x → 1` as `|t| → 0`, so the mirrored
|
|
32
|
+
* branch is the one every near-null t-statistic takes.
|
|
33
|
+
*/
|
|
34
|
+
function regularizedIncompleteBeta(x, a, b) {
|
|
35
|
+
if (x <= 0) return 0;
|
|
36
|
+
if (x >= 1) return 1;
|
|
37
|
+
const logBeta = lnGamma(a) + lnGamma(b) - lnGamma(a + b);
|
|
38
|
+
const front = Math.exp(Math.log(x) * a + Math.log(1 - x) * b - logBeta);
|
|
39
|
+
if (x < (a + 1) / (a + b + 2)) return front * betaContinuedFraction(x, a, b) / a;
|
|
40
|
+
return 1 - front * betaContinuedFraction(1 - x, b, a) / b;
|
|
41
|
+
}
|
|
42
|
+
/** Modified Lentz evaluation of the beta continued fraction at `x`. */
|
|
43
|
+
function betaContinuedFraction(x, a, b) {
|
|
44
|
+
const maxIterations = 300;
|
|
45
|
+
const epsilon = 3e-15;
|
|
46
|
+
let c = 1;
|
|
47
|
+
let d = 1 - (a + b) * x / (a + 1);
|
|
48
|
+
if (Math.abs(d) < 1e-30) d = 1e-30;
|
|
49
|
+
d = 1 / d;
|
|
50
|
+
let fraction = d;
|
|
51
|
+
for (let m = 1; m <= maxIterations; m++) {
|
|
52
|
+
const m2 = 2 * m;
|
|
53
|
+
let numerator = m * (b - m) * x / ((a + m2 - 1) * (a + m2));
|
|
54
|
+
d = 1 + numerator * d;
|
|
55
|
+
if (Math.abs(d) < 1e-30) d = 1e-30;
|
|
56
|
+
c = 1 + numerator / c;
|
|
57
|
+
if (Math.abs(c) < 1e-30) c = 1e-30;
|
|
58
|
+
d = 1 / d;
|
|
59
|
+
fraction *= d * c;
|
|
60
|
+
numerator = -((a + m) * (a + b + m) * x) / ((a + m2) * (a + m2 + 1));
|
|
61
|
+
d = 1 + numerator * d;
|
|
62
|
+
if (Math.abs(d) < 1e-30) d = 1e-30;
|
|
63
|
+
c = 1 + numerator / c;
|
|
64
|
+
if (Math.abs(c) < 1e-30) c = 1e-30;
|
|
65
|
+
d = 1 / d;
|
|
66
|
+
const delta = d * c;
|
|
67
|
+
fraction *= delta;
|
|
68
|
+
if (Math.abs(delta - 1) < epsilon) break;
|
|
69
|
+
}
|
|
70
|
+
return fraction;
|
|
71
|
+
}
|
|
72
|
+
// src/math/student-t.ts
|
|
73
|
+
/**
|
|
74
|
+
* Student-t CDF via the regularized incomplete beta function.
|
|
75
|
+
*/
|
|
76
|
+
function studentTCdf(t, degreesOfFreedom) {
|
|
77
|
+
if (degreesOfFreedom <= 0) return .5;
|
|
78
|
+
const beta = regularizedIncompleteBeta(degreesOfFreedom / (degreesOfFreedom + t * t), degreesOfFreedom / 2, .5);
|
|
79
|
+
return t >= 0 ? 1 - .5 * beta : .5 * beta;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Inverse Student-t CDF, solved against {@link studentTCdf}.
|
|
83
|
+
*
|
|
84
|
+
* The CDF is monotone, so bracket expansion followed by bisection is stable
|
|
85
|
+
* across fractional degrees of freedom and does not need a separate
|
|
86
|
+
* approximation with a different error profile.
|
|
87
|
+
*/
|
|
88
|
+
function studentTQuantile(probability, degreesOfFreedom) {
|
|
89
|
+
if (!Number.isFinite(probability) || probability < 0 || probability > 1) throw new RangeError(`studentTQuantile: probability must be in [0,1], got ${probability}`);
|
|
90
|
+
if (!Number.isFinite(degreesOfFreedom) || degreesOfFreedom <= 0) throw new RangeError(`studentTQuantile: degreesOfFreedom must be positive and finite, got ${degreesOfFreedom}`);
|
|
91
|
+
if (probability === 0) return Number.NEGATIVE_INFINITY;
|
|
92
|
+
if (probability === 1) return Number.POSITIVE_INFINITY;
|
|
93
|
+
if (probability === .5) return 0;
|
|
94
|
+
if (probability < .5) return -studentTQuantile(1 - probability, degreesOfFreedom);
|
|
95
|
+
let low = 0;
|
|
96
|
+
let high = 1;
|
|
97
|
+
while (studentTCdf(high, degreesOfFreedom) < probability) high *= 2;
|
|
98
|
+
for (let iteration = 0; iteration < 64; iteration++) {
|
|
99
|
+
const middle = (low + high) / 2;
|
|
100
|
+
if (studentTCdf(middle, degreesOfFreedom) < probability) low = middle;
|
|
101
|
+
else high = middle;
|
|
102
|
+
}
|
|
103
|
+
return (low + high) / 2;
|
|
104
|
+
}
|
|
105
|
+
// src/statistics/internal.ts
|
|
106
|
+
/**
|
|
107
|
+
* Shared internals for the statistics modules. Nothing here is part of the
|
|
108
|
+
* public statistics surface — `./index` does not re-export this module.
|
|
109
|
+
*/
|
|
110
|
+
/** Every rank test refuses non-finite input. Beyond the arithmetic being
|
|
111
|
+
* undefined, the tie-grouping scan compares values with `===`, and
|
|
112
|
+
* `NaN === NaN` is false, so a NaN would leave the group boundary unable to
|
|
113
|
+
* advance and spin the loop forever. */
|
|
114
|
+
function assertFiniteSample(fn, label, xs) {
|
|
115
|
+
for (let i = 0; i < xs.length; i++) if (!Number.isFinite(xs[i])) throw new ValidationError(`${fn}: ${label}[${i}] must be finite, got ${xs[i]}`);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Two-sided exact p-value for b successes out of (b + c) Bernoulli(0.5) trials —
|
|
119
|
+
* the exact-binomial core of {@link mcnemar}. `min(1, 2·P(X ≤ min(b,c)))`. No
|
|
120
|
+
* discordant pairs ⇒ no evidence ⇒ p = 1. Summed in log space (lnGamma) so it
|
|
121
|
+
* stays exact at large discordant counts without overflow.
|
|
122
|
+
*/
|
|
123
|
+
function binomialSignTwoSided(b, c) {
|
|
124
|
+
const nd = b + c;
|
|
125
|
+
if (nd === 0) return 1;
|
|
126
|
+
return Math.min(1, 2 * binomialHalfLowerTail(Math.min(b, c), nd));
|
|
127
|
+
}
|
|
128
|
+
/** P(X >= successes) for X ~ Binomial(n, 0.5). */
|
|
129
|
+
function binomialHalfUpperTail(successes, n) {
|
|
130
|
+
if (successes <= 0) return 1;
|
|
131
|
+
if (successes > n) return 0;
|
|
132
|
+
if (successes <= n / 2) return Math.max(0, 1 - binomialHalfLowerTail(successes - 1, n));
|
|
133
|
+
return binomialHalfLowerTail(n - successes, n);
|
|
134
|
+
}
|
|
135
|
+
/** P(X <= maxSuccesses) for X ~ Binomial(n, 0.5), accumulated in log space. */
|
|
136
|
+
function binomialHalfLowerTail(maxSuccesses, n) {
|
|
137
|
+
if (maxSuccesses < 0) return 0;
|
|
138
|
+
if (maxSuccesses >= n) return 1;
|
|
139
|
+
if (maxSuccesses === 0) return 2 ** -n;
|
|
140
|
+
const logHalfN = n * Math.log(.5);
|
|
141
|
+
let logTail = Number.NEGATIVE_INFINITY;
|
|
142
|
+
for (let i = 0; i <= maxSuccesses; i++) {
|
|
143
|
+
const logChoose = lnGamma(n + 1) - lnGamma(i + 1) - lnGamma(n - i + 1);
|
|
144
|
+
logTail = logAddExp(logTail, logChoose + logHalfN);
|
|
145
|
+
}
|
|
146
|
+
return Math.min(1, Math.exp(logTail));
|
|
147
|
+
}
|
|
148
|
+
function logAddExp(a, b) {
|
|
149
|
+
if (a === Number.NEGATIVE_INFINITY) return b;
|
|
150
|
+
if (b === Number.NEGATIVE_INFINITY) return a;
|
|
151
|
+
const max = Math.max(a, b);
|
|
152
|
+
return max + Math.log1p(Math.exp(Math.min(a, b) - max));
|
|
153
|
+
}
|
|
154
|
+
/** Standard-normal inverse CDF (Acklam approximation). */
|
|
155
|
+
function zQuantile(p) {
|
|
156
|
+
if (p <= 0 || p >= 1) {
|
|
157
|
+
if (p === 0) return -Infinity;
|
|
158
|
+
if (p === 1) return Infinity;
|
|
159
|
+
return NaN;
|
|
160
|
+
}
|
|
161
|
+
const a = [
|
|
162
|
+
-39.69683028665376,
|
|
163
|
+
220.9460984245205,
|
|
164
|
+
-275.9285104469687,
|
|
165
|
+
138.357751867269,
|
|
166
|
+
-30.66479806614716,
|
|
167
|
+
2.506628277459239
|
|
168
|
+
];
|
|
169
|
+
const b = [
|
|
170
|
+
-54.47609879822406,
|
|
171
|
+
161.5858368580409,
|
|
172
|
+
-155.6989798598866,
|
|
173
|
+
66.80131188771972,
|
|
174
|
+
-13.28068155288572
|
|
175
|
+
];
|
|
176
|
+
const c = [
|
|
177
|
+
-.007784894002430293,
|
|
178
|
+
-.3223964580411365,
|
|
179
|
+
-2.400758277161838,
|
|
180
|
+
-2.549732539343734,
|
|
181
|
+
4.374664141464968,
|
|
182
|
+
2.938163982698783
|
|
183
|
+
];
|
|
184
|
+
const d = [
|
|
185
|
+
.007784695709041462,
|
|
186
|
+
.3224671290700398,
|
|
187
|
+
2.445134137142996,
|
|
188
|
+
3.754408661907416
|
|
189
|
+
];
|
|
190
|
+
const pLow = .02425;
|
|
191
|
+
const pHigh = .97575;
|
|
192
|
+
let q;
|
|
193
|
+
let r;
|
|
194
|
+
if (p < pLow) {
|
|
195
|
+
q = Math.sqrt(-2 * Math.log(p));
|
|
196
|
+
return (((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q + c[4]) * q + c[5]) / ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);
|
|
197
|
+
}
|
|
198
|
+
if (p <= pHigh) {
|
|
199
|
+
q = p - .5;
|
|
200
|
+
r = q * q;
|
|
201
|
+
return (((((a[0] * r + a[1]) * r + a[2]) * r + a[3]) * r + a[4]) * r + a[5]) * q / (((((b[0] * r + b[1]) * r + b[2]) * r + b[3]) * r + b[4]) * r + 1);
|
|
202
|
+
}
|
|
203
|
+
q = Math.sqrt(-2 * Math.log(1 - p));
|
|
204
|
+
return -(((((c[0] * q + c[1]) * q + c[2]) * q + c[3]) * q + c[4]) * q + c[5]) / ((((d[0] * q + d[1]) * q + d[2]) * q + d[3]) * q + 1);
|
|
205
|
+
}
|
|
206
|
+
function medianInPlace(xs) {
|
|
207
|
+
if (xs.length === 0) return 0;
|
|
208
|
+
xs.sort((a, b) => a - b);
|
|
209
|
+
return interpolatedQuantile(xs, .5);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* PRNG for every resampling path in this module.
|
|
213
|
+
*
|
|
214
|
+
* With no caller seed the seed is DERIVED FROM THE DATA rather than taken from
|
|
215
|
+
* `Math.random`, so re-running the same input reproduces the same interval —
|
|
216
|
+
* a gate verdict that cannot be re-derived is not evidence. Distinct data
|
|
217
|
+
* still gets a distinct stream. Same pattern as `promotion-gate.ts`.
|
|
218
|
+
*/
|
|
219
|
+
function makeRng(seed, ...series) {
|
|
220
|
+
return mulberry32(seed ?? seedFromData(series));
|
|
221
|
+
}
|
|
222
|
+
/** FNV-1a over the IEEE-754 bytes of every observation. */
|
|
223
|
+
function seedFromData(series) {
|
|
224
|
+
const view = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
225
|
+
let hash = 2166136261;
|
|
226
|
+
for (const xs of series) {
|
|
227
|
+
for (const x of xs) {
|
|
228
|
+
view.setFloat64(0, x);
|
|
229
|
+
for (let byte = 0; byte < 8; byte++) hash = Math.imul(hash ^ view.getUint8(byte), 16777619);
|
|
230
|
+
}
|
|
231
|
+
hash = Math.imul(hash ^ 255, 16777619);
|
|
232
|
+
}
|
|
233
|
+
return hash | 0;
|
|
234
|
+
}
|
|
235
|
+
/** Order-independent seed for a symmetric two-sample statistic. */
|
|
236
|
+
function symmetricTwoSampleSeed(a, b) {
|
|
237
|
+
const sortedA = [...a].sort((left, right) => left - right);
|
|
238
|
+
const sortedB = [...b].sort((left, right) => left - right);
|
|
239
|
+
const forward = seedFromData([sortedA, sortedB]) >>> 0;
|
|
240
|
+
const reversed = seedFromData([sortedB, sortedA]) >>> 0;
|
|
241
|
+
return Math.min(forward, reversed);
|
|
242
|
+
}
|
|
243
|
+
// src/statistics/mean.ts
|
|
244
|
+
/** Arithmetic mean. An empty input has no mean and returns NaN. */
|
|
245
|
+
function mean(values) {
|
|
246
|
+
return values.reduce((sum, value) => sum + value, 0) / values.length;
|
|
247
|
+
}
|
|
248
|
+
/** Arithmetic mean, or null for an empty input. */
|
|
249
|
+
function meanOrNull(values) {
|
|
250
|
+
return values.length === 0 ? null : mean(values);
|
|
251
|
+
}
|
|
252
|
+
/** Arithmetic mean, or 0 for an empty input. */
|
|
253
|
+
function meanOrZero(values) {
|
|
254
|
+
return values.length === 0 ? 0 : mean(values);
|
|
255
|
+
}
|
|
256
|
+
// src/statistics/descriptive.ts
|
|
257
|
+
/**
|
|
258
|
+
* Descriptive statistics: means, bootstrap spread, correlation, and the
|
|
259
|
+
* weighted judge-dimension composite. Nothing here is a significance test.
|
|
260
|
+
*/
|
|
261
|
+
/** Weighted mean — falls back to uniform weights when omitted */
|
|
262
|
+
function weightedMean(scores) {
|
|
263
|
+
if (scores.length === 0) return 0;
|
|
264
|
+
let totalWeight = 0;
|
|
265
|
+
let weightedSum = 0;
|
|
266
|
+
for (const { score, weight } of scores) {
|
|
267
|
+
const w = weight ?? 1;
|
|
268
|
+
weightedSum += score * w;
|
|
269
|
+
totalWeight += w;
|
|
270
|
+
}
|
|
271
|
+
return totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Percentile bootstrap confidence interval on the mean of `scores`.
|
|
275
|
+
*
|
|
276
|
+
* Descriptive spread. It is not a significance test, and at small n its bounds
|
|
277
|
+
* are anti-conservative in the same way {@link pairedBootstrap}'s are — see
|
|
278
|
+
* {@link BOOTSTRAP_GATE_MIN_N}. With no `seed` the resampling is seeded from
|
|
279
|
+
* the scores themselves, so the interval is reproducible either way.
|
|
280
|
+
*/
|
|
281
|
+
function confidenceInterval(scores, confidence = .95, opts = {}) {
|
|
282
|
+
if (scores.length === 0) return {
|
|
283
|
+
mean: 0,
|
|
284
|
+
lower: 0,
|
|
285
|
+
upper: 0
|
|
286
|
+
};
|
|
287
|
+
if (scores.length === 1) return {
|
|
288
|
+
mean: scores[0],
|
|
289
|
+
lower: scores[0],
|
|
290
|
+
upper: scores[0]
|
|
291
|
+
};
|
|
292
|
+
const n = scores.length;
|
|
293
|
+
const mean = scores.reduce((a, b) => a + b, 0) / n;
|
|
294
|
+
const B = opts.resamples ?? 1e3;
|
|
295
|
+
const rng = makeRng(opts.seed, scores);
|
|
296
|
+
const bootstrapMeans = [];
|
|
297
|
+
for (let i = 0; i < B; i++) {
|
|
298
|
+
let sum = 0;
|
|
299
|
+
for (let j = 0; j < n; j++) sum += scores[Math.floor(rng() * n)];
|
|
300
|
+
bootstrapMeans.push(sum / n);
|
|
301
|
+
}
|
|
302
|
+
bootstrapMeans.sort((a, b) => a - b);
|
|
303
|
+
const alpha = 1 - confidence;
|
|
304
|
+
const lowerIdx = Math.floor(alpha / 2 * B);
|
|
305
|
+
const upperIdx = Math.floor((1 - alpha / 2) * B) - 1;
|
|
306
|
+
return {
|
|
307
|
+
mean,
|
|
308
|
+
lower: bootstrapMeans[lowerIdx],
|
|
309
|
+
upper: bootstrapMeans[Math.min(upperIdx, B - 1)]
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Two-sided Student-t critical value: the `t` with `P(|T| ≤ t) = confidence`
|
|
314
|
+
* for `df` degrees of freedom. Exact, from {@link studentTQuantile}, so any
|
|
315
|
+
* confidence in (0, 1) and fractional `df` are supported.
|
|
316
|
+
*/
|
|
317
|
+
function studentTCritical(df, confidence = .95) {
|
|
318
|
+
if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) throw new ValidationError(`studentTCritical: confidence must be in (0, 1), got ${confidence}`);
|
|
319
|
+
if (!Number.isFinite(df) || df <= 0) throw new ValidationError(`studentTCritical: df must be positive and finite, got ${df}`);
|
|
320
|
+
return studentTQuantile(1 - (1 - confidence) / 2, df);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Student-t confidence interval on the mean of one sample:
|
|
324
|
+
* `mean ± t(df = n − 1) · s / √n`. Below two samples there is no spread to
|
|
325
|
+
* estimate, so the bounds are null rather than a zero-width interval that
|
|
326
|
+
* would read as certainty. Unlike {@link confidenceInterval} (a percentile
|
|
327
|
+
* bootstrap), the width keeps the small-n t penalty that z = 1.96 drops.
|
|
328
|
+
*/
|
|
329
|
+
function meanConfidenceInterval(samples, confidence = .95) {
|
|
330
|
+
assertFiniteSample("meanConfidenceInterval", "samples", samples);
|
|
331
|
+
const n = samples.length;
|
|
332
|
+
if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) throw new ValidationError(`meanConfidenceInterval: confidence must be in (0, 1), got ${confidence}`);
|
|
333
|
+
if (n < 2) return {
|
|
334
|
+
n,
|
|
335
|
+
mean: n === 0 ? null : samples[0],
|
|
336
|
+
stdev: null,
|
|
337
|
+
low: null,
|
|
338
|
+
high: null,
|
|
339
|
+
criticalValue: null
|
|
340
|
+
};
|
|
341
|
+
const center = mean(samples);
|
|
342
|
+
const sumSquares = samples.reduce((sum, value) => sum + (value - center) ** 2, 0);
|
|
343
|
+
const stdev = Math.sqrt(sumSquares / (n - 1));
|
|
344
|
+
const criticalValue = studentTCritical(n - 1, confidence);
|
|
345
|
+
const halfWidth = criticalValue * stdev / Math.sqrt(n);
|
|
346
|
+
return {
|
|
347
|
+
n,
|
|
348
|
+
mean: center,
|
|
349
|
+
stdev,
|
|
350
|
+
low: center - halfWidth,
|
|
351
|
+
high: center + halfWidth,
|
|
352
|
+
criticalValue
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/** Partial credit: returns 0-1 ratio of current toward target */
|
|
356
|
+
function partialCredit(current, target) {
|
|
357
|
+
if (target <= 0) return 1;
|
|
358
|
+
return Math.min(1, Math.max(0, current / target));
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Fold a number series into its distribution summary. Quantiles use the
|
|
362
|
+
* nearest-rank definition — the `ceil(q·n)`-th order statistic — so every
|
|
363
|
+
* reported quantile is a value from the series. Returns `null` for an empty
|
|
364
|
+
* series: an empty series has no distribution, and a zero-filled summary
|
|
365
|
+
* would read as a measured all-zero series.
|
|
366
|
+
*/
|
|
367
|
+
function summarizeNumberSeries(values, options) {
|
|
368
|
+
const criticalValue = options?.medianInterval?.criticalValue;
|
|
369
|
+
if (options) {
|
|
370
|
+
assertFiniteSample("summarizeNumberSeries", "values", values);
|
|
371
|
+
for (const percentile of options.percentiles ?? []) if (!Number.isFinite(percentile) || percentile < 0 || percentile > 100) throw new ValidationError("summarizeNumberSeries: percentiles must be finite and between 0 and 100");
|
|
372
|
+
if (options.medianInterval && (criticalValue === void 0 || !Number.isFinite(criticalValue) || criticalValue < 0)) throw new ValidationError("summarizeNumberSeries: median criticalValue must be finite and nonnegative");
|
|
373
|
+
}
|
|
374
|
+
if (values.length === 0) return null;
|
|
375
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
376
|
+
const n = sorted.length;
|
|
377
|
+
const rank = (q) => sorted[Math.min(n - 1, Math.max(0, Math.ceil(q * n) - 1))];
|
|
378
|
+
const sum = sorted.reduce((a, b) => a + b, 0);
|
|
379
|
+
if (options && !Number.isFinite(sum)) throw new ValidationError("summarizeNumberSeries: sample sum exceeded finite range");
|
|
380
|
+
const spread = criticalValue === void 0 ? void 0 : criticalValue / 2 * Math.sqrt(n);
|
|
381
|
+
const lowRank = spread === void 0 ? 1 : Math.max(1, Math.floor(n / 2 - spread));
|
|
382
|
+
const highRank = spread === void 0 ? n : Math.min(n, Math.ceil(n / 2 + 1 + spread));
|
|
383
|
+
return {
|
|
384
|
+
n,
|
|
385
|
+
min: sorted[0],
|
|
386
|
+
p50: rank(.5),
|
|
387
|
+
p90: rank(.9),
|
|
388
|
+
max: sorted[sorted.length - 1],
|
|
389
|
+
sum,
|
|
390
|
+
...options?.percentiles === void 0 ? {} : { percentiles: Object.fromEntries(options.percentiles.map((percentile) => [percentile, rank(percentile / 100)])) },
|
|
391
|
+
...criticalValue === void 0 ? {} : { medianInterval: {
|
|
392
|
+
method: "normal-order-statistics",
|
|
393
|
+
criticalValue,
|
|
394
|
+
sampleSize: n,
|
|
395
|
+
lowRank,
|
|
396
|
+
highRank,
|
|
397
|
+
low: sorted[lowRank - 1],
|
|
398
|
+
high: sorted[highRank - 1]
|
|
399
|
+
} }
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Average-rank-with-ties transform (1-indexed). Tied values receive the mean
|
|
404
|
+
* of the ranks they span, the standard correction for Spearman's ρ.
|
|
405
|
+
*/
|
|
406
|
+
function ranks(xs) {
|
|
407
|
+
const indexed = xs.map((v, i) => ({
|
|
408
|
+
v,
|
|
409
|
+
i
|
|
410
|
+
})).sort((a, b) => a.v - b.v);
|
|
411
|
+
const r = new Array(xs.length);
|
|
412
|
+
let i = 0;
|
|
413
|
+
while (i < indexed.length) {
|
|
414
|
+
let j = i;
|
|
415
|
+
while (j + 1 < indexed.length && indexed[j + 1].v === indexed[i].v) j++;
|
|
416
|
+
const avg = (i + j) / 2 + 1;
|
|
417
|
+
for (let k = i; k <= j; k++) r[indexed[k].i] = avg;
|
|
418
|
+
i = j + 1;
|
|
419
|
+
}
|
|
420
|
+
return r;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Pearson product-moment correlation coefficient r ∈ [-1, 1] between two
|
|
424
|
+
* equal-length series. See the edge-case contract above: NaN for n < 2 or
|
|
425
|
+
* unequal lengths, 1 when both series are constant, 0 when exactly one is.
|
|
426
|
+
*/
|
|
427
|
+
function pearsonR(a, b) {
|
|
428
|
+
if (a.length !== b.length || a.length < 2) return NaN;
|
|
429
|
+
const n = a.length;
|
|
430
|
+
const meanA = a.reduce((s, v) => s + v, 0) / n;
|
|
431
|
+
const meanB = b.reduce((s, v) => s + v, 0) / n;
|
|
432
|
+
let num = 0;
|
|
433
|
+
let varA = 0;
|
|
434
|
+
let varB = 0;
|
|
435
|
+
for (let i = 0; i < n; i++) {
|
|
436
|
+
const da = a[i] - meanA;
|
|
437
|
+
const db = b[i] - meanB;
|
|
438
|
+
num += da * db;
|
|
439
|
+
varA += da * da;
|
|
440
|
+
varB += db * db;
|
|
441
|
+
}
|
|
442
|
+
if (varA === 0 || varB === 0) return varA === 0 && varB === 0 ? 1 : 0;
|
|
443
|
+
return num / Math.sqrt(varA * varB);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Spearman's rank correlation ρ — Pearson over the average-rank-with-ties
|
|
447
|
+
* transform of each series. Same edge-case contract as {@link pearsonR}.
|
|
448
|
+
*/
|
|
449
|
+
function spearmanR(a, b) {
|
|
450
|
+
if (a.length !== b.length || a.length < 2) return NaN;
|
|
451
|
+
return pearsonR(ranks(a), ranks(b));
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Weighted composite over judge dimensions: `Σ(score_d · w_d) / Σ(w_d)` across
|
|
455
|
+
* the weighted dimensions. The canonical replacement for the per-consumer
|
|
456
|
+
* hand-rolled composite math (tax/legal/creative/gtm each ship a copy).
|
|
457
|
+
*
|
|
458
|
+
* Fail-loud: throws if a weighted dimension is missing from `dims`, if any
|
|
459
|
+
* weight is negative, or if the weights sum to 0 — none of which can produce
|
|
460
|
+
* a meaningful composite.
|
|
461
|
+
*/
|
|
462
|
+
function weightedComposite(input) {
|
|
463
|
+
const entries = Object.entries(input.weights);
|
|
464
|
+
if (entries.length === 0) throw new Error("weightedComposite: `weights` is empty — nothing to combine");
|
|
465
|
+
let weightedSum = 0;
|
|
466
|
+
let weightTotal = 0;
|
|
467
|
+
for (const [dim, weight] of entries) {
|
|
468
|
+
if (weight < 0) throw new Error(`weightedComposite: weight for '${dim}' is negative (${weight})`);
|
|
469
|
+
if (!(dim in input.dims)) throw new Error(`weightedComposite: weighted dimension '${dim}' is absent from \`dims\` — refusing to renormalise onto a different denominator`);
|
|
470
|
+
weightedSum += input.dims[dim] * weight;
|
|
471
|
+
weightTotal += weight;
|
|
472
|
+
}
|
|
473
|
+
if (weightTotal === 0) throw new Error("weightedComposite: weights sum to 0 — composite is undefined");
|
|
474
|
+
const composite = weightedSum / weightTotal;
|
|
475
|
+
return input.threshold === void 0 ? { composite } : {
|
|
476
|
+
composite,
|
|
477
|
+
pass: composite >= input.threshold
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
// src/statistics/paired-tests.ts
|
|
481
|
+
/**
|
|
482
|
+
* Paired significance tests on continuous scores: the paired t-test, the
|
|
483
|
+
* promotion-gate paired bootstrap, the exact sign test, and the package-wide
|
|
484
|
+
* paired-delta decision statistic.
|
|
485
|
+
*/
|
|
486
|
+
/**
|
|
487
|
+
* Paired t-test — before/after measurements on the SAME items.
|
|
488
|
+
* Pairing removes inter-item variance, giving tighter significance than
|
|
489
|
+
* an unpaired test when comparing prompt v1 vs prompt v2 on identical
|
|
490
|
+
* scenarios.
|
|
491
|
+
*
|
|
492
|
+
* Returns `t = p = null` where the statistic is undefined: fewer than two
|
|
493
|
+
* pairs, or a non-zero constant delta whose observed variance is zero. A
|
|
494
|
+
* constant shift carries no information about the variance it would have to
|
|
495
|
+
* be compared against, so the honest answer is "undefined", not `p = 0` —
|
|
496
|
+
* three observations cannot buy absolute certainty. This is the same contract
|
|
497
|
+
* {@link pairedCohensDz} states for the same condition. An all-zero delta is
|
|
498
|
+
* different: it is a measured null, and returns `t = 0, p = 1`.
|
|
499
|
+
*/
|
|
500
|
+
function pairedTTest(before, after) {
|
|
501
|
+
if (before.length !== after.length) throw new ValidationError(`pairedTTest: unequal sample sizes (${before.length} vs ${after.length})`);
|
|
502
|
+
assertFiniteSample("pairedTTest", "before", before);
|
|
503
|
+
assertFiniteSample("pairedTTest", "after", after);
|
|
504
|
+
const n = before.length;
|
|
505
|
+
if (n < 2) return {
|
|
506
|
+
t: null,
|
|
507
|
+
df: 0,
|
|
508
|
+
p: null
|
|
509
|
+
};
|
|
510
|
+
const diffs = before.map((b, i) => after[i] - b);
|
|
511
|
+
const mean = diffs.reduce((a, b) => a + b, 0) / n;
|
|
512
|
+
const variance = diffs.reduce((acc, d) => acc + (d - mean) ** 2, 0) / (n - 1);
|
|
513
|
+
const se = Math.sqrt(variance / n);
|
|
514
|
+
if (se === 0) return mean === 0 ? {
|
|
515
|
+
t: 0,
|
|
516
|
+
df: n - 1,
|
|
517
|
+
p: 1
|
|
518
|
+
} : {
|
|
519
|
+
t: null,
|
|
520
|
+
df: n - 1,
|
|
521
|
+
p: null
|
|
522
|
+
};
|
|
523
|
+
const t = mean / se;
|
|
524
|
+
const df = n - 1;
|
|
525
|
+
return {
|
|
526
|
+
t,
|
|
527
|
+
df,
|
|
528
|
+
p: 2 * (1 - studentTCdf(Math.abs(t), df))
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Pairs below which a percentile bootstrap interval is descriptive spread only.
|
|
533
|
+
*
|
|
534
|
+
* `P(low > 0)` under a true null, against a nominal 2.5 %, measured over 4000
|
|
535
|
+
* seeded trials: 13.53 % at n = 3, 3.52 % at n = 10, 3.10 % at n = 20 on the
|
|
536
|
+
* median; 13.85 %, 4.90 %, 3.80 % on the mean. This is intrinsic to resampling
|
|
537
|
+
* three points, not an implementation error — scipy's BCa gives 16.0 % on the
|
|
538
|
+
* same n = 3 data — so no change to the estimator moves it. Below this floor
|
|
539
|
+
* the decision belongs to the exact sign test or exact signed-rank test.
|
|
540
|
+
*/
|
|
541
|
+
const BOOTSTRAP_GATE_MIN_N = 20;
|
|
542
|
+
/**
|
|
543
|
+
* Paired bootstrap on (after − before) deltas. Returns a CI on the chosen
|
|
544
|
+
* statistic (median by default); pairs are resampled with replacement. Throws
|
|
545
|
+
* on unequal sample sizes.
|
|
546
|
+
*
|
|
547
|
+
* `low > threshold` carries the stated confidence ONLY at `n ≥
|
|
548
|
+
* {@link BOOTSTRAP_GATE_MIN_N}`, which `gateEligible` reports. Below it the
|
|
549
|
+
* check fires under a true null several times more often than nominal, so the
|
|
550
|
+
* interval is descriptive spread and a promotion must not turn on it.
|
|
551
|
+
*/
|
|
552
|
+
function pairedBootstrap(before, after, opts = {}) {
|
|
553
|
+
if (before.length !== after.length) throw new Error(`pairedBootstrap: unequal sample sizes (${before.length} vs ${after.length})`);
|
|
554
|
+
const confidence = opts.confidence ?? .95;
|
|
555
|
+
const resamples = opts.resamples ?? 2e3;
|
|
556
|
+
const statistic = opts.statistic ?? "median";
|
|
557
|
+
if (confidence <= 0 || confidence >= 1) throw new Error(`pairedBootstrap: confidence must be in (0,1), got ${confidence}`);
|
|
558
|
+
const n = before.length;
|
|
559
|
+
const deltas = before.map((b, i) => after[i] - b);
|
|
560
|
+
const gateEligible = n >= 20;
|
|
561
|
+
if (n === 0) return {
|
|
562
|
+
n: 0,
|
|
563
|
+
median: 0,
|
|
564
|
+
mean: 0,
|
|
565
|
+
low: 0,
|
|
566
|
+
high: 0,
|
|
567
|
+
confidence,
|
|
568
|
+
resamples,
|
|
569
|
+
gateEligible
|
|
570
|
+
};
|
|
571
|
+
if (n === 1) {
|
|
572
|
+
const d = deltas[0];
|
|
573
|
+
return {
|
|
574
|
+
n: 1,
|
|
575
|
+
median: d,
|
|
576
|
+
mean: d,
|
|
577
|
+
low: d,
|
|
578
|
+
high: d,
|
|
579
|
+
confidence,
|
|
580
|
+
resamples,
|
|
581
|
+
gateEligible
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
const rng = makeRng(opts.seed, deltas);
|
|
585
|
+
const samples = new Array(resamples);
|
|
586
|
+
for (let b = 0; b < resamples; b++) if (statistic === "mean") {
|
|
587
|
+
let sum = 0;
|
|
588
|
+
for (let k = 0; k < n; k++) sum += deltas[Math.floor(rng() * n)];
|
|
589
|
+
samples[b] = sum / n;
|
|
590
|
+
} else {
|
|
591
|
+
const acc = new Array(n);
|
|
592
|
+
for (let k = 0; k < n; k++) acc[k] = deltas[Math.floor(rng() * n)];
|
|
593
|
+
samples[b] = medianInPlace(acc);
|
|
594
|
+
}
|
|
595
|
+
samples.sort((a, b) => a - b);
|
|
596
|
+
const alpha = 1 - confidence;
|
|
597
|
+
const lowIdx = Math.floor(alpha / 2 * resamples);
|
|
598
|
+
const highIdx = Math.min(resamples - 1, Math.ceil((1 - alpha / 2) * resamples) - 1);
|
|
599
|
+
return {
|
|
600
|
+
n,
|
|
601
|
+
median: medianInPlace([...deltas]),
|
|
602
|
+
mean: deltas.reduce((s, x) => s + x, 0) / n,
|
|
603
|
+
low: samples[lowIdx],
|
|
604
|
+
high: samples[Math.max(highIdx, lowIdx)],
|
|
605
|
+
confidence,
|
|
606
|
+
resamples,
|
|
607
|
+
gateEligible
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Exact one-sided sign test over paired differences.
|
|
612
|
+
*
|
|
613
|
+
* Pass `after[i] - before[i]` for each matched item. `alternative = 'greater'`
|
|
614
|
+
* tests whether positive signs are more likely than negative signs and returns
|
|
615
|
+
* `P(Binomial(nNonTies, 0.5) >= positive)`. `alternative = 'less'` treats
|
|
616
|
+
* negative signs as successes instead. With a continuous difference
|
|
617
|
+
* distribution this is the usual directional median test. Exact zero
|
|
618
|
+
* differences are ties and do not enter the binomial denominator. All-tie and
|
|
619
|
+
* empty inputs return p = 1. Every input difference must be finite, and the
|
|
620
|
+
* direction must be chosen explicitly so a caller cannot select it after
|
|
621
|
+
* seeing the signs.
|
|
622
|
+
*/
|
|
623
|
+
function pairedSignTest(differences, alternative) {
|
|
624
|
+
if (alternative !== "greater" && alternative !== "less") throw new ValidationError(`pairedSignTest: alternative must be 'greater' or 'less', got ${alternative}`);
|
|
625
|
+
let positive = 0;
|
|
626
|
+
let negative = 0;
|
|
627
|
+
let ties = 0;
|
|
628
|
+
for (let i = 0; i < differences.length; i++) {
|
|
629
|
+
const difference = differences[i];
|
|
630
|
+
if (!Number.isFinite(difference)) throw new ValidationError(`pairedSignTest: difference at index ${i} must be finite, got ${difference}`);
|
|
631
|
+
if (difference > 0) positive++;
|
|
632
|
+
else if (difference < 0) negative++;
|
|
633
|
+
else ties++;
|
|
634
|
+
}
|
|
635
|
+
const nNonTies = positive + negative;
|
|
636
|
+
const successes = alternative === "greater" ? positive : negative;
|
|
637
|
+
return {
|
|
638
|
+
n: differences.length,
|
|
639
|
+
positive,
|
|
640
|
+
negative,
|
|
641
|
+
ties,
|
|
642
|
+
nNonTies,
|
|
643
|
+
alternative,
|
|
644
|
+
pValue: binomialHalfUpperTail(successes, nNonTies)
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
/** Fraction of paired observations whose delta is an exact tie (|after − before|
|
|
648
|
+
* < 1e-9). Throws on unequal sample sizes; 0 pairs ⇒ 0. */
|
|
649
|
+
function pairedDeltaTieFraction(before, after) {
|
|
650
|
+
if (before.length !== after.length) throw new Error(`pairedDeltaTieFraction: unequal sample sizes (${before.length} vs ${after.length})`);
|
|
651
|
+
const n = before.length;
|
|
652
|
+
if (n === 0) return 0;
|
|
653
|
+
let ties = 0;
|
|
654
|
+
for (let i = 0; i < n; i++) if (Math.abs(after[i] - before[i]) < 1e-9) ties++;
|
|
655
|
+
return ties / n;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* The paired-delta statistic a DECISION is computed on, package-wide.
|
|
659
|
+
*
|
|
660
|
+
* The mean paired delta is the estimator that answers the question a promotion
|
|
661
|
+
* gate asks — "by how much did the candidate move the score" — in the caller's
|
|
662
|
+
* own units, and it equals the aggregate lift everyone quotes. The MEDIAN
|
|
663
|
+
* answers a different question and loses the answer to this one in every regime
|
|
664
|
+
* eval data actually lands in:
|
|
665
|
+
* - TWO-POINT (pass/fail) outcomes on any encoding: the delta vector lives in
|
|
666
|
+
* {−s, 0, +s} dominated by zeros, so the median and its whole bootstrap CI
|
|
667
|
+
* are pinned at exactly 0 however large the shift. (Decide these on
|
|
668
|
+
* {@link pairedRiskDifferenceExact} instead — same estimand, exact interval.)
|
|
669
|
+
* - TIE-DOMINATED outcomes: at half the pairs tied the sample median is 0 by
|
|
670
|
+
* construction, and `ci.low > threshold` then answers "no" forever at a
|
|
671
|
+
* non-negative threshold and "yes" forever at a negative one.
|
|
672
|
+
* - LOW-CARDINALITY outcomes, even well below half ties: judge dimensions on
|
|
673
|
+
* integer 0-100, and block scores like {⅔, 1} from averaging pass/fail
|
|
674
|
+
* leaves, put the median on a coarse lattice whose bootstrap percentiles
|
|
675
|
+
* land on atoms. Measured: 26 blocks of 3 pass/fail leaves carrying a real
|
|
676
|
+
* +12.8pp lift, only 23% of pairs tied, gives a median CI of [0, 0.333] —
|
|
677
|
+
* lower bound exactly 0, so a gate at threshold 0 refuses a real lift.
|
|
678
|
+
* That last case is why there is no tie-fraction threshold here: any cutoff on
|
|
679
|
+
* ties leaves the lattice case open on the other side of it.
|
|
680
|
+
*
|
|
681
|
+
* `heldoutSignificance` has defaulted to the mean since #316 for the same
|
|
682
|
+
* reason. The median remains available per call site for callers who
|
|
683
|
+
* specifically want outlier robustness and accept the blindness.
|
|
684
|
+
*/
|
|
685
|
+
const DECISION_PAIRED_DELTA_STATISTIC = "mean";
|
|
686
|
+
export { regularizedIncompleteBeta as A, medianInPlace as C, studentTCdf as D, zQuantile as E, studentTQuantile as O, makeRng as S, symmetricTwoSampleSeed as T, mean as _, pairedSignTest as a, assertFiniteSample as b, meanConfidenceInterval as c, ranks as d, spearmanR as f, weightedMean as g, weightedComposite as h, pairedDeltaTieFraction as i, lnGamma as k, partialCredit as l, summarizeNumberSeries as m, DECISION_PAIRED_DELTA_STATISTIC as n, pairedTTest as o, studentTCritical as p, pairedBootstrap as r, confidenceInterval as s, BOOTSTRAP_GATE_MIN_N as t, pearsonR as u, meanOrNull as v, seedFromData as w, binomialSignTwoSided as x, meanOrZero as y };
|
|
687
|
+
|
|
688
|
+
//# sourceMappingURL=paired-tests-CXcD_B80.js.map
|