@tangle-network/agent-eval 1.0.12 → 1.0.14
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 +36 -0
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-CoD1Dotf.d.ts → agent-profile-CPv4tENR.d.ts} +2 -2
- package/dist/{agent-profile-CoD1Dotf.d.ts.map → agent-profile-CPv4tENR.d.ts.map} +1 -1
- package/dist/{agreement-irr-w-t3XUTD.js → agreement-irr-DXcXEt4I.js} +20 -23
- package/dist/agreement-irr-DXcXEt4I.js.map +1 -0
- package/dist/analyst/index.d.ts +59 -13
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +144 -57
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-dGYmYNtb.js → analyze-runs-C7vWBDhl.js} +11 -11
- package/dist/{analyze-runs-dGYmYNtb.js.map → analyze-runs-C7vWBDhl.js.map} +1 -1
- package/dist/{analyze-runs-BYyMShsj.d.ts → analyze-runs-pJ4fhnYg.d.ts} +2 -2
- package/dist/{analyze-runs-BYyMShsj.d.ts.map → analyze-runs-pJ4fhnYg.d.ts.map} +1 -1
- package/dist/{benchmark-command-DZQrxqUL.js → benchmark-command-BRRhjX2k.js} +12 -14
- package/dist/benchmark-command-BRRhjX2k.js.map +1 -0
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +5 -5
- package/dist/builder-eval/index.js +1 -1
- package/dist/{calibration-DLzckXnn.js → calibration-CbZPApIO.js} +2 -2
- package/dist/{calibration-DLzckXnn.js.map → calibration-CbZPApIO.js.map} +1 -1
- package/dist/campaign/index.d.ts +6 -6
- package/dist/campaign/index.js +12 -12
- package/dist/{campaign-VKtf8HRr.js → campaign-DzLlT0So.js} +17 -17
- package/dist/{campaign-VKtf8HRr.js.map → campaign-DzLlT0So.js.map} +1 -1
- package/dist/{campaign-evidence-BICB3a9Z.js → campaign-evidence-CcA7a67m.js} +3 -3
- package/dist/{campaign-evidence-BICB3a9Z.js.map → campaign-evidence-CcA7a67m.js.map} +1 -1
- package/dist/cli.js +16 -10
- package/dist/cli.js.map +1 -1
- package/dist/{cluster-bootstrap-hNXESoc1.js → cluster-bootstrap-BteuR1hg.js} +2 -2
- package/dist/{cluster-bootstrap-hNXESoc1.js.map → cluster-bootstrap-BteuR1hg.js.map} +1 -1
- package/dist/contract/index.d.ts +9 -9
- package/dist/contract/index.js +14 -14
- package/dist/{decision-point-CErE7GnP.js → decision-point-CNyoKOkz.js} +13 -7
- package/dist/{decision-point-CErE7GnP.js.map → decision-point-CNyoKOkz.js.map} +1 -1
- package/dist/{default-registry-DKlKVXMx.d.ts → default-registry-BNv7eB1C.d.ts} +10 -7
- package/dist/default-registry-BNv7eB1C.d.ts.map +1 -0
- package/dist/{default-registry-gmDeN0KT.js → default-registry-eCkZFfuF.js} +6 -6
- package/dist/default-registry-eCkZFfuF.js.map +1 -0
- package/dist/{define-agent-eval-DyzJ0wOo.js → define-agent-eval-CjF2nTA3.js} +8 -8
- package/dist/{define-agent-eval-DyzJ0wOo.js.map → define-agent-eval-CjF2nTA3.js.map} +1 -1
- package/dist/{define-agent-eval-B9zPWFSK.d.ts → define-agent-eval-DKVYlm-T.d.ts} +7 -7
- package/dist/{define-agent-eval-B9zPWFSK.d.ts.map → define-agent-eval-DKVYlm-T.d.ts.map} +1 -1
- package/dist/{descriptive-BTzLL-aj.js → descriptive-B3Eb7tX0.js} +2 -2
- package/dist/{descriptive-BTzLL-aj.js.map → descriptive-B3Eb7tX0.js.map} +1 -1
- package/dist/diagnosis/index.d.ts +2 -2
- package/dist/diagnosis/index.js +1 -1
- package/dist/{dspy-rlm-engine-Xt3znknf.js → dspy-rlm-engine-_MEe2jIO.js} +3 -3
- package/dist/{dspy-rlm-engine-Xt3znknf.js.map → dspy-rlm-engine-_MEe2jIO.js.map} +1 -1
- package/dist/{engine-CaHaCc3W.d.ts → engine-rfV8Ff8V.d.ts} +2 -2
- package/dist/{engine-CaHaCc3W.d.ts.map → engine-rfV8Ff8V.d.ts.map} +1 -1
- package/dist/{eval-campaign-B-dQl_lA.js → eval-campaign-CZSCjxVb.js} +3 -3
- package/dist/{eval-campaign-B-dQl_lA.js.map → eval-campaign-CZSCjxVb.js.map} +1 -1
- package/dist/{evaluation-B0-KVXaV.d.ts → evaluation-DYAIkPQB.d.ts} +4 -4
- package/dist/{evaluation-B0-KVXaV.d.ts.map → evaluation-DYAIkPQB.d.ts.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/{exact-types-CIViGj98.d.ts → exact-types-CaLLU1Pz.d.ts} +2 -2
- package/dist/{exact-types-CIViGj98.d.ts.map → exact-types-CaLLU1Pz.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +1 -1
- package/dist/experiment/index.js +9 -9
- package/dist/{external-optimizer-process-BgitfZ-Q.js → external-optimizer-process-za-SsIap.js} +2 -2
- package/dist/{external-optimizer-process-BgitfZ-Q.js.map → external-optimizer-process-za-SsIap.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-CeHuAaMJ.js → external-optimizer-subprocess-B44kOfZb.js} +3 -3
- package/dist/external-optimizer-subprocess-B44kOfZb.js.map +1 -0
- package/dist/{feedback-trajectory-BgomnFOe.d.ts → feedback-trajectory-P37ju-gW.d.ts} +3 -3
- package/dist/{feedback-trajectory-BgomnFOe.d.ts.map → feedback-trajectory-P37ju-gW.d.ts.map} +1 -1
- package/dist/{finding-composition-DlvE1Qul.js → finding-composition-Belh_qU3.js} +12 -3
- package/dist/finding-composition-Belh_qU3.js.map +1 -0
- package/dist/{findings-store-Bp-0Guuv.js → findings-store-DWiBvJVM.js} +22 -5
- package/dist/findings-store-DWiBvJVM.js.map +1 -0
- package/dist/fuzz.js +1 -1
- package/dist/hosted/index.js +1 -1
- package/dist/{index-BwutH5i7.d.ts → index-BJM4rwP2.d.ts} +6 -6
- package/dist/{index-BwutH5i7.d.ts.map → index-BJM4rwP2.d.ts.map} +1 -1
- package/dist/{index-DAk2quYu.d.ts → index-C3t17kHu.d.ts} +16 -21
- package/dist/index-C3t17kHu.d.ts.map +1 -0
- package/dist/{index-Bn-P_XAl.d.ts → index-Dt6E4BHX.d.ts} +6 -6
- package/dist/{index-Bn-P_XAl.d.ts.map → index-Dt6E4BHX.d.ts.map} +1 -1
- package/dist/{index-ByJ20lyu.d.ts → index-chNyKroE.d.ts} +8 -8
- package/dist/{index-ByJ20lyu.d.ts.map → index-chNyKroE.d.ts.map} +1 -1
- package/dist/{index-CtcCSO1Y.d.ts → index-f09MX_H_.d.ts} +2 -2
- package/dist/{index-CtcCSO1Y.d.ts.map → index-f09MX_H_.d.ts.map} +1 -1
- package/dist/index.d.ts +52 -146
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -204
- package/dist/index.js.map +1 -1
- package/dist/{integrity-B1V6klyO.js → integrity-Vx5xgn3s.js} +2 -2
- package/dist/{integrity-B1V6klyO.js.map → integrity-Vx5xgn3s.js.map} +1 -1
- package/dist/{judge-calibration-D93UCm1k.js → judge-calibration-DKR6Xi-w.js} +13 -36
- package/dist/judge-calibration-DKR6Xi-w.js.map +1 -0
- package/dist/judge-calibration-DnrbQaXI.d.ts.map +1 -1
- package/dist/{judge-gate-DMlX38B7.js → judge-gate-CIlBrn6q.js} +2 -2
- package/dist/{judge-gate-DMlX38B7.js.map → judge-gate-CIlBrn6q.js.map} +1 -1
- package/dist/{kind-factory-VKysp1ds.js → kind-factory-Cfz8DUCc.js} +2 -2
- package/dist/{kind-factory-VKysp1ds.js.map → kind-factory-Cfz8DUCc.js.map} +1 -1
- package/dist/{llm-judge-CyDyqb6V.js → llm-judge-CHLvjbVR.js} +14 -14
- package/dist/{llm-judge-CyDyqb6V.js.map → llm-judge-CHLvjbVR.js.map} +1 -1
- package/dist/{matrix-4DcRFJ7Q.d.ts → matrix-Cy3oy7Rq.d.ts} +2 -2
- package/dist/{matrix-4DcRFJ7Q.d.ts.map → matrix-Cy3oy7Rq.d.ts.map} +1 -1
- package/dist/{mean-DDFhslBt.js → mean-D1d6gedE.js} +28 -2
- package/dist/{mean-DDFhslBt.js.map → mean-D1d6gedE.js.map} +1 -1
- package/dist/meta-eval/index.d.ts +1 -1
- package/dist/meta-eval/index.js +6 -6
- package/dist/{mint-D9ZysYtY.js → mint-BH_3Ak2x.js} +3 -3
- package/dist/{mint-D9ZysYtY.js.map → mint-BH_3Ak2x.js.map} +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +2 -2
- package/dist/openapi.json +1 -1
- package/dist/{outcome-observations-ahbNtxuP.js → outcome-observations-DZu5hLYF.js} +3 -3
- package/dist/{outcome-observations-ahbNtxuP.js.map → outcome-observations-DZu5hLYF.js.map} +1 -1
- package/dist/{paired-arms-C0Vd9bGG.js → paired-arms-3-tsXvvC.js} +5 -5
- package/dist/{paired-arms-C0Vd9bGG.js.map → paired-arms-3-tsXvvC.js.map} +1 -1
- package/dist/{paired-binary-B477lksS.js → paired-binary-CMzmSSd5.js} +2 -2
- package/dist/{paired-binary-B477lksS.js.map → paired-binary-CMzmSSd5.js.map} +1 -1
- package/dist/{paired-promotion-decision-5Pl_qJLX.js → paired-promotion-decision-CiueaTTj.js} +3 -3
- package/dist/{paired-promotion-decision-5Pl_qJLX.js.map → paired-promotion-decision-CiueaTTj.js.map} +1 -1
- package/dist/{paired-tests-kASEKpc-.js → paired-tests-Buh6feJ4.js} +2 -2
- package/dist/{paired-tests-kASEKpc-.js.map → paired-tests-Buh6feJ4.js.map} +1 -1
- package/dist/{pareto-DY_x3HHg.js → pareto-B34N-vnn.js} +7 -7
- package/dist/{pareto-DY_x3HHg.js.map → pareto-B34N-vnn.js.map} +1 -1
- package/dist/pipelines/index.js +1 -1
- package/dist/{power-and-mde-CRxepy8y.js → power-and-mde-g3vOn0XK.js} +3 -3
- package/dist/{power-and-mde-CRxepy8y.js.map → power-and-mde-g3vOn0XK.js.map} +1 -1
- package/dist/{prime-protocol-COFkxas6.d.ts → prime-protocol-DKRk4l4U.d.ts} +2 -2
- package/dist/{prime-protocol-COFkxas6.d.ts.map → prime-protocol-DKRk4l4U.d.ts.map} +1 -1
- package/dist/{promotion-policy-f79oklG_.js → promotion-policy-DLPcEnCf.js} +4 -4
- package/dist/{promotion-policy-f79oklG_.js.map → promotion-policy-DLPcEnCf.js.map} +1 -1
- package/dist/{proposal-findings-BclX0PFh.js → proposal-findings-CZJkS_GY.js} +2 -2
- package/dist/{proposal-findings-BclX0PFh.js.map → proposal-findings-CZJkS_GY.js.map} +1 -1
- package/dist/{registry-CMtGAxOw.d.ts → registry-Ck7w-rr5.d.ts} +3 -3
- package/dist/{registry-CMtGAxOw.d.ts.map → registry-Ck7w-rr5.d.ts.map} +1 -1
- package/dist/{release-confidence--1iP-d3x.js → release-confidence-nfQNh3eb.js} +4 -4
- package/dist/{release-confidence--1iP-d3x.js.map → release-confidence-nfQNh3eb.js.map} +1 -1
- package/dist/{render-CFrJ7M0o.js → render-DIQ5nqp_.js} +80 -51
- package/dist/{render-CFrJ7M0o.js.map → render-DIQ5nqp_.js.map} +1 -1
- package/dist/reporting.js +5 -5
- package/dist/{reward-P0VD_Aft.js → reward-DqMfaEax.js} +10 -2
- package/dist/{reward-P0VD_Aft.js.map → reward-DqMfaEax.js.map} +1 -1
- package/dist/{reward-hacking-D-Vi9-fE.js → reward-hacking-B88f-Kh7.js} +4 -4
- package/dist/{reward-hacking-D-Vi9-fE.js.map → reward-hacking-B88f-Kh7.js.map} +1 -1
- package/dist/rl.d.ts +3 -3
- package/dist/rl.js +12 -12
- package/dist/rollout/index.d.ts +2 -2
- package/dist/rollout/index.js +3 -3
- package/dist/{rollout-BC4u-d_I.js → rollout-CbOGxuHl.js} +2 -2
- package/dist/{rollout-BC4u-d_I.js.map → rollout-CbOGxuHl.js.map} +1 -1
- package/dist/{rollout-nodes-BHR9Q5jP.js → rollout-nodes-DKZ3vAYY.js} +2 -2
- package/dist/{rollout-nodes-BHR9Q5jP.js.map → rollout-nodes-DKZ3vAYY.js.map} +1 -1
- package/dist/{rubric-predictive-validity-BdxXDN6h.js → rubric-predictive-validity-D_6ZPTNR.js} +2 -2
- package/dist/{rubric-predictive-validity-BdxXDN6h.js.map → rubric-predictive-validity-D_6ZPTNR.js.map} +1 -1
- package/dist/{run-record-B-G2Tu11.js → run-record-CbUi2adH.js} +3 -3
- package/dist/{run-record-B-G2Tu11.js.map → run-record-CbUi2adH.js.map} +1 -1
- package/dist/{run-record-DEjx43cI.js → run-record-CpLS4Uid.js} +2 -2
- package/dist/{run-record-DEjx43cI.js.map → run-record-CpLS4Uid.js.map} +1 -1
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-BjR2Sr7w.d.ts → search-kernel-kwO-sgCq.d.ts} +2 -2
- package/dist/{search-kernel-BjR2Sr7w.d.ts.map → search-kernel-kwO-sgCq.d.ts.map} +1 -1
- package/dist/{search-ledger-BsVi-Ngv.js → search-ledger-CV_bQQed.js} +2 -2
- package/dist/{search-ledger-BsVi-Ngv.js.map → search-ledger-CV_bQQed.js.map} +1 -1
- package/dist/{search-shipper-pdg4viK7.js → search-shipper-CA3ooBbC.js} +2 -2
- package/dist/{search-shipper-pdg4viK7.js.map → search-shipper-CA3ooBbC.js.map} +1 -1
- package/dist/{search-summary-DedyTdiM.js → search-summary-DBMjdecs.js} +4 -4
- package/dist/{search-summary-DedyTdiM.js.map → search-summary-DBMjdecs.js.map} +1 -1
- package/dist/{sequential-Zp1tsxqI.js → sequential-BPbvgzfe.js} +2 -2
- package/dist/{sequential-Zp1tsxqI.js.map → sequential-BPbvgzfe.js.map} +1 -1
- package/dist/{skillopt-optimization-method-O35aMdxU.js → skillopt-optimization-method-D72XZZfR.js} +9 -9
- package/dist/{skillopt-optimization-method-O35aMdxU.js.map → skillopt-optimization-method-D72XZZfR.js.map} +1 -1
- package/dist/{statistical-heldout-DYF5f10K.js → statistical-heldout-NBxC7jGo.js} +3 -3
- package/dist/{statistical-heldout-DYF5f10K.js.map → statistical-heldout-NBxC7jGo.js.map} +1 -1
- package/dist/{statistical-heldout-bU7FBNjR.d.ts → statistical-heldout-_dXihc9T.d.ts} +3 -3
- package/dist/{statistical-heldout-bU7FBNjR.d.ts.map → statistical-heldout-_dXihc9T.d.ts.map} +1 -1
- package/dist/{store-otlp-DmLm65XW.js → store-otlp-BfPRa2p8.js} +2 -2
- package/dist/{store-otlp-DmLm65XW.js.map → store-otlp-BfPRa2p8.js.map} +1 -1
- package/dist/{store-tool-spans-lWf6INTH.d.ts → store-tool-spans-BgwVHXma.d.ts} +4 -4
- package/dist/{store-tool-spans-lWf6INTH.d.ts.map → store-tool-spans-BgwVHXma.d.ts.map} +1 -1
- package/dist/{store-tool-spans-GGaCijFy.js → store-tool-spans-BrSWHB9O.js} +3 -3
- package/dist/{store-tool-spans-GGaCijFy.js.map → store-tool-spans-BrSWHB9O.js.map} +1 -1
- package/dist/{summary-report-B4BLQb88.js → summary-report-C3IJvp0i.js} +7 -7
- package/dist/{summary-report-B4BLQb88.js.map → summary-report-C3IJvp0i.js.map} +1 -1
- package/dist/supervisor-run/index.d.ts +6 -0
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +3 -3
- package/dist/{systemone-BDVgb6XV.d.ts → systemone-CBvL1gx-.d.ts} +14 -8
- package/dist/systemone-CBvL1gx-.d.ts.map +1 -0
- package/dist/{systemone-review-S49gsy_y.js → systemone-review-BusEIzsg.js} +2 -2
- package/dist/{systemone-review-S49gsy_y.js.map → systemone-review-BusEIzsg.js.map} +1 -1
- package/dist/{systemone-review-BLgxt-4Q.d.ts → systemone-review-nbuMxxmi.d.ts} +2 -2
- package/dist/{systemone-review-BLgxt-4Q.d.ts.map → systemone-review-nbuMxxmi.d.ts.map} +1 -1
- package/dist/systemone.d.ts +4 -4
- package/dist/systemone.js +3 -3
- package/dist/{tool-groups-C3K-d3gd.d.ts → tool-groups-BQsjZD9F.d.ts} +3 -3
- package/dist/tool-groups-BQsjZD9F.d.ts.map +1 -0
- package/dist/{tool-waste-CRJqOASv.js → tool-waste-Czt3aWID.js} +3 -3
- package/dist/{tool-waste-CRJqOASv.js.map → tool-waste-Czt3aWID.js.map} +1 -1
- package/dist/{trace-questions-ej5AEJ5X.d.ts → trace-questions-CpTrtEcm.d.ts} +3 -3
- package/dist/{trace-questions-ej5AEJ5X.d.ts.map → trace-questions-CpTrtEcm.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +1 -1
- package/dist/trace-repair/index.js +2 -2
- package/dist/traces.d.ts +3 -3
- package/dist/traces.js +4 -4
- package/dist/{tree-C2N31CoI.js → tree-DPwgM2LX.js} +6 -6
- package/dist/{tree-C2N31CoI.js.map → tree-DPwgM2LX.js.map} +1 -1
- package/dist/{types-DzCO-S1m.d.ts → types-B9s9Xo5_.d.ts} +24 -2
- package/dist/types-B9s9Xo5_.d.ts.map +1 -0
- package/dist/{types-BF-xQGQn.d.ts → types-CBkDo7ja.d.ts} +2 -2
- package/dist/{types-BF-xQGQn.d.ts.map → types-CBkDo7ja.d.ts.map} +1 -1
- package/dist/{types-BK0blWhe.js → types-CL1_N7AZ.js} +2 -2
- package/dist/{types-BK0blWhe.js.map → types-CL1_N7AZ.js.map} +1 -1
- package/dist/{types-yofaDmQa.d.ts → types-D91tnhzf.d.ts} +2 -2
- package/dist/{types-yofaDmQa.d.ts.map → types-D91tnhzf.d.ts.map} +1 -1
- package/dist/wire/index.d.ts +3 -3
- package/docs/behavioral-trace-questions.md +23 -0
- package/docs/public-api.md +1 -1
- package/package.json +2 -2
- package/dist/agreement-irr-w-t3XUTD.js.map +0 -1
- package/dist/benchmark-command-DZQrxqUL.js.map +0 -1
- package/dist/default-registry-DKlKVXMx.d.ts.map +0 -1
- package/dist/default-registry-gmDeN0KT.js.map +0 -1
- package/dist/external-optimizer-subprocess-CeHuAaMJ.js.map +0 -1
- package/dist/finding-composition-DlvE1Qul.js.map +0 -1
- package/dist/findings-store-Bp-0Guuv.js.map +0 -1
- package/dist/index-DAk2quYu.d.ts.map +0 -1
- package/dist/judge-calibration-D93UCm1k.js.map +0 -1
- package/dist/systemone-BDVgb6XV.d.ts.map +0 -1
- package/dist/tool-groups-C3K-d3gd.d.ts.map +0 -1
- package/dist/types-DzCO-S1m.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as CostProvenance } from "./cost-ledger-Czro9wmo.js";
|
|
2
|
-
import { C as JudgeDimension, w as JudgeScore } from "./types-
|
|
2
|
+
import { C as JudgeDimension, w as JudgeScore } from "./types-CBkDo7ja.js";
|
|
3
3
|
import { o as MatrixResult } from "./index-DwUGehqX.js";
|
|
4
4
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
5
5
|
interface MultishotMessage {
|
|
@@ -381,4 +381,4 @@ interface RunMultishotMatrixResult {
|
|
|
381
381
|
}
|
|
382
382
|
declare function runMultishotMatrix<TPersona extends MultishotPersona>(opts: RunMultishotMatrixOptions<TPersona>): Promise<RunMultishotMatrixResult>;
|
|
383
383
|
export { MultishotTransportRequest as A, MultishotMessage as C, MultishotToolDefinition as D, MultishotShape as E, MultishotTransportToolCall as M, assertMultishotShotResult as N, MultishotToolExecutor as O, MultishotFatalToolError as S, MultishotResult as T, renderDimensions as _, MultishotCellOutput as a, MultishotArtifact as b, RunMultishotMatrixResult as c, MultishotShot as d, RunMultishotOptions as f, MultishotJudgeConfig as g, JudgeRunResult as h, ConversationJudgeInput as i, MultishotTransportResponse as j, MultishotTransport as k, computeCellComposite as l, DEFAULT_JUDGE_MODEL as m, CellCompositeInput as n, MultishotJudges as o, runMultishot as p, CellCompositeScore as r, RunMultishotMatrixOptions as s, ArtifactJudgeInput as t, runMultishotMatrix as u, renderJsonFooter as v, MultishotPersona as w, MultishotDriverEmptyError as x, runJudge as y };
|
|
384
|
-
//# sourceMappingURL=matrix-
|
|
384
|
+
//# sourceMappingURL=matrix-Cy3oy7Rq.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix-
|
|
1
|
+
{"version":3,"file":"matrix-Cy3oy7Rq.d.ts","names":[],"sources":["../src/multishot/types.ts","../src/multishot/judges.ts","../src/multishot/multishot.ts","../src/multishot/matrix.ts"],"mappings":";;;;UAIiB;EACf;EACA;EACA;EACA,YAAY;IAAQ;IAAY;IAAc,MAAM;;;UAGrC;EACf;EACA;EACA;IAAc;IAAc,MAAM;;EAClC;;UAGe;EACf,YAAY;EACZ,WAAW;EACX;EACA;;;EAGA;;;;;;;;EAQA,iBAAiB;;UAGF;EACf;EACA;IACE;IACA;IACA,YAAY;;;;;;UAOC;EACf;EACA,UAAU,MAAM;EAChB,QAAQ;EACR;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;IAAY;IAAc;;;UAGX;EACf;IAAW;IAAyB,aAAa;;EACjD;IAAU;IAAwB;;;;EAGlC;;;;EAIA;;;;;;;;KASU,sBACV,KAAK,8BACF,QAAQ;KAED,yBACV,MAAM,yBACN;;EAEE,WAAW;EACX,SAAS;MAER;EAAU;EAAiB;;UAEf;;EAEf;;GAEC;;;;;;;;UASc,eAAe,iBAAiB;;EAE/C,eAAe,SAAS;;;EAGxB,2BAA2B,SAAS;;cAGzB,kCAAkC;WACjB;EAAA,YAAA;;cAMjB,gCAAgC;EAC/B,YAAA;;;;;;;;;;;;;;;;;;;iBAgCE,0BAA0B,yBAAyB,SAAS;cCvI/D;UAEI,qBAAqB;;EAEpC;;;EAGA,WAAW;;EAEX;;EAEA,YAAY;;EAEZ;;;EAGA,cAAc,OAAO;;EAErB;;UAGe;;EAEf,OAAO;;EAEP,MAAM;;iBAGc,SAAS,QAC7B,OAAO,qBAAqB,SAC5B,OAAO,SACN,QAAQ;;;iBAsIK,iBAAiB,eAAe;;iBAKhC,iBAAiB,eAAe;UCxK/B,oBAAoB,iBAAiB;EACpD,SAAS;EACT,SAAS;;;EAGT,QAAQ,eAAe;;EAEvB,QAAQ;;EAER,gBAAgB,eAAe;;;;EAI/B,mBAAmB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(a, b) {
|
|
|
240
240
|
const reversed = seedFromData([sortedB, sortedA]) >>> 0;
|
|
241
241
|
return Math.min(forward, reversed);
|
|
242
242
|
}
|
|
243
|
+
const DEFAULT_BOOTSTRAP_SEED = 12648430;
|
|
244
|
+
/** Seeded percentile bootstrap over clusters: each resample redraws whole clusters with replacement, so
|
|
245
|
+
* observations sharing a source move together. Non-finite statistics are dropped; none left gives NaN bounds. */
|
|
246
|
+
function clusterBootstrap(items, cluster, statistic, { resamples = 2e3, seed = DEFAULT_BOOTSTRAP_SEED, level = .95 } = {}) {
|
|
247
|
+
const groups = /* @__PURE__ */ new Map();
|
|
248
|
+
items.forEach((item, index) => {
|
|
249
|
+
const key = cluster(item, index);
|
|
250
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
251
|
+
groups.get(key).push(item);
|
|
252
|
+
});
|
|
253
|
+
const clusters = [...groups.values()];
|
|
254
|
+
const rng = mulberry32(seed);
|
|
255
|
+
const values = [];
|
|
256
|
+
for (let b = 0; b < resamples; b++) {
|
|
257
|
+
const draw = () => clusters[Math.floor(rng() * clusters.length)];
|
|
258
|
+
const value = statistic(Array.from({ length: clusters.length }, draw).flat());
|
|
259
|
+
if (Number.isFinite(value)) values.push(value);
|
|
260
|
+
}
|
|
261
|
+
const q = (p) => interpolatedQuantile(values.sort((a, b) => a - b), p);
|
|
262
|
+
return {
|
|
263
|
+
low: q((1 - level) / 2),
|
|
264
|
+
high: q((1 + level) / 2),
|
|
265
|
+
resamples,
|
|
266
|
+
clusters: clusters.length
|
|
267
|
+
};
|
|
268
|
+
}
|
|
243
269
|
// src/statistics/mean.ts
|
|
244
270
|
/** Arithmetic mean. An empty input has no mean and returns NaN. */
|
|
245
271
|
function mean(values) {
|
|
@@ -253,6 +279,6 @@ function meanOrNull(values) {
|
|
|
253
279
|
function meanOrZero(values) {
|
|
254
280
|
return values.length === 0 ? 0 : mean(values);
|
|
255
281
|
}
|
|
256
|
-
export {
|
|
282
|
+
export { assertFiniteSample as a, clusterBootstrap as c, symmetricTwoSampleSeed as d, zQuantile as f, regularizedIncompleteBeta as g, lnGamma as h, DEFAULT_BOOTSTRAP_SEED as i, makeRng as l, studentTQuantile as m, meanOrNull as n, binomialHalfUpperTail as o, studentTCdf as p, meanOrZero as r, binomialSignTwoSided as s, mean as t, medianInPlace as u };
|
|
257
283
|
|
|
258
|
-
//# sourceMappingURL=mean-
|
|
284
|
+
//# sourceMappingURL=mean-D1d6gedE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mean-DDFhslBt.js","names":[],"sources":["../src/math/special-functions.ts","../src/math/student-t.ts","../src/statistics/internal.ts","../src/statistics/mean.ts"],"sourcesContent":["/** Lanczos approximation to ln Gamma(z). */\nexport function lnGamma(z: number): number {\n const g = 7\n const coefficients = [\n 0.99999999999980993, 676.5203681218851, -1259.1392167224028, 771.32342877765313,\n -176.61502916214059, 12.507343278686905, -0.13857109526572012, 9.9843695780195716e-6,\n 1.5056327351493116e-7,\n ]\n if (z < 0.5) {\n return Math.log(Math.PI / Math.sin(Math.PI * z)) - lnGamma(1 - z)\n }\n z -= 1\n let x = coefficients[0]!\n for (let i = 1; i < g + 2; i++) x += coefficients[i]! / (z + i)\n const t = z + g + 0.5\n return 0.5 * Math.log(2 * Math.PI) + (z + 0.5) * Math.log(t) - t + Math.log(x)\n}\n\n/**\n * Regularized incomplete beta function I_x(a, b).\n *\n * The Lentz continued fraction converges only for `x < (a+1)/(a+b+2)`; outside\n * that domain it must be reached through the symmetry `I_x(a,b) = 1 −\n * I_{1−x}(b,a)`. `studentTCdf` drives `x → 1` as `|t| → 0`, so the mirrored\n * branch is the one every near-null t-statistic takes.\n */\nexport function regularizedIncompleteBeta(x: number, a: number, b: number): number {\n if (x <= 0) return 0\n if (x >= 1) return 1\n const logBeta = lnGamma(a) + lnGamma(b) - lnGamma(a + b)\n // x^a·(1−x)^b / B(a,b) — symmetric under (x,a,b) → (1−x,b,a), so the\n // mirrored branch reuses it unchanged.\n const front = Math.exp(Math.log(x) * a + Math.log(1 - x) * b - logBeta)\n if (x < (a + 1) / (a + b + 2)) {\n return (front * betaContinuedFraction(x, a, b)) / a\n }\n return 1 - (front * betaContinuedFraction(1 - x, b, a)) / b\n}\n\n/** Modified Lentz evaluation of the beta continued fraction at `x`. */\nfunction betaContinuedFraction(x: number, a: number, b: number): number {\n const maxIterations = 300\n const epsilon = 3e-15\n let c = 1\n let d = 1 - ((a + b) * x) / (a + 1)\n if (Math.abs(d) < 1e-30) d = 1e-30\n d = 1 / d\n let fraction = d\n for (let m = 1; m <= maxIterations; m++) {\n const m2 = 2 * m\n let numerator = (m * (b - m) * x) / ((a + m2 - 1) * (a + m2))\n d = 1 + numerator * d\n if (Math.abs(d) < 1e-30) d = 1e-30\n c = 1 + numerator / c\n if (Math.abs(c) < 1e-30) c = 1e-30\n d = 1 / d\n fraction *= d * c\n numerator = -((a + m) * (a + b + m) * x) / ((a + m2) * (a + m2 + 1))\n d = 1 + numerator * d\n if (Math.abs(d) < 1e-30) d = 1e-30\n c = 1 + numerator / c\n if (Math.abs(c) < 1e-30) c = 1e-30\n d = 1 / d\n const delta = d * c\n fraction *= delta\n if (Math.abs(delta - 1) < epsilon) break\n }\n return fraction\n}\n","import { regularizedIncompleteBeta } from './special-functions'\n\n/**\n * Student-t CDF via the regularized incomplete beta function.\n */\nexport function studentTCdf(t: number, degreesOfFreedom: number): number {\n if (degreesOfFreedom <= 0) return 0.5\n\n const x = degreesOfFreedom / (degreesOfFreedom + t * t)\n const beta = regularizedIncompleteBeta(x, degreesOfFreedom / 2, 0.5)\n return t >= 0 ? 1 - 0.5 * beta : 0.5 * beta\n}\n\n/**\n * Inverse Student-t CDF, solved against {@link studentTCdf}.\n *\n * The CDF is monotone, so bracket expansion followed by bisection is stable\n * across fractional degrees of freedom and does not need a separate\n * approximation with a different error profile.\n */\nexport function studentTQuantile(probability: number, degreesOfFreedom: number): number {\n if (!Number.isFinite(probability) || probability < 0 || probability > 1) {\n throw new RangeError(`studentTQuantile: probability must be in [0,1], got ${probability}`)\n }\n if (!Number.isFinite(degreesOfFreedom) || degreesOfFreedom <= 0) {\n throw new RangeError(\n `studentTQuantile: degreesOfFreedom must be positive and finite, got ${degreesOfFreedom}`,\n )\n }\n if (probability === 0) return Number.NEGATIVE_INFINITY\n if (probability === 1) return Number.POSITIVE_INFINITY\n if (probability === 0.5) return 0\n if (probability < 0.5) return -studentTQuantile(1 - probability, degreesOfFreedom)\n\n let low = 0\n let high = 1\n while (studentTCdf(high, degreesOfFreedom) < probability) high *= 2\n for (let iteration = 0; iteration < 64; iteration++) {\n const middle = (low + high) / 2\n if (studentTCdf(middle, degreesOfFreedom) < probability) low = middle\n else high = middle\n }\n return (low + high) / 2\n}\n","/**\n * Shared internals for the statistics modules. Nothing here is part of the\n * public statistics surface — `./index` does not re-export this module.\n */\n\nimport { ValidationError } from '../errors'\nimport { interpolatedQuantile } from '../math/quantile'\nimport { lnGamma } from '../math/special-functions'\nimport { mulberry32 } from './random'\n\n/** Every rank test refuses non-finite input. Beyond the arithmetic being\n * undefined, the tie-grouping scan compares values with `===`, and\n * `NaN === NaN` is false, so a NaN would leave the group boundary unable to\n * advance and spin the loop forever. */\nexport function assertFiniteSample(fn: string, label: string, xs: readonly number[]): void {\n for (let i = 0; i < xs.length; i++) {\n if (!Number.isFinite(xs[i])) {\n throw new ValidationError(`${fn}: ${label}[${i}] must be finite, got ${xs[i]}`)\n }\n }\n}\n\n/**\n * Two-sided exact p-value for b successes out of (b + c) Bernoulli(0.5) trials —\n * the exact-binomial core of {@link mcnemar}. `min(1, 2·P(X ≤ min(b,c)))`. No\n * discordant pairs ⇒ no evidence ⇒ p = 1. Summed in log space (lnGamma) so it\n * stays exact at large discordant counts without overflow.\n */\nexport function binomialSignTwoSided(b: number, c: number): number {\n const nd = b + c\n if (nd === 0) return 1\n return Math.min(1, 2 * binomialHalfLowerTail(Math.min(b, c), nd))\n}\n\n/** P(X >= successes) for X ~ Binomial(n, 0.5). */\nexport function binomialHalfUpperTail(successes: number, n: number): number {\n if (successes <= 0) return 1\n if (successes > n) return 0\n\n // Use the smaller side of the distribution. For lower thresholds the\n // complement sums at most half the mass; for upper thresholds symmetry\n // maps the upper tail to a lower tail without subtraction.\n if (successes <= n / 2) {\n return Math.max(0, 1 - binomialHalfLowerTail(successes - 1, n))\n }\n return binomialHalfLowerTail(n - successes, n)\n}\n\n/** P(X <= maxSuccesses) for X ~ Binomial(n, 0.5), accumulated in log space. */\nfunction binomialHalfLowerTail(maxSuccesses: number, n: number): number {\n if (maxSuccesses < 0) return 0\n if (maxSuccesses >= n) return 1\n if (maxSuccesses === 0) return 2 ** -n\n\n const logHalfN = n * Math.log(0.5)\n let logTail = Number.NEGATIVE_INFINITY\n for (let i = 0; i <= maxSuccesses; i++) {\n const logChoose = lnGamma(n + 1) - lnGamma(i + 1) - lnGamma(n - i + 1)\n logTail = logAddExp(logTail, logChoose + logHalfN)\n }\n return Math.min(1, Math.exp(logTail))\n}\n\nfunction logAddExp(a: number, b: number): number {\n if (a === Number.NEGATIVE_INFINITY) return b\n if (b === Number.NEGATIVE_INFINITY) return a\n const max = Math.max(a, b)\n const min = Math.min(a, b)\n return max + Math.log1p(Math.exp(min - max))\n}\n\n/** Standard-normal inverse CDF (Acklam approximation). */\nexport function zQuantile(p: number): number {\n if (p <= 0 || p >= 1) {\n if (p === 0) return -Infinity\n if (p === 1) return Infinity\n return NaN\n }\n const a = [\n -3.969683028665376e1, 2.209460984245205e2, -2.759285104469687e2, 1.38357751867269e2,\n -3.066479806614716e1, 2.506628277459239,\n ]\n const b = [\n -5.447609879822406e1, 1.615858368580409e2, -1.556989798598866e2, 6.680131188771972e1,\n -1.328068155288572e1,\n ]\n const c = [\n -7.784894002430293e-3, -3.223964580411365e-1, -2.400758277161838, -2.549732539343734,\n 4.374664141464968, 2.938163982698783,\n ]\n const d = [7.784695709041462e-3, 3.224671290700398e-1, 2.445134137142996, 3.754408661907416]\n const pLow = 0.02425\n const pHigh = 1 - pLow\n let q: number\n let r: number\n if (p < pLow) {\n q = Math.sqrt(-2 * Math.log(p))\n return (\n (((((c[0]! * q + c[1]!) * q + c[2]!) * q + c[3]!) * q + c[4]!) * q + c[5]!) /\n ((((d[0]! * q + d[1]!) * q + d[2]!) * q + d[3]!) * q + 1)\n )\n }\n if (p <= pHigh) {\n q = p - 0.5\n r = q * q\n return (\n ((((((a[0]! * r + a[1]!) * r + a[2]!) * r + a[3]!) * r + a[4]!) * r + a[5]!) * q) /\n (((((b[0]! * r + b[1]!) * r + b[2]!) * r + b[3]!) * r + b[4]!) * r + 1)\n )\n }\n q = Math.sqrt(-2 * Math.log(1 - p))\n return (\n -(((((c[0]! * q + c[1]!) * q + c[2]!) * q + c[3]!) * q + c[4]!) * q + c[5]!) /\n ((((d[0]! * q + d[1]!) * q + d[2]!) * q + d[3]!) * q + 1)\n )\n}\n\nexport function medianInPlace(xs: number[]): number {\n if (xs.length === 0) return 0\n xs.sort((a, b) => a - b)\n return interpolatedQuantile(xs, 0.5)\n}\n\n/**\n * PRNG for every resampling path in this module.\n *\n * With no caller seed the seed is DERIVED FROM THE DATA rather than taken from\n * `Math.random`, so re-running the same input reproduces the same interval —\n * a gate verdict that cannot be re-derived is not evidence. Distinct data\n * still gets a distinct stream. Same pattern as `promotion-gate.ts`.\n */\nexport function makeRng(\n seed: number | undefined,\n ...series: readonly (readonly number[])[]\n): () => number {\n return mulberry32(seed ?? seedFromData(series))\n}\n\n/** FNV-1a over the IEEE-754 bytes of every observation. */\nfunction seedFromData(series: readonly (readonly number[])[]): number {\n const view = new DataView(new ArrayBuffer(8))\n // 32-bit FNV-1a over the IEEE-754 BYTES of each observation, not over a\n // string. Frozen: it seeds the unseeded bootstrap from the data itself, so a\n // change moves every interval this package has already published. The\n // string-input variants elsewhere cannot be substituted here.\n let hash = 0x811c9dc5\n for (const xs of series) {\n for (const x of xs) {\n view.setFloat64(0, x)\n for (let byte = 0; byte < 8; byte++) {\n hash = Math.imul(hash ^ view.getUint8(byte), 0x01000193)\n }\n }\n // Separator, so ([1],[2]) and ([1,2],[]) do not collide.\n hash = Math.imul(hash ^ 0xff, 0x01000193)\n }\n return hash | 0\n}\n\n/** Order-independent seed for a symmetric two-sample statistic. */\nexport function symmetricTwoSampleSeed(a: readonly number[], b: readonly number[]): number {\n const sortedA = [...a].sort((left, right) => left - right)\n const sortedB = [...b].sort((left, right) => left - right)\n const forward = seedFromData([sortedA, sortedB]) >>> 0\n const reversed = seedFromData([sortedB, sortedA]) >>> 0\n return Math.min(forward, reversed)\n}\n","/** Arithmetic mean. An empty input has no mean and returns NaN. */\nexport function mean(values: readonly number[]): number {\n return values.reduce((sum, value) => sum + value, 0) / values.length\n}\n\n/** Arithmetic mean, or null for an empty input. */\nexport function meanOrNull(values: readonly number[]): number | null {\n return values.length === 0 ? null : mean(values)\n}\n\n/** Arithmetic mean, or 0 for an empty input. */\nexport function meanOrZero(values: readonly number[]): number {\n return values.length === 0 ? 0 : mean(values)\n}\n"],"mappings":";;;;;AACA,SAAgB,QAAQ,GAAmB;CACzC,MAAM,IAAI;CACV,MAAM,eAAe;EACnB;EAAqB;EAAmB;EAAqB;EAC7D;EAAqB;EAAoB;EAAsB;EAC/D;CACF;CACA,IAAI,IAAI,IACN,OAAO,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC;CAElE,KAAK;CACL,IAAI,IAAI,aAAa;CACrB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAO,KAAK,KAAK,aAAa,MAAO,IAAI;CAC7D,MAAM,IAAI,IAAI,IAAI;CAClB,OAAO,KAAM,KAAK,IAAI,IAAI,KAAK,EAAE,KAAK,IAAI,MAAO,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,IAAI,CAAC;AAC/E;;;;;;;;;AAUA,SAAgB,0BAA0B,GAAW,GAAW,GAAmB;CACjF,IAAI,KAAK,GAAG,OAAO;CACnB,IAAI,KAAK,GAAG,OAAO;CACn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AAQ,aAAa,MAAM,CAAC;AAChD;;AAGA,SAAS,aAAa,QAAgD;CACpE,MAAM,uBAAO,IAAI,yBAAS,IAAI,YAAY,CAAC,CAAC;CAK5C,IAAI,OAAO;CACX,KAAK,MAAM,MAAM,QAAQ;EACvB,KAAK,MAAM,KAAK,IAAI;GAClB,KAAK,WAAW,GAAG,CAAC;GACpB,KAAK,IAAI,OAAO,GAAG,OAAO,GAAG,QAC3B,OAAO,KAAK,KAAK,OAAO,KAAK,SAAS,IAAI,GAAG,QAAU;EAE3D;EAEA,OAAO,KAAK,KAAK,OAAO,KAAM,QAAU;CAC1C;CACA,OAAO,OAAO;AAChB;;AAGA,SAAgB,uBAAuB,GAAsB,GAA8B;CACzF,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,MAAM,UAAU,OAAO,KAAK;CACzD,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,MAAM,UAAU,OAAO,KAAK;CACzD,MAAM,UAAU,aAAa,CAAC,SAAS,OAAO,CAAC,MAAM;CACrD,MAAM,WAAW,aAAa,CAAC,SAAS,OAAO,CAAC,MAAM;CACtD,OAAO,KAAK,IAAI,SAAS,QAAQ;AACnC;;;ACrKA,SAAgB,KAAK,QAAmC;CACtD,OAAO,OAAO,QAAQ,KAAK,UAAU,MAAM,OAAO,CAAC,IAAI,OAAO;AAChE;;AAGA,SAAgB,WAAW,QAA0C;CACnE,OAAO,OAAO,WAAW,IAAI,OAAO,KAAK,MAAM;AACjD;;AAGA,SAAgB,WAAW,QAAmC;CAC5D,OAAO,OAAO,WAAW,IAAI,IAAI,KAAK,MAAM;AAC9C"}
|
|
1
|
+
{"version":3,"file":"mean-D1d6gedE.js","names":[],"sources":["../src/math/special-functions.ts","../src/math/student-t.ts","../src/statistics/internal.ts","../src/statistics/mean.ts"],"sourcesContent":["/** Lanczos approximation to ln Gamma(z). */\nexport function lnGamma(z: number): number {\n const g = 7\n const coefficients = [\n 0.99999999999980993, 676.5203681218851, -1259.1392167224028, 771.32342877765313,\n -176.61502916214059, 12.507343278686905, -0.13857109526572012, 9.9843695780195716e-6,\n 1.5056327351493116e-7,\n ]\n if (z < 0.5) {\n return Math.log(Math.PI / Math.sin(Math.PI * z)) - lnGamma(1 - z)\n }\n z -= 1\n let x = coefficients[0]!\n for (let i = 1; i < g + 2; i++) x += coefficients[i]! / (z + i)\n const t = z + g + 0.5\n return 0.5 * Math.log(2 * Math.PI) + (z + 0.5) * Math.log(t) - t + Math.log(x)\n}\n\n/**\n * Regularized incomplete beta function I_x(a, b).\n *\n * The Lentz continued fraction converges only for `x < (a+1)/(a+b+2)`; outside\n * that domain it must be reached through the symmetry `I_x(a,b) = 1 −\n * I_{1−x}(b,a)`. `studentTCdf` drives `x → 1` as `|t| → 0`, so the mirrored\n * branch is the one every near-null t-statistic takes.\n */\nexport function regularizedIncompleteBeta(x: number, a: number, b: number): number {\n if (x <= 0) return 0\n if (x >= 1) return 1\n const logBeta = lnGamma(a) + lnGamma(b) - lnGamma(a + b)\n // x^a·(1−x)^b / B(a,b) — symmetric under (x,a,b) → (1−x,b,a), so the\n // mirrored branch reuses it unchanged.\n const front = Math.exp(Math.log(x) * a + Math.log(1 - x) * b - logBeta)\n if (x < (a + 1) / (a + b + 2)) {\n return (front * betaContinuedFraction(x, a, b)) / a\n }\n return 1 - (front * betaContinuedFraction(1 - x, b, a)) / b\n}\n\n/** Modified Lentz evaluation of the beta continued fraction at `x`. */\nfunction betaContinuedFraction(x: number, a: number, b: number): number {\n const maxIterations = 300\n const epsilon = 3e-15\n let c = 1\n let d = 1 - ((a + b) * x) / (a + 1)\n if (Math.abs(d) < 1e-30) d = 1e-30\n d = 1 / d\n let fraction = d\n for (let m = 1; m <= maxIterations; m++) {\n const m2 = 2 * m\n let numerator = (m * (b - m) * x) / ((a + m2 - 1) * (a + m2))\n d = 1 + numerator * d\n if (Math.abs(d) < 1e-30) d = 1e-30\n c = 1 + numerator / c\n if (Math.abs(c) < 1e-30) c = 1e-30\n d = 1 / d\n fraction *= d * c\n numerator = -((a + m) * (a + b + m) * x) / ((a + m2) * (a + m2 + 1))\n d = 1 + numerator * d\n if (Math.abs(d) < 1e-30) d = 1e-30\n c = 1 + numerator / c\n if (Math.abs(c) < 1e-30) c = 1e-30\n d = 1 / d\n const delta = d * c\n fraction *= delta\n if (Math.abs(delta - 1) < epsilon) break\n }\n return fraction\n}\n","import { regularizedIncompleteBeta } from './special-functions'\n\n/**\n * Student-t CDF via the regularized incomplete beta function.\n */\nexport function studentTCdf(t: number, degreesOfFreedom: number): number {\n if (degreesOfFreedom <= 0) return 0.5\n\n const x = degreesOfFreedom / (degreesOfFreedom + t * t)\n const beta = regularizedIncompleteBeta(x, degreesOfFreedom / 2, 0.5)\n return t >= 0 ? 1 - 0.5 * beta : 0.5 * beta\n}\n\n/**\n * Inverse Student-t CDF, solved against {@link studentTCdf}.\n *\n * The CDF is monotone, so bracket expansion followed by bisection is stable\n * across fractional degrees of freedom and does not need a separate\n * approximation with a different error profile.\n */\nexport function studentTQuantile(probability: number, degreesOfFreedom: number): number {\n if (!Number.isFinite(probability) || probability < 0 || probability > 1) {\n throw new RangeError(`studentTQuantile: probability must be in [0,1], got ${probability}`)\n }\n if (!Number.isFinite(degreesOfFreedom) || degreesOfFreedom <= 0) {\n throw new RangeError(\n `studentTQuantile: degreesOfFreedom must be positive and finite, got ${degreesOfFreedom}`,\n )\n }\n if (probability === 0) return Number.NEGATIVE_INFINITY\n if (probability === 1) return Number.POSITIVE_INFINITY\n if (probability === 0.5) return 0\n if (probability < 0.5) return -studentTQuantile(1 - probability, degreesOfFreedom)\n\n let low = 0\n let high = 1\n while (studentTCdf(high, degreesOfFreedom) < probability) high *= 2\n for (let iteration = 0; iteration < 64; iteration++) {\n const middle = (low + high) / 2\n if (studentTCdf(middle, degreesOfFreedom) < probability) low = middle\n else high = middle\n }\n return (low + high) / 2\n}\n","/**\n * Shared internals for the statistics modules. Nothing here is part of the\n * public statistics surface — `./index` does not re-export this module.\n */\n\nimport { ValidationError } from '../errors'\nimport { interpolatedQuantile } from '../math/quantile'\nimport { lnGamma } from '../math/special-functions'\nimport { mulberry32 } from './random'\n\n/** Every rank test refuses non-finite input. Beyond the arithmetic being\n * undefined, the tie-grouping scan compares values with `===`, and\n * `NaN === NaN` is false, so a NaN would leave the group boundary unable to\n * advance and spin the loop forever. */\nexport function assertFiniteSample(fn: string, label: string, xs: readonly number[]): void {\n for (let i = 0; i < xs.length; i++) {\n if (!Number.isFinite(xs[i])) {\n throw new ValidationError(`${fn}: ${label}[${i}] must be finite, got ${xs[i]}`)\n }\n }\n}\n\n/**\n * Two-sided exact p-value for b successes out of (b + c) Bernoulli(0.5) trials —\n * the exact-binomial core of {@link mcnemar}. `min(1, 2·P(X ≤ min(b,c)))`. No\n * discordant pairs ⇒ no evidence ⇒ p = 1. Summed in log space (lnGamma) so it\n * stays exact at large discordant counts without overflow.\n */\nexport function binomialSignTwoSided(b: number, c: number): number {\n const nd = b + c\n if (nd === 0) return 1\n return Math.min(1, 2 * binomialHalfLowerTail(Math.min(b, c), nd))\n}\n\n/** P(X >= successes) for X ~ Binomial(n, 0.5). */\nexport function binomialHalfUpperTail(successes: number, n: number): number {\n if (successes <= 0) return 1\n if (successes > n) return 0\n\n // Use the smaller side of the distribution. For lower thresholds the\n // complement sums at most half the mass; for upper thresholds symmetry\n // maps the upper tail to a lower tail without subtraction.\n if (successes <= n / 2) {\n return Math.max(0, 1 - binomialHalfLowerTail(successes - 1, n))\n }\n return binomialHalfLowerTail(n - successes, n)\n}\n\n/** P(X <= maxSuccesses) for X ~ Binomial(n, 0.5), accumulated in log space. */\nfunction binomialHalfLowerTail(maxSuccesses: number, n: number): number {\n if (maxSuccesses < 0) return 0\n if (maxSuccesses >= n) return 1\n if (maxSuccesses === 0) return 2 ** -n\n\n const logHalfN = n * Math.log(0.5)\n let logTail = Number.NEGATIVE_INFINITY\n for (let i = 0; i <= maxSuccesses; i++) {\n const logChoose = lnGamma(n + 1) - lnGamma(i + 1) - lnGamma(n - i + 1)\n logTail = logAddExp(logTail, logChoose + logHalfN)\n }\n return Math.min(1, Math.exp(logTail))\n}\n\nfunction logAddExp(a: number, b: number): number {\n if (a === Number.NEGATIVE_INFINITY) return b\n if (b === Number.NEGATIVE_INFINITY) return a\n const max = Math.max(a, b)\n const min = Math.min(a, b)\n return max + Math.log1p(Math.exp(min - max))\n}\n\n/** Standard-normal inverse CDF (Acklam approximation). */\nexport function zQuantile(p: number): number {\n if (p <= 0 || p >= 1) {\n if (p === 0) return -Infinity\n if (p === 1) return Infinity\n return NaN\n }\n const a = [\n -3.969683028665376e1, 2.209460984245205e2, -2.759285104469687e2, 1.38357751867269e2,\n -3.066479806614716e1, 2.506628277459239,\n ]\n const b = [\n -5.447609879822406e1, 1.615858368580409e2, -1.556989798598866e2, 6.680131188771972e1,\n -1.328068155288572e1,\n ]\n const c = [\n -7.784894002430293e-3, -3.223964580411365e-1, -2.400758277161838, -2.549732539343734,\n 4.374664141464968, 2.938163982698783,\n ]\n const d = [7.784695709041462e-3, 3.224671290700398e-1, 2.445134137142996, 3.754408661907416]\n const pLow = 0.02425\n const pHigh = 1 - pLow\n let q: number\n let r: number\n if (p < pLow) {\n q = Math.sqrt(-2 * Math.log(p))\n return (\n (((((c[0]! * q + c[1]!) * q + c[2]!) * q + c[3]!) * q + c[4]!) * q + c[5]!) /\n ((((d[0]! * q + d[1]!) * q + d[2]!) * q + d[3]!) * q + 1)\n )\n }\n if (p <= pHigh) {\n q = p - 0.5\n r = q * q\n return (\n ((((((a[0]! * r + a[1]!) * r + a[2]!) * r + a[3]!) * r + a[4]!) * r + a[5]!) * q) /\n (((((b[0]! * r + b[1]!) * r + b[2]!) * r + b[3]!) * r + b[4]!) * r + 1)\n )\n }\n q = Math.sqrt(-2 * Math.log(1 - p))\n return (\n -(((((c[0]! * q + c[1]!) * q + c[2]!) * q + c[3]!) * q + c[4]!) * q + c[5]!) /\n ((((d[0]! * q + d[1]!) * q + d[2]!) * q + d[3]!) * q + 1)\n )\n}\n\nexport function medianInPlace(xs: number[]): number {\n if (xs.length === 0) return 0\n xs.sort((a, b) => a - b)\n return interpolatedQuantile(xs, 0.5)\n}\n\n/**\n * PRNG for every resampling path in this module.\n *\n * With no caller seed the seed is DERIVED FROM THE DATA rather than taken from\n * `Math.random`, so re-running the same input reproduces the same interval —\n * a gate verdict that cannot be re-derived is not evidence. Distinct data\n * still gets a distinct stream. Same pattern as `promotion-gate.ts`.\n */\nexport function makeRng(\n seed: number | undefined,\n ...series: readonly (readonly number[])[]\n): () => number {\n return mulberry32(seed ?? seedFromData(series))\n}\n\n/** FNV-1a over the IEEE-754 bytes of every observation. */\nfunction seedFromData(series: readonly (readonly number[])[]): number {\n const view = new DataView(new ArrayBuffer(8))\n // 32-bit FNV-1a over the IEEE-754 BYTES of each observation, not over a\n // string. Frozen: it seeds the unseeded bootstrap from the data itself, so a\n // change moves every interval this package has already published. The\n // string-input variants elsewhere cannot be substituted here.\n let hash = 0x811c9dc5\n for (const xs of series) {\n for (const x of xs) {\n view.setFloat64(0, x)\n for (let byte = 0; byte < 8; byte++) {\n hash = Math.imul(hash ^ view.getUint8(byte), 0x01000193)\n }\n }\n // Separator, so ([1],[2]) and ([1,2],[]) do not collide.\n hash = Math.imul(hash ^ 0xff, 0x01000193)\n }\n return hash | 0\n}\n\n/** Order-independent seed for a symmetric two-sample statistic. */\nexport function symmetricTwoSampleSeed(a: readonly number[], b: readonly number[]): number {\n const sortedA = [...a].sort((left, right) => left - right)\n const sortedB = [...b].sort((left, right) => left - right)\n const forward = seedFromData([sortedA, sortedB]) >>> 0\n const reversed = seedFromData([sortedB, sortedA]) >>> 0\n return Math.min(forward, reversed)\n}\n\nexport const DEFAULT_BOOTSTRAP_SEED = 0xc0ffee\nexport type BootstrapInterval = { low: number; high: number; resamples: number; clusters: number }\n\n/** Seeded percentile bootstrap over clusters: each resample redraws whole clusters with replacement, so\n * observations sharing a source move together. Non-finite statistics are dropped; none left gives NaN bounds. */\nexport function clusterBootstrap<T>(\n items: readonly T[],\n cluster: (item: T, index: number) => string,\n statistic: (sample: T[]) => number,\n { resamples = 2000, seed = DEFAULT_BOOTSTRAP_SEED, level = 0.95 } = {},\n): BootstrapInterval {\n const groups = new Map<string, T[]>()\n items.forEach((item, index) => {\n const key = cluster(item, index)\n if (!groups.has(key)) groups.set(key, [])\n groups.get(key)!.push(item)\n })\n const clusters = [...groups.values()]\n const rng = mulberry32(seed)\n const values: number[] = []\n for (let b = 0; b < resamples; b++) {\n const draw = () => clusters[Math.floor(rng() * clusters.length)]!\n const value = statistic(Array.from({ length: clusters.length }, draw).flat())\n if (Number.isFinite(value)) values.push(value)\n }\n const q = (p: number) =>\n interpolatedQuantile(\n values.sort((a, b) => a - b),\n p,\n )\n return { low: q((1 - level) / 2), high: q((1 + level) / 2), resamples, clusters: clusters.length }\n}\n","/** Arithmetic mean. An empty input has no mean and returns NaN. */\nexport function mean(values: readonly number[]): number {\n return values.reduce((sum, value) => sum + value, 0) / values.length\n}\n\n/** Arithmetic mean, or null for an empty input. */\nexport function meanOrNull(values: readonly number[]): number | null {\n return values.length === 0 ? null : mean(values)\n}\n\n/** Arithmetic mean, or 0 for an empty input. */\nexport function meanOrZero(values: readonly number[]): number {\n return values.length === 0 ? 0 : mean(values)\n}\n"],"mappings":";;;;;AACA,SAAgB,QAAQ,GAAmB;CACzC,MAAM,IAAI;CACV,MAAM,eAAe;EACnB;EAAqB;EAAmB;EAAqB;EAC7D;EAAqB;EAAoB;EAAsB;EAC/D;CACF;CACA,IAAI,IAAI,IACN,OAAO,KAAK,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC;CAElE,KAAK;CACL,IAAI,IAAI,aAAa;CACrB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAO,KAAK,KAAK,aAAa,MAAO,IAAI;CAC7D,MAAM,IAAI,IAAI,IAAI;CAClB,OAAO,KAAM,KAAK,IAAI,IAAI,KA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CAAC;EACxC,OAAO,IAAI,GAAG,CAAC,CAAE,KAAK,IAAI;CAC5B,CAAC;CACD,MAAM,WAAW,CAAC,GAAG,OAAO,OAAO,CAAC;CACpC,MAAM,MAAM,WAAW,IAAI;CAC3B,MAAM,SAAmB,CAAC;CAC1B,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,KAAK;EAClC,MAAM,aAAa,SAAS,KAAK,MAAM,IAAI,IAAI,SAAS,MAAM;EAC9D,MAAM,QAAQ,UAAU,MAAM,KAAK,EAAE,QAAQ,SAAS,OAAO,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC;EAC5E,IAAI,OAAO,SAAS,KAAK,GAAG,OAAO,KAAK,KAAK;CAC/C;CACA,MAAM,KAAK,MACT,qBACE,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC,GAC3B,CACF;CACF,OAAO;EAAE,KAAK,GAAG,IAAI,SAAS,CAAC;EAAG,MAAM,GAAG,IAAI,SAAS,CAAC;EAAG;EAAW,UAAU,SAAS;CAAO;AACnG;;;ACtMA,SAAgB,KAAK,QAAmC;CACtD,OAAO,OAAO,QAAQ,KAAK,UAAU,MAAM,OAAO,CAAC,IAAI,OAAO;AAChE;;AAGA,SAAgB,WAAW,QAA0C;CACnE,OAAO,OAAO,WAAW,IAAI,OAAO,KAAK,MAAM;AACjD;;AAGA,SAAgB,WAAW,QAAmC;CAC5D,OAAO,OAAO,WAAW,IAAI,IAAI,KAAK,MAAM;AAC9C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as ContinuousCalibrationResult, c as SelfPreferenceResult, d as calibrateJudgeContinuous, f as continuousAgreement, h as verbosityBias, i as ContinuousAgreementOptions, l as VerbosityBiasResult, m as selfPreference, n as CandidateScore, o as GoldenItem, p as positionalBias, r as ContinuousAgreement, s as PositionalBiasResult, t as CalibrationResult, u as calibrateJudge } from "../judge-calibration-DnrbQaXI.js";
|
|
2
|
-
import { $ as measureJudgeAgreement, $t as CorrelationStudyOptions, A as JudgePanelOutput, At as ProbabilityPolicyAuditInput, B as JudgeConfusion, Bt as clusterBootstrapMean, C as JudgeCalibrationCellVerdict, Ct as EvaluatorAdmissionPolicy, D as JudgeCalibrationGoldItem, Dt as EvaluatorAuditPlan, E as JudgeCalibrationGateConfig, Et as EvaluatorAuditObservation, F as CalibrationExample, Ft as evaluatorAuditObservationSchema, G as JudgeGateRefusedError, Gt as CategoricalForecast, H as JudgeGateDecision, Ht as CalibrationOptions, I as CalibrationMerge, It as planEvaluatorAudit, J as JudgeRunMeta, Jt as calibrationCurve, K as JudgeGateStatus, Kt as OrdinalForecast, L as DEFAULT_JUDGE_GATE_POLICY, Lt as ClusterBootstrapOptions, M as RubricDimensionGuide, Mt as auditEvaluator, N as calibrateJudgePanel, Nt as auditProbabilityPolicy, O as JudgeDimensionCalibration, Ot as EvaluatorAuditPlanInput, P as gateJudgeCalibration, Pt as evaluatorAdmissionPolicySchema, Q as judgeGateDecision, Qt as CorrelationResult, R as JudgeAgreement, Rt as ClusterBootstrapResult, S as CalibrateJudgePanelInput, T as JudgeCalibrationGateCell, Tt as EvaluatorAuditInput, U as JudgeGateInput, Ut as CalibrationPair, V as JudgeExampleAgreement, Vt as CalibrationBin, W as JudgeGatePolicy, Wt as CalibrationReport, X as addCalibrationVerdicts, Xt as multiclassBrierScore, Y as OwnerVerdict, Yt as calibrationFromPairs, Z as assertJudgeMayGate, Zt as rankedProbabilityScore, _ as catchRate, _t as snapshotFromCalibration, a as PerturbedField, at as SentinelMetrics, b as plantByPerturbation, c as PlantEvidence, ct as SentinelSnapshot, d as PlantKindCounts, dt as SentinelTrend, en as CorrelationStudyResult, et as registerCalibrationSet, f as PlantManifest, ft as SnapshotMeta, g as UnseededRejection, gt as snapshotFromAgreement, h as SeededGradingSet, ht as judgeSentinelReport, i as PerturbationKind, it as SentinelMetricName, j as JudgePanelPrompt, jt as ProbabilityPolicyAuditReport, k as JudgePanelCalibration, kt as EvaluatorErrorRate, l as PlantExpectation, lt as SentinelStore, m as SeedPlantsOptions, mt as fileSentinelStore, n as CatchRateStatus, nn as OutcomePair, nt as EvalHealthStamp, o as PerturbedPlant, ot as SentinelReport, p as PlantOutcome, pt as evalHealthStamp, q as JudgeRun, qt as brierScore, r as EvidencePerturbation, rn as correlationStudy, rt as JudgeSentinelOptions, s as Plant, st as SentinelSetOptions, t as CatchRateReport, tn as EvalMetricSpec, tt as snapshotFromJudgeAgreement, u as PlantKind, ut as SentinelThresholds, v as definePlant, vt as snapshotFromSentinelSet, w as JudgeCalibrationGate, wt as EvaluatorAdmissionReport, x as seedPlants, y as perturbEvidence, yt as validateSentinelSnapshot, z as JudgeCalibrationSet, zt as ClusteredObservation } from "../index-
|
|
2
|
+
import { $ as measureJudgeAgreement, $t as CorrelationStudyOptions, A as JudgePanelOutput, At as ProbabilityPolicyAuditInput, B as JudgeConfusion, Bt as clusterBootstrapMean, C as JudgeCalibrationCellVerdict, Ct as EvaluatorAdmissionPolicy, D as JudgeCalibrationGoldItem, Dt as EvaluatorAuditPlan, E as JudgeCalibrationGateConfig, Et as EvaluatorAuditObservation, F as CalibrationExample, Ft as evaluatorAuditObservationSchema, G as JudgeGateRefusedError, Gt as CategoricalForecast, H as JudgeGateDecision, Ht as CalibrationOptions, I as CalibrationMerge, It as planEvaluatorAudit, J as JudgeRunMeta, Jt as calibrationCurve, K as JudgeGateStatus, Kt as OrdinalForecast, L as DEFAULT_JUDGE_GATE_POLICY, Lt as ClusterBootstrapOptions, M as RubricDimensionGuide, Mt as auditEvaluator, N as calibrateJudgePanel, Nt as auditProbabilityPolicy, O as JudgeDimensionCalibration, Ot as EvaluatorAuditPlanInput, P as gateJudgeCalibration, Pt as evaluatorAdmissionPolicySchema, Q as judgeGateDecision, Qt as CorrelationResult, R as JudgeAgreement, Rt as ClusterBootstrapResult, S as CalibrateJudgePanelInput, T as JudgeCalibrationGateCell, Tt as EvaluatorAuditInput, U as JudgeGateInput, Ut as CalibrationPair, V as JudgeExampleAgreement, Vt as CalibrationBin, W as JudgeGatePolicy, Wt as CalibrationReport, X as addCalibrationVerdicts, Xt as multiclassBrierScore, Y as OwnerVerdict, Yt as calibrationFromPairs, Z as assertJudgeMayGate, Zt as rankedProbabilityScore, _ as catchRate, _t as snapshotFromCalibration, a as PerturbedField, at as SentinelMetrics, b as plantByPerturbation, c as PlantEvidence, ct as SentinelSnapshot, d as PlantKindCounts, dt as SentinelTrend, en as CorrelationStudyResult, et as registerCalibrationSet, f as PlantManifest, ft as SnapshotMeta, g as UnseededRejection, gt as snapshotFromAgreement, h as SeededGradingSet, ht as judgeSentinelReport, i as PerturbationKind, it as SentinelMetricName, j as JudgePanelPrompt, jt as ProbabilityPolicyAuditReport, k as JudgePanelCalibration, kt as EvaluatorErrorRate, l as PlantExpectation, lt as SentinelStore, m as SeedPlantsOptions, mt as fileSentinelStore, n as CatchRateStatus, nn as OutcomePair, nt as EvalHealthStamp, o as PerturbedPlant, ot as SentinelReport, p as PlantOutcome, pt as evalHealthStamp, q as JudgeRun, qt as brierScore, r as EvidencePerturbation, rn as correlationStudy, rt as JudgeSentinelOptions, s as Plant, st as SentinelSetOptions, t as CatchRateReport, tn as EvalMetricSpec, tt as snapshotFromJudgeAgreement, u as PlantKind, ut as SentinelThresholds, v as definePlant, vt as snapshotFromSentinelSet, w as JudgeCalibrationGate, wt as EvaluatorAdmissionReport, x as seedPlants, y as perturbEvidence, yt as validateSentinelSnapshot, z as JudgeCalibrationSet, zt as ClusteredObservation } from "../index-C3t17kHu.js";
|
|
3
3
|
import { a as RubricPredictiveValidityReport, c as CorrelationInterval, d as FileSystemOutcomeStore, f as FileSystemOutcomeStoreOptions, g as OutcomeStoreError, h as OutcomeStore, i as RubricPredictiveValidityInput, l as OutcomeReduction, m as OutcomeFilter, n as RubricOutcomeExclusion, o as RubricRanking, p as InMemoryOutcomeStore, r as RubricOutcomePair, s as rubricPredictiveValidity, t as OutcomeMetricSpec, u as DeploymentOutcome } from "../rubric-predictive-validity-B3RzbwOx.js";
|
|
4
4
|
export { type CalibrateJudgePanelInput, CalibrationBin, CalibrationExample, CalibrationMerge, CalibrationOptions, CalibrationPair, CalibrationReport, type CalibrationResult, type CandidateScore, CatchRateReport, CatchRateStatus, CategoricalForecast, ClusterBootstrapOptions, ClusterBootstrapResult, ClusteredObservation, type ContinuousAgreement, type ContinuousAgreementOptions, type ContinuousCalibrationResult, type CorrelationInterval, CorrelationResult, CorrelationStudyOptions, CorrelationStudyResult, DEFAULT_JUDGE_GATE_POLICY, DeploymentOutcome, type EvalHealthStamp, EvalMetricSpec, type EvaluatorAdmissionPolicy, type EvaluatorAdmissionReport, type EvaluatorAuditInput, type EvaluatorAuditObservation, type EvaluatorAuditPlan, type EvaluatorAuditPlanInput, type EvaluatorErrorRate, EvidencePerturbation, FileSystemOutcomeStore, FileSystemOutcomeStoreOptions, type GoldenItem, InMemoryOutcomeStore, JudgeAgreement, type JudgeCalibrationCellVerdict, type JudgeCalibrationGate, type JudgeCalibrationGateCell, type JudgeCalibrationGateConfig, type JudgeCalibrationGoldItem, JudgeCalibrationSet, JudgeConfusion, type JudgeDimensionCalibration, JudgeExampleAgreement, JudgeGateDecision, JudgeGateInput, JudgeGatePolicy, JudgeGateRefusedError, JudgeGateStatus, type JudgePanelCalibration, type JudgePanelOutput, type JudgePanelPrompt, JudgeRun, JudgeRunMeta, type JudgeSentinelOptions, OrdinalForecast, OutcomeFilter, OutcomeMetricSpec, OutcomePair, type OutcomeReduction, OutcomeStore, OutcomeStoreError, OwnerVerdict, PerturbationKind, PerturbedField, PerturbedPlant, Plant, PlantEvidence, PlantExpectation, PlantKind, PlantKindCounts, PlantManifest, PlantOutcome, type PositionalBiasResult, type ProbabilityPolicyAuditInput, type ProbabilityPolicyAuditReport, type RubricDimensionGuide, RubricOutcomeExclusion, RubricOutcomePair, RubricPredictiveValidityInput, RubricPredictiveValidityReport, RubricRanking, SeedPlantsOptions, SeededGradingSet, type SelfPreferenceResult, type SentinelMetricName, type SentinelMetrics, type SentinelReport, type SentinelSetOptions, type SentinelSnapshot, type SentinelStore, type SentinelThresholds, type SentinelTrend, type SnapshotMeta, UnseededRejection, type VerbosityBiasResult, 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 };
|
package/dist/meta-eval/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { n as CaptureIntegrityError, s as ValidationError } from "../errors-DeEEV9Vx.js";
|
|
2
2
|
import { a as hashCanonical, i as compareCodeUnits } from "../canonical-CicJlINA.js";
|
|
3
3
|
import { t as mulberry32 } from "../random-DrzcgC7F.js";
|
|
4
|
-
import { a as selfPreference, i as positionalBias, n as calibrateJudgeContinuous, o as verbosityBias, r as continuousAgreement, t as calibrateJudge } from "../judge-calibration-
|
|
4
|
+
import { a as selfPreference, i as positionalBias, n as calibrateJudgeContinuous, o as verbosityBias, r as continuousAgreement, t as calibrateJudge } from "../judge-calibration-DKR6Xi-w.js";
|
|
5
5
|
import { s as runMetricExtractor } from "../query-CGXzO9d4.js";
|
|
6
6
|
import { n as callLlmJson } from "../llm-client-BdSiZ4qz.js";
|
|
7
|
-
import { a as validateObservationOptions, i as reduceOutcomeMetric, n as correlationSummary, r as hasVariation, t as assertUniqueObservationIds } from "../outcome-observations-
|
|
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-
|
|
7
|
+
import { a as validateObservationOptions, i as reduceOutcomeMetric, n as correlationSummary, r as hasVariation, t as assertUniqueObservationIds } from "../outcome-observations-DZu5hLYF.js";
|
|
8
|
+
import { a as rankedProbabilityScore, i as multiclassBrierScore, n as calibrationCurve, r as calibrationFromPairs, t as brierScore } from "../calibration-CbZPApIO.js";
|
|
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-CIlBrn6q.js";
|
|
10
10
|
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-
|
|
11
|
+
import { t as clusterBootstrapMean } from "../cluster-bootstrap-BteuR1hg.js";
|
|
12
|
+
import { t as rubricPredictiveValidity } from "../rubric-predictive-validity-D_6ZPTNR.js";
|
|
13
13
|
import { n as InMemoryOutcomeStore, r as OutcomeStoreError, t as FileSystemOutcomeStore } from "../outcome-store-TarrcfHG.js";
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
// src/meta-eval/correlation-study.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as ValidationError } from "./errors-DeEEV9Vx.js";
|
|
2
|
-
import { a as scoreOrigin, i as rolloutRewardFields } from "./reward-
|
|
3
|
-
import { o as runTaskScore } from "./run-record-
|
|
2
|
+
import { a as scoreOrigin, i as rolloutRewardFields } from "./reward-DqMfaEax.js";
|
|
3
|
+
import { o as runTaskScore } from "./run-record-CpLS4Uid.js";
|
|
4
4
|
import { t as buildTrajectory } from "./trajectory-O3GDHmev.js";
|
|
5
5
|
import { a as assertMinted, r as ROLLOUT_SCHEMA } from "./schema-YUIXT8iW.js";
|
|
6
6
|
// src/rollout/mint.ts
|
|
@@ -400,4 +400,4 @@ async function mintRolloutRows(records, store, options = {}) {
|
|
|
400
400
|
}
|
|
401
401
|
export { unmintableReasons as n, mintRolloutRows as t };
|
|
402
402
|
|
|
403
|
-
//# sourceMappingURL=mint-
|
|
403
|
+
//# sourceMappingURL=mint-BH_3Ak2x.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mint-D9ZysYtY.js","names":[],"sources":["../src/rollout/mint.ts"],"sourcesContent":["/**\n * Rollout minting — `tangle.rollout.v1` lines joined from the records the\n * substrate ALREADY keeps. There is no separate rollout store: a rollout\n * is the JOIN of a RunRecord (identity, provenance, cost, outcome) with\n * its trace (spans share `runId`), projected into the canonical line.\n *\n * Composition, not duplication:\n * - identity/provenance → `RunRecord` (candidateId, splitTag, agentProfile, hashes)\n * - step structure → `buildTrajectory` over the shared TraceStore\n * - preference-pair export → `feedbackTrajectoryToOptimizerRow` (feedback-trajectory.ts)\n * - PRM / reward-model → `reward-model-export.ts`\n * - search lineage → `searchLineage`, read from the run's search ledger\n *\n * Anti-Goodhart invariant: a run whose `outcome.realness.gated` is true is\n * never exported with a positive reward OR with any of the numbers that reward\n * was computed from. The gate travels into the training data (`reward` forced\n * to 0, `realness_gated: true`) and the whole outcome is transformed by\n * `gateGamedOutcome` inside `assertMinted` below, which relocates `metrics` and\n * `verdict` to `provenance.gated_evidence`. Mint returns\n * `MintedRolloutLine[]`: the brand the training exporters require, which only\n * this function, `readRolloutLedger`, and an explicit `assertMinted` can mint.\n *\n * A record carrying NEITHER split score is REJECTED (`ValidationError`), never\n * minted at 0 — \"nobody graded this\" is not the same claim as \"graded a total\n * failure\", and a trainer reading 0 learns the second. Lines that already\n * carry `reward: null` (interchange imports, existing ledgers) remain valid on\n * the wire; only the RunRecord→line door refuses.\n *\n * Records without spans or an explicit full capture become labeled GAP LINES (messages: [],\n * provenance.gap) — present in the output AND surfaced in\n * `missingTraces`; a capture gap is a finding, never a silent omission.\n */\n\nimport { ValidationError } from '../errors'\nimport { type RunRecord, type RunSearchCoordinates, runTaskScore } from '../run-record'\nimport type { LlmSpan, Span, ToolSpan } from '../trace/schema'\nimport type { TraceStore } from '../trace/store'\nimport { buildTrajectory } from '../trajectory'\nimport { rolloutRewardFields, scoreOrigin } from './reward'\nimport {\n assertMinted,\n type ChatMessage,\n type MintedRolloutLine,\n ROLLOUT_SCHEMA,\n type RolloutEvidenceAttempt,\n type RolloutRole,\n type RolloutSplit,\n type RolloutStep,\n} from './schema'\n\n/** Redactor for transcript/step payload text (secrets, PII), not opaque identity. */\nexport type RolloutScrubber = (text: string) => string\n\n/** A search cell's place in its search tree, read from the search ledger. */\nexport interface RolloutSearchLineage {\n /** Edges between the cell's node and the search root; the root is 0. */\n depth: number\n /** Order in which the node registered in its search; the root is 0. */\n ordinal: number\n /** Repeat index of the cell on its task, from 0. */\n rep: number\n /** Run id of the cell whose execution contains this search; null for a\n * top-level search. */\n containingRunId: string | null\n}\n\nexport interface MintRolloutOptions {\n scrub?: RolloutScrubber\n /**\n * Full canonical capture, including turns no longer in the model's context.\n * When supplied, missing/empty capture is refused, never replaced with a\n * span summary. Use the execution owner's capture or the existing harness\n * readers; reviewer traces and compacted histories are not full capture.\n */\n messagesOf?: (\n runId: string,\n ) => readonly ChatMessage[] | undefined | Promise<readonly ChatMessage[] | undefined>\n /** Provider attempts from a retained receipt bound to the exact run. */\n evidenceOf?: (\n runId: string,\n ) =>\n | { runId: string; attempts: readonly RolloutEvidenceAttempt[] }\n | undefined\n | Promise<{ runId: string; attempts: readonly RolloutEvidenceAttempt[] } | undefined>\n /** Cap steps per line (longest runs first drop middle steps). Default: no cap. */\n maxSteps?: number\n /** Role recorded on every minted line. Default 'agent' (a solo eval run). */\n role?: RolloutRole\n /** Task suite label. Default: the record's `experimentId`. */\n suite?: string\n /** Injected clock for deterministic output. */\n now?: () => Date\n /**\n * Lineage of a search run, read from its search ledger. It fills the line's\n * `generation` (node depth), `candidate_index` (node order), `task.rep` and\n * `parent_rollout_id` (the containing cell's run). Mint refuses a record\n * that carries `search` when this is absent, because a null `generation`\n * states that the run is not part of a search.\n */\n searchLineage?: (\n search: RunSearchCoordinates,\n ) => RolloutSearchLineage | Promise<RolloutSearchLineage>\n}\n\nexport interface MintRolloutResult {\n rows: MintedRolloutLine[]\n /** runIds that had a RunRecord but no spans — emitted as gap lines AND listed here. */\n missingTraces: string[]\n}\n\nconst asText = (v: unknown, scrub: RolloutScrubber): string => {\n const s = typeof v === 'string' ? v : JSON.stringify(v)\n return scrub(s ?? '')\n}\n\nfunction projectStep(span: Span, scrub: RolloutScrubber): RolloutStep {\n const base: RolloutStep = {\n kind: span.kind,\n name: scrub(span.name),\n status: span.status,\n durationMs: span.endedAt !== undefined ? span.endedAt - span.startedAt : undefined,\n }\n if (span.kind === 'llm') {\n const llm = span as LlmSpan\n const last = llm.messages[llm.messages.length - 1]\n if (last && last.content !== null) base.input = scrub(last.content)\n if (llm.output !== undefined) base.output = scrub(llm.output)\n } else if (span.kind === 'tool') {\n const tool = span as ToolSpan\n base.input = asText(tool.args, scrub)\n if (tool.result !== undefined) base.output = asText(tool.result, scrub)\n }\n return base\n}\n\n/** Preserve captured fields; invocation ids are opaque linkage, not generated text. */\nfunction projectMessage(message: ChatMessage, scrub: RolloutScrubber): ChatMessage {\n return {\n role: message.role,\n content: message.content === null ? null : scrub(message.content),\n ...(message.reasoning_content !== undefined\n ? { reasoning_content: scrub(message.reasoning_content) }\n : {}),\n ...(message.tool_calls !== undefined\n ? {\n tool_calls: message.tool_calls.map((call) => ({\n id: call.id,\n type: call.type,\n function: {\n name: call.function.name,\n arguments: scrub(call.function.arguments),\n },\n })),\n }\n : {}),\n ...(message.tool_call_id !== undefined ? { tool_call_id: message.tool_call_id } : {}),\n ...(message.name !== undefined ? { name: message.name } : {}),\n ...(message.is_copied_context !== undefined\n ? { is_copied_context: message.is_copied_context }\n : {}),\n }\n}\n\n/** Never recover missing calls from tool names, span order or argument summaries. */\nfunction requireToolLinkage(messages: readonly ChatMessage[], runId: string): void {\n const seen = new Set<string>()\n const pending = new Map<string, string>()\n const refuse: (detail: string) => never = (detail) => {\n throw new ValidationError(`Cannot mint rollout for run ${runId}: ${detail}`)\n }\n for (const message of messages) {\n if (message.tool_calls !== undefined) {\n if (message.role !== 'assistant' || !Array.isArray(message.tool_calls)) {\n refuse('tool calls must be captured on an assistant message')\n }\n if (pending.size > 0) refuse('new tool calls precede the prior invocation results')\n for (const call of message.tool_calls) {\n if (\n !call ||\n typeof call.id !== 'string' ||\n call.id.length === 0 ||\n seen.has(call.id) ||\n call.type !== 'function' ||\n !call.function ||\n typeof call.function.name !== 'string' ||\n call.function.name.length === 0 ||\n typeof call.function.arguments !== 'string'\n ) {\n refuse('missing, duplicate or malformed tool invocation')\n }\n seen.add(call.id)\n pending.set(call.id, call.function.name)\n }\n }\n if (message.role === 'tool') {\n const id = message.tool_call_id\n if (typeof id !== 'string' || !pending.has(id)) {\n refuse('tool result has no captured invocation (or answers it more than once)')\n }\n if (message.name !== undefined && message.name !== pending.get(id)) {\n refuse('tool result name does not match its invocation')\n }\n pending.delete(id)\n } else if (message.tool_call_id !== undefined) {\n refuse('tool_call_id is only valid on a tool result')\n } else if (pending.size > 0 && message.tool_calls === undefined) {\n refuse('conversation advances before all tool results were captured')\n }\n }\n if (pending.size > 0) refuse('tool invocation has no captured result')\n}\n\n/** Legacy span history; callers with compacted contexts supply messagesOf instead. */\nfunction finalConversation(spans: Span[]): ChatMessage[] {\n const llms = spans.filter((s): s is LlmSpan => s.kind === 'llm')\n const last = llms[llms.length - 1]\n if (!last) return []\n const messages: ChatMessage[] = [...last.messages]\n if (last.output !== undefined && last.output !== '') {\n messages.push({ role: 'assistant', content: last.output })\n }\n return messages\n}\n\n// The reward derivations live in the leaf module `./reward` so gate and\n// reporting code can import them without dragging in the trace store; they are\n// re-exported here because the derivations shipped from this path.\nexport {\n isRealnessGated,\n observedScore,\n observedSplitScore,\n type ScoreOrigin,\n type ScorePreference,\n scoreOrigin,\n trainingReward,\n trainingScore,\n} from './reward'\n\nconst REWARD_SOURCE: Record<ReturnType<typeof scoreOrigin>, string> = {\n holdout: 'run-record/holdout-score',\n search: 'run-record/search-score',\n unscored: 'run-record/unscored',\n}\n\n/**\n * The mint door refuses an execution-only record: a missing training label is\n * not a zero reward, and not a mintable line either. Lines that already carry\n * `reward: null` — interchange imports, existing ledgers — stay valid on the\n * wire and keep their labeled gap; this guard is only about the\n * RunRecord→line door, where the producer can still be told to go score the\n * run instead of shipping an unlabeled row.\n */\nfunction requireTaskScore(record: RunRecord): void {\n if (runTaskScore(record) === undefined) {\n throw new ValidationError(`Cannot mint rollout for run ${record.runId}: task score is missing`)\n }\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null\n\ninterface MintFieldCheck {\n /** The RunRecord path, spelled the way the caller has to fix it. */\n readonly field: string\n /** True when the record carries something the line can honestly be built from. */\n readonly present: (bag: Record<string, unknown>) => boolean\n /** What the caller writes onto the record, and why that value and not another. */\n readonly remedy: string\n}\n\n/**\n * The RunRecord fields mint reads that a record can be missing even though the\n * TYPE says it cannot. There are exactly two ways that happens:\n *\n * 1. The field was OPTIONAL when the record was serialized. `costProvenance`,\n * `terminalOutcome` and `scenarioId` were optional through agent-eval\n * 0.125 and became required in 0.126, with no on-disk migration — so every\n * ledger written before 0.126 is full of records the type calls complete.\n * 2. Mint reads a level DEEPER than the record's own type is checked at:\n * `outcome.raw`, `tokenUsage.input`, `tokenUsage.output`.\n *\n * Nothing else needs a check here. Every other field mint copies is a top-level\n * scalar landing in a typed slot on the line, where an absent value arrives as\n * `undefined` and `assertMinted` refuses it by name. These are the ones where an\n * absent value instead kills the join with `TypeError: Cannot read properties of\n * undefined`, or — worse — mints a line that reads as measured.\n *\n * This is deliberately NOT `validateRunRecord`. That validator answers \"is this\n * a valid RunRecord\", which is a wider question than \"can a rollout line be\n * built from this one\": it also enforces model-snapshot discipline, the\n * `terminalFailureReason` coupling, and the `costUsd === costProvenance.usd`\n * agreement. Routing the mint door through it would refuse records mint can\n * mint honestly today (a model alias with no snapshot date, for one), which is\n * a policy change with its own blast radius and not this bug. The door asks the\n * narrower question and answers it precisely.\n */\nconst MINT_FIELD_CHECKS: readonly MintFieldCheck[] = [\n {\n field: 'costProvenance',\n present: (bag) => isObject(bag.costProvenance) && typeof bag.costProvenance.kind === 'string',\n remedy:\n \"Records written before agent-eval 0.126 predate this field and carry `costUsd: 0` as the documented uncaptured sentinel, which is NOT an observed zero. Backfill it as costProvenance: { kind: 'uncaptured', usd: null } WITH costUsd: null — an uncaptured cost whose costUsd is non-null is rejected by validateRunRecord, so provenance alone leaves the record invalid.\",\n },\n {\n field: 'tokenUsage',\n present: (bag) => isObject(bag.tokenUsage),\n remedy:\n \"The line's cost.tokens_in and cost.tokens_out are read from it. Backfill it from the provider's usage report; mint will not write 0 for tokens nobody counted.\",\n },\n {\n field: 'tokenUsage.input',\n present: (bag) => !isObject(bag.tokenUsage) || typeof bag.tokenUsage.input === 'number',\n remedy: \"The line's cost.tokens_in is read from it, and a missing count is not a zero count.\",\n },\n {\n field: 'tokenUsage.output',\n present: (bag) => !isObject(bag.tokenUsage) || typeof bag.tokenUsage.output === 'number',\n remedy: \"The line's cost.tokens_out is read from it, and a missing count is not a zero count.\",\n },\n {\n field: 'outcome',\n present: (bag) => isObject(bag.outcome),\n remedy:\n \"The line's reward, reward_source and metrics are all read from it. A record with no outcome carries no training label at all, and mint refuses an unlabeled row.\",\n },\n {\n field: 'outcome.raw',\n // Reported only when `outcome` itself is present: one absent field should\n // produce one reason per CAUSE, not one per path that dereferences it.\n present: (bag) => !isObject(bag.outcome) || isObject(bag.outcome.raw),\n remedy:\n 'It is the metric bag copied verbatim into the line\\'s outcome.metrics. `{ ...undefined }` spreads to `{}` without complaint, so an absent bag would mint as \"this run reported no metrics\" — a different claim from \"this record predates the field\". Backfill it as {} only when that is what you mean.',\n },\n {\n field: 'terminalOutcome',\n present: (bag) => typeof bag.terminalOutcome === 'string',\n remedy:\n \"It became required in agent-eval 0.126. Backfill it from root-run or process evidence, or as 'unknown' when the producer has none — mint will not decide the line's is_completed and is_truncated for you.\",\n },\n {\n field: 'scenarioId',\n present: (bag) => typeof bag.scenarioId === 'string' && bag.scenarioId.length > 0,\n remedy:\n \"It became required in agent-eval 0.126 and becomes the line's task.instance_id, which must be a non-empty string. Backfill it from the scenario the run was dealt (pre-0.126 producers often left it in outcome.raw.scenario_id).\",\n },\n]\n\n/**\n * Why a record cannot be minted, one entry per missing field, empty when it can.\n *\n * Exported so a caller can partition a whole ledger — \"which of my 2742 records\n * predate 0.126\" — without catching an exception per record, and without\n * re-deriving the field list on their side. A re-derived list is a list that\n * drifts from the door it is supposed to predict.\n *\n * Takes a `RunRecord` because that is what the caller holds and what the\n * compiler agrees they hold. The type is precisely the thing that is wrong, so\n * the checks read the record as the untyped bag it actually is on disk.\n */\nexport function unmintableReasons(record: RunRecord): string[] {\n const bag = record as unknown as Record<string, unknown>\n return MINT_FIELD_CHECKS.filter((check) => !check.present(bag)).map(\n (check) => `${check.field} is missing. ${check.remedy}`,\n )\n}\n\n/**\n * The mint door THROWS on a record it cannot build a line from. It does NOT\n * normalise an absent `costProvenance` to `{kind:'uncaptured', usd:null}`, and\n * the choice is not stylistic:\n *\n * - Normalising cannot cover the record, only part of it. `terminalOutcome`\n * feeds `is_completed` and `is_truncated`, which the rollout schema requires\n * to be BOOLEAN — there is no null to fall back to, so every possible\n * default is a claim about how the run ended. A door that quietly fixes the\n * cost and invents the ending is a door no caller can predict.\n * - Normalising the cost requires knowing what `costUsd: 0` meant, and mint\n * cannot know. A genuinely free run and an uncaptured one are the same bytes\n * in a pre-0.126 record; only the producer can tell them apart. Guessing is\n * exactly the failure this guard exists to stop — the 0.125 optional chain\n * `record.costProvenance?.kind === 'uncaptured'` already made that guess,\n * silently, and every record it touched minted `cost.usd: 0`: an unmeasured\n * cost published as a measured zero, into a training dataset.\n * - `requireTaskScore`, directly above, already refuses an unlabeled record\n * for the same reason: \"nobody graded this\" is not \"graded zero\". \"Nobody\n * billed this\" is not \"billed zero\".\n *\n * The caller who wants historical records minted backfills them at their store,\n * in one pass, where `costUsd` can be corrected alongside `costProvenance` —\n * which is the only place that decision can be made correctly. The refusal names\n * the run, names every missing field, and spells the value to write.\n */\nfunction requireMintableRecord(record: RunRecord): void {\n const reasons = unmintableReasons(record)\n if (reasons.length === 0) return\n throw new ValidationError(`Cannot mint rollout for run ${record.runId}: ${reasons.join('\\n ')}`)\n}\n\n/** The search lineage a record's line is built from; undefined for a record outside a search. */\nasync function resolveSearchLineage(\n record: RunRecord,\n options: MintRolloutOptions,\n): Promise<RolloutSearchLineage | undefined> {\n if (record.search === undefined) return undefined\n const refuse: (detail: string) => never = (detail) => {\n throw new ValidationError(`Cannot mint rollout for search run ${record.runId}: ${detail}`)\n }\n if (!options.searchLineage) {\n refuse('pass searchLineage so generation, candidate_index, rep and parent come from its ledger')\n }\n const lineage = await options.searchLineage(record.search)\n const isCount = (value: unknown): boolean => Number.isSafeInteger(value) && (value as number) >= 0\n if (!isCount(lineage.depth)) refuse('lineage depth must be a non-negative integer')\n if (!isCount(lineage.ordinal)) refuse('lineage ordinal must be a non-negative integer')\n if (!isCount(lineage.rep)) refuse('lineage rep must be a non-negative integer')\n if (\n lineage.containingRunId !== null &&\n (typeof lineage.containingRunId !== 'string' || lineage.containingRunId.length === 0)\n ) {\n refuse('lineage containingRunId must be null or a non-empty run id')\n }\n if (lineage.containingRunId === record.runId) refuse('a run cannot contain itself')\n return lineage\n}\n\nconst SPLIT_FROM_TAG: Record<RunRecord['splitTag'], RolloutSplit> = {\n search: 'search',\n dev: 'dev',\n holdout: 'holdout',\n}\n\nfunction mintLine(\n record: RunRecord,\n lineage: RolloutSearchLineage | undefined,\n steps: RolloutStep[],\n messages: ChatMessage[],\n options: MintRolloutOptions,\n capturedAt: string,\n gap?: string,\n attempts?: readonly RolloutEvidenceAttempt[],\n lossyProjection = false,\n): MintedRolloutLine {\n // Field presence first, and BEFORE `requireTaskScore`: that guard reads\n // `record.outcome.searchScore` on its way to the answer, so an absent\n // `outcome` would throw a bare TypeError from inside the guard whose whole\n // job is to produce a clean refusal.\n //\n // Both branches of `mintRolloutRows` — the traced line and the gap line —\n // land here, which is the point: `mintLine` is the only constructor of a\n // `MintedRolloutLine` from a RunRecord, so there is no path into the waist\n // that skips the check and no way to get this wrong from the outside.\n requireMintableRecord(record)\n // A missing task score is refused before anything is built: an\n // execution-only record has no training label, and a missing label is\n // neither a zero reward nor a mintable row.\n requireTaskScore(record)\n // `reward` and `realness_gated` come out of one call, so neither door into\n // the waist can write one and forget the other.\n const rewardFields = rolloutRewardFields(record)\n // Only an observed or estimated amount is a total; a lower bound is not.\n const knownTotal =\n record.costProvenance.kind === 'observed' || record.costProvenance.kind === 'estimated'\n const terminalOutcome = record.terminalOutcome\n const isCompleted = terminalOutcome === 'succeeded' || terminalOutcome === 'failed'\n const isTruncated = terminalOutcome === 'cancelled' || terminalOutcome === 'incomplete'\n const terminalError =\n terminalOutcome === 'failed' ||\n terminalOutcome === 'cancelled' ||\n terminalOutcome === 'incomplete'\n ? (record.terminalFailureReason ?? `run ended ${terminalOutcome}`)\n : null\n // `assertMinted` rather than a cast: mint is the producer the whole gate\n // rests on, so it proves the line it just built is valid instead of asserting\n // it by fiat. The brand is unforgeable precisely because nobody casts to it.\n return assertMinted(\n {\n schema: ROLLOUT_SCHEMA,\n rollout_id: record.runId,\n parent_rollout_id: lineage?.containingRunId ?? null,\n run_id: record.runId,\n experiment_id: record.experimentId,\n candidate_id: record.candidateId,\n generation: lineage?.depth ?? null,\n candidate_index: lineage?.ordinal ?? null,\n role: options.role ?? 'agent',\n task: {\n suite: options.suite ?? record.experimentId,\n instance_id: record.scenarioId,\n split: SPLIT_FROM_TAG[record.splitTag],\n seed: record.seed,\n rep: lineage?.rep ?? 0,\n },\n policy: {\n harness: null,\n harness_version: null,\n model: record.model,\n provider: null,\n profile_commit: record.commitSha,\n prompt_hash: record.promptHash,\n config_hash: record.configHash,\n agent_profile_cell_id: record.agentProfile?.cellId ?? null,\n sampling: null,\n },\n messages,\n tool_defs: [],\n ...(steps.length > 0 ? { steps } : {}),\n outcome: {\n ...rewardFields,\n reward_source: REWARD_SOURCE[scoreOrigin(record)],\n verdict: null,\n // A verbatim bulk copy, deliberately UNFILTERED here. `outcome.raw`\n // holds the per-layer verifier scores (`layer.*`) that the reward was\n // derived from, so on a gated run this dict is the reward signal in\n // component form — but filtering it at this call site is the pattern\n // that has now leaked twice, because the next producer to write a\n // reward-bearing field forgets. The gate is applied to the whole\n // outcome once, in `assertMinted` below (`gateGamedOutcome`), which\n // moves the block to `provenance.gated_evidence` when the run is gated\n // and leaves it here untouched when it is not.\n metrics: { ...record.outcome.raw },\n is_completed: isCompleted,\n is_truncated: isTruncated,\n error: terminalError,\n },\n cost: {\n usd: knownTotal ? record.costUsd : null,\n tokens_in: record.tokenUsage.input,\n tokens_out: record.tokenUsage.output,\n tokens_reasoning: record.tokenUsage.reasoning ?? null,\n cache_read: record.tokenUsage.cached ?? null,\n cache_write: record.tokenUsage.cacheWrite ?? null,\n wall_s: Math.round(record.wallMs / 1000),\n },\n artifacts: {\n patch_path: null,\n run_dir: null,\n transcript_ref: record.traceRef ? `trace:${record.traceRef.traceId}` : null,\n },\n provenance: {\n captured_at: capturedAt,\n capture: 'mint',\n ...(record.search !== undefined ? { search: { ...record.search } } : {}),\n ...(attempts !== undefined ? { attempts: [...attempts] } : {}),\n ...(lossyProjection ? { lossy_projection: true } : {}),\n ...(gap !== undefined ? { gap } : {}),\n },\n },\n `minted rollout line for run ${record.runId}`,\n )\n}\n\n/**\n * Join RunRecords with their traces into canonical rollout lines. Records\n * without spans or an explicit capture are emitted as labeled gap lines and reported in\n * `missingTraces`. Execution-only records without a task score are rejected\n * because a missing training label is not a zero reward.\n */\nexport async function mintRolloutRows(\n records: RunRecord[],\n store: TraceStore,\n options: MintRolloutOptions = {},\n): Promise<MintRolloutResult> {\n const scrub = options.scrub ?? ((t) => t)\n const capturedAt = (options.now?.() ?? new Date()).toISOString()\n if (\n options.maxSteps !== undefined &&\n (!Number.isSafeInteger(options.maxSteps) || options.maxSteps < 1)\n ) {\n throw new ValidationError('maxSteps must be a positive integer')\n }\n const rows: MintedRolloutLine[] = []\n const missingTraces: string[] = []\n for (const record of records) {\n const trajectory = await buildTrajectory(store, record.runId)\n const captured = options.messagesOf ? await options.messagesOf(record.runId) : undefined\n const evidence = options.evidenceOf ? await options.evidenceOf(record.runId) : undefined\n if (evidence !== undefined && evidence?.runId !== record.runId) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: capture evidence belongs to another run`,\n )\n }\n if (\n options.evidenceOf &&\n (!evidence || !Array.isArray(evidence.attempts) || evidence.attempts.length === 0)\n ) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: provider attempt evidence is missing`,\n )\n }\n if (\n evidence?.attempts.some(\n (attempt) =>\n !attempt ||\n !Array.isArray(attempt.nativeSessionIds) ||\n !Array.isArray(attempt.processIds) ||\n !Array.isArray(attempt.missingReasons),\n )\n ) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: malformed provider attempt evidence`,\n )\n }\n const attempts = evidence?.attempts.map((attempt) => ({\n ...attempt,\n nativeSessionIds: [...attempt.nativeSessionIds],\n processIds: [...attempt.processIds],\n missingReasons: attempt.missingReasons.map(scrub),\n }))\n if (options.messagesOf && (!Array.isArray(captured) || captured.length === 0)) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: full capture is missing`,\n )\n }\n const lineage = await resolveSearchLineage(record, options)\n if (trajectory.steps.length === 0 && !options.messagesOf) {\n missingTraces.push(record.runId)\n rows.push(\n mintLine(\n record,\n lineage,\n [],\n [],\n options,\n capturedAt,\n 'no trace spans recorded for this runId',\n attempts,\n ),\n )\n continue\n }\n let steps = trajectory.steps.map((s) => projectStep(s.span, scrub))\n const omittedSteps =\n options.maxSteps !== undefined && steps.length > options.maxSteps\n ? steps.length - options.maxSteps\n : 0\n if (options.maxSteps !== undefined && omittedSteps > 0) {\n // Keep the head and tail — the middle of a long run is the least\n // informative for outcome attribution.\n const head = Math.ceil(options.maxSteps / 2)\n const tail = options.maxSteps - head\n steps = [...steps.slice(0, head), ...steps.slice(steps.length - tail)]\n }\n const spans = trajectory.steps.map((s) => s.span)\n const messages = captured ?? finalConversation(spans)\n requireToolLinkage(messages, record.runId)\n const conversation = messages.map((message) => projectMessage(message, scrub))\n // SFT drops copied context. That projection must not orphan a retained result.\n requireToolLinkage(\n conversation.filter((message) => message.is_copied_context !== true),\n record.runId,\n )\n const gaps: string[] = []\n if (conversation.length === 0) gaps.push('trace has no llm spans; no conversation to inline')\n else if (!options.messagesOf) {\n gaps.push('messages project only the last LLM context; full transcript was not captured')\n }\n if (omittedSteps > 0) gaps.push(`${omittedSteps} middle trace steps omitted by maxSteps`)\n for (const attempt of attempts ?? []) {\n if (attempt.missingReasons.length > 0) {\n gaps.push(`provider attempt ${attempt.ordinal}: ${attempt.missingReasons.join(', ')}`)\n }\n }\n rows.push(\n mintLine(\n record,\n lineage,\n steps,\n conversation,\n options,\n capturedAt,\n gaps.length > 0 ? gaps.join('; ') : undefined,\n attempts,\n (conversation.length > 0 && !options.messagesOf) ||\n omittedSteps > 0 ||\n (attempts?.some((attempt) => attempt.missingReasons.length > 0) ?? false),\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2x.js","names":[],"sources":["../src/rollout/mint.ts"],"sourcesContent":["/**\n * Rollout minting — `tangle.rollout.v1` lines joined from the records the\n * substrate ALREADY keeps. There is no separate rollout store: a rollout\n * is the JOIN of a RunRecord (identity, provenance, cost, outcome) with\n * its trace (spans share `runId`), projected into the canonical line.\n *\n * Composition, not duplication:\n * - identity/provenance → `RunRecord` (candidateId, splitTag, agentProfile, hashes)\n * - step structure → `buildTrajectory` over the shared TraceStore\n * - preference-pair export → `feedbackTrajectoryToOptimizerRow` (feedback-trajectory.ts)\n * - PRM / reward-model → `reward-model-export.ts`\n * - search lineage → `searchLineage`, read from the run's search ledger\n *\n * Anti-Goodhart invariant: a run whose `outcome.realness.gated` is true is\n * never exported with a positive reward OR with any of the numbers that reward\n * was computed from. The gate travels into the training data (`reward` forced\n * to 0, `realness_gated: true`) and the whole outcome is transformed by\n * `gateGamedOutcome` inside `assertMinted` below, which relocates `metrics` and\n * `verdict` to `provenance.gated_evidence`. Mint returns\n * `MintedRolloutLine[]`: the brand the training exporters require, which only\n * this function, `readRolloutLedger`, and an explicit `assertMinted` can mint.\n *\n * A record carrying NEITHER split score is REJECTED (`ValidationError`), never\n * minted at 0 — \"nobody graded this\" is not the same claim as \"graded a total\n * failure\", and a trainer reading 0 learns the second. Lines that already\n * carry `reward: null` (interchange imports, existing ledgers) remain valid on\n * the wire; only the RunRecord→line door refuses.\n *\n * Records without spans or an explicit full capture become labeled GAP LINES (messages: [],\n * provenance.gap) — present in the output AND surfaced in\n * `missingTraces`; a capture gap is a finding, never a silent omission.\n */\n\nimport { ValidationError } from '../errors'\nimport { type RunRecord, type RunSearchCoordinates, runTaskScore } from '../run-record'\nimport type { LlmSpan, Span, ToolSpan } from '../trace/schema'\nimport type { TraceStore } from '../trace/store'\nimport { buildTrajectory } from '../trajectory'\nimport { rolloutRewardFields, scoreOrigin } from './reward'\nimport {\n assertMinted,\n type ChatMessage,\n type MintedRolloutLine,\n ROLLOUT_SCHEMA,\n type RolloutEvidenceAttempt,\n type RolloutRole,\n type RolloutSplit,\n type RolloutStep,\n} from './schema'\n\n/** Redactor for transcript/step payload text (secrets, PII), not opaque identity. */\nexport type RolloutScrubber = (text: string) => string\n\n/** A search cell's place in its search tree, read from the search ledger. */\nexport interface RolloutSearchLineage {\n /** Edges between the cell's node and the search root; the root is 0. */\n depth: number\n /** Order in which the node registered in its search; the root is 0. */\n ordinal: number\n /** Repeat index of the cell on its task, from 0. */\n rep: number\n /** Run id of the cell whose execution contains this search; null for a\n * top-level search. */\n containingRunId: string | null\n}\n\nexport interface MintRolloutOptions {\n scrub?: RolloutScrubber\n /**\n * Full canonical capture, including turns no longer in the model's context.\n * When supplied, missing/empty capture is refused, never replaced with a\n * span summary. Use the execution owner's capture or the existing harness\n * readers; reviewer traces and compacted histories are not full capture.\n */\n messagesOf?: (\n runId: string,\n ) => readonly ChatMessage[] | undefined | Promise<readonly ChatMessage[] | undefined>\n /** Provider attempts from a retained receipt bound to the exact run. */\n evidenceOf?: (\n runId: string,\n ) =>\n | { runId: string; attempts: readonly RolloutEvidenceAttempt[] }\n | undefined\n | Promise<{ runId: string; attempts: readonly RolloutEvidenceAttempt[] } | undefined>\n /** Cap steps per line (longest runs first drop middle steps). Default: no cap. */\n maxSteps?: number\n /** Role recorded on every minted line. Default 'agent' (a solo eval run). */\n role?: RolloutRole\n /** Task suite label. Default: the record's `experimentId`. */\n suite?: string\n /** Injected clock for deterministic output. */\n now?: () => Date\n /**\n * Lineage of a search run, read from its search ledger. It fills the line's\n * `generation` (node depth), `candidate_index` (node order), `task.rep` and\n * `parent_rollout_id` (the containing cell's run). Mint refuses a record\n * that carries `search` when this is absent, because a null `generation`\n * states that the run is not part of a search.\n */\n searchLineage?: (\n search: RunSearchCoordinates,\n ) => RolloutSearchLineage | Promise<RolloutSearchLineage>\n}\n\nexport interface MintRolloutResult {\n rows: MintedRolloutLine[]\n /** runIds that had a RunRecord but no spans — emitted as gap lines AND listed here. */\n missingTraces: string[]\n}\n\nconst asText = (v: unknown, scrub: RolloutScrubber): string => {\n const s = typeof v === 'string' ? v : JSON.stringify(v)\n return scrub(s ?? '')\n}\n\nfunction projectStep(span: Span, scrub: RolloutScrubber): RolloutStep {\n const base: RolloutStep = {\n kind: span.kind,\n name: scrub(span.name),\n status: span.status,\n durationMs: span.endedAt !== undefined ? span.endedAt - span.startedAt : undefined,\n }\n if (span.kind === 'llm') {\n const llm = span as LlmSpan\n const last = llm.messages[llm.messages.length - 1]\n if (last && last.content !== null) base.input = scrub(last.content)\n if (llm.output !== undefined) base.output = scrub(llm.output)\n } else if (span.kind === 'tool') {\n const tool = span as ToolSpan\n base.input = asText(tool.args, scrub)\n if (tool.result !== undefined) base.output = asText(tool.result, scrub)\n }\n return base\n}\n\n/** Preserve captured fields; invocation ids are opaque linkage, not generated text. */\nfunction projectMessage(message: ChatMessage, scrub: RolloutScrubber): ChatMessage {\n return {\n role: message.role,\n content: message.content === null ? null : scrub(message.content),\n ...(message.reasoning_content !== undefined\n ? { reasoning_content: scrub(message.reasoning_content) }\n : {}),\n ...(message.tool_calls !== undefined\n ? {\n tool_calls: message.tool_calls.map((call) => ({\n id: call.id,\n type: call.type,\n function: {\n name: call.function.name,\n arguments: scrub(call.function.arguments),\n },\n })),\n }\n : {}),\n ...(message.tool_call_id !== undefined ? { tool_call_id: message.tool_call_id } : {}),\n ...(message.name !== undefined ? { name: message.name } : {}),\n ...(message.is_copied_context !== undefined\n ? { is_copied_context: message.is_copied_context }\n : {}),\n }\n}\n\n/** Never recover missing calls from tool names, span order or argument summaries. */\nfunction requireToolLinkage(messages: readonly ChatMessage[], runId: string): void {\n const seen = new Set<string>()\n const pending = new Map<string, string>()\n const refuse: (detail: string) => never = (detail) => {\n throw new ValidationError(`Cannot mint rollout for run ${runId}: ${detail}`)\n }\n for (const message of messages) {\n if (message.tool_calls !== undefined) {\n if (message.role !== 'assistant' || !Array.isArray(message.tool_calls)) {\n refuse('tool calls must be captured on an assistant message')\n }\n if (pending.size > 0) refuse('new tool calls precede the prior invocation results')\n for (const call of message.tool_calls) {\n if (\n !call ||\n typeof call.id !== 'string' ||\n call.id.length === 0 ||\n seen.has(call.id) ||\n call.type !== 'function' ||\n !call.function ||\n typeof call.function.name !== 'string' ||\n call.function.name.length === 0 ||\n typeof call.function.arguments !== 'string'\n ) {\n refuse('missing, duplicate or malformed tool invocation')\n }\n seen.add(call.id)\n pending.set(call.id, call.function.name)\n }\n }\n if (message.role === 'tool') {\n const id = message.tool_call_id\n if (typeof id !== 'string' || !pending.has(id)) {\n refuse('tool result has no captured invocation (or answers it more than once)')\n }\n if (message.name !== undefined && message.name !== pending.get(id)) {\n refuse('tool result name does not match its invocation')\n }\n pending.delete(id)\n } else if (message.tool_call_id !== undefined) {\n refuse('tool_call_id is only valid on a tool result')\n } else if (pending.size > 0 && message.tool_calls === undefined) {\n refuse('conversation advances before all tool results were captured')\n }\n }\n if (pending.size > 0) refuse('tool invocation has no captured result')\n}\n\n/** Legacy span history; callers with compacted contexts supply messagesOf instead. */\nfunction finalConversation(spans: Span[]): ChatMessage[] {\n const llms = spans.filter((s): s is LlmSpan => s.kind === 'llm')\n const last = llms[llms.length - 1]\n if (!last) return []\n const messages: ChatMessage[] = [...last.messages]\n if (last.output !== undefined && last.output !== '') {\n messages.push({ role: 'assistant', content: last.output })\n }\n return messages\n}\n\n// The reward derivations live in the leaf module `./reward` so gate and\n// reporting code can import them without dragging in the trace store; they are\n// re-exported here because the derivations shipped from this path.\nexport {\n isRealnessGated,\n observedScore,\n observedSplitScore,\n type ScoreOrigin,\n type ScorePreference,\n scoreOrigin,\n trainingReward,\n trainingScore,\n} from './reward'\n\nconst REWARD_SOURCE: Record<ReturnType<typeof scoreOrigin>, string> = {\n holdout: 'run-record/holdout-score',\n search: 'run-record/search-score',\n unscored: 'run-record/unscored',\n}\n\n/**\n * The mint door refuses an execution-only record: a missing training label is\n * not a zero reward, and not a mintable line either. Lines that already carry\n * `reward: null` — interchange imports, existing ledgers — stay valid on the\n * wire and keep their labeled gap; this guard is only about the\n * RunRecord→line door, where the producer can still be told to go score the\n * run instead of shipping an unlabeled row.\n */\nfunction requireTaskScore(record: RunRecord): void {\n if (runTaskScore(record) === undefined) {\n throw new ValidationError(`Cannot mint rollout for run ${record.runId}: task score is missing`)\n }\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null\n\ninterface MintFieldCheck {\n /** The RunRecord path, spelled the way the caller has to fix it. */\n readonly field: string\n /** True when the record carries something the line can honestly be built from. */\n readonly present: (bag: Record<string, unknown>) => boolean\n /** What the caller writes onto the record, and why that value and not another. */\n readonly remedy: string\n}\n\n/**\n * The RunRecord fields mint reads that a record can be missing even though the\n * TYPE says it cannot. There are exactly two ways that happens:\n *\n * 1. The field was OPTIONAL when the record was serialized. `costProvenance`,\n * `terminalOutcome` and `scenarioId` were optional through agent-eval\n * 0.125 and became required in 0.126, with no on-disk migration — so every\n * ledger written before 0.126 is full of records the type calls complete.\n * 2. Mint reads a level DEEPER than the record's own type is checked at:\n * `outcome.raw`, `tokenUsage.input`, `tokenUsage.output`.\n *\n * Nothing else needs a check here. Every other field mint copies is a top-level\n * scalar landing in a typed slot on the line, where an absent value arrives as\n * `undefined` and `assertMinted` refuses it by name. These are the ones where an\n * absent value instead kills the join with `TypeError: Cannot read properties of\n * undefined`, or — worse — mints a line that reads as measured.\n *\n * This is deliberately NOT `validateRunRecord`. That validator answers \"is this\n * a valid RunRecord\", which is a wider question than \"can a rollout line be\n * built from this one\": it also enforces model-snapshot discipline, the\n * `terminalFailureReason` coupling, and the `costUsd === costProvenance.usd`\n * agreement. Routing the mint door through it would refuse records mint can\n * mint honestly today (a model alias with no snapshot date, for one), which is\n * a policy change with its own blast radius and not this bug. The door asks the\n * narrower question and answers it precisely.\n */\nconst MINT_FIELD_CHECKS: readonly MintFieldCheck[] = [\n {\n field: 'costProvenance',\n present: (bag) => isObject(bag.costProvenance) && typeof bag.costProvenance.kind === 'string',\n remedy:\n \"Records written before agent-eval 0.126 predate this field and carry `costUsd: 0` as the documented uncaptured sentinel, which is NOT an observed zero. Backfill it as costProvenance: { kind: 'uncaptured', usd: null } WITH costUsd: null — an uncaptured cost whose costUsd is non-null is rejected by validateRunRecord, so provenance alone leaves the record invalid.\",\n },\n {\n field: 'tokenUsage',\n present: (bag) => isObject(bag.tokenUsage),\n remedy:\n \"The line's cost.tokens_in and cost.tokens_out are read from it. Backfill it from the provider's usage report; mint will not write 0 for tokens nobody counted.\",\n },\n {\n field: 'tokenUsage.input',\n present: (bag) => !isObject(bag.tokenUsage) || typeof bag.tokenUsage.input === 'number',\n remedy: \"The line's cost.tokens_in is read from it, and a missing count is not a zero count.\",\n },\n {\n field: 'tokenUsage.output',\n present: (bag) => !isObject(bag.tokenUsage) || typeof bag.tokenUsage.output === 'number',\n remedy: \"The line's cost.tokens_out is read from it, and a missing count is not a zero count.\",\n },\n {\n field: 'outcome',\n present: (bag) => isObject(bag.outcome),\n remedy:\n \"The line's reward, reward_source and metrics are all read from it. A record with no outcome carries no training label at all, and mint refuses an unlabeled row.\",\n },\n {\n field: 'outcome.raw',\n // Reported only when `outcome` itself is present: one absent field should\n // produce one reason per CAUSE, not one per path that dereferences it.\n present: (bag) => !isObject(bag.outcome) || isObject(bag.outcome.raw),\n remedy:\n 'It is the metric bag copied verbatim into the line\\'s outcome.metrics. `{ ...undefined }` spreads to `{}` without complaint, so an absent bag would mint as \"this run reported no metrics\" — a different claim from \"this record predates the field\". Backfill it as {} only when that is what you mean.',\n },\n {\n field: 'terminalOutcome',\n present: (bag) => typeof bag.terminalOutcome === 'string',\n remedy:\n \"It became required in agent-eval 0.126. Backfill it from root-run or process evidence, or as 'unknown' when the producer has none — mint will not decide the line's is_completed and is_truncated for you.\",\n },\n {\n field: 'scenarioId',\n present: (bag) => typeof bag.scenarioId === 'string' && bag.scenarioId.length > 0,\n remedy:\n \"It became required in agent-eval 0.126 and becomes the line's task.instance_id, which must be a non-empty string. Backfill it from the scenario the run was dealt (pre-0.126 producers often left it in outcome.raw.scenario_id).\",\n },\n]\n\n/**\n * Why a record cannot be minted, one entry per missing field, empty when it can.\n *\n * Exported so a caller can partition a whole ledger — \"which of my 2742 records\n * predate 0.126\" — without catching an exception per record, and without\n * re-deriving the field list on their side. A re-derived list is a list that\n * drifts from the door it is supposed to predict.\n *\n * Takes a `RunRecord` because that is what the caller holds and what the\n * compiler agrees they hold. The type is precisely the thing that is wrong, so\n * the checks read the record as the untyped bag it actually is on disk.\n */\nexport function unmintableReasons(record: RunRecord): string[] {\n const bag = record as unknown as Record<string, unknown>\n return MINT_FIELD_CHECKS.filter((check) => !check.present(bag)).map(\n (check) => `${check.field} is missing. ${check.remedy}`,\n )\n}\n\n/**\n * The mint door THROWS on a record it cannot build a line from. It does NOT\n * normalise an absent `costProvenance` to `{kind:'uncaptured', usd:null}`, and\n * the choice is not stylistic:\n *\n * - Normalising cannot cover the record, only part of it. `terminalOutcome`\n * feeds `is_completed` and `is_truncated`, which the rollout schema requires\n * to be BOOLEAN — there is no null to fall back to, so every possible\n * default is a claim about how the run ended. A door that quietly fixes the\n * cost and invents the ending is a door no caller can predict.\n * - Normalising the cost requires knowing what `costUsd: 0` meant, and mint\n * cannot know. A genuinely free run and an uncaptured one are the same bytes\n * in a pre-0.126 record; only the producer can tell them apart. Guessing is\n * exactly the failure this guard exists to stop — the 0.125 optional chain\n * `record.costProvenance?.kind === 'uncaptured'` already made that guess,\n * silently, and every record it touched minted `cost.usd: 0`: an unmeasured\n * cost published as a measured zero, into a training dataset.\n * - `requireTaskScore`, directly above, already refuses an unlabeled record\n * for the same reason: \"nobody graded this\" is not \"graded zero\". \"Nobody\n * billed this\" is not \"billed zero\".\n *\n * The caller who wants historical records minted backfills them at their store,\n * in one pass, where `costUsd` can be corrected alongside `costProvenance` —\n * which is the only place that decision can be made correctly. The refusal names\n * the run, names every missing field, and spells the value to write.\n */\nfunction requireMintableRecord(record: RunRecord): void {\n const reasons = unmintableReasons(record)\n if (reasons.length === 0) return\n throw new ValidationError(`Cannot mint rollout for run ${record.runId}: ${reasons.join('\\n ')}`)\n}\n\n/** The search lineage a record's line is built from; undefined for a record outside a search. */\nasync function resolveSearchLineage(\n record: RunRecord,\n options: MintRolloutOptions,\n): Promise<RolloutSearchLineage | undefined> {\n if (record.search === undefined) return undefined\n const refuse: (detail: string) => never = (detail) => {\n throw new ValidationError(`Cannot mint rollout for search run ${record.runId}: ${detail}`)\n }\n if (!options.searchLineage) {\n refuse('pass searchLineage so generation, candidate_index, rep and parent come from its ledger')\n }\n const lineage = await options.searchLineage(record.search)\n const isCount = (value: unknown): boolean => Number.isSafeInteger(value) && (value as number) >= 0\n if (!isCount(lineage.depth)) refuse('lineage depth must be a non-negative integer')\n if (!isCount(lineage.ordinal)) refuse('lineage ordinal must be a non-negative integer')\n if (!isCount(lineage.rep)) refuse('lineage rep must be a non-negative integer')\n if (\n lineage.containingRunId !== null &&\n (typeof lineage.containingRunId !== 'string' || lineage.containingRunId.length === 0)\n ) {\n refuse('lineage containingRunId must be null or a non-empty run id')\n }\n if (lineage.containingRunId === record.runId) refuse('a run cannot contain itself')\n return lineage\n}\n\nconst SPLIT_FROM_TAG: Record<RunRecord['splitTag'], RolloutSplit> = {\n search: 'search',\n dev: 'dev',\n holdout: 'holdout',\n}\n\nfunction mintLine(\n record: RunRecord,\n lineage: RolloutSearchLineage | undefined,\n steps: RolloutStep[],\n messages: ChatMessage[],\n options: MintRolloutOptions,\n capturedAt: string,\n gap?: string,\n attempts?: readonly RolloutEvidenceAttempt[],\n lossyProjection = false,\n): MintedRolloutLine {\n // Field presence first, and BEFORE `requireTaskScore`: that guard reads\n // `record.outcome.searchScore` on its way to the answer, so an absent\n // `outcome` would throw a bare TypeError from inside the guard whose whole\n // job is to produce a clean refusal.\n //\n // Both branches of `mintRolloutRows` — the traced line and the gap line —\n // land here, which is the point: `mintLine` is the only constructor of a\n // `MintedRolloutLine` from a RunRecord, so there is no path into the waist\n // that skips the check and no way to get this wrong from the outside.\n requireMintableRecord(record)\n // A missing task score is refused before anything is built: an\n // execution-only record has no training label, and a missing label is\n // neither a zero reward nor a mintable row.\n requireTaskScore(record)\n // `reward` and `realness_gated` come out of one call, so neither door into\n // the waist can write one and forget the other.\n const rewardFields = rolloutRewardFields(record)\n // Only an observed or estimated amount is a total; a lower bound is not.\n const knownTotal =\n record.costProvenance.kind === 'observed' || record.costProvenance.kind === 'estimated'\n const terminalOutcome = record.terminalOutcome\n const isCompleted = terminalOutcome === 'succeeded' || terminalOutcome === 'failed'\n const isTruncated = terminalOutcome === 'cancelled' || terminalOutcome === 'incomplete'\n const terminalError =\n terminalOutcome === 'failed' ||\n terminalOutcome === 'cancelled' ||\n terminalOutcome === 'incomplete'\n ? (record.terminalFailureReason ?? `run ended ${terminalOutcome}`)\n : null\n // `assertMinted` rather than a cast: mint is the producer the whole gate\n // rests on, so it proves the line it just built is valid instead of asserting\n // it by fiat. The brand is unforgeable precisely because nobody casts to it.\n return assertMinted(\n {\n schema: ROLLOUT_SCHEMA,\n rollout_id: record.runId,\n parent_rollout_id: lineage?.containingRunId ?? null,\n run_id: record.runId,\n experiment_id: record.experimentId,\n candidate_id: record.candidateId,\n generation: lineage?.depth ?? null,\n candidate_index: lineage?.ordinal ?? null,\n role: options.role ?? 'agent',\n task: {\n suite: options.suite ?? record.experimentId,\n instance_id: record.scenarioId,\n split: SPLIT_FROM_TAG[record.splitTag],\n seed: record.seed,\n rep: lineage?.rep ?? 0,\n },\n policy: {\n harness: null,\n harness_version: null,\n model: record.model,\n provider: null,\n profile_commit: record.commitSha,\n prompt_hash: record.promptHash,\n config_hash: record.configHash,\n agent_profile_cell_id: record.agentProfile?.cellId ?? null,\n sampling: null,\n },\n messages,\n tool_defs: [],\n ...(steps.length > 0 ? { steps } : {}),\n outcome: {\n ...rewardFields,\n reward_source: REWARD_SOURCE[scoreOrigin(record)],\n verdict: null,\n // A verbatim bulk copy, deliberately UNFILTERED here. `outcome.raw`\n // holds the per-layer verifier scores (`layer.*`) that the reward was\n // derived from, so on a gated run this dict is the reward signal in\n // component form — but filtering it at this call site is the pattern\n // that has now leaked twice, because the next producer to write a\n // reward-bearing field forgets. The gate is applied to the whole\n // outcome once, in `assertMinted` below (`gateGamedOutcome`), which\n // moves the block to `provenance.gated_evidence` when the run is gated\n // and leaves it here untouched when it is not.\n metrics: { ...record.outcome.raw },\n is_completed: isCompleted,\n is_truncated: isTruncated,\n error: terminalError,\n },\n cost: {\n usd: knownTotal ? record.costUsd : null,\n tokens_in: record.tokenUsage.input,\n tokens_out: record.tokenUsage.output,\n tokens_reasoning: record.tokenUsage.reasoning ?? null,\n cache_read: record.tokenUsage.cached ?? null,\n cache_write: record.tokenUsage.cacheWrite ?? null,\n wall_s: Math.round(record.wallMs / 1000),\n },\n artifacts: {\n patch_path: null,\n run_dir: null,\n transcript_ref: record.traceRef ? `trace:${record.traceRef.traceId}` : null,\n },\n provenance: {\n captured_at: capturedAt,\n capture: 'mint',\n ...(record.search !== undefined ? { search: { ...record.search } } : {}),\n ...(attempts !== undefined ? { attempts: [...attempts] } : {}),\n ...(lossyProjection ? { lossy_projection: true } : {}),\n ...(gap !== undefined ? { gap } : {}),\n },\n },\n `minted rollout line for run ${record.runId}`,\n )\n}\n\n/**\n * Join RunRecords with their traces into canonical rollout lines. Records\n * without spans or an explicit capture are emitted as labeled gap lines and reported in\n * `missingTraces`. Execution-only records without a task score are rejected\n * because a missing training label is not a zero reward.\n */\nexport async function mintRolloutRows(\n records: RunRecord[],\n store: TraceStore,\n options: MintRolloutOptions = {},\n): Promise<MintRolloutResult> {\n const scrub = options.scrub ?? ((t) => t)\n const capturedAt = (options.now?.() ?? new Date()).toISOString()\n if (\n options.maxSteps !== undefined &&\n (!Number.isSafeInteger(options.maxSteps) || options.maxSteps < 1)\n ) {\n throw new ValidationError('maxSteps must be a positive integer')\n }\n const rows: MintedRolloutLine[] = []\n const missingTraces: string[] = []\n for (const record of records) {\n const trajectory = await buildTrajectory(store, record.runId)\n const captured = options.messagesOf ? await options.messagesOf(record.runId) : undefined\n const evidence = options.evidenceOf ? await options.evidenceOf(record.runId) : undefined\n if (evidence !== undefined && evidence?.runId !== record.runId) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: capture evidence belongs to another run`,\n )\n }\n if (\n options.evidenceOf &&\n (!evidence || !Array.isArray(evidence.attempts) || evidence.attempts.length === 0)\n ) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: provider attempt evidence is missing`,\n )\n }\n if (\n evidence?.attempts.some(\n (attempt) =>\n !attempt ||\n !Array.isArray(attempt.nativeSessionIds) ||\n !Array.isArray(attempt.processIds) ||\n !Array.isArray(attempt.missingReasons),\n )\n ) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: malformed provider attempt evidence`,\n )\n }\n const attempts = evidence?.attempts.map((attempt) => ({\n ...attempt,\n nativeSessionIds: [...attempt.nativeSessionIds],\n processIds: [...attempt.processIds],\n missingReasons: attempt.missingReasons.map(scrub),\n }))\n if (options.messagesOf && (!Array.isArray(captured) || captured.length === 0)) {\n throw new ValidationError(\n `Cannot mint rollout for run ${record.runId}: full capture is missing`,\n )\n }\n const lineage = await resolveSearchLineage(record, options)\n if (trajectory.steps.length === 0 && !options.messagesOf) {\n missingTraces.push(record.runId)\n rows.push(\n mintLine(\n record,\n lineage,\n [],\n [],\n options,\n capturedAt,\n 'no trace spans recorded for this runId',\n attempts,\n ),\n )\n continue\n }\n let steps = trajectory.steps.map((s) => projectStep(s.span, scrub))\n const omittedSteps =\n options.maxSteps !== undefined && steps.length > options.maxSteps\n ? steps.length - options.maxSteps\n : 0\n if (options.maxSteps !== undefined && omittedSteps > 0) {\n // Keep the head and tail — the middle of a long run is the least\n // informative for outcome attribution.\n const head = Math.ceil(options.maxSteps / 2)\n const tail = options.maxSteps - head\n steps = [...steps.slice(0, head), ...steps.slice(steps.length - tail)]\n }\n const spans = trajectory.steps.map((s) => s.span)\n const messages = captured ?? finalConversation(spans)\n requireToolLinkage(messages, record.runId)\n const conversation = messages.map((message) => projectMessage(message, scrub))\n // SFT drops copied context. That projection must not orphan a retained result.\n requireToolLinkage(\n conversation.filter((message) => message.is_copied_context !== true),\n record.runId,\n )\n const gaps: string[] = []\n if (conversation.length === 0) gaps.push('trace has no llm spans; no conversation to inline')\n else if (!options.messagesOf) {\n gaps.push('messages project only the last LLM context; full transcript was not captured')\n }\n if (omittedSteps > 0) gaps.push(`${omittedSteps} middle trace steps omitted by maxSteps`)\n for (const attempt of attempts ?? []) {\n if (attempt.missingReasons.length > 0) {\n gaps.push(`provider attempt ${attempt.ordinal}: ${attempt.missingReasons.join(', ')}`)\n }\n }\n rows.push(\n mintLine(\n record,\n lineage,\n steps,\n conversation,\n options,\n capturedAt,\n gaps.length > 0 ? gaps.join('; ') : undefined,\n attempts,\n (conversation.length > 0 && !options.messagesOf) ||\n omittedSteps > 0 ||\n (attempts?.some((attempt) => attempt.missingReasons.length > 0) ?? false),\n ),\n )\n }\n return { rows, missingTraces }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GA,MAAM,UAAU,GAAY,UAAmC;CAE7D,OAAO,OADG,OAAO,MAAM,WAAW,IAAI,KAAK,UAAU,CAAC,MACpC,EAAE;AACtB;AAEA,SAAS,YAAY,MAAY,OAAqC;CACpE,MAAM,OAAoB;EACxB,MAAM,KAAK;EACX,MAAM,MAAM,KAAK,IAAI;EACrB,QAAQ,KAAK;EACb,YAAY,KAAK,YAAY,KAAA,IAAY,KAAK,UAAU,KAAK,YAAY,KAAA;CAC3E;CACA,IAAI,KAAK,SAAS,OAAO;EACvB,MAAM,MAAM;EACZ,MAAM,OAAO,IAAI,SAAS,IAAI,SAAS,SAAS;EAChD,IAAI,QAAQ,KAAK,YAAY,MAAM,KAAK,QAAQ,MAAM,KAAK,OAAO;EAClE,IAAI,IAAI,WAAW,KAAA,GAAW,KAAK,SAAS,MAAM,IAAI,MAAM;CAC9D,OAAO,IAAI,KAAK,SAAS,QAAQ;EAC/B,MAAM,O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,mDAAmD;OACvF,IAAI,CAAC,QAAQ,YAChB,KAAK,KAAK,8EAA8E;EAE1F,IAAI,eAAe,GAAG,KAAK,KAAK,GAAG,aAAa,wCAAwC;EACxF,KAAK,MAAM,WAAW,YAAY,CAAC,GACjC,IAAI,QAAQ,eAAe,SAAS,GAClC,KAAK,KAAK,oBAAoB,QAAQ,QAAQ,IAAI,QAAQ,eAAe,KAAK,IAAI,GAAG;EAGzF,KAAK,KACH,SACE,QACA,SACA,OACA,cACA,SACA,YACA,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAA,GACpC,UACC,aAAa,SAAS,KAAK,CAAC,QAAQ,cACnC,eAAe,MACd,UAAU,MAAM,YAAY,QAAQ,eAAe,SAAS,CAAC,KAAK,MACvE,CACF;CACF;CACA,OAAO;EAAE;EAAM;CAAc;AAC/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as MultishotTransportRequest, D as MultishotToolDefinition, T as MultishotResult, c as RunMultishotMatrixResult, f as RunMultishotOptions, s as RunMultishotMatrixOptions, w as MultishotPersona } from "../../matrix-
|
|
1
|
+
import { A as MultishotTransportRequest, D as MultishotToolDefinition, T as MultishotResult, c as RunMultishotMatrixResult, f as RunMultishotOptions, s as RunMultishotMatrixOptions, w as MultishotPersona } from "../../matrix-Cy3oy7Rq.js";
|
|
2
2
|
interface CompareOptions {
|
|
3
3
|
/** Stop after this many mismatches. A structural divergence high in the
|
|
4
4
|
* tree would otherwise report every leaf below it. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as JudgeDimension, w as JudgeScore } from "../types-
|
|
2
|
-
import { A as MultishotTransportRequest, C as MultishotMessage, D as MultishotToolDefinition, E as MultishotShape, M as MultishotTransportToolCall, N as assertMultishotShotResult, O as MultishotToolExecutor, S as MultishotFatalToolError, T as MultishotResult, _ as renderDimensions, a as MultishotCellOutput, b as MultishotArtifact, c as RunMultishotMatrixResult, d as MultishotShot, f as RunMultishotOptions, g as MultishotJudgeConfig, h as JudgeRunResult, i as ConversationJudgeInput, j as MultishotTransportResponse, k as MultishotTransport, l as computeCellComposite, m as DEFAULT_JUDGE_MODEL, n as CellCompositeInput, o as MultishotJudges, p as runMultishot, r as CellCompositeScore, s as RunMultishotMatrixOptions, t as ArtifactJudgeInput, u as runMultishotMatrix, v as renderJsonFooter, w as MultishotPersona, x as MultishotDriverEmptyError, y as runJudge } from "../matrix-
|
|
1
|
+
import { C as JudgeDimension, w as JudgeScore } from "../types-CBkDo7ja.js";
|
|
2
|
+
import { A as MultishotTransportRequest, C as MultishotMessage, D as MultishotToolDefinition, E as MultishotShape, M as MultishotTransportToolCall, N as assertMultishotShotResult, O as MultishotToolExecutor, S as MultishotFatalToolError, T as MultishotResult, _ as renderDimensions, a as MultishotCellOutput, b as MultishotArtifact, c as RunMultishotMatrixResult, d as MultishotShot, f as RunMultishotOptions, g as MultishotJudgeConfig, h as JudgeRunResult, i as ConversationJudgeInput, j as MultishotTransportResponse, k as MultishotTransport, l as computeCellComposite, m as DEFAULT_JUDGE_MODEL, n as CellCompositeInput, o as MultishotJudges, p as runMultishot, r as CellCompositeScore, s as RunMultishotMatrixOptions, t as ArtifactJudgeInput, u as runMultishotMatrix, v as renderJsonFooter, w as MultishotPersona, x as MultishotDriverEmptyError, y as runJudge } from "../matrix-Cy3oy7Rq.js";
|
|
3
3
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
4
4
|
/** Prompt and completion tokens one leg reported. */
|
|
5
5
|
interface MultishotLegTokens {
|
package/dist/openapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.1.0",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "@tangle-network/agent-eval — wire protocol",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.14",
|
|
6
6
|
"description": "HTTP and stdio RPC interface to agent-eval. The TypeScript runtime is the source of truth; this spec is the contract that cross-language clients (Python, Rust, Go) generate from.\n\nWire-protocol version: 1.1.0. Bumps on breaking changes to request/response schemas.",
|
|
7
7
|
"contact": {
|
|
8
8
|
"name": "Tangle Network",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as pearsonR, o as spearmanR } from "./descriptive-
|
|
1
|
+
import { l as makeRng } from "./mean-D1d6gedE.js";
|
|
2
|
+
import { i as pearsonR, o as spearmanR } from "./descriptive-B3Eb7tX0.js";
|
|
3
3
|
// src/meta-eval/outcome-observations.ts
|
|
4
4
|
/** Reduce observations of one named metric; unrelated keys cannot supply a value. */
|
|
5
5
|
function reduceOutcomeMetric(outcomes, metric, reduction) {
|
|
@@ -74,4 +74,4 @@ function interval(values) {
|
|
|
74
74
|
}
|
|
75
75
|
export { validateObservationOptions as a, reduceOutcomeMetric as i, correlationSummary as n, validateOutcomeMetricSpecifications as o, hasVariation as r, assertUniqueObservationIds as t };
|
|
76
76
|
|
|
77
|
-
//# sourceMappingURL=outcome-observations-
|
|
77
|
+
//# sourceMappingURL=outcome-observations-DZu5hLYF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome-observations-
|
|
1
|
+
{"version":3,"file":"outcome-observations-DZu5hLYF.js","names":[],"sources":["../src/meta-eval/outcome-observations.ts"],"sourcesContent":["import { pearsonR, spearmanR } from '../statistics'\nimport { makeRng } from '../statistics/internal'\nimport type { DeploymentOutcome } from './outcome-store'\n\nexport type OutcomeReduction = 'latest' | 'mean' | 'max'\n\nexport interface CorrelationInterval {\n lower: number\n upper: number\n}\n\n/** Reduce observations of one named metric; unrelated keys cannot supply a value. */\nexport function reduceOutcomeMetric(\n outcomes: readonly DeploymentOutcome[],\n metric: string,\n reduction: OutcomeReduction,\n): number | null {\n const observations = outcomes.flatMap((outcome) => {\n const value = outcome.metrics[metric]\n return Number.isFinite(outcome.capturedAt) &&\n typeof value === 'number' &&\n Number.isFinite(value)\n ? [{ capturedAt: outcome.capturedAt, value }]\n : []\n })\n if (observations.length === 0) return null\n if (reduction === 'mean') {\n return observations.reduce(\n (sum, observation) => sum + observation.value / observations.length,\n 0,\n )\n }\n if (reduction === 'max') return Math.max(...observations.map((observation) => observation.value))\n return observations.reduce((a, b) => (b.capturedAt > a.capturedAt ? b : a)).value\n}\n\nexport function hasVariation(values: readonly number[]): boolean {\n return values.some((value) => value !== values[0])\n}\n\nexport function correlationSummary(\n xs: number[],\n ys: number[],\n iterations: number,\n seed: number | undefined,\n): {\n pearson: number\n spearman: number\n pearsonCi95: CorrelationInterval | null\n spearmanCi95: CorrelationInterval | null\n} {\n const rng = makeRng(seed, xs, ys)\n const pearsons: number[] = []\n const spearmans: number[] = []\n for (let b = 0; b < iterations; b++) {\n const rx: number[] = []\n const ry: number[] = []\n for (let i = 0; i < xs.length; i++) {\n const index = Math.floor(rng() * xs.length)\n rx.push(xs[index]!)\n ry.push(ys[index]!)\n }\n // A constant resample has no estimable correlation, even when both sides agree.\n if (!hasVariation(rx) || !hasVariation(ry)) continue\n const pearson = pearsonR(rx, ry)\n const spearman = spearmanR(rx, ry)\n if (Number.isFinite(pearson)) pearsons.push(pearson)\n if (Number.isFinite(spearman)) spearmans.push(spearman)\n }\n return {\n pearson: pearsonR(xs, ys),\n spearman: spearmanR(xs, ys),\n pearsonCi95: interval(pearsons),\n spearmanCi95: interval(spearmans),\n }\n}\n\nexport function validateObservationOptions(\n reduction: OutcomeReduction,\n iterations: number,\n seed: number | undefined,\n): void {\n if (!['latest', 'mean', 'max'].includes(reduction)) {\n throw new Error('outcome reduction must be latest, mean, or max')\n }\n if (!Number.isSafeInteger(iterations) || iterations < 1) {\n throw new Error('bootstrap iterations must be a positive safe integer')\n }\n if (seed !== undefined && !Number.isFinite(seed)) {\n throw new Error('bootstrap seed must be finite')\n }\n}\n\nexport function assertUniqueObservationIds(ids: readonly string[], name: string): void {\n if (ids.some((id) => typeof id !== 'string' || id.trim().length === 0)) {\n throw new Error(`${name} must be a nonempty string`)\n }\n if (new Set(ids).size !== ids.length) throw new Error(`duplicate ${name} in outcome study`)\n}\n\nexport function validateOutcomeMetricSpecifications(\n metrics: readonly { id: string; direction: string }[],\n): void {\n if (!Array.isArray(metrics) || metrics.length === 0) {\n throw new Error('outcomeMetrics must declare at least one outcome metric and direction')\n }\n for (const metric of metrics) {\n if (!metric || typeof metric.id !== 'string' || metric.id.trim().length === 0) {\n throw new Error('each outcome metric must have a nonempty id and explicit direction')\n }\n if (metric.direction !== 'higher-is-better' && metric.direction !== 'lower-is-better') {\n throw new Error(\n `outcome metric ${metric.id} must declare higher-is-better or lower-is-better`,\n )\n }\n }\n assertUniqueObservationIds(\n metrics.map((metric) => metric.id),\n 'outcome metric',\n )\n}\n\nfunction interval(values: number[]): CorrelationInterval | null {\n if (values.length === 0) return null\n values.sort((a, b) => a - b)\n return {\n lower: Math.max(-1, values[Math.floor(0.025 * values.length)]!),\n upper: Math.min(1, values[Math.min(values.length - 1, Math.floor(0.975 * values.length))]!),\n }\n}\n"],"mappings":";;;;AAYA,SAAgB,oBACd,UACA,QACA,WACe;CACf,MAAM,eAAe,SAAS,SAAS,YAAY;EACjD,MAAM,QAAQ,QAAQ,QAAQ;EAC9B,OAAO,OAAO,SAAS,QAAQ,UAAU,KACvC,OAAO,UAAU,YACjB,OAAO,SAAS,KAAK,IACnB,CAAC;GAAE,YAAY,QAAQ;GAAY;EAAM,CAAC,IAC1C,CAAC;CACP,CAAC;CACD,IAAI,aAAa,WAAW,GAAG,OAAO;CACtC,IAAI,cAAc,QAChB,OAAO,aAAa,QACjB,KAAK,gBAAgB,MAAM,YAAY,QAAQ,aAAa,QAC7D,CACF;CAEF,IAAI,cAAc,OAAO,OAAO,KAAK,IAAI,GAAG,aAAa,KAAK,gBAAgB,YAAY,KAAK,CAAC;CAChG,OAAO,aAAa,QAAQ,GAAG,MAAO,EAAE,aAAa,EAAE,aAAa,IAAI,CAAE,CAAC,CAAC;AAC9E;AAEA,SAAgB,aAAa,QAAoC;CAC/D,OAAO,OAAO,MAAM,UAAU,UAAU,OAAO,EAA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ACnE,MAAM,IAAI,MAAM,GAAG,KAAK,2BAA2B;CAErD,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,QAAQ,MAAM,IAAI,MAAM,aAAa,KAAK,kBAAkB;AAC5F;AAEA,SAAgB,oCACd,SACM;CACN,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,GAChD,MAAM,IAAI,MAAM,uEAAuE;CAEzF,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,CAAC,UAAU,OAAO,OAAO,OAAO,YAAY,OAAO,GAAG,KAAK,CAAC,CAAC,WAAW,GAC1E,MAAM,IAAI,MAAM,oEAAoE;EAEtF,IAAI,OAAO,cAAc,sBAAsB,OAAO,cAAc,mBAClE,MAAM,IAAI,MACR,kBAAkB,OAAO,GAAG,kDAC9B;CAEJ;CACA,2BACE,QAAQ,KAAK,WAAW,OAAO,EAAE,GACjC,gBACF;AACF;AAEA,SAAS,SAAS,QAA8C;CAC9D,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,OAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAC3B,OAAO;EACL,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,OAAQ,OAAO,MAAM,EAAG;EAC9D,OAAO,KAAK,IAAI,GAAG,OAAO,KAAK,IAAI,OAAO,SAAS,GAAG,KAAK,MAAM,OAAQ,OAAO,MAAM,CAAC,EAAG;CAC5F;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { s as ValidationError } from "./errors-DeEEV9Vx.js";
|
|
2
|
-
import { a as findingTreatmentSchema } from "./finding-composition-
|
|
3
|
-
import {
|
|
4
|
-
import { r as pairedRiskDifference, t as mcnemar } from "./paired-binary-
|
|
5
|
-
import { r as pairedBootstrap } from "./paired-tests-
|
|
2
|
+
import { a as findingTreatmentSchema } from "./finding-composition-Belh_qU3.js";
|
|
3
|
+
import { a as assertFiniteSample, d as symmetricTwoSampleSeed, h as lnGamma, l as makeRng, s as binomialSignTwoSided } from "./mean-D1d6gedE.js";
|
|
4
|
+
import { r as pairedRiskDifference, t as mcnemar } from "./paired-binary-CMzmSSd5.js";
|
|
5
|
+
import { r as pairedBootstrap } from "./paired-tests-Buh6feJ4.js";
|
|
6
6
|
// src/arm-populations.ts
|
|
7
7
|
const keyOf = (row) => JSON.stringify([
|
|
8
8
|
row.arm,
|
|
@@ -737,4 +737,4 @@ function metricValue(row, name) {
|
|
|
737
737
|
}
|
|
738
738
|
export { wilcoxonSignedRank as a, mannWhitneyU as i, pairArms as n, normalCdf as o, pairRunRecords as r, comparePairedArms as t };
|
|
739
739
|
|
|
740
|
-
//# sourceMappingURL=paired-arms-
|
|
740
|
+
//# sourceMappingURL=paired-arms-3-tsXvvC.js.map
|