@tangle-network/agent-eval 0.200.0 → 0.201.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/adapters/http.d.ts +7 -8
- package/dist/adapters/http.d.ts.map +1 -1
- package/dist/adapters/http.js +2 -2
- package/dist/adapters/http.js.map +1 -1
- package/dist/agent-profile-DDfIjdyS.d.ts.map +1 -1
- package/dist/analyst/index.d.ts +76 -76
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +6 -6
- package/dist/{analyze-runs-DFbp2gB8.js → analyze-runs-BrIibNd0.js} +47 -42
- package/dist/{analyze-runs-DFbp2gB8.js.map → analyze-runs-BrIibNd0.js.map} +1 -1
- package/dist/{ast-CP9ae9B0.js → ast-DJ6Bc7ab.js} +5 -4
- package/dist/{ast-CP9ae9B0.js.map → ast-DJ6Bc7ab.js.map} +1 -1
- package/dist/authenticity/index.d.ts +14 -15
- package/dist/authenticity/index.d.ts.map +1 -1
- package/dist/{baseline-BC-eBZ7U.js → baseline-CVKsfWTg.js} +2 -2
- package/dist/{baseline-BC-eBZ7U.js.map → baseline-CVKsfWTg.js.map} +1 -1
- package/dist/{benchmark-BeQJyrRC.js → benchmark-BywPeAUo.js} +4 -3
- package/dist/{benchmark-BeQJyrRC.js.map → benchmark-BywPeAUo.js.map} +1 -1
- package/dist/{benchmark-command-EBmuMUBo.js → benchmark-command-DFs_i62N.js} +24 -23
- package/dist/{benchmark-command-EBmuMUBo.js.map → benchmark-command-DFs_i62N.js.map} +1 -1
- package/dist/benchmarks/index.d.ts +12 -12
- package/dist/benchmarks/index.d.ts.map +1 -1
- package/dist/benchmarks/index.js +3 -3
- package/dist/{bounded-process-BBZob7vl.js → bounded-process-Cj9YjXbE.js} +3 -3
- package/dist/{bounded-process-BBZob7vl.js.map → bounded-process-Cj9YjXbE.js.map} +1 -1
- package/dist/builder-eval/index.d.ts +16 -17
- package/dist/builder-eval/index.d.ts.map +1 -1
- package/dist/builder-eval/index.js +12 -10
- package/dist/builder-eval/index.js.map +1 -1
- package/dist/campaign/index.js +11 -11
- package/dist/{campaign-L391bmir.js → campaign-PmTWZi72.js} +30 -25
- package/dist/{campaign-L391bmir.js.map → campaign-PmTWZi72.js.map} +1 -1
- package/dist/{campaign-evidence-jL_U7Ikv.js → campaign-evidence-Dt_rWPk2.js} +4 -4
- package/dist/{campaign-evidence-jL_U7Ikv.js.map → campaign-evidence-Dt_rWPk2.js.map} +1 -1
- package/dist/{chat-client-CJORSG_J.js → chat-client-DUhWNQQS.js} +5 -4
- package/dist/{chat-client-CJORSG_J.js.map → chat-client-DUhWNQQS.js.map} +1 -1
- package/dist/{chat-json-call-DnlDjpco.js → chat-json-call-Dx_sHzqm.js} +2 -2
- package/dist/{chat-json-call-DnlDjpco.js.map → chat-json-call-Dx_sHzqm.js.map} +1 -1
- package/dist/{claim-V9Zqbq0J.js → claim-BXcZw-jo.js} +2 -2
- package/dist/{claim-V9Zqbq0J.js.map → claim-BXcZw-jo.js.map} +1 -1
- package/dist/cli.js +12 -11
- package/dist/cli.js.map +1 -1
- package/dist/contract/index.js +22 -19
- package/dist/contract/index.js.map +1 -1
- package/dist/{default-registry-xMLX160E.js → default-registry-D4qXx2aG.js} +2 -2
- package/dist/{default-registry-xMLX160E.js.map → default-registry-D4qXx2aG.js.map} +1 -1
- package/dist/define-agent-eval-1YuvJpOs.d.ts.map +1 -1
- package/dist/{define-agent-eval-7q_UwsTt.js → define-agent-eval-CJN9dTQw.js} +10 -9
- package/dist/{define-agent-eval-7q_UwsTt.js.map → define-agent-eval-CJN9dTQw.js.map} +1 -1
- package/dist/{descriptive-1V17A-qa.js → descriptive-D9LUFk1-.js} +2 -2
- package/dist/{descriptive-1V17A-qa.js.map → descriptive-D9LUFk1-.js.map} +1 -1
- package/dist/diagnosis/index.d.ts +7 -7
- package/dist/diagnosis/index.d.ts.map +1 -1
- package/dist/diagnosis/index.js +2 -2
- package/dist/diagnosis/index.js.map +1 -1
- package/dist/{dspy-rlm-engine-B5T43BkZ.js → dspy-rlm-engine-US8YsYGq.js} +5 -5
- package/dist/{dspy-rlm-engine-B5T43BkZ.js.map → dspy-rlm-engine-US8YsYGq.js.map} +1 -1
- package/dist/{eval-campaign-GapmPHIA.js → eval-campaign-ha_aWtk7.js} +14 -12
- package/dist/{eval-campaign-GapmPHIA.js.map → eval-campaign-ha_aWtk7.js.map} +1 -1
- package/dist/evaluation.d.ts +9 -10
- package/dist/evaluation.d.ts.map +1 -1
- package/dist/experiment/index.d.ts +29 -29
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/experiment/index.js +13 -12
- package/dist/experiment/index.js.map +1 -1
- package/dist/{exporters-DEcXbvgO.js → exporters-Coiv-qO2.js} +2 -2
- package/dist/{exporters-DEcXbvgO.js.map → exporters-Coiv-qO2.js.map} +1 -1
- package/dist/{external-optimizer-process-CEXcCKqd.js → external-optimizer-process-KLcw0Vnc.js} +2 -2
- package/dist/{external-optimizer-process-CEXcCKqd.js.map → external-optimizer-process-KLcw0Vnc.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-laM1-UDV.js → external-optimizer-subprocess-CkyUUV7h.js} +4 -4
- package/dist/{external-optimizer-subprocess-laM1-UDV.js.map → external-optimizer-subprocess-CkyUUV7h.js.map} +1 -1
- package/dist/fuzz.d.ts +15 -15
- package/dist/fuzz.d.ts.map +1 -1
- package/dist/{hf-dataset-CRqtSjnR.js → hf-dataset-kjIfIK_e.js} +3 -3
- package/dist/{hf-dataset-CRqtSjnR.js.map → hf-dataset-kjIfIK_e.js.map} +1 -1
- package/dist/hosted/index.d.ts +8 -8
- package/dist/hosted/index.d.ts.map +1 -1
- package/dist/hosted/index.js +1 -1
- package/dist/{index-D4pC7Tvd2.d.ts → index-D4pC7Tvd.d.ts} +1 -1
- package/dist/index-D4pC7Tvd.d.ts.map +1 -0
- package/dist/index-DKmrHA02.d.ts.map +1 -1
- package/dist/{index-DNgf5gyG2.d.ts → index-DNgf5gyG.d.ts} +1 -1
- package/dist/index-DNgf5gyG.d.ts.map +1 -0
- package/dist/index.d.ts +124 -124
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -42
- package/dist/index.js.map +1 -1
- package/dist/{integrity-BFP4kjGj.js → integrity-BvnVARVl.js} +30 -29
- package/dist/{integrity-BFP4kjGj.js.map → integrity-BvnVARVl.js.map} +1 -1
- package/dist/{integrity-BvHANvnp.js → integrity-uwK7XC-8.js} +2 -2
- package/dist/{integrity-BvHANvnp.js.map → integrity-uwK7XC-8.js.map} +1 -1
- package/dist/{internal-BMFSR8Ns.js → internal-BOe3zmjQ.js} +2 -2
- package/dist/{internal-BMFSR8Ns.js.map → internal-BOe3zmjQ.js.map} +1 -1
- package/dist/{jev-review-Cu9xtIu4.js → jev-review-DZEjDzlF.js} +7 -5
- package/dist/{jev-review-Cu9xtIu4.js.map → jev-review-DZEjDzlF.js.map} +1 -1
- package/dist/jev.d.ts +10 -10
- package/dist/jev.d.ts.map +1 -1
- package/dist/jev.js +2 -2
- package/dist/{judge-calibration-DYmaBtJr.js → judge-calibration-C5zgtiJT.js} +2 -2
- package/dist/{judge-calibration-DYmaBtJr.js.map → judge-calibration-C5zgtiJT.js.map} +1 -1
- package/dist/kind-factory-CdPPHtGZ.js.map +1 -1
- package/dist/{llm-client-c_bKHTXz.js → llm-client-Bhqoglar.js} +6 -4
- package/dist/{llm-client-c_bKHTXz.js.map → llm-client-Bhqoglar.js.map} +1 -1
- package/dist/{llm-judge-CL6f3utD.js → llm-judge-C-0P1WiT.js} +26 -21
- package/dist/{llm-judge-CL6f3utD.js.map → llm-judge-C-0P1WiT.js.map} +1 -1
- package/dist/matrix/index.d.ts +1 -1
- package/dist/matrix/index.js +1 -1
- package/dist/{matrix-_NLSWsKM.d.ts → matrix--IZKROxD.d.ts} +2 -2
- package/dist/{matrix-_NLSWsKM.d.ts.map → matrix--IZKROxD.d.ts.map} +1 -1
- package/dist/{matrix-pWinRMPl.js → matrix-DnlHn5x1.js} +8 -6
- package/dist/{matrix-pWinRMPl.js.map → matrix-DnlHn5x1.js.map} +1 -1
- package/dist/meta-eval/index.d.ts +55 -55
- package/dist/meta-eval/index.d.ts.map +1 -1
- package/dist/meta-eval/index.js +4 -4
- package/dist/{mint-iCD-W43s.js → mint-vlRckJEX.js} +2 -2
- package/dist/{mint-iCD-W43s.js.map → mint-vlRckJEX.js.map} +1 -1
- package/dist/multishot/golden/index.d.ts +23 -23
- package/dist/multishot/golden/index.d.ts.map +1 -1
- package/dist/multishot/golden/index.js +1 -1
- package/dist/multishot/index.d.ts +9 -9
- package/dist/multishot/index.d.ts.map +1 -1
- package/dist/multishot/index.js +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{otel-spans-CQmSxtcS.js → otel-spans-C8YIJWy1.js} +9 -4
- package/dist/{otel-spans-CQmSxtcS.js.map → otel-spans-C8YIJWy1.js.map} +1 -1
- package/dist/{outcome-store-BXlkwMPR.js → outcome-store-DUcMj-3D.js} +2 -2
- package/dist/{outcome-store-BXlkwMPR.js.map → outcome-store-DUcMj-3D.js.map} +1 -1
- package/dist/package-version-D7lQHt_-.js.map +1 -1
- package/dist/{paired-arms-DKZFVPt8.js → paired-arms-DpS_h8ON.js} +8 -5
- package/dist/{paired-arms-DKZFVPt8.js.map → paired-arms-DpS_h8ON.js.map} +1 -1
- package/dist/{paired-binary-fzkwENI4.js → paired-binary-OMBVRtc-.js} +2 -2
- package/dist/{paired-binary-fzkwENI4.js.map → paired-binary-OMBVRtc-.js.map} +1 -1
- package/dist/{paired-promotion-decision-D5B1Cxc2.js → paired-promotion-decision-DhrmjdV8.js} +5 -4
- package/dist/{paired-promotion-decision-D5B1Cxc2.js.map → paired-promotion-decision-DhrmjdV8.js.map} +1 -1
- package/dist/{paired-tests-C8iCsioC.js → paired-tests-Ccr16gcW.js} +3 -3
- package/dist/{paired-tests-C8iCsioC.js.map → paired-tests-Ccr16gcW.js.map} +1 -1
- package/dist/pipelines/index.d.ts +19 -19
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js +5 -4
- package/dist/pipelines/index.js.map +1 -1
- package/dist/{power-and-mde-K_CmO3dc.js → power-and-mde-bie6i965.js} +9 -6
- package/dist/{power-and-mde-K_CmO3dc.js.map → power-and-mde-bie6i965.js.map} +1 -1
- package/dist/{produced-state-DZMW8cuF.js → produced-state-CR2tAPLf.js} +8 -5
- package/dist/{produced-state-DZMW8cuF.js.map → produced-state-CR2tAPLf.js.map} +1 -1
- package/dist/{promotion-policy-C6FAJvmZ.js → promotion-policy-BI1RxzwD.js} +4 -4
- package/dist/{promotion-policy-C6FAJvmZ.js.map → promotion-policy-BI1RxzwD.js.map} +1 -1
- package/dist/{raw-provider-sink-CXuOhLvT.js → raw-provider-sink-rB2DYxr6.js} +2 -2
- package/dist/{raw-provider-sink-CXuOhLvT.js.map → raw-provider-sink-rB2DYxr6.js.map} +1 -1
- package/dist/{release-confidence-XQm_xjhR.js → release-confidence-CiFg1EPq.js} +3 -2
- package/dist/{release-confidence-XQm_xjhR.js.map → release-confidence-CiFg1EPq.js.map} +1 -1
- package/dist/{report-command-DKJ_yAIj.js → report-command-DzPpFgjB.js} +20 -18
- package/dist/{report-command-DKJ_yAIj.js.map → report-command-DzPpFgjB.js.map} +1 -1
- package/dist/reporting.js +5 -5
- package/dist/{reward-hacking-D0XwhVWE.js → reward-hacking-C-a__ShZ.js} +5 -3
- package/dist/{reward-hacking-D0XwhVWE.js.map → reward-hacking-C-a__ShZ.js.map} +1 -1
- package/dist/rl.d.ts +199 -202
- package/dist/rl.d.ts.map +1 -1
- package/dist/rl.js +48 -49
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +1 -1
- package/dist/rollout/index.js +5 -5
- package/dist/{rollout-B-XBReTC.js → rollout-BUQixCoc.js} +5 -5
- package/dist/{rollout-B-XBReTC.js.map → rollout-BUQixCoc.js.map} +1 -1
- package/dist/{rubric-predictive-validity-CCK-1B7w.js → rubric-predictive-validity-B0Pg-3I5.js} +3 -3
- package/dist/{rubric-predictive-validity-CCK-1B7w.js.map → rubric-predictive-validity-B0Pg-3I5.js.map} +1 -1
- package/dist/{run-record-tNnlQIrD.js → run-record-BB290Y9A.js} +5 -3
- package/dist/{run-record-tNnlQIrD.js.map → run-record-BB290Y9A.js.map} +1 -1
- package/dist/{schema-C1aaAxTf.js → schema-DAMp77zB.js} +24 -20
- package/dist/{schema-C1aaAxTf.js.map → schema-DAMp77zB.js.map} +1 -1
- package/dist/search/index.d.ts +34 -34
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-AVgIjXaI.js → search-kernel-Dpniloks.js} +33 -26
- package/dist/{search-kernel-AVgIjXaI.js.map → search-kernel-Dpniloks.js.map} +1 -1
- package/dist/{search-ledger-CL0-mXQ8.js → search-ledger-CXQPwdWz.js} +4 -3
- package/dist/{search-ledger-CL0-mXQ8.js.map → search-ledger-CXQPwdWz.js.map} +1 -1
- package/dist/{search-shipper-Cs6K4km9.js → search-shipper-DhhofkDX.js} +3 -6
- package/dist/{search-shipper-Cs6K4km9.js.map → search-shipper-DhhofkDX.js.map} +1 -1
- package/dist/{search-summary-DvWk0hb3.js → search-summary-C1nAHgkB.js} +4 -4
- package/dist/{search-summary-DvWk0hb3.js.map → search-summary-C1nAHgkB.js.map} +1 -1
- package/dist/{semantic-concept-judge-2SE_kXGF.js → semantic-concept-judge-BcjYg37z.js} +4 -4
- package/dist/{semantic-concept-judge-2SE_kXGF.js.map → semantic-concept-judge-BcjYg37z.js.map} +1 -1
- package/dist/{sequential-Yz3OSskl.js → sequential-DWn_np6P.js} +2 -3
- package/dist/{sequential-Yz3OSskl.js.map → sequential-DWn_np6P.js.map} +1 -1
- package/dist/{server-D56r1lhp.js → server-B4jMhqQn.js} +2 -2
- package/dist/{server-D56r1lhp.js.map → server-B4jMhqQn.js.map} +1 -1
- package/dist/{skillopt-optimization-method-B2syNik0.js → skillopt-optimization-method-Bls9t-G_.js} +9 -9
- package/dist/{skillopt-optimization-method-B2syNik0.js.map → skillopt-optimization-method-Bls9t-G_.js.map} +1 -1
- package/dist/{statistical-heldout-BAFDCo07.js → statistical-heldout-CNLOvRq_.js} +3 -3
- package/dist/{statistical-heldout-BAFDCo07.js.map → statistical-heldout-CNLOvRq_.js.map} +1 -1
- package/dist/statistical-heldout-HswMvzbP.d.ts.map +1 -1
- package/dist/{store-DNe_Uv1Q.js → store-BhNuLdJw.js} +3 -5
- package/dist/{store-DNe_Uv1Q.js.map → store-BhNuLdJw.js.map} +1 -1
- package/dist/store-C4avFjIi.d.ts.map +1 -1
- package/dist/{store-otlp-BPowgPm6.js → store-otlp-yd9lDziN.js} +2 -2
- package/dist/{store-otlp-BPowgPm6.js.map → store-otlp-yd9lDziN.js.map} +1 -1
- package/dist/{store-tool-spans-BaGakFc2.js → store-tool-spans-Biio4_Nw.js} +4 -4
- package/dist/{store-tool-spans-BaGakFc2.js.map → store-tool-spans-Biio4_Nw.js.map} +1 -1
- package/dist/storyboard/index.d.ts +20 -21
- package/dist/storyboard/index.d.ts.map +1 -1
- package/dist/{student-t-BA-Uy51p.js → student-t-BBZYka0E.js} +4 -3
- package/dist/{student-t-BA-Uy51p.js.map → student-t-BBZYka0E.js.map} +1 -1
- package/dist/{summary-report-BeYnvddy.js → summary-report-DLzptLSA.js} +8 -7
- package/dist/{summary-report-BeYnvddy.js.map → summary-report-DLzptLSA.js.map} +1 -1
- package/dist/supervisor-run/index.d.ts +25 -25
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +2 -2
- package/dist/{tool-waste-CJDfxH45.js → tool-waste-B-u3rzCz.js} +11 -6
- package/dist/{tool-waste-CJDfxH45.js.map → tool-waste-B-u3rzCz.js.map} +1 -1
- package/dist/trace-repair/index.d.ts +96 -96
- package/dist/trace-repair/index.d.ts.map +1 -1
- package/dist/trace-repair/index.js +1 -1
- package/dist/trace-repair/index.js.map +1 -1
- package/dist/traces.d.ts +29 -29
- package/dist/traces.d.ts.map +1 -1
- package/dist/traces.js +9 -7
- package/dist/traces.js.map +1 -1
- package/dist/trajectory-replay/index.d.ts +35 -35
- package/dist/trajectory-replay/index.d.ts.map +1 -1
- package/dist/trajectory-replay/index.js +5 -5
- package/dist/trajectory-replay/index.js.map +1 -1
- package/dist/{tree-Ki_gW7z8.js → tree-D48IJUK0.js} +39 -31
- package/dist/{tree-Ki_gW7z8.js.map → tree-D48IJUK0.js.map} +1 -1
- package/dist/wire/index.d.ts +48 -48
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +1 -1
- package/docs/jev-behavior-review.md +4 -3
- package/package.json +18 -36
- package/dist/index-D4pC7Tvd2.d.ts.map +0 -1
- package/dist/index-DNgf5gyG2.d.ts.map +0 -1
package/dist/matrix/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { p as CostProvenance } from "../cost-ledger-DbQdN3nO.js";
|
|
2
2
|
import { t as DefaultVerdict } from "../verdict-E4eRNf7-.js";
|
|
3
|
-
import { a as MatrixCell, c as CellSpend, i as MatrixAxis, l as readCellSpend, n as AxisSummary, o as MatrixResult, r as CellResult, s as RunAgentMatrixOptions, t as runAgentMatrix, u as withCellSpend } from "../index-
|
|
3
|
+
import { a as MatrixCell, c as CellSpend, i as MatrixAxis, l as readCellSpend, n as AxisSummary, o as MatrixResult, r as CellResult, s as RunAgentMatrixOptions, t as runAgentMatrix, u as withCellSpend } from "../index-DNgf5gyG.js";
|
|
4
4
|
export { type AxisSummary, type CellResult, type CellSpend, type CostProvenance, type DefaultVerdict, type MatrixAxis, type MatrixCell, type MatrixResult, type RunAgentMatrixOptions, readCellSpend, runAgentMatrix, withCellSpend };
|
package/dist/matrix/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as readCellSpend, r as withCellSpend, t as runAgentMatrix } from "../matrix-
|
|
1
|
+
import { n as readCellSpend, r as withCellSpend, t as runAgentMatrix } from "../matrix-DnlHn5x1.js";
|
|
2
2
|
export { readCellSpend, runAgentMatrix, withCellSpend };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as CostProvenance } from "./cost-ledger-DbQdN3nO.js";
|
|
2
2
|
import { w as JudgeScore } from "./types-DfvQOe91.js";
|
|
3
|
-
import { o as MatrixResult } from "./index-
|
|
3
|
+
import { o as MatrixResult } from "./index-DNgf5gyG.js";
|
|
4
4
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
5
5
|
//#region src/multishot/types.d.ts
|
|
6
6
|
interface MultishotMessage {
|
|
@@ -398,4 +398,4 @@ interface RunMultishotMatrixResult {
|
|
|
398
398
|
declare function runMultishotMatrix<TPersona extends MultishotPersona>(opts: RunMultishotMatrixOptions<TPersona>): Promise<RunMultishotMatrixResult>;
|
|
399
399
|
//#endregion
|
|
400
400
|
export { MultishotToolExecutor as A, MultishotFatalToolError as C, MultishotShape as D, MultishotResult as E, assertMultishotShotResult as F, MultishotTransportRequest as M, MultishotTransportResponse as N, MultishotShotResultError as O, MultishotTransportToolCall as P, MultishotDriverEmptyError as S, MultishotPersona as T, JudgeRunResult as _, MultishotCellOutput as a, runJudge as b, RunMultishotMatrixResult as c, MultishotShot as d, RunMultishotOptions as f, JudgeDimension as g, JudgeConfig as h, ConversationJudgeInput as i, MultishotTransport as j, MultishotToolDefinition 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, renderDimensions as v, MultishotMessage as w, MultishotArtifact as x, renderJsonFooter as y };
|
|
401
|
-
//# sourceMappingURL=matrix
|
|
401
|
+
//# sourceMappingURL=matrix--IZKROxD.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix
|
|
1
|
+
{"version":3,"file":"matrix--IZKROxD.d.ts","names":[],"sources":["../src/multishot/types.ts","../src/multishot/judges.ts","../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
|
};
|
|
371
|
-
if (opts.signal)
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
371
|
+
if (opts.signal) {
|
|
372
|
+
if (opts.signal.aborted) {
|
|
373
|
+
cellsUnscheduled = planned.length;
|
|
374
|
+
cursor = planned.length;
|
|
375
|
+
resolveAll?.();
|
|
376
|
+
} else opts.signal.addEventListener("abort", onAbort, { once: true });
|
|
377
|
+
}
|
|
376
378
|
if (planned.length === 0) resolveAll?.();
|
|
377
379
|
else pump();
|
|
378
380
|
await done;
|
|
@@ -409,4 +411,4 @@ async function runAgentMatrix(opts) {
|
|
|
409
411
|
//#endregion
|
|
410
412
|
export { readCellSpend as n, withCellSpend as r, runAgentMatrix as t };
|
|
411
413
|
|
|
412
|
-
//# sourceMappingURL=matrix-
|
|
414
|
+
//# sourceMappingURL=matrix-DnlHn5x1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix-pWinRMPl.js","names":[],"sources":["../src/matrix/cell-spend.ts","../src/matrix/aggregation.ts","../src/matrix/runner.ts"],"sourcesContent":["/**\n * Spend carrier for a cell that fails after it has already spent money.\n *\n * `runCell` reports what a cell cost by returning a `CellResult`. A throw\n * carries no result, so the runner cannot know what the cell spent before it\n * failed: the cumulative sum the cost ceiling reads, and `totalCostUsd`, both\n * miss that money. A throw that carries a `CellSpend` closes the gap — the\n * runner bills the failed cell for the spend the carrier declares, and records\n * a cell that declared nothing as `uncaptured` instead of a zero that reads\n * like \"this cell spent nothing\".\n *\n * The carrier is read structurally, never by `instanceof`, so a throw that\n * crosses a package or realm boundary still bills.\n */\n\n/** Property key the carrier occupies on a thrown object. Stable across\n * versions — two copies of this package must agree on it. */\nconst CELL_SPEND_KEY = '__agentEvalCellSpend'\n\n/** Money and wall time a cell consumed before it threw. */\nexport interface CellSpend {\n /** KNOWN subtotal in USD. When `kind` is `uncaptured` the cell spent this\n * much AND an unknown amount more, so the value must not be read as the\n * cell's total. */\n costUsd: number\n /** Wall time the cell consumed before the throw, in milliseconds. */\n durationMs: number\n /** `observed` = provider-reported amounts, `estimated` = computed from token\n * prices, `uncaptured` = `costUsd` is a subtotal and part of the spend\n * could not be measured. */\n kind: 'observed' | 'estimated' | 'uncaptured'\n}\n\n/**\n * Return `error` carrying `spend`, for a throw site inside `runCell`:\n * `throw withCellSpend(err, { costUsd, durationMs, kind })`.\n *\n * A value that cannot hold the carrier — a thrown string or number, or a\n * frozen, sealed, or otherwise non-extensible object — is wrapped in an\n * `Error` that keeps the original as `cause`, so the spend is never dropped.\n * A later call overwrites an earlier carrier — the outer frame knows more\n * than the inner one.\n *\n * Throws `TypeError` on a non-finite or negative amount. A poisoned amount\n * would reach `cumulativeCost` and disable the cost ceiling for the whole run,\n * because `NaN >= ceiling` is false.\n */\nexport function withCellSpend(error: unknown, spend: CellSpend): unknown {\n assertAmount(spend.costUsd, 'costUsd')\n assertAmount(spend.durationMs, 'durationMs')\n if (spend.kind !== 'observed' && spend.kind !== 'estimated' && spend.kind !== 'uncaptured') {\n throw new TypeError(\n `withCellSpend: kind must be observed, estimated or uncaptured, received ${String(spend.kind)}`,\n )\n }\n const carrier: CellSpend = {\n costUsd: spend.costUsd,\n durationMs: spend.durationMs,\n kind: spend.kind,\n }\n if (typeof error === 'object' && error !== null && attach(error, carrier)) return error\n // A primitive cannot hold a property, and a frozen or sealed object refuses\n // one. Carry the spend on a fresh Error that keeps the original as `cause`\n // rather than lose it — a dropped carrier bills the cell as uncaptured,\n // which is the under-billing this module exists to prevent.\n const wrapper = new Error(`cell failed: ${messageOf(error)}`, { cause: error })\n attach(wrapper, carrier)\n return wrapper\n}\n\n/** True when the carrier landed. `defineProperty` throws on a non-extensible\n * target, so the caller must be able to fall back. */\nfunction attach(target: object, carrier: CellSpend): boolean {\n try {\n Object.defineProperty(target, CELL_SPEND_KEY, {\n value: carrier,\n enumerable: false,\n configurable: true,\n writable: true,\n })\n return true\n } catch {\n return false\n }\n}\n\nfunction messageOf(error: unknown): string {\n if (error instanceof Error) return error.message\n return String(error)\n}\n\n/** Read the spend a thrown value carries. `undefined` when the value carries\n * none, or carries one that does not satisfy `CellSpend` — the runner records\n * both as `uncaptured`. */\nexport function readCellSpend(error: unknown): CellSpend | undefined {\n if (typeof error !== 'object' || error === null) return undefined\n const raw = (error as Record<string, unknown>)[CELL_SPEND_KEY]\n if (typeof raw !== 'object' || raw === null) return undefined\n const candidate = raw as Record<string, unknown>\n if (!isAmount(candidate.costUsd) || !isAmount(candidate.durationMs)) return undefined\n const kind = candidate.kind\n if (kind !== 'observed' && kind !== 'estimated' && kind !== 'uncaptured') return undefined\n return { costUsd: candidate.costUsd, durationMs: candidate.durationMs, kind }\n}\n\n/** A number the matrix can add to a running cost or duration: finite and not\n * negative. Anything else would poison a sum the cost ceiling reads. */\nexport function isAmount(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0\n}\n\nfunction assertAmount(value: number, field: string): void {\n if (!isAmount(value)) {\n throw new TypeError(\n `withCellSpend: ${field} must be a finite number >= 0, received ${String(value)}`,\n )\n }\n}\n","/**\n * Per-axis aggregation of cell runs into `AxisSummary` rows.\n *\n * Pure: consumes the final `cells: [{cell, runs}]` array and returns the\n * `byAxis` table. Error runs contribute 0 to passRate and meanScore. Cost and\n * duration always count — the budget was spent regardless. A run whose cost is\n * a subtotal rather than a total raises `costUncapturedCells` for its bucket,\n * so a per-axis cost row says when it under-counts.\n */\n\nimport type { AxisSummary, CellResult, MatrixAxis, MatrixCell, MatrixResult } from './types'\n\ninterface Row<Output> {\n cell: MatrixCell\n result: CellResult<Output>\n}\n\nfunction flattenRuns<Output>(cells: MatrixResult<Output>['cells']): Row<Output>[] {\n const rows: Row<Output>[] = []\n for (const { cell, runs } of cells) {\n for (const result of runs) rows.push({ cell, result })\n }\n return rows\n}\n\nfunction quantile(sorted: number[], q: number): number {\n if (sorted.length === 0) return 0\n if (sorted.length === 1) return sorted[0] as number\n const pos = (sorted.length - 1) * q\n const lo = Math.floor(pos)\n const hi = Math.ceil(pos)\n if (lo === hi) return sorted[lo] as number\n const frac = pos - lo\n return (sorted[lo] as number) * (1 - frac) + (sorted[hi] as number) * frac\n}\n\nexport function summariseRows<Output>(\n rows: Row<Output>[],\n axisName: string,\n axisValue: string,\n): AxisSummary {\n if (rows.length === 0) {\n return {\n axisName,\n axisValue,\n cells: 0,\n passRate: 0,\n meanScore: 0,\n p50Score: 0,\n p90Score: 0,\n totalCostUsd: 0,\n costUncapturedCells: 0,\n meanDurationMs: 0,\n }\n }\n let pass = 0\n let scoreSum = 0\n let costSum = 0\n let durSum = 0\n let costUncapturedCells = 0\n const scores: number[] = []\n for (const { result } of rows) {\n const errored = result.error !== undefined\n const score = errored ? 0 : result.verdict.score\n const valid = !errored && result.verdict.valid\n if (valid) pass++\n scoreSum += score\n scores.push(score)\n costSum += result.costUsd\n durSum += result.durationMs\n if (result.costProvenance?.kind === 'uncaptured') costUncapturedCells++\n }\n scores.sort((a, b) => a - b)\n return {\n axisName,\n axisValue,\n cells: rows.length,\n passRate: pass / rows.length,\n meanScore: scoreSum / rows.length,\n p50Score: quantile(scores, 0.5),\n p90Score: quantile(scores, 0.9),\n totalCostUsd: costSum,\n costUncapturedCells,\n meanDurationMs: durSum / rows.length,\n }\n}\n\nfunction bucketBy<Output>(\n rows: Row<Output>[],\n axisName: string,\n labelFor: (id: string) => string,\n): Record<string, AxisSummary> {\n const buckets = new Map<string, Row<Output>[]>()\n for (const row of rows) {\n const slot = row.cell.axes[axisName]\n if (!slot) continue\n const id = slot.id\n let arr = buckets.get(id)\n if (!arr) {\n arr = []\n buckets.set(id, arr)\n }\n arr.push(row)\n }\n const out: Record<string, AxisSummary> = {}\n // Sorted keys for deterministic JSON serialisation.\n for (const id of [...buckets.keys()].sort()) {\n out[id] = summariseRows(buckets.get(id) as Row<Output>[], axisName, labelFor(id))\n }\n return out\n}\n\nexport function buildByAxis<Output>(\n cells: MatrixResult<Output>['cells'],\n axes: MatrixAxis<unknown>[],\n aggregateBy: string[],\n): Record<string, Record<string, AxisSummary>> {\n const rows = flattenRuns(cells)\n const byName = new Map(axes.map((a) => [a.name, a]))\n const byAxis: Record<string, Record<string, AxisSummary>> = {}\n for (const name of aggregateBy) {\n const axis = byName.get(name)\n const labelFor = (id: string): string => {\n if (!axis?.label) return id\n const found = axis.values.find((v) => v.id === id)\n if (!found) return id\n return axis.label(found.value, id)\n }\n byAxis[name] = bucketBy(rows, name, labelFor)\n }\n return byAxis\n}\n","/**\n * N-axis cartesian runner.\n *\n * Expansion order: cartesian over `axes` in declared order, then `reps` as the\n * inner-most dim → `ordinal = (cartIdx * reps) + rep`. The returned\n * `cells[]` is sorted by `ordinal` so concurrent execution does not reorder\n * the output.\n *\n * Scheduling is a sliding window of in-flight promises capped at\n * `maxConcurrency`. The window stops admitting new cells when the cost\n * ceiling trips or the abort signal fires; in-flight cells finish.\n */\n\nimport { buildByAxis } from './aggregation'\nimport { isAmount, readCellSpend } from './cell-spend'\nimport type {\n CellResult,\n CostProvenance,\n MatrixAxis,\n MatrixCell,\n MatrixResult,\n RunAgentMatrixOptions,\n} from './types'\n\ninterface BaseCell {\n axes: Record<string, { id: string; value: unknown }>\n}\n\nfunction cartesian(axes: MatrixAxis<unknown>[]): BaseCell[] {\n // Empty axes (`values=[]`) collapse the whole product to zero cells. An\n // empty `axes` array yields a single empty-axes cell — degenerate but\n // valid (caller is iterating only reps).\n if (axes.length === 0) return [{ axes: {} }]\n for (const a of axes) if (a.values.length === 0) return []\n const out: BaseCell[] = []\n const idx = new Array(axes.length).fill(0)\n while (true) {\n const slot: Record<string, { id: string; value: unknown }> = {}\n for (let i = 0; i < axes.length; i++) {\n const axis = axes[i] as MatrixAxis<unknown>\n const v = axis.values[idx[i] as number] as { id: string; value: unknown }\n slot[axis.name] = { id: v.id, value: v.value }\n }\n out.push({ axes: slot })\n // Increment like an odometer, left-most axis is fastest.\n let i = 0\n while (i < axes.length) {\n const next = (idx[i] as number) + 1\n const axis = axes[i] as MatrixAxis<unknown>\n if (next < axis.values.length) {\n idx[i] = next\n break\n }\n idx[i] = 0\n i++\n }\n if (i === axes.length) break\n }\n return out\n}\n\nfunction makeMatrixId(): string {\n // Stable id-like string: time + 8 random hex chars. Avoids node:crypto\n // import to keep the matrix dep-free.\n const t = Date.now().toString(36)\n let r = ''\n for (let i = 0; i < 8; i++) r += Math.floor(Math.random() * 16).toString(16)\n return `mtx_${t}_${r}`\n}\n\n/** Fresh per result — a shared object would let one consumer's mutation reach\n * every other cell in the run. */\nfunction uncaptured(): CostProvenance {\n return { kind: 'uncaptured', usd: null }\n}\n\nfunction makeErrorResult<Output>(err: unknown): CellResult<Output> {\n const e = err as { message?: string; name?: string }\n const spend = readCellSpend(err)\n return {\n output: undefined as unknown as Output,\n verdict: { valid: false, score: 0 },\n costUsd: spend?.costUsd ?? 0,\n durationMs: spend?.durationMs ?? 0,\n costProvenance:\n spend === undefined || spend.kind === 'uncaptured'\n ? uncaptured()\n : { kind: spend.kind, usd: spend.costUsd },\n error: {\n message: typeof e?.message === 'string' ? e.message : String(err),\n kind: typeof e?.name === 'string' ? e.name : 'Error',\n },\n }\n}\n\n/** Make a result safe to sum.\n *\n * A `costUsd` that cannot be summed fails the cell: `NaN` in `cumulativeCost`\n * makes `>= costCeiling` false forever, so one bad cell would disable the\n * ceiling for every cell after it.\n *\n * A bad `durationMs` reaches only `meanDurationMs`, never the ceiling, so it\n * cannot justify throwing away a real verdict and a real cost. It is reported\n * as 0 and warned about, and the rest of the result stands. A wall clock that\n * steps back mid-cell makes `Date.now() - startedAt` negative, so this is a\n * reachable state, not only a caller bug. */\nfunction billableResult<Output>(\n result: CellResult<Output>,\n onBadDuration: (reported: unknown) => void,\n): CellResult<Output> {\n if (!isAmount(result.costUsd)) {\n return makeErrorResult<Output>(\n new RangeError(\n `runCell reported costUsd=${String(result.costUsd)}; a cell cost must be a finite number >= 0 so the cost ceiling stays enforceable`,\n ),\n )\n }\n if (isAmount(result.durationMs)) return result\n onBadDuration(result.durationMs)\n return { ...result, durationMs: 0 }\n}\n\nexport async function runAgentMatrix<Output>(\n opts: RunAgentMatrixOptions<Output>,\n): Promise<MatrixResult<Output>> {\n const startedAt = Date.now()\n const reps = Math.max(1, opts.reps ?? 1)\n const maxConcurrency = Math.max(1, opts.maxConcurrency ?? 4)\n const costCeiling = opts.costCeiling ?? Number.POSITIVE_INFINITY\n const aggregateBy = opts.aggregateBy ?? opts.axes.map((a) => a.name)\n if (opts.maxCellCostUsd !== undefined && !isAmount(opts.maxCellCostUsd)) {\n throw new RangeError(\n `runAgentMatrix: maxCellCostUsd must be a finite number >= 0, received ${String(opts.maxCellCostUsd)}`,\n )\n }\n\n const base = cartesian(opts.axes)\n const filtered = opts.filter\n ? base.filter((c) => (opts.filter as (b: BaseCell) => boolean)(c))\n : base\n const filteredOut = base.length - filtered.length\n\n const planned: MatrixCell[] = []\n for (let i = 0; i < filtered.length; i++) {\n for (let r = 0; r < reps; r++) {\n planned.push({\n axes: (filtered[i] as BaseCell).axes,\n rep: r,\n ordinal: i * reps + r,\n })\n }\n }\n\n const cellRecords: Array<{ cell: MatrixCell; runs: CellResult<Output>[] }> = []\n // What the ceiling reads. It runs ahead of the reported total whenever a\n // cell's cost is a subtotal and `maxCellCostUsd` bounds what it could have\n // been — a budget must assume the worst about spend it cannot see.\n let cumulativeCost = 0\n let costCeilingReached = false\n let runsExecuted = 0\n let cellsUnscheduled = 0\n let costUncapturedCells = 0\n let badDurationCells = 0\n\n const aborted = (): boolean => opts.signal?.aborted === true\n\n // Per-run abort controller forwards the external signal so cell executors\n // see cancellation. We don't expose it on `MatrixCell` — the signature on\n // `runCell` per the public API is `(cell) => Promise<...>`. Executors that\n // need cancellation use the external signal directly via closure.\n\n let inFlight = 0\n let cursor = 0\n let resolveAll: (() => void) | undefined\n const done = new Promise<void>((res) => {\n resolveAll = res\n })\n\n const pump = (): void => {\n while (inFlight < maxConcurrency && cursor < planned.length) {\n if (aborted() || costCeilingReached) {\n // Drain remaining as unscheduled.\n const left = planned.length - cursor\n cellsUnscheduled += left\n cursor = planned.length\n break\n }\n const cell = planned[cursor++] as MatrixCell\n inFlight++\n // Lazily allocate the record so cells appear in `cells[]` in any\n // arrival order; we sort by ordinal at the end.\n const record = { cell, runs: [] as CellResult<Output>[] }\n cellRecords.push(record)\n const promise: Promise<CellResult<Output>> = (async () => {\n try {\n return await opts.runCell(cell)\n } catch (err) {\n return makeErrorResult<Output>(err)\n }\n })()\n promise.then((settled) => {\n const result = billableResult(settled, (reported) => {\n badDurationCells++\n if (badDurationCells === 1) {\n // eslint-disable-next-line no-console\n console.warn(\n `[matrix] a cell reported durationMs=${String(reported)}; recorded as 0 — meanDurationMs under-reports this run`,\n )\n }\n })\n record.runs.push(result)\n runsExecuted++\n const uncapturedCost = result.costProvenance?.kind === 'uncaptured'\n cumulativeCost +=\n uncapturedCost && opts.maxCellCostUsd !== undefined\n ? Math.max(result.costUsd, opts.maxCellCostUsd)\n : result.costUsd\n if (uncapturedCost) {\n costUncapturedCells++\n if (costUncapturedCells === 1) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[matrix] a cell's cost is a subtotal, not a total — totalCostUsd and the cost ceiling under-count this run\",\n )\n }\n }\n if (cumulativeCost >= costCeiling && !costCeilingReached) {\n costCeilingReached = true\n // eslint-disable-next-line no-console\n console.warn('[matrix] cost ceiling reached')\n }\n try {\n opts.onCellComplete?.(cell, result)\n } catch {\n // onCellComplete is observational — swallow throws so a noisy\n // callback can't tank the run.\n }\n inFlight--\n if (cursor < planned.length) {\n pump()\n } else if (inFlight === 0) {\n resolveAll?.()\n }\n })\n }\n if (cursor >= planned.length && inFlight === 0) resolveAll?.()\n }\n\n const onAbort = (): void => {\n // External abort: stop scheduling. In-flight cells finish; their\n // executors observe `opts.signal.aborted` directly via closure.\n if (cursor < planned.length) {\n cellsUnscheduled += planned.length - cursor\n cursor = planned.length\n }\n if (inFlight === 0) resolveAll?.()\n }\n if (opts.signal) {\n if (opts.signal.aborted) {\n cellsUnscheduled = planned.length\n cursor = planned.length\n resolveAll?.()\n } else {\n opts.signal.addEventListener('abort', onAbort, { once: true })\n }\n }\n\n if (planned.length === 0) {\n resolveAll?.()\n } else {\n pump()\n }\n\n await done\n if (opts.signal) opts.signal.removeEventListener('abort', onAbort)\n\n cellRecords.sort((a, b) => a.cell.ordinal - b.cell.ordinal)\n\n let pass = 0\n let scoreSum = 0\n let totalCost = 0\n let runCount = 0\n for (const { runs } of cellRecords) {\n for (const r of runs) {\n runCount++\n const errored = r.error !== undefined\n if (!errored && r.verdict.valid) pass++\n scoreSum += errored ? 0 : r.verdict.score\n totalCost += r.costUsd\n }\n }\n\n const byAxis = buildByAxis(cellRecords, opts.axes, aggregateBy)\n\n return {\n cells: cellRecords,\n byAxis,\n summary: {\n totalCells: planned.length,\n runsExecuted,\n cellsSkipped: cellsUnscheduled + filteredOut * reps,\n overallPassRate: runCount === 0 ? 0 : pass / runCount,\n overallMeanScore: runCount === 0 ? 0 : scoreSum / runCount,\n totalCostUsd: totalCost,\n costUncapturedCells,\n ceilingChargedUsd: cumulativeCost,\n durationMs: Date.now() - startedAt,\n },\n matrixId: makeMatrixId(),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,iBAAiB;;;;;;;;;;;;;;;AA8BvB,SAAgB,cAAc,OAAgB,OAA2B;CACvE,aAAa,MAAM,SAAS,SAAS;CACrC,aAAa,MAAM,YAAY,YAAY;CAC3C,IAAI,MAAM,SAAS,cAAc,MAAM,SAAS,eAAe,MAAM,SAAS,cAC5E,MAAM,IAAI,UACR,2EAA2E,OAAO,MAAM,IAAI,GAC9F;CAEF,MAAM,UAAqB;EACzB,SAAS,MAAM;EACf,YAAY,MAAM;EAClB,MAAM,MAAM;CACd;CACA,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,OAAO,OAAO,GAAG,OAAO;CAKlF,MAAM,UAAU,IAAI,MAAM,gBAAgB,UAAU,KAAK,KAAK,EAAE,OAAO,MAAM,CAAC;CAC9E,OA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,SAAS,QAAQ;EACnB;EACA,IAAI,aAAa,GAAG,aAAa;CACnC;CACA,IAAI,KAAK,QACP,IAAI,KAAK,OAAO,SAAS;EACvB,mBAAmB,QAAQ;EAC3B,SAAS,QAAQ;EACjB,aAAa;CACf,OACE,KAAK,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;CAIjE,IAAI,QAAQ,WAAW,GACrB,aAAa;MAEb,KAAK;CAGP,MAAM;CACN,IAAI,KAAK,QAAQ,KAAK,OAAO,oBAAoB,SAAS,OAAO;CAEjE,YAAY,MAAM,GAAG,MAAM,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO;CAE1D,IAAI,OAAO;CACX,IAAI,WAAW;CACf,IAAI,YAAY;CAChB,IAAI,WAAW;CACf,KAAK,MAAM,EAAE,UAAU,aACrB,KAAK,MAAM,KAAK,MAAM;EACpB;EACA,MAAM,UAAU,EAAE,UAAU,KAAA;EAC5B,IAAI,CAAC,WAAW,EAAE,QAAQ,OAAO;EACjC,YAAY,UAAU,IAAI,EAAE,QAAQ;EACpC,aAAa,EAAE;CACjB;CAKF,OAAO;EACL,OAAO;EACP,QAJa,YAAY,aAAa,KAAK,MAAM,WAI5C;EACL,SAAS;GACP,YAAY,QAAQ;GACpB;GACA,cAAc,mBAAmB,cAAc;GAC/C,iBAAiB,aAAa,IAAI,IAAI,OAAO;GAC7C,kBAAkB,aAAa,IAAI,IAAI,WAAW;GAClD,cAAc;GACd;GACA,mBAAmB;GACnB,YAAY,KAAK,IAAI,IAAI;EAC3B;EACA,UAAU,aAAa;CACzB;AACF"}
|
|
1
|
+
{"version":3,"file":"matrix-DnlHn5x1.js","names":[],"sources":["../src/matrix/cell-spend.ts","../src/matrix/aggregation.ts","../src/matrix/runner.ts"],"sourcesContent":["/**\n * Spend carrier for a cell that fails after it has already spent money.\n *\n * `runCell` reports what a cell cost by returning a `CellResult`. A throw\n * carries no result, so the runner cannot know what the cell spent before it\n * failed: the cumulative sum the cost ceiling reads, and `totalCostUsd`, both\n * miss that money. A throw that carries a `CellSpend` closes the gap — the\n * runner bills the failed cell for the spend the carrier declares, and records\n * a cell that declared nothing as `uncaptured` instead of a zero that reads\n * like \"this cell spent nothing\".\n *\n * The carrier is read structurally, never by `instanceof`, so a throw that\n * crosses a package or realm boundary still bills.\n */\n\n/** Property key the carrier occupies on a thrown object. Stable across\n * versions — two copies of this package must agree on it. */\nconst CELL_SPEND_KEY = '__agentEvalCellSpend'\n\n/** Money and wall time a cell consumed before it threw. */\nexport interface CellSpend {\n /** KNOWN subtotal in USD. When `kind` is `uncaptured` the cell spent this\n * much AND an unknown amount more, so the value must not be read as the\n * cell's total. */\n costUsd: number\n /** Wall time the cell consumed before the throw, in milliseconds. */\n durationMs: number\n /** `observed` = provider-reported amounts, `estimated` = computed from token\n * prices, `uncaptured` = `costUsd` is a subtotal and part of the spend\n * could not be measured. */\n kind: 'observed' | 'estimated' | 'uncaptured'\n}\n\n/**\n * Return `error` carrying `spend`, for a throw site inside `runCell`:\n * `throw withCellSpend(err, { costUsd, durationMs, kind })`.\n *\n * A value that cannot hold the carrier — a thrown string or number, or a\n * frozen, sealed, or otherwise non-extensible object — is wrapped in an\n * `Error` that keeps the original as `cause`, so the spend is never dropped.\n * A later call overwrites an earlier carrier — the outer frame knows more\n * than the inner one.\n *\n * Throws `TypeError` on a non-finite or negative amount. A poisoned amount\n * would reach `cumulativeCost` and disable the cost ceiling for the whole run,\n * because `NaN >= ceiling` is false.\n */\nexport function withCellSpend(error: unknown, spend: CellSpend): unknown {\n assertAmount(spend.costUsd, 'costUsd')\n assertAmount(spend.durationMs, 'durationMs')\n if (spend.kind !== 'observed' && spend.kind !== 'estimated' && spend.kind !== 'uncaptured') {\n throw new TypeError(\n `withCellSpend: kind must be observed, estimated or uncaptured, received ${String(spend.kind)}`,\n )\n }\n const carrier: CellSpend = {\n costUsd: spend.costUsd,\n durationMs: spend.durationMs,\n kind: spend.kind,\n }\n if (typeof error === 'object' && error !== null && attach(error, carrier)) return error\n // A primitive cannot hold a property, and a frozen or sealed object refuses\n // one. Carry the spend on a fresh Error that keeps the original as `cause`\n // rather than lose it — a dropped carrier bills the cell as uncaptured,\n // which is the under-billing this module exists to prevent.\n const wrapper = new Error(`cell failed: ${messageOf(error)}`, { cause: error })\n attach(wrapper, carrier)\n return wrapper\n}\n\n/** True when the carrier landed. `defineProperty` throws on a non-extensible\n * target, so the caller must be able to fall back. */\nfunction attach(target: object, carrier: CellSpend): boolean {\n try {\n Object.defineProperty(target, CELL_SPEND_KEY, {\n value: carrier,\n enumerable: false,\n configurable: true,\n writable: true,\n })\n return true\n } catch {\n return false\n }\n}\n\nfunction messageOf(error: unknown): string {\n if (error instanceof Error) return error.message\n return String(error)\n}\n\n/** Read the spend a thrown value carries. `undefined` when the value carries\n * none, or carries one that does not satisfy `CellSpend` — the runner records\n * both as `uncaptured`. */\nexport function readCellSpend(error: unknown): CellSpend | undefined {\n if (typeof error !== 'object' || error === null) return undefined\n const raw = (error as Record<string, unknown>)[CELL_SPEND_KEY]\n if (typeof raw !== 'object' || raw === null) return undefined\n const candidate = raw as Record<string, unknown>\n if (!isAmount(candidate.costUsd) || !isAmount(candidate.durationMs)) return undefined\n const kind = candidate.kind\n if (kind !== 'observed' && kind !== 'estimated' && kind !== 'uncaptured') return undefined\n return { costUsd: candidate.costUsd, durationMs: candidate.durationMs, kind }\n}\n\n/** A number the matrix can add to a running cost or duration: finite and not\n * negative. Anything else would poison a sum the cost ceiling reads. */\nexport function isAmount(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0\n}\n\nfunction assertAmount(value: number, field: string): void {\n if (!isAmount(value)) {\n throw new TypeError(\n `withCellSpend: ${field} must be a finite number >= 0, received ${String(value)}`,\n )\n }\n}\n","/**\n * Per-axis aggregation of cell runs into `AxisSummary` rows.\n *\n * Pure: consumes the final `cells: [{cell, runs}]` array and returns the\n * `byAxis` table. Error runs contribute 0 to passRate and meanScore. Cost and\n * duration always count — the budget was spent regardless. A run whose cost is\n * a subtotal rather than a total raises `costUncapturedCells` for its bucket,\n * so a per-axis cost row says when it under-counts.\n */\n\nimport type { AxisSummary, CellResult, MatrixAxis, MatrixCell, MatrixResult } from './types'\n\ninterface Row<Output> {\n cell: MatrixCell\n result: CellResult<Output>\n}\n\nfunction flattenRuns<Output>(cells: MatrixResult<Output>['cells']): Row<Output>[] {\n const rows: Row<Output>[] = []\n for (const { cell, runs } of cells) {\n for (const result of runs) rows.push({ cell, result })\n }\n return rows\n}\n\nfunction quantile(sorted: number[], q: number): number {\n if (sorted.length === 0) return 0\n if (sorted.length === 1) return sorted[0] as number\n const pos = (sorted.length - 1) * q\n const lo = Math.floor(pos)\n const hi = Math.ceil(pos)\n if (lo === hi) return sorted[lo] as number\n const frac = pos - lo\n return (sorted[lo] as number) * (1 - frac) + (sorted[hi] as number) * frac\n}\n\nexport function summariseRows<Output>(\n rows: Row<Output>[],\n axisName: string,\n axisValue: string,\n): AxisSummary {\n if (rows.length === 0) {\n return {\n axisName,\n axisValue,\n cells: 0,\n passRate: 0,\n meanScore: 0,\n p50Score: 0,\n p90Score: 0,\n totalCostUsd: 0,\n costUncapturedCells: 0,\n meanDurationMs: 0,\n }\n }\n let pass = 0\n let scoreSum = 0\n let costSum = 0\n let durSum = 0\n let costUncapturedCells = 0\n const scores: number[] = []\n for (const { result } of rows) {\n const errored = result.error !== undefined\n const score = errored ? 0 : result.verdict.score\n const valid = !errored && result.verdict.valid\n if (valid) pass++\n scoreSum += score\n scores.push(score)\n costSum += result.costUsd\n durSum += result.durationMs\n if (result.costProvenance?.kind === 'uncaptured') costUncapturedCells++\n }\n scores.sort((a, b) => a - b)\n return {\n axisName,\n axisValue,\n cells: rows.length,\n passRate: pass / rows.length,\n meanScore: scoreSum / rows.length,\n p50Score: quantile(scores, 0.5),\n p90Score: quantile(scores, 0.9),\n totalCostUsd: costSum,\n costUncapturedCells,\n meanDurationMs: durSum / rows.length,\n }\n}\n\nfunction bucketBy<Output>(\n rows: Row<Output>[],\n axisName: string,\n labelFor: (id: string) => string,\n): Record<string, AxisSummary> {\n const buckets = new Map<string, Row<Output>[]>()\n for (const row of rows) {\n const slot = row.cell.axes[axisName]\n if (!slot) continue\n const id = slot.id\n let arr = buckets.get(id)\n if (!arr) {\n arr = []\n buckets.set(id, arr)\n }\n arr.push(row)\n }\n const out: Record<string, AxisSummary> = {}\n // Sorted keys for deterministic JSON serialisation.\n for (const id of [...buckets.keys()].sort()) {\n out[id] = summariseRows(buckets.get(id) as Row<Output>[], axisName, labelFor(id))\n }\n return out\n}\n\nexport function buildByAxis<Output>(\n cells: MatrixResult<Output>['cells'],\n axes: MatrixAxis<unknown>[],\n aggregateBy: string[],\n): Record<string, Record<string, AxisSummary>> {\n const rows = flattenRuns(cells)\n const byName = new Map(axes.map((a) => [a.name, a]))\n const byAxis: Record<string, Record<string, AxisSummary>> = {}\n for (const name of aggregateBy) {\n const axis = byName.get(name)\n const labelFor = (id: string): string => {\n if (!axis?.label) return id\n const found = axis.values.find((v) => v.id === id)\n if (!found) return id\n return axis.label(found.value, id)\n }\n byAxis[name] = bucketBy(rows, name, labelFor)\n }\n return byAxis\n}\n","/**\n * N-axis cartesian runner.\n *\n * Expansion order: cartesian over `axes` in declared order, then `reps` as the\n * inner-most dim → `ordinal = (cartIdx * reps) + rep`. The returned\n * `cells[]` is sorted by `ordinal` so concurrent execution does not reorder\n * the output.\n *\n * Scheduling is a sliding window of in-flight promises capped at\n * `maxConcurrency`. The window stops admitting new cells when the cost\n * ceiling trips or the abort signal fires; in-flight cells finish.\n */\n\nimport { buildByAxis } from './aggregation'\nimport { isAmount, readCellSpend } from './cell-spend'\nimport type {\n CellResult,\n CostProvenance,\n MatrixAxis,\n MatrixCell,\n MatrixResult,\n RunAgentMatrixOptions,\n} from './types'\n\ninterface BaseCell {\n axes: Record<string, { id: string; value: unknown }>\n}\n\nfunction cartesian(axes: MatrixAxis<unknown>[]): BaseCell[] {\n // Empty axes (`values=[]`) collapse the whole product to zero cells. An\n // empty `axes` array yields a single empty-axes cell — degenerate but\n // valid (caller is iterating only reps).\n if (axes.length === 0) return [{ axes: {} }]\n for (const a of axes) if (a.values.length === 0) return []\n const out: BaseCell[] = []\n const idx = new Array(axes.length).fill(0)\n while (true) {\n const slot: Record<string, { id: string; value: unknown }> = {}\n for (let i = 0; i < axes.length; i++) {\n const axis = axes[i] as MatrixAxis<unknown>\n const v = axis.values[idx[i] as number] as { id: string; value: unknown }\n slot[axis.name] = { id: v.id, value: v.value }\n }\n out.push({ axes: slot })\n // Increment like an odometer, left-most axis is fastest.\n let i = 0\n while (i < axes.length) {\n const next = (idx[i] as number) + 1\n const axis = axes[i] as MatrixAxis<unknown>\n if (next < axis.values.length) {\n idx[i] = next\n break\n }\n idx[i] = 0\n i++\n }\n if (i === axes.length) break\n }\n return out\n}\n\nfunction makeMatrixId(): string {\n // Stable id-like string: time + 8 random hex chars. Avoids node:crypto\n // import to keep the matrix dep-free.\n const t = Date.now().toString(36)\n let r = ''\n for (let i = 0; i < 8; i++) r += Math.floor(Math.random() * 16).toString(16)\n return `mtx_${t}_${r}`\n}\n\n/** Fresh per result — a shared object would let one consumer's mutation reach\n * every other cell in the run. */\nfunction uncaptured(): CostProvenance {\n return { kind: 'uncaptured', usd: null }\n}\n\nfunction makeErrorResult<Output>(err: unknown): CellResult<Output> {\n const e = err as { message?: string; name?: string }\n const spend = readCellSpend(err)\n return {\n output: undefined as unknown as Output,\n verdict: { valid: false, score: 0 },\n costUsd: spend?.costUsd ?? 0,\n durationMs: spend?.durationMs ?? 0,\n costProvenance:\n spend === undefined || spend.kind === 'uncaptured'\n ? uncaptured()\n : { kind: spend.kind, usd: spend.costUsd },\n error: {\n message: typeof e?.message === 'string' ? e.message : String(err),\n kind: typeof e?.name === 'string' ? e.name : 'Error',\n },\n }\n}\n\n/** Make a result safe to sum.\n *\n * A `costUsd` that cannot be summed fails the cell: `NaN` in `cumulativeCost`\n * makes `>= costCeiling` false forever, so one bad cell would disable the\n * ceiling for every cell after it.\n *\n * A bad `durationMs` reaches only `meanDurationMs`, never the ceiling, so it\n * cannot justify throwing away a real verdict and a real cost. It is reported\n * as 0 and warned about, and the rest of the result stands. A wall clock that\n * steps back mid-cell makes `Date.now() - startedAt` negative, so this is a\n * reachable state, not only a caller bug. */\nfunction billableResult<Output>(\n result: CellResult<Output>,\n onBadDuration: (reported: unknown) => void,\n): CellResult<Output> {\n if (!isAmount(result.costUsd)) {\n return makeErrorResult<Output>(\n new RangeError(\n `runCell reported costUsd=${String(result.costUsd)}; a cell cost must be a finite number >= 0 so the cost ceiling stays enforceable`,\n ),\n )\n }\n if (isAmount(result.durationMs)) return result\n onBadDuration(result.durationMs)\n return { ...result, durationMs: 0 }\n}\n\nexport async function runAgentMatrix<Output>(\n opts: RunAgentMatrixOptions<Output>,\n): Promise<MatrixResult<Output>> {\n const startedAt = Date.now()\n const reps = Math.max(1, opts.reps ?? 1)\n const maxConcurrency = Math.max(1, opts.maxConcurrency ?? 4)\n const costCeiling = opts.costCeiling ?? Number.POSITIVE_INFINITY\n const aggregateBy = opts.aggregateBy ?? opts.axes.map((a) => a.name)\n if (opts.maxCellCostUsd !== undefined && !isAmount(opts.maxCellCostUsd)) {\n throw new RangeError(\n `runAgentMatrix: maxCellCostUsd must be a finite number >= 0, received ${String(opts.maxCellCostUsd)}`,\n )\n }\n\n const base = cartesian(opts.axes)\n const filtered = opts.filter\n ? base.filter((c) => (opts.filter as (b: BaseCell) => boolean)(c))\n : base\n const filteredOut = base.length - filtered.length\n\n const planned: MatrixCell[] = []\n for (let i = 0; i < filtered.length; i++) {\n for (let r = 0; r < reps; r++) {\n planned.push({\n axes: (filtered[i] as BaseCell).axes,\n rep: r,\n ordinal: i * reps + r,\n })\n }\n }\n\n const cellRecords: Array<{ cell: MatrixCell; runs: CellResult<Output>[] }> = []\n // What the ceiling reads. It runs ahead of the reported total whenever a\n // cell's cost is a subtotal and `maxCellCostUsd` bounds what it could have\n // been — a budget must assume the worst about spend it cannot see.\n let cumulativeCost = 0\n let costCeilingReached = false\n let runsExecuted = 0\n let cellsUnscheduled = 0\n let costUncapturedCells = 0\n let badDurationCells = 0\n\n const aborted = (): boolean => opts.signal?.aborted === true\n\n // Per-run abort controller forwards the external signal so cell executors\n // see cancellation. We don't expose it on `MatrixCell` — the signature on\n // `runCell` per the public API is `(cell) => Promise<...>`. Executors that\n // need cancellation use the external signal directly via closure.\n\n let inFlight = 0\n let cursor = 0\n let resolveAll: (() => void) | undefined\n const done = new Promise<void>((res) => {\n resolveAll = res\n })\n\n const pump = (): void => {\n while (inFlight < maxConcurrency && cursor < planned.length) {\n if (aborted() || costCeilingReached) {\n // Drain remaining as unscheduled.\n const left = planned.length - cursor\n cellsUnscheduled += left\n cursor = planned.length\n break\n }\n const cell = planned[cursor++] as MatrixCell\n inFlight++\n // Lazily allocate the record so cells appear in `cells[]` in any\n // arrival order; we sort by ordinal at the end.\n const record = { cell, runs: [] as CellResult<Output>[] }\n cellRecords.push(record)\n const promise: Promise<CellResult<Output>> = (async () => {\n try {\n return await opts.runCell(cell)\n } catch (err) {\n return makeErrorResult<Output>(err)\n }\n })()\n promise.then((settled) => {\n const result = billableResult(settled, (reported) => {\n badDurationCells++\n if (badDurationCells === 1) {\n // eslint-disable-next-line no-console\n console.warn(\n `[matrix] a cell reported durationMs=${String(reported)}; recorded as 0 — meanDurationMs under-reports this run`,\n )\n }\n })\n record.runs.push(result)\n runsExecuted++\n const uncapturedCost = result.costProvenance?.kind === 'uncaptured'\n cumulativeCost +=\n uncapturedCost && opts.maxCellCostUsd !== undefined\n ? Math.max(result.costUsd, opts.maxCellCostUsd)\n : result.costUsd\n if (uncapturedCost) {\n costUncapturedCells++\n if (costUncapturedCells === 1) {\n // eslint-disable-next-line no-console\n console.warn(\n \"[matrix] a cell's cost is a subtotal, not a total — totalCostUsd and the cost ceiling under-count this run\",\n )\n }\n }\n if (cumulativeCost >= costCeiling && !costCeilingReached) {\n costCeilingReached = true\n // eslint-disable-next-line no-console\n console.warn('[matrix] cost ceiling reached')\n }\n try {\n opts.onCellComplete?.(cell, result)\n } catch {\n // onCellComplete is observational — swallow throws so a noisy\n // callback can't tank the run.\n }\n inFlight--\n if (cursor < planned.length) {\n pump()\n } else if (inFlight === 0) {\n resolveAll?.()\n }\n })\n }\n if (cursor >= planned.length && inFlight === 0) resolveAll?.()\n }\n\n const onAbort = (): void => {\n // External abort: stop scheduling. In-flight cells finish; their\n // executors observe `opts.signal.aborted` directly via closure.\n if (cursor < planned.length) {\n cellsUnscheduled += planned.length - cursor\n cursor = planned.length\n }\n if (inFlight === 0) resolveAll?.()\n }\n if (opts.signal) {\n if (opts.signal.aborted) {\n cellsUnscheduled = planned.length\n cursor = planned.length\n resolveAll?.()\n } else {\n opts.signal.addEventListener('abort', onAbort, { once: true })\n }\n }\n\n if (planned.length === 0) {\n resolveAll?.()\n } else {\n pump()\n }\n\n await done\n if (opts.signal) opts.signal.removeEventListener('abort', onAbort)\n\n cellRecords.sort((a, b) => a.cell.ordinal - b.cell.ordinal)\n\n let pass = 0\n let scoreSum = 0\n let totalCost = 0\n let runCount = 0\n for (const { runs } of cellRecords) {\n for (const r of runs) {\n runCount++\n const errored = r.error !== undefined\n if (!errored && r.verdict.valid) pass++\n scoreSum += errored ? 0 : r.verdict.score\n totalCost += r.costUsd\n }\n }\n\n const byAxis = buildByAxis(cellRecords, opts.axes, aggregateBy)\n\n return {\n cells: cellRecords,\n byAxis,\n summary: {\n totalCells: planned.length,\n runsExecuted,\n cellsSkipped: cellsUnscheduled + filteredOut * reps,\n overallPassRate: runCount === 0 ? 0 : pass / runCount,\n overallMeanScore: runCount === 0 ? 0 : scoreSum / runCount,\n totalCostUsd: totalCost,\n costUncapturedCells,\n ceilingChargedUsd: cumulativeCost,\n durationMs: Date.now() - startedAt,\n },\n matrixId: makeMatrixId(),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,iBAAiB;;;;;;;;;;;;;;;AA8BvB,SAAgB,cAAc,OAAgB,OAA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mBAAmB,cAAc;GAC/C,iBAAiB,aAAa,IAAI,IAAI,OAAO;GAC7C,kBAAkB,aAAa,IAAI,IAAI,WAAW;GAClD,cAAc;GACd;GACA,mBAAmB;GACnB,YAAY,KAAK,IAAI,IAAI;EAC3B;EACA,UAAU,aAAa;CACzB;AACF"}
|
|
@@ -8,17 +8,17 @@ import { a as ComputedInterval } from "../ast-hI-vjW6J.js";
|
|
|
8
8
|
import { a as RubricPredictiveValidityReport, c as CorrelationInterval, i as RubricPredictiveValidityInput, l as OutcomeReduction, n as RubricOutcomeExclusion, o as RubricRanking, r as RubricOutcomePair, s as rubricPredictiveValidity, t as OutcomeMetricSpec } from "../rubric-predictive-validity-DIUwJJ9Y.js";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
//#region src/meta-eval/correlation-study.d.ts
|
|
11
|
-
interface EvalMetricSpec {
|
|
11
|
+
export interface EvalMetricSpec {
|
|
12
12
|
id: string;
|
|
13
13
|
/** Extract a scalar from a run. Omit it and `id` must name one of
|
|
14
14
|
* `RUN_METRICS`; any other `id` is refused. */
|
|
15
15
|
extract?: (run: Run, store: TraceStore) => Promise<number | null>;
|
|
16
16
|
}
|
|
17
|
-
interface OutcomePair {
|
|
17
|
+
export interface OutcomePair {
|
|
18
18
|
evalMetric: string;
|
|
19
19
|
outcomeMetric: string;
|
|
20
20
|
}
|
|
21
|
-
interface CorrelationResult {
|
|
21
|
+
export interface CorrelationResult {
|
|
22
22
|
evalMetric: string;
|
|
23
23
|
outcomeMetric: string;
|
|
24
24
|
n: number;
|
|
@@ -37,7 +37,7 @@ interface CorrelationResult {
|
|
|
37
37
|
/** Rough verdict: 'strong' ≥ 0.7, 'moderate' ≥ 0.4, else 'weak'. */
|
|
38
38
|
verdict: 'strong' | 'moderate' | 'weak';
|
|
39
39
|
}
|
|
40
|
-
interface CorrelationStudyResult {
|
|
40
|
+
export interface CorrelationStudyResult {
|
|
41
41
|
pairs: CorrelationResult[];
|
|
42
42
|
/** Declared pairs without an estimable correlation, including their usable sample count. */
|
|
43
43
|
excludedPairs: Array<OutcomePair & {
|
|
@@ -47,7 +47,7 @@ interface CorrelationStudyResult {
|
|
|
47
47
|
joinedSamples: number;
|
|
48
48
|
skippedRuns: number;
|
|
49
49
|
}
|
|
50
|
-
interface CorrelationStudyOptions {
|
|
50
|
+
export interface CorrelationStudyOptions {
|
|
51
51
|
/** Only join outcomes captured within this window after run.startedAt. */
|
|
52
52
|
maxCaptureLagMs?: number;
|
|
53
53
|
/** Restrict to a subset of outcomes (cohort, region, source). */
|
|
@@ -60,10 +60,10 @@ interface CorrelationStudyOptions {
|
|
|
60
60
|
* paired observations, so the same study reproduces the same interval. */
|
|
61
61
|
seed?: number;
|
|
62
62
|
}
|
|
63
|
-
declare function correlationStudy(traceStore: TraceStore, outcomeStore: OutcomeStore, evalMetrics: EvalMetricSpec[], outcomeMetricNames: string[], options?: CorrelationStudyOptions): Promise<CorrelationStudyResult>;
|
|
63
|
+
export declare function correlationStudy(traceStore: TraceStore, outcomeStore: OutcomeStore, evalMetrics: EvalMetricSpec[], outcomeMetricNames: string[], options?: CorrelationStudyOptions): Promise<CorrelationStudyResult>;
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/meta-eval/calibration.d.ts
|
|
66
|
-
interface CalibrationBin {
|
|
66
|
+
export interface CalibrationBin {
|
|
67
67
|
lower: number;
|
|
68
68
|
upper: number;
|
|
69
69
|
n: number;
|
|
@@ -72,7 +72,7 @@ interface CalibrationBin {
|
|
|
72
72
|
/** |outcomeMean − evalMean|; contributes to ECE weighted by n/total. */
|
|
73
73
|
gap: number;
|
|
74
74
|
}
|
|
75
|
-
interface CalibrationReport {
|
|
75
|
+
export interface CalibrationReport {
|
|
76
76
|
evalMetric: string;
|
|
77
77
|
outcomeMetric: string;
|
|
78
78
|
n: number;
|
|
@@ -82,7 +82,7 @@ interface CalibrationReport {
|
|
|
82
82
|
/** Largest observed difference between a bin's mean score and mean outcome. */
|
|
83
83
|
maxGap: number;
|
|
84
84
|
}
|
|
85
|
-
interface CalibrationOptions {
|
|
85
|
+
export interface CalibrationOptions {
|
|
86
86
|
/** Positive integer; empty bins are omitted. Default 10. */
|
|
87
87
|
bins?: number;
|
|
88
88
|
/** Equal-width (fixed bin edges) or equal-frequency (quantile bins). */
|
|
@@ -93,13 +93,13 @@ interface CalibrationOptions {
|
|
|
93
93
|
hi: number;
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
interface CalibrationPair {
|
|
96
|
+
export interface CalibrationPair {
|
|
97
97
|
evalScore: number;
|
|
98
98
|
outcome: number;
|
|
99
99
|
}
|
|
100
|
-
declare function calibrationCurve(traceStore: TraceStore, outcomeStore: OutcomeStore, evalMetric: EvalMetricSpec, outcomeMetric: string, options?: CalibrationOptions): Promise<CalibrationReport | null>;
|
|
100
|
+
export declare function calibrationCurve(traceStore: TraceStore, outcomeStore: OutcomeStore, evalMetric: EvalMetricSpec, outcomeMetric: string, options?: CalibrationOptions): Promise<CalibrationReport | null>;
|
|
101
101
|
/** Measure already joined observations without constructing trace and outcome stores. */
|
|
102
|
-
declare function calibrationFromPairs(inputPairs: readonly CalibrationPair[], evalMetric: string, outcomeMetric: string, options?: CalibrationOptions): CalibrationReport | null;
|
|
102
|
+
export declare function calibrationFromPairs(inputPairs: readonly CalibrationPair[], evalMetric: string, outcomeMetric: string, options?: CalibrationOptions): CalibrationReport | null;
|
|
103
103
|
//#endregion
|
|
104
104
|
//#region src/meta-eval/evaluator-admission.d.ts
|
|
105
105
|
declare const policySchema: z.ZodObject<{
|
|
@@ -215,7 +215,7 @@ interface EvaluatorAdmissionReport {
|
|
|
215
215
|
* A unit fails a class when any control in that class is misjudged.
|
|
216
216
|
* The execution owner enforces auditor separation, fresh sampling, and evidence authenticity.
|
|
217
217
|
*/
|
|
218
|
-
declare function auditEvaluator(input: EvaluatorAuditInput): EvaluatorAdmissionReport;
|
|
218
|
+
export declare function auditEvaluator(input: EvaluatorAuditInput): EvaluatorAdmissionReport;
|
|
219
219
|
declare const probabilityAuditSchema: z.ZodObject<{
|
|
220
220
|
evaluatorDigest: z.ZodString;
|
|
221
221
|
population: z.ZodString;
|
|
@@ -267,7 +267,7 @@ interface ProbabilityPolicyAuditReport extends EvaluatorAdmissionReport {
|
|
|
267
267
|
* No threshold search, model calls, promotion, or assumption of calibrated probabilities.
|
|
268
268
|
* Null scores and the open interval between thresholds remain unknown, never correct by default.
|
|
269
269
|
*/
|
|
270
|
-
declare function auditProbabilityPolicy(input: ProbabilityPolicyAuditInput): ProbabilityPolicyAuditReport;
|
|
270
|
+
export declare function auditProbabilityPolicy(input: ProbabilityPolicyAuditInput): ProbabilityPolicyAuditReport;
|
|
271
271
|
//#endregion
|
|
272
272
|
//#region src/meta-eval/plants.d.ts
|
|
273
273
|
/**
|
|
@@ -275,7 +275,7 @@ declare function auditProbabilityPolicy(input: ProbabilityPolicyAuditInput): Pro
|
|
|
275
275
|
* {@link CatchRateReport.byKind} because a grader is routinely sharp on one
|
|
276
276
|
* and blind to another.
|
|
277
277
|
*/
|
|
278
|
-
type PlantKind =
|
|
278
|
+
export type PlantKind =
|
|
279
279
|
/** A load-bearing value is altered: a number off by one, a comparison flipped. */
|
|
280
280
|
'wrong-value' |
|
|
281
281
|
/** The item carries its own check, and that check passes without testing the claim. */
|
|
@@ -285,8 +285,8 @@ type PlantKind =
|
|
|
285
285
|
/** A copy of an item already in the set, which is owed a duplicate flag rather than a second grade. */
|
|
286
286
|
'duplicate';
|
|
287
287
|
/** What a working grader owes a seeded item. */
|
|
288
|
-
type PlantExpectation = 'reject' | 'accept';
|
|
289
|
-
interface Plant {
|
|
288
|
+
export type PlantExpectation = 'reject' | 'accept';
|
|
289
|
+
export interface Plant {
|
|
290
290
|
/** Name of the plant record. Reported in `missedIds` and `missingIds`. */
|
|
291
291
|
id: string;
|
|
292
292
|
kind: PlantKind;
|
|
@@ -307,7 +307,7 @@ interface Plant {
|
|
|
307
307
|
* cannot change what the manifest sealed, and `group` is dropped when it is
|
|
308
308
|
* absent so the record always has a canonical JSON form.
|
|
309
309
|
*/
|
|
310
|
-
declare function definePlant(input: {
|
|
310
|
+
export declare function definePlant(input: {
|
|
311
311
|
id: string;
|
|
312
312
|
kind: PlantKind;
|
|
313
313
|
item: GoldenItem;
|
|
@@ -317,17 +317,17 @@ declare function definePlant(input: {
|
|
|
317
317
|
* A claim's executable evidence: the command a grader runs and the output it
|
|
318
318
|
* must produce.
|
|
319
319
|
*/
|
|
320
|
-
interface PlantEvidence {
|
|
320
|
+
export interface PlantEvidence {
|
|
321
321
|
/** The command a grader runs to test the claim. */
|
|
322
322
|
check?: string;
|
|
323
323
|
/** The output that command must produce for the claim to stand. */
|
|
324
324
|
expect?: string;
|
|
325
325
|
}
|
|
326
326
|
/** Which evidence field {@link perturbEvidence} altered. */
|
|
327
|
-
type PerturbedField = 'check' | 'expect';
|
|
327
|
+
export type PerturbedField = 'check' | 'expect';
|
|
328
328
|
/** How {@link perturbEvidence} altered it. */
|
|
329
|
-
type PerturbationKind = 'number-off-by-one' | 'comparison-flipped';
|
|
330
|
-
interface EvidencePerturbation {
|
|
329
|
+
export type PerturbationKind = 'number-off-by-one' | 'comparison-flipped';
|
|
330
|
+
export interface EvidencePerturbation {
|
|
331
331
|
/** The evidence with exactly one value altered. */
|
|
332
332
|
evidence: PlantEvidence;
|
|
333
333
|
/** Which field changed. */
|
|
@@ -370,8 +370,8 @@ interface EvidencePerturbation {
|
|
|
370
370
|
* rounds back to itself, and the plant is then a correct claim the grader is
|
|
371
371
|
* right to verify.
|
|
372
372
|
*/
|
|
373
|
-
declare function perturbEvidence(evidence: PlantEvidence): EvidencePerturbation | null;
|
|
374
|
-
interface PerturbedPlant {
|
|
373
|
+
export declare function perturbEvidence(evidence: PlantEvidence): EvidencePerturbation | null;
|
|
374
|
+
export interface PerturbedPlant {
|
|
375
375
|
plant: Plant;
|
|
376
376
|
/** The perturbed evidence to write into the item the grader is handed. */
|
|
377
377
|
evidence: PlantEvidence;
|
|
@@ -400,7 +400,7 @@ interface PerturbedPlant {
|
|
|
400
400
|
* and in `missedIds`, the other in the join with the results — and a miss
|
|
401
401
|
* nobody can look up is not a measurement.
|
|
402
402
|
*/
|
|
403
|
-
declare function plantByPerturbation(input: {
|
|
403
|
+
export declare function plantByPerturbation(input: {
|
|
404
404
|
id: string;
|
|
405
405
|
itemId: string;
|
|
406
406
|
evidence: PlantEvidence;
|
|
@@ -408,7 +408,7 @@ declare function plantByPerturbation(input: {
|
|
|
408
408
|
humanScore?: number;
|
|
409
409
|
group?: string;
|
|
410
410
|
}): PerturbedPlant | null;
|
|
411
|
-
interface PlantManifest {
|
|
411
|
+
export interface PlantManifest {
|
|
412
412
|
/**
|
|
413
413
|
* Digest over the seeded order, the plants, and the threshold. Publish it
|
|
414
414
|
* before the grading run: a manifest edited afterwards to match the results
|
|
@@ -424,7 +424,7 @@ interface PlantManifest {
|
|
|
424
424
|
/** The seeded plants. This is the answer key; keep it out of the graded workspace. */
|
|
425
425
|
plants: Plant[];
|
|
426
426
|
}
|
|
427
|
-
interface SeededGradingSet {
|
|
427
|
+
export interface SeededGradingSet {
|
|
428
428
|
/**
|
|
429
429
|
* The mixed set in seeded order. Operator-side: it still carries every
|
|
430
430
|
* item's `humanScore`, so hand the graded policy the payload each `itemId`
|
|
@@ -433,7 +433,7 @@ interface SeededGradingSet {
|
|
|
433
433
|
items: GoldenItem[];
|
|
434
434
|
manifest: PlantManifest;
|
|
435
435
|
}
|
|
436
|
-
interface SeedPlantsOptions {
|
|
436
|
+
export interface SeedPlantsOptions {
|
|
437
437
|
/**
|
|
438
438
|
* Fixes the mix order. The same dataset, plants, threshold, and seed always
|
|
439
439
|
* produce the same seeded order and the same seal.
|
|
@@ -455,13 +455,13 @@ interface SeedPlantsOptions {
|
|
|
455
455
|
* dataset item with no usable label, and a plant whose expectation the run's
|
|
456
456
|
* `acceptThreshold` contradicts.
|
|
457
457
|
*/
|
|
458
|
-
declare function seedPlants(dataset: readonly GoldenItem[], plants: readonly Plant[], options?: SeedPlantsOptions): SeededGradingSet;
|
|
458
|
+
export declare function seedPlants(dataset: readonly GoldenItem[], plants: readonly Plant[], options?: SeedPlantsOptions): SeededGradingSet;
|
|
459
459
|
/**
|
|
460
460
|
* One grader outcome for one item. `score: null` says the grader ran and
|
|
461
461
|
* declined to decide — the check never tested the item's defect. Any
|
|
462
462
|
* `CandidateScore` from a judge run is already a valid outcome.
|
|
463
463
|
*/
|
|
464
|
-
interface PlantOutcome {
|
|
464
|
+
export interface PlantOutcome {
|
|
465
465
|
itemId: string;
|
|
466
466
|
score: number | null;
|
|
467
467
|
}
|
|
@@ -469,8 +469,8 @@ interface PlantOutcome {
|
|
|
469
469
|
* `evaluated` — a rate stands. `incomplete` — a seeded id had no result.
|
|
470
470
|
* `not_evaluated` — nothing was seeded, or nothing seeded was decided.
|
|
471
471
|
*/
|
|
472
|
-
type CatchRateStatus = 'evaluated' | 'incomplete' | 'not_evaluated';
|
|
473
|
-
interface PlantKindCounts {
|
|
472
|
+
export type CatchRateStatus = 'evaluated' | 'incomplete' | 'not_evaluated';
|
|
473
|
+
export interface PlantKindCounts {
|
|
474
474
|
seeded: number;
|
|
475
475
|
caught: number;
|
|
476
476
|
missed: number;
|
|
@@ -484,14 +484,14 @@ interface PlantKindCounts {
|
|
|
484
484
|
* on reject-plants, and a `rejectionRate` of 1.0 here is what separates that
|
|
485
485
|
* reflex from discrimination.
|
|
486
486
|
*/
|
|
487
|
-
interface UnseededRejection {
|
|
487
|
+
export interface UnseededRejection {
|
|
488
488
|
n: number;
|
|
489
489
|
decided: number;
|
|
490
490
|
rejected: number;
|
|
491
491
|
/** rejected / decided, or null when nothing unseeded was decided. */
|
|
492
492
|
rejectionRate: number | null;
|
|
493
493
|
}
|
|
494
|
-
interface CatchRateReport {
|
|
494
|
+
export interface CatchRateReport {
|
|
495
495
|
status: CatchRateStatus;
|
|
496
496
|
/** Why the status is not `evaluated`. Absent when it is. */
|
|
497
497
|
reason?: string;
|
|
@@ -521,12 +521,12 @@ interface CatchRateReport {
|
|
|
521
521
|
* the results and the manifest describe different runs, and a rate computed
|
|
522
522
|
* across two runs is a fabrication.
|
|
523
523
|
*/
|
|
524
|
-
declare function catchRate(results: readonly PlantOutcome[], manifest: PlantManifest): CatchRateReport;
|
|
524
|
+
export declare function catchRate(results: readonly PlantOutcome[], manifest: PlantManifest): CatchRateReport;
|
|
525
525
|
//#endregion
|
|
526
526
|
//#region src/meta-eval/sentinel.d.ts
|
|
527
527
|
declare const SENTINEL_METRIC_NAMES: readonly ['irr', 'calibrationKappa', 'sentinelPassRate'];
|
|
528
|
-
type SentinelMetricName = (typeof SENTINEL_METRIC_NAMES)[number];
|
|
529
|
-
interface SentinelMetrics {
|
|
528
|
+
export type SentinelMetricName = (typeof SENTINEL_METRIC_NAMES)[number];
|
|
529
|
+
export interface SentinelMetrics {
|
|
530
530
|
/** Inter-rater reliability — ICC(2,1) from agreement instruments. */
|
|
531
531
|
irr?: number;
|
|
532
532
|
/** Weighted κ vs the human golden set (`calibrateJudge*`). */
|
|
@@ -534,7 +534,7 @@ interface SentinelMetrics {
|
|
|
534
534
|
/** Fraction of a fixed sentinel golden set the judge still scores within tolerance. */
|
|
535
535
|
sentinelPassRate?: number;
|
|
536
536
|
}
|
|
537
|
-
interface SentinelSnapshot {
|
|
537
|
+
export interface SentinelSnapshot {
|
|
538
538
|
/** Caller-supplied ISO-8601 timestamp — the module never reads a clock. */
|
|
539
539
|
at: string;
|
|
540
540
|
judgeId: string;
|
|
@@ -549,19 +549,19 @@ interface SentinelSnapshot {
|
|
|
549
549
|
metrics: SentinelMetrics;
|
|
550
550
|
}
|
|
551
551
|
/** Identity + timestamp the caller supplies alongside an instrument output. */
|
|
552
|
-
interface SnapshotMeta {
|
|
552
|
+
export interface SnapshotMeta {
|
|
553
553
|
at: string;
|
|
554
554
|
judgeId: string;
|
|
555
555
|
judgeModel: string;
|
|
556
556
|
}
|
|
557
557
|
/** Shape guard for snapshots crossing a boundary (store append, JSONL load, report input). */
|
|
558
|
-
declare function validateSentinelSnapshot(snapshot: SentinelSnapshot, source?: string): void;
|
|
558
|
+
export declare function validateSentinelSnapshot(snapshot: SentinelSnapshot, source?: string): void;
|
|
559
559
|
/**
|
|
560
560
|
* From `calibrateJudge` / `calibrateJudgeContinuous` output. Prefers the
|
|
561
561
|
* un-rounded continuous κ_w when the report carries one (integer κ
|
|
562
562
|
* discards information for [0,1] judges).
|
|
563
563
|
*/
|
|
564
|
-
declare function snapshotFromCalibration(report: CalibrationResult | ContinuousCalibrationResult, meta: SnapshotMeta): SentinelSnapshot;
|
|
564
|
+
export declare function snapshotFromCalibration(report: CalibrationResult | ContinuousCalibrationResult, meta: SnapshotMeta): SentinelSnapshot;
|
|
565
565
|
/**
|
|
566
566
|
* From `corpusInterRaterAgreement` (statistics.ts) or `continuousAgreement`
|
|
567
567
|
* (judge-calibration.ts) output. IRR = ICC(2,1) — the reliability
|
|
@@ -569,8 +569,8 @@ declare function snapshotFromCalibration(report: CalibrationResult | ContinuousC
|
|
|
569
569
|
* `meta.judgeId` names the ensemble and `meta.judgeModel` pins its
|
|
570
570
|
* composition (e.g. a joined list of member model strings).
|
|
571
571
|
*/
|
|
572
|
-
declare function snapshotFromAgreement(report: CorpusAgreementReport | ContinuousAgreement, meta: SnapshotMeta): SentinelSnapshot;
|
|
573
|
-
interface SentinelSetOptions {
|
|
572
|
+
export declare function snapshotFromAgreement(report: CorpusAgreementReport | ContinuousAgreement, meta: SnapshotMeta): SentinelSnapshot;
|
|
573
|
+
export interface SentinelSetOptions {
|
|
574
574
|
/** Max |judge − human| for an item to count as passed. Default 0.1 (tuned for [0,1] scores). */
|
|
575
575
|
tolerance?: number;
|
|
576
576
|
}
|
|
@@ -581,21 +581,21 @@ interface SentinelSetOptions {
|
|
|
581
581
|
* human score. Items the judge didn't score are excluded from the
|
|
582
582
|
* denominator; zero joined items is an error, not a 0% pass rate.
|
|
583
583
|
*/
|
|
584
|
-
declare function snapshotFromSentinelSet(scores: CandidateScore[], golden: GoldenItem[], meta: SnapshotMeta, options?: SentinelSetOptions): SentinelSnapshot;
|
|
585
|
-
interface SentinelStore {
|
|
584
|
+
export declare function snapshotFromSentinelSet(scores: CandidateScore[], golden: GoldenItem[], meta: SnapshotMeta, options?: SentinelSetOptions): SentinelSnapshot;
|
|
585
|
+
export interface SentinelStore {
|
|
586
586
|
append(snapshot: SentinelSnapshot): Promise<void>;
|
|
587
587
|
/** All snapshots (optionally for one judge), in append order. */
|
|
588
588
|
history(judgeId?: string): Promise<SentinelSnapshot[]>;
|
|
589
589
|
}
|
|
590
|
-
declare function inMemorySentinelStore(initial?: SentinelSnapshot[]): SentinelStore;
|
|
590
|
+
export declare function inMemorySentinelStore(initial?: SentinelSnapshot[]): SentinelStore;
|
|
591
591
|
/**
|
|
592
592
|
* JSONL store — one snapshot per line, appended atomically per call.
|
|
593
593
|
* A corrupt or shape-invalid line is a loud error naming the file and
|
|
594
594
|
* line number: a sentinel history that silently drops records would
|
|
595
595
|
* defeat the drift detection it exists to provide.
|
|
596
596
|
*/
|
|
597
|
-
declare function fileSentinelStore(path: string): SentinelStore;
|
|
598
|
-
interface SentinelThresholds {
|
|
597
|
+
export declare function fileSentinelStore(path: string): SentinelStore;
|
|
598
|
+
export interface SentinelThresholds {
|
|
599
599
|
/** Floor for irr — below it the judge ensemble is unreliable regardless of trend. Default 0.6. */
|
|
600
600
|
minIrr?: number;
|
|
601
601
|
/** Max tolerated calibrationKappa drop vs the series baseline. Default 0.15. */
|
|
@@ -605,14 +605,14 @@ interface SentinelThresholds {
|
|
|
605
605
|
/** Newest snapshot older than this (days, vs asOf) = the sentinel itself went blind. Default 30. */
|
|
606
606
|
staleAfterDays?: number;
|
|
607
607
|
}
|
|
608
|
-
interface JudgeSentinelOptions {
|
|
608
|
+
export interface JudgeSentinelOptions {
|
|
609
609
|
/** Caller-supplied ISO timestamp staleness is measured against. */
|
|
610
610
|
asOf: string;
|
|
611
611
|
thresholds?: SentinelThresholds;
|
|
612
612
|
/** Forwarded to `analyzeSeries` (window, stableCv, driftRun). */
|
|
613
613
|
convergence?: SeriesConvergenceOptions;
|
|
614
614
|
}
|
|
615
|
-
interface SentinelTrend {
|
|
615
|
+
export interface SentinelTrend {
|
|
616
616
|
judgeId: string;
|
|
617
617
|
metric: SentinelMetricName;
|
|
618
618
|
/** Verbatim `analyzeSeries` state for this judge×metric history. */
|
|
@@ -626,7 +626,7 @@ interface SentinelTrend {
|
|
|
626
626
|
alarmed: boolean;
|
|
627
627
|
reason?: string;
|
|
628
628
|
}
|
|
629
|
-
interface SentinelReport {
|
|
629
|
+
export interface SentinelReport {
|
|
630
630
|
perJudge: SentinelTrend[];
|
|
631
631
|
alarms: string[];
|
|
632
632
|
healthy: boolean;
|
|
@@ -638,8 +638,8 @@ interface SentinelReport {
|
|
|
638
638
|
*/
|
|
639
639
|
insufficientHistory: string[];
|
|
640
640
|
}
|
|
641
|
-
declare function judgeSentinelReport(history: SentinelSnapshot[], opts: JudgeSentinelOptions): SentinelReport;
|
|
642
|
-
interface EvalHealthStamp {
|
|
641
|
+
export declare function judgeSentinelReport(history: SentinelSnapshot[], opts: JudgeSentinelOptions): SentinelReport;
|
|
642
|
+
export interface EvalHealthStamp {
|
|
643
643
|
healthy: boolean;
|
|
644
644
|
alarms: string[];
|
|
645
645
|
}
|
|
@@ -651,7 +651,7 @@ interface EvalHealthStamp {
|
|
|
651
651
|
* unresolved drift / decay / silent-upgrade / staleness alarm — treat the
|
|
652
652
|
* verdicts as carrying an integrity warning until recalibration clears it.
|
|
653
653
|
*/
|
|
654
|
-
declare function evalHealthStamp(report: SentinelReport): EvalHealthStamp;
|
|
654
|
+
export declare function evalHealthStamp(report: SentinelReport): EvalHealthStamp;
|
|
655
655
|
//#endregion
|
|
656
|
-
export {
|
|
656
|
+
export { type CalibrationResult, type CandidateScore, type ContinuousAgreement, type ContinuousAgreementOptions, type ContinuousCalibrationResult, type CorrelationInterval, DeploymentOutcome, type EvaluatorAdmissionPolicy, type EvaluatorAdmissionReport, type EvaluatorAuditInput, type EvaluatorAuditObservation, type EvaluatorErrorRate, FileSystemOutcomeStore, FileSystemOutcomeStoreOptions, type GoldenItem, InMemoryOutcomeStore, OutcomeFilter, OutcomeMetricSpec, type OutcomeReduction, OutcomeStore, OutcomeStoreError, type PositionalBiasResult, type ProbabilityPolicyAuditInput, type ProbabilityPolicyAuditReport, RubricOutcomeExclusion, RubricOutcomePair, RubricPredictiveValidityInput, RubricPredictiveValidityReport, RubricRanking, type SelfPreferenceResult, type VerbosityBiasResult, calibrateJudge, calibrateJudgeContinuous, continuousAgreement, positionalBias, rubricPredictiveValidity, selfPreference, verbosityBias };
|
|
657
657
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/meta-eval/correlation-study.ts","../../src/meta-eval/calibration.ts","../../src/meta-eval/evaluator-admission.ts","../../src/meta-eval/plants.ts","../../src/meta-eval/sentinel.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/meta-eval/correlation-study.ts","../../src/meta-eval/calibration.ts","../../src/meta-eval/evaluator-admission.ts","../../src/meta-eval/plants.ts","../../src/meta-eval/sentinel.ts"],"mappings":";;;;;;;;;;iBAoBiB;EACf;;;EAGA,WAAW,KAAK,KAAK,OAAO,eAAe;;iBAG5B;EACf;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;;EAEA;IAAe;IAAe;;;EAE9B;IAAgB;IAAe;;;EAE/B;;iBAGe;EACf,OAAO;;EAEP,eAAe,MACb;IACE;IACA;;EAGJ;EACA;;iBAGe;;EAEf;;EAEA,gBAAgB;;EAEhB;;EAEA;;;EAGA;;wBAGoB,iBACpB,YAAY,YACZ,cAAc,cACd,aAAa,kBACb,8BACA,UAAS,0BACR,QAAQ;;;iBChEM;EACf;EACA;EACA;EACA;EACA;;EAEA;;iBAGe;EACf;EACA;EACA;EACA,MAAM;;EAEN;;EAEA;;i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A;;iBAGe;;EAEf;EACA,aAAa;;EAEb,cAAc;;iBAGC;EACf;EACA,QAAQ;;EAER,OAAO;;EAEP;;EAEA;;EAEA;EACA;EACA;;iBAGe;EACf,UAAU;EACV;EACA;;;;;;;EAOA;;wBAKc,oBACd,SAAS,oBACT,MAAM,uBACL;iBA6Gc;EACf;EACA;;;;;;;;;;wBAWc,gBAAgB,QAAQ,iBAAiB"}
|
package/dist/meta-eval/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { n as CaptureIntegrityError, s as ValidationError } from "../errors-Dngq5h35.js";
|
|
2
2
|
import { a as hashCanonical, i as compareCodeUnits } from "../canonical-BsZVgBhW.js";
|
|
3
3
|
import { t as mulberry32 } from "../random-Dn5fPWkt.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-C5zgtiJT.js";
|
|
5
5
|
import { u as runMetricExtractor } from "../query-DlV0pdx4.js";
|
|
6
|
-
import { r as computeInterval } from "../ast-
|
|
6
|
+
import { r as computeInterval } from "../ast-DJ6Bc7ab.js";
|
|
7
7
|
import { t as analyzeSeries } from "../series-convergence-CjO2QdRW.js";
|
|
8
|
-
import { a as reduceOutcomeMetric, i as hasVariation, n as assertUniqueObservationIds, o as validateObservationOptions, r as correlationSummary, t as rubricPredictiveValidity } from "../rubric-predictive-validity-
|
|
9
|
-
import { n as InMemoryOutcomeStore, r as OutcomeStoreError, t as FileSystemOutcomeStore } from "../outcome-store-
|
|
8
|
+
import { a as reduceOutcomeMetric, i as hasVariation, n as assertUniqueObservationIds, o as validateObservationOptions, r as correlationSummary, t as rubricPredictiveValidity } from "../rubric-predictive-validity-B0Pg-3I5.js";
|
|
9
|
+
import { n as InMemoryOutcomeStore, r as OutcomeStoreError, t as FileSystemOutcomeStore } from "../outcome-store-DUcMj-3D.js";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
//#region src/meta-eval/calibration.ts
|
|
12
12
|
/**
|