@tangle-network/agent-eval 0.128.2 → 0.130.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.
Files changed (424) hide show
  1. package/CHANGELOG.md +279 -0
  2. package/README.md +19 -0
  3. package/dist/active-curriculum-C4mk67HP.js +214 -0
  4. package/dist/active-curriculum-C4mk67HP.js.map +1 -0
  5. package/dist/adversarial-smnADNFS.d.ts +21 -0
  6. package/dist/adversarial-smnADNFS.d.ts.map +1 -0
  7. package/dist/analyst/index.d.ts +83 -2932
  8. package/dist/analyst/index.d.ts.map +1 -0
  9. package/dist/analyst/index.js +319 -364
  10. package/dist/analyst/index.js.map +1 -1
  11. package/dist/analyst-BkTS3C58.d.ts +89 -0
  12. package/dist/analyst-BkTS3C58.d.ts.map +1 -0
  13. package/dist/analyst-LsnNpSkm.js +152 -0
  14. package/dist/analyst-LsnNpSkm.js.map +1 -0
  15. package/dist/analyze-runs-C1CavBMk.js +1067 -0
  16. package/dist/analyze-runs-C1CavBMk.js.map +1 -0
  17. package/dist/analyze-runs-FsgYCinh.d.ts +72 -0
  18. package/dist/analyze-runs-FsgYCinh.d.ts.map +1 -0
  19. package/dist/attribute-vocabulary-DLJ6303h.d.ts +54 -0
  20. package/dist/attribute-vocabulary-DLJ6303h.d.ts.map +1 -0
  21. package/dist/authenticity/index.d.ts +81 -79
  22. package/dist/authenticity/index.d.ts.map +1 -0
  23. package/dist/authenticity/index.js +209 -193
  24. package/dist/authenticity/index.js.map +1 -1
  25. package/dist/baseline-HsBvw_dk.js +550 -0
  26. package/dist/baseline-HsBvw_dk.js.map +1 -0
  27. package/dist/baseline-hG3K85h4.d.ts +125 -0
  28. package/dist/baseline-hG3K85h4.d.ts.map +1 -0
  29. package/dist/belief-state/index.d.ts +448 -1205
  30. package/dist/belief-state/index.d.ts.map +1 -0
  31. package/dist/belief-state/index.js +1617 -1710
  32. package/dist/belief-state/index.js.map +1 -1
  33. package/dist/benchmarks/index.d.ts +2 -894
  34. package/dist/benchmarks/index.js +2 -59
  35. package/dist/benchmarks-DviOvUNr.js +754 -0
  36. package/dist/benchmarks-DviOvUNr.js.map +1 -0
  37. package/dist/builder-eval/index.d.ts +150 -662
  38. package/dist/builder-eval/index.d.ts.map +1 -0
  39. package/dist/builder-eval/index.js +356 -345
  40. package/dist/builder-eval/index.js.map +1 -1
  41. package/dist/calibration-CNWWA6K8.js +94 -0
  42. package/dist/calibration-CNWWA6K8.js.map +1 -0
  43. package/dist/campaign/index.d.ts +5 -6390
  44. package/dist/campaign/index.js +3 -212
  45. package/dist/campaign-CBKZvQ1H.js +3885 -0
  46. package/dist/campaign-CBKZvQ1H.js.map +1 -0
  47. package/dist/cli.d.ts +1 -1
  48. package/dist/cli.js +164 -174
  49. package/dist/cli.js.map +1 -1
  50. package/dist/client-C97NMzqi.d.ts +581 -0
  51. package/dist/client-C97NMzqi.d.ts.map +1 -0
  52. package/dist/client-CYzbdJOZ.js +637 -0
  53. package/dist/client-CYzbdJOZ.js.map +1 -0
  54. package/dist/code-agent-session-BjkMTQ7H.js +1390 -0
  55. package/dist/code-agent-session-BjkMTQ7H.js.map +1 -0
  56. package/dist/code-agent-session-DqqgOJaz.d.ts +143 -0
  57. package/dist/code-agent-session-DqqgOJaz.d.ts.map +1 -0
  58. package/dist/concurrency-DIxRZF_J.js +85 -0
  59. package/dist/concurrency-DIxRZF_J.js.map +1 -0
  60. package/dist/contract/index.d.ts +645 -5605
  61. package/dist/contract/index.d.ts.map +1 -0
  62. package/dist/contract/index.js +1730 -1937
  63. package/dist/contract/index.js.map +1 -1
  64. package/dist/control.d.ts +3 -1030
  65. package/dist/control.js +2 -32
  66. package/dist/cost-ledger-DIgQUFZZ.js +801 -0
  67. package/dist/cost-ledger-DIgQUFZZ.js.map +1 -0
  68. package/dist/cost-ledger-Dye6jCgg.d.ts +236 -0
  69. package/dist/cost-ledger-Dye6jCgg.d.ts.map +1 -0
  70. package/dist/dataset-BvtnC8Dc.d.ts +115 -0
  71. package/dist/dataset-BvtnC8Dc.d.ts.map +1 -0
  72. package/dist/default-registry-C-vFCSEc.js +2579 -0
  73. package/dist/default-registry-C-vFCSEc.js.map +1 -0
  74. package/dist/default-registry-CNPo-Vsb.d.ts +540 -0
  75. package/dist/default-registry-CNPo-Vsb.d.ts.map +1 -0
  76. package/dist/emitter-CPBAhxum.js +266 -0
  77. package/dist/emitter-CPBAhxum.js.map +1 -0
  78. package/dist/emitter-DGQGoLyj.d.ts +113 -0
  79. package/dist/emitter-DGQGoLyj.d.ts.map +1 -0
  80. package/dist/errors-8YnH8WlF.js +64 -0
  81. package/dist/errors-8YnH8WlF.js.map +1 -0
  82. package/dist/errors-CEk209JS.d.ts +76 -0
  83. package/dist/errors-CEk209JS.d.ts.map +1 -0
  84. package/dist/eval-campaign-DEm6c8ru.js +349 -0
  85. package/dist/eval-campaign-DEm6c8ru.js.map +1 -0
  86. package/dist/execution-tracks-CpgFPpS5.js +93 -0
  87. package/dist/execution-tracks-CpgFPpS5.js.map +1 -0
  88. package/dist/exporters-q9iL-2Jf.js +148 -0
  89. package/dist/exporters-q9iL-2Jf.js.map +1 -0
  90. package/dist/extract-usage-BrQ8mCLX.js +155 -0
  91. package/dist/extract-usage-BrQ8mCLX.js.map +1 -0
  92. package/dist/failure-cluster-CqcvCcdR.d.ts +59 -0
  93. package/dist/failure-cluster-CqcvCcdR.d.ts.map +1 -0
  94. package/dist/feedback-trajectory-CVaeREXV.d.ts +340 -0
  95. package/dist/feedback-trajectory-CVaeREXV.d.ts.map +1 -0
  96. package/dist/fuzz.d.ts +320 -646
  97. package/dist/fuzz.d.ts.map +1 -0
  98. package/dist/fuzz.js +670 -617
  99. package/dist/fuzz.js.map +1 -1
  100. package/dist/hf-dataset-DBJXXoY1.js +763 -0
  101. package/dist/hf-dataset-DBJXXoY1.js.map +1 -0
  102. package/dist/hosted/index.d.ts +11 -831
  103. package/dist/hosted/index.d.ts.map +1 -0
  104. package/dist/hosted/index.js +2 -37
  105. package/dist/index-2JJSA6-r2.d.ts +926 -0
  106. package/dist/index-2JJSA6-r2.d.ts.map +1 -0
  107. package/dist/index-6N0aYmpW.d.ts +217 -0
  108. package/dist/index-6N0aYmpW.d.ts.map +1 -0
  109. package/dist/index-BAvgST_9.d.ts +131 -0
  110. package/dist/index-BAvgST_9.d.ts.map +1 -0
  111. package/dist/index-BvnJuTGD.d.ts +68 -0
  112. package/dist/index-BvnJuTGD.d.ts.map +1 -0
  113. package/dist/index-C61Wi7yg.d.ts +547 -0
  114. package/dist/index-C61Wi7yg.d.ts.map +1 -0
  115. package/dist/index-CAPUUKaM.d.ts +335 -0
  116. package/dist/index-CAPUUKaM.d.ts.map +1 -0
  117. package/dist/index-DE5fb3EC.d.ts +2244 -0
  118. package/dist/index-DE5fb3EC.d.ts.map +1 -0
  119. package/dist/index-DSC51roc.d.ts +102 -0
  120. package/dist/index-DSC51roc.d.ts.map +1 -0
  121. package/dist/index.d.ts +3776 -15120
  122. package/dist/index.d.ts.map +1 -0
  123. package/dist/index.js +11185 -11191
  124. package/dist/index.js.map +1 -1
  125. package/dist/integrity-BzRbCHzi.js +424 -0
  126. package/dist/integrity-BzRbCHzi.js.map +1 -0
  127. package/dist/integrity-rmVhXWA7.d.ts +61 -0
  128. package/dist/integrity-rmVhXWA7.d.ts.map +1 -0
  129. package/dist/judge-calibration-DFtEMlde.d.ts +146 -0
  130. package/dist/judge-calibration-DFtEMlde.d.ts.map +1 -0
  131. package/dist/ledger-core/index.d.ts +2 -0
  132. package/dist/ledger-core/index.js +2 -0
  133. package/dist/ledger-core-DtZz1RG0.js +388 -0
  134. package/dist/ledger-core-DtZz1RG0.js.map +1 -0
  135. package/dist/llm-client--GR4JbZE.js +687 -0
  136. package/dist/llm-client--GR4JbZE.js.map +1 -0
  137. package/dist/llm-client-B_nIBlYo.d.ts +290 -0
  138. package/dist/llm-client-B_nIBlYo.d.ts.map +1 -0
  139. package/dist/matrix/index.d.ts +3 -155
  140. package/dist/matrix/index.js +2 -8
  141. package/dist/matrix-BzQnu2S6.js +270 -0
  142. package/dist/matrix-BzQnu2S6.js.map +1 -0
  143. package/dist/meta-eval/index.d.ts +4 -1027
  144. package/dist/meta-eval/index.js +393 -390
  145. package/dist/meta-eval/index.js.map +1 -1
  146. package/dist/metrics-C9YY1OcL.js +239 -0
  147. package/dist/metrics-C9YY1OcL.js.map +1 -0
  148. package/dist/mint-yN2M2eh0.js +201 -0
  149. package/dist/mint-yN2M2eh0.js.map +1 -0
  150. package/dist/multi-layer-verifier-BHY1gWAc.d.ts +138 -0
  151. package/dist/multi-layer-verifier-BHY1gWAc.d.ts.map +1 -0
  152. package/dist/multishot/index.d.ts +273 -481
  153. package/dist/multishot/index.d.ts.map +1 -0
  154. package/dist/multishot/index.js +595 -548
  155. package/dist/multishot/index.js.map +1 -1
  156. package/dist/off-policy-DvgzvtIx.js +220 -0
  157. package/dist/off-policy-DvgzvtIx.js.map +1 -0
  158. package/dist/off-policy-mskQw8Mb.d.ts +153 -0
  159. package/dist/off-policy-mskQw8Mb.d.ts.map +1 -0
  160. package/dist/openapi.json +1 -1
  161. package/dist/opencode-sqlite-BGrHeDu3.js +318 -0
  162. package/dist/opencode-sqlite-BGrHeDu3.js.map +1 -0
  163. package/dist/outcome-store-BYHIuO0e.d.ts +65 -0
  164. package/dist/outcome-store-BYHIuO0e.d.ts.map +1 -0
  165. package/dist/outcome-store-ChBKlTd_.js +75 -0
  166. package/dist/outcome-store-ChBKlTd_.js.map +1 -0
  167. package/dist/paired-arms-D9D0wXj2.js +260 -0
  168. package/dist/paired-arms-D9D0wXj2.js.map +1 -0
  169. package/dist/pipelines/index.d.ts +95 -532
  170. package/dist/pipelines/index.d.ts.map +1 -0
  171. package/dist/pipelines/index.js +497 -478
  172. package/dist/pipelines/index.js.map +1 -1
  173. package/dist/pre-registration-DakwTRXk.js +96 -0
  174. package/dist/pre-registration-DakwTRXk.js.map +1 -0
  175. package/dist/propose-review-control-LhIWGzHl.js +1458 -0
  176. package/dist/propose-review-control-LhIWGzHl.js.map +1 -0
  177. package/dist/query-CJ_DX8vl.d.ts +28 -0
  178. package/dist/query-CJ_DX8vl.d.ts.map +1 -0
  179. package/dist/query-Di7eEQ79.js +83 -0
  180. package/dist/query-Di7eEQ79.js.map +1 -0
  181. package/dist/raw-provider-sink-BQd7mzyT.js +201 -0
  182. package/dist/raw-provider-sink-BQd7mzyT.js.map +1 -0
  183. package/dist/raw-provider-sink-BU29Sh8h.d.ts +134 -0
  184. package/dist/raw-provider-sink-BU29Sh8h.d.ts.map +1 -0
  185. package/dist/redact-7Aq1ukl-.js +107 -0
  186. package/dist/redact-7Aq1ukl-.js.map +1 -0
  187. package/dist/release-report-Cz9NKH39.js +603 -0
  188. package/dist/release-report-Cz9NKH39.js.map +1 -0
  189. package/dist/release-report-mvB2G4_J.d.ts +244 -0
  190. package/dist/release-report-mvB2G4_J.d.ts.map +1 -0
  191. package/dist/replay-GnyotH0J.js +1741 -0
  192. package/dist/replay-GnyotH0J.js.map +1 -0
  193. package/dist/replay-OoidtG1E.d.ts +749 -0
  194. package/dist/replay-OoidtG1E.d.ts.map +1 -0
  195. package/dist/reporting.d.ts +6 -1298
  196. package/dist/reporting.js +6 -50
  197. package/dist/researcher-CwTdwXG1.d.ts +314 -0
  198. package/dist/researcher-CwTdwXG1.d.ts.map +1 -0
  199. package/dist/reward-hacking-eAnOsynk.d.ts +224 -0
  200. package/dist/reward-hacking-eAnOsynk.d.ts.map +1 -0
  201. package/dist/reward-hacking-qipEpKvY.js +596 -0
  202. package/dist/reward-hacking-qipEpKvY.js.map +1 -0
  203. package/dist/reward-nw2xZGZG.js +137 -0
  204. package/dist/reward-nw2xZGZG.js.map +1 -0
  205. package/dist/rl.d.ts +916 -3596
  206. package/dist/rl.d.ts.map +1 -0
  207. package/dist/rl.js +2362 -1751
  208. package/dist/rl.js.map +1 -1
  209. package/dist/rolldown-runtime-8H4AJuhK.js +14 -0
  210. package/dist/rollout/index.d.ts +3 -1048
  211. package/dist/rollout/index.js +8 -110
  212. package/dist/rollout-BOYjemfR.js +624 -0
  213. package/dist/rollout-BOYjemfR.js.map +1 -0
  214. package/dist/rubric-predictive-validity-B3xmbmS1.js +141 -0
  215. package/dist/rubric-predictive-validity-B3xmbmS1.js.map +1 -0
  216. package/dist/rubric-predictive-validity-Ku_clp_1.d.ts +74 -0
  217. package/dist/rubric-predictive-validity-Ku_clp_1.d.ts.map +1 -0
  218. package/dist/run-evidence-ClRX_8A9.d.ts +225 -0
  219. package/dist/run-evidence-ClRX_8A9.d.ts.map +1 -0
  220. package/dist/run-record-BuoE80Dq.js +467 -0
  221. package/dist/run-record-BuoE80Dq.js.map +1 -0
  222. package/dist/run-record-CnZu_gjl.d.ts +357 -0
  223. package/dist/run-record-CnZu_gjl.d.ts.map +1 -0
  224. package/dist/run-score-iEEAWiBY.js +41 -0
  225. package/dist/run-score-iEEAWiBY.js.map +1 -0
  226. package/dist/runtime-trajectory-1gyaTOoC.js +93 -0
  227. package/dist/runtime-trajectory-1gyaTOoC.js.map +1 -0
  228. package/dist/runtime-trajectory-BvSZcCHD.d.ts +50 -0
  229. package/dist/runtime-trajectory-BvSZcCHD.d.ts.map +1 -0
  230. package/dist/schema-BtVldJ3T.d.ts +206 -0
  231. package/dist/schema-BtVldJ3T.d.ts.map +1 -0
  232. package/dist/schema-C6DW4ZHR.js +821 -0
  233. package/dist/schema-C6DW4ZHR.js.map +1 -0
  234. package/dist/schema-CRhEY1SO.js +69 -0
  235. package/dist/schema-CRhEY1SO.js.map +1 -0
  236. package/dist/schema-Cef2cFmb.d.ts +408 -0
  237. package/dist/schema-Cef2cFmb.d.ts.map +1 -0
  238. package/dist/semantic-concept-judge-B6cWNJ2K.js +725 -0
  239. package/dist/semantic-concept-judge-B6cWNJ2K.js.map +1 -0
  240. package/dist/sequential-Br0mAPHA.js +148 -0
  241. package/dist/sequential-Br0mAPHA.js.map +1 -0
  242. package/dist/sequential-CYwq6Ff_.d.ts +141 -0
  243. package/dist/sequential-CYwq6Ff_.d.ts.map +1 -0
  244. package/dist/series-convergence-CjO2QdRW.js +43 -0
  245. package/dist/series-convergence-CjO2QdRW.js.map +1 -0
  246. package/dist/series-convergence-ofsqPWhs.d.ts +35 -0
  247. package/dist/series-convergence-ofsqPWhs.d.ts.map +1 -0
  248. package/dist/server-m5D9cvnG.js +1040 -0
  249. package/dist/server-m5D9cvnG.js.map +1 -0
  250. package/dist/skill-usage-C_pXm7lP.d.ts +534 -0
  251. package/dist/skill-usage-C_pXm7lP.d.ts.map +1 -0
  252. package/dist/skillopt-optimization-method-B7wX7XkF.d.ts +1739 -0
  253. package/dist/skillopt-optimization-method-B7wX7XkF.d.ts.map +1 -0
  254. package/dist/skillopt-optimization-method-D4ODwFVV.js +7712 -0
  255. package/dist/skillopt-optimization-method-D4ODwFVV.js.map +1 -0
  256. package/dist/statistics-Cmj6nynr.d.ts +514 -0
  257. package/dist/statistics-Cmj6nynr.d.ts.map +1 -0
  258. package/dist/statistics-CnnxdpOg.js +1437 -0
  259. package/dist/statistics-CnnxdpOg.js.map +1 -0
  260. package/dist/store-CT9YIIve.d.ts +117 -0
  261. package/dist/store-CT9YIIve.d.ts.map +1 -0
  262. package/dist/store-CxJry_cs.d.ts +229 -0
  263. package/dist/store-CxJry_cs.d.ts.map +1 -0
  264. package/dist/storyboard/index.d.ts +84 -203
  265. package/dist/storyboard/index.d.ts.map +1 -0
  266. package/dist/storyboard/index.js +609 -542
  267. package/dist/storyboard/index.js.map +1 -1
  268. package/dist/summary-report-BNs5nmXI.js +862 -0
  269. package/dist/summary-report-BNs5nmXI.js.map +1 -0
  270. package/dist/summary-report-Cj9gdw4i.d.ts +407 -0
  271. package/dist/summary-report-Cj9gdw4i.d.ts.map +1 -0
  272. package/dist/supervisor-run/index.d.ts +2 -849
  273. package/dist/supervisor-run/index.js +2 -64
  274. package/dist/supervisor-run-_lnTLM3z.js +1679 -0
  275. package/dist/supervisor-run-_lnTLM3z.js.map +1 -0
  276. package/dist/task-failure-attributes-CQZlB3et.js +311 -0
  277. package/dist/task-failure-attributes-CQZlB3et.js.map +1 -0
  278. package/dist/test-graded-scenario-BsqWLmPt.js +318 -0
  279. package/dist/test-graded-scenario-BsqWLmPt.js.map +1 -0
  280. package/dist/test-graded-scenario-D1TaI2va.d.ts +141 -0
  281. package/dist/test-graded-scenario-D1TaI2va.d.ts.map +1 -0
  282. package/dist/tools-BmuN627J.js +1085 -0
  283. package/dist/tools-BmuN627J.js.map +1 -0
  284. package/dist/trace-attributes.d.ts +2 -52
  285. package/dist/trace-attributes.js +131 -61
  286. package/dist/trace-attributes.js.map +1 -1
  287. package/dist/traces.d.ts +12 -2365
  288. package/dist/traces.js +12 -251
  289. package/dist/trajectory-D_7rLrvE.js +56 -0
  290. package/dist/trajectory-D_7rLrvE.js.map +1 -0
  291. package/dist/types-DGsxbAEd.d.ts +387 -0
  292. package/dist/types-DGsxbAEd.d.ts.map +1 -0
  293. package/dist/types-k9tZGKUg.d.ts +640 -0
  294. package/dist/types-k9tZGKUg.d.ts.map +1 -0
  295. package/dist/verdict-Dps8_okt.d.ts +37 -0
  296. package/dist/verdict-Dps8_okt.d.ts.map +1 -0
  297. package/dist/wire/index.d.ts +702 -1174
  298. package/dist/wire/index.d.ts.map +1 -0
  299. package/dist/wire/index.js +2 -81
  300. package/docs/feature-guide.md +1 -1
  301. package/docs/rollout.md +116 -2
  302. package/package.json +18 -10
  303. package/dist/benchmarks/index.js.map +0 -1
  304. package/dist/campaign/index.js.map +0 -1
  305. package/dist/chunk-2JX3CFMB.js +0 -695
  306. package/dist/chunk-2JX3CFMB.js.map +0 -1
  307. package/dist/chunk-2MKQIFS4.js +0 -183
  308. package/dist/chunk-2MKQIFS4.js.map +0 -1
  309. package/dist/chunk-3RF76KTD.js +0 -84
  310. package/dist/chunk-3RF76KTD.js.map +0 -1
  311. package/dist/chunk-5DTSBUL2.js +0 -159
  312. package/dist/chunk-5DTSBUL2.js.map +0 -1
  313. package/dist/chunk-7ZZMD7UK.js +0 -386
  314. package/dist/chunk-7ZZMD7UK.js.map +0 -1
  315. package/dist/chunk-BOD4O7OF.js +0 -40
  316. package/dist/chunk-BOD4O7OF.js.map +0 -1
  317. package/dist/chunk-BYT7ELPS.js +0 -1553
  318. package/dist/chunk-BYT7ELPS.js.map +0 -1
  319. package/dist/chunk-DJKY2TSY.js +0 -2428
  320. package/dist/chunk-DJKY2TSY.js.map +0 -1
  321. package/dist/chunk-DPUHNQLN.js +0 -232
  322. package/dist/chunk-DPUHNQLN.js.map +0 -1
  323. package/dist/chunk-DRYIUNWY.js +0 -622
  324. package/dist/chunk-DRYIUNWY.js.map +0 -1
  325. package/dist/chunk-EJGRPCO3.js +0 -617
  326. package/dist/chunk-EJGRPCO3.js.map +0 -1
  327. package/dist/chunk-EOSZT7PL.js +0 -2001
  328. package/dist/chunk-EOSZT7PL.js.map +0 -1
  329. package/dist/chunk-EZJEIH2R.js +0 -1559
  330. package/dist/chunk-EZJEIH2R.js.map +0 -1
  331. package/dist/chunk-GGE4NNQT.js +0 -65
  332. package/dist/chunk-GGE4NNQT.js.map +0 -1
  333. package/dist/chunk-HHWE3POT.js +0 -94
  334. package/dist/chunk-HHWE3POT.js.map +0 -1
  335. package/dist/chunk-IHQDPH7D.js +0 -171
  336. package/dist/chunk-IHQDPH7D.js.map +0 -1
  337. package/dist/chunk-JHCHEVET.js +0 -274
  338. package/dist/chunk-JHCHEVET.js.map +0 -1
  339. package/dist/chunk-K4DBDHLK.js +0 -158
  340. package/dist/chunk-K4DBDHLK.js.map +0 -1
  341. package/dist/chunk-K6N6XJJX.js +0 -306
  342. package/dist/chunk-K6N6XJJX.js.map +0 -1
  343. package/dist/chunk-MA6HLL3S.js +0 -65
  344. package/dist/chunk-MA6HLL3S.js.map +0 -1
  345. package/dist/chunk-MAZ26DC7.js +0 -99
  346. package/dist/chunk-MAZ26DC7.js.map +0 -1
  347. package/dist/chunk-MHELPNRP.js +0 -1212
  348. package/dist/chunk-MHELPNRP.js.map +0 -1
  349. package/dist/chunk-NACAGYSY.js +0 -1040
  350. package/dist/chunk-NACAGYSY.js.map +0 -1
  351. package/dist/chunk-NKAGIDE2.js +0 -7633
  352. package/dist/chunk-NKAGIDE2.js.map +0 -1
  353. package/dist/chunk-NPCTHQIO.js +0 -91
  354. package/dist/chunk-NPCTHQIO.js.map +0 -1
  355. package/dist/chunk-NYLOYM6N.js +0 -332
  356. package/dist/chunk-NYLOYM6N.js.map +0 -1
  357. package/dist/chunk-ONWEPEDO.js +0 -57
  358. package/dist/chunk-ONWEPEDO.js.map +0 -1
  359. package/dist/chunk-P5W7RQKK.js +0 -576
  360. package/dist/chunk-P5W7RQKK.js.map +0 -1
  361. package/dist/chunk-P6FYH6K4.js +0 -1161
  362. package/dist/chunk-P6FYH6K4.js.map +0 -1
  363. package/dist/chunk-PBE2LOSS.js +0 -669
  364. package/dist/chunk-PBE2LOSS.js.map +0 -1
  365. package/dist/chunk-PC4UYEBM.js +0 -166
  366. package/dist/chunk-PC4UYEBM.js.map +0 -1
  367. package/dist/chunk-PXE2VKMX.js +0 -140
  368. package/dist/chunk-PXE2VKMX.js.map +0 -1
  369. package/dist/chunk-PZ5AY32C.js +0 -10
  370. package/dist/chunk-PZ5AY32C.js.map +0 -1
  371. package/dist/chunk-RZTMDUO7.js +0 -49
  372. package/dist/chunk-RZTMDUO7.js.map +0 -1
  373. package/dist/chunk-S5YLIBFX.js +0 -136
  374. package/dist/chunk-S5YLIBFX.js.map +0 -1
  375. package/dist/chunk-SZLVEKMJ.js +0 -1446
  376. package/dist/chunk-SZLVEKMJ.js.map +0 -1
  377. package/dist/chunk-T4SQEITX.js +0 -95
  378. package/dist/chunk-T4SQEITX.js.map +0 -1
  379. package/dist/chunk-TBL77AUT.js +0 -355
  380. package/dist/chunk-TBL77AUT.js.map +0 -1
  381. package/dist/chunk-TSN7JT6D.js +0 -1646
  382. package/dist/chunk-TSN7JT6D.js.map +0 -1
  383. package/dist/chunk-TT4KNT67.js +0 -124
  384. package/dist/chunk-TT4KNT67.js.map +0 -1
  385. package/dist/chunk-UB2LOJ6Q.js +0 -4461
  386. package/dist/chunk-UB2LOJ6Q.js.map +0 -1
  387. package/dist/chunk-UWZZKKU7.js +0 -237
  388. package/dist/chunk-UWZZKKU7.js.map +0 -1
  389. package/dist/chunk-VBQ3CRKH.js +0 -291
  390. package/dist/chunk-VBQ3CRKH.js.map +0 -1
  391. package/dist/chunk-VGRCHJON.js +0 -163
  392. package/dist/chunk-VGRCHJON.js.map +0 -1
  393. package/dist/chunk-VI2UW6B6.js +0 -162
  394. package/dist/chunk-VI2UW6B6.js.map +0 -1
  395. package/dist/chunk-VLOATJQ2.js +0 -908
  396. package/dist/chunk-VLOATJQ2.js.map +0 -1
  397. package/dist/chunk-VQMK5FMP.js +0 -247
  398. package/dist/chunk-VQMK5FMP.js.map +0 -1
  399. package/dist/chunk-VZSRQ272.js +0 -149
  400. package/dist/chunk-VZSRQ272.js.map +0 -1
  401. package/dist/chunk-WGXIEX7P.js +0 -116
  402. package/dist/chunk-WGXIEX7P.js.map +0 -1
  403. package/dist/chunk-WS3NZZQQ.js +0 -929
  404. package/dist/chunk-WS3NZZQQ.js.map +0 -1
  405. package/dist/chunk-XDWDC2MP.js +0 -695
  406. package/dist/chunk-XDWDC2MP.js.map +0 -1
  407. package/dist/chunk-XPRT64IE.js +0 -766
  408. package/dist/chunk-XPRT64IE.js.map +0 -1
  409. package/dist/chunk-YJBNWCAA.js +0 -1056
  410. package/dist/chunk-YJBNWCAA.js.map +0 -1
  411. package/dist/chunk-ZET2UAYW.js +0 -89
  412. package/dist/chunk-ZET2UAYW.js.map +0 -1
  413. package/dist/chunk-ZUUWPZCV.js +0 -752
  414. package/dist/chunk-ZUUWPZCV.js.map +0 -1
  415. package/dist/control.js.map +0 -1
  416. package/dist/hosted/index.js.map +0 -1
  417. package/dist/matrix/index.js.map +0 -1
  418. package/dist/reporting.js.map +0 -1
  419. package/dist/rollout/index.js.map +0 -1
  420. package/dist/run-campaign-ISHFZ7FJ.js +0 -17
  421. package/dist/run-campaign-ISHFZ7FJ.js.map +0 -1
  422. package/dist/supervisor-run/index.js.map +0 -1
  423. package/dist/traces.js.map +0 -1
  424. package/dist/wire/index.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-C6DW4ZHR.js","names":[],"sources":["../src/rollout/gate-checks.ts","../src/rollout/schema.ts"],"sourcesContent":["/**\n * THE canonical list of anti-Goodhart gate checks, plus the TOTAL policy every\n * entry point has to declare over it.\n *\n * Four rounds of adversarial review found the same defect four times, and it\n * was never the check itself: it was the COMPOSITION. `validateRolloutLine`\n * composed one check, `assertMinted` composed two, `assertRewardGate` composed\n * two of the three, `assertGateReport` composed its own pair — each by hand, in\n * its own file. So a check added to the package applied wherever its author\n * happened to remember, and the guard that forgot it looked exactly like the\n * guard that didn't. The last leak was literally that: `assertRewardGate`\n * composed `reward-relationship` + `gated-evidence` and not `unscreened-reward`,\n * so a never-screened positive reward that `assertMinted` correctly REFUSED\n * walked through all four waist exporters at full value.\n *\n * The fix is to make hand-composition impossible rather than to add a third\n * call to the two places that had two:\n *\n * - `GATE_CHECKS` is a TOTAL map over `GateCheckId`. A new id with no\n * implementation does not compile.\n * - `GatePolicy` is a TOTAL map over `GateCheckId`. Every entry point\n * declares one, so a new id makes EVERY entry point's policy a type error\n * until it is wired. Wiring it means writing `enforced`, `repairedBy(...)`\n * or `omittedBecause(...)` — and the last two force a written reason, so a\n * silent gap is not expressible.\n * - every check carries a `tripwire`: the minimal outcome it must refuse.\n * `gate-checks.test.ts` feeds each tripwire to every entry point that\n * declares `enforced` and requires a rejection, so wiring a check to the\n * wrong disposition is a TEST failure even when it type-checks.\n *\n * Adding a check is therefore: append the id, write the check, and the compiler\n * enumerates every place that has to decide about it.\n */\n\nimport type { GatedEvidence, RolloutOutcome, RolloutStep } from './schema'\n\n/**\n * Every gate check in the package, in the order they are applied.\n *\n * Order is load-bearing only for which message a caller sees first: a line that\n * trips two checks reports the earlier one, and `reward-relationship` is first\n * because it is the invariant the other three protect.\n */\nexport const GATE_CHECK_IDS = [\n 'reward-relationship',\n 'gated-evidence',\n 'undeclared-step-payload',\n 'unscreened-reward',\n] as const\n\nexport type GateCheckId = (typeof GATE_CHECK_IDS)[number]\n\n/**\n * An outcome as it reaches a check.\n *\n * Deliberately accepts a raw record as well as the typed shape: the checks are\n * the RUNTIME half of the gate, and the callers they exist for — JSON off a\n * ledger, a plain-JavaScript consumer of the published package — arrive with no\n * types at all. `Partial` because a tripwire states only the fields it trips on.\n */\nexport type GateCheckedOutcome = Partial<RolloutOutcome> | Readonly<Record<string, unknown>>\n\n/**\n * What a gate check reads: the reward-bearing surface of ONE LINE.\n *\n * For three rounds the subject was the OUTCOME alone, and that assumption is\n * what produced the next leak rather than any missing check: `steps[]` sits on\n * the LINE, outside `outcome`, so a per-step reward on a gated line was read by\n * no check at all while `toRewardRows` copied it out verbatim — through the\n * MINTED door, not merely the raw one. Widening the subject is what makes\n * \"somewhere else on the line\" a place the checks can see.\n *\n * `outcome` is REQUIRED, and that is the point: a bare `RolloutOutcome` is then\n * not assignable to a subject, so every call site that used to pass one is a\n * COMPILE error until it passes the line instead. A subject with an optional\n * `outcome` would have let the old call sites keep compiling while silently\n * checking nothing — the exact failure this module exists to make impossible.\n */\nexport interface GateSubject {\n outcome: GateCheckedOutcome\n /** The line's trajectory steps, when it carries any. */\n steps?: unknown\n}\n\n/** One untyped field read off the outcome, so every check narrows from the same place. */\nconst field = (subject: GateSubject, name: string): unknown =>\n (subject.outcome as Readonly<Record<string, unknown>>)?.[name]\n\nexport interface GateCheck {\n id: GateCheckId\n /** One sentence: what this check refuses. */\n refuses: string\n /** One dotted-path message per defect; `[]` when the line is clean. */\n errors: (subject: GateSubject) => string[]\n /**\n * Every minimal subject that MUST trip `errors` — the executable form of\n * `refuses`, and the reason a check cannot be added without being provable.\n * The calibration test feeds each one to every entry point declaring\n * `enforced`.\n *\n * A LIST rather than one case: a check that refuses two distinct populations\n * (a positive reward AND a reward it cannot read as a number) proved able to\n * hold for the first while silently passing the second, so each population\n * states its own tripwire and each is exercised separately.\n */\n tripwires: GateSubject[]\n}\n\n// ---------------------------------------------------------------------------\n// Total readers. Every \"is this positive?\" / \"is this populated?\" question the\n// checks ask goes through one of these.\n// ---------------------------------------------------------------------------\n\n/**\n * How the gate reads one `outcome.reward`.\n *\n * TOTAL over `unknown`, with an explicit `unreadable` case, because the\n * recurring defect across four rounds was a hand-written type test whose\n * NEGATIVE branch silently passed: `typeof reward !== 'number' || !(reward > 0)`\n * returned \"clean\" for `reward: \"0.95\"`, so a plain-JavaScript producer that\n * stringifies its numbers — the exact population the runtime backstop exists\n * for — shipped a gamed run at full value through three waist exporters.\n *\n * A value the gate cannot read as a number is not evidence the reward is\n * cleared; it is the absence of that evidence, and the gate fails closed on it.\n */\nexport type RewardReading =\n /** `null`/`undefined` — a labeled gap, which is never a positive signal. */\n | { kind: 'absent' }\n /** A number at or below zero: the gate's own verdict, applied. */\n | { kind: 'cleared' }\n /** A number above zero, `Infinity` and the 5e-324 denormal included. */\n | { kind: 'positive'; shown: string }\n /** Anything the wire format does not permit here, plus `NaN`. */\n | { kind: 'unreadable'; shown: string }\n\nexport function readReward(value: unknown): RewardReading {\n if (value === null || value === undefined) return { kind: 'absent' }\n if (typeof value === 'number') {\n if (Number.isNaN(value)) return { kind: 'unreadable', shown: 'NaN' }\n return value > 0 ? { kind: 'positive', shown: String(value) } : { kind: 'cleared' }\n }\n return {\n kind: 'unreadable',\n shown: `${JSON.stringify(value) ?? String(value)} (${typeof value})`,\n }\n}\n\nconst isPlainRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/**\n * Whether a reward-derived field carries anything at all.\n *\n * The previous emptiness test was `Object.keys(value).length > 0`, which reads\n * `[]` for a NUMBER, a BOOLEAN and the empty string — so `metrics: 0.95` on a\n * gated line counted as empty and shipped verbatim in the verifiers format's\n * per-rubric score dict. `Object.keys` being total over primitives is not the\n * same property as being CORRECT over them.\n *\n * The rule that has no such hole: only `undefined`, `null` and a record with no\n * keys are empty. Everything else is payload, whatever its type.\n */\nexport function payloadIsPopulated(value: unknown): boolean {\n if (value === undefined || value === null) return false\n if (isPlainRecord(value)) return Object.keys(value).length > 0\n return true\n}\n\n/**\n * Every key `tangle.rollout.v1` declares on a step, as a TOTAL map over the\n * interface: a field added to `RolloutStep` and not to this list does not\n * compile, so the list cannot silently fall behind the schema it mirrors.\n *\n * This is the producer's OWN classification, which is the only partition\n * `gatedEvidenceOf` accepts — a key-name heuristic (\"strip anything matching\n * /reward|score/\") holds until someone names a field `credit` and the next\n * per-step signal ships at full value.\n */\nconst DECLARED_STEP_KEYS: { readonly [K in keyof Required<RolloutStep>]: true } = {\n kind: true,\n name: true,\n input: true,\n output: true,\n status: true,\n durationMs: true,\n llm_call_count: true,\n prompt_token_ids: true,\n completion_token_ids: true,\n logprobs: true,\n}\n\n/**\n * The part of `steps` the wire format has no name for — a per-step reward, a\n * per-step score, whatever a producer decided to hang there.\n *\n * `undefined` when the steps carry nothing undeclared.\n */\nexport function undeclaredStepPayload(steps: unknown): unknown {\n if (steps === undefined || steps === null) return undefined\n // The format says `steps` is a list. Anything else is wholly unclassified.\n if (!Array.isArray(steps)) return steps\n const extras: Array<Record<string, unknown>> = []\n let found = false\n for (const step of steps) {\n const extra: Record<string, unknown> = {}\n if (isPlainRecord(step)) {\n for (const [key, value] of Object.entries(step)) {\n if (key in DECLARED_STEP_KEYS) continue\n extra[key] = value\n found = true\n }\n } else if (step !== undefined && step !== null) {\n // A step that is not even a record carries no declared key to keep.\n extras.push({ step } as Record<string, unknown>)\n found = true\n continue\n }\n extras.push(extra)\n }\n return found ? extras : undefined\n}\n\n/** `steps` projected down to the keys the wire format declares. */\nexport function declaredSteps(steps: unknown): RolloutStep[] | undefined {\n if (!Array.isArray(steps)) return undefined\n const kept: RolloutStep[] = []\n for (const step of steps) {\n if (!isPlainRecord(step)) continue\n const projected: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(step)) {\n if (key in DECLARED_STEP_KEYS) projected[key] = value\n }\n kept.push(projected as unknown as RolloutStep)\n }\n return kept\n}\n\n/**\n * THE anti-Goodhart invariant, checked as a RELATIONSHIP between two fields\n * rather than as two independent type checks.\n *\n * Everything upstream of a training export is allowed to be wrong; this is the\n * one thing that cannot be. `realness_gated: true` means the run faked its\n * success signal, so its reward is a fabrication, and a fabrication above zero\n * is precisely what a trainer would learn to reproduce. Validating only that\n * `reward` is a number and `realness_gated` is a boolean is what let a line\n * claiming `{reward: 0.95, realness_gated: true}` validate clean and walk\n * through every exporter.\n */\nconst rewardRelationship: GateCheck = {\n id: 'reward-relationship',\n refuses: 'a positive — or unreadable — reward on a line the authenticity screen flagged as gamed',\n tripwires: [\n { outcome: { reward: 0.95, realness_gated: true } },\n // The second population, stated separately because the check held for the\n // first while passing this one for a full round.\n { outcome: { reward: '0.95' as unknown as number, realness_gated: true } },\n ],\n errors: (subject) => {\n if (field(subject, 'realness_gated') !== true) return []\n const reading = readReward(field(subject, 'reward'))\n if (reading.kind === 'absent' || reading.kind === 'cleared') return []\n if (reading.kind === 'unreadable') {\n return [\n `outcome.reward: ${reading.shown} with outcome.realness_gated: true — the wire format ` +\n 'declares this field `number | null`, so the gate cannot read this value as a number ' +\n 'and cannot establish that the reward was cleared. On a run flagged as gamed that is ' +\n 'not evidence of a zero, it is the absence of it, and a consumer that coerces the ' +\n 'value (`\"0.95\"`, `\"2\"`) reads a positive reward off a faked success. Emit a number ' +\n 'or null — `trainingReward` / `trainingScore` from `rollout/reward.ts` produce one.',\n ]\n }\n return [\n `outcome.reward: ${reading.shown} with outcome.realness_gated: true — a run flagged as ` +\n 'gamed may not carry a positive reward. The anti-Goodhart gate forces the reward to 0 (a ' +\n 'real verdict: the gate decided) before the line is written, so a fine-tune cannot learn ' +\n 'from a faked success. Derive the reward with `trainingReward` / `trainingScore` from ' +\n '`rollout/reward.ts`, or drop the line.',\n ]\n },\n}\n\n/**\n * The reward-bearing outcome fields that are NOT the scalar: the numbers the\n * reward was computed from, and the verdict record that claimed it.\n *\n * Returned as one block rather than filtered key-by-key. A key-name heuristic\n * (\"zero anything matching `layer.*` or `/score/`\") is the same defect shape as\n * the line-oriented regex the AST score guard replaced: it holds until someone\n * names a metric `pass_fraction`, and the next reward-shaped key ships at full\n * value. The producer's OWN classification — \"this is the scalar, that is\n * everything else\" — is the only partition that cannot be out-guessed.\n */\nexport function gatedEvidenceOf(subject: GateSubject): GatedEvidence | undefined {\n const evidence: GatedEvidence = {}\n // `payloadIsPopulated`, not an inline key count: a plain-JavaScript caller can\n // hand any value here, and a non-record `metrics` is still reward-derived\n // payload. See that function for the primitives an `Object.keys` test missed.\n const metrics = field(subject, 'metrics')\n if (payloadIsPopulated(metrics)) evidence.metrics = metrics as Record<string, unknown>\n const verdict = field(subject, 'verdict')\n if (verdict !== null && verdict !== undefined) evidence.verdict = verdict\n const steps = undeclaredStepPayload(subject.steps)\n if (steps !== undefined) evidence.steps = steps\n return evidence.metrics === undefined && evidence.verdict === undefined && steps === undefined\n ? undefined\n : evidence\n}\n\n/**\n * The invariant is about the OUTCOME, not about one field of it.\n *\n * `mintRolloutRows` bulk-copied `RunRecord.outcome.raw` into `outcome.metrics`\n * with no gate, so a gated run exported `reward: 0` (correct) while the\n * deterministic per-layer scores that reward was COMPUTED FROM — the `layer.*`\n * keys `rl/verifiable-reward.ts` calls the RL training signal — shipped at 1.0,\n * in the top-level `metrics` dict of the Prime Intellect verifiers format, which\n * IS that format's per-rubric score dict. `verdict` leaks the same way into\n * `toRftItem`'s `reference.verdict`, where a grader author reads\n * `resolved: true` off a run that faked it.\n */\nconst gatedEvidence: GateCheck = {\n id: 'gated-evidence',\n refuses: 'the numbers a fabricated reward was computed from, riding along at reward 0',\n tripwires: [\n { outcome: { reward: 0, realness_gated: true, metrics: { 'layer.tests': 1 } } },\n // A PRIMITIVE `metrics`: `Object.keys(0.95)` is `[]`, so the emptiness test\n // this check used to run reported it clean and the verifiers format shipped\n // it as its per-rubric score dict.\n { outcome: { reward: 0, realness_gated: true, metrics: 0.95 as unknown as never } },\n ],\n errors: (subject) => {\n if (field(subject, 'realness_gated') !== true) return []\n const evidence = gatedEvidenceOf(subject)\n if (evidence === undefined) return []\n // Each check reports only the fields it owns; `steps` is `undeclared-step-payload`.\n if (evidence.metrics === undefined && evidence.verdict === undefined) return []\n const path = evidence.metrics !== undefined ? 'outcome.metrics' : 'outcome.verdict'\n return [\n `${path} is populated with outcome.realness_gated: true — a run flagged as gamed may not ` +\n 'ship the numbers its fabricated reward was computed from, even at reward 0. The ' +\n 'per-layer scores in `metrics` ARE the reward signal in the verifiers format, and ' +\n '`verdict` is the record that claimed the success. Mint through `assertMinted`, which ' +\n 'relocates both to `provenance.gated_evidence` (see `gateGamedOutcome`), or drop the line.',\n ]\n },\n}\n\n/**\n * A reward-bearing field hung on `steps[]`, where the gate was not looking.\n *\n * The first three checks all read `outcome`, so the whole apparatus was blind to\n * anything a producer wrote elsewhere on the line — and `toRewardRows` emits\n * `steps` verbatim beside the scalar it just forced to 0. A generated corpus\n * found it in twenty cases: a gated line carrying\n * `steps: [{kind, name, reward: 0.86}]` exported `{\"reward\": 0, \"steps\":\n * [{\"reward\": 0.86}]}`, which is the per-step credit assignment of a run that\n * faked its success, at full value, through the MINTED door.\n *\n * `RolloutStep` declares ten keys and none of them is a reward, so the partition\n * needs no judgement call: whatever the format does not name is unclassified\n * payload, and on a gated line unclassified payload is exactly what the gate\n * refuses. `assertMinted` relocates it rather than rejecting, like the sibling\n * check, so an already-published ledger stays readable.\n */\nconst undeclaredStepPayloadCheck: GateCheck = {\n id: 'undeclared-step-payload',\n refuses: 'per-step reward signal hung on a gated line’s steps, outside every field the gate read',\n tripwires: [\n {\n outcome: { reward: 0, realness_gated: true },\n steps: [{ kind: 'tool', name: 'edit', reward: 0.9 }],\n },\n ],\n errors: (subject) => {\n if (field(subject, 'realness_gated') !== true) return []\n const extra = undeclaredStepPayload(subject.steps)\n if (extra === undefined) return []\n return [\n `steps[] carries fields \\`${ROLLOUT_SCHEMA_NAME}\\` does not declare (${JSON.stringify(extra).slice(0, 120)}) ` +\n 'with outcome.realness_gated: true — a per-step reward is training signal exactly like ' +\n 'the scalar, and the exporters copy `steps` through verbatim, so zeroing `outcome.reward` ' +\n 'while leaving it in place ships the gamed run’s step-level credit assignment at full ' +\n 'value. Mint through `assertMinted`, which projects the steps down to the declared keys ' +\n 'and relocates the rest to `provenance.gated_evidence.steps` (see `gateGamedOutcome`).',\n ]\n },\n}\n\n/** Named here rather than imported, so `gate-checks` stays free of schema cycles. */\nconst ROLLOUT_SCHEMA_NAME = 'tangle.rollout.v1'\n\n/**\n * A positive reward whose producer DECLARED that no authenticity screen exists.\n *\n * `realness_gated: false` is the screen's VERDICT, so writing it with no screen\n * behind it claims \"we looked and nothing fired\" about a reward nobody looked\n * at. `realness_screened: false` is the producer saying so out loud, and a\n * positive reward carrying it is exactly the signal the gate exists to qualify\n * with nothing having qualified it.\n */\nconst unscreenedReward: GateCheck = {\n id: 'unscreened-reward',\n refuses: 'a positive reward whose producer declares that no authenticity screen ever ran',\n tripwires: [\n { outcome: { reward: 1, realness_gated: false, realness_screened: false } },\n {\n outcome: {\n reward: '2' as unknown as number,\n realness_gated: false,\n realness_screened: false,\n },\n },\n ],\n errors: (subject) => {\n if (field(subject, 'realness_screened') !== false) return []\n const reading = readReward(field(subject, 'reward'))\n if (reading.kind === 'absent' || reading.kind === 'cleared') return []\n return [\n `outcome.reward: ${reading.shown} with outcome.realness_screened: false — this producer declares ` +\n 'that NO authenticity screen ran on this reward, so nothing has established the success ' +\n 'is real, and an unscreened positive reward is exactly the signal the anti-Goodhart gate ' +\n 'exists to qualify. Screen the run and write the verdict (`rolloutRewardFields` from a ' +\n '`RunRecord` carrying `outcome.realness`), or emit `reward: null` — an unqualified ' +\n 'verdict is a labeled gap, not a measured success.',\n ]\n },\n}\n\n/**\n * The registry. Total over `GateCheckId`, so an id with no check does not\n * compile, and `GATE_CHECK_IDS` stays the single enumeration everything\n * iterates.\n */\nexport const GATE_CHECKS: { readonly [K in GateCheckId]: GateCheck } = {\n 'reward-relationship': rewardRelationship,\n 'gated-evidence': gatedEvidence,\n 'undeclared-step-payload': undeclaredStepPayloadCheck,\n 'unscreened-reward': unscreenedReward,\n}\n\n/**\n * What ONE entry point does about ONE check.\n *\n * `repair` and `omit` both carry a mandatory sentence, which is the mechanism\n * that keeps a legitimate omission distinguishable from a forgotten one: you\n * cannot skip a check without writing down why, and the reasons are readable\n * side by side in `GATE_POLICIES`.\n */\nexport type GateCheckDisposition =\n | { readonly kind: 'enforce' }\n /** Resolved by TRANSFORMING the line instead of rejecting it; `by` names the function. */\n | { readonly kind: 'repair'; readonly by: string }\n /** Deliberately not applied here; `because` states the reason. */\n | { readonly kind: 'omit'; readonly because: string }\n\nexport const enforced: GateCheckDisposition = { kind: 'enforce' }\nexport const repairedBy = (by: string): GateCheckDisposition => ({ kind: 'repair', by })\nexport const omittedBecause = (because: string): GateCheckDisposition => ({\n kind: 'omit',\n because,\n})\n\n/** Total over `GateCheckId`: a new check makes every policy literal a type error. */\nexport type GatePolicy = { readonly [K in GateCheckId]: GateCheckDisposition }\n\n/**\n * Every entry point that decides about the gate, and what it decides.\n *\n * Read this as the package's gate policy in one screen. The four entry points\n * are not interchangeable — a validator that rejects, a mint funnel that\n * repairs, a runtime backstop for untyped callers, and a release certifier over\n * emitted rows — and the dispositions say which is which.\n */\nexport const GATE_POLICIES = {\n /**\n * The schema validator. Rejects the reward relationship and NOTHING ELSE, on\n * purpose: it runs on every line read off disk, and the other two conditions\n * describe artifacts that already exist.\n */\n validateRolloutLine: {\n // Stays a REJECTION rather than a transformation. A caller emitting\n // `{reward: 0.95, realness_gated: true}` is a producer defect and has to\n // fail loudly; laundering it into `reward: 0` here would hide the producer,\n // which is the actual bug.\n 'reward-relationship': enforced,\n 'gated-evidence': omittedBecause(\n 'a ledger written before the relocation existed carries `metrics` on its gated lines; ' +\n 'rejecting those would make every already-published artifact unreadable. The condition ' +\n 'is REPAIRED at `assertMinted` (`gateGamedOutcome`) instead, which is the only door into ' +\n 'the training path, so the artifact stays readable and the leak still closes.',\n ),\n 'undeclared-step-payload': omittedBecause(\n 'identical reasoning to `gated-evidence`, one field over: a foreign or pre-unification ' +\n 'ledger may carry producer-invented keys on its steps, and refusing to READ those files ' +\n 'buys nothing the relocation at `assertMinted` does not already buy. Promotion into ' +\n 'training is where it closes.',\n ),\n 'unscreened-reward': omittedBecause(\n 'supervision-journal rows legitimately carry an unscreened positive reward (there is no ' +\n '`RunRecord.outcome.realness` behind them) and must stay writable, readable and ' +\n 'reportable. Only PROMOTION into training is closed, at `assertMinted`.',\n ),\n },\n /**\n * The mint funnel — the single door every `MintedRolloutLine` passes. Validates\n * first (so the reward relationship has already been rejected), then refuses\n * what cannot be repaired, then repairs what can.\n */\n assertMinted: {\n // Re-run after `assertRolloutLine`, which already rejected it. Cheap, and it\n // makes this entry point independently complete rather than complete only\n // because of what it happens to call first.\n 'reward-relationship': enforced,\n 'gated-evidence': repairedBy('gateGamedOutcome'),\n 'undeclared-step-payload': repairedBy('gateGamedOutcome'),\n 'unscreened-reward': enforced,\n },\n /**\n * The runtime backstop, and the one entry point with no license to omit\n * anything: it exists for callers the type system never saw (plain JavaScript\n * handing an object literal to a published exporter), so a check it skips is a\n * check that does not run at all for them. This is where the fourth leak was.\n */\n assertRewardGate: {\n 'reward-relationship': enforced,\n 'gated-evidence': enforced,\n 'undeclared-step-payload': enforced,\n 'unscreened-reward': enforced,\n },\n /**\n * The release certifier. Same checks, measured over the rows a release is\n * ABOUT TO WRITE rather than over one line's outcome — see `REPORT_MEASURES`\n * in `release/gate-report.ts`, which is the second total map this policy\n * drives.\n */\n assertGateReport: {\n 'reward-relationship': enforced,\n 'gated-evidence': enforced,\n 'undeclared-step-payload': enforced,\n 'unscreened-reward': enforced,\n },\n} as const satisfies Record<string, GatePolicy>\n\n/** Every entry point that declares a gate policy. */\nexport type GateEntryPoint = keyof typeof GATE_POLICIES\n\n/**\n * Run the checks one entry point enforces. The ONLY way an entry point should\n * obtain gate errors — hand-composing two of the three is the bug this module\n * exists to remove.\n */\nexport function gateErrors(subject: GateSubject, policy: GatePolicy): string[] {\n const errors: string[] = []\n for (const id of GATE_CHECK_IDS) {\n if (policy[id].kind !== 'enforce') continue\n errors.push(...GATE_CHECKS[id].errors(subject))\n }\n return errors\n}\n","/**\n * `tangle.rollout.v1` — THE canonical rollout serialization, owned by\n * agent-eval. One JSONL line per agent invocation (a solo eval run, a\n * supervisor episode, a worker session, a proposer shot, a judge call, an\n * analyst pass), labeled with its task/split coordinates and a single\n * scalar reward, carrying the FULL message transcript inline.\n *\n * This schema is the reconciliation of two prior producers:\n * - agent-eval's RunRecord-joined rollout rows (PR #410): identity,\n * provenance hashes, the realness gate travelling into the reward,\n * trace-derived steps.\n * - the bench rollout-ledger (agent-runtime PR #591): the wire shape —\n * role, task.split/rep, parent_rollout_id, policy provenance, capture\n * provenance, inline canonical chat-with-tools messages.\n * Where the two conflicted, RunRecord-derived semantics won; the wire\n * field names follow the ledger (snake_case). See `docs/rollout.md` for\n * the field-by-field decision table.\n *\n * Messages are inlined — never referenced — because every harness store a\n * rollout can be recovered from is mutable or garbage-collected. A line\n * must stay a complete training/eval example on its own.\n *\n * `outcome.reward` is THE single scalar (null = no verdict exists — a\n * labeled gap, never 0). `outcome.realness_gated` is the anti-Goodhart\n * flag: a gated line must never export as a positive training example.\n *\n * That last sentence is enforced here, by `validateRolloutLine`, not merely\n * documented. Validating `reward` and `realness_gated` independently — each a\n * well-typed field, their COMBINATION unchecked — is what let a line claiming\n * `{reward: 0.95, realness_gated: true}` validate clean and walk into every\n * training export. The relationship between the two IS the invariant, so it is\n * checked where every other structural claim about a line is checked.\n *\n * The invariant is about the OUTCOME, not about one field of it. Zeroing\n * `reward` while `outcome.metrics` still carried the per-layer scores that\n * reward was computed from exported the gamed signal anyway, in the dict the\n * verifiers format reads as its per-rubric scores. So `gateGamedOutcome`\n * transforms the whole outcome once, at `assertMinted` — the funnel every\n * minted line passes — and the reward-bearing components are relocated to\n * `provenance.gated_evidence`, which no exporter projects.\n *\n * WHICH checks each door applies is not decided in this file. `./gate-checks`\n * owns the canonical list and the total per-entry-point policy; the three doors\n * below (`validateRolloutLine`, `assertRewardGate`, `assertMinted`) each call\n * `gateErrors` with their declared policy, so a check added to that list applies\n * here without anyone editing this file, and a check deliberately skipped has to\n * name itself there.\n */\n\nimport { declaredSteps, GATE_POLICIES, gatedEvidenceOf, gateErrors } from './gate-checks'\n\nexport const ROLLOUT_SCHEMA = 'tangle.rollout.v1'\n\n/** `agent` = a solo evaluation run (no multi-agent topology). */\nexport type RolloutRole = 'agent' | 'supervisor' | 'worker' | 'proposer' | 'judge' | 'analyst'\nexport const ROLLOUT_ROLES: readonly RolloutRole[] = [\n 'agent',\n 'supervisor',\n 'worker',\n 'proposer',\n 'judge',\n 'analyst',\n]\n\n/** Split vocabulary follows `RunRecord.splitTag`, extended with `canary`. */\nexport type RolloutSplit = 'search' | 'dev' | 'holdout' | 'canary'\nexport const ROLLOUT_SPLITS: readonly RolloutSplit[] = ['search', 'dev', 'holdout', 'canary']\n/** Splits that may ship in training exports. Everything else is fail-closed excluded. */\nexport const TRAINABLE_SPLITS: readonly RolloutSplit[] = ['search']\n\nexport function isTrainableSplit(split: RolloutSplit): boolean {\n return TRAINABLE_SPLITS.includes(split)\n}\n\n/** 'mint' = joined live from RunRecord + trace by `mintRolloutRows`. */\nexport type RolloutCapture = 'mint' | 'settle-time' | 'backfill'\nexport const ROLLOUT_CAPTURES: readonly RolloutCapture[] = ['mint', 'settle-time', 'backfill']\n\n// ---------------------------------------------------------------------------\n// Canonical message format — OpenAI chat-with-tools, full fidelity.\n// ---------------------------------------------------------------------------\n\nexport type ChatRole = 'system' | 'user' | 'assistant' | 'tool'\nexport const CHAT_ROLES: readonly ChatRole[] = ['system', 'user', 'assistant', 'tool']\n\nexport interface ChatToolCall {\n id: string\n type: 'function'\n function: {\n name: string\n /** JSON-encoded argument object, exactly as the model emitted it. */\n arguments: string\n }\n}\n\nexport interface ChatMessage {\n role: ChatRole\n content: string | null\n /** Reasoning/thinking channel where the harness captured it (full fidelity). */\n reasoning_content?: string\n tool_calls?: ChatToolCall[]\n /** Required on role:\"tool\" — the ChatToolCall this result answers. */\n tool_call_id?: string\n name?: string\n /**\n * Harbor ATIF `is_copied_context` (RFC 0001 rule 7): this turn was COPIED IN\n * from another trajectory's context, not produced by the agent on this line.\n * The RFC makes excluding it from SFT a MUST, and `toSftRows` does — training\n * on it teaches the model to author text it never authored, and credits this\n * run for another one's work. Absent = false (authored here).\n */\n is_copied_context?: boolean\n}\n\nexport interface ToolDef {\n type: 'function'\n function: {\n name: string\n description?: string\n parameters?: Record<string, unknown>\n }\n}\n\n/**\n * Compact trace-span projection (llm/tool step) carried alongside the\n * conversation when the line was minted from a trace. Optional: lines\n * recovered from harness stores have no span structure.\n */\nexport interface RolloutStep {\n kind: string\n name: string\n /** llm: last-message summary · tool: stringified args. Scrubbed. */\n input?: string\n /** llm: output text · tool: stringified result. Scrubbed. */\n output?: string\n status?: 'ok' | 'error'\n durationMs?: number\n // The four fields below are lifted verbatim from Harbor ATIF's per-step\n // `metrics` (see `interchange/harbor.ts`); the wire names stay snake_case to\n // match that spec exactly, which is why they differ from `durationMs`.\n // All optional and never back-filled: an absent field means \"not captured\",\n // which is not the same claim as an empty array.\n /**\n * LLM inferences this span represents. 0 = deterministic dispatch with no\n * model call — distinct from absent, which means the producer did not track it.\n */\n llm_call_count?: number\n /** Exact prompt tokenization. Removes the ambiguity of re-tokenizing text at train time. */\n prompt_token_ids?: number[]\n /** Exact completion tokenization; aligns index-wise with `logprobs`. */\n completion_token_ids?: number[]\n /**\n * Per-completion-token log probabilities under the sampling policy. Required\n * for off-policy correction (importance weighting) when the rollout was\n * generated by a policy other than the one being trained.\n */\n logprobs?: number[]\n}\n\n// ---------------------------------------------------------------------------\n// Ledger line sections.\n// ---------------------------------------------------------------------------\n\nexport interface RolloutTask {\n /** Benchmark/suite id (e.g. \"swe-bench-verified\") or the experiment id. */\n suite: string\n instance_id: string\n split: RolloutSplit\n /** Sampling seed the campaign pinned; null = not recorded. */\n seed: number | null\n /** Replicate index (0-based). */\n rep: number\n}\n\nexport interface RolloutPolicy {\n /** Harness that drove the invocation (e.g. \"opencode\", \"claude\", \"pi-loops\"). */\n harness: string | null\n harness_version: string | null\n model: string | null\n provider: string | null\n /** Commit of the agent profile / candidate under evaluation. */\n profile_commit: string | null\n /** sha256 of the effective prompt (post-steering), when recorded. */\n prompt_hash?: string | null\n /** sha256 of the effective run config, when recorded. */\n config_hash?: string | null\n /** Canonical agent-profile cell identity, when the run carries one. */\n agent_profile_cell_id?: string | null\n /** Sampling params (temperature, top_p, max_tokens…); null = not recorded. */\n sampling: Record<string, unknown> | null\n}\n\nexport interface RolloutOutcome {\n /**\n * THE single scalar training signal — the official verdict.\n * null = no verdict exists for this invocation (a labeled gap, never 0).\n */\n reward: number | null\n /** Where the reward came from (judge id; \"/inherited\" = parent episode's). */\n reward_source: string | null\n /** Raw judge verdict record, verbatim. */\n verdict: unknown\n /** Everything that is NOT the scalar reward. */\n metrics: Record<string, unknown>\n is_completed: boolean\n is_truncated: boolean\n error: string | null\n /**\n * Anti-Goodhart flag from `RunRecord.outcome.realness.gated`: the run faked\n * its success signal. `true` requires `reward` to be 0 or null — the\n * validator rejects the line otherwise — and the line never qualifies for\n * SFT. Required on the wire: a line that does not state the flag does not\n * validate, so no producer can dodge the gate by omitting it.\n *\n * `true` ALSO requires `metrics` to be empty and `verdict` to be null: the\n * numbers the reward was computed from are relocated to\n * `provenance.gated_evidence` by `gateGamedOutcome`. See that function for\n * why zeroing the scalar alone was not enough.\n */\n realness_gated: boolean\n /**\n * Whether an authenticity SCREEN ever RAN on this reward — a different claim\n * from `realness_gated`, which is the screen's VERDICT.\n *\n * `realness_gated: false` reads as \"we looked and nothing fired\". A producer\n * with no screen at all was emitting exactly that, so a never-screened reward\n * was indistinguishable on the wire from a screened-clean one, and the whole\n * anti-Goodhart apparatus silently treated the first as the second. The two\n * claims are now separable:\n *\n * - `true` — a screen ran; `realness_gated` is its verdict.\n * - `false` — the producer declares it HAS no screen (`unscreenedRewardFields`).\n * `assertMinted` REFUSES such a line when its reward is above\n * zero: an unscreened positive reward is precisely the signal\n * the gate exists to qualify, and nothing has qualified it.\n * - absent — not stated. Pre-unification ledgers land here, as does a\n * `RunRecord` carrying no `outcome.realness` at all. Absent is\n * read as \"unknown\", never as `false` (which would refuse most\n * of the existing corpus) and never as `true`.\n */\n realness_screened?: boolean\n}\n\nexport interface RolloutCostBlock {\n usd: number | null\n tokens_in: number | null\n tokens_out: number | null\n tokens_reasoning: number | null\n cache_read: number | null\n cache_write: number | null\n wall_s: number | null\n /**\n * Total LLM inferences across the invocation (ATIF `llm_call_count`,\n * aggregated). Optional and additive: absent = not tracked, never 0.\n */\n llm_call_count?: number | null\n}\n\nexport interface RolloutArtifacts {\n patch_path: string | null\n run_dir: string | null\n /** Source-of-truth transcript pointer (session id / jsonl path) for audit. */\n transcript_ref: string | null\n}\n\n/**\n * The reward-bearing half of a GATED line's outcome, moved off `outcome` and\n * parked here verbatim. Diagnostics, never training input — see\n * `gateGamedOutcome`.\n */\nexport interface GatedEvidence {\n /** `outcome.metrics` exactly as the producer measured it. */\n metrics?: Record<string, unknown>\n /** `outcome.verdict` verbatim — the judge record that claimed the success. */\n verdict?: unknown\n /**\n * The per-step fields `tangle.rollout.v1` does not declare, parked here when\n * the gate projected `steps[]` down to the schema's own key set.\n *\n * A per-step reward is training signal exactly like the scalar, and `steps`\n * rides through `toRewardRows` verbatim — so a gated line was shipping its\n * step-level credit assignment at full value beside a `reward` of 0.\n */\n steps?: unknown\n}\n\nexport interface RolloutProvenance {\n captured_at: string\n capture: RolloutCapture\n /**\n * Why this line is incomplete. Required when `messages` is empty (the\n * transcript could not be recovered); also set by interchange importers to\n * name a MISSING LABEL — an imported trajectory carries no verdict, so\n * `outcome.reward` is null and this says why.\n */\n gap?: string\n /**\n * Present only on a realness-gated line: the outcome fields the gate\n * relocated, kept so an auditor can still see WHY the run was gated and what\n * it claimed. Deliberately OUTSIDE `outcome`, because every training exporter\n * reads `outcome` and none reads `provenance`.\n */\n gated_evidence?: GatedEvidence\n}\n\nexport interface RolloutLine {\n schema: typeof ROLLOUT_SCHEMA\n rollout_id: string\n /** Spawning invocation within the same episode (worker → supervisor). */\n parent_rollout_id: string | null\n run_id: string\n /** Logical experiment grouping from `RunRecord.experimentId`; null = not recorded. */\n experiment_id: string | null\n /** Stable candidate identity from `RunRecord.candidateId`; null = not recorded. */\n candidate_id: string | null\n /** Improvement-loop generation (-1 = baseline); null = not an improvement loop. */\n generation: number | null\n /** Improvement-loop candidate index (-1 = baseline); null = not an improvement loop. */\n candidate_index: number | null\n role: RolloutRole\n task: RolloutTask\n policy: RolloutPolicy\n /** Full transcript, inline. [] = gap line (see provenance.gap). */\n messages: ChatMessage[]\n tool_defs: ToolDef[]\n /** Trace-span projections, when minted from a trace. */\n steps?: RolloutStep[]\n outcome: RolloutOutcome\n cost: RolloutCostBlock\n artifacts: RolloutArtifacts\n provenance: RolloutProvenance\n}\n\n// ---------------------------------------------------------------------------\n// Validation — pure TS, no runtime schema dependency, mirroring the\n// run-record validator's fail-loud discipline. Returns [] when the value\n// is a valid RolloutLine; otherwise one dotted-path error per defect.\n// ---------------------------------------------------------------------------\n\nconst isRecord = (v: unknown): v is Record<string, unknown> =>\n typeof v === 'object' && v !== null && !Array.isArray(v)\n\nconst isNumberOrNull = (v: unknown): boolean => v === null || typeof v === 'number'\nconst isNumberArray = (v: unknown): boolean =>\n Array.isArray(v) && v.every((n) => typeof n === 'number' && Number.isFinite(n))\nconst isIntegerArray = (v: unknown): boolean =>\n Array.isArray(v) && v.every((n) => Number.isInteger(n))\nconst isStringOrNull = (v: unknown): boolean => v === null || typeof v === 'string'\nconst isIntegerOrNull = (v: unknown): boolean => v === null || Number.isInteger(v)\n\nfunction validateChatMessage(value: unknown, path: string, errors: string[]): void {\n if (!isRecord(value)) {\n errors.push(`${path}: not an object`)\n return\n }\n if (!CHAT_ROLES.includes(value.role as ChatRole))\n errors.push(`${path}.role: invalid role ${String(value.role)}`)\n if (!isStringOrNull(value.content)) errors.push(`${path}.content: must be string|null`)\n if (value.reasoning_content !== undefined && typeof value.reasoning_content !== 'string') {\n errors.push(`${path}.reasoning_content: must be string when present`)\n }\n if (value.tool_call_id !== undefined && typeof value.tool_call_id !== 'string') {\n errors.push(`${path}.tool_call_id: must be string when present`)\n }\n if (value.role === 'tool' && typeof value.tool_call_id !== 'string') {\n errors.push(`${path}.tool_call_id: required on role:\"tool\"`)\n }\n if (value.is_copied_context !== undefined && typeof value.is_copied_context !== 'boolean') {\n errors.push(`${path}.is_copied_context: must be boolean when present`)\n }\n if (value.tool_calls !== undefined) {\n if (!Array.isArray(value.tool_calls)) {\n errors.push(`${path}.tool_calls: must be an array when present`)\n } else {\n value.tool_calls.forEach((call, i) => {\n if (!isRecord(call) || typeof call.id !== 'string' || call.type !== 'function') {\n errors.push(`${path}.tool_calls[${i}]: must be {id, type:\"function\", function}`)\n return\n }\n const fn = call.function\n if (!isRecord(fn) || typeof fn.name !== 'string' || typeof fn.arguments !== 'string') {\n errors.push(\n `${path}.tool_calls[${i}].function: must be {name: string, arguments: string}`,\n )\n }\n })\n }\n }\n}\n\nfunction validateSection(\n value: unknown,\n path: string,\n fields: Array<[name: string, check: (v: unknown) => boolean, expect: string]>,\n errors: string[],\n): void {\n if (!isRecord(value)) {\n errors.push(`${path}: not an object`)\n return\n }\n for (const [name, check, expect] of fields) {\n if (!check(value[name])) errors.push(`${path}.${name}: expected ${expect}`)\n }\n}\n\n/**\n * THE anti-Goodhart gate, applied to the WHOLE outcome as a TRANSFORMATION.\n *\n * Two prior rounds enforced the gate as a CHECK ON ONE FIELD at N call sites,\n * and each round the next reward-bearing field leaked. The one that shipped:\n * `mintRolloutRows` bulk-copied `RunRecord.outcome.raw` into `outcome.metrics`\n * with no gate, so a gated run exported `reward: 0` (correct) while the\n * deterministic per-layer scores that reward was COMPUTED FROM — the\n * `layer.*` keys `rl/verifiable-reward.ts` calls the RL training signal —\n * shipped at 1.0, in the top-level `metrics` dict of the Prime Intellect\n * verifiers format, which IS that format's per-rubric score dict. `verdict`\n * leaks the same way into `toRftItem`'s `reference.verdict`, where a grader\n * author reads `resolved: true` off a run that faked it.\n *\n * So the rule is no longer \"zero the field we remembered\". It is: if the gate\n * fired, the outcome that leaves here carries NOTHING positive that was derived\n * from the reward, whichever field a present or future exporter decides to\n * read. `reward` is already forced to 0 upstream (`trainingReward`) and\n * REJECTED here if it is not; `metrics` and `verdict` are relocated.\n *\n * WHERE they go, and why relocation rather than deletion: zeroing destroys the\n * audit trail that shows why the run was gated and what it claimed, which is\n * the row an auditor most wants and the labeled example a gaming DETECTOR\n * trains on. `provenance.gated_evidence` keeps every byte, at a path no\n * training exporter reads — all four release configs and every `rl/exporters`\n * shape project from `outcome`, `messages`, `cost` and `task`; none projects\n * `provenance`. Auditability preserved, training signal removed, and a future\n * exporter that reads a field nobody thought of is safe by construction because\n * the field is empty rather than because the exporter remembered to check.\n *\n * Idempotent: a second application finds nothing left to move and returns the\n * line unchanged, so re-minting a line read back off a ledger cannot clobber\n * the evidence it already carries.\n */\nexport function gateGamedOutcome(line: RolloutLine): RolloutLine {\n if (line.outcome.realness_gated !== true) return line\n const moved = gatedEvidenceOf(line)\n if (moved === undefined) return line\n const kept = line.provenance.gated_evidence\n const evidence: GatedEvidence = {}\n const metrics = { ...kept?.metrics, ...moved.metrics }\n if (Object.keys(metrics).length > 0) evidence.metrics = metrics\n if (moved.verdict !== undefined) evidence.verdict = moved.verdict\n else if (kept?.verdict !== undefined) evidence.verdict = kept.verdict\n if (moved.steps !== undefined) evidence.steps = moved.steps\n else if (kept?.steps !== undefined) evidence.steps = kept.steps\n // The trajectory itself STAYS: a gamed transcript is the labeled example a\n // gaming detector trains on, and the exporters are meant to ship it. Only the\n // fields the wire format does not declare come off, which is the same\n // partition `gatedEvidenceOf` applies to `metrics` — the producer's own,\n // never a key-name guess.\n const steps = moved.steps === undefined ? line.steps : declaredSteps(line.steps)\n return {\n ...line,\n ...(steps === undefined ? {} : { steps }),\n outcome: { ...line.outcome, metrics: {}, verdict: null },\n provenance: { ...line.provenance, gated_evidence: evidence },\n }\n}\n\n/**\n * EVERY gate check, for the export path — the runtime backstop.\n *\n * `validateRolloutLine` checks the reward relationship too, but an exporter\n * cannot afford to re-validate every field of every line, and more importantly\n * it is not the exporter's job to re-check the schema — it is its job never to\n * emit a signal it was told is fabricated. Thrown rather than filtered: an\n * exporter silently dropping a poisoned line would hide the producer that made\n * it, and the producer is the actual defect.\n *\n * This is the third layer, and it exists for exactly one caller: JavaScript.\n * The brand stops TypeScript callers at compile time and `assertMinted` fixes\n * data arriving from disk, but neither is present for a plain JS consumer of\n * the published package handing an object literal to `toRewardRows`. Which is\n * exactly why this entry point's policy omits nothing: a check it skips is a\n * check that never runs for those callers at all. It composed two of the three\n * for one round, and a never-screened positive reward walked through all four\n * waist exporters at full value. `GATE_POLICIES.assertRewardGate` is now the\n * only place that list is written down.\n */\nexport function assertRewardGate(line: RolloutLine, context: string): void {\n const errors = gateErrors(line, GATE_POLICIES.assertRewardGate)\n if (errors.length > 0) {\n throw new Error(`${context}: rollout ${line.rollout_id} — ${errors[0]}`)\n }\n}\n\nexport function validateRolloutLine(value: unknown): string[] {\n const errors: string[] = []\n if (!isRecord(value)) return ['line: not an object']\n\n if (value.schema !== ROLLOUT_SCHEMA) errors.push(`schema: expected \"${ROLLOUT_SCHEMA}\"`)\n if (typeof value.rollout_id !== 'string' || value.rollout_id.length === 0)\n errors.push('rollout_id: expected non-empty string')\n if (!isStringOrNull(value.parent_rollout_id))\n errors.push('parent_rollout_id: expected string|null')\n if (typeof value.run_id !== 'string' || value.run_id.length === 0)\n errors.push('run_id: expected non-empty string')\n if (!isStringOrNull(value.experiment_id)) errors.push('experiment_id: expected string|null')\n if (!isStringOrNull(value.candidate_id)) errors.push('candidate_id: expected string|null')\n if (!isIntegerOrNull(value.generation)) errors.push('generation: expected integer|null')\n if (!isIntegerOrNull(value.candidate_index)) errors.push('candidate_index: expected integer|null')\n if (!ROLLOUT_ROLES.includes(value.role as RolloutRole))\n errors.push(`role: invalid role ${String(value.role)}`)\n\n validateSection(\n value.task,\n 'task',\n [\n ['suite', (v) => typeof v === 'string' && v.length > 0, 'non-empty string'],\n ['instance_id', (v) => typeof v === 'string' && v.length > 0, 'non-empty string'],\n [\n 'split',\n (v) => ROLLOUT_SPLITS.includes(v as RolloutSplit),\n `one of ${ROLLOUT_SPLITS.join('|')}`,\n ],\n ['seed', isNumberOrNull, 'number|null'],\n ['rep', (v) => Number.isInteger(v), 'integer'],\n ],\n errors,\n )\n\n validateSection(\n value.policy,\n 'policy',\n [\n ['harness', isStringOrNull, 'string|null'],\n ['harness_version', isStringOrNull, 'string|null'],\n ['model', isStringOrNull, 'string|null'],\n ['provider', isStringOrNull, 'string|null'],\n ['profile_commit', isStringOrNull, 'string|null'],\n ['sampling', (v) => v === null || isRecord(v), 'object|null'],\n ],\n errors,\n )\n if (isRecord(value.policy)) {\n for (const key of ['prompt_hash', 'config_hash', 'agent_profile_cell_id'] as const) {\n if (value.policy[key] !== undefined && !isStringOrNull(value.policy[key])) {\n errors.push(`policy.${key}: expected string|null when present`)\n }\n }\n }\n\n if (!Array.isArray(value.messages)) {\n errors.push('messages: expected array')\n } else {\n for (const [i, m] of value.messages.entries()) validateChatMessage(m, `messages[${i}]`, errors)\n }\n\n if (!Array.isArray(value.tool_defs)) {\n errors.push('tool_defs: expected array')\n } else {\n value.tool_defs.forEach((d, i) => {\n if (\n !isRecord(d) ||\n d.type !== 'function' ||\n !isRecord(d.function) ||\n typeof d.function.name !== 'string'\n ) {\n errors.push(`tool_defs[${i}]: must be {type:\"function\", function:{name}}`)\n }\n })\n }\n\n if (value.steps !== undefined) {\n if (!Array.isArray(value.steps)) {\n errors.push('steps: expected array when present')\n } else {\n value.steps.forEach((s, i) => {\n if (!isRecord(s) || typeof s.kind !== 'string' || typeof s.name !== 'string') {\n errors.push(`steps[${i}]: must be {kind: string, name: string, …}`)\n return\n }\n // ATIF-lifted optionals: absent on every line written before they\n // existed, so they are checked only when present — old ledgers stay valid.\n if (s.llm_call_count !== undefined && !Number.isInteger(s.llm_call_count)) {\n errors.push(`steps[${i}].llm_call_count: expected integer when present`)\n }\n for (const key of ['prompt_token_ids', 'completion_token_ids'] as const) {\n if (s[key] !== undefined && !isIntegerArray(s[key])) {\n errors.push(`steps[${i}].${key}: expected integer[] when present`)\n }\n }\n if (s.logprobs !== undefined && !isNumberArray(s.logprobs)) {\n errors.push(`steps[${i}].logprobs: expected number[] when present`)\n }\n })\n }\n }\n\n validateSection(\n value.outcome,\n 'outcome',\n [\n ['reward', isNumberOrNull, 'number|null'],\n ['reward_source', isStringOrNull, 'string|null'],\n ['metrics', isRecord, 'object'],\n ['is_completed', (v) => typeof v === 'boolean', 'boolean'],\n ['is_truncated', (v) => typeof v === 'boolean', 'boolean'],\n ['error', isStringOrNull, 'string|null'],\n ],\n errors,\n )\n if (isRecord(value.outcome)) {\n if (!('verdict' in value.outcome)) errors.push('outcome.verdict: field required (may be null)')\n if (typeof value.outcome.realness_gated !== 'boolean') {\n errors.push('outcome.realness_gated: expected boolean')\n }\n if (\n value.outcome.realness_screened !== undefined &&\n typeof value.outcome.realness_screened !== 'boolean'\n ) {\n errors.push('outcome.realness_screened: expected boolean when present')\n }\n errors.push(\n ...gateErrors(\n { outcome: value.outcome, steps: value.steps },\n GATE_POLICIES.validateRolloutLine,\n ),\n )\n }\n\n validateSection(\n value.cost,\n 'cost',\n [\n ['usd', isNumberOrNull, 'number|null'],\n ['tokens_in', isNumberOrNull, 'number|null'],\n ['tokens_out', isNumberOrNull, 'number|null'],\n ['tokens_reasoning', isNumberOrNull, 'number|null'],\n ['cache_read', isNumberOrNull, 'number|null'],\n ['cache_write', isNumberOrNull, 'number|null'],\n ['wall_s', isNumberOrNull, 'number|null'],\n ],\n errors,\n )\n if (\n isRecord(value.cost) &&\n value.cost.llm_call_count !== undefined &&\n !(value.cost.llm_call_count === null || Number.isInteger(value.cost.llm_call_count))\n ) {\n errors.push('cost.llm_call_count: expected integer|null when present')\n }\n\n validateSection(\n value.artifacts,\n 'artifacts',\n [\n ['patch_path', isStringOrNull, 'string|null'],\n ['run_dir', isStringOrNull, 'string|null'],\n ['transcript_ref', isStringOrNull, 'string|null'],\n ],\n errors,\n )\n\n validateSection(\n value.provenance,\n 'provenance',\n [\n [\n 'captured_at',\n (v) => typeof v === 'string' && !Number.isNaN(Date.parse(v)),\n 'ISO-8601 timestamp',\n ],\n [\n 'capture',\n (v) => ROLLOUT_CAPTURES.includes(v as RolloutCapture),\n `one of ${ROLLOUT_CAPTURES.join('|')}`,\n ],\n ],\n errors,\n )\n if (isRecord(value.provenance)) {\n if (value.provenance.gap !== undefined && typeof value.provenance.gap !== 'string') {\n errors.push('provenance.gap: must be string when present')\n }\n const evidence = value.provenance.gated_evidence\n if (evidence !== undefined) {\n if (!isRecord(evidence)) {\n errors.push('provenance.gated_evidence: must be an object when present')\n } else if (evidence.metrics !== undefined && !isRecord(evidence.metrics)) {\n errors.push('provenance.gated_evidence.metrics: must be an object when present')\n }\n }\n }\n\n // A gap line must say WHY it is a gap; a full line must not carry a gap note.\n if (Array.isArray(value.messages) && isRecord(value.provenance)) {\n if (value.messages.length === 0 && typeof value.provenance.gap !== 'string') {\n errors.push('provenance.gap: required when messages is empty')\n }\n }\n\n return errors\n}\n\nexport function assertRolloutLine(\n value: unknown,\n context = 'rollout line',\n): asserts value is RolloutLine {\n const errors = validateRolloutLine(value)\n if (errors.length > 0) {\n throw new Error(`invalid ${context}:\\n ${errors.join('\\n ')}`)\n }\n}\n\nexport function isRolloutLine(value: unknown): value is RolloutLine {\n return validateRolloutLine(value).length === 0\n}\n\n// ---------------------------------------------------------------------------\n// The minted brand — the COMPILE-TIME half of the anti-Goodhart gate.\n// ---------------------------------------------------------------------------\n\n/**\n * Phantom property. `declare const` means it exists only in the type system:\n * nothing is written at runtime, so a branded line still serializes to exactly\n * the same JSON as a plain one.\n */\ndeclare const MINTED_ROLLOUT: unique symbol\n\n/**\n * A minted outcome states the gate verdict — it is not allowed to stay silent —\n * and, when that verdict is `true`, carries nothing else the reward was derived\n * from (`gateGamedOutcome` has run).\n */\nexport interface MintedRolloutOutcome extends RolloutOutcome {\n realness_gated: boolean\n}\n\n/**\n * A `RolloutLine` whose reward has been checked against the anti-Goodhart\n * invariant. The type every training-data exporter takes.\n *\n * Why a brand and not just the interface: `RolloutLine` is structural, so any\n * hand-built object literal of the right shape IS one — which is how a line\n * declaring `{reward: 0.95, realness_gated: true}` reached the exporters\n * despite them \"only accepting a minted line\". The phantom symbol makes the\n * type nominal: it cannot be produced by writing an object literal, only by\n * `mintRolloutRows` (which applies the gate), `readRolloutLedger` (which\n * validates every line off disk), or an explicit, greppable `assertMinted`.\n *\n * Belt and braces on purpose. The brand closes first-party call sites at\n * COMPILE time; `validateRolloutLine` closes data arriving at RUNTIME (ledger\n * files, foreign imports, JSON from another process) where types are absent.\n * Neither alone is enough.\n *\n * Assignable to `RolloutLine` in one direction only: readers, analysis, and\n * the ledger writer keep taking the plain type.\n */\nexport type MintedRolloutLine = Omit<RolloutLine, 'outcome'> & {\n readonly [MINTED_ROLLOUT]: true\n outcome: MintedRolloutOutcome\n}\n\n/**\n * Promote a line to the type the training exporters accept, applying the\n * anti-Goodhart gate to the WHOLE outcome on the way through. THE escape hatch\n * — grep `assertMinted` to enumerate every place a line enters the training\n * path without coming from mint or a ledger.\n *\n * The gate runs HERE, once, rather than at each producer, because this is the\n * single funnel every minted line passes: `mintRolloutRows` calls it,\n * `readRolloutLedger` calls it per line off disk, `scrubLines` calls it on the\n * way out of a release, and a hand-built line has no other door. One\n * transformation at the funnel means an already-published ledger holding a\n * gated line with populated `metrics` is RE-GATED when it is read, instead of\n * being rejected (which would make every such artifact unreadable) or trusted\n * (which is the leak). Three steps, in this order:\n *\n * 1. VALIDATE the schema.\n * 2. REFUSE every check `GATE_POLICIES.assertMinted` marks `enforce` — today\n * the reward relationship (which stays a REJECTION: a caller claiming\n * `{reward: 0.95, realness_gated: true}` is a producer defect and must fail\n * loudly, since laundering it into `reward: 0` here would hide the\n * producer) and a positive reward the producer declared it never screened.\n * 3. TRANSFORM the one check that policy marks `repair` — relocate the\n * reward's components off `outcome` (`gateGamedOutcome`), so no exporter\n * can leak them whichever field it reads.\n *\n * Step 2 enumerates nothing by hand: a check added to `GATE_CHECKS` is enforced\n * here the moment its disposition in that policy says so.\n *\n * Also normalizes the optional wire flag to an explicit boolean.\n * `realness_gated` is absent on pre-unification ledgers and absent means \"not\n * flagged\" per the schema, so filling it in states a claim the line was already\n * making, and makes the flag readable on every published row instead of most of\n * them. `realness_screened` is NOT filled in: absent means \"unknown\", and\n * inventing either value there would be the same overclaim this round removed.\n */\nexport function assertMinted(value: unknown, context = 'rollout line'): MintedRolloutLine {\n assertRolloutLine(value, context)\n const refused = gateErrors(value, GATE_POLICIES.assertMinted)\n if (refused.length > 0) {\n throw new Error(`invalid ${context}: rollout ${value.rollout_id} — ${refused[0]}`)\n }\n const gated = gateGamedOutcome(value)\n if (gated.outcome.realness_gated === undefined) {\n return {\n ...gated,\n outcome: { ...gated.outcome, realness_gated: false },\n } as MintedRolloutLine\n }\n return gated as MintedRolloutLine\n}\n\n/** `assertMinted` over a batch, naming the offending index in the error. */\nexport function assertMintedLines(\n values: readonly unknown[],\n context = 'rollout line',\n): MintedRolloutLine[] {\n return values.map((value, i) => assertMinted(value, `${context} [${i}]`))\n}\n"],"mappings":";;;;;;;;AA2CA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;AACF;;AAqCA,MAAM,SAAS,SAAsB,SAClC,QAAQ,UAAgD;AAkD3D,SAAgB,WAAW,OAA+B;CACxD,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO,EAAE,MAAM,SAAS;CACnE,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,OAAO,M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AO,KAAK,OAAO,MAAM,aAAa,OAAO,GAAG,QAAQ,IAAI,EAAE,EAAE,CAAC;AAC1E"}
