@tangle-network/agent-eval 0.216.1 → 0.218.1
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 +137 -57
- package/README.md +2 -2
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-VFcQncbW.d.ts → agent-profile-DTt8uGP9.d.ts} +4 -17
- package/dist/agent-profile-DTt8uGP9.d.ts.map +1 -0
- package/dist/{agent-profile-cell-BK8mlqlq.js → agent-profile-cell-B1V1gUZs.js} +4 -53
- package/dist/agent-profile-cell-B1V1gUZs.js.map +1 -0
- package/dist/{agent-profile-cell-BNp-Js9F.d.ts → agent-profile-cell-BcpFbNd5.d.ts} +2 -22
- package/dist/agent-profile-cell-BcpFbNd5.d.ts.map +1 -0
- package/dist/{agreement-irr-BEWLIF3_.js → agreement-irr-BhAqjluA.js} +5 -5
- package/dist/agreement-irr-BhAqjluA.js.map +1 -0
- package/dist/analyst/index.d.ts +36 -169
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +17 -192
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-D68fd-su.d.ts → analyze-runs-DjlZOVXx.d.ts} +5 -5
- package/dist/{analyze-runs-D68fd-su.d.ts.map → analyze-runs-DjlZOVXx.d.ts.map} +1 -1
- package/dist/{analyze-runs-C84irm4i.js → analyze-runs-DqPJaJ4X.js} +225 -21
- package/dist/analyze-runs-DqPJaJ4X.js.map +1 -0
- package/dist/authenticity/index.d.ts +0 -23
- package/dist/authenticity/index.d.ts.map +1 -1
- package/dist/authenticity/index.js +1 -34
- package/dist/authenticity/index.js.map +1 -1
- package/dist/{benchmark-command-By0vh8q7.js → benchmark-command-BupdHRyf.js} +1225 -661
- package/dist/benchmark-command-BupdHRyf.js.map +1 -0
- package/dist/benchmarks/index.d.ts +5 -6
- package/dist/benchmarks/index.d.ts.map +1 -1
- package/dist/benchmarks/index.js +4 -4
- package/dist/benchmarks/index.js.map +1 -1
- package/dist/builder-eval/index.d.ts +3 -3
- package/dist/builder-eval/index.js +2 -2
- package/dist/builder-eval/index.js.map +1 -1
- package/dist/campaign/index.d.ts +7 -7
- package/dist/campaign/index.js +15 -15
- package/dist/{campaign-BudZ70zo.js → campaign-CGvUTnmc.js} +324 -800
- package/dist/campaign-CGvUTnmc.js.map +1 -0
- package/dist/{campaign-evidence-Clrn4hBV.js → campaign-evidence-DunzcJGv.js} +10 -18
- package/dist/{campaign-evidence-Clrn4hBV.js.map → campaign-evidence-DunzcJGv.js.map} +1 -1
- package/dist/{canonical-B2RqLofv.js → canonical-Dq2hOQ8L.js} +2 -2
- package/dist/{canonical-B2RqLofv.js.map → canonical-Dq2hOQ8L.js.map} +1 -1
- package/dist/cell-spend-DEWR3nj-.js +90 -0
- package/dist/cell-spend-DEWR3nj-.js.map +1 -0
- package/dist/{chat-client-l-MVDlDk.js → chat-client-B2pXlPdx.js} +2 -2
- package/dist/{chat-client-l-MVDlDk.js.map → chat-client-B2pXlPdx.js.map} +1 -1
- package/dist/{chat-json-call-puMArmtW.js → chat-json-call-Dm9c-b41.js} +3 -2
- package/dist/chat-json-call-Dm9c-b41.js.map +1 -0
- package/dist/{claim-q4HQhK1G.js → claim-BPVuyHuy.js} +3 -3
- package/dist/{claim-q4HQhK1G.js.map → claim-BPVuyHuy.js.map} +1 -1
- package/dist/cli.js +113 -12
- package/dist/cli.js.map +1 -1
- package/dist/{client-BzL9niqi.d.ts → client-hwo3cJjR.d.ts} +3 -16
- package/dist/client-hwo3cJjR.d.ts.map +1 -0
- package/dist/{cluster-bootstrap-qcUWYFl-.js → cluster-bootstrap-DEwwhl0C.js} +3 -3
- package/dist/{cluster-bootstrap-qcUWYFl-.js.map → cluster-bootstrap-DEwwhl0C.js.map} +1 -1
- package/dist/{produced-state-BsDmnwxc.js → completion-verifier-DbLVf3i8.js} +9 -64
- package/dist/completion-verifier-DbLVf3i8.js.map +1 -0
- package/dist/contract/index.d.ts +12 -12
- package/dist/contract/index.js +107 -403
- package/dist/contract/index.js.map +1 -1
- package/dist/{cost-ledger-BP8V4kUQ.js → cost-ledger-D0352Z4d.js} +4 -8
- package/dist/cost-ledger-D0352Z4d.js.map +1 -0
- package/dist/dataset-DQqhOCPt.d.ts.map +1 -1
- package/dist/{default-registry-COhk9g36.js → default-registry-BJ-Pq6yL.js} +314 -285
- package/dist/default-registry-BJ-Pq6yL.js.map +1 -0
- package/dist/{default-registry-DzHiGruW.d.ts → default-registry-DXgLmoDI.d.ts} +7 -50
- package/dist/default-registry-DXgLmoDI.d.ts.map +1 -0
- package/dist/{define-agent-eval-CNTPzIkp.js → define-agent-eval-BGdFKlrc.js} +170 -110
- package/dist/define-agent-eval-BGdFKlrc.js.map +1 -0
- package/dist/{define-agent-eval-WSck0CZJ.d.ts → define-agent-eval-BlH10zEw.d.ts} +8 -8
- package/dist/define-agent-eval-BlH10zEw.d.ts.map +1 -0
- package/dist/{descriptive-DboxPZrG.js → descriptive-CVNy48rR.js} +2 -2
- package/dist/{descriptive-DboxPZrG.js.map → descriptive-CVNy48rR.js.map} +1 -1
- package/dist/diagnosis/index.d.ts +4 -14
- package/dist/diagnosis/index.d.ts.map +1 -1
- package/dist/diagnosis/index.js +67 -28
- package/dist/diagnosis/index.js.map +1 -1
- package/dist/{dspy-rlm-engine-LRCu61m5.js → dspy-rlm-engine-CSMwudLO.js} +5 -10
- package/dist/dspy-rlm-engine-CSMwudLO.js.map +1 -0
- package/dist/{emitter-HcCmFQl_.d.ts → emitter-DABYYTcH.d.ts} +5 -5
- package/dist/emitter-DABYYTcH.d.ts.map +1 -0
- package/dist/emitter-DbMXUIVP.js.map +1 -1
- package/dist/{engine-3A_4jOlI.d.ts → engine-BvZ0R-36.d.ts} +17 -21
- package/dist/engine-BvZ0R-36.d.ts.map +1 -0
- package/dist/{equal-terms-BtdXayCJ.js → equal-terms-DbPGcVtI.js} +2 -2
- package/dist/equal-terms-DbPGcVtI.js.map +1 -0
- package/dist/{errors-DVZiqS7K.js → errors-BcOs5MKW.js} +2 -8
- package/dist/{errors-DVZiqS7K.js.map → errors-BcOs5MKW.js.map} +1 -1
- package/dist/eval-campaign-BUMIxKTE.js +393 -0
- package/dist/eval-campaign-BUMIxKTE.js.map +1 -0
- package/dist/{evaluation-6Yoi74gM.d.ts → evaluation-BOZ38vOH.d.ts} +7 -7
- package/dist/evaluation-BOZ38vOH.d.ts.map +1 -0
- package/dist/evaluation.d.ts +2 -2
- package/dist/evaluation.js +1 -1
- package/dist/evaluation.js.map +1 -1
- package/dist/{exact-types-ClugMJfI.d.ts → exact-types-CflbJ9f3.d.ts} +2 -2
- package/dist/{exact-types-ClugMJfI.d.ts.map → exact-types-CflbJ9f3.d.ts.map} +1 -1
- package/dist/{exec-ChJ6d5if.js → exec-CpbtOXVt.js} +2 -24
- package/dist/{exec-ChJ6d5if.js.map → exec-CpbtOXVt.js.map} +1 -1
- package/dist/execution-tracks-CpgFPpS5.js.map +1 -1
- package/dist/experiment/index.d.ts +9 -112
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/experiment/index.js +258 -311
- package/dist/experiment/index.js.map +1 -1
- package/dist/{exporters-X4xwla8A.js → exporters-DWvM16LE.js} +3 -3
- package/dist/exporters-DWvM16LE.js.map +1 -0
- package/dist/{exporters-ChTnR90l.d.ts → exporters-Dk3oEbK_.d.ts} +2 -4
- package/dist/{exporters-ChTnR90l.d.ts.map → exporters-Dk3oEbK_.d.ts.map} +1 -1
- package/dist/{external-optimizer-process-BjMGUuds.js → external-optimizer-process-C3Wm7Vhn.js} +4 -3
- package/dist/external-optimizer-process-C3Wm7Vhn.js.map +1 -0
- package/dist/{external-optimizer-subprocess-BqW0hHcI.js → external-optimizer-subprocess-B5gdLRZv.js} +9 -11
- package/dist/external-optimizer-subprocess-B5gdLRZv.js.map +1 -0
- package/dist/{extract-usage-BrnzRJ6H.js → extract-usage-BZLU01kR.js} +2 -23
- package/dist/{extract-usage-BrnzRJ6H.js.map → extract-usage-BZLU01kR.js.map} +1 -1
- package/dist/{failure-cluster-CbgEDcFJ.d.ts → failure-cluster-DN0t63Z0.d.ts} +4 -43
- package/dist/failure-cluster-DN0t63Z0.d.ts.map +1 -0
- package/dist/{failure-taxonomy-CjabTATj.js → failure-taxonomy-Bx5oWqaW.js} +2 -19
- package/dist/{failure-taxonomy-CjabTATj.js.map → failure-taxonomy-Bx5oWqaW.js.map} +1 -1
- package/dist/{feedback-trajectory-C4EG0nNH.d.ts → feedback-trajectory-BWmhRBGu.d.ts} +7 -9
- package/dist/feedback-trajectory-BWmhRBGu.d.ts.map +1 -0
- package/dist/{semantic-concept-judge-BQF8te0T.js → findings-store-BtTzPL0d.js} +9 -249
- package/dist/findings-store-BtTzPL0d.js.map +1 -0
- package/dist/fuzz.d.ts +19 -62
- package/dist/fuzz.d.ts.map +1 -1
- package/dist/fuzz.js +62 -108
- package/dist/fuzz.js.map +1 -1
- package/dist/{hf-dataset-BR2yhuNn.js → hf-dataset-CKxIJQba.js} +4 -24
- package/dist/hf-dataset-CKxIJQba.js.map +1 -0
- package/dist/hosted/index.d.ts +2 -2
- package/dist/hosted/index.js +2 -2
- package/dist/{index-CyszSg4O.d.ts → index-B16FNdW5.d.ts} +145 -360
- package/dist/index-B16FNdW5.d.ts.map +1 -0
- package/dist/{index-DV-jSzxF.d.ts → index-BLGqZ81N.d.ts} +10 -15
- package/dist/{index-DV-jSzxF.d.ts.map → index-BLGqZ81N.d.ts.map} +1 -1
- package/dist/{index-BO41eGj5.d.ts → index-CX-GAUpw.d.ts} +3 -7
- package/dist/index-CX-GAUpw.d.ts.map +1 -0
- package/dist/{index-DHKEAv3s.d.ts → index-CalAsXMR.d.ts} +8 -68
- package/dist/index-CalAsXMR.d.ts.map +1 -0
- package/dist/{index-BFRO6chs.d.ts → index-CiRwLv2R.d.ts} +5 -69
- package/dist/index-CiRwLv2R.d.ts.map +1 -0
- package/dist/{index-DPcngtwt.d.ts → index-DbMOXYnP.d.ts} +11 -36
- package/dist/index-DbMOXYnP.d.ts.map +1 -0
- package/dist/index.d.ts +211 -218
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +999 -1714
- package/dist/index.js.map +1 -1
- package/dist/{integrity-dLiDe2kD.js → integrity-C8oUeB0g.js} +326 -203
- package/dist/integrity-C8oUeB0g.js.map +1 -0
- package/dist/{integrity-BXOsAb3i.js → integrity-W4CADcFc.js} +3 -7
- package/dist/{integrity-BXOsAb3i.js.map → integrity-W4CADcFc.js.map} +1 -1
- package/dist/{integrity-DAMEDFaC.d.ts → integrity-_qgZLA5p.d.ts} +4 -6
- package/dist/{integrity-DAMEDFaC.d.ts.map → integrity-_qgZLA5p.d.ts.map} +1 -1
- package/dist/{internal-Epl-YBZW.js → internal-BTK91Bqt.js} +3 -3
- package/dist/{internal-Epl-YBZW.js.map → internal-BTK91Bqt.js.map} +1 -1
- package/dist/{interval-CELpye1n.js → interval-Dq9gt7jx.js} +3 -3
- package/dist/{interval-CELpye1n.js.map → interval-Dq9gt7jx.js.map} +1 -1
- package/dist/{journal-DfRz9kps.js → journal-C7om8Gum.js} +157 -147
- package/dist/journal-C7om8Gum.js.map +1 -0
- package/dist/json-BhdsJaOQ.js +111 -0
- package/dist/json-BhdsJaOQ.js.map +1 -0
- package/dist/{judge-calibration-BpCy5XQl.js → judge-calibration-BkXMIWA4.js} +3 -3
- package/dist/{judge-calibration-BpCy5XQl.js.map → judge-calibration-BkXMIWA4.js.map} +1 -1
- package/dist/{judge-gate-iY9s4L44.js → judge-gate-Co5tuh57.js} +4 -27
- package/dist/{judge-gate-iY9s4L44.js.map → judge-gate-Co5tuh57.js.map} +1 -1
- package/dist/{judge-gate-CE7CQAgt.d.ts → judge-gate-DsL0yFcb.d.ts} +8 -9
- package/dist/judge-gate-DsL0yFcb.d.ts.map +1 -0
- package/dist/{kind-factory-BobI5Jy3.js → kind-factory-Gy4fXixd.js} +88 -17
- package/dist/kind-factory-Gy4fXixd.js.map +1 -0
- package/dist/ledger-core/index.d.ts +2 -2
- package/dist/ledger-core/index.js +4 -4
- package/dist/ledger-core/lock-holder.d.ts +2 -0
- package/dist/ledger-core/lock-holder.js +181 -0
- package/dist/ledger-core/lock-holder.js.map +1 -0
- package/dist/{ledger-core-Gq7yp8lP.js → ledger-core-CAxUdDk0.js} +5 -84
- package/dist/ledger-core-CAxUdDk0.js.map +1 -0
- package/dist/{llm-client-CyBAoYiX.js → llm-client-_Y6ic-tf.js} +243 -355
- package/dist/llm-client-_Y6ic-tf.js.map +1 -0
- package/dist/{llm-judge-CG12SQJq.js → llm-judge-Djxh-Uhs.js} +662 -482
- package/dist/llm-judge-Djxh-Uhs.js.map +1 -0
- package/dist/lock-holder-DaJbfpci.d.ts +86 -0
- package/dist/lock-holder-DaJbfpci.d.ts.map +1 -0
- package/dist/matrix/index.d.ts +3 -3
- package/dist/matrix/index.js +3 -2
- package/dist/{matrix-Dm0BQW7U.js → matrix-B8l-Nsxd.js} +3 -88
- package/dist/matrix-B8l-Nsxd.js.map +1 -0
- package/dist/{matrix-DSrSxjjy.d.ts → matrix-CCSBna4q.d.ts} +9 -18
- package/dist/matrix-CCSBna4q.d.ts.map +1 -0
- package/dist/{mean-DHoMiudD.js → mean-BbA_JCzW.js} +39 -5
- package/dist/mean-BbA_JCzW.js.map +1 -0
- package/dist/meta-eval/index.d.ts +5 -5
- package/dist/meta-eval/index.js +10 -10
- package/dist/metrics-BKaPBtIG.js.map +1 -1
- package/dist/{mint-DNU8QPG4.d.ts → mint-BRZXuwRi.d.ts} +4 -4
- package/dist/{mint-DNU8QPG4.d.ts.map → mint-BRZXuwRi.d.ts.map} +1 -1
- package/dist/{mint-QaD5cA0u.js → mint-CbdwjTPW.js} +4 -4
- package/dist/{mint-QaD5cA0u.js.map → mint-CbdwjTPW.js.map} +1 -1
- package/dist/{multi-layer-verifier-BUaQ4C17.d.ts → multi-layer-verifier-DEgMUk6v.d.ts} +2 -2
- package/dist/{multi-layer-verifier-BUaQ4C17.d.ts.map → multi-layer-verifier-DEgMUk6v.d.ts.map} +1 -1
- package/dist/{multiplicity-DQUFcbW4.js → multiplicity-Sg0U7h8j.js} +2 -2
- package/dist/{multiplicity-DQUFcbW4.js.map → multiplicity-Sg0U7h8j.js.map} +1 -1
- package/dist/multishot/golden/index.d.ts +1 -23
- package/dist/multishot/golden/index.d.ts.map +1 -1
- package/dist/multishot/golden/index.js +3 -3
- package/dist/multishot/golden/index.js.map +1 -1
- package/dist/multishot/index.d.ts +3 -12
- package/dist/multishot/index.d.ts.map +1 -1
- package/dist/multishot/index.js +4 -3
- package/dist/multishot/index.js.map +1 -1
- package/dist/openapi.json +114 -10
- package/dist/{otel-spans-B9tUXRHF.js → otel-spans-CdN909k1.js} +3 -3
- package/dist/{otel-spans-B9tUXRHF.js.map → otel-spans-CdN909k1.js.map} +1 -1
- package/dist/{paired-arms-CwMGJsrS.js → paired-arms-Ct4LTKc1.js} +32 -9
- package/dist/paired-arms-Ct4LTKc1.js.map +1 -0
- package/dist/{paired-binary-CvpFHfKZ.js → paired-binary-B_nejA44.js} +3 -36
- package/dist/paired-binary-B_nejA44.js.map +1 -0
- package/dist/{paired-promotion-decision-DPKz8ZnF.d.ts → paired-promotion-decision-CQMJ5xGN.d.ts} +2 -34
- package/dist/paired-promotion-decision-CQMJ5xGN.d.ts.map +1 -0
- package/dist/{paired-promotion-decision-DsAPYGCm.js → paired-promotion-decision-D0SHb-ZL.js} +3 -3
- package/dist/{paired-promotion-decision-DsAPYGCm.js.map → paired-promotion-decision-D0SHb-ZL.js.map} +1 -1
- package/dist/{pareto-Cm6ndrWN.js → pareto-CTv8vozZ.js} +11 -11
- package/dist/pareto-CTv8vozZ.js.map +1 -0
- package/dist/pipelines/index.d.ts +16 -19
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js +4 -68
- package/dist/pipelines/index.js.map +1 -1
- package/dist/{power-and-mde-Hj2ubb4B.js → power-and-mde-N5nU4_Ly.js} +3 -3
- package/dist/{power-and-mde-Hj2ubb4B.js.map → power-and-mde-N5nU4_Ly.js.map} +1 -1
- package/dist/{prime-protocol-CHKgA3a6.js → prime-protocol-BFgGrEMP.js} +3 -3
- package/dist/prime-protocol-BFgGrEMP.js.map +1 -0
- package/dist/{prime-protocol-HiB9HX7E.d.ts → prime-protocol-BWG2DQIk.d.ts} +3 -21
- package/dist/prime-protocol-BWG2DQIk.d.ts.map +1 -0
- package/dist/profile-cell.d.ts +2 -2
- package/dist/profile-cell.js +2 -2
- package/dist/{promotion-gate-BawrdPYr.d.ts → promotion-gate-CxEHRsZW.d.ts} +7 -8
- package/dist/{promotion-gate-BawrdPYr.d.ts.map → promotion-gate-CxEHRsZW.d.ts.map} +1 -1
- package/dist/{promotion-policy-KO57gbyV.js → promotion-policy-6A8osGr_.js} +4 -4
- package/dist/{promotion-policy-KO57gbyV.js.map → promotion-policy-6A8osGr_.js.map} +1 -1
- package/dist/{proposal-findings-CY1xKn_a.js → proposal-findings-n-5WBbEx.js} +3 -3
- package/dist/proposal-findings-n-5WBbEx.js.map +1 -0
- package/dist/{query-BUCZCK7F.js → query-B_RZ36an.js} +5 -5
- package/dist/query-B_RZ36an.js.map +1 -0
- package/dist/{query-DK1nWcmp.d.ts → query-Cmv_U8vf.d.ts} +4 -24
- package/dist/{query-DK1nWcmp.d.ts.map → query-Cmv_U8vf.d.ts.map} +1 -1
- package/dist/{random-ByUSnV9w.js → random-DDDcC7YU.js} +2 -2
- package/dist/{random-ByUSnV9w.js.map → random-DDDcC7YU.js.map} +1 -1
- package/dist/{raw-provider-sink-DoHz4JNG.js → raw-provider-sink-75w4FWBj.js} +2 -2
- package/dist/{raw-provider-sink-DoHz4JNG.js.map → raw-provider-sink-75w4FWBj.js.map} +1 -1
- package/dist/{redact-mtCCcT8z.d.ts → redact-DXdlFb_U.d.ts} +2 -3
- package/dist/redact-DXdlFb_U.d.ts.map +1 -0
- package/dist/{redact-B5xXKqQ3.js → redact-mtkTiJVk.js} +2 -7
- package/dist/{redact-B5xXKqQ3.js.map → redact-mtkTiJVk.js.map} +1 -1
- package/dist/{registry-D7_hm2fK.d.ts → registry-ssNoHzwD.d.ts} +4 -4
- package/dist/{registry-D7_hm2fK.d.ts.map → registry-ssNoHzwD.d.ts.map} +1 -1
- package/dist/{release-confidence-CpuP65S5.js → release-confidence-CYIFH-fp.js} +6 -11
- package/dist/release-confidence-CYIFH-fp.js.map +1 -0
- package/dist/{report-command-SC9nqb4M.js → render-Cs34y0iX.js} +625 -587
- package/dist/render-Cs34y0iX.js.map +1 -0
- package/dist/reporting.d.ts +6 -6
- package/dist/reporting.js +8 -8
- package/dist/{researcher-CEcfku-T.d.ts → researcher-GU1tV4dn.d.ts} +9 -9
- package/dist/{researcher-CEcfku-T.d.ts.map → researcher-GU1tV4dn.d.ts.map} +1 -1
- package/dist/{reward-CpCmAM8L.d.ts → reward-DrZ71vnf.d.ts} +3 -26
- package/dist/reward-DrZ71vnf.d.ts.map +1 -0
- package/dist/{reward-hacking-E0d-WVcP.js → reward-hacking-ByuETaIb.js} +3 -3
- package/dist/{reward-hacking-E0d-WVcP.js.map → reward-hacking-ByuETaIb.js.map} +1 -1
- package/dist/{reward-hacking-RVdZ6Kkt.d.ts → reward-hacking-E52wq86n.d.ts} +5 -18
- package/dist/reward-hacking-E52wq86n.d.ts.map +1 -0
- package/dist/reward-nw2xZGZG.js.map +1 -1
- package/dist/rl.d.ts +117 -295
- package/dist/rl.d.ts.map +1 -1
- package/dist/rl.js +27 -747
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +5 -5
- package/dist/rollout/index.js +7 -8
- package/dist/{rollout-DZV1t2Wg.js → rollout-Dd1ucT_M.js} +88 -13
- package/dist/rollout-Dd1ucT_M.js.map +1 -0
- package/dist/{rubric-predictive-validity-DaFW70y9.js → rubric-predictive-validity-D3_oI72N.js} +3 -3
- package/dist/{rubric-predictive-validity-DaFW70y9.js.map → rubric-predictive-validity-D3_oI72N.js.map} +1 -1
- package/dist/{rubric-predictive-validity-C03EC7ZE.d.ts → rubric-predictive-validity-DiwT8PbL.d.ts} +2 -2
- package/dist/{rubric-predictive-validity-C03EC7ZE.d.ts.map → rubric-predictive-validity-DiwT8PbL.d.ts.map} +1 -1
- package/dist/{run-record-C1E24G2A.d.ts → run-record-CaxbLq6Y.d.ts} +4 -10
- package/dist/run-record-CaxbLq6Y.d.ts.map +1 -0
- package/dist/{run-record-C5e7FjhJ.js → run-record-CysKLB93.js} +3 -3
- package/dist/run-record-CysKLB93.js.map +1 -0
- package/dist/{run-record-Boc5IUTp.js → run-record-DhEJgoPz.js} +4 -4
- package/dist/{run-record-Boc5IUTp.js.map → run-record-DhEJgoPz.js.map} +1 -1
- package/dist/sandbox-harness-BlSOu4LX.d.ts.map +1 -1
- package/dist/{schema-CSf6qWgZ.js → schema-Bt2vLFm3.js} +2 -14
- package/dist/schema-Bt2vLFm3.js.map +1 -0
- package/dist/schema-C-ziyJD7.d.ts.map +1 -1
- package/dist/{schema-BuiujZ-g.js → schema-CvhfLjtZ.js} +78 -48
- package/dist/schema-CvhfLjtZ.js.map +1 -0
- package/dist/{schema-2g7trUwH.d.ts → schema-D6EVKzTB.d.ts} +4 -5
- package/dist/schema-D6EVKzTB.d.ts.map +1 -0
- package/dist/search/index.d.ts +3 -31
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +4 -4
- package/dist/{search-kernel-DyNEa6IU.d.ts → search-kernel-p9JB3SmL.d.ts} +10 -27
- package/dist/search-kernel-p9JB3SmL.d.ts.map +1 -0
- package/dist/{search-ledger-CVUGLDZp.js → search-ledger-ClpN4I3e.js} +7 -7
- package/dist/{search-ledger-CVUGLDZp.js.map → search-ledger-ClpN4I3e.js.map} +1 -1
- package/dist/{search-ledger-file-DDQUgvCg.js → search-ledger-file-Bd5Tioq6.js} +4 -4
- package/dist/search-ledger-file-Bd5Tioq6.js.map +1 -0
- package/dist/{search-shipper-BOSD46qv.js → search-shipper-Bg2HW3Uv.js} +4 -4
- package/dist/search-shipper-Bg2HW3Uv.js.map +1 -0
- package/dist/{search-summary-BQCSWf1g.js → search-summary-CrBuvVnf.js} +5 -5
- package/dist/{search-summary-BQCSWf1g.js.map → search-summary-CrBuvVnf.js.map} +1 -1
- package/dist/{sequential-CzK5DarL.js → sequential-BVv1sjsw.js} +2 -32
- package/dist/{sequential-CzK5DarL.js.map → sequential-BVv1sjsw.js.map} +1 -1
- package/dist/{sequential-Bf_pbE50.js → sequential-CimQrbjv.js} +5 -5
- package/dist/sequential-CimQrbjv.js.map +1 -0
- package/dist/{sequential-BhsrMupG.d.ts → sequential-KwGspfeR.d.ts} +2 -9
- package/dist/{sequential-BhsrMupG.d.ts.map → sequential-KwGspfeR.d.ts.map} +1 -1
- package/dist/{sequential-eprocess-DM_qENCl.js → sequential-eprocess-DodI6RoF.js} +2 -2
- package/dist/{sequential-eprocess-DM_qENCl.js.map → sequential-eprocess-DodI6RoF.js.map} +1 -1
- package/dist/{server-e9oWO_bN.js → server-C6M0qR8h.js} +101 -101
- package/dist/server-C6M0qR8h.js.map +1 -0
- package/dist/{single-run-lock-CV9Eyd_q.js → single-run-lock-Dekd8_Wv.js} +7 -7
- package/dist/single-run-lock-Dekd8_Wv.js.map +1 -0
- package/dist/{skillopt-optimization-method-BiwA8nfX.js → skillopt-optimization-method-5dlex7MJ.js} +1386 -1184
- package/dist/skillopt-optimization-method-5dlex7MJ.js.map +1 -0
- package/dist/{spans-BHAUXMGN.d.ts → spans-CVngGij3.d.ts} +2 -2
- package/dist/{spans-BHAUXMGN.d.ts.map → spans-CVngGij3.d.ts.map} +1 -1
- package/dist/{statistical-heldout-CYpGaoDH.d.ts → statistical-heldout-BHfLZHrm.d.ts} +8 -67
- package/dist/statistical-heldout-BHfLZHrm.d.ts.map +1 -0
- package/dist/{statistical-heldout-42NlCNDe.js → statistical-heldout-Bksv92Th.js} +3 -3
- package/dist/statistical-heldout-Bksv92Th.js.map +1 -0
- package/dist/{steps-Bg5-KVx1.d.ts → steps-DlepJPwD.d.ts} +2 -56
- package/dist/steps-DlepJPwD.d.ts.map +1 -0
- package/dist/{store-C4avFjIi.d.ts → store-B3nWRy3B.d.ts} +2 -2
- package/dist/{store-C4avFjIi.d.ts.map → store-B3nWRy3B.d.ts.map} +1 -1
- package/dist/{store-otlp-DJ9dtA5x.js → store-otlp-BteDAbHK.js} +3 -3
- package/dist/{store-otlp-DJ9dtA5x.js.map → store-otlp-BteDAbHK.js.map} +1 -1
- package/dist/{store-tool-spans-CIX5arAG.js → store-tool-spans-D5l_OfTJ.js} +8 -8
- package/dist/store-tool-spans-D5l_OfTJ.js.map +1 -0
- package/dist/{store-tool-spans-DdCSPa7C.d.ts → store-tool-spans-DZS0HWVf.d.ts} +9 -18
- package/dist/store-tool-spans-DZS0HWVf.d.ts.map +1 -0
- package/dist/storyboard/index.d.ts +4 -11
- package/dist/storyboard/index.d.ts.map +1 -1
- package/dist/storyboard/index.js +1 -16
- package/dist/storyboard/index.js.map +1 -1
- package/dist/{summary-report-V_JACR4Y.js → summary-report-BsXJoYX5.js} +88 -10
- package/dist/summary-report-BsXJoYX5.js.map +1 -0
- package/dist/{summary-report-bdFDXq0b.d.ts → summary-report-CkbRcSuu.d.ts} +25 -19
- package/dist/summary-report-CkbRcSuu.d.ts.map +1 -0
- package/dist/supervisor-run/index.d.ts +60 -28
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +4 -458
- package/dist/supervisor-run/index.js.map +1 -1
- package/dist/{systemone-BomhHr2c.d.ts → systemone-BMzDJb1i.d.ts} +5 -5
- package/dist/{systemone-BomhHr2c.d.ts.map → systemone-BMzDJb1i.d.ts.map} +1 -1
- package/dist/systemone-protocol.js +1 -1
- package/dist/{systemone-review-CUVcQJu6.d.ts → systemone-review-CwE6JGIp.d.ts} +2 -2
- package/dist/{systemone-review-CUVcQJu6.d.ts.map → systemone-review-CwE6JGIp.d.ts.map} +1 -1
- package/dist/{systemone-review-D7sXwsqq.js → systemone-review-DzdOJ8I6.js} +3 -3
- package/dist/{systemone-review-D7sXwsqq.js.map → systemone-review-DzdOJ8I6.js.map} +1 -1
- package/dist/systemone.d.ts +5 -5
- package/dist/systemone.js +5 -5
- package/dist/systemone.js.map +1 -1
- package/dist/{task-failure-attributes-hEmASjix.js → task-failure-attributes-BMsblaDh.js} +3 -3
- package/dist/task-failure-attributes-BMsblaDh.js.map +1 -0
- package/dist/{terminal-record-DZyQZ3pz.js → terminal-record-D4Rv-j1W.js} +244 -196
- package/dist/terminal-record-D4Rv-j1W.js.map +1 -0
- package/dist/{tool-groups-C3NEcdCM.d.ts → tool-groups-DyNz2JZ_.d.ts} +3 -3
- package/dist/tool-groups-DyNz2JZ_.d.ts.map +1 -0
- package/dist/{tool-waste-BKgvd-TP.d.ts → tool-waste-CkjzWmeY.d.ts} +25 -28
- package/dist/tool-waste-CkjzWmeY.d.ts.map +1 -0
- package/dist/{tool-waste-BlesqTqW.js → tool-waste-DLsjS_p-.js} +5 -5
- package/dist/{tool-waste-BlesqTqW.js.map → tool-waste-DLsjS_p-.js.map} +1 -1
- package/dist/{trace-questions-CM2CAocU.d.ts → trace-questions-xxwgsuMi.d.ts} +4 -9
- package/dist/{trace-questions-CM2CAocU.d.ts.map → trace-questions-xxwgsuMi.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +14 -211
- package/dist/trace-repair/index.d.ts.map +1 -1
- package/dist/trace-repair/index.js +865 -981
- package/dist/trace-repair/index.js.map +1 -1
- package/dist/traces.d.ts +18 -46
- package/dist/traces.d.ts.map +1 -1
- package/dist/traces.js +13 -13
- package/dist/traces.js.map +1 -1
- package/dist/trajectory-replay/index.d.ts +7 -118
- package/dist/trajectory-replay/index.d.ts.map +1 -1
- package/dist/trajectory-replay/index.js +921 -869
- package/dist/trajectory-replay/index.js.map +1 -1
- package/dist/{tree-C1XYeXvy.js → tree-B5e1uAeL.js} +132 -21
- package/dist/tree-B5e1uAeL.js.map +1 -0
- package/dist/{types-Cbe2fWBa.d.ts → types-BKCzzmit.d.ts} +3 -3
- package/dist/{types-Cbe2fWBa.d.ts.map → types-BKCzzmit.d.ts.map} +1 -1
- package/dist/{types-B3jzCp0p.js → types-BXgASBCL.js} +2 -2
- package/dist/{types-B3jzCp0p.js.map → types-BXgASBCL.js.map} +1 -1
- package/dist/{types-C1tnkEgM.d.ts → types-CW8ewATZ.d.ts} +4 -113
- package/dist/types-CW8ewATZ.d.ts.map +1 -0
- package/dist/{types-BqkVmHfv.d.ts → types-CmXY0PQf.d.ts} +2 -4
- package/dist/types-CmXY0PQf.d.ts.map +1 -0
- package/dist/{types-C02qtnG8.d.ts → types-D-mgRzlh.d.ts} +7 -28
- package/dist/types-D-mgRzlh.d.ts.map +1 -0
- package/dist/{types-IXD2HJzu.js → types-DqFMNTgK.js} +2 -4
- package/dist/types-DqFMNTgK.js.map +1 -0
- package/dist/{types-Cq8mSbq8.d.ts → types-DtkO1G9L.d.ts} +7 -9
- package/dist/{types-Cq8mSbq8.d.ts.map → types-DtkO1G9L.d.ts.map} +1 -1
- package/dist/{verdict-Dl0tiT1X.js → verdict-BGQmxQ8A.js} +3 -3
- package/dist/verdict-BGQmxQ8A.js.map +1 -0
- package/dist/{verdict-E4eRNf7-.d.ts → verdict-C24NELtN.d.ts} +2 -15
- package/dist/{verdict-E4eRNf7-.d.ts.map → verdict-C24NELtN.d.ts.map} +1 -1
- package/dist/{verdict-cache-Bm8EKL2s.js → verdict-cache-CL_7tePD.js} +2 -2
- package/dist/verdict-cache-CL_7tePD.js.map +1 -0
- package/dist/wire/index.d.ts +31 -410
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +2 -2
- package/docs/changes/jev-evidence-review.md +1 -1
- package/docs/changes/jev-product-adoption.md +1 -1
- package/docs/changes/jev-recorded-evidence.md +1 -1
- package/docs/design/statistics-decisions.md +18 -18
- package/docs/design.md +1 -1
- package/docs/eval-surface-map.md +1 -0
- package/docs/evaluation-integrity.md +1 -1
- package/docs/profile-json-identity.md +1 -2
- package/docs/proofs/campaign-attempt-retention-20261001/README.md +2 -2
- package/docs/public-api.md +158 -538
- package/docs/rollout.md +1 -1
- package/docs/trace-repair-admission.md +1 -1
- package/docs/wire-protocol.md +1 -1
- package/package.json +7 -2
- package/dist/active-curriculum-B_Lc9kfO.js +0 -61
- package/dist/active-curriculum-B_Lc9kfO.js.map +0 -1
- package/dist/agent-profile-VFcQncbW.d.ts.map +0 -1
- package/dist/agent-profile-cell-BK8mlqlq.js.map +0 -1
- package/dist/agent-profile-cell-BNp-Js9F.d.ts.map +0 -1
- package/dist/agreement-irr-BEWLIF3_.js.map +0 -1
- package/dist/analyze-runs-C84irm4i.js.map +0 -1
- package/dist/baseline-Udi_PLuT.js +0 -259
- package/dist/baseline-Udi_PLuT.js.map +0 -1
- package/dist/benchmark-CXmVVHH2.js +0 -562
- package/dist/benchmark-CXmVVHH2.js.map +0 -1
- package/dist/benchmark-command-By0vh8q7.js.map +0 -1
- package/dist/campaign-BudZ70zo.js.map +0 -1
- package/dist/chat-json-call-puMArmtW.js.map +0 -1
- package/dist/claude-jsonl-dZir12m6.js +0 -86
- package/dist/claude-jsonl-dZir12m6.js.map +0 -1
- package/dist/client-BzL9niqi.d.ts.map +0 -1
- package/dist/cost-ledger-BP8V4kUQ.js.map +0 -1
- package/dist/counterfactual-CPaWN99-.d.ts +0 -60
- package/dist/counterfactual-CPaWN99-.d.ts.map +0 -1
- package/dist/counterfactual-Dn3veueY.js +0 -98
- package/dist/counterfactual-Dn3veueY.js.map +0 -1
- package/dist/default-registry-COhk9g36.js.map +0 -1
- package/dist/default-registry-DzHiGruW.d.ts.map +0 -1
- package/dist/define-agent-eval-CNTPzIkp.js.map +0 -1
- package/dist/define-agent-eval-WSck0CZJ.d.ts.map +0 -1
- package/dist/dspy-rlm-engine-LRCu61m5.js.map +0 -1
- package/dist/effect-sizes-BhzEpXMc.js +0 -82
- package/dist/effect-sizes-BhzEpXMc.js.map +0 -1
- package/dist/emitter-HcCmFQl_.d.ts.map +0 -1
- package/dist/engine-3A_4jOlI.d.ts.map +0 -1
- package/dist/equal-terms-BtdXayCJ.js.map +0 -1
- package/dist/eval-campaign-90jeaCAI.js +0 -343
- package/dist/eval-campaign-90jeaCAI.js.map +0 -1
- package/dist/evaluation-6Yoi74gM.d.ts.map +0 -1
- package/dist/exporters-X4xwla8A.js.map +0 -1
- package/dist/external-optimizer-process-BjMGUuds.js.map +0 -1
- package/dist/external-optimizer-subprocess-BqW0hHcI.js.map +0 -1
- package/dist/failure-cluster-CbgEDcFJ.d.ts.map +0 -1
- package/dist/feedback-trajectory-C4EG0nNH.d.ts.map +0 -1
- package/dist/hf-dataset-BR2yhuNn.js.map +0 -1
- package/dist/index-BFRO6chs.d.ts.map +0 -1
- package/dist/index-BO41eGj5.d.ts.map +0 -1
- package/dist/index-CyszSg4O.d.ts.map +0 -1
- package/dist/index-DHKEAv3s.d.ts.map +0 -1
- package/dist/index-DPcngtwt.d.ts.map +0 -1
- package/dist/integrity-dLiDe2kD.js.map +0 -1
- package/dist/journal-DfRz9kps.js.map +0 -1
- package/dist/judge-gate-CE7CQAgt.d.ts.map +0 -1
- package/dist/kind-factory-BobI5Jy3.js.map +0 -1
- package/dist/ledger-core-Gq7yp8lP.js.map +0 -1
- package/dist/llm-client-CyBAoYiX.js.map +0 -1
- package/dist/llm-judge-CG12SQJq.js.map +0 -1
- package/dist/matrix-DSrSxjjy.d.ts.map +0 -1
- package/dist/matrix-Dm0BQW7U.js.map +0 -1
- package/dist/mean-DHoMiudD.js.map +0 -1
- package/dist/normal-DsJZtrJc.js +0 -25
- package/dist/normal-DsJZtrJc.js.map +0 -1
- package/dist/paired-arms-CwMGJsrS.js.map +0 -1
- package/dist/paired-binary-CvpFHfKZ.js.map +0 -1
- package/dist/paired-promotion-decision-DPKz8ZnF.d.ts.map +0 -1
- package/dist/pareto-Cm6ndrWN.js.map +0 -1
- package/dist/prime-protocol-CHKgA3a6.js.map +0 -1
- package/dist/prime-protocol-HiB9HX7E.d.ts.map +0 -1
- package/dist/produced-state-BsDmnwxc.js.map +0 -1
- package/dist/proposal-findings-CY1xKn_a.js.map +0 -1
- package/dist/query-BUCZCK7F.js.map +0 -1
- package/dist/redact-mtCCcT8z.d.ts.map +0 -1
- package/dist/release-confidence-CpuP65S5.js.map +0 -1
- package/dist/report-command-SC9nqb4M.js.map +0 -1
- package/dist/reward-CpCmAM8L.d.ts.map +0 -1
- package/dist/reward-hacking-RVdZ6Kkt.d.ts.map +0 -1
- package/dist/rollout-DZV1t2Wg.js.map +0 -1
- package/dist/run-record-C1E24G2A.d.ts.map +0 -1
- package/dist/run-record-C5e7FjhJ.js.map +0 -1
- package/dist/schema-2g7trUwH.d.ts.map +0 -1
- package/dist/schema-BuiujZ-g.js.map +0 -1
- package/dist/schema-CSf6qWgZ.js.map +0 -1
- package/dist/search-kernel-DyNEa6IU.d.ts.map +0 -1
- package/dist/search-ledger-file-DDQUgvCg.js.map +0 -1
- package/dist/search-shipper-BOSD46qv.js.map +0 -1
- package/dist/semantic-concept-judge-BQF8te0T.js.map +0 -1
- package/dist/sequential-Bf_pbE50.js.map +0 -1
- package/dist/server-e9oWO_bN.js.map +0 -1
- package/dist/single-run-lock-CV9Eyd_q.js.map +0 -1
- package/dist/skillopt-optimization-method-BiwA8nfX.js.map +0 -1
- package/dist/statistical-heldout-42NlCNDe.js.map +0 -1
- package/dist/statistical-heldout-CYpGaoDH.d.ts.map +0 -1
- package/dist/steps-Bg5-KVx1.d.ts.map +0 -1
- package/dist/store-tool-spans-CIX5arAG.js.map +0 -1
- package/dist/store-tool-spans-DdCSPa7C.d.ts.map +0 -1
- package/dist/student-t-DVPW7CdL.js +0 -39
- package/dist/student-t-DVPW7CdL.js.map +0 -1
- package/dist/summary-report-V_JACR4Y.js.map +0 -1
- package/dist/summary-report-bdFDXq0b.d.ts.map +0 -1
- package/dist/task-failure-attributes-hEmASjix.js.map +0 -1
- package/dist/terminal-record-DZyQZ3pz.js.map +0 -1
- package/dist/tool-groups-C3NEcdCM.d.ts.map +0 -1
- package/dist/tool-waste-BKgvd-TP.d.ts.map +0 -1
- package/dist/trajectory-Y1fmdlw7.d.ts +0 -24
- package/dist/trajectory-Y1fmdlw7.d.ts.map +0 -1
- package/dist/tree-C1XYeXvy.js.map +0 -1
- package/dist/types-BqkVmHfv.d.ts.map +0 -1
- package/dist/types-C02qtnG8.d.ts.map +0 -1
- package/dist/types-C1tnkEgM.d.ts.map +0 -1
- package/dist/types-IXD2HJzu.js.map +0 -1
- package/dist/usage-receipt-Cx3xNeyB.js +0 -76
- package/dist/usage-receipt-Cx3xNeyB.js.map +0 -1
- package/dist/verdict-Dl0tiT1X.js.map +0 -1
- package/dist/verdict-cache-Bm8EKL2s.js.map +0 -1
- package/docs/design/self-improvement-evidence-audit.md +0 -263
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as hashCanonical, i as compareCodeUnits, o as jsonDocument, r as canonicalString } from "./canonical-
|
|
3
|
-
import { i as pairedBootstrap, t as mean$
|
|
1
|
+
import { c as errorMessage, s as ValidationError, t as AgentEvalError } from "./errors-BcOs5MKW.js";
|
|
2
|
+
import { a as hashCanonical, i as compareCodeUnits, o as jsonDocument, r as canonicalString } from "./canonical-Dq2hOQ8L.js";
|
|
3
|
+
import { i as pairedBootstrap, t as mean$3 } from "./mean-BbA_JCzW.js";
|
|
4
4
|
import { a as resolveModelPricing } from "./metrics-BKaPBtIG.js";
|
|
5
|
-
import { a as CostLedgerPersistenceError, i as CostCeilingReachedError, n as CostAccountingIncompleteError, o as CostReceiptCaptureError, r as CostCallConflictError, s as CostReservationExceededError, t as CostLedger } from "./cost-ledger-
|
|
6
|
-
import {
|
|
7
|
-
import "./ledger-core-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { t as acquireSingleRunLock } from "./single-run-lock-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { t as createDspyRlmTraceEngine } from "./dspy-rlm-engine-
|
|
16
|
-
import { i as otlpTextToTraceAnalysisStore, n as DEFAULT_MAX_TRACE_FILE_BYTES, t as BufferTraceStore } from "./store-otlp-
|
|
17
|
-
import
|
|
18
|
-
import "./
|
|
19
|
-
import { t as
|
|
20
|
-
import { c as primeProtocolSha256, d as runPrimeExchange, f as decodeReplyRows, n as buildPrimePrompt, t as analystUsageReceiptFromPrimeUsage, u as projectPrimeTrajectory } from "./prime-protocol-CHKgA3a6.js";
|
|
5
|
+
import { a as CostLedgerPersistenceError, i as CostCeilingReachedError, n as CostAccountingIncompleteError, o as CostReceiptCaptureError, r as CostCallConflictError, s as CostReservationExceededError, t as CostLedger } from "./cost-ledger-D0352Z4d.js";
|
|
6
|
+
import { l as withLedgerFileLock, u as writeLedgerFileAtomically } from "./journal-C7om8Gum.js";
|
|
7
|
+
import "./ledger-core-CAxUdDk0.js";
|
|
8
|
+
import { M as fsCampaignStorage, b as AnalystFindingSchema, i as startExternalOptimizerModelProxy, j as createRunCostLedger, r as runWithCleanup, v as resolveExternalOptimizerProcessLimits } from "./external-optimizer-subprocess-B5gdLRZv.js";
|
|
9
|
+
import { s as redactText } from "./redact-mtkTiJVk.js";
|
|
10
|
+
import { i as makeFinding } from "./types-DqFMNTgK.js";
|
|
11
|
+
import { t as acquireSingleRunLock } from "./single-run-lock-Dekd8_Wv.js";
|
|
12
|
+
import { a as LlmCallError, n as isRecord, o as LlmResponseError } from "./json-BhdsJaOQ.js";
|
|
13
|
+
import { A as RawAnalystFindingSchema, U as assertValidAnalystUsageReceipt, W as usageReceiptFromCostLedger, j as evidenceRefsFromRawFinding, k as RAW_FINDING_SCHEMA_PROMPT, m as TRACE_ANALYSIS_LIMITS, n as runTraceAnalyst } from "./kind-factory-Gy4fXixd.js";
|
|
14
|
+
import { n as callLlmJson } from "./llm-client-_Y6ic-tf.js";
|
|
15
|
+
import { t as createDspyRlmTraceEngine } from "./dspy-rlm-engine-CSMwudLO.js";
|
|
16
|
+
import { i as otlpTextToTraceAnalysisStore, n as DEFAULT_MAX_TRACE_FILE_BYTES, t as BufferTraceStore } from "./store-otlp-BteDAbHK.js";
|
|
17
|
+
import "./external-optimizer-process-C3Wm7Vhn.js";
|
|
18
|
+
import { t as assertEqualDeclarativeTerms } from "./equal-terms-DbPGcVtI.js";
|
|
19
|
+
import { c as runPrimeExchange, l as decodeReplyRows, n as buildPrimePrompt, o as primeProtocolSha256, s as projectPrimeTrajectory, t as analystUsageReceiptFromPrimeUsage } from "./prime-protocol-BFgGrEMP.js";
|
|
21
20
|
import { t as nodeHttpPrimeBridgeTransport } from "./prime-bridge-transport-Z3cpKGoV.js";
|
|
22
21
|
import { createHash, randomUUID } from "node:crypto";
|
|
23
22
|
import { constants, existsSync, lstatSync, readFileSync } from "node:fs";
|
|
@@ -28,6 +27,504 @@ import { arch, platform } from "node:os";
|
|
|
28
27
|
import { pathToFileURL } from "node:url";
|
|
29
28
|
import { link, lstat, mkdir, open, readFile, readdir, realpath, stat, unlink } from "node:fs/promises";
|
|
30
29
|
import { TextDecoder as TextDecoder$1 } from "node:util";
|
|
30
|
+
import { performance } from "node:perf_hooks";
|
|
31
|
+
import { linearSumAssignment } from "linear-sum-assignment";
|
|
32
|
+
//#region src/analyst/benchmark-scoring.ts
|
|
33
|
+
function scoreAnalystFindings(testCase, findings) {
|
|
34
|
+
assertValidAnalystScoringCase(testCase);
|
|
35
|
+
const matchedFindingByIssue = matchFindingsToIssues(testCase.expectedIssues, findings);
|
|
36
|
+
const matchedIssueIds = testCase.expectedIssues.filter((_, index) => matchedFindingByIssue.has(index)).map((issue) => issue.id);
|
|
37
|
+
const missedIssueIds = testCase.expectedIssues.filter((_, index) => !matchedFindingByIssue.has(index)).map((issue) => issue.id);
|
|
38
|
+
const supportedFindingIndexes = new Set(matchedFindingByIssue.values());
|
|
39
|
+
const unsupportedFindingIndexes = findings.map((_, index) => index).filter((index) => !supportedFindingIndexes.has(index));
|
|
40
|
+
const expectedIssueCount = testCase.expectedIssues.length;
|
|
41
|
+
const issueRecall = expectedIssueCount === 0 ? 1 : matchedIssueIds.length / expectedIssueCount;
|
|
42
|
+
const findingPrecision = findings.length === 0 ? expectedIssueCount === 0 ? 1 : 0 : supportedFindingIndexes.size / findings.length;
|
|
43
|
+
const f1 = harmonicMeanScore(findingPrecision, issueRecall);
|
|
44
|
+
const allEvidence = findings.flatMap((finding) => finding.evidence_refs);
|
|
45
|
+
const criticalIssues = testCase.expectedIssues.filter((issue) => (issue.criticalEvidence?.length ?? 0) > 0);
|
|
46
|
+
const criticalHits = testCase.expectedIssues.filter((issue) => {
|
|
47
|
+
if ((issue.criticalEvidence?.length ?? 0) === 0) return false;
|
|
48
|
+
return matchesEvidence(allEvidence, issue.criticalEvidence ?? [], "any");
|
|
49
|
+
}).length;
|
|
50
|
+
const findingsWithEvidence = findings.filter((finding) => finding.evidence_refs.length > 0).length;
|
|
51
|
+
const unlabeledEvidence = testCase.labeledEvidence ? allEvidence.filter((ref) => !testCase.labeledEvidence.some((expected) => evidenceMatches(ref, expected))) : [];
|
|
52
|
+
return {
|
|
53
|
+
expectedIssueCount,
|
|
54
|
+
matchedIssueIds,
|
|
55
|
+
missedIssueIds,
|
|
56
|
+
supportedFindingIndexes: [...supportedFindingIndexes].sort((a, b) => a - b),
|
|
57
|
+
unsupportedFindingIndexes,
|
|
58
|
+
unlabeledEvidence,
|
|
59
|
+
issueRecall,
|
|
60
|
+
findingPrecision,
|
|
61
|
+
f1,
|
|
62
|
+
criticalStepAccuracy: criticalIssues.length === 0 ? null : criticalHits / criticalIssues.length,
|
|
63
|
+
citationCoverage: findings.length === 0 ? null : findingsWithEvidence / findings.length,
|
|
64
|
+
citationExcerptCoverage: allEvidence.length === 0 ? null : allEvidence.filter((evidence) => Boolean(evidence.excerpt?.trim())).length / allEvidence.length,
|
|
65
|
+
citationLabelAgreement: testCase.labeledEvidence === void 0 ? null : allEvidence.length === 0 ? findings.length === 0 ? null : 0 : (allEvidence.length - unlabeledEvidence.length) / allEvidence.length,
|
|
66
|
+
predictionOnLabelEmptyCase: expectedIssueCount === 0 && findings.length > 0
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function assertValidAnalystScoringCase(testCase) {
|
|
70
|
+
if (!testCase.id.trim()) throw new TypeError("analyst benchmark case id must not be empty");
|
|
71
|
+
const ids = /* @__PURE__ */ new Set();
|
|
72
|
+
for (const issue of testCase.expectedIssues) {
|
|
73
|
+
if (!issue.id.trim()) throw new TypeError(`${testCase.id}: expected issue id must not be empty`);
|
|
74
|
+
if (ids.has(issue.id)) throw new TypeError(`${testCase.id}: duplicate expected issue id '${issue.id}'`);
|
|
75
|
+
ids.add(issue.id);
|
|
76
|
+
if (!issue.findingIds?.length && !issue.areas?.length && !issue.subjects?.length && !issue.evidence?.length) throw new TypeError(`${testCase.id}/${issue.id}: expected issue must identify a finding by id, area, subject, or evidence`);
|
|
77
|
+
}
|
|
78
|
+
for (const ref of testCase.labeledEvidence ?? []) if (!ref.uri.trim()) throw new TypeError(`${testCase.id}: labeled evidence URI must not be empty`);
|
|
79
|
+
}
|
|
80
|
+
function harmonicMeanScore(a, b) {
|
|
81
|
+
return a + b === 0 ? 0 : 2 * a * b / (a + b);
|
|
82
|
+
}
|
|
83
|
+
function matchFindingsToIssues(issues, findings) {
|
|
84
|
+
if (issues.length === 0) return /* @__PURE__ */ new Map();
|
|
85
|
+
const cardinalityWeight = issues.length + 1;
|
|
86
|
+
const scores = issues.map((issue) => [...findings.map((finding) => {
|
|
87
|
+
if (!findingMatchesIssue(finding, issue)) return -1;
|
|
88
|
+
const criticalHit = (issue.criticalEvidence?.length ?? 0) > 0 && matchesEvidence(finding.evidence_refs, issue.criticalEvidence ?? [], "any");
|
|
89
|
+
return cardinalityWeight + Number(criticalHit);
|
|
90
|
+
}), ...Array.from({ length: issues.length }, () => 0)]);
|
|
91
|
+
const assignment = linearSumAssignment(scores, { maximaze: true }).rowAssignments;
|
|
92
|
+
const matches = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const [issueIndex, column] of assignment.entries()) {
|
|
94
|
+
if (column < 0 || column >= findings.length) continue;
|
|
95
|
+
if (!findingMatchesIssue(findings[column], issues[issueIndex])) continue;
|
|
96
|
+
matches.set(issueIndex, column);
|
|
97
|
+
}
|
|
98
|
+
return matches;
|
|
99
|
+
}
|
|
100
|
+
function findingMatchesIssue(finding, issue) {
|
|
101
|
+
if (issue.findingIds && !issue.findingIds.includes(finding.finding_id)) return false;
|
|
102
|
+
if (issue.areas && !issue.areas.includes(finding.area)) return false;
|
|
103
|
+
if (issue.subjects && (!finding.subject || !issue.subjects.includes(finding.subject))) return false;
|
|
104
|
+
if (issue.evidence && !matchesEvidence(finding.evidence_refs, issue.evidence, issue.evidenceMode ?? "any")) return false;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function matchesEvidence(actual, expected, mode) {
|
|
108
|
+
if (expected.length === 0) return true;
|
|
109
|
+
const match = (target) => actual.some((ref) => evidenceMatches(ref, target));
|
|
110
|
+
return mode === "all" ? expected.every(match) : expected.some(match);
|
|
111
|
+
}
|
|
112
|
+
function evidenceMatches(actual, expected) {
|
|
113
|
+
return actual.uri === expected.uri && (expected.kind === void 0 || actual.kind === expected.kind);
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/analyst/benchmark-summary.ts
|
|
117
|
+
function summarizeAnalystBenchmarkRunner(runnerId, observations) {
|
|
118
|
+
const issueBearing = observations.filter((observation) => observation.labelState === "positive");
|
|
119
|
+
const completed = observations.filter((observation) => !observation.error);
|
|
120
|
+
const expectedIssues = issueBearing.reduce((sum, observation) => sum + observation.score.expectedIssueCount, 0);
|
|
121
|
+
const matchedIssues = issueBearing.reduce((sum, observation) => sum + observation.score.matchedIssueIds.length, 0);
|
|
122
|
+
const issueFindings = issueBearing.reduce((sum, observation) => sum + (observation.error ? 0 : observation.findings.length), 0);
|
|
123
|
+
const supportedFindings = issueBearing.reduce((sum, observation) => sum + observation.score.supportedFindingIndexes.length, 0);
|
|
124
|
+
const issueRecall = expectedIssues === 0 ? null : matchedIssues / expectedIssues;
|
|
125
|
+
const findingPrecision = expectedIssues === 0 ? null : issueFindings === 0 ? 0 : supportedFindings / issueFindings;
|
|
126
|
+
const macroIssueRecall = issueBearing.length === 0 ? null : mean$2(issueBearing.map((observation) => observation.score.issueRecall));
|
|
127
|
+
const macroFindingPrecision = issueBearing.length === 0 ? null : mean$2(issueBearing.map((observation) => observation.score.findingPrecision));
|
|
128
|
+
const macroF1 = issueBearing.length === 0 ? null : mean$2(issueBearing.map((observation) => observation.score.f1));
|
|
129
|
+
const critical = observations.map((observation) => observation.score.criticalStepAccuracy).filter((value) => value !== null);
|
|
130
|
+
const findingsWithEvidence = completed.reduce((sum, observation) => sum + observation.findings.filter((finding) => finding.evidence_refs.length > 0).length, 0);
|
|
131
|
+
const allFindings = completed.reduce((sum, observation) => sum + observation.findings.length, 0);
|
|
132
|
+
const allCitations = completed.flatMap((observation) => observation.findings.flatMap((finding) => finding.evidence_refs));
|
|
133
|
+
const citationObservations = completed.filter((observation) => observation.score.citationLabelAgreement !== null);
|
|
134
|
+
const citationCount = citationObservations.reduce((sum, observation) => sum + observation.findings.reduce((count, finding) => count + finding.evidence_refs.length, 0), 0);
|
|
135
|
+
const invalidCitationCount = citationObservations.reduce((sum, observation) => sum + observation.score.unlabeledEvidence.length, 0);
|
|
136
|
+
const trustedNegative = observations.filter((observation) => observation.labelState === "trusted-negative");
|
|
137
|
+
const completedTrustedNegative = trustedNegative.filter((observation) => !observation.error);
|
|
138
|
+
const unlabeled = observations.filter((observation) => observation.labelState === "unlabeled");
|
|
139
|
+
const completedUnlabeled = unlabeled.filter((observation) => !observation.error);
|
|
140
|
+
const resolvedCitations = completed.reduce((sum, observation) => sum + (observation.evidenceResolution?.resolved ?? 0), 0);
|
|
141
|
+
const unresolvedCitations = completed.reduce((sum, observation) => sum + (observation.evidenceResolution?.unresolvedEvidence.length ?? 0), 0);
|
|
142
|
+
const citationResolutionErrors = completed.reduce((sum, observation) => sum + (observation.evidenceResolution?.errors.length ?? 0), 0);
|
|
143
|
+
const resolutionAttempts = completed.filter((observation) => observation.findings.some((finding) => finding.evidence_refs.length > 0));
|
|
144
|
+
const citationResolutionUnknownRuns = resolutionAttempts.filter((observation) => !observation.evidenceResolution || observation.evidenceResolution.errors.length > 0).length;
|
|
145
|
+
const usages = observations.map((observation) => observation.usage);
|
|
146
|
+
const knownCostUsd = stableSum(usages.map((usage) => {
|
|
147
|
+
if (!usage) return 0;
|
|
148
|
+
return usage.cost.kind === "uncaptured" ? usage.knownCostUsd ?? 0 : usage.cost.usd;
|
|
149
|
+
}));
|
|
150
|
+
const predictionAgreement = repeatedObservationAgreement(observations, predictionSignature);
|
|
151
|
+
const matchedLabelAgreement = repeatedObservationAgreement(observations.filter((observation) => observation.labelState === "positive"), matchedLabelSignature);
|
|
152
|
+
return {
|
|
153
|
+
runnerId,
|
|
154
|
+
plannedRuns: observations.length,
|
|
155
|
+
completedRuns: observations.filter((observation) => !observation.error).length,
|
|
156
|
+
failedRuns: observations.filter((observation) => Boolean(observation.error)).length,
|
|
157
|
+
issueBearingRuns: issueBearing.length,
|
|
158
|
+
trustedNegativeRuns: trustedNegative.length,
|
|
159
|
+
unlabeledRuns: unlabeled.length,
|
|
160
|
+
issueRecall,
|
|
161
|
+
findingPrecision,
|
|
162
|
+
f1: findingPrecision === null || issueRecall === null ? null : harmonicMeanScore(findingPrecision, issueRecall),
|
|
163
|
+
macroIssueRecall,
|
|
164
|
+
macroFindingPrecision,
|
|
165
|
+
macroF1,
|
|
166
|
+
criticalStepAccuracy: critical.length === 0 ? null : mean$2(critical),
|
|
167
|
+
citationCoverage: allFindings === 0 ? null : findingsWithEvidence / allFindings,
|
|
168
|
+
citationExcerptCoverage: allCitations.length === 0 ? null : allCitations.filter((evidence) => Boolean(evidence.excerpt?.trim())).length / allCitations.length,
|
|
169
|
+
citationLabelAgreement: citationObservations.length === 0 ? null : citationCount === 0 ? 0 : (citationCount - invalidCitationCount) / citationCount,
|
|
170
|
+
citationResolution: resolutionAttempts.length === 0 || citationResolutionUnknownRuns > 0 || resolvedCitations + unresolvedCitations === 0 ? null : resolvedCitations / (resolvedCitations + unresolvedCitations),
|
|
171
|
+
citationResolutionUnknownRuns,
|
|
172
|
+
unresolvedCitations,
|
|
173
|
+
citationResolutionErrors,
|
|
174
|
+
trustedNegativeFalsePositiveRate: completedTrustedNegative.length === 0 ? null : completedTrustedNegative.filter((observation) => observation.score.predictionOnLabelEmptyCase).length / completedTrustedNegative.length,
|
|
175
|
+
trustedNegativeFailureRate: trustedNegative.length === 0 ? null : trustedNegative.filter((observation) => Boolean(observation.error)).length / trustedNegative.length,
|
|
176
|
+
unlabeledPredictionRate: completedUnlabeled.length === 0 ? null : completedUnlabeled.filter((observation) => observation.findings.length > 0).length / completedUnlabeled.length,
|
|
177
|
+
unlabeledFailureRate: unlabeled.length === 0 ? null : unlabeled.filter((observation) => Boolean(observation.error)).length / unlabeled.length,
|
|
178
|
+
predictionAgreement: predictionAgreement.value,
|
|
179
|
+
predictionAgreementCases: predictionAgreement.cases,
|
|
180
|
+
matchedLabelAgreement: matchedLabelAgreement.value,
|
|
181
|
+
matchedLabelAgreementCases: matchedLabelAgreement.cases,
|
|
182
|
+
latencyMs: latencyDistribution(observations.map((observation) => observation.latencyMs).filter((value) => value !== null)),
|
|
183
|
+
benchmarkClockLatencyRuns: observations.filter((observation) => observation.latencySource === "benchmark-clock").length,
|
|
184
|
+
runnerReportedLatencyRuns: observations.filter((observation) => observation.latencySource === "runner-reported").length,
|
|
185
|
+
latencyUnknownRuns: observations.filter((observation) => observation.latencySource === "uncaptured").length,
|
|
186
|
+
calls: usages.reduce((sum, usage) => sum + (usage?.calls ?? 0), 0),
|
|
187
|
+
callsUnknownRuns: usages.filter((usage) => !usage || usage.calls === null).length,
|
|
188
|
+
inputTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.input ?? 0), 0),
|
|
189
|
+
outputTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.output ?? 0), 0),
|
|
190
|
+
reasoningTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.reasoning ?? 0), 0),
|
|
191
|
+
cachedTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.cached ?? 0), 0),
|
|
192
|
+
cacheWriteTokens: usages.reduce((sum, usage) => sum + (usage?.tokens?.cacheWrite ?? 0), 0),
|
|
193
|
+
tokenUsageUnknownRuns: usages.filter((usage) => !usage?.tokens).length,
|
|
194
|
+
reasoningTokenUsageUnknownRuns: usages.filter((usage) => usage?.tokens?.reasoning === void 0).length,
|
|
195
|
+
cachedTokenUsageUnknownRuns: usages.filter((usage) => usage?.tokens?.cached === void 0).length,
|
|
196
|
+
cacheWriteTokenUsageUnknownRuns: usages.filter((usage) => usage?.tokens?.cacheWrite === void 0).length,
|
|
197
|
+
knownCostUsd,
|
|
198
|
+
costUnknownRuns: usages.filter((usage) => !usage || usage.cost.kind === "uncaptured").length
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function mean$2(values) {
|
|
202
|
+
return values.length === 0 ? 0 : stableSum(values) / values.length;
|
|
203
|
+
}
|
|
204
|
+
function stableSum(values) {
|
|
205
|
+
const ordered = [...values].sort((left, right) => Math.abs(left) - Math.abs(right) || left - right);
|
|
206
|
+
let sum = 0;
|
|
207
|
+
let correction = 0;
|
|
208
|
+
for (const value of ordered) {
|
|
209
|
+
const next = sum + value;
|
|
210
|
+
correction += Math.abs(sum) >= Math.abs(value) ? sum - next + value : value - next + sum;
|
|
211
|
+
sum = next;
|
|
212
|
+
}
|
|
213
|
+
return sum + correction;
|
|
214
|
+
}
|
|
215
|
+
function latencyDistribution(values) {
|
|
216
|
+
if (values.length === 0) return null;
|
|
217
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
218
|
+
return {
|
|
219
|
+
min: sorted[0],
|
|
220
|
+
mean: mean$2(sorted),
|
|
221
|
+
p50: percentile(sorted, .5),
|
|
222
|
+
p95: percentile(sorted, .95),
|
|
223
|
+
max: sorted.at(-1)
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function percentile(sorted, quantile) {
|
|
227
|
+
if (sorted.length === 0) return 0;
|
|
228
|
+
return sorted[Math.ceil(quantile * sorted.length) - 1] ?? sorted.at(-1) ?? 0;
|
|
229
|
+
}
|
|
230
|
+
function repeatedObservationAgreement(observations, signature) {
|
|
231
|
+
const byCase = /* @__PURE__ */ new Map();
|
|
232
|
+
for (const observation of observations) {
|
|
233
|
+
const rows = byCase.get(observation.caseId) ?? [];
|
|
234
|
+
rows.push(observation);
|
|
235
|
+
byCase.set(observation.caseId, rows);
|
|
236
|
+
}
|
|
237
|
+
const caseAgreements = [];
|
|
238
|
+
for (const rows of byCase.values()) {
|
|
239
|
+
const agreements = [];
|
|
240
|
+
for (let left = 0; left < rows.length; left++) for (let right = left + 1; right < rows.length; right++) agreements.push(jaccard(signature(rows[left]), signature(rows[right])));
|
|
241
|
+
if (agreements.length > 0) caseAgreements.push(mean$2(agreements));
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
value: caseAgreements.length === 0 ? null : mean$2(caseAgreements),
|
|
245
|
+
cases: caseAgreements.length
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function matchedLabelSignature(observation) {
|
|
249
|
+
if (observation.error) return [`error:${observation.error.class}`];
|
|
250
|
+
return observation.score.matchedIssueIds;
|
|
251
|
+
}
|
|
252
|
+
function predictionSignature(observation) {
|
|
253
|
+
if (observation.error) return [`error:${observation.error.class}`];
|
|
254
|
+
return observation.findings.map((finding) => JSON.stringify([finding.finding_id, finding.evidence_refs.map((evidence) => [
|
|
255
|
+
evidence.kind,
|
|
256
|
+
evidence.uri,
|
|
257
|
+
evidence.excerpt ?? null
|
|
258
|
+
]).sort((left, right) => compareCodeUnits(JSON.stringify(left), JSON.stringify(right)))])).sort();
|
|
259
|
+
}
|
|
260
|
+
function jaccard(left, right) {
|
|
261
|
+
const a = new Set(left);
|
|
262
|
+
const b = new Set(right);
|
|
263
|
+
const union = /* @__PURE__ */ new Set([...a, ...b]);
|
|
264
|
+
if (union.size === 0) return 1;
|
|
265
|
+
let intersection = 0;
|
|
266
|
+
for (const value of a) if (b.has(value)) intersection += 1;
|
|
267
|
+
return intersection / union.size;
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/analyst/benchmark.ts
|
|
271
|
+
/**
|
|
272
|
+
* Resolve canonical `trace://<trace>/span/<span>` evidence against a trace store.
|
|
273
|
+
* Other evidence kinds and URI schemes require a caller-supplied resolver.
|
|
274
|
+
*/
|
|
275
|
+
function traceStoreEvidenceResolver(getStore) {
|
|
276
|
+
return async ({ caseInput, evidence, signal }) => {
|
|
277
|
+
if (evidence.kind !== "span") return false;
|
|
278
|
+
const location = parseTraceSpanUri(evidence.uri);
|
|
279
|
+
if (!location) return false;
|
|
280
|
+
const result = await getStore(caseInput).viewSpans({
|
|
281
|
+
trace_id: location.traceId,
|
|
282
|
+
span_ids: [location.spanId]
|
|
283
|
+
}, signal ? { signal } : void 0);
|
|
284
|
+
return result.trace_id === location.traceId && result.missing_span_ids.length === 0 && result.spans.some((span) => span.span_id === location.spanId);
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
async function runAnalystBenchmark(options) {
|
|
288
|
+
validateBenchmarkOptions(options);
|
|
289
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
290
|
+
const repetitions = options.repetitions ?? 1;
|
|
291
|
+
const runnerOrderSeed = options.runnerOrderSeed ?? 0;
|
|
292
|
+
const allJobs = benchmarkJobs(options.cases, options.runners, repetitions, runnerOrderSeed);
|
|
293
|
+
const maxConcurrency = Math.min(options.maxConcurrency ?? 1, allJobs.length);
|
|
294
|
+
const initialObservations = validateInitialObservations(options.initialObservations ?? [], allJobs);
|
|
295
|
+
const completed = new Set(initialObservations.map(observationKey$1));
|
|
296
|
+
const jobs = allJobs.filter((job) => !completed.has(jobKey(job)));
|
|
297
|
+
const observations = [...initialObservations];
|
|
298
|
+
let cursor = 0;
|
|
299
|
+
const worker = async () => {
|
|
300
|
+
while (cursor < jobs.length) {
|
|
301
|
+
options.signal?.throwIfAborted();
|
|
302
|
+
const job = jobs[cursor++];
|
|
303
|
+
const observation = await runBenchmarkJob(job, options.signal, options.resolveEvidence);
|
|
304
|
+
options.signal?.throwIfAborted();
|
|
305
|
+
await options.onObservation?.(observation);
|
|
306
|
+
options.signal?.throwIfAborted();
|
|
307
|
+
observations.push(observation);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
await Promise.all(Array.from({ length: Math.min(maxConcurrency, jobs.length) }, worker));
|
|
311
|
+
options.signal?.throwIfAborted();
|
|
312
|
+
const runnerOrder = new Map(options.runners.map((runner, index) => [runner.id, index]));
|
|
313
|
+
const caseOrder = new Map(options.cases.map((testCase, index) => [testCase.id, index]));
|
|
314
|
+
observations.sort((a, b) => (runnerOrder.get(a.runnerId) ?? 0) - (runnerOrder.get(b.runnerId) ?? 0) || (caseOrder.get(a.caseId) ?? 0) - (caseOrder.get(b.caseId) ?? 0) || a.repetition - b.repetition);
|
|
315
|
+
return {
|
|
316
|
+
provenance: {
|
|
317
|
+
...options.benchmark,
|
|
318
|
+
startedAt,
|
|
319
|
+
endedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
320
|
+
caseCount: options.cases.length,
|
|
321
|
+
runnerIds: options.runners.map((runner) => runner.id),
|
|
322
|
+
repetitions,
|
|
323
|
+
maxConcurrency,
|
|
324
|
+
runnerOrderSeed
|
|
325
|
+
},
|
|
326
|
+
observations,
|
|
327
|
+
summaries: options.runners.map((runner) => summarizeAnalystBenchmarkRunner(runner.id, observations.filter((observation) => observation.runnerId === runner.id)))
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
async function runBenchmarkJob(job, signal, resolveEvidence) {
|
|
331
|
+
const started = performance.now();
|
|
332
|
+
try {
|
|
333
|
+
const output = await job.runner.analyze(job.testCase.input, {
|
|
334
|
+
caseId: job.testCase.id,
|
|
335
|
+
repetition: job.repetition,
|
|
336
|
+
signal
|
|
337
|
+
});
|
|
338
|
+
if (output.usage) assertValidAnalystUsageReceipt(output.usage, "analyst benchmark usage");
|
|
339
|
+
const benchmarkLatencyMs = performance.now() - started;
|
|
340
|
+
const latency = resolveBenchmarkLatency(output.observedLatencyMs, benchmarkLatencyMs);
|
|
341
|
+
const scoredFindings = output.error ? [] : output.findings;
|
|
342
|
+
return {
|
|
343
|
+
runnerId: job.runner.id,
|
|
344
|
+
caseId: job.testCase.id,
|
|
345
|
+
clusterId: job.testCase.clusterId,
|
|
346
|
+
labelState: job.testCase.labelState,
|
|
347
|
+
repetition: job.repetition,
|
|
348
|
+
executionIndex: job.executionIndex,
|
|
349
|
+
latencyMs: latency.value,
|
|
350
|
+
latencySource: latency.source,
|
|
351
|
+
findings: output.findings,
|
|
352
|
+
score: scoreAnalystFindings(job.testCase, scoredFindings),
|
|
353
|
+
evidenceResolution: resolveEvidence ? await resolveFindingEvidence(job.testCase, output.findings, resolveEvidence, signal) : void 0,
|
|
354
|
+
caseTags: [...job.testCase.tags ?? []],
|
|
355
|
+
caseMetadata: job.testCase.metadata,
|
|
356
|
+
usage: output.usage,
|
|
357
|
+
runnerMetadata: output.metadata,
|
|
358
|
+
...output.error ? { error: output.error } : {}
|
|
359
|
+
};
|
|
360
|
+
} catch (error) {
|
|
361
|
+
if (signal?.aborted) throw error;
|
|
362
|
+
const findings = [];
|
|
363
|
+
return {
|
|
364
|
+
runnerId: job.runner.id,
|
|
365
|
+
caseId: job.testCase.id,
|
|
366
|
+
clusterId: job.testCase.clusterId,
|
|
367
|
+
labelState: job.testCase.labelState,
|
|
368
|
+
repetition: job.repetition,
|
|
369
|
+
executionIndex: job.executionIndex,
|
|
370
|
+
latencyMs: performance.now() - started,
|
|
371
|
+
latencySource: "benchmark-clock",
|
|
372
|
+
findings,
|
|
373
|
+
score: scoreAnalystFindings(job.testCase, findings),
|
|
374
|
+
caseTags: [...job.testCase.tags ?? []],
|
|
375
|
+
caseMetadata: job.testCase.metadata,
|
|
376
|
+
error: {
|
|
377
|
+
class: error instanceof Error ? error.constructor.name : "Error",
|
|
378
|
+
message: error instanceof Error ? error.message : String(error)
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function resolveBenchmarkLatency(observedLatencyMs, fallbackMs) {
|
|
384
|
+
if (observedLatencyMs === void 0) return {
|
|
385
|
+
value: fallbackMs,
|
|
386
|
+
source: "benchmark-clock"
|
|
387
|
+
};
|
|
388
|
+
if (observedLatencyMs === null) return {
|
|
389
|
+
value: null,
|
|
390
|
+
source: "uncaptured"
|
|
391
|
+
};
|
|
392
|
+
if (!Number.isFinite(observedLatencyMs) || observedLatencyMs < 0) throw new RangeError("analyst benchmark observedLatencyMs must be finite and non-negative");
|
|
393
|
+
return {
|
|
394
|
+
value: observedLatencyMs,
|
|
395
|
+
source: "runner-reported"
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function benchmarkJobs(cases, runners, repetitions, runnerOrderSeed) {
|
|
399
|
+
const seededRunners = [...runners].sort((left, right) => stableHash(`${runnerOrderSeed}\u0000${left.id}`) - stableHash(`${runnerOrderSeed}\u0000${right.id}`) || left.id.localeCompare(right.id));
|
|
400
|
+
let executionIndex = 0;
|
|
401
|
+
return cases.flatMap((testCase, caseIndex) => Array.from({ length: repetitions }, (_, repetition) => {
|
|
402
|
+
const rotation = (caseIndex * repetitions + repetition) % seededRunners.length;
|
|
403
|
+
return [...seededRunners.slice(rotation), ...seededRunners.slice(0, rotation)].map((runner) => ({
|
|
404
|
+
runner,
|
|
405
|
+
testCase,
|
|
406
|
+
repetition,
|
|
407
|
+
executionIndex: executionIndex++
|
|
408
|
+
}));
|
|
409
|
+
}).flat());
|
|
410
|
+
}
|
|
411
|
+
function validateInitialObservations(observations, jobs) {
|
|
412
|
+
const expected = new Map(jobs.map((job) => [jobKey(job), job]));
|
|
413
|
+
const seen = /* @__PURE__ */ new Set();
|
|
414
|
+
return observations.map((observation) => {
|
|
415
|
+
const key = observationKey$1(observation);
|
|
416
|
+
if (seen.has(key)) throw new TypeError(`duplicate initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`);
|
|
417
|
+
seen.add(key);
|
|
418
|
+
const job = expected.get(key);
|
|
419
|
+
if (!job) throw new TypeError(`initial analyst benchmark observation does not match a planned job: '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`);
|
|
420
|
+
if (observation.executionIndex !== job.executionIndex) throw new TypeError(`initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has executionIndex ${observation.executionIndex}; expected ${job.executionIndex}`);
|
|
421
|
+
if (observation.clusterId !== job.testCase.clusterId || observation.labelState !== job.testCase.labelState) throw new TypeError(`initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' does not match the current case labels`);
|
|
422
|
+
if (JSON.stringify(observation.caseTags) !== JSON.stringify(job.testCase.tags ?? []) || JSON.stringify(observation.caseMetadata) !== JSON.stringify(job.testCase.metadata)) throw new TypeError(`initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' does not match the current case metadata`);
|
|
423
|
+
const expectedScore = scoreAnalystFindings(job.testCase, observation.error ? [] : observation.findings);
|
|
424
|
+
if (JSON.stringify(observation.score) !== JSON.stringify(expectedScore)) throw new TypeError(`initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has stale or invalid scores`);
|
|
425
|
+
if (observation.usage) assertValidAnalystUsageReceipt(observation.usage, `initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' usage`);
|
|
426
|
+
if (![
|
|
427
|
+
"benchmark-clock",
|
|
428
|
+
"runner-reported",
|
|
429
|
+
"uncaptured"
|
|
430
|
+
].includes(observation.latencySource) || observation.latencySource === "uncaptured" && observation.latencyMs !== null || observation.latencySource !== "uncaptured" && (observation.latencyMs === null || !Number.isFinite(observation.latencyMs) || observation.latencyMs < 0)) throw new TypeError(`initial analyst benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' has invalid latency`);
|
|
431
|
+
return { ...observation };
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
function jobKey(job) {
|
|
435
|
+
return `${job.runner.id}\u0000${job.testCase.id}\u0000${job.repetition}`;
|
|
436
|
+
}
|
|
437
|
+
function observationKey$1(observation) {
|
|
438
|
+
return `${observation.runnerId}\u0000${observation.caseId}\u0000${observation.repetition}`;
|
|
439
|
+
}
|
|
440
|
+
async function resolveFindingEvidence(testCase, findings, resolver, signal) {
|
|
441
|
+
const evidence = findings.flatMap((finding) => finding.evidence_refs);
|
|
442
|
+
const resolved = [];
|
|
443
|
+
const unresolvedEvidence = [];
|
|
444
|
+
const errors = [];
|
|
445
|
+
for (const ref of evidence) {
|
|
446
|
+
signal?.throwIfAborted();
|
|
447
|
+
try {
|
|
448
|
+
if (await resolver({
|
|
449
|
+
caseId: testCase.id,
|
|
450
|
+
caseInput: testCase.input,
|
|
451
|
+
evidence: ref,
|
|
452
|
+
signal
|
|
453
|
+
})) resolved.push(ref);
|
|
454
|
+
else unresolvedEvidence.push(ref);
|
|
455
|
+
} catch (error) {
|
|
456
|
+
if (signal?.aborted) throw error;
|
|
457
|
+
errors.push({
|
|
458
|
+
evidence: ref,
|
|
459
|
+
class: error instanceof Error ? error.constructor.name : "Error",
|
|
460
|
+
message: error instanceof Error ? error.message : String(error)
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
checked: evidence.length,
|
|
466
|
+
resolved: resolved.length,
|
|
467
|
+
unresolvedEvidence,
|
|
468
|
+
errors,
|
|
469
|
+
validity: evidence.length === 0 || errors.length > 0 ? null : resolved.length / evidence.length
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function parseTraceSpanUri(uri) {
|
|
473
|
+
const match = /^trace:\/\/([^/]+)\/span\/([^/]+)$/.exec(uri);
|
|
474
|
+
if (!match) return null;
|
|
475
|
+
try {
|
|
476
|
+
const traceId = decodeURIComponent(match[1]);
|
|
477
|
+
const spanId = decodeURIComponent(match[2]);
|
|
478
|
+
return traceId && spanId ? {
|
|
479
|
+
traceId,
|
|
480
|
+
spanId
|
|
481
|
+
} : null;
|
|
482
|
+
} catch {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
function validateBenchmarkOptions(options) {
|
|
487
|
+
if (options.cases.length === 0) throw new TypeError("runAnalystBenchmark requires cases");
|
|
488
|
+
if (options.runners.length === 0) throw new TypeError("runAnalystBenchmark requires runners");
|
|
489
|
+
const repetitions = options.repetitions ?? 1;
|
|
490
|
+
const maxConcurrency = options.maxConcurrency ?? 1;
|
|
491
|
+
if (!Number.isSafeInteger(repetitions) || repetitions < 1) throw new RangeError("runAnalystBenchmark repetitions must be a positive safe integer");
|
|
492
|
+
if (!Number.isSafeInteger(maxConcurrency) || maxConcurrency < 1) throw new RangeError("runAnalystBenchmark maxConcurrency must be a positive safe integer");
|
|
493
|
+
if (!Number.isSafeInteger(options.runnerOrderSeed ?? 0)) throw new RangeError("runAnalystBenchmark runnerOrderSeed must be a safe integer");
|
|
494
|
+
assertUniqueNonEmpty(options.cases.map((testCase) => testCase.id), "case");
|
|
495
|
+
assertUniqueNonEmpty(options.runners.map((runner) => runner.id), "runner");
|
|
496
|
+
for (const testCase of options.cases) validateBenchmarkCase(testCase);
|
|
497
|
+
}
|
|
498
|
+
function validateBenchmarkCase(testCase) {
|
|
499
|
+
assertValidAnalystScoringCase(testCase);
|
|
500
|
+
if (!testCase.clusterId.trim()) throw new TypeError(`${testCase.id}: analyst benchmark clusterId must not be empty`);
|
|
501
|
+
if (testCase.labelState !== "positive" && testCase.labelState !== "trusted-negative" && testCase.labelState !== "unlabeled") throw new TypeError(`${testCase.id}: analyst benchmark labelState is invalid`);
|
|
502
|
+
if (testCase.labelState === "positive" && testCase.expectedIssues.length === 0) throw new TypeError(`${testCase.id}: positive case requires at least one expected issue`);
|
|
503
|
+
if (testCase.labelState !== "positive" && testCase.expectedIssues.length > 0) throw new TypeError(`${testCase.id}: ${testCase.labelState} case cannot contain expected issues`);
|
|
504
|
+
}
|
|
505
|
+
function assertUniqueNonEmpty(values, label) {
|
|
506
|
+
const seen = /* @__PURE__ */ new Set();
|
|
507
|
+
for (const value of values) {
|
|
508
|
+
if (!value.trim()) throw new TypeError(`analyst benchmark ${label} id must not be empty`);
|
|
509
|
+
if (seen.has(value)) throw new TypeError(`duplicate analyst benchmark ${label} id '${value}'`);
|
|
510
|
+
seen.add(value);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
/** 32-bit FNV-1a over raw UTF-16 code units, left SIGNED so subtracting two
|
|
514
|
+
* results is a valid comparator.
|
|
515
|
+
*
|
|
516
|
+
* Frozen: it fixes the runner order a benchmark reports. Adding the `>>> 0`
|
|
517
|
+
* the other variants carry would change that order, which is why this one
|
|
518
|
+
* does not have it. */
|
|
519
|
+
function stableHash(value) {
|
|
520
|
+
let hash = 2166136261;
|
|
521
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
522
|
+
hash ^= value.charCodeAt(index);
|
|
523
|
+
hash = Math.imul(hash, 16777619);
|
|
524
|
+
}
|
|
525
|
+
return hash >>> 0;
|
|
526
|
+
}
|
|
527
|
+
//#endregion
|
|
31
528
|
//#region src/analyst/benchmark-dataset-utils.ts
|
|
32
529
|
function normalizeBenchmarkLabel(value) {
|
|
33
530
|
const normalized = nonEmpty$1(value, "benchmark label").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -47,9 +544,6 @@ function assertStepWithinRange(step, stepCount, field) {
|
|
|
47
544
|
function defaultStepUri(trajectoryId, step) {
|
|
48
545
|
return `trace://${encodeURIComponent(trajectoryId)}/span/step-${step}`;
|
|
49
546
|
}
|
|
50
|
-
function isRecord$2(value) {
|
|
51
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
52
|
-
}
|
|
53
547
|
function positiveStep(value, field) {
|
|
54
548
|
if (!Number.isSafeInteger(value) || value < 1) throw new RangeError(`${field} must be a positive safe integer`);
|
|
55
549
|
return value;
|
|
@@ -203,7 +697,7 @@ function parseAgentRxPredictions(output, trajectoryId) {
|
|
|
203
697
|
let failures;
|
|
204
698
|
let report;
|
|
205
699
|
if (Array.isArray(output)) failures = output;
|
|
206
|
-
else if (isRecord
|
|
700
|
+
else if (isRecord(output)) {
|
|
207
701
|
assertMatchingAgentRxTaskId(output.task_id, trajectoryId, "report.task_id");
|
|
208
702
|
if (!Object.hasOwn(output, "failures")) throw new TypeError(`AgentRx prediction '${trajectoryId}' report must contain failures`);
|
|
209
703
|
failures = output.failures;
|
|
@@ -219,11 +713,11 @@ function parseAgentRxPredictions(output, trajectoryId) {
|
|
|
219
713
|
} else throw new TypeError(`AgentRx prediction '${trajectoryId}' must be a report or failures array`);
|
|
220
714
|
if (!Array.isArray(failures)) throw new TypeError(`AgentRx prediction '${trajectoryId}' failures must be an array`);
|
|
221
715
|
if (failures.length === 0) throw new TypeError(`AgentRx prediction '${trajectoryId}' failures must contain a judge prediction`);
|
|
222
|
-
if (isRecord
|
|
716
|
+
if (isRecord(output) && output.num_judges !== void 0 && output.num_judges !== failures.length) throw new TypeError(`AgentRx prediction '${trajectoryId}' declares ${output.num_judges} judges but contains ${failures.length} failures`);
|
|
223
717
|
return {
|
|
224
718
|
predictions: failures.map((value, index) => {
|
|
225
719
|
const field = `AgentRx prediction '${trajectoryId}' failures[${index}]`;
|
|
226
|
-
if (!isRecord
|
|
720
|
+
if (!isRecord(value)) throw new TypeError(`${field} must be an object`);
|
|
227
721
|
assertMatchingAgentRxTaskId(value.task_id, trajectoryId, `${field}.task_id`);
|
|
228
722
|
const failureCase = parseAgentRxFailureCase(value.failure_case, `${field}.failure_case`);
|
|
229
723
|
if (!Number.isSafeInteger(value.step_number)) throw new TypeError(`${field}.step_number must be a safe integer`);
|
|
@@ -437,7 +931,7 @@ function parseCodeTracerPredictionLabels(value, trajectoryId) {
|
|
|
437
931
|
flat.push(toCodeTracerPredictionLabel(item, codeTracerStageId(item, index + 1, trajectoryId), trajectoryId));
|
|
438
932
|
continue;
|
|
439
933
|
}
|
|
440
|
-
if (!isRecord
|
|
934
|
+
if (!isRecord(item) || !Array.isArray(item.labels)) throw new TypeError(`CodeTracer prediction '${trajectoryId}' contains an unsupported label row`);
|
|
441
935
|
const stageId = codeTracerStageId(item, index + 1, trajectoryId);
|
|
442
936
|
for (const label of item.labels) {
|
|
443
937
|
if (!isCodeTracerStepLabel(label)) throw new TypeError(`CodeTracer prediction '${trajectoryId}' contains an invalid step label`);
|
|
@@ -447,10 +941,10 @@ function parseCodeTracerPredictionLabels(value, trajectoryId) {
|
|
|
447
941
|
return flat;
|
|
448
942
|
}
|
|
449
943
|
function isCodeTraceStageAnnotation(value) {
|
|
450
|
-
return isRecord
|
|
944
|
+
return isRecord(value) && Number.isSafeInteger(value.stage_id) && value.stage_id > 0 && optionalStepArray(value.incorrect_step_ids) && optionalStepArray(value.unuseful_step_ids) && (value.reasoning === void 0 || typeof value.reasoning === "string");
|
|
451
945
|
}
|
|
452
946
|
function isCodeTracerStepLabel(value) {
|
|
453
|
-
return isRecord
|
|
947
|
+
return isRecord(value) && Number.isSafeInteger(value.step_id) && value.step_id > 0 && (value.stage === void 0 || typeof value.stage === "string" || typeof value.stage === "number") && (value.stage_name === void 0 || typeof value.stage_name === "string" || typeof value.stage_name === "number") && (value.stage_id === void 0 || typeof value.stage_id === "string" || typeof value.stage_id === "number") && (value.label === "incorrect" || value.label === "unuseful") && (value.rationale === void 0 || typeof value.rationale === "string") && (value.reason === void 0 || typeof value.reason === "string") && (value.note === void 0 || typeof value.note === "string") && (value.comment === void 0 || typeof value.comment === "string");
|
|
454
948
|
}
|
|
455
949
|
function toCodeTracerPredictionLabel(label, stageId, trajectoryId) {
|
|
456
950
|
if (!isCodeTracerStepLabel(label)) throw new TypeError(`CodeTracer prediction '${trajectoryId}' contains an invalid step label`);
|
|
@@ -728,8 +1222,8 @@ function compareMetric(options) {
|
|
|
728
1222
|
if (caseBefore.length === 0 || !clusterId) continue;
|
|
729
1223
|
pairedCases.push({
|
|
730
1224
|
clusterId,
|
|
731
|
-
baseline: mean$
|
|
732
|
-
candidate: mean$
|
|
1225
|
+
baseline: mean$3(caseBefore),
|
|
1226
|
+
candidate: mean$3(caseAfter)
|
|
733
1227
|
});
|
|
734
1228
|
}
|
|
735
1229
|
const byCluster = /* @__PURE__ */ new Map();
|
|
@@ -738,8 +1232,8 @@ function compareMetric(options) {
|
|
|
738
1232
|
rows.push(pairedCase);
|
|
739
1233
|
byCluster.set(pairedCase.clusterId, rows);
|
|
740
1234
|
}
|
|
741
|
-
const before = [...byCluster.values()].map((rows) => mean$
|
|
742
|
-
const after = [...byCluster.values()].map((rows) => mean$
|
|
1235
|
+
const before = [...byCluster.values()].map((rows) => mean$3(rows.map((row) => row.baseline)));
|
|
1236
|
+
const after = [...byCluster.values()].map((rows) => mean$3(rows.map((row) => row.candidate)));
|
|
743
1237
|
const interval = before.length === 0 ? null : pairedBootstrap(before, after, {
|
|
744
1238
|
confidence: options.confidence,
|
|
745
1239
|
resamples: options.resamples,
|
|
@@ -762,8 +1256,8 @@ function compareMetric(options) {
|
|
|
762
1256
|
candidateMissingObservations,
|
|
763
1257
|
asymmetricMissingObservations,
|
|
764
1258
|
survivorOnly,
|
|
765
|
-
baselineMean: before.length === 0 ? null : mean$
|
|
766
|
-
candidateMean: after.length === 0 ? null : mean$
|
|
1259
|
+
baselineMean: before.length === 0 ? null : mean$3(before),
|
|
1260
|
+
candidateMean: after.length === 0 ? null : mean$3(after),
|
|
767
1261
|
meanDelta: interval?.mean ?? null,
|
|
768
1262
|
intervalLow: interval?.low ?? null,
|
|
769
1263
|
intervalHigh: interval?.high ?? null,
|
|
@@ -1347,7 +1841,7 @@ const ANALYST_BENCHMARK_COST_LEDGER_FILE = "cost-ledger.jsonl";
|
|
|
1347
1841
|
function observationKey(observation) {
|
|
1348
1842
|
return `${observation.runnerId}\u0000${observation.caseId}\u0000${observation.repetition}`;
|
|
1349
1843
|
}
|
|
1350
|
-
function
|
|
1844
|
+
function parseJsonText(text, source) {
|
|
1351
1845
|
try {
|
|
1352
1846
|
return JSON.parse(text);
|
|
1353
1847
|
} catch {
|
|
@@ -1371,28 +1865,19 @@ function digestCanonical(value) {
|
|
|
1371
1865
|
}
|
|
1372
1866
|
/** RFC 8785 canonical JSON of the value's JSON document form — the byte form
|
|
1373
1867
|
* the receipt digests and compares against. */
|
|
1374
|
-
function
|
|
1868
|
+
function canonicalJsonDocument(value) {
|
|
1375
1869
|
return canonicalString(jsonDocument(value));
|
|
1376
1870
|
}
|
|
1377
|
-
function isRecord$1(value) {
|
|
1378
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1379
|
-
}
|
|
1380
1871
|
function isSha256(value) {
|
|
1381
1872
|
return typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
1382
1873
|
}
|
|
1383
|
-
|
|
1384
|
-
//#region src/analyst/benchmark-implementation.ts
|
|
1385
|
-
const ANALYST_BENCHMARK_IMPLEMENTATION_DIGEST_ALGORITHM = "sha256-canonical-source-manifest";
|
|
1386
|
-
/** The dependency files' manifest digest with the package's own version
|
|
1387
|
-
* fields blanked, so a release that only bumps the version keeps the pin. */
|
|
1388
|
-
const ANALYST_BENCHMARK_DEPENDENCY_LOCK_DIGEST_ALGORITHM = "sha256-canonical-file-manifest-without-own-version";
|
|
1389
|
-
const ANALYST_BENCHMARK_DEPENDENCY_LOCK_FILES = Object.freeze([
|
|
1874
|
+
Object.freeze([
|
|
1390
1875
|
"clients/python/pyproject.toml",
|
|
1391
1876
|
"clients/python/uv.lock",
|
|
1392
1877
|
"package.json",
|
|
1393
1878
|
"pnpm-lock.yaml"
|
|
1394
1879
|
]);
|
|
1395
|
-
const ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 = "
|
|
1880
|
+
const ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 = "79b7d34288f4a5c3fd39cc1d875b98507d822a27ae5adf2ad299c7ba2935fca4";
|
|
1396
1881
|
const ANALYST_BENCHMARK_EVIDENCE_DEPENDENCY_LOCK_SHA256 = "1e03f2daed356d60316aabefb407ec1e437ac94d408d61eea4ae096e9c6fbb5b";
|
|
1397
1882
|
const ANALYST_BENCHMARK_EVIDENCE_IMPLEMENTATION_SHA256 = "4dba263b6256a30d56c7fdb2d992d3a953c0035d731f359b704db806f68f75ac";
|
|
1398
1883
|
const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
@@ -1420,6 +1905,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1420
1905
|
"src/analyst/benchmark-instructions-override.ts",
|
|
1421
1906
|
"src/analyst/benchmark-public-adapters.ts",
|
|
1422
1907
|
"src/analyst/benchmark-public-calibration.ts",
|
|
1908
|
+
"src/analyst/benchmark-public-chunked.ts",
|
|
1423
1909
|
"src/analyst/benchmark-public-consensus.ts",
|
|
1424
1910
|
"src/analyst/benchmark-public-data.ts",
|
|
1425
1911
|
"src/analyst/benchmark-public-errors.ts",
|
|
@@ -1489,6 +1975,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1489
1975
|
"src/ledger-core/index.ts",
|
|
1490
1976
|
"src/ledger-core/journal-file.ts",
|
|
1491
1977
|
"src/ledger-core/journal.ts",
|
|
1978
|
+
"src/ledger-core/lock-holder.ts",
|
|
1492
1979
|
"src/ledger-core/merkle.ts",
|
|
1493
1980
|
"src/ledger-core/projector-snapshot.ts",
|
|
1494
1981
|
"src/ledger-core/trusted-head.ts",
|
|
@@ -1542,13 +2029,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1542
2029
|
"src/trace/redaction/detectors.ts",
|
|
1543
2030
|
"src/verdict-cache.ts"
|
|
1544
2031
|
]);
|
|
1545
|
-
const ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 = "
|
|
1546
|
-
function analystBenchmarkImplementationDigest() {
|
|
1547
|
-
return ANALYST_BENCHMARK_IMPLEMENTATION_SHA256;
|
|
1548
|
-
}
|
|
1549
|
-
function analystBenchmarkDependencyLockDigest() {
|
|
1550
|
-
return ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256;
|
|
1551
|
-
}
|
|
2032
|
+
const ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 = "f3ef71f1819dc0f9b35907c01bd2218e2802931b8749b77749127c3054149f3e";
|
|
1552
2033
|
//#endregion
|
|
1553
2034
|
//#region src/analyst/benchmark-evidence-validation.ts
|
|
1554
2035
|
const MIN_ACTION_EXCERPT_CHARACTERS = 12;
|
|
@@ -2356,17 +2837,6 @@ function isMissing(error) {
|
|
|
2356
2837
|
function isNodeError$1(error, code) {
|
|
2357
2838
|
return error instanceof Error && "code" in error && error.code === code;
|
|
2358
2839
|
}
|
|
2359
|
-
//#endregion
|
|
2360
|
-
//#region src/analyst/benchmark-public-prompt.ts
|
|
2361
|
-
/** Widest contiguous failure block a model may report. The published corpus's
|
|
2362
|
-
* widest labeled block is 8 steps and its widest stage span is 9, so this bound
|
|
2363
|
-
* never binds honest enumeration; it caps how far one over-wide block can push
|
|
2364
|
-
* unlabeled steps into the precision denominator. */
|
|
2365
|
-
const MAX_INCORRECT_BLOCK_STEPS = 12;
|
|
2366
|
-
/** Most blocks a model may report for one trajectory. The published corpus's
|
|
2367
|
-
* densest case carries 4 disjoint labeled blocks. Together with the per-block
|
|
2368
|
-
* cap this bounds one case at 192 predicted steps without a second ceiling. */
|
|
2369
|
-
const MAX_INCORRECT_BLOCKS = 16;
|
|
2370
2840
|
const TRACE_PROJECTION_ATTRIBUTE_BYTE_CAPS = [
|
|
2371
2841
|
4096,
|
|
2372
2842
|
2048,
|
|
@@ -2738,8 +3208,8 @@ async function readAndValidateResumeFiles(paths, currentIdentity, currentIdentit
|
|
|
2738
3208
|
if (!await regularFileExists(paths.initializationComplete)) return initializeRunFiles(paths, currentIdentity, currentIdentitySha256, currentLocalIdentitySha256, localReceiptInput);
|
|
2739
3209
|
const manifest = await readAndValidateManifest(paths.manifest, currentIdentity, currentIdentitySha256, currentLocalIdentitySha256);
|
|
2740
3210
|
const localReceiptContent = await readRegularFile(paths.localReceipt, "benchmark local run receipt");
|
|
2741
|
-
const value =
|
|
2742
|
-
if (!isRecord
|
|
3211
|
+
const value = parseJsonText(localReceiptContent, paths.localReceipt);
|
|
3212
|
+
if (!isRecord(value)) throw new TypeError(`benchmark local run receipt must be an object: ${paths.localReceipt}`);
|
|
2743
3213
|
assertExactKeys(value, [
|
|
2744
3214
|
"kind",
|
|
2745
3215
|
"runIdentitySha256",
|
|
@@ -2749,13 +3219,13 @@ async function readAndValidateResumeFiles(paths, currentIdentity, currentIdentit
|
|
|
2749
3219
|
"environment",
|
|
2750
3220
|
"files"
|
|
2751
3221
|
], "benchmark local run receipt");
|
|
2752
|
-
if (value.kind !== "agent-eval/analyst-benchmark-local-run" || value.runIdentitySha256 !== currentIdentitySha256 || value.localIdentitySha256 !== currentLocalIdentitySha256 || !isRecord
|
|
3222
|
+
if (value.kind !== "agent-eval/analyst-benchmark-local-run" || value.runIdentitySha256 !== currentIdentitySha256 || value.localIdentitySha256 !== currentLocalIdentitySha256 || !isRecord(value.local)) throw new Error("benchmark local run receipt does not match the requested resume");
|
|
2753
3223
|
const expectedLocalReceipt = {
|
|
2754
3224
|
...localReceiptInput,
|
|
2755
3225
|
runIdentitySha256: currentIdentitySha256,
|
|
2756
3226
|
localIdentitySha256: currentLocalIdentitySha256
|
|
2757
3227
|
};
|
|
2758
|
-
if (digestCanonical(value.local) !== currentLocalIdentitySha256 ||
|
|
3228
|
+
if (digestCanonical(value.local) !== currentLocalIdentitySha256 || canonicalJsonDocument(value.local) !== canonicalJsonDocument(localReceiptInput.local)) throw new Error("benchmark local paths or model-owner module do not match the requested resume");
|
|
2759
3229
|
if (localReceiptContent !== `${JSON.stringify(expectedLocalReceipt, null, 2)}\n`) throw new Error(`benchmark local run receipt does not exactly match: ${paths.localReceipt}`);
|
|
2760
3230
|
if (await readRegularFile(paths.initializationComplete, "benchmark initialization marker") !== renderInitializationComplete(manifest)) throw new Error(`benchmark initialization marker does not match the run manifest: ${paths.initializationComplete}`);
|
|
2761
3231
|
return manifest;
|
|
@@ -2767,8 +3237,8 @@ async function readAndValidateManifest(path, currentIdentity, currentIdentitySha
|
|
|
2767
3237
|
return manifest;
|
|
2768
3238
|
}
|
|
2769
3239
|
async function readAndValidateManifestContent(path, content, currentIdentity, currentIdentitySha256, currentLocalIdentitySha256) {
|
|
2770
|
-
const value =
|
|
2771
|
-
if (!isRecord
|
|
3240
|
+
const value = parseJsonText(content, path);
|
|
3241
|
+
if (!isRecord(value)) throw new TypeError(`benchmark run manifest must be an object: ${path}`);
|
|
2772
3242
|
assertExactKeys(value, [
|
|
2773
3243
|
"kind",
|
|
2774
3244
|
"createdAt",
|
|
@@ -2778,9 +3248,9 @@ async function readAndValidateManifestContent(path, content, currentIdentity, cu
|
|
|
2778
3248
|
], "benchmark run manifest");
|
|
2779
3249
|
if (value.kind !== "agent-eval/analyst-benchmark-run") throw new TypeError(`unsupported benchmark run manifest: ${path}`);
|
|
2780
3250
|
if (typeof value.createdAt !== "string" || !Number.isFinite(Date.parse(value.createdAt))) throw new TypeError(`benchmark run manifest has an invalid createdAt: ${path}`);
|
|
2781
|
-
if (!isSha256(value.identitySha256) || !isSha256(value.localIdentitySha256) || !isRecord
|
|
3251
|
+
if (!isSha256(value.identitySha256) || !isSha256(value.localIdentitySha256) || !isRecord(value.identity)) throw new TypeError(`benchmark run manifest has an invalid identity: ${path}`);
|
|
2782
3252
|
if (digestCanonical(value.identity) !== value.identitySha256) throw new Error(`benchmark run manifest identity digest does not match its contents: ${path}`);
|
|
2783
|
-
if (currentIdentitySha256 !== value.identitySha256 || currentLocalIdentitySha256 !== value.localIdentitySha256 ||
|
|
3253
|
+
if (currentIdentitySha256 !== value.identitySha256 || currentLocalIdentitySha256 !== value.localIdentitySha256 || canonicalJsonDocument(currentIdentity) !== canonicalJsonDocument(value.identity)) throw new Error(`benchmark resume configuration or inputs do not match ${ANALYST_BENCHMARK_MANIFEST_FILE}`);
|
|
2784
3254
|
return {
|
|
2785
3255
|
kind: "agent-eval/analyst-benchmark-run",
|
|
2786
3256
|
createdAt: value.createdAt,
|
|
@@ -2844,8 +3314,8 @@ async function readProgress(path, runIdentitySha256, caseIds, repetitions, analy
|
|
|
2844
3314
|
const plannedObservationCount = caseIds.length * 2 * repetitions;
|
|
2845
3315
|
for (const [index, line] of rawLines.entries()) {
|
|
2846
3316
|
if (!line.trim()) throw new Error(`benchmark observation log contains an empty row at line ${index + 1}`);
|
|
2847
|
-
const parsed =
|
|
2848
|
-
if (!isRecord
|
|
3317
|
+
const parsed = parseJsonText(line, `${path}:${index + 1}`);
|
|
3318
|
+
if (!isRecord(parsed)) throw new TypeError(`benchmark observation row ${index + 1} must be an object`);
|
|
2849
3319
|
assertExactKeys(parsed, [
|
|
2850
3320
|
"sequence",
|
|
2851
3321
|
"runIdentitySha256",
|
|
@@ -3045,7 +3515,7 @@ function escapeCell$1(value) {
|
|
|
3045
3515
|
//#endregion
|
|
3046
3516
|
//#region src/analyst/benchmark-command-result.ts
|
|
3047
3517
|
async function readAnalystBenchmarkArtifact(path) {
|
|
3048
|
-
const value =
|
|
3518
|
+
const value = parseJsonText(await readRegularFile(path, "analyst benchmark result"), path);
|
|
3049
3519
|
assertAnalystBenchmarkArtifact(value, "analyst benchmark result");
|
|
3050
3520
|
return value;
|
|
3051
3521
|
}
|
|
@@ -3103,33 +3573,33 @@ function assertCompletedArtifactMatchesRun(artifact, manifest, observations, pre
|
|
|
3103
3573
|
dependencyLockSha256: config.dependencyLockSha256
|
|
3104
3574
|
}
|
|
3105
3575
|
};
|
|
3106
|
-
if (
|
|
3576
|
+
if (canonicalJsonDocument(artifact.inputs) !== canonicalJsonDocument(expectedInputs)) throw new Error("completed benchmark result inputs do not match the run manifest");
|
|
3107
3577
|
const provenance = artifact.result.provenance;
|
|
3108
3578
|
const expectedDatasetId = config.dataset === "agentrx" ? "microsoft/AgentRx" : "NJU-LINK/CodeTraceBench";
|
|
3109
3579
|
const expectedOutputAdapter = config.dataset === "agentrx" ? "agentrx-taxonomy-and-root-step" : "codetracebench-incorrect-block";
|
|
3110
|
-
if (provenance.id !== `${config.dataset}-real-model-analyst` || provenance.startedAt !== manifest.createdAt || !Number.isFinite(Date.parse(provenance.endedAt)) || Date.parse(provenance.endedAt) < Date.parse(provenance.startedAt) ||
|
|
3580
|
+
if (provenance.id !== `${config.dataset}-real-model-analyst` || provenance.startedAt !== manifest.createdAt || !Number.isFinite(Date.parse(provenance.endedAt)) || Date.parse(provenance.endedAt) < Date.parse(provenance.startedAt) || canonicalJsonDocument(provenance.dataset) !== canonicalJsonDocument({
|
|
3111
3581
|
id: expectedDatasetId,
|
|
3112
3582
|
revision: config.datasetRevision,
|
|
3113
3583
|
split: config.datasetSplit
|
|
3114
|
-
}) || provenance.caseCount !== inputs.selectedCaseIds.length ||
|
|
3584
|
+
}) || provenance.caseCount !== inputs.selectedCaseIds.length || canonicalJsonDocument(provenance.runnerIds) !== canonicalJsonDocument(config.runnerIds) || provenance.repetitions !== config.repetitions || provenance.maxConcurrency !== Math.min(config.concurrency, expectedCount) || provenance.runnerOrderSeed !== config.seed || provenance.metadata?.model !== config.model.id || provenance.metadata?.modelOwnerCallRef !== config.model.ownerCallRef || provenance.metadata?.rlmSamples !== config.rlmSamples || provenance.metadata?.outputAdapter !== expectedOutputAdapter || provenance.metadata?.caseSelection !== prepared.selection.method || provenance.metadata?.caseSelectionSeed !== config.seed || provenance.metadata?.selectionStratified !== prepared.selection.stratified || provenance.metadata?.protocolSha256 !== config.analystProtocolSha256 || provenance.metadata?.implementationSha256 !== config.implementationSha256 || provenance.metadata?.dependencyLockSha256 !== config.dependencyLockSha256 || provenance.metadata?.populationRepresentativenessProven !== false) throw new Error("completed benchmark result provenance does not match the run manifest");
|
|
3115
3585
|
const expectedSummaries = config.runnerIds.map((runnerId) => summarizeAnalystBenchmarkRunner(runnerId, observations.filter((observation) => observation.runnerId === runnerId)));
|
|
3116
|
-
if (
|
|
3586
|
+
if (canonicalJsonDocument(artifact.result.summaries) !== canonicalJsonDocument(expectedSummaries)) throw new Error("completed benchmark summaries do not match durable observations");
|
|
3117
3587
|
const expectedComparisons = [compareAnalystRunners(artifact.result, {
|
|
3118
3588
|
baselineRunnerId: "empty",
|
|
3119
3589
|
candidateRunnerId: config.runnerIds[1],
|
|
3120
3590
|
seed: config.seed
|
|
3121
3591
|
})];
|
|
3122
|
-
if (
|
|
3592
|
+
if (canonicalJsonDocument(artifact.comparisons) !== canonicalJsonDocument(expectedComparisons)) throw new Error("completed benchmark comparisons do not match durable observations");
|
|
3123
3593
|
if (config.dataset === "codetracebench") {
|
|
3124
|
-
if (
|
|
3125
|
-
} else if (
|
|
3594
|
+
if (canonicalJsonDocument(artifact.codeTraceCalibration) !== canonicalJsonDocument(summarizeCodeTraceCalibration(artifact.result)) || artifact.agentRxCalibration !== void 0) throw new Error("completed CodeTraceBench calibration does not match durable observations");
|
|
3595
|
+
} else if (canonicalJsonDocument(artifact.agentRxCalibration) !== canonicalJsonDocument(summarizeAgentRxCalibration(artifact.result, "f228165bfec60a801fd5fedd9d8ffe0f9de0c69d")) || artifact.codeTraceCalibration !== void 0) throw new Error("completed AgentRx calibration does not match durable observations");
|
|
3126
3596
|
}
|
|
3127
3597
|
function assertSameObservations(expected, actual) {
|
|
3128
3598
|
if (expected.length !== actual.length) throw new Error(`benchmark result has ${expected.length} observations but the durable log has ${actual.length}`);
|
|
3129
|
-
const expectedByKey = new Map(expected.map((observation) => [observationKey(observation),
|
|
3599
|
+
const expectedByKey = new Map(expected.map((observation) => [observationKey(observation), canonicalJsonDocument(observation)]));
|
|
3130
3600
|
for (const observation of actual) {
|
|
3131
3601
|
const key = observationKey(observation);
|
|
3132
|
-
if (expectedByKey.get(key) !==
|
|
3602
|
+
if (expectedByKey.get(key) !== canonicalJsonDocument(observation)) throw new Error(`benchmark result does not match durable observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`);
|
|
3133
3603
|
expectedByKey.delete(key);
|
|
3134
3604
|
}
|
|
3135
3605
|
if (expectedByKey.size > 0) throw new Error("benchmark result is missing durable observations");
|
|
@@ -3475,9 +3945,6 @@ function safeInteger(value, field) {
|
|
|
3475
3945
|
if (!Number.isSafeInteger(value)) throw new RangeError(`${field} must be a safe integer`);
|
|
3476
3946
|
return value;
|
|
3477
3947
|
}
|
|
3478
|
-
function isRecord(value) {
|
|
3479
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3480
|
-
}
|
|
3481
3948
|
//#endregion
|
|
3482
3949
|
//#region src/analyst/benchmark-response-cache.ts
|
|
3483
3950
|
const SHA256 = /^[a-f0-9]{64}$/;
|
|
@@ -3705,89 +4172,10 @@ function analystDefinitionAsymmetries(definitions) {
|
|
|
3705
4172
|
};
|
|
3706
4173
|
}
|
|
3707
4174
|
//#endregion
|
|
3708
|
-
//#region src/analyst/benchmark-public-
|
|
3709
|
-
/** The
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
const outputAdapter = dataset === "agentrx" ? "agentrx-taxonomy-and-root-step" : "codetracebench-incorrect-block";
|
|
3713
|
-
return {
|
|
3714
|
-
id: "direct",
|
|
3715
|
-
description: "One-shot JSON baseline over the caller-owned model path.",
|
|
3716
|
-
version: "1.0.0",
|
|
3717
|
-
area: dataset === "agentrx" ? "root-cause" : "incorrect",
|
|
3718
|
-
profile: { model: { reasoningEffort: "none" } },
|
|
3719
|
-
question: "",
|
|
3720
|
-
taskDefinition: publicBenchmarkTaskPrompt(dataset),
|
|
3721
|
-
projection: {
|
|
3722
|
-
mode: "chunked",
|
|
3723
|
-
attributeByteCaps: TRACE_PROJECTION_ATTRIBUTE_BYTE_CAPS
|
|
3724
|
-
},
|
|
3725
|
-
replyContract: directReplyContract(dataset),
|
|
3726
|
-
contractLimits: dataset === "agentrx" ? { maxFindings: 1 } : {
|
|
3727
|
-
maxBlocks: 16,
|
|
3728
|
-
maxBlockSteps: 12
|
|
3729
|
-
},
|
|
3730
|
-
budget: {
|
|
3731
|
-
timeoutMs: args.timeoutMs,
|
|
3732
|
-
maxCostUsd: args.maxCostUsd,
|
|
3733
|
-
maxOutputTokens: args.maxOutputTokens
|
|
3734
|
-
},
|
|
3735
|
-
repair: { turns: 0 },
|
|
3736
|
-
protocolSha256: publicBenchmarkProtocolSha256(dataset),
|
|
3737
|
-
binding: {
|
|
3738
|
-
kind: "chunked",
|
|
3739
|
-
subjectFromCaseId: (caseId) => trajectoryIdFromCaseId$2(dataset, caseId),
|
|
3740
|
-
baseMetadata: {
|
|
3741
|
-
analysisMode: "direct-baseline",
|
|
3742
|
-
outputAdapter
|
|
3743
|
-
},
|
|
3744
|
-
costActor: actor,
|
|
3745
|
-
costPhase: "analyst.public-benchmark",
|
|
3746
|
-
userMessage: (rendered) => `TRACE DATA:\n${rendered}\n\nReturn the analysis JSON object.`,
|
|
3747
|
-
async expandRows({ subject, rows, store, analystId, producedAt, providerModel, signal }) {
|
|
3748
|
-
const converted = await publicBenchmarkPredictionsToFindings({
|
|
3749
|
-
dataset,
|
|
3750
|
-
trajectoryId: subject,
|
|
3751
|
-
predictions: rows,
|
|
3752
|
-
store,
|
|
3753
|
-
analystId,
|
|
3754
|
-
providerModel: requiredString(providerModel ?? "", "finding providerModel"),
|
|
3755
|
-
producedAt: requiredString(producedAt ?? "", "finding producedAt"),
|
|
3756
|
-
...signal ? { signal } : {}
|
|
3757
|
-
});
|
|
3758
|
-
return {
|
|
3759
|
-
findings: converted.findings,
|
|
3760
|
-
diagnostics: converted.diagnostics
|
|
3761
|
-
};
|
|
3762
|
-
},
|
|
3763
|
-
...dataset === "codetracebench" ? { verifyFindings: async (args) => {
|
|
3764
|
-
await validateCodeTraceFindingEvidence({
|
|
3765
|
-
trajectoryId: args.subject,
|
|
3766
|
-
findings: [...args.findings],
|
|
3767
|
-
store: args.store,
|
|
3768
|
-
...args.signal ? { signal: args.signal } : {}
|
|
3769
|
-
});
|
|
3770
|
-
} } : {}
|
|
3771
|
-
}
|
|
3772
|
-
};
|
|
3773
|
-
}
|
|
3774
|
-
/** Thin shell: validate config, declare the definition, run the chunked strategy. */
|
|
3775
|
-
function createPublicBenchmarkDirectRunner(dataset, config) {
|
|
3776
|
-
if (config.instructionsOverride) throw new Error("the direct runner executes only the stock protocol; an instructions override requires the dspy-rlm runner");
|
|
3777
|
-
const maxOutputTokens = positiveSafeInteger(config.maxOutputTokens, "maxOutputTokens");
|
|
3778
|
-
return runChunkedAnalystDefinition(publicDirectAnalystDefinition(dataset, {
|
|
3779
|
-
timeoutMs: positiveSafeInteger(config.timeoutMs, "timeoutMs"),
|
|
3780
|
-
maxOutputTokens,
|
|
3781
|
-
maxCostUsd: config.maxCostUsdPerAnalysis ?? 1
|
|
3782
|
-
}), config);
|
|
3783
|
-
}
|
|
3784
|
-
/**
|
|
3785
|
-
* Compile a chunked-projection definition into a runnable one-shot JSON arm
|
|
3786
|
-
* over the caller-owned model path. Prompt content, the projection ladder,
|
|
3787
|
-
* the reply grammar, and the budget declaration come from the definition;
|
|
3788
|
-
* caching, cost settlement, and the model proxy are transport machinery.
|
|
3789
|
-
*/
|
|
3790
|
-
function runChunkedAnalystDefinition(definition, config) {
|
|
4175
|
+
//#region src/analyst/benchmark-public-chunked.ts
|
|
4176
|
+
/** The chunked one-shot JSON strategy: compile a chunked definition into a runnable arm. */
|
|
4177
|
+
/** Refuse a definition the one-shot JSON strategy cannot execute exactly as declared. */
|
|
4178
|
+
function checkChunkedDefinition(definition, config) {
|
|
3791
4179
|
const { projection, binding, replyContract } = definition;
|
|
3792
4180
|
if (projection.mode !== "chunked" || binding.kind !== "chunked") throw new AnalystExpressivenessError(`the chunked one-shot strategy compiles only chunked projections; definition '${definition.id}' declares projection '${projection.mode}' with a '${binding.kind}' binding`);
|
|
3793
4181
|
if (config.instructionsOverride) throw new Error("the direct runner executes only the stock protocol; an instructions override requires the dspy-rlm runner");
|
|
@@ -3796,6 +4184,16 @@ function runChunkedAnalystDefinition(definition, config) {
|
|
|
3796
4184
|
if (reasoningEffort !== "none") throw new AnalystExpressivenessError(`the one-shot JSON strategy runs with thinking disabled and can express only reasoning effort 'none'; definition '${definition.id}' declares '${reasoningEffort}'`);
|
|
3797
4185
|
if (!replyContract.parseEnvelope) throw new AnalystExpressivenessError(`the one-shot JSON strategy needs a strict reply envelope; definition '${definition.id}' declares no parseEnvelope`);
|
|
3798
4186
|
if (definition.taskDefinition === void 0) throw new AnalystExpressivenessError(`the one-shot JSON strategy composes its system prompt from the task definition; definition '${definition.id}' declares none`);
|
|
4187
|
+
return {
|
|
4188
|
+
binding,
|
|
4189
|
+
replyContract,
|
|
4190
|
+
attributeByteCaps: projection.attributeByteCaps,
|
|
4191
|
+
taskDefinition: definition.taskDefinition
|
|
4192
|
+
};
|
|
4193
|
+
}
|
|
4194
|
+
/** Validate the definition and transport, then resolve the model, budget, ledger and system prompt. */
|
|
4195
|
+
function compileChunkedArm(definition, config) {
|
|
4196
|
+
const { binding, replyContract, attributeByteCaps, taskDefinition } = checkChunkedDefinition(definition, config);
|
|
3799
4197
|
const model = requiredString(config.model, "model");
|
|
3800
4198
|
const callRef = requiredString(config.callRef, "callRef");
|
|
3801
4199
|
if (typeof config.call !== "function") throw new TypeError("call must be a function");
|
|
@@ -3808,263 +4206,316 @@ function runChunkedAnalystDefinition(definition, config) {
|
|
|
3808
4206
|
maxOutputTokens,
|
|
3809
4207
|
maxCostUsd
|
|
3810
4208
|
});
|
|
3811
|
-
const maxReasoningTokens = config.maxReasoningTokens ?? maxOutputTokens * 4;
|
|
3812
|
-
const maxModelRequestBytes = config.maxModelRequestBytes ?? 16777216;
|
|
3813
|
-
const maxModelResponseBytes = config.maxModelResponseBytes ?? 4194304;
|
|
3814
|
-
const modelRequestTimeoutMs = config.modelRequestTimeoutMs ?? timeoutMs;
|
|
3815
|
-
const pricing = config.pricing ?? pricingForModel$2(model);
|
|
3816
|
-
const costLedger = config.costLedger ?? new CostLedger();
|
|
3817
|
-
const durability = config.durability ? {
|
|
3818
|
-
runIdentitySha256: requiredString(config.durability.runIdentitySha256, "durability.runIdentitySha256"),
|
|
3819
|
-
responseCacheDir: requiredString(config.durability.responseCacheDir, "durability.responseCacheDir")
|
|
3820
|
-
} : void 0;
|
|
3821
|
-
const systemPrompt = [definition.taskDefinition, ...replyContract.contractLines].join("\n\n");
|
|
3822
4209
|
return {
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
const preparedContext = await prepareSingleTraceContext(input.traceStore, context, projection.attributeByteCaps);
|
|
3844
|
-
if (preparedContext === void 0) throw new Error(`trace '${trajectoryId}' has no readable spans`);
|
|
3845
|
-
const request = {
|
|
3846
|
-
model,
|
|
3847
|
-
messages: [{
|
|
3848
|
-
role: "system",
|
|
3849
|
-
content: systemPrompt
|
|
3850
|
-
}, {
|
|
3851
|
-
role: "user",
|
|
3852
|
-
content: binding.userMessage(preparedContext)
|
|
3853
|
-
}],
|
|
3854
|
-
jsonMode: true,
|
|
3855
|
-
thinking: "disabled",
|
|
3856
|
-
maxTokens: maxOutputTokens,
|
|
3857
|
-
timeoutMs: modelRequestTimeoutMs
|
|
3858
|
-
};
|
|
3859
|
-
const cacheIdentity = durability ? {
|
|
3860
|
-
runIdentitySha256: durability.runIdentitySha256,
|
|
3861
|
-
caseId: context.caseId,
|
|
3862
|
-
repetition: context.repetition
|
|
3863
|
-
} : void 0;
|
|
3864
|
-
const callId = cacheIdentity ? publicBenchmarkCallId(cacheIdentity) : void 0;
|
|
3865
|
-
const cached = cacheIdentity ? readPublicBenchmarkResponseCache(durability.responseCacheDir, cacheIdentity) : void 0;
|
|
3866
|
-
if (cached) {
|
|
3867
|
-
const receipt = settleCachedResponse(costLedger, cached);
|
|
3868
|
-
modelMetadata = {
|
|
3869
|
-
...modelMetadata,
|
|
3870
|
-
responseSource: "durable-cache",
|
|
3871
|
-
cost: costReceiptMetadata(receipt)
|
|
3872
|
-
};
|
|
3873
|
-
if (cached.status === "failed") return {
|
|
3874
|
-
findings: [],
|
|
3875
|
-
usage: usageReceiptFromCostLedger(costLedger, {
|
|
3876
|
-
channel: "analyst",
|
|
3877
|
-
tags: costTags
|
|
3878
|
-
}),
|
|
3879
|
-
error: cached.error,
|
|
3880
|
-
metadata: modelMetadata
|
|
3881
|
-
};
|
|
3882
|
-
const response = decodeReplyRows(replyContract, cached.response);
|
|
3883
|
-
rawPredictions = response.rows;
|
|
3884
|
-
rejectedRows = response.rejected.map((entry) => entry.reason);
|
|
3885
|
-
providerModel = cached.metadata.providerModel;
|
|
3886
|
-
producedAt = cached.metadata.producedAt;
|
|
3887
|
-
modelMetadata = {
|
|
3888
|
-
...modelMetadata,
|
|
3889
|
-
...response.extras,
|
|
3890
|
-
providerModel: cached.metadata.providerModel,
|
|
3891
|
-
providerDurationMs: cached.metadata.providerDurationMs,
|
|
3892
|
-
finishReason: cached.metadata.finishReason
|
|
3893
|
-
};
|
|
3894
|
-
} else {
|
|
3895
|
-
assertNoSettledResponseWithoutCache(costLedger, callId);
|
|
3896
|
-
const providerCallId = callId ?? `analyst-benchmark-${randomUUID()}`;
|
|
3897
|
-
let modelProxy;
|
|
3898
|
-
const completed = await runWithCleanup({
|
|
3899
|
-
label: "public benchmark direct model resources",
|
|
3900
|
-
run: async () => {
|
|
3901
|
-
modelProxy = await startExternalOptimizerModelProxy({
|
|
3902
|
-
call: config.call,
|
|
3903
|
-
callRef,
|
|
3904
|
-
recordExecution: config.recordExecution,
|
|
3905
|
-
model,
|
|
3906
|
-
budget: {
|
|
3907
|
-
maxCostUsd,
|
|
3908
|
-
maxRequests: 1,
|
|
3909
|
-
maxRequestBytes: maxModelRequestBytes,
|
|
3910
|
-
maxResponseBytes: maxModelResponseBytes,
|
|
3911
|
-
maxOutputTokensPerRequest: maxOutputTokens,
|
|
3912
|
-
maxReasoningTokensPerRequest: maxReasoningTokens,
|
|
3913
|
-
pricing,
|
|
3914
|
-
requestTimeoutMs: modelRequestTimeoutMs
|
|
3915
|
-
},
|
|
3916
|
-
costLedger,
|
|
3917
|
-
channel: "analyst",
|
|
3918
|
-
phase: binding.costPhase,
|
|
3919
|
-
actor: binding.costActor,
|
|
3920
|
-
tags: costTags,
|
|
3921
|
-
callId: providerCallId,
|
|
3922
|
-
...context.signal ? { signal: context.signal } : {}
|
|
3923
|
-
});
|
|
3924
|
-
const llmOptions = {
|
|
3925
|
-
baseUrl: modelProxy.baseUrl,
|
|
3926
|
-
apiKey: modelProxy.apiKey,
|
|
3927
|
-
maximumAttempts: 1,
|
|
3928
|
-
jsonSchemaTransport: "json-object",
|
|
3929
|
-
jsonPayloadMode: "exact",
|
|
3930
|
-
thinking: "disabled"
|
|
3931
|
-
};
|
|
3932
|
-
try {
|
|
3933
|
-
const completed = await callLlmJson(request, {
|
|
3934
|
-
...llmOptions,
|
|
3935
|
-
...context.signal ? { signal: context.signal } : {},
|
|
3936
|
-
idempotencyKey: providerCallId
|
|
3937
|
-
});
|
|
3938
|
-
const response = decodeReplyRows(replyContract, completed.value);
|
|
3939
|
-
const responseProducedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3940
|
-
const receipt = requiredSettledReceipt(costLedger, providerCallId);
|
|
3941
|
-
if (cacheIdentity) writePublicBenchmarkResponseCache(durability.responseCacheDir, {
|
|
3942
|
-
kind: "agent-eval/public-benchmark-model-response",
|
|
3943
|
-
...cacheIdentity,
|
|
3944
|
-
callId: providerCallId,
|
|
3945
|
-
status: "succeeded",
|
|
3946
|
-
response: completed.value,
|
|
3947
|
-
metadata: {
|
|
3948
|
-
providerModel: completed.result.model,
|
|
3949
|
-
providerDurationMs: completed.result.durationMs,
|
|
3950
|
-
finishReason: completed.result.finishReason ?? null,
|
|
3951
|
-
producedAt: responseProducedAt
|
|
3952
|
-
},
|
|
3953
|
-
receipt: cacheReceiptInput(receipt)
|
|
3954
|
-
});
|
|
3955
|
-
modelProxy.assertExecutionComplete();
|
|
3956
|
-
return {
|
|
3957
|
-
...completed,
|
|
3958
|
-
response,
|
|
3959
|
-
producedAt: responseProducedAt,
|
|
3960
|
-
receipt
|
|
3961
|
-
};
|
|
3962
|
-
} catch (error) {
|
|
3963
|
-
const controlFailure = modelProxy.failures().find(isPaidCallControlError$1);
|
|
3964
|
-
if (controlFailure) throw controlFailure;
|
|
3965
|
-
const receipt = settledReceipt(costLedger, providerCallId);
|
|
3966
|
-
if (cacheIdentity) {
|
|
3967
|
-
if (receipt) writePublicBenchmarkResponseCache(durability.responseCacheDir, {
|
|
3968
|
-
kind: "agent-eval/public-benchmark-model-response",
|
|
3969
|
-
...cacheIdentity,
|
|
3970
|
-
callId: providerCallId,
|
|
3971
|
-
status: "failed",
|
|
3972
|
-
error: publicBenchmarkError(error, []),
|
|
3973
|
-
receipt: cacheReceiptInput(receipt)
|
|
3974
|
-
});
|
|
3975
|
-
}
|
|
3976
|
-
throw error;
|
|
3977
|
-
}
|
|
3978
|
-
},
|
|
3979
|
-
cleanup: async () => {
|
|
3980
|
-
await modelProxy?.close();
|
|
3981
|
-
}
|
|
3982
|
-
});
|
|
3983
|
-
const response = completed.response;
|
|
3984
|
-
rawPredictions = response.rows;
|
|
3985
|
-
rejectedRows = response.rejected.map((entry) => entry.reason);
|
|
3986
|
-
providerModel = completed.result.model;
|
|
3987
|
-
producedAt = completed.producedAt;
|
|
3988
|
-
modelMetadata = {
|
|
3989
|
-
...modelMetadata,
|
|
3990
|
-
responseSource: "provider",
|
|
3991
|
-
...response.extras,
|
|
3992
|
-
providerModel: completed.result.model,
|
|
3993
|
-
providerDurationMs: completed.result.durationMs,
|
|
3994
|
-
finishReason: completed.result.finishReason ?? null,
|
|
3995
|
-
cost: costReceiptMetadata(completed.receipt)
|
|
3996
|
-
};
|
|
3997
|
-
}
|
|
3998
|
-
const converted = await binding.expandRows({
|
|
3999
|
-
subject: trajectoryId,
|
|
4000
|
-
rows: rawPredictions,
|
|
4001
|
-
store: input.traceStore,
|
|
4002
|
-
analystId: definition.id,
|
|
4003
|
-
providerModel,
|
|
4004
|
-
producedAt: requiredString(producedAt ?? "", "finding producedAt"),
|
|
4005
|
-
...context.signal ? { signal: context.signal } : {}
|
|
4006
|
-
});
|
|
4007
|
-
modelFindings = converted.findings;
|
|
4008
|
-
if (converted.diagnostics) modelMetadata = {
|
|
4009
|
-
...modelMetadata,
|
|
4010
|
-
blockDiagnostics: {
|
|
4011
|
-
...converted.diagnostics,
|
|
4012
|
-
rejectedBlocks: rejectedRows
|
|
4013
|
-
}
|
|
4014
|
-
};
|
|
4015
|
-
if (binding.verifyFindings) await binding.verifyFindings({
|
|
4016
|
-
subject: trajectoryId,
|
|
4017
|
-
findings: modelFindings,
|
|
4018
|
-
store: input.traceStore,
|
|
4019
|
-
...context.signal ? { signal: context.signal } : {}
|
|
4020
|
-
});
|
|
4021
|
-
return {
|
|
4022
|
-
findings: modelFindings,
|
|
4023
|
-
usage: usageReceiptFromCostLedger(costLedger, {
|
|
4024
|
-
channel: "analyst",
|
|
4025
|
-
tags: costTags
|
|
4026
|
-
}),
|
|
4027
|
-
metadata: modelMetadata
|
|
4028
|
-
};
|
|
4029
|
-
} catch (error) {
|
|
4030
|
-
if (context.signal?.aborted) throw error;
|
|
4031
|
-
if (isPaidCallControlError$1(error)) throw error;
|
|
4032
|
-
return {
|
|
4033
|
-
findings: [],
|
|
4034
|
-
usage: usageReceiptFromCostLedger(costLedger, {
|
|
4035
|
-
channel: "analyst",
|
|
4036
|
-
tags: costTags
|
|
4037
|
-
}),
|
|
4038
|
-
error: publicBenchmarkError(error, []),
|
|
4039
|
-
metadata: {
|
|
4040
|
-
...modelMetadata,
|
|
4041
|
-
rawPredictions,
|
|
4042
|
-
acceptedFindings: modelFindings
|
|
4043
|
-
}
|
|
4044
|
-
};
|
|
4045
|
-
}
|
|
4046
|
-
}
|
|
4210
|
+
definition,
|
|
4211
|
+
binding,
|
|
4212
|
+
replyContract,
|
|
4213
|
+
attributeByteCaps,
|
|
4214
|
+
config,
|
|
4215
|
+
model,
|
|
4216
|
+
callRef,
|
|
4217
|
+
maxOutputTokens,
|
|
4218
|
+
maxCostUsd,
|
|
4219
|
+
maxReasoningTokens: config.maxReasoningTokens ?? maxOutputTokens * 4,
|
|
4220
|
+
maxModelRequestBytes: config.maxModelRequestBytes ?? 16777216,
|
|
4221
|
+
maxModelResponseBytes: config.maxModelResponseBytes ?? 4194304,
|
|
4222
|
+
modelRequestTimeoutMs: config.modelRequestTimeoutMs ?? timeoutMs,
|
|
4223
|
+
pricing: config.pricing ?? pricingForModel$2(model),
|
|
4224
|
+
costLedger: config.costLedger ?? new CostLedger(),
|
|
4225
|
+
durability: config.durability ? {
|
|
4226
|
+
runIdentitySha256: requiredString(config.durability.runIdentitySha256, "durability.runIdentitySha256"),
|
|
4227
|
+
responseCacheDir: requiredString(config.durability.responseCacheDir, "durability.responseCacheDir")
|
|
4228
|
+
} : void 0,
|
|
4229
|
+
systemPrompt: [taskDefinition, ...replyContract.contractLines].join("\n\n")
|
|
4047
4230
|
};
|
|
4048
4231
|
}
|
|
4049
|
-
/**
|
|
4050
|
-
function
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
const settled = costLedger.list().find((receipt) => receipt.callId === cached.callId);
|
|
4056
|
-
const pending = costLedger.listPending?.().find((record) => record.callId === cached.callId);
|
|
4057
|
-
if (settled && pending) throw new CostCallConflictError(`benchmark response '${cached.callId}' is both pending and settled`, { callId: cached.callId });
|
|
4058
|
-
const receipt = pending ? costLedger.reconcile(cached.callId, cached.receipt, { ...cached.status === "failed" ? { failed: true } : {} }) : settled;
|
|
4059
|
-
if (!receipt) throw new CostCallConflictError(`benchmark response cache '${cached.callId}' has no matching cost record`, { callId: cached.callId });
|
|
4060
|
-
assertCacheReceiptMatches(cached, receipt);
|
|
4061
|
-
return receipt;
|
|
4232
|
+
/** The case's usage as the cost ledger has settled it so far. */
|
|
4233
|
+
function chunkedCaseUsage(arm, run) {
|
|
4234
|
+
return usageReceiptFromCostLedger(arm.costLedger, {
|
|
4235
|
+
channel: "analyst",
|
|
4236
|
+
tags: run.costTags
|
|
4237
|
+
});
|
|
4062
4238
|
}
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4239
|
+
/** The one JSON-mode, thinking-disabled request this case sends. */
|
|
4240
|
+
function buildChunkedRequest(arm, preparedContext) {
|
|
4241
|
+
return {
|
|
4242
|
+
model: arm.model,
|
|
4243
|
+
messages: [{
|
|
4244
|
+
role: "system",
|
|
4245
|
+
content: arm.systemPrompt
|
|
4246
|
+
}, {
|
|
4247
|
+
role: "user",
|
|
4248
|
+
content: arm.binding.userMessage(preparedContext)
|
|
4249
|
+
}],
|
|
4250
|
+
jsonMode: true,
|
|
4251
|
+
thinking: "disabled",
|
|
4252
|
+
maxTokens: arm.maxOutputTokens,
|
|
4253
|
+
timeoutMs: arm.modelRequestTimeoutMs
|
|
4254
|
+
};
|
|
4066
4255
|
}
|
|
4067
|
-
|
|
4256
|
+
/** Settle a durable-cache hit; returns the failed output when the cached call had failed. */
|
|
4257
|
+
function applyCachedResponse(arm, run, cached) {
|
|
4258
|
+
const receipt = settleCachedResponse(arm.costLedger, cached);
|
|
4259
|
+
run.modelMetadata = {
|
|
4260
|
+
...run.modelMetadata,
|
|
4261
|
+
responseSource: "durable-cache",
|
|
4262
|
+
cost: costReceiptMetadata(receipt)
|
|
4263
|
+
};
|
|
4264
|
+
if (cached.status === "failed") return {
|
|
4265
|
+
findings: [],
|
|
4266
|
+
usage: chunkedCaseUsage(arm, run),
|
|
4267
|
+
error: cached.error,
|
|
4268
|
+
metadata: run.modelMetadata
|
|
4269
|
+
};
|
|
4270
|
+
const response = decodeReplyRows(arm.replyContract, cached.response);
|
|
4271
|
+
run.rawPredictions = response.rows;
|
|
4272
|
+
run.rejectedRows = response.rejected.map((entry) => entry.reason);
|
|
4273
|
+
run.providerModel = cached.metadata.providerModel;
|
|
4274
|
+
run.producedAt = cached.metadata.producedAt;
|
|
4275
|
+
run.modelMetadata = {
|
|
4276
|
+
...run.modelMetadata,
|
|
4277
|
+
...response.extras,
|
|
4278
|
+
providerModel: cached.metadata.providerModel,
|
|
4279
|
+
providerDurationMs: cached.metadata.providerDurationMs,
|
|
4280
|
+
finishReason: cached.metadata.finishReason
|
|
4281
|
+
};
|
|
4282
|
+
}
|
|
4283
|
+
/** Make the one paid call through the model proxy, caching its response or its settled failure. */
|
|
4284
|
+
async function callChunkedThroughProxy(arm, context, modelProxy, request, cacheIdentity, providerCallId) {
|
|
4285
|
+
const { costLedger, durability, replyContract } = arm;
|
|
4286
|
+
const llmOptions = {
|
|
4287
|
+
baseUrl: modelProxy.baseUrl,
|
|
4288
|
+
apiKey: modelProxy.apiKey,
|
|
4289
|
+
maximumAttempts: 1,
|
|
4290
|
+
jsonSchemaTransport: "json-object",
|
|
4291
|
+
jsonPayloadMode: "exact",
|
|
4292
|
+
thinking: "disabled"
|
|
4293
|
+
};
|
|
4294
|
+
try {
|
|
4295
|
+
const completed = await callLlmJson(request, {
|
|
4296
|
+
...llmOptions,
|
|
4297
|
+
...context.signal ? { signal: context.signal } : {},
|
|
4298
|
+
idempotencyKey: providerCallId
|
|
4299
|
+
});
|
|
4300
|
+
const response = decodeReplyRows(replyContract, completed.value);
|
|
4301
|
+
const responseProducedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4302
|
+
const receipt = requiredSettledReceipt(costLedger, providerCallId);
|
|
4303
|
+
if (cacheIdentity) writePublicBenchmarkResponseCache(durability.responseCacheDir, {
|
|
4304
|
+
kind: "agent-eval/public-benchmark-model-response",
|
|
4305
|
+
...cacheIdentity,
|
|
4306
|
+
callId: providerCallId,
|
|
4307
|
+
status: "succeeded",
|
|
4308
|
+
response: completed.value,
|
|
4309
|
+
metadata: {
|
|
4310
|
+
providerModel: completed.result.model,
|
|
4311
|
+
providerDurationMs: completed.result.durationMs,
|
|
4312
|
+
finishReason: completed.result.finishReason ?? null,
|
|
4313
|
+
producedAt: responseProducedAt
|
|
4314
|
+
},
|
|
4315
|
+
receipt: cacheReceiptInput(receipt)
|
|
4316
|
+
});
|
|
4317
|
+
modelProxy.assertExecutionComplete();
|
|
4318
|
+
return {
|
|
4319
|
+
...completed,
|
|
4320
|
+
response,
|
|
4321
|
+
producedAt: responseProducedAt,
|
|
4322
|
+
receipt
|
|
4323
|
+
};
|
|
4324
|
+
} catch (error) {
|
|
4325
|
+
const controlFailure = modelProxy.failures().find(isPaidCallControlError$1);
|
|
4326
|
+
if (controlFailure) throw controlFailure;
|
|
4327
|
+
const receipt = settledReceipt(costLedger, providerCallId);
|
|
4328
|
+
if (cacheIdentity) {
|
|
4329
|
+
if (receipt) writePublicBenchmarkResponseCache(durability.responseCacheDir, {
|
|
4330
|
+
kind: "agent-eval/public-benchmark-model-response",
|
|
4331
|
+
...cacheIdentity,
|
|
4332
|
+
callId: providerCallId,
|
|
4333
|
+
status: "failed",
|
|
4334
|
+
error: publicBenchmarkError(error, []),
|
|
4335
|
+
receipt: cacheReceiptInput(receipt)
|
|
4336
|
+
});
|
|
4337
|
+
}
|
|
4338
|
+
throw error;
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
/** Call the provider once behind a budgeted loopback proxy and record the response on the case. */
|
|
4342
|
+
async function applyProviderResponse(arm, run, request, cacheIdentity, callId) {
|
|
4343
|
+
const { binding, costLedger, config, callRef, model } = arm;
|
|
4344
|
+
const { context } = run;
|
|
4345
|
+
assertNoSettledResponseWithoutCache(costLedger, callId);
|
|
4346
|
+
const providerCallId = callId ?? `analyst-benchmark-${randomUUID()}`;
|
|
4347
|
+
let modelProxy;
|
|
4348
|
+
const completed = await runWithCleanup({
|
|
4349
|
+
label: "public benchmark direct model resources",
|
|
4350
|
+
run: async () => {
|
|
4351
|
+
modelProxy = await startExternalOptimizerModelProxy({
|
|
4352
|
+
call: config.call,
|
|
4353
|
+
callRef,
|
|
4354
|
+
recordExecution: config.recordExecution,
|
|
4355
|
+
model,
|
|
4356
|
+
budget: {
|
|
4357
|
+
maxCostUsd: arm.maxCostUsd,
|
|
4358
|
+
maxRequests: 1,
|
|
4359
|
+
maxRequestBytes: arm.maxModelRequestBytes,
|
|
4360
|
+
maxResponseBytes: arm.maxModelResponseBytes,
|
|
4361
|
+
maxOutputTokensPerRequest: arm.maxOutputTokens,
|
|
4362
|
+
maxReasoningTokensPerRequest: arm.maxReasoningTokens,
|
|
4363
|
+
pricing: arm.pricing,
|
|
4364
|
+
requestTimeoutMs: arm.modelRequestTimeoutMs
|
|
4365
|
+
},
|
|
4366
|
+
costLedger,
|
|
4367
|
+
channel: "analyst",
|
|
4368
|
+
phase: binding.costPhase,
|
|
4369
|
+
actor: binding.costActor,
|
|
4370
|
+
tags: run.costTags,
|
|
4371
|
+
callId: providerCallId,
|
|
4372
|
+
...context.signal ? { signal: context.signal } : {}
|
|
4373
|
+
});
|
|
4374
|
+
return callChunkedThroughProxy(arm, context, modelProxy, request, cacheIdentity, providerCallId);
|
|
4375
|
+
},
|
|
4376
|
+
cleanup: async () => {
|
|
4377
|
+
await modelProxy?.close();
|
|
4378
|
+
}
|
|
4379
|
+
});
|
|
4380
|
+
const response = completed.response;
|
|
4381
|
+
run.rawPredictions = response.rows;
|
|
4382
|
+
run.rejectedRows = response.rejected.map((entry) => entry.reason);
|
|
4383
|
+
run.providerModel = completed.result.model;
|
|
4384
|
+
run.producedAt = completed.producedAt;
|
|
4385
|
+
run.modelMetadata = {
|
|
4386
|
+
...run.modelMetadata,
|
|
4387
|
+
responseSource: "provider",
|
|
4388
|
+
...response.extras,
|
|
4389
|
+
providerModel: completed.result.model,
|
|
4390
|
+
providerDurationMs: completed.result.durationMs,
|
|
4391
|
+
finishReason: completed.result.finishReason ?? null,
|
|
4392
|
+
cost: costReceiptMetadata(completed.receipt)
|
|
4393
|
+
};
|
|
4394
|
+
}
|
|
4395
|
+
/** Expand the accepted rows into findings and ground them against the store. */
|
|
4396
|
+
async function expandChunkedFindings(arm, run, store) {
|
|
4397
|
+
const { binding, definition } = arm;
|
|
4398
|
+
const { context } = run;
|
|
4399
|
+
const converted = await binding.expandRows({
|
|
4400
|
+
subject: run.trajectoryId,
|
|
4401
|
+
rows: run.rawPredictions,
|
|
4402
|
+
store,
|
|
4403
|
+
analystId: definition.id,
|
|
4404
|
+
providerModel: run.providerModel,
|
|
4405
|
+
producedAt: requiredString(run.producedAt ?? "", "finding producedAt"),
|
|
4406
|
+
...context.signal ? { signal: context.signal } : {}
|
|
4407
|
+
});
|
|
4408
|
+
run.modelFindings = converted.findings;
|
|
4409
|
+
if (converted.diagnostics) run.modelMetadata = {
|
|
4410
|
+
...run.modelMetadata,
|
|
4411
|
+
blockDiagnostics: {
|
|
4412
|
+
...converted.diagnostics,
|
|
4413
|
+
rejectedBlocks: run.rejectedRows
|
|
4414
|
+
}
|
|
4415
|
+
};
|
|
4416
|
+
if (binding.verifyFindings) await binding.verifyFindings({
|
|
4417
|
+
subject: run.trajectoryId,
|
|
4418
|
+
findings: run.modelFindings,
|
|
4419
|
+
store,
|
|
4420
|
+
...context.signal ? { signal: context.signal } : {}
|
|
4421
|
+
});
|
|
4422
|
+
}
|
|
4423
|
+
/** Answer one case from the durable cache or the provider, then expand and ground its findings. */
|
|
4424
|
+
async function analyzeChunkedRows(arm, run, store) {
|
|
4425
|
+
const { context, trajectoryId } = run;
|
|
4426
|
+
const preparedContext = await prepareSingleTraceContext(store, context, arm.attributeByteCaps);
|
|
4427
|
+
if (preparedContext === void 0) throw new Error(`trace '${trajectoryId}' has no readable spans`);
|
|
4428
|
+
const request = buildChunkedRequest(arm, preparedContext);
|
|
4429
|
+
const cacheIdentity = arm.durability ? {
|
|
4430
|
+
runIdentitySha256: arm.durability.runIdentitySha256,
|
|
4431
|
+
caseId: context.caseId,
|
|
4432
|
+
repetition: context.repetition
|
|
4433
|
+
} : void 0;
|
|
4434
|
+
const callId = cacheIdentity ? publicBenchmarkCallId(cacheIdentity) : void 0;
|
|
4435
|
+
const cached = cacheIdentity ? readPublicBenchmarkResponseCache(arm.durability.responseCacheDir, cacheIdentity) : void 0;
|
|
4436
|
+
if (cached) {
|
|
4437
|
+
const failed = applyCachedResponse(arm, run, cached);
|
|
4438
|
+
if (failed) return failed;
|
|
4439
|
+
} else await applyProviderResponse(arm, run, request, cacheIdentity, callId);
|
|
4440
|
+
await expandChunkedFindings(arm, run, store);
|
|
4441
|
+
return {
|
|
4442
|
+
findings: run.modelFindings,
|
|
4443
|
+
usage: chunkedCaseUsage(arm, run),
|
|
4444
|
+
metadata: run.modelMetadata
|
|
4445
|
+
};
|
|
4446
|
+
}
|
|
4447
|
+
/** Analyze one benchmark case; a paid-call control error or an abort is rethrown, any other failure is recorded. */
|
|
4448
|
+
async function analyzeChunkedCase(arm, input, context) {
|
|
4449
|
+
const { definition, binding } = arm;
|
|
4450
|
+
const run = {
|
|
4451
|
+
context,
|
|
4452
|
+
trajectoryId: binding.subjectFromCaseId(context.caseId),
|
|
4453
|
+
costTags: {
|
|
4454
|
+
analystId: binding.costActor,
|
|
4455
|
+
benchmarkCaseId: context.caseId,
|
|
4456
|
+
benchmarkRepetition: String(context.repetition)
|
|
4457
|
+
},
|
|
4458
|
+
rawPredictions: [],
|
|
4459
|
+
rejectedRows: [],
|
|
4460
|
+
modelFindings: [],
|
|
4461
|
+
providerModel: arm.model,
|
|
4462
|
+
producedAt: void 0,
|
|
4463
|
+
modelMetadata: {
|
|
4464
|
+
...binding.baseMetadata,
|
|
4465
|
+
protocolSha256: definition.protocolSha256,
|
|
4466
|
+
callRef: arm.callRef
|
|
4467
|
+
}
|
|
4468
|
+
};
|
|
4469
|
+
try {
|
|
4470
|
+
if (!input.traceStore) throw new Error(`chunked analyst '${definition.id}' requires a trace store`);
|
|
4471
|
+
return await analyzeChunkedRows(arm, run, input.traceStore);
|
|
4472
|
+
} catch (error) {
|
|
4473
|
+
if (context.signal?.aborted) throw error;
|
|
4474
|
+
if (isPaidCallControlError$1(error)) throw error;
|
|
4475
|
+
return {
|
|
4476
|
+
findings: [],
|
|
4477
|
+
usage: chunkedCaseUsage(arm, run),
|
|
4478
|
+
error: publicBenchmarkError(error, []),
|
|
4479
|
+
metadata: {
|
|
4480
|
+
...run.modelMetadata,
|
|
4481
|
+
rawPredictions: run.rawPredictions,
|
|
4482
|
+
acceptedFindings: run.modelFindings
|
|
4483
|
+
}
|
|
4484
|
+
};
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
/**
|
|
4488
|
+
* Compile a chunked-projection definition into a runnable one-shot JSON arm
|
|
4489
|
+
* over the caller-owned model path. Prompt content, the projection ladder,
|
|
4490
|
+
* the reply grammar, and the budget declaration come from the definition;
|
|
4491
|
+
* caching, cost settlement, and the model proxy are transport machinery.
|
|
4492
|
+
*/
|
|
4493
|
+
function runChunkedAnalystDefinition(definition, config) {
|
|
4494
|
+
const arm = compileChunkedArm(definition, config);
|
|
4495
|
+
return {
|
|
4496
|
+
id: definition.id,
|
|
4497
|
+
analyze: (input, context) => analyzeChunkedCase(arm, input, context)
|
|
4498
|
+
};
|
|
4499
|
+
}
|
|
4500
|
+
/** A definition that declares one budget while the transport runs another is refused. */
|
|
4501
|
+
function assertDeclaredBudget(definition, effective) {
|
|
4502
|
+
const declared = definition.budget;
|
|
4503
|
+
if (declared.timeoutMs !== effective.timeoutMs || declared.maxOutputTokens !== effective.maxOutputTokens || declared.maxCostUsd !== effective.maxCostUsd) throw new AnalystExpressivenessError(`definition '${definition.id}' declares budget ${JSON.stringify(declared)} but the bound transport runs ${JSON.stringify(effective)}; the declaration must state what executes`);
|
|
4504
|
+
}
|
|
4505
|
+
function settleCachedResponse(costLedger, cached) {
|
|
4506
|
+
const settled = costLedger.list().find((receipt) => receipt.callId === cached.callId);
|
|
4507
|
+
const pending = costLedger.listPending?.().find((record) => record.callId === cached.callId);
|
|
4508
|
+
if (settled && pending) throw new CostCallConflictError(`benchmark response '${cached.callId}' is both pending and settled`, { callId: cached.callId });
|
|
4509
|
+
const receipt = pending ? costLedger.reconcile(cached.callId, cached.receipt, { ...cached.status === "failed" ? { failed: true } : {} }) : settled;
|
|
4510
|
+
if (!receipt) throw new CostCallConflictError(`benchmark response cache '${cached.callId}' has no matching cost record`, { callId: cached.callId });
|
|
4511
|
+
assertCacheReceiptMatches(cached, receipt);
|
|
4512
|
+
return receipt;
|
|
4513
|
+
}
|
|
4514
|
+
function assertNoSettledResponseWithoutCache(costLedger, callId) {
|
|
4515
|
+
if (!callId) return;
|
|
4516
|
+
if (costLedger.list().some((receipt) => receipt.callId === callId)) throw new CostCallConflictError(`settled benchmark call '${callId}' has no durable response cache`, { callId });
|
|
4517
|
+
}
|
|
4518
|
+
function assertCacheReceiptMatches(cached, receipt) {
|
|
4068
4519
|
const expected = cached.receipt;
|
|
4069
4520
|
if (receipt.callId !== cached.callId || receipt.model !== expected.model || receipt.inputTokens !== expected.inputTokens || receipt.outputTokens !== expected.outputTokens || (receipt.reasoningTokens ?? 0) !== (expected.reasoningTokens ?? 0) || (receipt.cachedTokens ?? 0) !== (expected.cachedTokens ?? 0) || (receipt.cacheWriteTokens ?? 0) !== (expected.cacheWriteTokens ?? 0) || expected.actualCostUsd !== void 0 && receipt.actualCostUsd !== expected.actualCostUsd || expected.estimatedCostUsd !== void 0 && receipt.estimatedCostUsd !== expected.estimatedCostUsd || expected.costUnknown === true && !receipt.costUnknown || expected.usageUnknown === true && !receipt.usageUnknown || cached.status === "succeeded" && receipt.error !== void 0 || cached.status === "failed" && receipt.error === void 0) throw new CostCallConflictError(`benchmark response cache receipt does not match cost record '${cached.callId}'`, {
|
|
4070
4521
|
callId: cached.callId,
|
|
@@ -4145,6 +4596,101 @@ function pricingForModel$2(model) {
|
|
|
4145
4596
|
outputUsdPerMillion: pricing.output * 1e3
|
|
4146
4597
|
};
|
|
4147
4598
|
}
|
|
4599
|
+
async function prepareSingleTraceContext(store, context, attributeByteCaps) {
|
|
4600
|
+
const storeContext = context.signal ? { signal: context.signal } : void 0;
|
|
4601
|
+
const overview = await store.getOverview(void 0, storeContext);
|
|
4602
|
+
if (overview.total_traces !== 1 || overview.sample_trace_ids.length !== 1) throw new Error(`public model benchmark requires exactly one trace, received ${overview.total_traces}`);
|
|
4603
|
+
const traceId = overview.sample_trace_ids[0];
|
|
4604
|
+
for (const perAttributeByteCap of attributeByteCaps) {
|
|
4605
|
+
const viewed = await store.viewTrace({
|
|
4606
|
+
trace_id: traceId,
|
|
4607
|
+
per_attribute_byte_cap: perAttributeByteCap
|
|
4608
|
+
}, storeContext);
|
|
4609
|
+
if (!viewed.spans) continue;
|
|
4610
|
+
return JSON.stringify({
|
|
4611
|
+
trace_id: traceId,
|
|
4612
|
+
per_attribute_byte_cap: perAttributeByteCap,
|
|
4613
|
+
spans: viewed.spans
|
|
4614
|
+
});
|
|
4615
|
+
}
|
|
4616
|
+
}
|
|
4617
|
+
//#endregion
|
|
4618
|
+
//#region src/analyst/benchmark-public-model.ts
|
|
4619
|
+
/** The direct arm as a declarative unit for one public dataset. */
|
|
4620
|
+
function publicDirectAnalystDefinition(dataset, args) {
|
|
4621
|
+
const actor = dataset === "agentrx" ? "agentrx-root-cause-localizer" : "codetracebench-step-localizer";
|
|
4622
|
+
const outputAdapter = dataset === "agentrx" ? "agentrx-taxonomy-and-root-step" : "codetracebench-incorrect-block";
|
|
4623
|
+
return {
|
|
4624
|
+
id: "direct",
|
|
4625
|
+
description: "One-shot JSON baseline over the caller-owned model path.",
|
|
4626
|
+
version: "1.0.0",
|
|
4627
|
+
area: dataset === "agentrx" ? "root-cause" : "incorrect",
|
|
4628
|
+
profile: { model: { reasoningEffort: "none" } },
|
|
4629
|
+
question: "",
|
|
4630
|
+
taskDefinition: publicBenchmarkTaskPrompt(dataset),
|
|
4631
|
+
projection: {
|
|
4632
|
+
mode: "chunked",
|
|
4633
|
+
attributeByteCaps: TRACE_PROJECTION_ATTRIBUTE_BYTE_CAPS
|
|
4634
|
+
},
|
|
4635
|
+
replyContract: directReplyContract(dataset),
|
|
4636
|
+
contractLimits: dataset === "agentrx" ? { maxFindings: 1 } : {
|
|
4637
|
+
maxBlocks: 16,
|
|
4638
|
+
maxBlockSteps: 12
|
|
4639
|
+
},
|
|
4640
|
+
budget: {
|
|
4641
|
+
timeoutMs: args.timeoutMs,
|
|
4642
|
+
maxCostUsd: args.maxCostUsd,
|
|
4643
|
+
maxOutputTokens: args.maxOutputTokens
|
|
4644
|
+
},
|
|
4645
|
+
repair: { turns: 0 },
|
|
4646
|
+
protocolSha256: publicBenchmarkProtocolSha256(dataset),
|
|
4647
|
+
binding: {
|
|
4648
|
+
kind: "chunked",
|
|
4649
|
+
subjectFromCaseId: (caseId) => trajectoryIdFromCaseId$2(dataset, caseId),
|
|
4650
|
+
baseMetadata: {
|
|
4651
|
+
analysisMode: "direct-baseline",
|
|
4652
|
+
outputAdapter
|
|
4653
|
+
},
|
|
4654
|
+
costActor: actor,
|
|
4655
|
+
costPhase: "analyst.public-benchmark",
|
|
4656
|
+
userMessage: (rendered) => `TRACE DATA:\n${rendered}\n\nReturn the analysis JSON object.`,
|
|
4657
|
+
async expandRows({ subject, rows, store, analystId, producedAt, providerModel, signal }) {
|
|
4658
|
+
const converted = await publicBenchmarkPredictionsToFindings({
|
|
4659
|
+
dataset,
|
|
4660
|
+
trajectoryId: subject,
|
|
4661
|
+
predictions: rows,
|
|
4662
|
+
store,
|
|
4663
|
+
analystId,
|
|
4664
|
+
providerModel: requiredString(providerModel ?? "", "finding providerModel"),
|
|
4665
|
+
producedAt: requiredString(producedAt ?? "", "finding producedAt"),
|
|
4666
|
+
...signal ? { signal } : {}
|
|
4667
|
+
});
|
|
4668
|
+
return {
|
|
4669
|
+
findings: converted.findings,
|
|
4670
|
+
diagnostics: converted.diagnostics
|
|
4671
|
+
};
|
|
4672
|
+
},
|
|
4673
|
+
...dataset === "codetracebench" ? { verifyFindings: async (args) => {
|
|
4674
|
+
await validateCodeTraceFindingEvidence({
|
|
4675
|
+
trajectoryId: args.subject,
|
|
4676
|
+
findings: [...args.findings],
|
|
4677
|
+
store: args.store,
|
|
4678
|
+
...args.signal ? { signal: args.signal } : {}
|
|
4679
|
+
});
|
|
4680
|
+
} } : {}
|
|
4681
|
+
}
|
|
4682
|
+
};
|
|
4683
|
+
}
|
|
4684
|
+
/** Thin shell: validate config, declare the definition, run the chunked strategy. */
|
|
4685
|
+
function createPublicBenchmarkDirectRunner(dataset, config) {
|
|
4686
|
+
if (config.instructionsOverride) throw new Error("the direct runner executes only the stock protocol; an instructions override requires the dspy-rlm runner");
|
|
4687
|
+
const maxOutputTokens = positiveSafeInteger(config.maxOutputTokens, "maxOutputTokens");
|
|
4688
|
+
return runChunkedAnalystDefinition(publicDirectAnalystDefinition(dataset, {
|
|
4689
|
+
timeoutMs: positiveSafeInteger(config.timeoutMs, "timeoutMs"),
|
|
4690
|
+
maxOutputTokens,
|
|
4691
|
+
maxCostUsd: config.maxCostUsdPerAnalysis ?? 1
|
|
4692
|
+
}), config);
|
|
4693
|
+
}
|
|
4148
4694
|
const ModelSeveritySchema = z.enum([
|
|
4149
4695
|
"critical",
|
|
4150
4696
|
"high",
|
|
@@ -4324,24 +4870,6 @@ async function publicBenchmarkPredictionsToFindings(options) {
|
|
|
4324
4870
|
...options.signal ? { signal: options.signal } : {}
|
|
4325
4871
|
});
|
|
4326
4872
|
}
|
|
4327
|
-
async function prepareSingleTraceContext(store, context, attributeByteCaps) {
|
|
4328
|
-
const storeContext = context.signal ? { signal: context.signal } : void 0;
|
|
4329
|
-
const overview = await store.getOverview(void 0, storeContext);
|
|
4330
|
-
if (overview.total_traces !== 1 || overview.sample_trace_ids.length !== 1) throw new Error(`public model benchmark requires exactly one trace, received ${overview.total_traces}`);
|
|
4331
|
-
const traceId = overview.sample_trace_ids[0];
|
|
4332
|
-
for (const perAttributeByteCap of attributeByteCaps) {
|
|
4333
|
-
const viewed = await store.viewTrace({
|
|
4334
|
-
trace_id: traceId,
|
|
4335
|
-
per_attribute_byte_cap: perAttributeByteCap
|
|
4336
|
-
}, storeContext);
|
|
4337
|
-
if (!viewed.spans) continue;
|
|
4338
|
-
return JSON.stringify({
|
|
4339
|
-
trace_id: traceId,
|
|
4340
|
-
per_attribute_byte_cap: perAttributeByteCap,
|
|
4341
|
-
spans: viewed.spans
|
|
4342
|
-
});
|
|
4343
|
-
}
|
|
4344
|
-
}
|
|
4345
4873
|
function trajectoryIdFromCaseId$2(dataset, caseId) {
|
|
4346
4874
|
const prefix = dataset === "agentrx" ? "agentrx:" : "codetrace:";
|
|
4347
4875
|
if (!caseId.startsWith(prefix) || caseId.length === prefix.length) throw new Error(`unexpected ${dataset} benchmark case id '${caseId}'`);
|
|
@@ -4607,13 +5135,8 @@ function rlmEngineLimits(config) {
|
|
|
4607
5135
|
maxOutputChars: config.dspyRlm?.maxOutputChars ?? 8e3
|
|
4608
5136
|
};
|
|
4609
5137
|
}
|
|
4610
|
-
/**
|
|
4611
|
-
|
|
4612
|
-
* the caller-owned model path. The question, instructions, tool group, and
|
|
4613
|
-
* iteration limits come from the definition; the engine, model proxy, sampling
|
|
4614
|
-
* loop, and abstention floor are transport machinery.
|
|
4615
|
-
*/
|
|
4616
|
-
function runReplVariableAnalystDefinition(definition, config) {
|
|
5138
|
+
/** Refuse a definition or transport the repl-variable strategy cannot execute exactly as declared. */
|
|
5139
|
+
function checkReplVariableDefinition(definition, config) {
|
|
4617
5140
|
const { projection, binding } = definition;
|
|
4618
5141
|
if (projection.mode !== "repl-variable" || binding.kind !== "repl-variable") throw new AnalystExpressivenessError(`the repl-variable strategy compiles only repl-variable projections; definition '${definition.id}' declares projection '${projection.mode}' with a '${binding.kind}' binding`);
|
|
4619
5142
|
const instructions = definition.taskDefinition;
|
|
@@ -4625,12 +5148,17 @@ function runReplVariableAnalystDefinition(definition, config) {
|
|
|
4625
5148
|
if (limits === void 0) throw new AnalystExpressivenessError(`the repl-variable strategy needs declared engine limits; definition '${definition.id}' declares none`);
|
|
4626
5149
|
const effectiveLimits = rlmEngineLimits(config);
|
|
4627
5150
|
if (limits.maxIterations !== effectiveLimits.maxIterations || limits.maxLlmCalls !== effectiveLimits.maxLlmCalls || limits.maxToolCalls !== effectiveLimits.maxToolCalls || limits.maxOutputChars !== effectiveLimits.maxOutputChars) throw new AnalystExpressivenessError(`definition '${definition.id}' declares engine limits ${JSON.stringify(limits)} but the bound transport runs ${JSON.stringify(effectiveLimits)}; the declaration must state what executes`);
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
5151
|
+
return {
|
|
5152
|
+
binding,
|
|
5153
|
+
instructions,
|
|
5154
|
+
area,
|
|
5155
|
+
limits,
|
|
5156
|
+
toolGroup: projection.toolGroup
|
|
5157
|
+
};
|
|
5158
|
+
}
|
|
5159
|
+
/** The recursive engine over the caller-owned model path, with only the configured options set. */
|
|
5160
|
+
function createReplVariableEngine(config, pricing) {
|
|
5161
|
+
return createDspyRlmTraceEngine({
|
|
4634
5162
|
call: config.call,
|
|
4635
5163
|
callRef: config.callRef,
|
|
4636
5164
|
recordExecution: config.recordExecution,
|
|
@@ -4651,7 +5179,15 @@ function runReplVariableAnalystDefinition(definition, config) {
|
|
|
4651
5179
|
...config.dspyRlm?.traceToolTimeoutMs === void 0 ? {} : { traceToolTimeoutMs: config.dspyRlm.traceToolTimeoutMs },
|
|
4652
5180
|
...config.dspyRlm?.runner ? { runner: config.dspyRlm.runner } : {}
|
|
4653
5181
|
});
|
|
4654
|
-
|
|
5182
|
+
}
|
|
5183
|
+
/** Validate the definition and transport, then build the engine, ledger and abstention floor. */
|
|
5184
|
+
function compileReplVariableArm(definition, config) {
|
|
5185
|
+
const { binding, instructions, area, limits, toolGroup } = checkReplVariableDefinition(definition, config);
|
|
5186
|
+
const costLedger = config.costLedger ?? new CostLedger();
|
|
5187
|
+
const samples = config.dspyRlm?.samples ?? 1;
|
|
5188
|
+
if (!Number.isSafeInteger(samples) || samples < 1) throw new RangeError("dspyRlm.samples must be a positive safe integer");
|
|
5189
|
+
if (samples > 1 && binding.consensus === void 0) throw new AnalystExpressivenessError(`samples > 1 needs a consensus port; definition '${definition.id}' declares none`);
|
|
5190
|
+
const engine = createReplVariableEngine(config, config.pricing ?? pricingForModel$1(config.model));
|
|
4655
5191
|
const traceDefinition = {
|
|
4656
5192
|
id: binding.traceAnalystId,
|
|
4657
5193
|
description: definition.description,
|
|
@@ -4659,218 +5195,246 @@ function runReplVariableAnalystDefinition(definition, config) {
|
|
|
4659
5195
|
version: definition.version,
|
|
4660
5196
|
question: definition.question,
|
|
4661
5197
|
instructions,
|
|
4662
|
-
toolGroup
|
|
5198
|
+
toolGroup,
|
|
4663
5199
|
limits
|
|
4664
5200
|
};
|
|
4665
5201
|
const { instructionsOverride: _rlmOnlyOverride, ...directConfig } = config;
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
5202
|
+
return {
|
|
5203
|
+
definition,
|
|
5204
|
+
binding,
|
|
5205
|
+
config,
|
|
5206
|
+
area,
|
|
5207
|
+
samples,
|
|
5208
|
+
costLedger,
|
|
5209
|
+
engine,
|
|
5210
|
+
traceDefinition,
|
|
5211
|
+
abstentionFallbackRunner: binding.abstentionFallback({
|
|
5212
|
+
...directConfig,
|
|
5213
|
+
costLedger
|
|
5214
|
+
})
|
|
5215
|
+
};
|
|
5216
|
+
}
|
|
5217
|
+
/** Stamp the engine's raw rows as findings; `extra` metadata sits between the model and the subject block. */
|
|
5218
|
+
function stampFindings(arm, rows, extra) {
|
|
5219
|
+
const { definition, binding, config, area } = arm;
|
|
5220
|
+
const producedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5221
|
+
return rows.map((finding) => makeFinding({
|
|
5222
|
+
analyst_id: definition.id,
|
|
5223
|
+
area,
|
|
5224
|
+
subject: finding.subject,
|
|
5225
|
+
claim: finding.claim,
|
|
5226
|
+
rationale: finding.rationale,
|
|
5227
|
+
severity: finding.severity,
|
|
5228
|
+
confidence: finding.confidence,
|
|
5229
|
+
evidence_refs: evidenceRefsFromRawFinding(finding),
|
|
5230
|
+
recommended_action: finding.recommended_action,
|
|
5231
|
+
metadata: {
|
|
5232
|
+
...binding.findingBaseMetadata,
|
|
5233
|
+
model: config.model,
|
|
5234
|
+
...extra,
|
|
5235
|
+
...binding.metadataFromSubject?.(finding.subject) ?? {}
|
|
5236
|
+
},
|
|
5237
|
+
produced_at: producedAt
|
|
5238
|
+
}));
|
|
5239
|
+
}
|
|
5240
|
+
/** Metadata that records a direct abstention-floor call, or nothing when none fired. */
|
|
5241
|
+
function abstentionFallbackMetadata(fallback) {
|
|
5242
|
+
if (!fallback) return {};
|
|
5243
|
+
return {
|
|
5244
|
+
abstentionFallback: "direct",
|
|
5245
|
+
...fallback.metadata ? { abstentionFallbackMetadata: fallback.metadata } : {},
|
|
5246
|
+
...fallback.error ? { abstentionFallbackError: fallback.error } : {}
|
|
5247
|
+
};
|
|
5248
|
+
}
|
|
5249
|
+
/** Run one engine sample of a multi-sample case and fold it into the totals. */
|
|
5250
|
+
async function runReplVariableSample(arm, run, store, sample, totals) {
|
|
5251
|
+
const { definition, binding, costLedger } = arm;
|
|
5252
|
+
const { context, tags } = run;
|
|
5253
|
+
const caseUsageFilter = {
|
|
5254
|
+
channel: "analyst",
|
|
5255
|
+
tags
|
|
5256
|
+
};
|
|
5257
|
+
let sampleUsage;
|
|
5258
|
+
const completed = await runTraceAnalyst({
|
|
5259
|
+
definition: arm.traceDefinition,
|
|
5260
|
+
engine: arm.engine,
|
|
5261
|
+
store,
|
|
5262
|
+
context: {
|
|
5263
|
+
runId: context.caseId,
|
|
5264
|
+
correlationId: `${context.caseId}:${context.repetition}:sample-${sample}`,
|
|
5265
|
+
costLedger,
|
|
5266
|
+
costPhase: binding.costPhase,
|
|
5267
|
+
tags,
|
|
5268
|
+
recordUsage: (receipt) => {
|
|
5269
|
+
sampleUsage = receipt;
|
|
5270
|
+
run.usage = usageReceiptFromCostLedger(costLedger, caseUsageFilter);
|
|
5271
|
+
},
|
|
5272
|
+
signal: context.signal
|
|
5273
|
+
}
|
|
5274
|
+
});
|
|
5275
|
+
const sampleFindings = stampFindings(arm, completed.findings, { sample });
|
|
5276
|
+
run.rawFindings = [...run.rawFindings, ...sampleFindings];
|
|
5277
|
+
const adapted = await binding.adapt({
|
|
5278
|
+
subject: run.trajectoryId,
|
|
5279
|
+
findings: sampleFindings,
|
|
5280
|
+
analystId: definition.id,
|
|
5281
|
+
store,
|
|
5282
|
+
...context.signal ? { signal: context.signal } : {}
|
|
5283
|
+
});
|
|
5284
|
+
const assignments = adapted.stepBlocks ?? [];
|
|
5285
|
+
totals.sampleAssignments.push(assignments);
|
|
5286
|
+
totals.modelCalls += completed.modelCalls;
|
|
5287
|
+
totals.toolCalls += completed.toolCalls;
|
|
5288
|
+
totals.sampleRuns.push({
|
|
5289
|
+
sample,
|
|
5290
|
+
answer: completed.answer,
|
|
5291
|
+
trajectory: completed.trajectory,
|
|
5292
|
+
modelCalls: completed.modelCalls,
|
|
5293
|
+
toolCalls: completed.toolCalls,
|
|
5294
|
+
runtime: completed.runtime,
|
|
5295
|
+
...binding.consensus.sampleRecord(assignments),
|
|
5296
|
+
...adapted.diagnostics ? { blockDiagnostics: adapted.diagnostics } : {},
|
|
5297
|
+
...sampleUsage ? { usage: sampleUsage } : {}
|
|
5298
|
+
});
|
|
5299
|
+
}
|
|
5300
|
+
/** Run k samples, vote on their step blocks, and fall back only when the whole panel found nothing. */
|
|
5301
|
+
async function analyzeReplVariableSamples(arm, run, input, store) {
|
|
5302
|
+
const { definition, binding, costLedger, samples } = arm;
|
|
5303
|
+
const { context } = run;
|
|
5304
|
+
const totals = {
|
|
5305
|
+
sampleRuns: [],
|
|
5306
|
+
sampleAssignments: [],
|
|
5307
|
+
modelCalls: 0,
|
|
5308
|
+
toolCalls: 0
|
|
5309
|
+
};
|
|
5310
|
+
for (let sample = 0; sample < samples; sample += 1) await runReplVariableSample(arm, run, store, sample, totals);
|
|
5311
|
+
const consensus = binding.consensus.vote(totals.sampleAssignments);
|
|
5312
|
+
const expanded = await binding.consensus.expand({
|
|
5313
|
+
subject: run.trajectoryId,
|
|
5314
|
+
blocks: consensus.blocks,
|
|
5315
|
+
store,
|
|
5316
|
+
analystId: definition.id,
|
|
5317
|
+
producedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5318
|
+
...context.signal ? { signal: context.signal } : {}
|
|
5319
|
+
});
|
|
5320
|
+
let fallback;
|
|
5321
|
+
if (consensus.blocks.length === 0) fallback = await arm.abstentionFallbackRunner.analyze(input, context);
|
|
5322
|
+
run.usage = usageReceiptFromCostLedger(costLedger, {
|
|
5323
|
+
channel: "analyst",
|
|
5324
|
+
tags: run.tags
|
|
4669
5325
|
});
|
|
4670
5326
|
return {
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
store,
|
|
4736
|
-
...context.signal ? { signal: context.signal } : {}
|
|
4737
|
-
});
|
|
4738
|
-
const assignments = adapted.stepBlocks ?? [];
|
|
4739
|
-
sampleAssignments.push(assignments);
|
|
4740
|
-
totalModelCalls += completed.modelCalls;
|
|
4741
|
-
totalToolCalls += completed.toolCalls;
|
|
4742
|
-
sampleRuns.push({
|
|
4743
|
-
sample,
|
|
4744
|
-
answer: completed.answer,
|
|
4745
|
-
trajectory: completed.trajectory,
|
|
4746
|
-
modelCalls: completed.modelCalls,
|
|
4747
|
-
toolCalls: completed.toolCalls,
|
|
4748
|
-
runtime: completed.runtime,
|
|
4749
|
-
...binding.consensus.sampleRecord(assignments),
|
|
4750
|
-
...adapted.diagnostics ? { blockDiagnostics: adapted.diagnostics } : {},
|
|
4751
|
-
...sampleUsage ? { usage: sampleUsage } : {}
|
|
4752
|
-
});
|
|
4753
|
-
}
|
|
4754
|
-
const consensus = binding.consensus.vote(sampleAssignments);
|
|
4755
|
-
const expanded = await binding.consensus.expand({
|
|
4756
|
-
subject: trajectoryId,
|
|
4757
|
-
blocks: consensus.blocks,
|
|
4758
|
-
store,
|
|
4759
|
-
analystId: definition.id,
|
|
4760
|
-
producedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4761
|
-
...context.signal ? { signal: context.signal } : {}
|
|
4762
|
-
});
|
|
4763
|
-
let fallback;
|
|
4764
|
-
if (consensus.blocks.length === 0) fallback = await abstentionFallbackRunner.analyze(input, context);
|
|
4765
|
-
usage = usageReceiptFromCostLedger(costLedger, caseUsageFilter);
|
|
4766
|
-
return {
|
|
4767
|
-
findings: fallback && !fallback.error ? fallback.findings : expanded.findings,
|
|
4768
|
-
usage,
|
|
4769
|
-
metadata: {
|
|
4770
|
-
...binding.baseMetadata,
|
|
4771
|
-
protocolSha256,
|
|
4772
|
-
samples,
|
|
4773
|
-
sampleRuns,
|
|
4774
|
-
consensus: consensus.decision,
|
|
4775
|
-
blockDiagnostics: expanded.diagnostics,
|
|
4776
|
-
modelCalls: totalModelCalls,
|
|
4777
|
-
toolCalls: totalToolCalls,
|
|
4778
|
-
...fallback ? {
|
|
4779
|
-
abstentionFallback: "direct",
|
|
4780
|
-
...fallback.metadata ? { abstentionFallbackMetadata: fallback.metadata } : {},
|
|
4781
|
-
...fallback.error ? { abstentionFallbackError: fallback.error } : {}
|
|
4782
|
-
} : {}
|
|
4783
|
-
}
|
|
4784
|
-
};
|
|
4785
|
-
}
|
|
4786
|
-
const completed = await runTraceAnalyst({
|
|
4787
|
-
definition: traceDefinition,
|
|
4788
|
-
engine,
|
|
4789
|
-
store: input.traceStore,
|
|
4790
|
-
context: {
|
|
4791
|
-
runId: context.caseId,
|
|
4792
|
-
correlationId: `${context.caseId}:${context.repetition}`,
|
|
4793
|
-
costLedger,
|
|
4794
|
-
costPhase: binding.costPhase,
|
|
4795
|
-
tags,
|
|
4796
|
-
recordUsage: (receipt) => {
|
|
4797
|
-
usage = receipt;
|
|
4798
|
-
},
|
|
4799
|
-
signal: context.signal
|
|
4800
|
-
}
|
|
4801
|
-
});
|
|
4802
|
-
const producedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4803
|
-
rawFindings = completed.findings.map((finding) => makeFinding({
|
|
4804
|
-
analyst_id: definition.id,
|
|
4805
|
-
area,
|
|
4806
|
-
subject: finding.subject,
|
|
4807
|
-
claim: finding.claim,
|
|
4808
|
-
rationale: finding.rationale,
|
|
4809
|
-
severity: finding.severity,
|
|
4810
|
-
confidence: finding.confidence,
|
|
4811
|
-
evidence_refs: evidenceRefsFromRawFinding(finding),
|
|
4812
|
-
recommended_action: finding.recommended_action,
|
|
4813
|
-
metadata: {
|
|
4814
|
-
...binding.findingBaseMetadata,
|
|
4815
|
-
model: config.model,
|
|
4816
|
-
...binding.metadataFromSubject?.(finding.subject) ?? {}
|
|
4817
|
-
},
|
|
4818
|
-
produced_at: producedAt
|
|
4819
|
-
}));
|
|
4820
|
-
const adapted = await binding.adapt({
|
|
4821
|
-
subject: trajectoryId,
|
|
4822
|
-
findings: rawFindings,
|
|
4823
|
-
analystId: definition.id,
|
|
4824
|
-
store: input.traceStore,
|
|
4825
|
-
...context.signal ? { signal: context.signal } : {}
|
|
4826
|
-
});
|
|
4827
|
-
let fallback;
|
|
4828
|
-
if (completed.findings.length === 0) {
|
|
4829
|
-
fallback = await abstentionFallbackRunner.analyze(input, context);
|
|
4830
|
-
usage = usageReceiptFromCostLedger(costLedger, {
|
|
4831
|
-
channel: "analyst",
|
|
4832
|
-
tags: {
|
|
4833
|
-
benchmarkCaseId: context.caseId,
|
|
4834
|
-
benchmarkRepetition: String(context.repetition)
|
|
4835
|
-
}
|
|
4836
|
-
});
|
|
4837
|
-
}
|
|
4838
|
-
return {
|
|
4839
|
-
findings: fallback && !fallback.error ? fallback.findings : adapted.findings,
|
|
4840
|
-
usage,
|
|
4841
|
-
metadata: {
|
|
4842
|
-
...binding.baseMetadata,
|
|
4843
|
-
protocolSha256,
|
|
4844
|
-
...adapted.diagnostics ? { blockDiagnostics: adapted.diagnostics } : {},
|
|
4845
|
-
answer: completed.answer,
|
|
4846
|
-
trajectory: completed.trajectory,
|
|
4847
|
-
modelCalls: completed.modelCalls,
|
|
4848
|
-
toolCalls: completed.toolCalls,
|
|
4849
|
-
runtime: completed.runtime,
|
|
4850
|
-
...fallback ? {
|
|
4851
|
-
abstentionFallback: "direct",
|
|
4852
|
-
...fallback.metadata ? { abstentionFallbackMetadata: fallback.metadata } : {},
|
|
4853
|
-
...fallback.error ? { abstentionFallbackError: fallback.error } : {}
|
|
4854
|
-
} : {}
|
|
4855
|
-
}
|
|
4856
|
-
};
|
|
4857
|
-
} catch (error) {
|
|
4858
|
-
if (context.signal?.aborted) throw error;
|
|
4859
|
-
if (isPaidCallControlError(error)) throw error;
|
|
4860
|
-
return {
|
|
4861
|
-
findings: [],
|
|
4862
|
-
usage,
|
|
4863
|
-
error: publicBenchmarkError(error, []),
|
|
4864
|
-
metadata: {
|
|
4865
|
-
...binding.baseMetadata,
|
|
4866
|
-
...samples > 1 ? { samples } : {},
|
|
4867
|
-
rawFindings
|
|
4868
|
-
}
|
|
4869
|
-
};
|
|
4870
|
-
}
|
|
5327
|
+
findings: fallback && !fallback.error ? fallback.findings : expanded.findings,
|
|
5328
|
+
usage: run.usage,
|
|
5329
|
+
metadata: {
|
|
5330
|
+
...binding.baseMetadata,
|
|
5331
|
+
protocolSha256: definition.protocolSha256,
|
|
5332
|
+
samples,
|
|
5333
|
+
sampleRuns: totals.sampleRuns,
|
|
5334
|
+
consensus: consensus.decision,
|
|
5335
|
+
blockDiagnostics: expanded.diagnostics,
|
|
5336
|
+
modelCalls: totals.modelCalls,
|
|
5337
|
+
toolCalls: totals.toolCalls,
|
|
5338
|
+
...abstentionFallbackMetadata(fallback)
|
|
5339
|
+
}
|
|
5340
|
+
};
|
|
5341
|
+
}
|
|
5342
|
+
/** Run the engine once, adapt its rows, and fall back only when it submitted no finding. */
|
|
5343
|
+
async function analyzeReplVariableOnce(arm, run, input, store) {
|
|
5344
|
+
const { definition, binding, costLedger } = arm;
|
|
5345
|
+
const { context, tags } = run;
|
|
5346
|
+
const completed = await runTraceAnalyst({
|
|
5347
|
+
definition: arm.traceDefinition,
|
|
5348
|
+
engine: arm.engine,
|
|
5349
|
+
store,
|
|
5350
|
+
context: {
|
|
5351
|
+
runId: context.caseId,
|
|
5352
|
+
correlationId: `${context.caseId}:${context.repetition}`,
|
|
5353
|
+
costLedger,
|
|
5354
|
+
costPhase: binding.costPhase,
|
|
5355
|
+
tags,
|
|
5356
|
+
recordUsage: (receipt) => {
|
|
5357
|
+
run.usage = receipt;
|
|
5358
|
+
},
|
|
5359
|
+
signal: context.signal
|
|
5360
|
+
}
|
|
5361
|
+
});
|
|
5362
|
+
run.rawFindings = stampFindings(arm, completed.findings, {});
|
|
5363
|
+
const adapted = await binding.adapt({
|
|
5364
|
+
subject: run.trajectoryId,
|
|
5365
|
+
findings: run.rawFindings,
|
|
5366
|
+
analystId: definition.id,
|
|
5367
|
+
store,
|
|
5368
|
+
...context.signal ? { signal: context.signal } : {}
|
|
5369
|
+
});
|
|
5370
|
+
let fallback;
|
|
5371
|
+
if (completed.findings.length === 0) {
|
|
5372
|
+
fallback = await arm.abstentionFallbackRunner.analyze(input, context);
|
|
5373
|
+
run.usage = usageReceiptFromCostLedger(costLedger, {
|
|
5374
|
+
channel: "analyst",
|
|
5375
|
+
tags
|
|
5376
|
+
});
|
|
5377
|
+
}
|
|
5378
|
+
return {
|
|
5379
|
+
findings: fallback && !fallback.error ? fallback.findings : adapted.findings,
|
|
5380
|
+
usage: run.usage,
|
|
5381
|
+
metadata: {
|
|
5382
|
+
...binding.baseMetadata,
|
|
5383
|
+
protocolSha256: definition.protocolSha256,
|
|
5384
|
+
...adapted.diagnostics ? { blockDiagnostics: adapted.diagnostics } : {},
|
|
5385
|
+
answer: completed.answer,
|
|
5386
|
+
trajectory: completed.trajectory,
|
|
5387
|
+
modelCalls: completed.modelCalls,
|
|
5388
|
+
toolCalls: completed.toolCalls,
|
|
5389
|
+
runtime: completed.runtime,
|
|
5390
|
+
...abstentionFallbackMetadata(fallback)
|
|
4871
5391
|
}
|
|
4872
5392
|
};
|
|
4873
5393
|
}
|
|
5394
|
+
/** Analyze one benchmark case; a paid-call control error or an abort is rethrown, any other failure is recorded. */
|
|
5395
|
+
async function analyzeReplVariableCase(arm, input, context) {
|
|
5396
|
+
const { definition, binding, samples } = arm;
|
|
5397
|
+
const run = {
|
|
5398
|
+
context,
|
|
5399
|
+
trajectoryId: binding.subjectFromCaseId(context.caseId),
|
|
5400
|
+
tags: {
|
|
5401
|
+
benchmarkCaseId: context.caseId,
|
|
5402
|
+
benchmarkRepetition: String(context.repetition)
|
|
5403
|
+
},
|
|
5404
|
+
usage: void 0,
|
|
5405
|
+
rawFindings: []
|
|
5406
|
+
};
|
|
5407
|
+
try {
|
|
5408
|
+
if (!input.traceStore) throw new Error(`repl-variable analyst '${definition.id}' requires a trace store`);
|
|
5409
|
+
return samples > 1 ? await analyzeReplVariableSamples(arm, run, input, input.traceStore) : await analyzeReplVariableOnce(arm, run, input, input.traceStore);
|
|
5410
|
+
} catch (error) {
|
|
5411
|
+
if (context.signal?.aborted) throw error;
|
|
5412
|
+
if (isPaidCallControlError(error)) throw error;
|
|
5413
|
+
return {
|
|
5414
|
+
findings: [],
|
|
5415
|
+
usage: run.usage,
|
|
5416
|
+
error: publicBenchmarkError(error, []),
|
|
5417
|
+
metadata: {
|
|
5418
|
+
...binding.baseMetadata,
|
|
5419
|
+
...samples > 1 ? { samples } : {},
|
|
5420
|
+
rawFindings: run.rawFindings
|
|
5421
|
+
}
|
|
5422
|
+
};
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
/**
|
|
5426
|
+
* Compile a repl-variable definition into a runnable recursive-engine arm over
|
|
5427
|
+
* the caller-owned model path. The question, instructions, tool group, and
|
|
5428
|
+
* iteration limits come from the definition; the engine, model proxy, sampling
|
|
5429
|
+
* loop, and abstention floor are transport machinery.
|
|
5430
|
+
*/
|
|
5431
|
+
function runReplVariableAnalystDefinition(definition, config) {
|
|
5432
|
+
const arm = compileReplVariableArm(definition, config);
|
|
5433
|
+
return {
|
|
5434
|
+
id: definition.id,
|
|
5435
|
+
analyze: (input, context) => analyzeReplVariableCase(arm, input, context)
|
|
5436
|
+
};
|
|
5437
|
+
}
|
|
4874
5438
|
/** Per-sample accepted blocks with the exact steps the expansion kept for each. */
|
|
4875
5439
|
function sampleBlockRecords(assignments) {
|
|
4876
5440
|
const stepsByBlock = /* @__PURE__ */ new Map();
|
|
@@ -6324,6 +6888,6 @@ function shellQuote(value) {
|
|
|
6324
6888
|
return /^[a-zA-Z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
|
|
6325
6889
|
}
|
|
6326
6890
|
//#endregion
|
|
6327
|
-
export {
|
|
6891
|
+
export { agentRxBenchmarkCase as A, ANALYST_BENCHMARK_COST_LEDGER_FILE as C, AGENT_RX_UPSTREAM_REVISION as D, ANALYST_BENCHMARK_OBSERVATIONS_FILE as E, normalizeAgentRxCategory as M, runAnalystBenchmark as N, codeTraceBenchCase as O, traceStoreEvidenceResolver as P, ANALYST_BENCHMARK_IMPLEMENTATION_FILES as S, ANALYST_BENCHMARK_MANIFEST_FILE as T, readAnalystBenchmarkArtifact as _, runInlineAnalystDefinition as a, ANALYST_BENCHMARK_EVIDENCE_DEPENDENCY_LOCK_SHA256 as b, publicRlmAnalystDefinition as c, publicDirectAnalystDefinition as d, runChunkedAnalystDefinition as f, expandCodeTraceFailureBlocks as g, analystDefinitionProtocolSha256 as h, primeCodeTraceAnalystDefinition as i, agentRxPredictionsToFindings as j, codeTracerPredictionsToFindings as k, runReplVariableAnalystDefinition as l, analystDefinitionAsymmetries as m, createPrimeBenchmarkRunner as n, loadPublicBenchmarkRows as o, AnalystExpressivenessError as p, primeAnalystProtocolSha256 as r, createPublicBenchmarkRlmRunner as s, runAnalystBenchmarkCommand as t, createPublicBenchmarkDirectRunner as u, CODE_TRACE_BENCH_ANALYST_PROMPT as v, ANALYST_BENCHMARK_LOCAL_RECEIPT_FILE as w, ANALYST_BENCHMARK_EVIDENCE_IMPLEMENTATION_SHA256 as x, publicBenchmarkProtocolSha256 as y };
|
|
6328
6892
|
|
|
6329
|
-
//# sourceMappingURL=benchmark-command-
|
|
6893
|
+
//# sourceMappingURL=benchmark-command-BupdHRyf.js.map
|