@tangle-network/agent-eval 0.217.1 → 0.219.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -1
- package/dist/adapters/http.d.ts +3 -3
- package/dist/adapters/http.d.ts.map +1 -1
- package/dist/adapters/http.js +1 -0
- package/dist/adapters/http.js.map +1 -1
- package/dist/{agent-profile-DTt8uGP9.d.ts → agent-profile-D01Io2Xw.d.ts} +4 -4
- package/dist/{agent-profile-DTt8uGP9.d.ts.map → agent-profile-D01Io2Xw.d.ts.map} +1 -1
- package/dist/analyst/index.d.ts +13 -13
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +10 -10
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-DyeNcenW.d.ts → analyze-runs-BWAHBDAw.d.ts} +4 -4
- package/dist/{analyze-runs-DyeNcenW.d.ts.map → analyze-runs-BWAHBDAw.d.ts.map} +1 -1
- package/dist/{benchmark-command-xQK8nOI6.js → benchmark-command-BzmMTnvC.js} +664 -565
- package/dist/benchmark-command-BzmMTnvC.js.map +1 -0
- package/dist/benchmarks/index.d.ts +5 -5
- package/dist/benchmarks/index.js +3 -3
- package/dist/benchmarks/index.js.map +1 -1
- package/dist/campaign/index.d.ts +8 -8
- package/dist/campaign/index.js +11 -11
- package/dist/{campaign-CJGkxAQ6.js → campaign-BVPC6ODQ.js} +452 -282
- package/dist/campaign-BVPC6ODQ.js.map +1 -0
- package/dist/{campaign-evidence-CQYw8_0H.js → campaign-evidence-DunzcJGv.js} +2 -2
- package/dist/campaign-evidence-DunzcJGv.js.map +1 -0
- package/dist/{chat-client-ldqxYYTN.js → chat-client-CMQ8_h4J.js} +2 -2
- package/dist/{chat-client-ldqxYYTN.js.map → chat-client-CMQ8_h4J.js.map} +1 -1
- package/dist/{chat-json-call-DavzexSp.js → chat-json-call-BrZKn0L3.js} +2 -2
- package/dist/{chat-json-call-DavzexSp.js.map → chat-json-call-BrZKn0L3.js.map} +1 -1
- package/dist/cli.js +10 -10
- package/dist/{completion-verifier-B_jw6C9p.js → completion-verifier-Cigap8CG.js} +5 -5
- package/dist/{completion-verifier-B_jw6C9p.js.map → completion-verifier-Cigap8CG.js.map} +1 -1
- package/dist/contract/index.d.ts +11 -11
- package/dist/contract/index.js +91 -11
- package/dist/contract/index.js.map +1 -1
- package/dist/{cost-ledger-D0352Z4d.js → cost-ledger-BGZB6yY2.js} +75 -2
- package/dist/cost-ledger-BGZB6yY2.js.map +1 -0
- package/dist/{cost-ledger-Jk62OBfF.d.ts → cost-ledger-C1W3ICmP.d.ts} +26 -2
- package/dist/cost-ledger-C1W3ICmP.d.ts.map +1 -0
- package/dist/{default-registry-ClYjq3QE.js → default-registry-BrKmT01n.js} +310 -278
- package/dist/{default-registry-ClYjq3QE.js.map → default-registry-BrKmT01n.js.map} +1 -1
- package/dist/{default-registry-DXgLmoDI.d.ts → default-registry-Cwg_QN3d.d.ts} +6 -6
- package/dist/{default-registry-DXgLmoDI.d.ts.map → default-registry-Cwg_QN3d.d.ts.map} +1 -1
- package/dist/{define-agent-eval-BIkH_gAR.d.ts → define-agent-eval-C2nFhHPu.d.ts} +8 -8
- package/dist/{define-agent-eval-BIkH_gAR.d.ts.map → define-agent-eval-C2nFhHPu.d.ts.map} +1 -1
- package/dist/{define-agent-eval-BDxNlP3D.js → define-agent-eval-UQY3VbJ2.js} +165 -105
- package/dist/define-agent-eval-UQY3VbJ2.js.map +1 -0
- package/dist/diagnosis/index.d.ts +2 -2
- package/dist/{dspy-rlm-engine-DhdCr1Dc.js → dspy-rlm-engine-Bn_Mt_LW.js} +3 -3
- package/dist/{dspy-rlm-engine-DhdCr1Dc.js.map → dspy-rlm-engine-Bn_Mt_LW.js.map} +1 -1
- package/dist/{engine-BvZ0R-36.d.ts → engine-BpGGw6cd.d.ts} +3 -3
- package/dist/{engine-BvZ0R-36.d.ts.map → engine-BpGGw6cd.d.ts.map} +1 -1
- package/dist/eval-campaign-BUMIxKTE.js +393 -0
- package/dist/eval-campaign-BUMIxKTE.js.map +1 -0
- package/dist/{evaluation-jTjC_QQD.d.ts → evaluation-CBdQt_kr.d.ts} +4 -4
- package/dist/{evaluation-jTjC_QQD.d.ts.map → evaluation-CBdQt_kr.d.ts.map} +1 -1
- package/dist/evaluation.d.ts +1 -1
- package/dist/evaluation.js +1 -1
- package/dist/{exact-types-CflbJ9f3.d.ts → exact-types-BYFmYq44.d.ts} +2 -2
- package/dist/{exact-types-CflbJ9f3.d.ts.map → exact-types-BYFmYq44.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +24 -1
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/experiment/index.js +110 -71
- package/dist/experiment/index.js.map +1 -1
- package/dist/{exporters-Cl6IeNAu.js → exporters-DWvM16LE.js} +2 -2
- package/dist/{exporters-Cl6IeNAu.js.map → exporters-DWvM16LE.js.map} +1 -1
- package/dist/{external-optimizer-process-KVFGvYX1.js → external-optimizer-process-wOLfzsCC.js} +2 -2
- package/dist/{external-optimizer-process-KVFGvYX1.js.map → external-optimizer-process-wOLfzsCC.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-XIHBOSKt.js → external-optimizer-subprocess-D670Oxf2.js} +4 -4
- package/dist/{external-optimizer-subprocess-XIHBOSKt.js.map → external-optimizer-subprocess-D670Oxf2.js.map} +1 -1
- package/dist/{feedback-trajectory-BWmhRBGu.d.ts → feedback-trajectory-DhB9WzYg.d.ts} +3 -3
- package/dist/{feedback-trajectory-BWmhRBGu.d.ts.map → feedback-trajectory-DhB9WzYg.d.ts.map} +1 -1
- package/dist/{findings-store-BMVQtEsm.js → findings-store-CvNo712L.js} +6 -6
- package/dist/{findings-store-BMVQtEsm.js.map → findings-store-CvNo712L.js.map} +1 -1
- package/dist/fuzz.d.ts +1 -1
- package/dist/fuzz.js +1 -1
- package/dist/{hf-dataset-D9f7-oX7.js → hf-dataset-CKxIJQba.js} +3 -3
- package/dist/{hf-dataset-D9f7-oX7.js.map → hf-dataset-CKxIJQba.js.map} +1 -1
- package/dist/hosted/index.js +1 -1
- package/dist/{index-CX-GAUpw.d.ts → index-CHxwfW5g.d.ts} +2 -2
- package/dist/{index-CX-GAUpw.d.ts.map → index-CHxwfW5g.d.ts.map} +1 -1
- package/dist/{index-BLGqZ81N.d.ts → index-CVFStrQD.d.ts} +8 -8
- package/dist/{index-BLGqZ81N.d.ts.map → index-CVFStrQD.d.ts.map} +1 -1
- package/dist/{index-9jJ2fKSX.d.ts → index-CalAsXMR.d.ts} +7 -5
- package/dist/index-CalAsXMR.d.ts.map +1 -0
- package/dist/{index-CiRwLv2R.d.ts → index-D7fmC-1K.d.ts} +3 -4
- package/dist/index-D7fmC-1K.d.ts.map +1 -0
- package/dist/{index-BiT6RtNH.d.ts → index-DAXfpVf7.d.ts} +10 -10
- package/dist/{index-BiT6RtNH.d.ts.map → index-DAXfpVf7.d.ts.map} +1 -1
- package/dist/{index-ZuWx52WG.d.ts → index-Q6DvdcwI.d.ts} +67 -24
- package/dist/index-Q6DvdcwI.d.ts.map +1 -0
- package/dist/index.d.ts +26 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +615 -692
- package/dist/index.js.map +1 -1
- package/dist/{integrity-DOd9Q86O.js → integrity-C8oUeB0g.js} +322 -197
- package/dist/integrity-C8oUeB0g.js.map +1 -0
- package/dist/{integrity-_qgZLA5p.d.ts → integrity-CCwvezWS.d.ts} +2 -2
- package/dist/{integrity-_qgZLA5p.d.ts.map → integrity-CCwvezWS.d.ts.map} +1 -1
- package/dist/{journal-CR4QikYp.js → journal-C7om8Gum.js} +48 -38
- package/dist/journal-C7om8Gum.js.map +1 -0
- package/dist/judge-gate-Co5tuh57.js.map +1 -1
- package/dist/{judge-gate-DsL0yFcb.d.ts → judge-gate-Dc_mXQsL.d.ts} +2 -2
- package/dist/judge-gate-Dc_mXQsL.d.ts.map +1 -0
- package/dist/{kind-factory-Gy4fXixd.js → kind-factory-BhxbtUsQ.js} +2 -2
- package/dist/{kind-factory-Gy4fXixd.js.map → kind-factory-BhxbtUsQ.js.map} +1 -1
- package/dist/ledger-core/index.d.ts +1 -1
- package/dist/ledger-core/index.js +2 -2
- 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-DrJhbms9.js → ledger-core-CAxUdDk0.js} +2 -2
- package/dist/{ledger-core-DrJhbms9.js.map → ledger-core-CAxUdDk0.js.map} +1 -1
- package/dist/{llm-client-BshCREn6.js → llm-client-DXuOTseU.js} +239 -249
- package/dist/llm-client-DXuOTseU.js.map +1 -0
- package/dist/{llm-judge-C8jMTNNG.js → llm-judge-Cc8vDJh_.js} +648 -459
- package/dist/llm-judge-Cc8vDJh_.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 +2 -2
- package/dist/{matrix-DHe-dwVJ.d.ts → matrix-Cf-AGxGh.d.ts} +4 -4
- package/dist/{matrix-DHe-dwVJ.d.ts.map → matrix-Cf-AGxGh.d.ts.map} +1 -1
- package/dist/meta-eval/index.d.ts +2 -2
- package/dist/{mint-zszyYlpA.js → mint-CbdwjTPW.js} +2 -2
- package/dist/{mint-zszyYlpA.js.map → mint-CbdwjTPW.js.map} +1 -1
- package/dist/{mint-BRZXuwRi.d.ts → mint-CkzpVPdz.d.ts} +3 -3
- package/dist/{mint-BRZXuwRi.d.ts.map → mint-CkzpVPdz.d.ts.map} +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +2 -2
- package/dist/multishot/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/{pareto-BzsxidFD.js → pareto-BiBnQXAE.js} +306 -212
- package/dist/pareto-BiBnQXAE.js.map +1 -0
- package/dist/pipelines/index.d.ts.map +1 -1
- package/dist/pipelines/index.js.map +1 -1
- package/dist/{prime-protocol-BWG2DQIk.d.ts → prime-protocol-CckHBxGu.d.ts} +3 -3
- package/dist/{prime-protocol-BWG2DQIk.d.ts.map → prime-protocol-CckHBxGu.d.ts.map} +1 -1
- package/dist/{promotion-gate-DaY95yU6.d.ts → promotion-gate-CkVZHagC.d.ts} +3 -3
- package/dist/{promotion-gate-DaY95yU6.d.ts.map → promotion-gate-CkVZHagC.d.ts.map} +1 -1
- package/dist/{proposal-findings-BbWidvUk.js → proposal-findings-E1aSC_cU.js} +2 -2
- package/dist/{proposal-findings-BbWidvUk.js.map → proposal-findings-E1aSC_cU.js.map} +1 -1
- package/dist/{registry-ssNoHzwD.d.ts → registry-B_yG-1jh.d.ts} +5 -5
- package/dist/{registry-ssNoHzwD.d.ts.map → registry-B_yG-1jh.d.ts.map} +1 -1
- package/dist/{render-C-w2EZ6p.js → render-Cs34y0iX.js} +404 -208
- package/dist/render-Cs34y0iX.js.map +1 -0
- package/dist/reporting.d.ts +3 -3
- package/dist/{researcher-0ABVIdGa.d.ts → researcher-H0p44OYC.d.ts} +5 -5
- package/dist/{researcher-0ABVIdGa.d.ts.map → researcher-H0p44OYC.d.ts.map} +1 -1
- package/dist/{reward-DrZ71vnf.d.ts → reward-BeUgVVC_.d.ts} +2 -2
- package/dist/{reward-DrZ71vnf.d.ts.map → reward-BeUgVVC_.d.ts.map} +1 -1
- package/dist/{reward-hacking-E52wq86n.d.ts → reward-hacking-WTxUbtbb.d.ts} +2 -2
- package/dist/{reward-hacking-E52wq86n.d.ts.map → reward-hacking-WTxUbtbb.d.ts.map} +1 -1
- package/dist/rl.d.ts +8 -8
- package/dist/rl.js +4 -4
- package/dist/rollout/index.d.ts +3 -3
- package/dist/rollout/index.js +5 -5
- package/dist/{rollout-D6C50mfA.js → rollout-Dd1ucT_M.js} +5 -5
- package/dist/{rollout-D6C50mfA.js.map → rollout-Dd1ucT_M.js.map} +1 -1
- package/dist/{rubric-predictive-validity-DiwT8PbL.d.ts → rubric-predictive-validity-noY7uE03.d.ts} +2 -2
- package/dist/{rubric-predictive-validity-DiwT8PbL.d.ts.map → rubric-predictive-validity-noY7uE03.d.ts.map} +1 -1
- package/dist/{run-record-CaxbLq6Y.d.ts → run-record-C3awiXPf.d.ts} +2 -2
- package/dist/{run-record-CaxbLq6Y.d.ts.map → run-record-C3awiXPf.d.ts.map} +1 -1
- package/dist/schema-C-ziyJD7.d.ts.map +1 -1
- package/dist/{schema-DxcKTzbi.js → schema-CvhfLjtZ.js} +77 -47
- package/dist/schema-CvhfLjtZ.js.map +1 -0
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +2 -2
- package/dist/{search-kernel-DxqjBxA-.d.ts → search-kernel-Dloxd6gs.d.ts} +5 -5
- package/dist/{search-kernel-DxqjBxA-.d.ts.map → search-kernel-Dloxd6gs.d.ts.map} +1 -1
- package/dist/{search-ledger-TUvB5gWH.js → search-ledger-CZRqtFbW.js} +252 -245
- package/dist/search-ledger-CZRqtFbW.js.map +1 -0
- package/dist/{search-ledger-file-UKCO2r8a.js → search-ledger-file-Bd5Tioq6.js} +3 -3
- package/dist/{search-ledger-file-UKCO2r8a.js.map → search-ledger-file-Bd5Tioq6.js.map} +1 -1
- package/dist/{search-shipper-Cw2z3-td.js → search-shipper-Dn3NLsuH.js} +3 -3
- package/dist/{search-shipper-Cw2z3-td.js.map → search-shipper-Dn3NLsuH.js.map} +1 -1
- package/dist/{search-summary-DQIvJsSB.js → search-summary-D4bwYnAE.js} +3 -3
- package/dist/{search-summary-DQIvJsSB.js.map → search-summary-D4bwYnAE.js.map} +1 -1
- package/dist/{server-DoVbqqtJ.js → server-8TS8XCvg.js} +3 -3
- package/dist/{server-DoVbqqtJ.js.map → server-8TS8XCvg.js.map} +1 -1
- package/dist/{single-run-lock-U58yf8N6.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-kyL94-ri.js → skillopt-optimization-method-DLKqdhcR.js} +1384 -1059
- package/dist/skillopt-optimization-method-DLKqdhcR.js.map +1 -0
- package/dist/{statistical-heldout-C9AbgREN.d.ts → statistical-heldout-3z3I-kJN.d.ts} +3 -3
- package/dist/{statistical-heldout-C9AbgREN.d.ts.map → statistical-heldout-3z3I-kJN.d.ts.map} +1 -1
- package/dist/{store-otlp-BteDAbHK.js → store-otlp-dyWE3wAG.js} +2 -2
- package/dist/{store-otlp-BteDAbHK.js.map → store-otlp-dyWE3wAG.js.map} +1 -1
- package/dist/{store-tool-spans-D5l_OfTJ.js → store-tool-spans-DIUgZbzu.js} +3 -3
- package/dist/{store-tool-spans-D5l_OfTJ.js.map → store-tool-spans-DIUgZbzu.js.map} +1 -1
- package/dist/{store-tool-spans-DZS0HWVf.d.ts → store-tool-spans-DPwXHQkH.d.ts} +7 -7
- package/dist/{store-tool-spans-DZS0HWVf.d.ts.map → store-tool-spans-DPwXHQkH.d.ts.map} +1 -1
- package/dist/{summary-report-DM7tlml1.d.ts → summary-report-C8V49Jt3.d.ts} +18 -3
- package/dist/summary-report-C8V49Jt3.d.ts.map +1 -0
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +3 -3
- package/dist/{systemone-Bp_Ac0p1.d.ts → systemone-DVA7t76V.d.ts} +6 -6
- package/dist/{systemone-Bp_Ac0p1.d.ts.map → systemone-DVA7t76V.d.ts.map} +1 -1
- package/dist/{systemone-review-CwE6JGIp.d.ts → systemone-review-CUBMuTLi.d.ts} +2 -2
- package/dist/{systemone-review-CwE6JGIp.d.ts.map → systemone-review-CUBMuTLi.d.ts.map} +1 -1
- package/dist/systemone.d.ts +3 -3
- package/dist/{terminal-record-78g6E4vh.js → terminal-record-D4Rv-j1W.js} +241 -193
- package/dist/{terminal-record-78g6E4vh.js.map → terminal-record-D4Rv-j1W.js.map} +1 -1
- package/dist/{tool-groups-DyNz2JZ_.d.ts → tool-groups-LISbBWCg.d.ts} +3 -3
- package/dist/tool-groups-LISbBWCg.d.ts.map +1 -0
- package/dist/{trace-questions-xxwgsuMi.d.ts → trace-questions-C42fYEE4.d.ts} +4 -4
- package/dist/{trace-questions-xxwgsuMi.d.ts.map → trace-questions-C42fYEE4.d.ts.map} +1 -1
- package/dist/trace-repair/index.d.ts +3 -3
- package/dist/traces.d.ts +6 -6
- package/dist/traces.js +3 -3
- package/dist/trajectory-replay/index.d.ts +4 -1
- package/dist/trajectory-replay/index.d.ts.map +1 -1
- package/dist/trajectory-replay/index.js +854 -823
- package/dist/trajectory-replay/index.js.map +1 -1
- package/dist/{tree-BGRglkKd.js → tree-DSqwJpL9.js} +122 -14
- package/dist/tree-DSqwJpL9.js.map +1 -0
- package/dist/{types-CW8ewATZ.d.ts → types-8yQzNm8u.d.ts} +4 -4
- package/dist/{types-CW8ewATZ.d.ts.map → types-8yQzNm8u.d.ts.map} +1 -1
- package/dist/{types-D8GhJoHk.d.ts → types-CHfn1zg5.d.ts} +70 -72
- package/dist/types-CHfn1zg5.d.ts.map +1 -0
- package/dist/{types-DtMbFw6U.d.ts → types-D8GXK9Z5.d.ts} +3 -3
- package/dist/{types-DtMbFw6U.d.ts.map → types-D8GXK9Z5.d.ts.map} +1 -1
- package/dist/{types-D-mgRzlh.d.ts → types-eMhdacVp.d.ts} +2 -2
- package/dist/{types-D-mgRzlh.d.ts.map → types-eMhdacVp.d.ts.map} +1 -1
- package/dist/wire/index.d.ts +3 -3
- package/dist/wire/index.js +1 -1
- package/docs/campaign-proposers.md +16 -0
- package/docs/concepts.md +31 -0
- package/docs/design/statistics-decisions.md +1 -1
- package/docs/eval-surface-map.md +1 -0
- package/docs/profile-json-identity.md +1 -2
- package/docs/public-api.md +100 -88
- package/package.json +8 -6
- package/dist/benchmark-command-xQK8nOI6.js.map +0 -1
- package/dist/campaign-CJGkxAQ6.js.map +0 -1
- package/dist/campaign-evidence-CQYw8_0H.js.map +0 -1
- package/dist/cost-ledger-D0352Z4d.js.map +0 -1
- package/dist/cost-ledger-Jk62OBfF.d.ts.map +0 -1
- package/dist/define-agent-eval-BDxNlP3D.js.map +0 -1
- package/dist/eval-campaign-BLEfBGbA.js +0 -343
- package/dist/eval-campaign-BLEfBGbA.js.map +0 -1
- package/dist/index-9jJ2fKSX.d.ts.map +0 -1
- package/dist/index-CiRwLv2R.d.ts.map +0 -1
- package/dist/index-ZuWx52WG.d.ts.map +0 -1
- package/dist/integrity-DOd9Q86O.js.map +0 -1
- package/dist/journal-CR4QikYp.js.map +0 -1
- package/dist/judge-gate-DsL0yFcb.d.ts.map +0 -1
- package/dist/llm-client-BshCREn6.js.map +0 -1
- package/dist/llm-judge-C8jMTNNG.js.map +0 -1
- package/dist/pareto-BzsxidFD.js.map +0 -1
- package/dist/render-C-w2EZ6p.js.map +0 -1
- package/dist/schema-DxcKTzbi.js.map +0 -1
- package/dist/search-ledger-TUvB5gWH.js.map +0 -1
- package/dist/single-run-lock-U58yf8N6.js.map +0 -1
- package/dist/skillopt-optimization-method-kyL94-ri.js.map +0 -1
- package/dist/summary-report-DM7tlml1.d.ts.map +0 -1
- package/dist/tool-groups-DyNz2JZ_.d.ts.map +0 -1
- package/dist/tree-BGRglkKd.js.map +0 -1
- package/dist/types-D8GhJoHk.d.ts.map +0 -1
|
@@ -2,19 +2,19 @@ import { c as errorMessage, s as ValidationError, t as AgentEvalError } from "./
|
|
|
2
2
|
import { a as hashCanonical, i as compareCodeUnits, o as jsonDocument, r as canonicalString } from "./canonical-Dq2hOQ8L.js";
|
|
3
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 { l as withLedgerFileLock, u as writeLedgerFileAtomically } from "./journal-
|
|
7
|
-
import "./ledger-core-
|
|
8
|
-
import { M as fsCampaignStorage, b as AnalystFindingSchema, i as startExternalOptimizerModelProxy, j as createRunCostLedger, r as runWithCleanup, v as resolveExternalOptimizerProcessLimits } from "./external-optimizer-subprocess-
|
|
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-BGZB6yY2.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-D670Oxf2.js";
|
|
9
9
|
import { s as redactText } from "./redact-mtkTiJVk.js";
|
|
10
10
|
import { i as makeFinding } from "./types-DqFMNTgK.js";
|
|
11
|
-
import { t as acquireSingleRunLock } from "./single-run-lock-
|
|
11
|
+
import { t as acquireSingleRunLock } from "./single-run-lock-Dekd8_Wv.js";
|
|
12
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-
|
|
14
|
-
import { n as callLlmJson } from "./llm-client-
|
|
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 "./external-optimizer-process-
|
|
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-BhxbtUsQ.js";
|
|
14
|
+
import { n as callLlmJson } from "./llm-client-DXuOTseU.js";
|
|
15
|
+
import { t as createDspyRlmTraceEngine } from "./dspy-rlm-engine-Bn_Mt_LW.js";
|
|
16
|
+
import { i as otlpTextToTraceAnalysisStore, n as DEFAULT_MAX_TRACE_FILE_BYTES, t as BufferTraceStore } from "./store-otlp-dyWE3wAG.js";
|
|
17
|
+
import "./external-optimizer-process-wOLfzsCC.js";
|
|
18
18
|
import { t as assertEqualDeclarativeTerms } from "./equal-terms-DbPGcVtI.js";
|
|
19
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";
|
|
20
20
|
import { t as nodeHttpPrimeBridgeTransport } from "./prime-bridge-transport-Z3cpKGoV.js";
|
|
@@ -1877,7 +1877,7 @@ Object.freeze([
|
|
|
1877
1877
|
"package.json",
|
|
1878
1878
|
"pnpm-lock.yaml"
|
|
1879
1879
|
]);
|
|
1880
|
-
const ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 = "
|
|
1880
|
+
const ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 = "2cbded9c738fb0bea1a90ac7da6714c75b6c7aae70aebf6ef4c833df2db652f8";
|
|
1881
1881
|
const ANALYST_BENCHMARK_EVIDENCE_DEPENDENCY_LOCK_SHA256 = "1e03f2daed356d60316aabefb407ec1e437ac94d408d61eea4ae096e9c6fbb5b";
|
|
1882
1882
|
const ANALYST_BENCHMARK_EVIDENCE_IMPLEMENTATION_SHA256 = "4dba263b6256a30d56c7fdb2d992d3a953c0035d731f359b704db806f68f75ac";
|
|
1883
1883
|
const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
@@ -1905,6 +1905,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1905
1905
|
"src/analyst/benchmark-instructions-override.ts",
|
|
1906
1906
|
"src/analyst/benchmark-public-adapters.ts",
|
|
1907
1907
|
"src/analyst/benchmark-public-calibration.ts",
|
|
1908
|
+
"src/analyst/benchmark-public-chunked.ts",
|
|
1908
1909
|
"src/analyst/benchmark-public-consensus.ts",
|
|
1909
1910
|
"src/analyst/benchmark-public-data.ts",
|
|
1910
1911
|
"src/analyst/benchmark-public-errors.ts",
|
|
@@ -1974,6 +1975,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
1974
1975
|
"src/ledger-core/index.ts",
|
|
1975
1976
|
"src/ledger-core/journal-file.ts",
|
|
1976
1977
|
"src/ledger-core/journal.ts",
|
|
1978
|
+
"src/ledger-core/lock-holder.ts",
|
|
1977
1979
|
"src/ledger-core/merkle.ts",
|
|
1978
1980
|
"src/ledger-core/projector-snapshot.ts",
|
|
1979
1981
|
"src/ledger-core/trusted-head.ts",
|
|
@@ -2027,7 +2029,7 @@ const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
|
2027
2029
|
"src/trace/redaction/detectors.ts",
|
|
2028
2030
|
"src/verdict-cache.ts"
|
|
2029
2031
|
]);
|
|
2030
|
-
const ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 = "
|
|
2032
|
+
const ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 = "ae18283837ab8e3eb1feb97e54f9b2574a45737e455a8c6b457c17f044bf5df9";
|
|
2031
2033
|
//#endregion
|
|
2032
2034
|
//#region src/analyst/benchmark-evidence-validation.ts
|
|
2033
2035
|
const MIN_ACTION_EXCERPT_CHARACTERS = 12;
|
|
@@ -4170,89 +4172,10 @@ function analystDefinitionAsymmetries(definitions) {
|
|
|
4170
4172
|
};
|
|
4171
4173
|
}
|
|
4172
4174
|
//#endregion
|
|
4173
|
-
//#region src/analyst/benchmark-public-
|
|
4174
|
-
/** The
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
const outputAdapter = dataset === "agentrx" ? "agentrx-taxonomy-and-root-step" : "codetracebench-incorrect-block";
|
|
4178
|
-
return {
|
|
4179
|
-
id: "direct",
|
|
4180
|
-
description: "One-shot JSON baseline over the caller-owned model path.",
|
|
4181
|
-
version: "1.0.0",
|
|
4182
|
-
area: dataset === "agentrx" ? "root-cause" : "incorrect",
|
|
4183
|
-
profile: { model: { reasoningEffort: "none" } },
|
|
4184
|
-
question: "",
|
|
4185
|
-
taskDefinition: publicBenchmarkTaskPrompt(dataset),
|
|
4186
|
-
projection: {
|
|
4187
|
-
mode: "chunked",
|
|
4188
|
-
attributeByteCaps: TRACE_PROJECTION_ATTRIBUTE_BYTE_CAPS
|
|
4189
|
-
},
|
|
4190
|
-
replyContract: directReplyContract(dataset),
|
|
4191
|
-
contractLimits: dataset === "agentrx" ? { maxFindings: 1 } : {
|
|
4192
|
-
maxBlocks: 16,
|
|
4193
|
-
maxBlockSteps: 12
|
|
4194
|
-
},
|
|
4195
|
-
budget: {
|
|
4196
|
-
timeoutMs: args.timeoutMs,
|
|
4197
|
-
maxCostUsd: args.maxCostUsd,
|
|
4198
|
-
maxOutputTokens: args.maxOutputTokens
|
|
4199
|
-
},
|
|
4200
|
-
repair: { turns: 0 },
|
|
4201
|
-
protocolSha256: publicBenchmarkProtocolSha256(dataset),
|
|
4202
|
-
binding: {
|
|
4203
|
-
kind: "chunked",
|
|
4204
|
-
subjectFromCaseId: (caseId) => trajectoryIdFromCaseId$2(dataset, caseId),
|
|
4205
|
-
baseMetadata: {
|
|
4206
|
-
analysisMode: "direct-baseline",
|
|
4207
|
-
outputAdapter
|
|
4208
|
-
},
|
|
4209
|
-
costActor: actor,
|
|
4210
|
-
costPhase: "analyst.public-benchmark",
|
|
4211
|
-
userMessage: (rendered) => `TRACE DATA:\n${rendered}\n\nReturn the analysis JSON object.`,
|
|
4212
|
-
async expandRows({ subject, rows, store, analystId, producedAt, providerModel, signal }) {
|
|
4213
|
-
const converted = await publicBenchmarkPredictionsToFindings({
|
|
4214
|
-
dataset,
|
|
4215
|
-
trajectoryId: subject,
|
|
4216
|
-
predictions: rows,
|
|
4217
|
-
store,
|
|
4218
|
-
analystId,
|
|
4219
|
-
providerModel: requiredString(providerModel ?? "", "finding providerModel"),
|
|
4220
|
-
producedAt: requiredString(producedAt ?? "", "finding producedAt"),
|
|
4221
|
-
...signal ? { signal } : {}
|
|
4222
|
-
});
|
|
4223
|
-
return {
|
|
4224
|
-
findings: converted.findings,
|
|
4225
|
-
diagnostics: converted.diagnostics
|
|
4226
|
-
};
|
|
4227
|
-
},
|
|
4228
|
-
...dataset === "codetracebench" ? { verifyFindings: async (args) => {
|
|
4229
|
-
await validateCodeTraceFindingEvidence({
|
|
4230
|
-
trajectoryId: args.subject,
|
|
4231
|
-
findings: [...args.findings],
|
|
4232
|
-
store: args.store,
|
|
4233
|
-
...args.signal ? { signal: args.signal } : {}
|
|
4234
|
-
});
|
|
4235
|
-
} } : {}
|
|
4236
|
-
}
|
|
4237
|
-
};
|
|
4238
|
-
}
|
|
4239
|
-
/** Thin shell: validate config, declare the definition, run the chunked strategy. */
|
|
4240
|
-
function createPublicBenchmarkDirectRunner(dataset, config) {
|
|
4241
|
-
if (config.instructionsOverride) throw new Error("the direct runner executes only the stock protocol; an instructions override requires the dspy-rlm runner");
|
|
4242
|
-
const maxOutputTokens = positiveSafeInteger(config.maxOutputTokens, "maxOutputTokens");
|
|
4243
|
-
return runChunkedAnalystDefinition(publicDirectAnalystDefinition(dataset, {
|
|
4244
|
-
timeoutMs: positiveSafeInteger(config.timeoutMs, "timeoutMs"),
|
|
4245
|
-
maxOutputTokens,
|
|
4246
|
-
maxCostUsd: config.maxCostUsdPerAnalysis ?? 1
|
|
4247
|
-
}), config);
|
|
4248
|
-
}
|
|
4249
|
-
/**
|
|
4250
|
-
* Compile a chunked-projection definition into a runnable one-shot JSON arm
|
|
4251
|
-
* over the caller-owned model path. Prompt content, the projection ladder,
|
|
4252
|
-
* the reply grammar, and the budget declaration come from the definition;
|
|
4253
|
-
* caching, cost settlement, and the model proxy are transport machinery.
|
|
4254
|
-
*/
|
|
4255
|
-
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) {
|
|
4256
4179
|
const { projection, binding, replyContract } = definition;
|
|
4257
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`);
|
|
4258
4181
|
if (config.instructionsOverride) throw new Error("the direct runner executes only the stock protocol; an instructions override requires the dspy-rlm runner");
|
|
@@ -4261,6 +4184,16 @@ function runChunkedAnalystDefinition(definition, config) {
|
|
|
4261
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}'`);
|
|
4262
4185
|
if (!replyContract.parseEnvelope) throw new AnalystExpressivenessError(`the one-shot JSON strategy needs a strict reply envelope; definition '${definition.id}' declares no parseEnvelope`);
|
|
4263
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);
|
|
4264
4197
|
const model = requiredString(config.model, "model");
|
|
4265
4198
|
const callRef = requiredString(config.callRef, "callRef");
|
|
4266
4199
|
if (typeof config.call !== "function") throw new TypeError("call must be a function");
|
|
@@ -4273,243 +4206,296 @@ function runChunkedAnalystDefinition(definition, config) {
|
|
|
4273
4206
|
maxOutputTokens,
|
|
4274
4207
|
maxCostUsd
|
|
4275
4208
|
});
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4209
|
+
return {
|
|
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")
|
|
4230
|
+
};
|
|
4231
|
+
}
|
|
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
|
+
});
|
|
4238
|
+
}
|
|
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
|
+
};
|
|
4255
|
+
}
|
|
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
|
|
4285
4433
|
} : void 0;
|
|
4286
|
-
const
|
|
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);
|
|
4287
4441
|
return {
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
role: "system",
|
|
4314
|
-
content: systemPrompt
|
|
4315
|
-
}, {
|
|
4316
|
-
role: "user",
|
|
4317
|
-
content: binding.userMessage(preparedContext)
|
|
4318
|
-
}],
|
|
4319
|
-
jsonMode: true,
|
|
4320
|
-
thinking: "disabled",
|
|
4321
|
-
maxTokens: maxOutputTokens,
|
|
4322
|
-
timeoutMs: modelRequestTimeoutMs
|
|
4323
|
-
};
|
|
4324
|
-
const cacheIdentity = durability ? {
|
|
4325
|
-
runIdentitySha256: durability.runIdentitySha256,
|
|
4326
|
-
caseId: context.caseId,
|
|
4327
|
-
repetition: context.repetition
|
|
4328
|
-
} : void 0;
|
|
4329
|
-
const callId = cacheIdentity ? publicBenchmarkCallId(cacheIdentity) : void 0;
|
|
4330
|
-
const cached = cacheIdentity ? readPublicBenchmarkResponseCache(durability.responseCacheDir, cacheIdentity) : void 0;
|
|
4331
|
-
if (cached) {
|
|
4332
|
-
const receipt = settleCachedResponse(costLedger, cached);
|
|
4333
|
-
modelMetadata = {
|
|
4334
|
-
...modelMetadata,
|
|
4335
|
-
responseSource: "durable-cache",
|
|
4336
|
-
cost: costReceiptMetadata(receipt)
|
|
4337
|
-
};
|
|
4338
|
-
if (cached.status === "failed") return {
|
|
4339
|
-
findings: [],
|
|
4340
|
-
usage: usageReceiptFromCostLedger(costLedger, {
|
|
4341
|
-
channel: "analyst",
|
|
4342
|
-
tags: costTags
|
|
4343
|
-
}),
|
|
4344
|
-
error: cached.error,
|
|
4345
|
-
metadata: modelMetadata
|
|
4346
|
-
};
|
|
4347
|
-
const response = decodeReplyRows(replyContract, cached.response);
|
|
4348
|
-
rawPredictions = response.rows;
|
|
4349
|
-
rejectedRows = response.rejected.map((entry) => entry.reason);
|
|
4350
|
-
providerModel = cached.metadata.providerModel;
|
|
4351
|
-
producedAt = cached.metadata.producedAt;
|
|
4352
|
-
modelMetadata = {
|
|
4353
|
-
...modelMetadata,
|
|
4354
|
-
...response.extras,
|
|
4355
|
-
providerModel: cached.metadata.providerModel,
|
|
4356
|
-
providerDurationMs: cached.metadata.providerDurationMs,
|
|
4357
|
-
finishReason: cached.metadata.finishReason
|
|
4358
|
-
};
|
|
4359
|
-
} else {
|
|
4360
|
-
assertNoSettledResponseWithoutCache(costLedger, callId);
|
|
4361
|
-
const providerCallId = callId ?? `analyst-benchmark-${randomUUID()}`;
|
|
4362
|
-
let modelProxy;
|
|
4363
|
-
const completed = await runWithCleanup({
|
|
4364
|
-
label: "public benchmark direct model resources",
|
|
4365
|
-
run: async () => {
|
|
4366
|
-
modelProxy = await startExternalOptimizerModelProxy({
|
|
4367
|
-
call: config.call,
|
|
4368
|
-
callRef,
|
|
4369
|
-
recordExecution: config.recordExecution,
|
|
4370
|
-
model,
|
|
4371
|
-
budget: {
|
|
4372
|
-
maxCostUsd,
|
|
4373
|
-
maxRequests: 1,
|
|
4374
|
-
maxRequestBytes: maxModelRequestBytes,
|
|
4375
|
-
maxResponseBytes: maxModelResponseBytes,
|
|
4376
|
-
maxOutputTokensPerRequest: maxOutputTokens,
|
|
4377
|
-
maxReasoningTokensPerRequest: maxReasoningTokens,
|
|
4378
|
-
pricing,
|
|
4379
|
-
requestTimeoutMs: modelRequestTimeoutMs
|
|
4380
|
-
},
|
|
4381
|
-
costLedger,
|
|
4382
|
-
channel: "analyst",
|
|
4383
|
-
phase: binding.costPhase,
|
|
4384
|
-
actor: binding.costActor,
|
|
4385
|
-
tags: costTags,
|
|
4386
|
-
callId: providerCallId,
|
|
4387
|
-
...context.signal ? { signal: context.signal } : {}
|
|
4388
|
-
});
|
|
4389
|
-
const llmOptions = {
|
|
4390
|
-
baseUrl: modelProxy.baseUrl,
|
|
4391
|
-
apiKey: modelProxy.apiKey,
|
|
4392
|
-
maximumAttempts: 1,
|
|
4393
|
-
jsonSchemaTransport: "json-object",
|
|
4394
|
-
jsonPayloadMode: "exact",
|
|
4395
|
-
thinking: "disabled"
|
|
4396
|
-
};
|
|
4397
|
-
try {
|
|
4398
|
-
const completed = await callLlmJson(request, {
|
|
4399
|
-
...llmOptions,
|
|
4400
|
-
...context.signal ? { signal: context.signal } : {},
|
|
4401
|
-
idempotencyKey: providerCallId
|
|
4402
|
-
});
|
|
4403
|
-
const response = decodeReplyRows(replyContract, completed.value);
|
|
4404
|
-
const responseProducedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4405
|
-
const receipt = requiredSettledReceipt(costLedger, providerCallId);
|
|
4406
|
-
if (cacheIdentity) writePublicBenchmarkResponseCache(durability.responseCacheDir, {
|
|
4407
|
-
kind: "agent-eval/public-benchmark-model-response",
|
|
4408
|
-
...cacheIdentity,
|
|
4409
|
-
callId: providerCallId,
|
|
4410
|
-
status: "succeeded",
|
|
4411
|
-
response: completed.value,
|
|
4412
|
-
metadata: {
|
|
4413
|
-
providerModel: completed.result.model,
|
|
4414
|
-
providerDurationMs: completed.result.durationMs,
|
|
4415
|
-
finishReason: completed.result.finishReason ?? null,
|
|
4416
|
-
producedAt: responseProducedAt
|
|
4417
|
-
},
|
|
4418
|
-
receipt: cacheReceiptInput(receipt)
|
|
4419
|
-
});
|
|
4420
|
-
modelProxy.assertExecutionComplete();
|
|
4421
|
-
return {
|
|
4422
|
-
...completed,
|
|
4423
|
-
response,
|
|
4424
|
-
producedAt: responseProducedAt,
|
|
4425
|
-
receipt
|
|
4426
|
-
};
|
|
4427
|
-
} catch (error) {
|
|
4428
|
-
const controlFailure = modelProxy.failures().find(isPaidCallControlError$1);
|
|
4429
|
-
if (controlFailure) throw controlFailure;
|
|
4430
|
-
const receipt = settledReceipt(costLedger, providerCallId);
|
|
4431
|
-
if (cacheIdentity) {
|
|
4432
|
-
if (receipt) writePublicBenchmarkResponseCache(durability.responseCacheDir, {
|
|
4433
|
-
kind: "agent-eval/public-benchmark-model-response",
|
|
4434
|
-
...cacheIdentity,
|
|
4435
|
-
callId: providerCallId,
|
|
4436
|
-
status: "failed",
|
|
4437
|
-
error: publicBenchmarkError(error, []),
|
|
4438
|
-
receipt: cacheReceiptInput(receipt)
|
|
4439
|
-
});
|
|
4440
|
-
}
|
|
4441
|
-
throw error;
|
|
4442
|
-
}
|
|
4443
|
-
},
|
|
4444
|
-
cleanup: async () => {
|
|
4445
|
-
await modelProxy?.close();
|
|
4446
|
-
}
|
|
4447
|
-
});
|
|
4448
|
-
const response = completed.response;
|
|
4449
|
-
rawPredictions = response.rows;
|
|
4450
|
-
rejectedRows = response.rejected.map((entry) => entry.reason);
|
|
4451
|
-
providerModel = completed.result.model;
|
|
4452
|
-
producedAt = completed.producedAt;
|
|
4453
|
-
modelMetadata = {
|
|
4454
|
-
...modelMetadata,
|
|
4455
|
-
responseSource: "provider",
|
|
4456
|
-
...response.extras,
|
|
4457
|
-
providerModel: completed.result.model,
|
|
4458
|
-
providerDurationMs: completed.result.durationMs,
|
|
4459
|
-
finishReason: completed.result.finishReason ?? null,
|
|
4460
|
-
cost: costReceiptMetadata(completed.receipt)
|
|
4461
|
-
};
|
|
4462
|
-
}
|
|
4463
|
-
const converted = await binding.expandRows({
|
|
4464
|
-
subject: trajectoryId,
|
|
4465
|
-
rows: rawPredictions,
|
|
4466
|
-
store: input.traceStore,
|
|
4467
|
-
analystId: definition.id,
|
|
4468
|
-
providerModel,
|
|
4469
|
-
producedAt: requiredString(producedAt ?? "", "finding producedAt"),
|
|
4470
|
-
...context.signal ? { signal: context.signal } : {}
|
|
4471
|
-
});
|
|
4472
|
-
modelFindings = converted.findings;
|
|
4473
|
-
if (converted.diagnostics) modelMetadata = {
|
|
4474
|
-
...modelMetadata,
|
|
4475
|
-
blockDiagnostics: {
|
|
4476
|
-
...converted.diagnostics,
|
|
4477
|
-
rejectedBlocks: rejectedRows
|
|
4478
|
-
}
|
|
4479
|
-
};
|
|
4480
|
-
if (binding.verifyFindings) await binding.verifyFindings({
|
|
4481
|
-
subject: trajectoryId,
|
|
4482
|
-
findings: modelFindings,
|
|
4483
|
-
store: input.traceStore,
|
|
4484
|
-
...context.signal ? { signal: context.signal } : {}
|
|
4485
|
-
});
|
|
4486
|
-
return {
|
|
4487
|
-
findings: modelFindings,
|
|
4488
|
-
usage: usageReceiptFromCostLedger(costLedger, {
|
|
4489
|
-
channel: "analyst",
|
|
4490
|
-
tags: costTags
|
|
4491
|
-
}),
|
|
4492
|
-
metadata: modelMetadata
|
|
4493
|
-
};
|
|
4494
|
-
} catch (error) {
|
|
4495
|
-
if (context.signal?.aborted) throw error;
|
|
4496
|
-
if (isPaidCallControlError$1(error)) throw error;
|
|
4497
|
-
return {
|
|
4498
|
-
findings: [],
|
|
4499
|
-
usage: usageReceiptFromCostLedger(costLedger, {
|
|
4500
|
-
channel: "analyst",
|
|
4501
|
-
tags: costTags
|
|
4502
|
-
}),
|
|
4503
|
-
error: publicBenchmarkError(error, []),
|
|
4504
|
-
metadata: {
|
|
4505
|
-
...modelMetadata,
|
|
4506
|
-
rawPredictions,
|
|
4507
|
-
acceptedFindings: modelFindings
|
|
4508
|
-
}
|
|
4509
|
-
};
|
|
4510
|
-
}
|
|
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
|
|
4511
4467
|
}
|
|
4512
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
|
+
};
|
|
4513
4499
|
}
|
|
4514
4500
|
/** A definition that declares one budget while the transport runs another is refused. */
|
|
4515
4501
|
function assertDeclaredBudget(definition, effective) {
|
|
@@ -4610,6 +4596,101 @@ function pricingForModel$2(model) {
|
|
|
4610
4596
|
outputUsdPerMillion: pricing.output * 1e3
|
|
4611
4597
|
};
|
|
4612
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
|
+
}
|
|
4613
4694
|
const ModelSeveritySchema = z.enum([
|
|
4614
4695
|
"critical",
|
|
4615
4696
|
"high",
|
|
@@ -4789,24 +4870,6 @@ async function publicBenchmarkPredictionsToFindings(options) {
|
|
|
4789
4870
|
...options.signal ? { signal: options.signal } : {}
|
|
4790
4871
|
});
|
|
4791
4872
|
}
|
|
4792
|
-
async function prepareSingleTraceContext(store, context, attributeByteCaps) {
|
|
4793
|
-
const storeContext = context.signal ? { signal: context.signal } : void 0;
|
|
4794
|
-
const overview = await store.getOverview(void 0, storeContext);
|
|
4795
|
-
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}`);
|
|
4796
|
-
const traceId = overview.sample_trace_ids[0];
|
|
4797
|
-
for (const perAttributeByteCap of attributeByteCaps) {
|
|
4798
|
-
const viewed = await store.viewTrace({
|
|
4799
|
-
trace_id: traceId,
|
|
4800
|
-
per_attribute_byte_cap: perAttributeByteCap
|
|
4801
|
-
}, storeContext);
|
|
4802
|
-
if (!viewed.spans) continue;
|
|
4803
|
-
return JSON.stringify({
|
|
4804
|
-
trace_id: traceId,
|
|
4805
|
-
per_attribute_byte_cap: perAttributeByteCap,
|
|
4806
|
-
spans: viewed.spans
|
|
4807
|
-
});
|
|
4808
|
-
}
|
|
4809
|
-
}
|
|
4810
4873
|
function trajectoryIdFromCaseId$2(dataset, caseId) {
|
|
4811
4874
|
const prefix = dataset === "agentrx" ? "agentrx:" : "codetrace:";
|
|
4812
4875
|
if (!caseId.startsWith(prefix) || caseId.length === prefix.length) throw new Error(`unexpected ${dataset} benchmark case id '${caseId}'`);
|
|
@@ -5072,13 +5135,8 @@ function rlmEngineLimits(config) {
|
|
|
5072
5135
|
maxOutputChars: config.dspyRlm?.maxOutputChars ?? 8e3
|
|
5073
5136
|
};
|
|
5074
5137
|
}
|
|
5075
|
-
/**
|
|
5076
|
-
|
|
5077
|
-
* the caller-owned model path. The question, instructions, tool group, and
|
|
5078
|
-
* iteration limits come from the definition; the engine, model proxy, sampling
|
|
5079
|
-
* loop, and abstention floor are transport machinery.
|
|
5080
|
-
*/
|
|
5081
|
-
function runReplVariableAnalystDefinition(definition, config) {
|
|
5138
|
+
/** Refuse a definition or transport the repl-variable strategy cannot execute exactly as declared. */
|
|
5139
|
+
function checkReplVariableDefinition(definition, config) {
|
|
5082
5140
|
const { projection, binding } = definition;
|
|
5083
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`);
|
|
5084
5142
|
const instructions = definition.taskDefinition;
|
|
@@ -5090,12 +5148,17 @@ function runReplVariableAnalystDefinition(definition, config) {
|
|
|
5090
5148
|
if (limits === void 0) throw new AnalystExpressivenessError(`the repl-variable strategy needs declared engine limits; definition '${definition.id}' declares none`);
|
|
5091
5149
|
const effectiveLimits = rlmEngineLimits(config);
|
|
5092
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`);
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
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({
|
|
5099
5162
|
call: config.call,
|
|
5100
5163
|
callRef: config.callRef,
|
|
5101
5164
|
recordExecution: config.recordExecution,
|
|
@@ -5116,7 +5179,15 @@ function runReplVariableAnalystDefinition(definition, config) {
|
|
|
5116
5179
|
...config.dspyRlm?.traceToolTimeoutMs === void 0 ? {} : { traceToolTimeoutMs: config.dspyRlm.traceToolTimeoutMs },
|
|
5117
5180
|
...config.dspyRlm?.runner ? { runner: config.dspyRlm.runner } : {}
|
|
5118
5181
|
});
|
|
5119
|
-
|
|
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));
|
|
5120
5191
|
const traceDefinition = {
|
|
5121
5192
|
id: binding.traceAnalystId,
|
|
5122
5193
|
description: definition.description,
|
|
@@ -5124,218 +5195,246 @@ function runReplVariableAnalystDefinition(definition, config) {
|
|
|
5124
5195
|
version: definition.version,
|
|
5125
5196
|
question: definition.question,
|
|
5126
5197
|
instructions,
|
|
5127
|
-
toolGroup
|
|
5198
|
+
toolGroup,
|
|
5128
5199
|
limits
|
|
5129
5200
|
};
|
|
5130
5201
|
const { instructionsOverride: _rlmOnlyOverride, ...directConfig } = config;
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
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
|
|
5134
5325
|
});
|
|
5135
5326
|
return {
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
const store = input.traceStore;
|
|
5149
|
-
const caseUsageFilter = {
|
|
5150
|
-
channel: "analyst",
|
|
5151
|
-
tags
|
|
5152
|
-
};
|
|
5153
|
-
const sampleRuns = [];
|
|
5154
|
-
const sampleAssignments = [];
|
|
5155
|
-
let totalModelCalls = 0;
|
|
5156
|
-
let totalToolCalls = 0;
|
|
5157
|
-
for (let sample = 0; sample < samples; sample += 1) {
|
|
5158
|
-
let sampleUsage;
|
|
5159
|
-
const completed = await runTraceAnalyst({
|
|
5160
|
-
definition: traceDefinition,
|
|
5161
|
-
engine,
|
|
5162
|
-
store,
|
|
5163
|
-
context: {
|
|
5164
|
-
runId: context.caseId,
|
|
5165
|
-
correlationId: `${context.caseId}:${context.repetition}:sample-${sample}`,
|
|
5166
|
-
costLedger,
|
|
5167
|
-
costPhase: binding.costPhase,
|
|
5168
|
-
tags,
|
|
5169
|
-
recordUsage: (receipt) => {
|
|
5170
|
-
sampleUsage = receipt;
|
|
5171
|
-
usage = usageReceiptFromCostLedger(costLedger, caseUsageFilter);
|
|
5172
|
-
},
|
|
5173
|
-
signal: context.signal
|
|
5174
|
-
}
|
|
5175
|
-
});
|
|
5176
|
-
const producedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5177
|
-
const sampleFindings = completed.findings.map((finding) => makeFinding({
|
|
5178
|
-
analyst_id: definition.id,
|
|
5179
|
-
area,
|
|
5180
|
-
subject: finding.subject,
|
|
5181
|
-
claim: finding.claim,
|
|
5182
|
-
rationale: finding.rationale,
|
|
5183
|
-
severity: finding.severity,
|
|
5184
|
-
confidence: finding.confidence,
|
|
5185
|
-
evidence_refs: evidenceRefsFromRawFinding(finding),
|
|
5186
|
-
recommended_action: finding.recommended_action,
|
|
5187
|
-
metadata: {
|
|
5188
|
-
...binding.findingBaseMetadata,
|
|
5189
|
-
model: config.model,
|
|
5190
|
-
sample,
|
|
5191
|
-
...binding.metadataFromSubject?.(finding.subject) ?? {}
|
|
5192
|
-
},
|
|
5193
|
-
produced_at: producedAt
|
|
5194
|
-
}));
|
|
5195
|
-
rawFindings = [...rawFindings, ...sampleFindings];
|
|
5196
|
-
const adapted = await binding.adapt({
|
|
5197
|
-
subject: trajectoryId,
|
|
5198
|
-
findings: sampleFindings,
|
|
5199
|
-
analystId: definition.id,
|
|
5200
|
-
store,
|
|
5201
|
-
...context.signal ? { signal: context.signal } : {}
|
|
5202
|
-
});
|
|
5203
|
-
const assignments = adapted.stepBlocks ?? [];
|
|
5204
|
-
sampleAssignments.push(assignments);
|
|
5205
|
-
totalModelCalls += completed.modelCalls;
|
|
5206
|
-
totalToolCalls += completed.toolCalls;
|
|
5207
|
-
sampleRuns.push({
|
|
5208
|
-
sample,
|
|
5209
|
-
answer: completed.answer,
|
|
5210
|
-
trajectory: completed.trajectory,
|
|
5211
|
-
modelCalls: completed.modelCalls,
|
|
5212
|
-
toolCalls: completed.toolCalls,
|
|
5213
|
-
runtime: completed.runtime,
|
|
5214
|
-
...binding.consensus.sampleRecord(assignments),
|
|
5215
|
-
...adapted.diagnostics ? { blockDiagnostics: adapted.diagnostics } : {},
|
|
5216
|
-
...sampleUsage ? { usage: sampleUsage } : {}
|
|
5217
|
-
});
|
|
5218
|
-
}
|
|
5219
|
-
const consensus = binding.consensus.vote(sampleAssignments);
|
|
5220
|
-
const expanded = await binding.consensus.expand({
|
|
5221
|
-
subject: trajectoryId,
|
|
5222
|
-
blocks: consensus.blocks,
|
|
5223
|
-
store,
|
|
5224
|
-
analystId: definition.id,
|
|
5225
|
-
producedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5226
|
-
...context.signal ? { signal: context.signal } : {}
|
|
5227
|
-
});
|
|
5228
|
-
let fallback;
|
|
5229
|
-
if (consensus.blocks.length === 0) fallback = await abstentionFallbackRunner.analyze(input, context);
|
|
5230
|
-
usage = usageReceiptFromCostLedger(costLedger, caseUsageFilter);
|
|
5231
|
-
return {
|
|
5232
|
-
findings: fallback && !fallback.error ? fallback.findings : expanded.findings,
|
|
5233
|
-
usage,
|
|
5234
|
-
metadata: {
|
|
5235
|
-
...binding.baseMetadata,
|
|
5236
|
-
protocolSha256,
|
|
5237
|
-
samples,
|
|
5238
|
-
sampleRuns,
|
|
5239
|
-
consensus: consensus.decision,
|
|
5240
|
-
blockDiagnostics: expanded.diagnostics,
|
|
5241
|
-
modelCalls: totalModelCalls,
|
|
5242
|
-
toolCalls: totalToolCalls,
|
|
5243
|
-
...fallback ? {
|
|
5244
|
-
abstentionFallback: "direct",
|
|
5245
|
-
...fallback.metadata ? { abstentionFallbackMetadata: fallback.metadata } : {},
|
|
5246
|
-
...fallback.error ? { abstentionFallbackError: fallback.error } : {}
|
|
5247
|
-
} : {}
|
|
5248
|
-
}
|
|
5249
|
-
};
|
|
5250
|
-
}
|
|
5251
|
-
const completed = await runTraceAnalyst({
|
|
5252
|
-
definition: traceDefinition,
|
|
5253
|
-
engine,
|
|
5254
|
-
store: input.traceStore,
|
|
5255
|
-
context: {
|
|
5256
|
-
runId: context.caseId,
|
|
5257
|
-
correlationId: `${context.caseId}:${context.repetition}`,
|
|
5258
|
-
costLedger,
|
|
5259
|
-
costPhase: binding.costPhase,
|
|
5260
|
-
tags,
|
|
5261
|
-
recordUsage: (receipt) => {
|
|
5262
|
-
usage = receipt;
|
|
5263
|
-
},
|
|
5264
|
-
signal: context.signal
|
|
5265
|
-
}
|
|
5266
|
-
});
|
|
5267
|
-
const producedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5268
|
-
rawFindings = completed.findings.map((finding) => makeFinding({
|
|
5269
|
-
analyst_id: definition.id,
|
|
5270
|
-
area,
|
|
5271
|
-
subject: finding.subject,
|
|
5272
|
-
claim: finding.claim,
|
|
5273
|
-
rationale: finding.rationale,
|
|
5274
|
-
severity: finding.severity,
|
|
5275
|
-
confidence: finding.confidence,
|
|
5276
|
-
evidence_refs: evidenceRefsFromRawFinding(finding),
|
|
5277
|
-
recommended_action: finding.recommended_action,
|
|
5278
|
-
metadata: {
|
|
5279
|
-
...binding.findingBaseMetadata,
|
|
5280
|
-
model: config.model,
|
|
5281
|
-
...binding.metadataFromSubject?.(finding.subject) ?? {}
|
|
5282
|
-
},
|
|
5283
|
-
produced_at: producedAt
|
|
5284
|
-
}));
|
|
5285
|
-
const adapted = await binding.adapt({
|
|
5286
|
-
subject: trajectoryId,
|
|
5287
|
-
findings: rawFindings,
|
|
5288
|
-
analystId: definition.id,
|
|
5289
|
-
store: input.traceStore,
|
|
5290
|
-
...context.signal ? { signal: context.signal } : {}
|
|
5291
|
-
});
|
|
5292
|
-
let fallback;
|
|
5293
|
-
if (completed.findings.length === 0) {
|
|
5294
|
-
fallback = await abstentionFallbackRunner.analyze(input, context);
|
|
5295
|
-
usage = usageReceiptFromCostLedger(costLedger, {
|
|
5296
|
-
channel: "analyst",
|
|
5297
|
-
tags: {
|
|
5298
|
-
benchmarkCaseId: context.caseId,
|
|
5299
|
-
benchmarkRepetition: String(context.repetition)
|
|
5300
|
-
}
|
|
5301
|
-
});
|
|
5302
|
-
}
|
|
5303
|
-
return {
|
|
5304
|
-
findings: fallback && !fallback.error ? fallback.findings : adapted.findings,
|
|
5305
|
-
usage,
|
|
5306
|
-
metadata: {
|
|
5307
|
-
...binding.baseMetadata,
|
|
5308
|
-
protocolSha256,
|
|
5309
|
-
...adapted.diagnostics ? { blockDiagnostics: adapted.diagnostics } : {},
|
|
5310
|
-
answer: completed.answer,
|
|
5311
|
-
trajectory: completed.trajectory,
|
|
5312
|
-
modelCalls: completed.modelCalls,
|
|
5313
|
-
toolCalls: completed.toolCalls,
|
|
5314
|
-
runtime: completed.runtime,
|
|
5315
|
-
...fallback ? {
|
|
5316
|
-
abstentionFallback: "direct",
|
|
5317
|
-
...fallback.metadata ? { abstentionFallbackMetadata: fallback.metadata } : {},
|
|
5318
|
-
...fallback.error ? { abstentionFallbackError: fallback.error } : {}
|
|
5319
|
-
} : {}
|
|
5320
|
-
}
|
|
5321
|
-
};
|
|
5322
|
-
} catch (error) {
|
|
5323
|
-
if (context.signal?.aborted) throw error;
|
|
5324
|
-
if (isPaidCallControlError(error)) throw error;
|
|
5325
|
-
return {
|
|
5326
|
-
findings: [],
|
|
5327
|
-
usage,
|
|
5328
|
-
error: publicBenchmarkError(error, []),
|
|
5329
|
-
metadata: {
|
|
5330
|
-
...binding.baseMetadata,
|
|
5331
|
-
...samples > 1 ? { samples } : {},
|
|
5332
|
-
rawFindings
|
|
5333
|
-
}
|
|
5334
|
-
};
|
|
5335
|
-
}
|
|
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)
|
|
5336
5339
|
}
|
|
5337
5340
|
};
|
|
5338
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)
|
|
5391
|
+
}
|
|
5392
|
+
};
|
|
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
|
+
}
|
|
5339
5438
|
/** Per-sample accepted blocks with the exact steps the expansion kept for each. */
|
|
5340
5439
|
function sampleBlockRecords(assignments) {
|
|
5341
5440
|
const stepsByBlock = /* @__PURE__ */ new Map();
|
|
@@ -6791,4 +6890,4 @@ function shellQuote(value) {
|
|
|
6791
6890
|
//#endregion
|
|
6792
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 };
|
|
6793
6892
|
|
|
6794
|
-
//# sourceMappingURL=benchmark-command-
|
|
6893
|
+
//# sourceMappingURL=benchmark-command-BzmMTnvC.js.map
|