@tangle-network/agent-eval 0.129.0 → 0.130.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 +21 -0
- package/README.md +2 -0
- package/dist/active-curriculum-C4mk67HP.js +214 -0
- package/dist/active-curriculum-C4mk67HP.js.map +1 -0
- package/dist/adversarial-smnADNFS.d.ts +21 -0
- package/dist/adversarial-smnADNFS.d.ts.map +1 -0
- package/dist/analyst/index.d.ts +81 -2872
- package/dist/analyst/index.d.ts.map +1 -0
- package/dist/analyst/index.js +319 -360
- package/dist/analyst/index.js.map +1 -1
- package/dist/analyst-BkTS3C58.d.ts +89 -0
- package/dist/analyst-BkTS3C58.d.ts.map +1 -0
- package/dist/analyst-LsnNpSkm.js +152 -0
- package/dist/analyst-LsnNpSkm.js.map +1 -0
- package/dist/analyze-runs-C1CavBMk.js +1067 -0
- package/dist/analyze-runs-C1CavBMk.js.map +1 -0
- package/dist/analyze-runs-FsgYCinh.d.ts +72 -0
- package/dist/analyze-runs-FsgYCinh.d.ts.map +1 -0
- package/dist/attribute-vocabulary-DLJ6303h.d.ts +54 -0
- package/dist/attribute-vocabulary-DLJ6303h.d.ts.map +1 -0
- package/dist/authenticity/index.d.ts +81 -79
- package/dist/authenticity/index.d.ts.map +1 -0
- package/dist/authenticity/index.js +209 -193
- package/dist/authenticity/index.js.map +1 -1
- package/dist/baseline-HsBvw_dk.js +550 -0
- package/dist/baseline-HsBvw_dk.js.map +1 -0
- package/dist/baseline-hG3K85h4.d.ts +125 -0
- package/dist/baseline-hG3K85h4.d.ts.map +1 -0
- package/dist/belief-state/index.d.ts +448 -1188
- package/dist/belief-state/index.d.ts.map +1 -0
- package/dist/belief-state/index.js +1617 -1709
- package/dist/belief-state/index.js.map +1 -1
- package/dist/benchmarks/index.d.ts +2 -891
- package/dist/benchmarks/index.js +2 -60
- package/dist/benchmarks-BJgDGkAD.js +754 -0
- package/dist/benchmarks-BJgDGkAD.js.map +1 -0
- package/dist/builder-eval/index.d.ts +150 -662
- package/dist/builder-eval/index.d.ts.map +1 -0
- package/dist/builder-eval/index.js +356 -345
- package/dist/builder-eval/index.js.map +1 -1
- package/dist/calibration-CNWWA6K8.js +94 -0
- package/dist/calibration-CNWWA6K8.js.map +1 -0
- package/dist/campaign/index.d.ts +5 -6381
- package/dist/campaign/index.js +3 -213
- package/dist/campaign-aKJt6emI.js +3886 -0
- package/dist/campaign-aKJt6emI.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +164 -175
- package/dist/cli.js.map +1 -1
- package/dist/client-C97NMzqi.d.ts +581 -0
- package/dist/client-C97NMzqi.d.ts.map +1 -0
- package/dist/client-CYzbdJOZ.js +637 -0
- package/dist/client-CYzbdJOZ.js.map +1 -0
- package/dist/code-agent-session-BjkMTQ7H.js +1390 -0
- package/dist/code-agent-session-BjkMTQ7H.js.map +1 -0
- package/dist/code-agent-session-DqqgOJaz.d.ts +143 -0
- package/dist/code-agent-session-DqqgOJaz.d.ts.map +1 -0
- package/dist/concurrency-DIxRZF_J.js +85 -0
- package/dist/concurrency-DIxRZF_J.js.map +1 -0
- package/dist/contract/index.d.ts +645 -5565
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +1730 -1938
- package/dist/contract/index.js.map +1 -1
- package/dist/control.d.ts +3 -1030
- package/dist/control.js +2 -33
- package/dist/cost-ledger-DIgQUFZZ.js +801 -0
- package/dist/cost-ledger-DIgQUFZZ.js.map +1 -0
- package/dist/cost-ledger-Dye6jCgg.d.ts +236 -0
- package/dist/cost-ledger-Dye6jCgg.d.ts.map +1 -0
- package/dist/dataset-BvtnC8Dc.d.ts +115 -0
- package/dist/dataset-BvtnC8Dc.d.ts.map +1 -0
- package/dist/default-registry-C-vFCSEc.js +2579 -0
- package/dist/default-registry-C-vFCSEc.js.map +1 -0
- package/dist/default-registry-CNPo-Vsb.d.ts +540 -0
- package/dist/default-registry-CNPo-Vsb.d.ts.map +1 -0
- package/dist/emitter-CPBAhxum.js +266 -0
- package/dist/emitter-CPBAhxum.js.map +1 -0
- package/dist/emitter-DGQGoLyj.d.ts +113 -0
- package/dist/emitter-DGQGoLyj.d.ts.map +1 -0
- package/dist/errors-8YnH8WlF.js +64 -0
- package/dist/errors-8YnH8WlF.js.map +1 -0
- package/dist/errors-CEk209JS.d.ts +76 -0
- package/dist/errors-CEk209JS.d.ts.map +1 -0
- package/dist/eval-campaign-DEm6c8ru.js +349 -0
- package/dist/eval-campaign-DEm6c8ru.js.map +1 -0
- package/dist/execution-tracks-CpgFPpS5.js +93 -0
- package/dist/execution-tracks-CpgFPpS5.js.map +1 -0
- package/dist/exporters-q9iL-2Jf.js +148 -0
- package/dist/exporters-q9iL-2Jf.js.map +1 -0
- package/dist/extract-usage-BrQ8mCLX.js +155 -0
- package/dist/extract-usage-BrQ8mCLX.js.map +1 -0
- package/dist/failure-cluster-CqcvCcdR.d.ts +59 -0
- package/dist/failure-cluster-CqcvCcdR.d.ts.map +1 -0
- package/dist/feedback-trajectory-CVaeREXV.d.ts +340 -0
- package/dist/feedback-trajectory-CVaeREXV.d.ts.map +1 -0
- package/dist/fuzz.d.ts +320 -646
- package/dist/fuzz.d.ts.map +1 -0
- package/dist/fuzz.js +670 -618
- package/dist/fuzz.js.map +1 -1
- package/dist/hf-dataset-DBJXXoY1.js +763 -0
- package/dist/hf-dataset-DBJXXoY1.js.map +1 -0
- package/dist/hosted/index.d.ts +11 -831
- package/dist/hosted/index.d.ts.map +1 -0
- package/dist/hosted/index.js +2 -37
- package/dist/index-2JJSA6-r2.d.ts +926 -0
- package/dist/index-2JJSA6-r2.d.ts.map +1 -0
- package/dist/index-6N0aYmpW.d.ts +217 -0
- package/dist/index-6N0aYmpW.d.ts.map +1 -0
- package/dist/index-BAvgST_9.d.ts +131 -0
- package/dist/index-BAvgST_9.d.ts.map +1 -0
- package/dist/index-BvnJuTGD.d.ts +68 -0
- package/dist/index-BvnJuTGD.d.ts.map +1 -0
- package/dist/index-C61Wi7yg.d.ts +547 -0
- package/dist/index-C61Wi7yg.d.ts.map +1 -0
- package/dist/index-CD_WZ_Xr.d.ts +2250 -0
- package/dist/index-CD_WZ_Xr.d.ts.map +1 -0
- package/dist/index-DSC51roc.d.ts +102 -0
- package/dist/index-DSC51roc.d.ts.map +1 -0
- package/dist/index-Em67JBjs.d.ts +335 -0
- package/dist/index-Em67JBjs.d.ts.map +1 -0
- package/dist/index.d.ts +3755 -15555
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11182 -11216
- package/dist/index.js.map +1 -1
- package/dist/integrity-BzRbCHzi.js +424 -0
- package/dist/integrity-BzRbCHzi.js.map +1 -0
- package/dist/integrity-rmVhXWA7.d.ts +61 -0
- package/dist/integrity-rmVhXWA7.d.ts.map +1 -0
- package/dist/judge-calibration-DFtEMlde.d.ts +146 -0
- package/dist/judge-calibration-DFtEMlde.d.ts.map +1 -0
- package/dist/ledger-core/index.d.ts +2 -0
- package/dist/ledger-core/index.js +2 -0
- package/dist/ledger-core-DtZz1RG0.js +388 -0
- package/dist/ledger-core-DtZz1RG0.js.map +1 -0
- package/dist/llm-client--GR4JbZE.js +687 -0
- package/dist/llm-client--GR4JbZE.js.map +1 -0
- package/dist/llm-client-B_nIBlYo.d.ts +290 -0
- package/dist/llm-client-B_nIBlYo.d.ts.map +1 -0
- package/dist/matrix/index.d.ts +3 -155
- package/dist/matrix/index.js +2 -8
- package/dist/matrix-BzQnu2S6.js +270 -0
- package/dist/matrix-BzQnu2S6.js.map +1 -0
- package/dist/meta-eval/index.d.ts +4 -1027
- package/dist/meta-eval/index.js +393 -390
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/metrics-C9YY1OcL.js +239 -0
- package/dist/metrics-C9YY1OcL.js.map +1 -0
- package/dist/mint-yN2M2eh0.js +201 -0
- package/dist/mint-yN2M2eh0.js.map +1 -0
- package/dist/multi-layer-verifier-BHY1gWAc.d.ts +138 -0
- package/dist/multi-layer-verifier-BHY1gWAc.d.ts.map +1 -0
- package/dist/multishot/index.d.ts +273 -480
- package/dist/multishot/index.d.ts.map +1 -0
- package/dist/multishot/index.js +595 -548
- package/dist/multishot/index.js.map +1 -1
- package/dist/off-policy-DvgzvtIx.js +220 -0
- package/dist/off-policy-DvgzvtIx.js.map +1 -0
- package/dist/off-policy-mskQw8Mb.d.ts +153 -0
- package/dist/off-policy-mskQw8Mb.d.ts.map +1 -0
- package/dist/openapi.json +1 -1
- package/dist/opencode-sqlite-BGrHeDu3.js +318 -0
- package/dist/opencode-sqlite-BGrHeDu3.js.map +1 -0
- package/dist/outcome-store-BYHIuO0e.d.ts +65 -0
- package/dist/outcome-store-BYHIuO0e.d.ts.map +1 -0
- package/dist/outcome-store-ChBKlTd_.js +75 -0
- package/dist/outcome-store-ChBKlTd_.js.map +1 -0
- package/dist/paired-arms-D9D0wXj2.js +260 -0
- package/dist/paired-arms-D9D0wXj2.js.map +1 -0
- package/dist/pipelines/index.d.ts +95 -532
- package/dist/pipelines/index.d.ts.map +1 -0
- package/dist/pipelines/index.js +497 -478
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pre-registration-DakwTRXk.js +96 -0
- package/dist/pre-registration-DakwTRXk.js.map +1 -0
- package/dist/propose-review-control-LhIWGzHl.js +1458 -0
- package/dist/propose-review-control-LhIWGzHl.js.map +1 -0
- package/dist/query-CJ_DX8vl.d.ts +28 -0
- package/dist/query-CJ_DX8vl.d.ts.map +1 -0
- package/dist/query-Di7eEQ79.js +83 -0
- package/dist/query-Di7eEQ79.js.map +1 -0
- package/dist/raw-provider-sink-BQd7mzyT.js +201 -0
- package/dist/raw-provider-sink-BQd7mzyT.js.map +1 -0
- package/dist/raw-provider-sink-BU29Sh8h.d.ts +134 -0
- package/dist/raw-provider-sink-BU29Sh8h.d.ts.map +1 -0
- package/dist/redact-7Aq1ukl-.js +107 -0
- package/dist/redact-7Aq1ukl-.js.map +1 -0
- package/dist/release-report-Cz9NKH39.js +603 -0
- package/dist/release-report-Cz9NKH39.js.map +1 -0
- package/dist/release-report-mvB2G4_J.d.ts +244 -0
- package/dist/release-report-mvB2G4_J.d.ts.map +1 -0
- package/dist/replay-GnyotH0J.js +1741 -0
- package/dist/replay-GnyotH0J.js.map +1 -0
- package/dist/replay-OoidtG1E.d.ts +749 -0
- package/dist/replay-OoidtG1E.d.ts.map +1 -0
- package/dist/reporting.d.ts +6 -1312
- package/dist/reporting.js +6 -51
- package/dist/researcher-CwTdwXG1.d.ts +314 -0
- package/dist/researcher-CwTdwXG1.d.ts.map +1 -0
- package/dist/reward-hacking-eAnOsynk.d.ts +224 -0
- package/dist/reward-hacking-eAnOsynk.d.ts.map +1 -0
- package/dist/reward-hacking-qipEpKvY.js +596 -0
- package/dist/reward-hacking-qipEpKvY.js.map +1 -0
- package/dist/reward-nw2xZGZG.js +137 -0
- package/dist/reward-nw2xZGZG.js.map +1 -0
- package/dist/rl.d.ts +760 -4010
- package/dist/rl.d.ts.map +1 -0
- package/dist/rl.js +2325 -1958
- package/dist/rl.js.map +1 -1
- package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
- package/dist/rollout/index.d.ts +3 -2087
- package/dist/rollout/index.js +8 -168
- package/dist/rollout-BOYjemfR.js +624 -0
- package/dist/rollout-BOYjemfR.js.map +1 -0
- package/dist/rubric-predictive-validity-B3xmbmS1.js +141 -0
- package/dist/rubric-predictive-validity-B3xmbmS1.js.map +1 -0
- package/dist/rubric-predictive-validity-Ku_clp_1.d.ts +74 -0
- package/dist/rubric-predictive-validity-Ku_clp_1.d.ts.map +1 -0
- package/dist/run-evidence-ClRX_8A9.d.ts +225 -0
- package/dist/run-evidence-ClRX_8A9.d.ts.map +1 -0
- package/dist/run-record-BuoE80Dq.js +467 -0
- package/dist/{chunk-56TAVBOK.js.map → run-record-BuoE80Dq.js.map} +1 -1
- package/dist/run-record-CnZu_gjl.d.ts +357 -0
- package/dist/run-record-CnZu_gjl.d.ts.map +1 -0
- package/dist/run-score-iEEAWiBY.js +41 -0
- package/dist/run-score-iEEAWiBY.js.map +1 -0
- package/dist/runtime-trajectory-1gyaTOoC.js +93 -0
- package/dist/runtime-trajectory-1gyaTOoC.js.map +1 -0
- package/dist/runtime-trajectory-BvSZcCHD.d.ts +50 -0
- package/dist/runtime-trajectory-BvSZcCHD.d.ts.map +1 -0
- package/dist/schema-BtVldJ3T.d.ts +206 -0
- package/dist/schema-BtVldJ3T.d.ts.map +1 -0
- package/dist/schema-C6DW4ZHR.js +821 -0
- package/dist/schema-C6DW4ZHR.js.map +1 -0
- package/dist/schema-CRhEY1SO.js +69 -0
- package/dist/schema-CRhEY1SO.js.map +1 -0
- package/dist/schema-Cef2cFmb.d.ts +408 -0
- package/dist/schema-Cef2cFmb.d.ts.map +1 -0
- package/dist/semantic-concept-judge-B6cWNJ2K.js +725 -0
- package/dist/semantic-concept-judge-B6cWNJ2K.js.map +1 -0
- package/dist/sequential-Br0mAPHA.js +148 -0
- package/dist/sequential-Br0mAPHA.js.map +1 -0
- package/dist/sequential-CYwq6Ff_.d.ts +141 -0
- package/dist/sequential-CYwq6Ff_.d.ts.map +1 -0
- package/dist/series-convergence-CjO2QdRW.js +43 -0
- package/dist/series-convergence-CjO2QdRW.js.map +1 -0
- package/dist/series-convergence-ofsqPWhs.d.ts +35 -0
- package/dist/series-convergence-ofsqPWhs.d.ts.map +1 -0
- package/dist/server-m5D9cvnG.js +1040 -0
- package/dist/server-m5D9cvnG.js.map +1 -0
- package/dist/skill-usage-C_pXm7lP.d.ts +534 -0
- package/dist/skill-usage-C_pXm7lP.d.ts.map +1 -0
- package/dist/skillopt-optimization-method-CUmHkGbI.js +7718 -0
- package/dist/skillopt-optimization-method-CUmHkGbI.js.map +1 -0
- package/dist/skillopt-optimization-method-CWKVTnks.d.ts +1740 -0
- package/dist/skillopt-optimization-method-CWKVTnks.d.ts.map +1 -0
- package/dist/statistics-Cmj6nynr.d.ts +514 -0
- package/dist/statistics-Cmj6nynr.d.ts.map +1 -0
- package/dist/statistics-CnnxdpOg.js +1437 -0
- package/dist/statistics-CnnxdpOg.js.map +1 -0
- package/dist/store-CT9YIIve.d.ts +117 -0
- package/dist/store-CT9YIIve.d.ts.map +1 -0
- package/dist/store-CxJry_cs.d.ts +229 -0
- package/dist/store-CxJry_cs.d.ts.map +1 -0
- package/dist/storyboard/index.d.ts +84 -203
- package/dist/storyboard/index.d.ts.map +1 -0
- package/dist/storyboard/index.js +609 -542
- package/dist/storyboard/index.js.map +1 -1
- package/dist/summary-report-BNs5nmXI.js +862 -0
- package/dist/summary-report-BNs5nmXI.js.map +1 -0
- package/dist/summary-report-Cj9gdw4i.d.ts +407 -0
- package/dist/summary-report-Cj9gdw4i.d.ts.map +1 -0
- package/dist/supervisor-run/index.d.ts +2 -959
- package/dist/supervisor-run/index.js +2 -65
- package/dist/supervisor-run-_lnTLM3z.js +1679 -0
- package/dist/supervisor-run-_lnTLM3z.js.map +1 -0
- package/dist/task-failure-attributes-CQZlB3et.js +311 -0
- package/dist/task-failure-attributes-CQZlB3et.js.map +1 -0
- package/dist/test-graded-scenario-BsqWLmPt.js +318 -0
- package/dist/test-graded-scenario-BsqWLmPt.js.map +1 -0
- package/dist/test-graded-scenario-D1TaI2va.d.ts +141 -0
- package/dist/test-graded-scenario-D1TaI2va.d.ts.map +1 -0
- package/dist/tools-BmuN627J.js +1085 -0
- package/dist/tools-BmuN627J.js.map +1 -0
- package/dist/trace-attributes.d.ts +2 -52
- package/dist/trace-attributes.js +131 -61
- package/dist/trace-attributes.js.map +1 -1
- package/dist/traces.d.ts +12 -2365
- package/dist/traces.js +12 -252
- package/dist/trajectory-D_7rLrvE.js +56 -0
- package/dist/trajectory-D_7rLrvE.js.map +1 -0
- package/dist/types-DGsxbAEd.d.ts +387 -0
- package/dist/types-DGsxbAEd.d.ts.map +1 -0
- package/dist/types-k9tZGKUg.d.ts +640 -0
- package/dist/types-k9tZGKUg.d.ts.map +1 -0
- package/dist/verdict-Dps8_okt.d.ts +37 -0
- package/dist/verdict-Dps8_okt.d.ts.map +1 -0
- package/dist/wire/index.d.ts +702 -1173
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +2 -81
- package/docs/campaign-proposers.md +1 -0
- package/package.json +17 -9
- package/dist/benchmarks/index.js.map +0 -1
- package/dist/campaign/index.js.map +0 -1
- package/dist/chunk-2QU3YOPR.js +0 -7374
- package/dist/chunk-2QU3YOPR.js.map +0 -1
- package/dist/chunk-3OCR4R5I.js +0 -728
- package/dist/chunk-3OCR4R5I.js.map +0 -1
- package/dist/chunk-3RF76KTD.js +0 -84
- package/dist/chunk-3RF76KTD.js.map +0 -1
- package/dist/chunk-56TAVBOK.js +0 -698
- package/dist/chunk-5DTSBUL2.js +0 -159
- package/dist/chunk-5DTSBUL2.js.map +0 -1
- package/dist/chunk-7FO3TNPI.js +0 -232
- package/dist/chunk-7FO3TNPI.js.map +0 -1
- package/dist/chunk-7ZZMD7UK.js +0 -386
- package/dist/chunk-7ZZMD7UK.js.map +0 -1
- package/dist/chunk-BOD4O7OF.js +0 -40
- package/dist/chunk-BOD4O7OF.js.map +0 -1
- package/dist/chunk-BSO5JDQH.js +0 -2335
- package/dist/chunk-BSO5JDQH.js.map +0 -1
- package/dist/chunk-C6LXANRU.js +0 -1550
- package/dist/chunk-C6LXANRU.js.map +0 -1
- package/dist/chunk-DODXQREJ.js +0 -752
- package/dist/chunk-DODXQREJ.js.map +0 -1
- package/dist/chunk-DRYIUNWY.js +0 -622
- package/dist/chunk-DRYIUNWY.js.map +0 -1
- package/dist/chunk-E7QXT7SX.js +0 -183
- package/dist/chunk-E7QXT7SX.js.map +0 -1
- package/dist/chunk-EG66UGL4.js +0 -341
- package/dist/chunk-EG66UGL4.js.map +0 -1
- package/dist/chunk-FXTVJPYD.js +0 -576
- package/dist/chunk-FXTVJPYD.js.map +0 -1
- package/dist/chunk-G7MGMCZD.js +0 -153
- package/dist/chunk-G7MGMCZD.js.map +0 -1
- package/dist/chunk-GGE4NNQT.js +0 -65
- package/dist/chunk-GGE4NNQT.js.map +0 -1
- package/dist/chunk-H23X7XKK.js +0 -181
- package/dist/chunk-H23X7XKK.js.map +0 -1
- package/dist/chunk-HHWE3POT.js +0 -94
- package/dist/chunk-HHWE3POT.js.map +0 -1
- package/dist/chunk-HPWUNB47.js +0 -289
- package/dist/chunk-HPWUNB47.js.map +0 -1
- package/dist/chunk-IYCLP2N2.js +0 -766
- package/dist/chunk-IYCLP2N2.js.map +0 -1
- package/dist/chunk-JHCHEVET.js +0 -274
- package/dist/chunk-JHCHEVET.js.map +0 -1
- package/dist/chunk-JQSF5DQT.js +0 -701
- package/dist/chunk-JQSF5DQT.js.map +0 -1
- package/dist/chunk-K4DBDHLK.js +0 -158
- package/dist/chunk-K4DBDHLK.js.map +0 -1
- package/dist/chunk-K6N6XJJX.js +0 -306
- package/dist/chunk-K6N6XJJX.js.map +0 -1
- package/dist/chunk-M4YBQKIJ.js +0 -1040
- package/dist/chunk-M4YBQKIJ.js.map +0 -1
- package/dist/chunk-MA6HLL3S.js +0 -65
- package/dist/chunk-MA6HLL3S.js.map +0 -1
- package/dist/chunk-MAZ26DC7.js +0 -99
- package/dist/chunk-MAZ26DC7.js.map +0 -1
- package/dist/chunk-NPCTHQIO.js +0 -91
- package/dist/chunk-NPCTHQIO.js.map +0 -1
- package/dist/chunk-NY44NC4A.js +0 -1056
- package/dist/chunk-NY44NC4A.js.map +0 -1
- package/dist/chunk-OIUOT4QD.js +0 -44
- package/dist/chunk-OIUOT4QD.js.map +0 -1
- package/dist/chunk-ONWEPEDO.js +0 -57
- package/dist/chunk-ONWEPEDO.js.map +0 -1
- package/dist/chunk-OWN5NPMC.js +0 -152
- package/dist/chunk-OWN5NPMC.js.map +0 -1
- package/dist/chunk-P6FYH6K4.js +0 -1161
- package/dist/chunk-P6FYH6K4.js.map +0 -1
- package/dist/chunk-PC4UYEBM.js +0 -166
- package/dist/chunk-PC4UYEBM.js.map +0 -1
- package/dist/chunk-PC5DOSM7.js +0 -579
- package/dist/chunk-PC5DOSM7.js.map +0 -1
- package/dist/chunk-PXE2VKMX.js +0 -140
- package/dist/chunk-PXE2VKMX.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-QB6BDBP2.js +0 -4464
- package/dist/chunk-QB6BDBP2.js.map +0 -1
- package/dist/chunk-RXHCETDZ.js +0 -536
- package/dist/chunk-RXHCETDZ.js.map +0 -1
- package/dist/chunk-RZTMDUO7.js +0 -49
- package/dist/chunk-RZTMDUO7.js.map +0 -1
- package/dist/chunk-SFLLL76A.js +0 -669
- package/dist/chunk-SFLLL76A.js.map +0 -1
- package/dist/chunk-SZLVEKMJ.js +0 -1446
- package/dist/chunk-SZLVEKMJ.js.map +0 -1
- package/dist/chunk-T4SQEITX.js +0 -95
- package/dist/chunk-T4SQEITX.js.map +0 -1
- package/dist/chunk-T6RLYGAD.js +0 -158
- package/dist/chunk-T6RLYGAD.js.map +0 -1
- package/dist/chunk-TJVT4QFF.js +0 -911
- package/dist/chunk-TJVT4QFF.js.map +0 -1
- package/dist/chunk-TQ7LNKZ3.js +0 -136
- package/dist/chunk-TQ7LNKZ3.js.map +0 -1
- package/dist/chunk-U4L7JRPZ.js +0 -1706
- package/dist/chunk-U4L7JRPZ.js.map +0 -1
- package/dist/chunk-U4PHLT2N.js +0 -419
- package/dist/chunk-U4PHLT2N.js.map +0 -1
- package/dist/chunk-VCZ5FQYW.js +0 -928
- package/dist/chunk-VCZ5FQYW.js.map +0 -1
- package/dist/chunk-VI2UW6B6.js +0 -162
- package/dist/chunk-VI2UW6B6.js.map +0 -1
- package/dist/chunk-VQMK5FMP.js +0 -247
- package/dist/chunk-VQMK5FMP.js.map +0 -1
- package/dist/chunk-WGXIEX7P.js +0 -116
- package/dist/chunk-WGXIEX7P.js.map +0 -1
- package/dist/chunk-WVATSFCP.js +0 -1553
- package/dist/chunk-WVATSFCP.js.map +0 -1
- package/dist/chunk-X4YIBDER.js +0 -1662
- package/dist/chunk-X4YIBDER.js.map +0 -1
- package/dist/chunk-YQN4ICPP.js +0 -355
- package/dist/chunk-YQN4ICPP.js.map +0 -1
- package/dist/chunk-ZET2UAYW.js +0 -89
- package/dist/chunk-ZET2UAYW.js.map +0 -1
- package/dist/chunk-ZHTZ4EYI.js +0 -1212
- package/dist/chunk-ZHTZ4EYI.js.map +0 -1
- package/dist/control.js.map +0 -1
- package/dist/hosted/index.js.map +0 -1
- package/dist/matrix/index.js.map +0 -1
- package/dist/reporting.js.map +0 -1
- package/dist/rollout/index.js.map +0 -1
- package/dist/run-campaign-OJJ7CZF4.js +0 -18
- package/dist/run-campaign-OJJ7CZF4.js.map +0 -1
- package/dist/supervisor-run/index.js.map +0 -1
- package/dist/traces.js.map +0 -1
- package/dist/wire/index.js.map +0 -1
package/dist/chunk-G7MGMCZD.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
observedScore
|
|
3
|
-
} from "./chunk-OIUOT4QD.js";
|
|
4
|
-
|
|
5
|
-
// src/rl/active-curriculum.ts
|
|
6
|
-
function varianceBasedCurriculum(observations, candidateCells, opts) {
|
|
7
|
-
const variancePrior = opts.variancePrior ?? 0.05;
|
|
8
|
-
const floor = opts.floorPerCell ?? 1;
|
|
9
|
-
const budget = opts.budget;
|
|
10
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
11
|
-
for (const o of observations) {
|
|
12
|
-
const k = `${o.variantId}::${o.scenarioId}`;
|
|
13
|
-
const arr = grouped.get(k) ?? [];
|
|
14
|
-
arr.push(o.score);
|
|
15
|
-
grouped.set(k, arr);
|
|
16
|
-
}
|
|
17
|
-
const cellStats = candidateCells.map((c) => {
|
|
18
|
-
const k = `${c.variantId}::${c.scenarioId}`;
|
|
19
|
-
const samples = grouped.get(k) ?? [];
|
|
20
|
-
const n = samples.length;
|
|
21
|
-
const mean = n === 0 ? 0.5 : samples.reduce((s, v) => s + v, 0) / n;
|
|
22
|
-
const variance = n < 2 ? variancePrior : samples.reduce((s, v) => s + (v - mean) ** 2, 0) / (n - 1) + variancePrior;
|
|
23
|
-
const weight = Math.sqrt(variance) + 1 / Math.sqrt(Math.max(1, n));
|
|
24
|
-
return { variantId: c.variantId, scenarioId: c.scenarioId, n, mean, variance, weight };
|
|
25
|
-
});
|
|
26
|
-
const floorTotal = floor * cellStats.length;
|
|
27
|
-
if (floorTotal >= budget) {
|
|
28
|
-
const each = Math.max(1, Math.floor(budget / Math.max(1, cellStats.length)));
|
|
29
|
-
return cellStats.map((c) => ({
|
|
30
|
-
variantId: c.variantId,
|
|
31
|
-
scenarioId: c.scenarioId,
|
|
32
|
-
count: each,
|
|
33
|
-
reason: `floor allocation (budget tight; n=${c.n})`
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
const remaining = budget - floorTotal;
|
|
37
|
-
const totalWeight = cellStats.reduce((s, c) => s + c.weight, 0);
|
|
38
|
-
return cellStats.map((c) => {
|
|
39
|
-
const proportional = totalWeight === 0 ? 0 : Math.round(c.weight / totalWeight * remaining);
|
|
40
|
-
return {
|
|
41
|
-
variantId: c.variantId,
|
|
42
|
-
scenarioId: c.scenarioId,
|
|
43
|
-
count: floor + proportional,
|
|
44
|
-
reason: `variance ${c.variance.toFixed(3)} (n=${c.n}, mean=${c.mean.toFixed(3)})`
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function thompsonCurriculum(observations, candidateCells, opts) {
|
|
49
|
-
const threshold = opts.decisionThreshold ?? 0.5;
|
|
50
|
-
const alpha0 = opts.priorAlpha ?? 1;
|
|
51
|
-
const beta0 = opts.priorBeta ?? 1;
|
|
52
|
-
const rng = makeRng(opts.seed);
|
|
53
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
54
|
-
for (const o of observations) {
|
|
55
|
-
const k = `${o.variantId}::${o.scenarioId}`;
|
|
56
|
-
const cur = grouped.get(k) ?? { passes: 0, failures: 0 };
|
|
57
|
-
const pass = o.pass ?? o.score >= threshold;
|
|
58
|
-
if (pass) cur.passes += 1;
|
|
59
|
-
else cur.failures += 1;
|
|
60
|
-
grouped.set(k, cur);
|
|
61
|
-
}
|
|
62
|
-
const stats = candidateCells.map((c) => {
|
|
63
|
-
const k = `${c.variantId}::${c.scenarioId}`;
|
|
64
|
-
const cur = grouped.get(k) ?? { passes: 0, failures: 0 };
|
|
65
|
-
const a = alpha0 + cur.passes;
|
|
66
|
-
const b = beta0 + cur.failures;
|
|
67
|
-
const sampled = sampleBeta(a, b, rng);
|
|
68
|
-
const distance = Math.abs(sampled - threshold);
|
|
69
|
-
const variance = a * b / ((a + b) ** 2 * (a + b + 1));
|
|
70
|
-
const sigma = Math.max(0.05, Math.sqrt(variance));
|
|
71
|
-
const weight = Math.exp(-((distance / sigma) ** 2));
|
|
72
|
-
return {
|
|
73
|
-
variantId: c.variantId,
|
|
74
|
-
scenarioId: c.scenarioId,
|
|
75
|
-
n: cur.passes + cur.failures,
|
|
76
|
-
sampled,
|
|
77
|
-
sigma,
|
|
78
|
-
weight,
|
|
79
|
-
a,
|
|
80
|
-
b
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
const totalWeight = stats.reduce((s, c) => s + c.weight, 0);
|
|
84
|
-
return stats.map((c) => {
|
|
85
|
-
const proportional = totalWeight === 0 ? 0 : Math.round(c.weight / totalWeight * opts.budget);
|
|
86
|
-
return {
|
|
87
|
-
variantId: c.variantId,
|
|
88
|
-
scenarioId: c.scenarioId,
|
|
89
|
-
count: Math.max(0, proportional),
|
|
90
|
-
reason: `Beta(${c.a.toFixed(1)},${c.b.toFixed(1)}) sample=${c.sampled.toFixed(3)} (target ${threshold})`
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function observationsFromRunRecords(runs, opts = {}) {
|
|
95
|
-
const threshold = opts.passThreshold ?? 0.5;
|
|
96
|
-
const useHoldout = opts.useHoldout ?? true;
|
|
97
|
-
const out = [];
|
|
98
|
-
for (const r of runs) {
|
|
99
|
-
if (!r.scenarioId) continue;
|
|
100
|
-
const score = observedScore(r, useHoldout ? "holdout" : "search");
|
|
101
|
-
if (typeof score !== "number" || !Number.isFinite(score)) continue;
|
|
102
|
-
out.push({
|
|
103
|
-
variantId: r.candidateId,
|
|
104
|
-
scenarioId: r.scenarioId,
|
|
105
|
-
score,
|
|
106
|
-
pass: score >= threshold
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
return out;
|
|
110
|
-
}
|
|
111
|
-
function makeRng(seed) {
|
|
112
|
-
if (seed === void 0) return Math.random;
|
|
113
|
-
let s = seed >>> 0;
|
|
114
|
-
return () => {
|
|
115
|
-
s = s + 1831565813 >>> 0;
|
|
116
|
-
let t = s;
|
|
117
|
-
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
118
|
-
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
119
|
-
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function sampleBeta(alpha, beta, rng) {
|
|
123
|
-
const a = Math.max(1, alpha);
|
|
124
|
-
const b = Math.max(1, beta);
|
|
125
|
-
const x = sampleGamma(a, rng);
|
|
126
|
-
const y = sampleGamma(b, rng);
|
|
127
|
-
return x / (x + y);
|
|
128
|
-
}
|
|
129
|
-
function sampleGamma(shape, rng) {
|
|
130
|
-
const d = shape - 1 / 3;
|
|
131
|
-
const c = 1 / Math.sqrt(9 * d);
|
|
132
|
-
while (true) {
|
|
133
|
-
let x;
|
|
134
|
-
let v;
|
|
135
|
-
do {
|
|
136
|
-
const u1 = rng() || 1e-12;
|
|
137
|
-
const u2 = rng() || 1e-12;
|
|
138
|
-
x = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
|
|
139
|
-
v = 1 + c * x;
|
|
140
|
-
} while (v <= 0);
|
|
141
|
-
v = v * v * v;
|
|
142
|
-
const u = rng();
|
|
143
|
-
if (u < 1 - 0.0331 * x ** 4) return d * v;
|
|
144
|
-
if (Math.log(u) < 0.5 * x * x + d * (1 - v + Math.log(v))) return d * v;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export {
|
|
149
|
-
varianceBasedCurriculum,
|
|
150
|
-
thompsonCurriculum,
|
|
151
|
-
observationsFromRunRecords
|
|
152
|
-
};
|
|
153
|
-
//# sourceMappingURL=chunk-G7MGMCZD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rl/active-curriculum.ts"],"sourcesContent":["/**\n * Adaptive curriculum / active scenario selection.\n *\n * Fixed scenario sets waste sample budget on cells the policy already\n * passes (no information left) and cells the policy never passes (no\n * gradient available either). Active learning over scenarios fixes this\n * by allocating the next sample budget to cells where the policy's\n * outcome is *uncertain* — those carry the most decision-relevant signal.\n *\n * This module ships two complementary strategies:\n *\n * 1. **Variance-based** — score each (variant, scenario) cell by the\n * empirical variance of past observations. Allocate next-round budget\n * proportional to variance. Standard active-learning-by-uncertainty\n * heuristic; works well when the policy is non-deterministic and\n * cells differ in observation noise.\n *\n * 2. **Bandit-based (Thompson sampling)** — model each (variant,\n * scenario) cell as a Beta-Bernoulli arm; sample a posterior; pick\n * cells whose posterior mean is closest to the per-scenario decision\n * threshold. The right primitive when scenarios are\n * \"pass/fail\" rather than continuous, and when promotion gates fire\n * at a known threshold (e.g., 0.5).\n *\n * The output is a *next-round budget allocation* — a list of (variant,\n * scenario, count) triples. The consumer's matrix runner consumes the\n * allocation, runs those cells, feeds the new observations back. Loop.\n *\n * Out of scope (deliberate): scenario *generation* — that's the\n * adversarial primitive's job. This module allocates over an existing\n * scenario pool.\n */\n\nimport { observedScore } from '../rollout/reward'\nimport type { RunRecord } from '../run-record'\n\nexport interface CellObservation {\n variantId: string\n scenarioId: string\n /** Observed score in [0, 1]. */\n score: number\n /** For Bernoulli arms — derive from the score with a threshold if needed. */\n pass?: boolean\n}\n\nexport interface CurriculumAllocation {\n variantId: string\n scenarioId: string\n /** How many additional reps to run on this cell. */\n count: number\n /** Strategy-specific reason for the allocation. */\n reason: string\n}\n\nexport interface VarianceCurriculumOptions {\n /** Total reps to allocate across all cells. */\n budget: number\n /**\n * Smoothing prior on variance — keeps the allocator from concentrating\n * on a cell with one observation just because its 1-sample variance is\n * 0. Default 0.05.\n */\n variancePrior?: number\n /**\n * Minimum reps per cell — even when the variance estimate is low, give\n * every cell at least this many. Default 1.\n */\n floorPerCell?: number\n}\n\n/**\n * Variance-proportional allocation. For each cell, estimate variance from\n * past observations + a prior, then allocate the budget proportional to\n * (sqrt(variance) + 1/sqrt(n)) — a classical optimal-allocation rule\n * (Neyman 1934) that balances \"explore noisy cells\" with \"explore\n * under-sampled cells.\"\n */\nexport function varianceBasedCurriculum(\n observations: CellObservation[],\n candidateCells: Array<{ variantId: string; scenarioId: string }>,\n opts: VarianceCurriculumOptions,\n): CurriculumAllocation[] {\n const variancePrior = opts.variancePrior ?? 0.05\n const floor = opts.floorPerCell ?? 1\n const budget = opts.budget\n\n const grouped = new Map<string, number[]>()\n for (const o of observations) {\n const k = `${o.variantId}::${o.scenarioId}`\n const arr = grouped.get(k) ?? []\n arr.push(o.score)\n grouped.set(k, arr)\n }\n\n const cellStats = candidateCells.map((c) => {\n const k = `${c.variantId}::${c.scenarioId}`\n const samples = grouped.get(k) ?? []\n const n = samples.length\n const mean = n === 0 ? 0.5 : samples.reduce((s, v) => s + v, 0) / n\n const variance =\n n < 2\n ? variancePrior\n : samples.reduce((s, v) => s + (v - mean) ** 2, 0) / (n - 1) + variancePrior\n // Neyman optimal allocation: weight ∝ √variance; add √(1/n) to break\n // ties toward under-sampled cells.\n const weight = Math.sqrt(variance) + 1 / Math.sqrt(Math.max(1, n))\n return { variantId: c.variantId, scenarioId: c.scenarioId, n, mean, variance, weight }\n })\n\n // Reserve floor*N for the floor; allocate the rest proportional to weight.\n const floorTotal = floor * cellStats.length\n if (floorTotal >= budget) {\n const each = Math.max(1, Math.floor(budget / Math.max(1, cellStats.length)))\n return cellStats.map((c) => ({\n variantId: c.variantId,\n scenarioId: c.scenarioId,\n count: each,\n reason: `floor allocation (budget tight; n=${c.n})`,\n }))\n }\n const remaining = budget - floorTotal\n const totalWeight = cellStats.reduce((s, c) => s + c.weight, 0)\n return cellStats.map((c) => {\n const proportional = totalWeight === 0 ? 0 : Math.round((c.weight / totalWeight) * remaining)\n return {\n variantId: c.variantId,\n scenarioId: c.scenarioId,\n count: floor + proportional,\n reason: `variance ${c.variance.toFixed(3)} (n=${c.n}, mean=${c.mean.toFixed(3)})`,\n }\n })\n}\n\nexport interface ThompsonCurriculumOptions {\n budget: number\n /**\n * The per-scenario decision threshold. Cells whose posterior mean is\n * closest to this get the most budget — that's where the next observation\n * has the highest information value for the gate decision. Default 0.5.\n */\n decisionThreshold?: number\n /** Beta prior parameters. Default α=β=1 (uniform). */\n priorAlpha?: number\n priorBeta?: number\n /** Seed the Thompson sampler. Default unset (Math.random). */\n seed?: number\n}\n\n/**\n * Thompson-sampling-style allocation for pass/fail cells. For each cell:\n *\n * - Maintain Beta(α + passes, β + failures) posterior on pass-rate\n * - Allocation weight ∝ exp(-((sampledMean - threshold) / σ)^2):\n * cells whose sampled posterior straddles the decision boundary get\n * the most weight; cells already clearly above or below get less.\n *\n * This is the right primitive when promotion gates fire at a known\n * threshold and you want to sharpen the posterior near the boundary.\n */\nexport function thompsonCurriculum(\n observations: CellObservation[],\n candidateCells: Array<{ variantId: string; scenarioId: string }>,\n opts: ThompsonCurriculumOptions,\n): CurriculumAllocation[] {\n const threshold = opts.decisionThreshold ?? 0.5\n const alpha0 = opts.priorAlpha ?? 1\n const beta0 = opts.priorBeta ?? 1\n const rng = makeRng(opts.seed)\n\n const grouped = new Map<string, { passes: number; failures: number }>()\n for (const o of observations) {\n const k = `${o.variantId}::${o.scenarioId}`\n const cur = grouped.get(k) ?? { passes: 0, failures: 0 }\n const pass = o.pass ?? o.score >= threshold\n if (pass) cur.passes += 1\n else cur.failures += 1\n grouped.set(k, cur)\n }\n\n const stats = candidateCells.map((c) => {\n const k = `${c.variantId}::${c.scenarioId}`\n const cur = grouped.get(k) ?? { passes: 0, failures: 0 }\n const a = alpha0 + cur.passes\n const b = beta0 + cur.failures\n // Sample a single Beta draw — the Thompson signal.\n const sampled = sampleBeta(a, b, rng)\n const distance = Math.abs(sampled - threshold)\n // Information-near-threshold weight: closer = higher.\n // Use Gaussian-shaped kernel with σ tuned to posterior std.\n const variance = (a * b) / ((a + b) ** 2 * (a + b + 1))\n const sigma = Math.max(0.05, Math.sqrt(variance))\n const weight = Math.exp(-((distance / sigma) ** 2))\n return {\n variantId: c.variantId,\n scenarioId: c.scenarioId,\n n: cur.passes + cur.failures,\n sampled,\n sigma,\n weight,\n a,\n b,\n }\n })\n\n const totalWeight = stats.reduce((s, c) => s + c.weight, 0)\n return stats.map((c) => {\n const proportional = totalWeight === 0 ? 0 : Math.round((c.weight / totalWeight) * opts.budget)\n return {\n variantId: c.variantId,\n scenarioId: c.scenarioId,\n count: Math.max(0, proportional),\n reason: `Beta(${c.a.toFixed(1)},${c.b.toFixed(1)}) sample=${c.sampled.toFixed(3)} (target ${threshold})`,\n }\n })\n}\n\n/** Convenience: extract `CellObservation[]` directly from `RunRecord[]`. */\nexport function observationsFromRunRecords(\n runs: RunRecord[],\n opts: { passThreshold?: number; useHoldout?: boolean } = {},\n): CellObservation[] {\n const threshold = opts.passThreshold ?? 0.5\n const useHoldout = opts.useHoldout ?? true\n const out: CellObservation[] = []\n for (const r of runs) {\n if (!r.scenarioId) continue\n // Ungated on purpose, and the precedence is caller policy, not a default:\n // `useHoldout: false` means \"score this curriculum on the search split when\n // both exist\". This feeds sampling COUNTS, not an exported reward. Known\n // risk: a gamed run's high score inflates the cell's Beta posterior, so the\n // curriculum stops sampling a cell it wrongly believes is solved. The fix\n // for that is an upstream filter on gated records — zeroing the score here\n // would push the posterior the opposite way and be equally wrong.\n const score = observedScore(r, useHoldout ? 'holdout' : 'search')\n if (typeof score !== 'number' || !Number.isFinite(score)) continue\n out.push({\n variantId: r.candidateId,\n scenarioId: r.scenarioId,\n score,\n pass: score >= threshold,\n })\n }\n return out\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────\n\nfunction makeRng(seed?: number): () => number {\n if (seed === undefined) return Math.random\n let s = seed >>> 0\n return () => {\n s = (s + 0x6d2b79f5) >>> 0\n let t = s\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\n/**\n * Sample from Beta(α, β) via the Marsaglia–Tsang method using two Gamma\n * variates. Accuracy is good for α, β > 1; we floor the parameters at 1\n * to avoid degenerate cases.\n */\nfunction sampleBeta(alpha: number, beta: number, rng: () => number): number {\n const a = Math.max(1, alpha)\n const b = Math.max(1, beta)\n const x = sampleGamma(a, rng)\n const y = sampleGamma(b, rng)\n return x / (x + y)\n}\n\nfunction sampleGamma(shape: number, rng: () => number): number {\n // Marsaglia–Tsang for shape ≥ 1.\n const d = shape - 1 / 3\n const c = 1 / Math.sqrt(9 * d)\n while (true) {\n let x: number\n let v: number\n do {\n const u1 = rng() || 1e-12\n const u2 = rng() || 1e-12\n // Box-Muller for a normal sample.\n x = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2)\n v = 1 + c * x\n } while (v <= 0)\n v = v * v * v\n const u = rng()\n if (u < 1 - 0.0331 * x ** 4) return d * v\n if (Math.log(u) < 0.5 * x * x + d * (1 - v + Math.log(v))) return d * v\n }\n}\n"],"mappings":";;;;;AA6EO,SAAS,wBACd,cACA,gBACA,MACwB;AACxB,QAAM,gBAAgB,KAAK,iBAAiB;AAC5C,QAAM,QAAQ,KAAK,gBAAgB;AACnC,QAAM,SAAS,KAAK;AAEpB,QAAM,UAAU,oBAAI,IAAsB;AAC1C,aAAW,KAAK,cAAc;AAC5B,UAAM,IAAI,GAAG,EAAE,SAAS,KAAK,EAAE,UAAU;AACzC,UAAM,MAAM,QAAQ,IAAI,CAAC,KAAK,CAAC;AA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[ -]*?){13,16}\b/g },
|
|
6
|
-
{ id: "phone-us", pattern: /\b(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g },
|
|
7
|
-
{ id: "ipv4", pattern: /\b(?:\d{1,3}\.){3}\d{1,3}\b/g },
|
|
8
|
-
{ id: "aws-access-key", pattern: /\bAKIA[0-9A-Z]{16}\b/g },
|
|
9
|
-
{ id: "bearer", pattern: /\bBearer\s+[A-Za-z0-9._~+/=-]{10,}/gi },
|
|
10
|
-
{ id: "sk-key", pattern: /\bsk-[A-Za-z0-9_-]{10,}\b/g },
|
|
11
|
-
{
|
|
12
|
-
id: "private-key-block",
|
|
13
|
-
pattern: /-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----[\s\S]*?-----END[^-]*-----/g
|
|
14
|
-
}
|
|
15
|
-
];
|
|
16
|
-
var REDACTION_VERSION = "1.0.0";
|
|
17
|
-
function redactString(input, rules = DEFAULT_REDACTION_RULES) {
|
|
18
|
-
const byRule = {};
|
|
19
|
-
let redactionCount = 0;
|
|
20
|
-
let output = input;
|
|
21
|
-
for (const rule of rules) {
|
|
22
|
-
let hits = 0;
|
|
23
|
-
output = output.replace(rule.pattern, () => {
|
|
24
|
-
hits++;
|
|
25
|
-
return rule.replacement ?? `[redacted:${rule.id}]`;
|
|
26
|
-
});
|
|
27
|
-
if (hits > 0) {
|
|
28
|
-
byRule[rule.id] = hits;
|
|
29
|
-
redactionCount += hits;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return { output, report: { redactionCount, byRule } };
|
|
33
|
-
}
|
|
34
|
-
function redactValue(value, rules = DEFAULT_REDACTION_RULES, report = { redactionCount: 0, byRule: {} }) {
|
|
35
|
-
if (typeof value === "string") {
|
|
36
|
-
const { output, report: r } = redactString(value, rules);
|
|
37
|
-
report.redactionCount += r.redactionCount;
|
|
38
|
-
for (const [k, v] of Object.entries(r.byRule)) {
|
|
39
|
-
report.byRule[k] = (report.byRule[k] ?? 0) + v;
|
|
40
|
-
}
|
|
41
|
-
return { value: output, report };
|
|
42
|
-
}
|
|
43
|
-
if (Array.isArray(value)) {
|
|
44
|
-
return {
|
|
45
|
-
value: value.map((v) => redactValue(v, rules, report).value),
|
|
46
|
-
report
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (value !== null && typeof value === "object") {
|
|
50
|
-
const next = {};
|
|
51
|
-
for (const [k, v] of Object.entries(value)) {
|
|
52
|
-
next[k] = redactValue(v, rules, report).value;
|
|
53
|
-
}
|
|
54
|
-
return { value: next, report };
|
|
55
|
-
}
|
|
56
|
-
return { value, report };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export {
|
|
60
|
-
DEFAULT_REDACTION_RULES,
|
|
61
|
-
REDACTION_VERSION,
|
|
62
|
-
redactString,
|
|
63
|
-
redactValue
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=chunk-GGE4NNQT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/trace/redact.ts"],"sourcesContent":["/**\n * Redaction — remove PII / secrets from trace payloads before persist.\n *\n * Pre-persistence rules mean raw traces in storage are already scrubbed.\n * Unredacted variants (for debugging / post-mortems) live in a separate\n * storage layer with stricter access controls; this module only covers\n * the default scrub-then-persist path.\n *\n * Rules compose: pass an array of `RedactionRule`, each is applied in\n * order. Strings that match get replaced with a tagged sentinel so the\n * eval framework can count how many redactions happened per run\n * (surfaced via `redaction_applied` events).\n */\n\nexport interface RedactionRule {\n id: string\n pattern: RegExp\n /** Replacement — e.g. '[PII:email]'. Defaults to `[redacted:{id}]`. */\n replacement?: string\n}\n\nexport interface RedactionReport {\n redactionCount: number\n byRule: Record<string, number>\n}\n\n/** OWASP / common-sense defaults — extend per-domain. */\nexport const DEFAULT_REDACTION_RULES: RedactionRule[] = [\n { id: 'email', pattern: /\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b/gi },\n { id: 'ssn', pattern: /\\b\\d{3}-\\d{2}-\\d{4}\\b/g },\n { id: 'credit-card', pattern: /\\b(?:\\d[ -]*?){13,16}\\b/g },\n { id: 'phone-us', pattern: /\\b(?:\\+?1[-.\\s]?)?\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}\\b/g },\n { id: 'ipv4', pattern: /\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b/g },\n { id: 'aws-access-key', pattern: /\\bAKIA[0-9A-Z]{16}\\b/g },\n { id: 'bearer', pattern: /\\bBearer\\s+[A-Za-z0-9._~+/=-]{10,}/gi },\n { id: 'sk-key', pattern: /\\bsk-[A-Za-z0-9_-]{10,}\\b/g },\n {\n id: 'private-key-block',\n pattern: /-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----[\\s\\S]*?-----END[^-]*-----/g,\n },\n]\n\nexport const REDACTION_VERSION = '1.0.0'\n\n/**\n * Redact a single string. Returns the new string and a per-rule count of\n * how many substitutions fired.\n */\nexport function redactString(\n input: string,\n rules: RedactionRule[] = DEFAULT_REDACTION_RULES,\n): { output: string; report: RedactionReport } {\n const byRule: Record<string, number> = {}\n let redactionCount = 0\n let output = input\n for (const rule of rules) {\n let hits = 0\n output = output.replace(rule.pattern, () => {\n hits++\n return rule.replacement ?? `[redacted:${rule.id}]`\n })\n if (hits > 0) {\n byRule[rule.id] = hits\n redactionCount += hits\n }\n }\n return { output, report: { redactionCount, byRule } }\n}\n\n/**\n * Walk a JSON-ish value applying `redactString` to every string leaf.\n * Arrays and plain objects are recursed; other types pass through\n * untouched. Circular references throw — traces should be tree-shaped.\n */\nexport function redactValue(\n value: unknown,\n rules: RedactionRule[] = DEFAULT_REDACTION_RULES,\n report: RedactionReport = { redactionCount: 0, byRule: {} },\n): { value: unknown; report: RedactionReport } {\n if (typeof value === 'string') {\n const { output, report: r } = redactString(value, rules)\n report.redactionCount += r.redactionCount\n for (const [k, v] of Object.entries(r.byRule)) {\n report.byRule[k] = (report.byRule[k] ?? 0) + v\n }\n return { value: output, report }\n }\n if (Array.isArray(value)) {\n return {\n value: value.map((v) => redactValue(v, rules, report).value),\n report,\n }\n }\n if (value !== null && typeof value === 'object') {\n const next: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(value)) {\n next[k] = redactValue(v, rules, report).value\n }\n return { value: next, report }\n }\n return { value, report }\n}\n"],"mappings":";AA2BO,IAAM,0BAA2C;AAAA,EACtD,EAAE,IAAI,SAAS,SAAS,8CAA8C;AAAA,EACtE,EAAE,IAAI,OAAO,SAAS,yBAAyB;AAAA,EAC/C,EAAE,IAAI,eAAe,SAAS,2BAA2B;AAAA,EACzD,EAAE,IAAI,YAAY,SAAS,2DAA2D;AAAA,EACtF,EAAE,IAAI,QAAQ,SAAS,+BAA+B;AAAA,EACtD,EAAE,IAAI,kBAAkB,SAAS,wBAAwB;AAAA,EACzD,EAAE,IAAI,UAAU,SAAS,uCAAuC;AAAA,EAChE,EAAE,IAAI,UAAU,SAAS,6BAA6B;AAAA,EACtD;AAAA,IACE,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;AAEO,IAAM,oBAAoB;AAM1B,SAAS,aACd,OACA,QAAyB,yBACoB;AAC7C,QAAM,SAAiC,CAAC;AACxC,MAAI,iBAAiB;AACrB,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACxB,QAAI,OAAO;AACX,aAAS,OAAO,QAAQ,KAAK,SAAS,MAAM;AAC1C;AACA,aAAO,KAAK,eAAe,aAAa,KAAK,EAAE;AAAA,IACjD,CAAC;AACD,QAAI,OAAO,GAAG;AACZ,aAAO,KAAK,EAAE,IAAI;AAClB,wBAAkB;AAAA,IACpB;AAAA,EACF;AACA,SAAO,EAAE,QAAQ,QAAQ,EAAE,gBAAgB,OAAO,EAAE;AACtD;AAOO,SAAS,YACd,OACA,QAAyB,yBACzB,SAA0B,EAAE,gBAAgB,GAAG,QAAQ,CAAC,EAAE,GACb;AAC7C,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,EAAE,QAAQ,QAAQ,EAAE,IAAI,aAAa,OAAO,KAAK;AACvD,WAAO,kBAAkB,EAAE;AAC3B,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,EAAE,MAAM,GAAG;AAC7C,aAAO,OAAO,CAAC,KAAK,OAAO,OAAO,CAAC,KAAK,KAAK;AAAA,IAC/C;AACA,WAAO,EAAE,OAAO,QAAQ,OAAO;AAAA,EACjC;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO;AAAA,MACL,OAAO,MAAM,IAAI,CAAC,MAAM,YAAY,GAAG,OAAO,MAAM,EAAE,KAAK;AAAA,MAC3D;AAAA,IACF;AAAA,EACF;AACA,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAC/C,UAAM,OAAgC,CAAC;AACvC,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,GAAG;AAC1C,WAAK,CAAC,IAAI,YAAY,GAAG,OAAO,MAAM,EAAE;AAAA,IAC1C;AACA,WAAO,EAAE,OAAO,MAAM,OAAO;AAAA,EAC/B;AACA,SAAO,EAAE,OAAO,OAAO;AACzB;","names":[]}
|
package/dist/chunk-H23X7XKK.js
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ROLLOUT_SCHEMA,
|
|
3
|
-
assertMinted
|
|
4
|
-
} from "./chunk-PC5DOSM7.js";
|
|
5
|
-
import {
|
|
6
|
-
buildTrajectory
|
|
7
|
-
} from "./chunk-RZTMDUO7.js";
|
|
8
|
-
import {
|
|
9
|
-
runTaskScore
|
|
10
|
-
} from "./chunk-56TAVBOK.js";
|
|
11
|
-
import {
|
|
12
|
-
rolloutRewardFields,
|
|
13
|
-
scoreOrigin
|
|
14
|
-
} from "./chunk-OIUOT4QD.js";
|
|
15
|
-
import {
|
|
16
|
-
ValidationError
|
|
17
|
-
} from "./chunk-ONWEPEDO.js";
|
|
18
|
-
|
|
19
|
-
// src/rollout/mint.ts
|
|
20
|
-
var asText = (v, scrub) => {
|
|
21
|
-
const s = typeof v === "string" ? v : JSON.stringify(v);
|
|
22
|
-
return scrub(s ?? "");
|
|
23
|
-
};
|
|
24
|
-
function projectStep(span, scrub) {
|
|
25
|
-
const base = {
|
|
26
|
-
kind: span.kind,
|
|
27
|
-
name: scrub(span.name),
|
|
28
|
-
status: span.status,
|
|
29
|
-
durationMs: span.endedAt !== void 0 ? span.endedAt - span.startedAt : void 0
|
|
30
|
-
};
|
|
31
|
-
if (span.kind === "llm") {
|
|
32
|
-
const llm = span;
|
|
33
|
-
const last = llm.messages[llm.messages.length - 1];
|
|
34
|
-
if (last) base.input = scrub(last.content);
|
|
35
|
-
if (llm.output !== void 0) base.output = scrub(llm.output);
|
|
36
|
-
} else if (span.kind === "tool") {
|
|
37
|
-
const tool = span;
|
|
38
|
-
base.input = asText(tool.args, scrub);
|
|
39
|
-
if (tool.result !== void 0) base.output = asText(tool.result, scrub);
|
|
40
|
-
}
|
|
41
|
-
return base;
|
|
42
|
-
}
|
|
43
|
-
function finalConversation(spans, scrub) {
|
|
44
|
-
const llms = spans.filter((s) => s.kind === "llm");
|
|
45
|
-
const last = llms[llms.length - 1];
|
|
46
|
-
if (!last) return [];
|
|
47
|
-
const messages = last.messages.map((m) => ({
|
|
48
|
-
role: m.role,
|
|
49
|
-
content: scrub(m.content)
|
|
50
|
-
}));
|
|
51
|
-
if (last.output !== void 0 && last.output !== "") {
|
|
52
|
-
messages.push({ role: "assistant", content: scrub(last.output) });
|
|
53
|
-
}
|
|
54
|
-
return messages;
|
|
55
|
-
}
|
|
56
|
-
var REWARD_SOURCE = {
|
|
57
|
-
holdout: "run-record/holdout-score",
|
|
58
|
-
search: "run-record/search-score",
|
|
59
|
-
unscored: "run-record/unscored"
|
|
60
|
-
};
|
|
61
|
-
function requireTaskScore(record) {
|
|
62
|
-
if (runTaskScore(record) === void 0) {
|
|
63
|
-
throw new ValidationError(`Cannot mint rollout for run ${record.runId}: task score is missing`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
var SPLIT_FROM_TAG = {
|
|
67
|
-
search: "search",
|
|
68
|
-
dev: "dev",
|
|
69
|
-
holdout: "holdout"
|
|
70
|
-
};
|
|
71
|
-
function mintLine(record, steps, messages, options, capturedAt, gap) {
|
|
72
|
-
requireTaskScore(record);
|
|
73
|
-
const rewardFields = rolloutRewardFields(record);
|
|
74
|
-
const uncaptured = record.costProvenance.kind === "uncaptured";
|
|
75
|
-
const terminalOutcome = record.terminalOutcome;
|
|
76
|
-
const isCompleted = terminalOutcome === "succeeded" || terminalOutcome === "failed";
|
|
77
|
-
const isTruncated = terminalOutcome === "cancelled" || terminalOutcome === "incomplete";
|
|
78
|
-
const terminalError = terminalOutcome === "failed" || terminalOutcome === "cancelled" || terminalOutcome === "incomplete" ? record.terminalFailureReason ?? `run ended ${terminalOutcome}` : null;
|
|
79
|
-
return assertMinted(
|
|
80
|
-
{
|
|
81
|
-
schema: ROLLOUT_SCHEMA,
|
|
82
|
-
rollout_id: record.runId,
|
|
83
|
-
parent_rollout_id: null,
|
|
84
|
-
run_id: record.runId,
|
|
85
|
-
experiment_id: record.experimentId,
|
|
86
|
-
candidate_id: record.candidateId,
|
|
87
|
-
generation: null,
|
|
88
|
-
candidate_index: null,
|
|
89
|
-
role: options.role ?? "agent",
|
|
90
|
-
task: {
|
|
91
|
-
suite: options.suite ?? record.experimentId,
|
|
92
|
-
instance_id: record.scenarioId,
|
|
93
|
-
split: SPLIT_FROM_TAG[record.splitTag],
|
|
94
|
-
seed: record.seed,
|
|
95
|
-
rep: 0
|
|
96
|
-
},
|
|
97
|
-
policy: {
|
|
98
|
-
harness: null,
|
|
99
|
-
harness_version: null,
|
|
100
|
-
model: record.model,
|
|
101
|
-
provider: null,
|
|
102
|
-
profile_commit: record.commitSha,
|
|
103
|
-
prompt_hash: record.promptHash,
|
|
104
|
-
config_hash: record.configHash,
|
|
105
|
-
agent_profile_cell_id: record.agentProfile?.cellId ?? null,
|
|
106
|
-
sampling: null
|
|
107
|
-
},
|
|
108
|
-
messages,
|
|
109
|
-
tool_defs: [],
|
|
110
|
-
...steps.length > 0 ? { steps } : {},
|
|
111
|
-
outcome: {
|
|
112
|
-
...rewardFields,
|
|
113
|
-
reward_source: REWARD_SOURCE[scoreOrigin(record)],
|
|
114
|
-
verdict: null,
|
|
115
|
-
// A verbatim bulk copy, deliberately UNFILTERED here. `outcome.raw`
|
|
116
|
-
// holds the per-layer verifier scores (`layer.*`) that the reward was
|
|
117
|
-
// derived from, so on a gated run this dict is the reward signal in
|
|
118
|
-
// component form — but filtering it at this call site is the pattern
|
|
119
|
-
// that has now leaked twice, because the next producer to write a
|
|
120
|
-
// reward-bearing field forgets. The gate is applied to the whole
|
|
121
|
-
// outcome once, in `assertMinted` below (`gateGamedOutcome`), which
|
|
122
|
-
// moves the block to `provenance.gated_evidence` when the run is gated
|
|
123
|
-
// and leaves it here untouched when it is not.
|
|
124
|
-
metrics: { ...record.outcome.raw },
|
|
125
|
-
is_completed: isCompleted,
|
|
126
|
-
is_truncated: isTruncated,
|
|
127
|
-
error: terminalError
|
|
128
|
-
},
|
|
129
|
-
cost: {
|
|
130
|
-
usd: uncaptured ? null : record.costUsd,
|
|
131
|
-
tokens_in: record.tokenUsage.input,
|
|
132
|
-
tokens_out: record.tokenUsage.output,
|
|
133
|
-
tokens_reasoning: record.tokenUsage.reasoning ?? null,
|
|
134
|
-
cache_read: record.tokenUsage.cached ?? null,
|
|
135
|
-
cache_write: record.tokenUsage.cacheWrite ?? null,
|
|
136
|
-
wall_s: Math.round(record.wallMs / 1e3)
|
|
137
|
-
},
|
|
138
|
-
artifacts: { patch_path: null, run_dir: null, transcript_ref: null },
|
|
139
|
-
provenance: {
|
|
140
|
-
captured_at: capturedAt,
|
|
141
|
-
capture: "mint",
|
|
142
|
-
...gap !== void 0 ? { gap } : {}
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
`minted rollout line for run ${record.runId}`
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
async function mintRolloutRows(records, store, options = {}) {
|
|
149
|
-
const scrub = options.scrub ?? ((t) => t);
|
|
150
|
-
const capturedAt = (options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
|
|
151
|
-
const rows = [];
|
|
152
|
-
const missingTraces = [];
|
|
153
|
-
for (const record of records) {
|
|
154
|
-
const trajectory = await buildTrajectory(store, record.runId);
|
|
155
|
-
if (trajectory.steps.length === 0) {
|
|
156
|
-
missingTraces.push(record.runId);
|
|
157
|
-
rows.push(
|
|
158
|
-
mintLine(record, [], [], options, capturedAt, "no trace spans recorded for this runId")
|
|
159
|
-
);
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
let steps = trajectory.steps.map((s) => projectStep(s.span, scrub));
|
|
163
|
-
if (options.maxSteps !== void 0 && steps.length > options.maxSteps) {
|
|
164
|
-
const head = Math.ceil(options.maxSteps / 2);
|
|
165
|
-
const tail = options.maxSteps - head;
|
|
166
|
-
steps = [...steps.slice(0, head), ...steps.slice(steps.length - tail)];
|
|
167
|
-
}
|
|
168
|
-
const conversation = finalConversation(
|
|
169
|
-
trajectory.steps.map((s) => s.span),
|
|
170
|
-
scrub
|
|
171
|
-
);
|
|
172
|
-
const gap = conversation.length === 0 ? "trace has no llm spans \u2014 no conversation to inline" : void 0;
|
|
173
|
-
rows.push(mintLine(record, steps, conversation, options, capturedAt, gap));
|
|
174
|
-
}
|
|
175
|
-
return { rows, missingTraces };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export {
|
|
179
|
-
mintRolloutRows
|
|
180
|
-
};
|
|
181
|
-
//# sourceMappingURL=chunk-H23X7XKK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/rollout/mint.ts"],"sourcesContent":["/**\n * Rollout minting — `tangle.rollout.v1` lines joined from the records the\n * substrate ALREADY keeps. There is no separate rollout store: a rollout\n * is the JOIN of a RunRecord (identity, provenance, cost, outcome) with\n * its trace (spans share `runId`), projected into the canonical line.\n *\n * Composition, not duplication:\n * - identity/provenance → `RunRecord` (candidateId, splitTag, agentProfile, hashes)\n * - step structure → `buildTrajectory` over the shared TraceStore\n * - preference-pair export → `feedbackTrajectoryToOptimizerRow` (feedback-trajectory.ts)\n * - PRM / reward-model → `reward-model-export.ts`\n *\n * Anti-Goodhart invariant: a run whose `outcome.realness.gated` is true is\n * never exported with a positive reward OR with any of the numbers that reward\n * was computed from. The gate travels into the training data (`reward` forced\n * to 0, `realness_gated: true`) and the whole outcome is transformed by\n * `gateGamedOutcome` inside `assertMinted` below, which relocates `metrics` and\n * `verdict` to `provenance.gated_evidence`. Mint returns\n * `MintedRolloutLine[]`: the brand the training exporters require, which only\n * this function, `readRolloutLedger`, and an explicit `assertMinted` can mint.\n *\n * A record carrying NEITHER split score is REJECTED (`ValidationError`), never\n * minted at 0 — \"nobody graded this\" is not the same claim as \"graded a total\n * failure\", and a trainer reading 0 learns the second. Lines that already\n * carry `reward: null` (interchange imports, existing ledgers) remain valid on\n * the wire; only the RunRecord→line door refuses.\n *\n * Records without spans become labeled GAP LINES (messages: [],\n * provenance.gap) — present in the output AND surfaced in\n * `missingTraces`; a capture gap is a finding, never a silent omission.\n */\n\nimport { ValidationError } from '../errors'\nimport { type RunRecord, runTaskScore } from '../run-record'\nimport type { LlmSpan, Message, Span, ToolSpan } from '../trace/schema'\nimport type { TraceStore } from '../trace/store'\nimport { buildTrajectory } from '../trajectory'\nimport { rolloutRewardFields, scoreOrigin } from './reward'\nimport {\n assertMinted,\n type ChatMessage,\n type MintedRolloutLine,\n ROLLOUT_SCHEMA,\n type RolloutRole,\n type RolloutSplit,\n type RolloutStep,\n} from './schema'\n\n/** Redactor applied to every exported string (secrets, PII). Identity by default. */\nexport type RolloutScrubber = (text: string) => string\n\nexport interface MintRolloutOptions {\n scrub?: RolloutScrubber\n /** Cap steps per line (longest runs first drop middle steps). Default: no cap. */\n maxSteps?: number\n /** Role recorded on every minted line. Default 'agent' (a solo eval run). */\n role?: RolloutRole\n /** Task suite label. Default: the record's `experimentId`. */\n suite?: string\n /** Injected clock for deterministic output. */\n now?: () => Date\n}\n\nexport interface MintRolloutResult {\n rows: MintedRolloutLine[]\n /** runIds that had a RunRecord but no spans — emitted as gap lines AND listed here. */\n missingTraces: string[]\n}\n\nconst asText = (v: unknown, scrub: RolloutScrubber): string => {\n const s = typeof v === 'string' ? v : JSON.stringify(v)\n return scrub(s ?? '')\n}\n\nfunction projectStep(span: Span, scrub: RolloutScrubber): RolloutStep {\n const base: RolloutStep = {\n kind: span.kind,\n name: scrub(span.name),\n status: span.status,\n durationMs: span.endedAt !== undefined ? span.endedAt - span.startedAt : undefined,\n }\n if (span.kind === 'llm') {\n const llm = span as LlmSpan\n const last = llm.messages[llm.messages.length - 1]\n if (last) base.input = scrub(last.content)\n if (llm.output !== undefined) base.output = scrub(llm.output)\n } else if (span.kind === 'tool') {\n const tool = span as ToolSpan\n base.input = asText(tool.args, scrub)\n if (tool.result !== undefined) base.output = asText(tool.result, scrub)\n }\n return base\n}\n\n/** The final llm span's history + output is the completed conversation. */\nfunction finalConversation(spans: Span[], scrub: RolloutScrubber): ChatMessage[] {\n const llms = spans.filter((s): s is LlmSpan => s.kind === 'llm')\n const last = llms[llms.length - 1]\n if (!last) return []\n const messages: ChatMessage[] = last.messages.map((m: Message) => ({\n role: m.role,\n content: scrub(m.content),\n }))\n if (last.output !== undefined && last.output !== '') {\n messages.push({ role: 'assistant', content: scrub(last.output) })\n }\n return messages\n}\n\n// The reward derivations live in the leaf module `./reward` so gate and\n// reporting code can import them without dragging in the trace store; they are\n// re-exported here because the derivations shipped from this path.\nexport {\n isRealnessGated,\n observedScore,\n observedSplitScore,\n type ScoreOrigin,\n type ScorePreference,\n scoreOrigin,\n trainingReward,\n trainingScore,\n} from './reward'\n\nconst REWARD_SOURCE: Record<ReturnType<typeof scoreOrigin>, string> = {\n holdout: 'run-record/holdout-score',\n search: 'run-record/search-score',\n unscored: 'run-record/unscored',\n}\n\n/**\n * The mint door refuses an execution-only record: a missing training label is\n * not a zero reward, and not a mintable line either. Lines that already carry\n * `reward: null` — interchange imports, existing ledgers — stay valid on the\n * wire and keep their labeled gap; this guard is only about the\n * RunRecord→line door, where the producer can still be told to go score the\n * run instead of shipping an unlabeled row.\n */\nfunction requireTaskScore(record: RunRecord): void {\n if (runTaskScore(record) === undefined) {\n throw new ValidationError(`Cannot mint rollout for run ${record.runId}: task score is missing`)\n }\n}\n\nconst SPLIT_FROM_TAG: Record<RunRecord['splitTag'], RolloutSplit> = {\n search: 'search',\n dev: 'dev',\n holdout: 'holdout',\n}\n\nfunction mintLine(\n record: RunRecord,\n steps: RolloutStep[],\n messages: ChatMessage[],\n options: MintRolloutOptions,\n capturedAt: string,\n gap?: string,\n): MintedRolloutLine {\n // A missing task score is refused before anything is built: an\n // execution-only record has no training label, and a missing label is\n // neither a zero reward nor a mintable row.\n requireTaskScore(record)\n // `reward` and `realness_gated` come out of one call, so neither door into\n // the waist can write one and forget the other.\n const rewardFields = rolloutRewardFields(record)\n const uncaptured = record.costProvenance.kind === 'uncaptured'\n const terminalOutcome = record.terminalOutcome\n const isCompleted = terminalOutcome === 'succeeded' || terminalOutcome === 'failed'\n const isTruncated = terminalOutcome === 'cancelled' || terminalOutcome === 'incomplete'\n const terminalError =\n terminalOutcome === 'failed' ||\n terminalOutcome === 'cancelled' ||\n terminalOutcome === 'incomplete'\n ? (record.terminalFailureReason ?? `run ended ${terminalOutcome}`)\n : null\n // `assertMinted` rather than a cast: mint is the producer the whole gate\n // rests on, so it proves the line it just built is valid instead of asserting\n // it by fiat. The brand is unforgeable precisely because nobody casts to it.\n return assertMinted(\n {\n schema: ROLLOUT_SCHEMA,\n rollout_id: record.runId,\n parent_rollout_id: null,\n run_id: record.runId,\n experiment_id: record.experimentId,\n candidate_id: record.candidateId,\n generation: null,\n candidate_index: null,\n role: options.role ?? 'agent',\n task: {\n suite: options.suite ?? record.experimentId,\n instance_id: record.scenarioId,\n split: SPLIT_FROM_TAG[record.splitTag],\n seed: record.seed,\n rep: 0,\n },\n policy: {\n harness: null,\n harness_version: null,\n model: record.model,\n provider: null,\n profile_commit: record.commitSha,\n prompt_hash: record.promptHash,\n config_hash: record.configHash,\n agent_profile_cell_id: record.agentProfile?.cellId ?? null,\n sampling: null,\n },\n messages,\n tool_defs: [],\n ...(steps.length > 0 ? { steps } : {}),\n outcome: {\n ...rewardFields,\n reward_source: REWARD_SOURCE[scoreOrigin(record)],\n verdict: null,\n // A verbatim bulk copy, deliberately UNFILTERED here. `outcome.raw`\n // holds the per-layer verifier scores (`layer.*`) that the reward was\n // derived from, so on a gated run this dict is the reward signal in\n // component form — but filtering it at this call site is the pattern\n // that has now leaked twice, because the next producer to write a\n // reward-bearing field forgets. The gate is applied to the whole\n // outcome once, in `assertMinted` below (`gateGamedOutcome`), which\n // moves the block to `provenance.gated_evidence` when the run is gated\n // and leaves it here untouched when it is not.\n metrics: { ...record.outcome.raw },\n is_completed: isCompleted,\n is_truncated: isTruncated,\n error: terminalError,\n },\n cost: {\n usd: uncaptured ? null : record.costUsd,\n tokens_in: record.tokenUsage.input,\n tokens_out: record.tokenUsage.output,\n tokens_reasoning: record.tokenUsage.reasoning ?? null,\n cache_read: record.tokenUsage.cached ?? null,\n cache_write: record.tokenUsage.cacheWrite ?? null,\n wall_s: Math.round(record.wallMs / 1000),\n },\n artifacts: { patch_path: null, run_dir: null, transcript_ref: null },\n provenance: {\n captured_at: capturedAt,\n capture: 'mint',\n ...(gap !== undefined ? { gap } : {}),\n },\n },\n `minted rollout line for run ${record.runId}`,\n )\n}\n\n/**\n * Join RunRecords with their traces into canonical rollout lines. Records\n * without spans are emitted as labeled gap lines and reported in\n * `missingTraces`. Execution-only records without a task score are rejected\n * because a missing training label is not a zero reward.\n */\nexport async function mintRolloutRows(\n records: RunRecord[],\n store: TraceStore,\n options: MintRolloutOptions = {},\n): Promise<MintRolloutResult> {\n const scrub = options.scrub ?? ((t) => t)\n const capturedAt = (options.now?.() ?? new Date()).toISOString()\n const rows: MintedRolloutLine[] = []\n const missingTraces: string[] = []\n for (const record of records) {\n const trajectory = await buildTrajectory(store, record.runId)\n if (trajectory.steps.length === 0) {\n missingTraces.push(record.runId)\n rows.push(\n mintLine(record, [], [], options, capturedAt, 'no trace spans recorded for this runId'),\n )\n continue\n }\n let steps = trajectory.steps.map((s) => projectStep(s.span, scrub))\n if (options.maxSteps !== undefined && steps.length > options.maxSteps) {\n // Keep the head and tail — the middle of a long run is the least\n // informative for outcome attribution.\n const head = Math.ceil(options.maxSteps / 2)\n const tail = options.maxSteps - head\n steps = [...steps.slice(0, head), ...steps.slice(steps.length - tail)]\n }\n const conversation = finalConversation(\n trajectory.steps.map((s) => s.span),\n scrub,\n )\n const gap =\n conversation.length === 0 ? 'trace has no llm spans — no conversation to inline' : undefined\n rows.push(mintLine(record, steps, conversation, options, capturedAt, gap))\n }\n return { rows, missingTraces }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqEA,IAAM,SAAS,CAAC,GAAY,UAAmC;AAC7D,QAAM,IAAI,OAAO,MAAM,WAAW,IAAI,KAAK,UAAU,CAAC;AACtD,SAAO,MAAM,KAAK,EAAE;AACtB;AAEA,SAAS,YAAY,MAAY,OAAqC;AACpE,QAAM,OAAoB;AAAA,IACxB,MAAM,KAAK;AAAA,IACX,MAAM,MAAM,KAAK,IAAI;AAAA,IACrB,QAAQ,KAAK;AAAA,IACb,YAAY,KAAK,YAAY,SAAY,KAAK,UAAU,KAAK,YAAY;AAAA,EAC3E;AACA,MAAI,KAAK,SAAS,OAAO;AACvB,UAAM,MAAM;AACZ,UAAM,OAAO,IAAI,SAAS,IAAI,SAAS,SAAS,CAAC;AACjD,QAAI,KAAM,MAAK,QAAQ,MAAM,KAAK,OAAO;AACzC,QAAI,IAAI,WAAW,OAAW,MAAK,SAAS,MAAM,IAAI,MAAM;AAAA,EAC9D,WAAW,KAAK,SAAS,QAAQ;AAC/B,UAAM,OAAO;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QAAQ,OAAO,cAAc,SAAS,YAAY,GAAG,CAAC;AAAA,EAC3E;AACA,SAAO,EAAE,MAAM,cAAc;AAC/B;","names":[]}
|
package/dist/chunk-HHWE3POT.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// src/trace/execution-tracks.ts
|
|
2
|
-
function executionTrackByLane(lanes) {
|
|
3
|
-
const unique = /* @__PURE__ */ new Map();
|
|
4
|
-
for (const lane of lanes) {
|
|
5
|
-
const existing = unique.get(lane.key);
|
|
6
|
-
if (existing && !sameLane(existing, lane)) {
|
|
7
|
-
throw new Error(`execution lane '${lane.key}' has conflicting scope or timing`);
|
|
8
|
-
}
|
|
9
|
-
unique.set(lane.key, lane);
|
|
10
|
-
}
|
|
11
|
-
const trackByLane = /* @__PURE__ */ new Map();
|
|
12
|
-
const lanesByScope = /* @__PURE__ */ new Map();
|
|
13
|
-
for (const lane of unique.values()) {
|
|
14
|
-
const scoped = lanesByScope.get(lane.scopeKey) ?? [];
|
|
15
|
-
scoped.push(lane);
|
|
16
|
-
lanesByScope.set(lane.scopeKey, scoped);
|
|
17
|
-
}
|
|
18
|
-
for (const [scopeKey, scoped] of lanesByScope) {
|
|
19
|
-
if (scoped.some((lane) => lane.start === null && lane.end === null)) {
|
|
20
|
-
for (const lane of scoped) trackByLane.set(lane.key, trackId("lane", lane.key));
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
const incompleteKeys = /* @__PURE__ */ new Set();
|
|
24
|
-
const boundarySet = /* @__PURE__ */ new Set();
|
|
25
|
-
for (const lane of scoped) {
|
|
26
|
-
if (lane.start !== null && lane.end !== null && lane.end > lane.start) continue;
|
|
27
|
-
incompleteKeys.add(lane.key);
|
|
28
|
-
const boundary = lane.start ?? lane.end;
|
|
29
|
-
if (boundary !== null) boundarySet.add(boundary);
|
|
30
|
-
trackByLane.set(lane.key, trackId("lane", lane.key));
|
|
31
|
-
}
|
|
32
|
-
const boundaries = [...boundarySet].sort((a, b) => a - b);
|
|
33
|
-
const completeBySegment = /* @__PURE__ */ new Map();
|
|
34
|
-
for (const lane of scoped) {
|
|
35
|
-
if (incompleteKeys.has(lane.key)) continue;
|
|
36
|
-
const segment = upperBound(boundaries, lane.start);
|
|
37
|
-
const nextBoundary = boundaries[segment];
|
|
38
|
-
if (nextBoundary !== void 0 && nextBoundary < lane.end) {
|
|
39
|
-
trackByLane.set(lane.key, trackId("lane", lane.key));
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const complete = completeBySegment.get(segment) ?? [];
|
|
43
|
-
complete.push(lane);
|
|
44
|
-
completeBySegment.set(segment, complete);
|
|
45
|
-
}
|
|
46
|
-
let serialTrack = 0;
|
|
47
|
-
for (const [, segment] of [...completeBySegment].sort(([a], [b]) => a - b)) {
|
|
48
|
-
const ordered = [...segment].sort(
|
|
49
|
-
(a, b) => a.start - b.start || a.end - b.end || a.key.localeCompare(b.key)
|
|
50
|
-
);
|
|
51
|
-
let component = [];
|
|
52
|
-
let componentEnd = Number.NEGATIVE_INFINITY;
|
|
53
|
-
const flush = () => {
|
|
54
|
-
if (component.length === 1) {
|
|
55
|
-
trackByLane.set(component[0].key, trackId("serial", scopeKey, serialTrack));
|
|
56
|
-
} else if (component.length > 1) {
|
|
57
|
-
for (const lane of component) trackByLane.set(lane.key, trackId("lane", lane.key));
|
|
58
|
-
serialTrack += 1;
|
|
59
|
-
}
|
|
60
|
-
component = [];
|
|
61
|
-
componentEnd = Number.NEGATIVE_INFINITY;
|
|
62
|
-
};
|
|
63
|
-
for (const lane of ordered) {
|
|
64
|
-
if (component.length > 0 && lane.start >= componentEnd) flush();
|
|
65
|
-
component.push(lane);
|
|
66
|
-
componentEnd = Math.max(componentEnd, lane.end);
|
|
67
|
-
}
|
|
68
|
-
flush();
|
|
69
|
-
serialTrack += 1;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return trackByLane;
|
|
73
|
-
}
|
|
74
|
-
function sameLane(a, b) {
|
|
75
|
-
return a.scopeKey === b.scopeKey && a.start === b.start && a.end === b.end;
|
|
76
|
-
}
|
|
77
|
-
function trackId(kind, key, index) {
|
|
78
|
-
return JSON.stringify(index === void 0 ? [kind, key] : [kind, key, index]);
|
|
79
|
-
}
|
|
80
|
-
function upperBound(sorted, target) {
|
|
81
|
-
let low = 0;
|
|
82
|
-
let high = sorted.length;
|
|
83
|
-
while (low < high) {
|
|
84
|
-
const middle = low + high >>> 1;
|
|
85
|
-
if (sorted[middle] <= target) low = middle + 1;
|
|
86
|
-
else high = middle;
|
|
87
|
-
}
|
|
88
|
-
return low;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export {
|
|
92
|
-
executionTrackByLane
|
|
93
|
-
};
|
|
94
|
-
//# sourceMappingURL=chunk-HHWE3POT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/trace/execution-tracks.ts"],"sourcesContent":["export interface ExecutionLane {\n key: string\n scopeKey: string\n start: number | null\n end: number | null\n}\n\n/** Assign lanes to serial tracks without joining concurrent or ambiguously timed work. */\nexport function executionTrackByLane(lanes: readonly ExecutionLane[]): Map<string, string> {\n const unique = new Map<string, ExecutionLane>()\n for (const lane of lanes) {\n const existing = unique.get(lane.key)\n if (existing && !sameLane(existing, lane)) {\n throw new Error(`execution lane '${lane.key}' has conflicting scope or timing`)\n }\n unique.set(lane.key, lane)\n }\n\n const trackByLane = new Map<string, string>()\n const lanesByScope = new Map<string, ExecutionLane[]>()\n for (const lane of unique.values()) {\n const scoped = lanesByScope.get(lane.scopeKey) ?? []\n scoped.push(lane)\n lanesByScope.set(lane.scopeKey, scoped)\n }\n\n for (const [scopeKey, scoped] of lanesByScope) {\n if (scoped.some((lane) => lane.start === null && lane.end === null)) {\n for (const lane of scoped) trackByLane.set(lane.key, trackId('lane', lane.key))\n continue\n }\n const incompleteKeys = new Set<string>()\n const boundarySet = new Set<number>()\n for (const lane of scoped) {\n if (lane.start !== null && lane.end !== null && lane.end > lane.start) continue\n incompleteKeys.add(lane.key)\n const boundary = lane.start ?? lane.end\n if (boundary !== null) boundarySet.add(boundary)\n trackByLane.set(lane.key, trackId('lane', lane.key))\n }\n const boundaries = [...boundarySet].sort((a, b) => a - b)\n const completeBySegment = new Map<number, ExecutionLane[]>()\n for (const lane of scoped) {\n if (incompleteKeys.has(lane.key)) continue\n const segment = upperBound(boundaries, lane.start!)\n const nextBoundary = boundaries[segment]\n if (nextBoundary !== undefined && nextBoundary < lane.end!) {\n trackByLane.set(lane.key, trackId('lane', lane.key))\n continue\n }\n const complete = completeBySegment.get(segment) ?? []\n complete.push(lane)\n completeBySegment.set(segment, complete)\n }\n\n let serialTrack = 0\n for (const [, segment] of [...completeBySegment].sort(([a], [b]) => a - b)) {\n const ordered = [...segment].sort(\n (a, b) => a.start! - b.start! || a.end! - b.end! || a.key.localeCompare(b.key),\n )\n let component: ExecutionLane[] = []\n let componentEnd = Number.NEGATIVE_INFINITY\n const flush = () => {\n if (component.length === 1) {\n trackByLane.set(component[0]!.key, trackId('serial', scopeKey, serialTrack))\n } else if (component.length > 1) {\n for (const lane of component) trackByLane.set(lane.key, trackId('lane', lane.key))\n serialTrack += 1\n }\n component = []\n componentEnd = Number.NEGATIVE_INFINITY\n }\n\n for (const lane of ordered) {\n if (component.length > 0 && lane.start! >= componentEnd) flush()\n component.push(lane)\n componentEnd = Math.max(componentEnd, lane.end!)\n }\n flush()\n serialTrack += 1\n }\n }\n\n return trackByLane\n}\n\nfunction sameLane(a: ExecutionLane, b: ExecutionLane): boolean {\n return a.scopeKey === b.scopeKey && a.start === b.start && a.end === b.end\n}\n\nfunction trackId(kind: string, key: string, index?: number): string {\n return JSON.stringify(index === undefined ? [kind, key] : [kind, key, index])\n}\n\nfunction upperBound(sorted: readonly number[], target: number): number {\n let low = 0\n let high = sorted.length\n while (low < high) {\n const middle = (low + high) >>> 1\n if (sorted[middle]! <= target) low = middle + 1\n else high = middle\n }\n return low\n}\n"],"mappings":";AAQO,SAAS,qBAAqB,OAAsD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