@@ -0,0 +1,69 @@
1
+ //#region src/trace/schema.ts
2
+ /**
3
+ * TraceSchema v1 — the canonical data model for agent-eval.
4
+ *
5
+ * Every score, every failure class, every pipeline in the framework is
6
+ * a view over this data. Shape it once, live with it.
7
+ *
8
+ * Wire-compatible with OpenTelemetry span semantics (see trace/otel.ts)
9
+ * but extended with agent-specific span kinds (llm, tool, retrieval,
10
+ * judge, sandbox) and first-class BudgetLedger / Artifact / JudgeVerdict
11
+ * entities that OTEL leaves as free-form attributes.
12
+ */
13
+ const TRACE_SCHEMA_VERSION = "1.0.0";
14
+ const FAILURE_CLASSES = [
15
+ "success",
16
+ "reasoning_error",
17
+ "tool_selection_error",
18
+ "tool_argument_error",
19
+ "tool_recovery_failure",
20
+ "hallucination",
21
+ "instruction_following",
22
+ "safety_refusal_miss",
23
+ "policy_violation",
24
+ "budget_exceeded",
25
+ "format_drift",
26
+ "permission_escalation",
27
+ "pii_leak",
28
+ "cost_overrun",
29
+ "timeout",
30
+ "sandbox_failure",
31
+ "missing_user_data",
32
+ "missing_domain_data",
33
+ "missing_codebase_context",
34
+ "missing_runtime_context",
35
+ "missing_credentials",
36
+ "missing_integration_connection",
37
+ "missing_integration_scope",
38
+ "integration_approval_required",
39
+ "integration_auth_expired",
40
+ "integration_provider_failure",
41
+ "bad_integration_manifest",
42
+ "unsafe_integration_write_denied",
43
+ "stale_external_data",
44
+ "bad_retrieval",
45
+ "insufficient_evidence",
46
+ "contradictory_evidence",
47
+ "ambiguous_user_intent",
48
+ "knowledge_readiness_blocked",
49
+ "unknown"
50
+ ];
51
+ function isLlmSpan(s) {
52
+ return s.kind === "llm";
53
+ }
54
+ function isToolSpan(s) {
55
+ return s.kind === "tool";
56
+ }
57
+ function isRetrievalSpan(s) {
58
+ return s.kind === "retrieval";
59
+ }
60
+ function isJudgeSpan(s) {
61
+ return s.kind === "judge";
62
+ }
63
+ function isSandboxSpan(s) {
64
+ return s.kind === "sandbox";
65
+ }
66
+ //#endregion
67
+ export { isRetrievalSpan as a, isLlmSpan as i, TRACE_SCHEMA_VERSION as n, isSandboxSpan as o, isJudgeSpan as r, isToolSpan as s, FAILURE_CLASSES as t };
68
+
69
+ //# sourceMappingURL=schema-CRhEY1SO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-CRhEY1SO.js","names":[],"sources":["../src/trace/schema.ts"],"sourcesContent":["/**\n * TraceSchema v1 — the canonical data model for agent-eval.\n *\n * Every score, every failure class, every pipeline in the framework is\n * a view over this data. Shape it once, live with it.\n *\n * Wire-compatible with OpenTelemetry span semantics (see trace/otel.ts)\n * but extended with agent-specific span kinds (llm, tool, retrieval,\n * judge, sandbox) and first-class BudgetLedger / Artifact / JudgeVerdict\n * entities that OTEL leaves as free-form attributes.\n */\n\nexport const TRACE_SCHEMA_VERSION = '1.0.0'\n\n// ── Run ──────────────────────────────────────────────────────────────\n\nexport type RunStatus = 'running' | 'completed' | 'failed' | 'aborted'\n\nexport interface BudgetSpec {\n tokens?: number\n wallMs?: number\n calls?: number\n usd?: number\n}\n\nexport interface RunOutcome {\n score?: number\n pass?: boolean\n failureClass?: FailureClass\n notes?: string\n}\n\n/**\n * Layer — optional classification in a nested build workflow.\n * `builder`: the meta-agent editing a project (e.g. agent-builder Forge chat).\n * `app-build`: sandbox harness that compiled + tested the generated scaffold.\n * `app-runtime`: a run of the generated agent against a domain scenario.\n * `meta`: any meta-eval (judge replay, correlation analysis).\n */\nexport type RunLayer = 'builder' | 'app-build' | 'app-runtime' | 'meta' | 'custom'\n\nexport interface Run {\n runId: string\n /**\n * Stable identifier of the scenario being executed.\n *\n * Always populated on the persisted Run — but `TraceEmitter.startRun` accepts\n * input WITHOUT this field, substituting a sensible default\n * (`run.layer ?? run.tags?.['kind'] ?? 'runtime'`) when the caller has no\n * curated scenario to anchor to (runtime / operator / meta-eval runs). This\n * keeps the persisted shape unambiguous for downstream filters + aggregations\n * while removing the boilerplate of inventing placeholder ids at the call site.\n */\n scenarioId: string\n variantId?: string\n datasetVersion?: string\n /** Git SHA of agent code at run time. */\n codeSha?: string\n /** Hash of the prompt template + any system prompt. */\n promptSha?: string\n /** Model id + date + system-prompt hash, concatenated. */\n modelFingerprint?: string\n seed?: number\n /** Arbitrary environment markers (shell, docker version, tz). */\n envFingerprint?: Record<string, string>\n /** Version of the redaction rules applied to this run. */\n redactionVersion?: string\n /** Parent run in a nested build workflow. A builder run's children are\n * app-build runs; those children are app-runtime runs. */\n parentRunId?: string\n /** Stable project identifier — groups runs across chats + sessions. */\n projectId?: string\n /** Chat/conversation identifier within a project. */\n chatId?: string\n /** Layer classification — hint for aggregation; not enforced. */\n layer?: RunLayer\n startedAt: number\n endedAt?: number\n status: RunStatus\n outcome?: RunOutcome\n budget?: BudgetSpec\n /** Free-form labels for downstream grouping. */\n tags?: Record<string, string>\n}\n\n// ── Spans (hierarchical work units) ──────────────────────────────────\n\nexport type SpanKind = 'agent' | 'llm' | 'tool' | 'retrieval' | 'judge' | 'sandbox' | 'custom'\n\nexport type SpanStatus = 'ok' | 'error'\n\nexport interface SpanBase {\n spanId: string\n parentSpanId?: string\n runId: string\n kind: SpanKind\n name: string\n startedAt: number\n endedAt?: number\n status?: SpanStatus\n error?: string\n /** Anything not covered by typed fields. Kept deliberately free-form. */\n attributes?: Record<string, unknown>\n}\n\nexport interface Message {\n role: 'system' | 'user' | 'assistant' | 'tool'\n content: string\n tokens?: number\n /** Multi-modal content descriptors; blobs themselves live in Artifacts. */\n images?: Array<{ artifactId?: string; url?: string; mime?: string }>\n}\n\nexport interface LlmSpan extends SpanBase {\n kind: 'llm'\n model: string\n messages: Message[]\n output?: string\n inputTokens?: number\n /** All generated tokens, including the reasoning subset when present. */\n outputTokens?: number\n cachedTokens?: number\n cacheWriteTokens?: number\n /** Reasoning-token subset of `outputTokens`. */\n reasoningTokens?: number\n costUsd?: number\n finishReason?: string\n}\n\nexport interface ToolSpan extends SpanBase {\n kind: 'tool'\n toolName: string\n args: unknown\n /** False when the source observed the call but did not capture its arguments. */\n argsCaptured?: boolean\n result?: unknown\n latencyMs?: number\n}\n\nexport interface RetrievalSpan extends SpanBase {\n kind: 'retrieval'\n query: string\n hits: Array<{ docId: string; score: number; content?: string }>\n}\n\nexport interface JudgeSpan extends SpanBase {\n kind: 'judge'\n judgeId: string\n /** Span this judgment applies to. */\n targetSpanId: string\n dimension: string\n /** Numeric score (free-range; interpretation up to the judge). */\n score: number\n rationale?: string\n evidence?: string\n}\n\nexport interface SandboxSpan extends SpanBase {\n kind: 'sandbox'\n image?: string\n command?: string\n exitCode?: number\n testsTotal?: number\n testsPassed?: number\n stdoutHash?: string\n stderrHash?: string\n /** Duration in ms; the harness fills this explicitly (endedAt - startedAt may miss setup). */\n wallMs?: number\n}\n\nexport interface GenericSpan extends SpanBase {\n kind: 'agent' | 'custom'\n}\n\nexport type Span = LlmSpan | ToolSpan | RetrievalSpan | JudgeSpan | SandboxSpan | GenericSpan\n\n// ── Events (point-in-time occurrences within a span) ─────────────────\n\nexport type EventKind =\n | 'log'\n | 'error'\n | 'budget_decrement'\n | 'budget_breach'\n | 'state_mutation'\n | 'policy_violation'\n | 'redaction_applied'\n | 'custom'\n\nexport interface TraceEvent {\n eventId: string\n runId: string\n spanId?: string\n kind: EventKind\n timestamp: number\n payload: Record<string, unknown>\n}\n\n// ── Budget ledger (running token/wall/call/$ accounting) ─────────────\n\nexport interface BudgetLedgerEntry {\n runId: string\n dimension: keyof BudgetSpec\n limit: number\n consumed: number\n remaining: number\n timestamp: number\n breached: boolean\n /** Span that triggered this entry, if any. */\n spanId?: string\n}\n\n// ── Artifacts (blobs addressed by hash) ──────────────────────────────\n\nexport interface Artifact {\n artifactId: string\n runId: string\n spanId?: string\n contentType: string\n sizeBytes: number\n /** sha256 in hex. */\n hash: string\n /** External storage URL (R2, S3, filesystem path). */\n storageUrl?: string\n /** Inline content for small blobs — keep under ~64KB. */\n inlineContent?: string\n}\n\n// ── Failure taxonomy ─────────────────────────────────────────────────\n\nexport type FailureClass =\n | 'success'\n | 'reasoning_error'\n | 'tool_selection_error'\n | 'tool_argument_error'\n | 'tool_recovery_failure'\n | 'hallucination'\n | 'instruction_following'\n | 'safety_refusal_miss'\n | 'policy_violation'\n | 'budget_exceeded'\n | 'format_drift'\n | 'permission_escalation'\n | 'pii_leak'\n | 'cost_overrun'\n | 'timeout'\n | 'sandbox_failure'\n | 'missing_user_data'\n | 'missing_domain_data'\n | 'missing_codebase_context'\n | 'missing_runtime_context'\n | 'missing_credentials'\n | 'missing_integration_connection'\n | 'missing_integration_scope'\n | 'integration_approval_required'\n | 'integration_auth_expired'\n | 'integration_provider_failure'\n | 'bad_integration_manifest'\n | 'unsafe_integration_write_denied'\n | 'stale_external_data'\n | 'bad_retrieval'\n | 'insufficient_evidence'\n | 'contradictory_evidence'\n | 'ambiguous_user_intent'\n | 'knowledge_readiness_blocked'\n | 'unknown'\n\nexport const FAILURE_CLASSES: readonly FailureClass[] = [\n 'success',\n 'reasoning_error',\n 'tool_selection_error',\n 'tool_argument_error',\n 'tool_recovery_failure',\n 'hallucination',\n 'instruction_following',\n 'safety_refusal_miss',\n 'policy_violation',\n 'budget_exceeded',\n 'format_drift',\n 'permission_escalation',\n 'pii_leak',\n 'cost_overrun',\n 'timeout',\n 'sandbox_failure',\n 'missing_user_data',\n 'missing_domain_data',\n 'missing_codebase_context',\n 'missing_runtime_context',\n 'missing_credentials',\n 'missing_integration_connection',\n 'missing_integration_scope',\n 'integration_approval_required',\n 'integration_auth_expired',\n 'integration_provider_failure',\n 'bad_integration_manifest',\n 'unsafe_integration_write_denied',\n 'stale_external_data',\n 'bad_retrieval',\n 'insufficient_evidence',\n 'contradictory_evidence',\n 'ambiguous_user_intent',\n 'knowledge_readiness_blocked',\n 'unknown',\n] as const\n\n// ── Helpers ──────────────────────────────────────────────────────────\n\nexport function isLlmSpan(s: Span): s is LlmSpan {\n return s.kind === 'llm'\n}\nexport function isToolSpan(s: Span): s is ToolSpan {\n return s.kind === 'tool'\n}\nexport function isRetrievalSpan(s: Span): s is RetrievalSpan {\n return s.kind === 'retrieval'\n}\nexport function isJudgeSpan(s: Span): s is JudgeSpan {\n return s.kind === 'judge'\n}\nexport function isSandboxSpan(s: Span): s is SandboxSpan {\n return s.kind === 'sandbox'\n}\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,uBAAuB;AA8PpC,MAAa,kBAA2C;CACtD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,SAAgB,UAAU,GAAuB;CAC/C,OAAO,EAAE,SAAS;AACpB;AACA,SAAgB,WAAW,GAAwB;CACjD,OAAO,EAAE,SAAS;AACpB;AACA,SAAgB,gBAAgB,GAA6B;CAC3D,OAAO,EAAE,SAAS;AACpB;AACA,SAAgB,YAAY,GAAyB;CACnD,OAAO,EAAE,SAAS;AACpB;AACA,SAAgB,cAAc,GAA2B;CACvD,OAAO,EAAE,SAAS;AACpB"}