@tangle-network/agent-eval 0.217.1 → 0.219.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/CHANGELOG.md +57 -1
  2. package/dist/adapters/http.d.ts +3 -3
  3. package/dist/adapters/http.d.ts.map +1 -1
  4. package/dist/adapters/http.js +1 -0
  5. package/dist/adapters/http.js.map +1 -1
  6. package/dist/{agent-profile-DTt8uGP9.d.ts → agent-profile-D01Io2Xw.d.ts} +4 -4
  7. package/dist/{agent-profile-DTt8uGP9.d.ts.map → agent-profile-D01Io2Xw.d.ts.map} +1 -1
  8. package/dist/analyst/index.d.ts +13 -13
  9. package/dist/analyst/index.d.ts.map +1 -1
  10. package/dist/analyst/index.js +10 -10
  11. package/dist/analyst/index.js.map +1 -1
  12. package/dist/{analyze-runs-DyeNcenW.d.ts → analyze-runs-BWAHBDAw.d.ts} +4 -4
  13. package/dist/{analyze-runs-DyeNcenW.d.ts.map → analyze-runs-BWAHBDAw.d.ts.map} +1 -1
  14. package/dist/{benchmark-command-xQK8nOI6.js → benchmark-command-BzmMTnvC.js} +664 -565
  15. package/dist/benchmark-command-BzmMTnvC.js.map +1 -0
  16. package/dist/benchmarks/index.d.ts +5 -5
  17. package/dist/benchmarks/index.js +3 -3
  18. package/dist/benchmarks/index.js.map +1 -1
  19. package/dist/campaign/index.d.ts +8 -8
  20. package/dist/campaign/index.js +11 -11
  21. package/dist/{campaign-CJGkxAQ6.js → campaign-BVPC6ODQ.js} +452 -282
  22. package/dist/campaign-BVPC6ODQ.js.map +1 -0
  23. package/dist/{campaign-evidence-CQYw8_0H.js → campaign-evidence-DunzcJGv.js} +2 -2
  24. package/dist/campaign-evidence-DunzcJGv.js.map +1 -0
  25. package/dist/{chat-client-ldqxYYTN.js → chat-client-CMQ8_h4J.js} +2 -2
  26. package/dist/{chat-client-ldqxYYTN.js.map → chat-client-CMQ8_h4J.js.map} +1 -1
  27. package/dist/{chat-json-call-DavzexSp.js → chat-json-call-BrZKn0L3.js} +2 -2
  28. package/dist/{chat-json-call-DavzexSp.js.map → chat-json-call-BrZKn0L3.js.map} +1 -1
  29. package/dist/cli.js +10 -10
  30. package/dist/{completion-verifier-B_jw6C9p.js → completion-verifier-Cigap8CG.js} +5 -5
  31. package/dist/{completion-verifier-B_jw6C9p.js.map → completion-verifier-Cigap8CG.js.map} +1 -1
  32. package/dist/contract/index.d.ts +11 -11
  33. package/dist/contract/index.js +91 -11
  34. package/dist/contract/index.js.map +1 -1
  35. package/dist/{cost-ledger-D0352Z4d.js → cost-ledger-BGZB6yY2.js} +75 -2
  36. package/dist/cost-ledger-BGZB6yY2.js.map +1 -0
  37. package/dist/{cost-ledger-Jk62OBfF.d.ts → cost-ledger-C1W3ICmP.d.ts} +26 -2
  38. package/dist/cost-ledger-C1W3ICmP.d.ts.map +1 -0
  39. package/dist/{default-registry-ClYjq3QE.js → default-registry-BrKmT01n.js} +310 -278
  40. package/dist/{default-registry-ClYjq3QE.js.map → default-registry-BrKmT01n.js.map} +1 -1
  41. package/dist/{default-registry-DXgLmoDI.d.ts → default-registry-Cwg_QN3d.d.ts} +6 -6
  42. package/dist/{default-registry-DXgLmoDI.d.ts.map → default-registry-Cwg_QN3d.d.ts.map} +1 -1
  43. package/dist/{define-agent-eval-BIkH_gAR.d.ts → define-agent-eval-C2nFhHPu.d.ts} +8 -8
  44. package/dist/{define-agent-eval-BIkH_gAR.d.ts.map → define-agent-eval-C2nFhHPu.d.ts.map} +1 -1
  45. package/dist/{define-agent-eval-BDxNlP3D.js → define-agent-eval-UQY3VbJ2.js} +165 -105
  46. package/dist/define-agent-eval-UQY3VbJ2.js.map +1 -0
  47. package/dist/diagnosis/index.d.ts +2 -2
  48. package/dist/{dspy-rlm-engine-DhdCr1Dc.js → dspy-rlm-engine-Bn_Mt_LW.js} +3 -3
  49. package/dist/{dspy-rlm-engine-DhdCr1Dc.js.map → dspy-rlm-engine-Bn_Mt_LW.js.map} +1 -1
  50. package/dist/{engine-BvZ0R-36.d.ts → engine-BpGGw6cd.d.ts} +3 -3
  51. package/dist/{engine-BvZ0R-36.d.ts.map → engine-BpGGw6cd.d.ts.map} +1 -1
  52. package/dist/eval-campaign-BUMIxKTE.js +393 -0
  53. package/dist/eval-campaign-BUMIxKTE.js.map +1 -0
  54. package/dist/{evaluation-jTjC_QQD.d.ts → evaluation-CBdQt_kr.d.ts} +4 -4
  55. package/dist/{evaluation-jTjC_QQD.d.ts.map → evaluation-CBdQt_kr.d.ts.map} +1 -1
  56. package/dist/evaluation.d.ts +1 -1
  57. package/dist/evaluation.js +1 -1
  58. package/dist/{exact-types-CflbJ9f3.d.ts → exact-types-BYFmYq44.d.ts} +2 -2
  59. package/dist/{exact-types-CflbJ9f3.d.ts.map → exact-types-BYFmYq44.d.ts.map} +1 -1
  60. package/dist/experiment/index.d.ts +24 -1
  61. package/dist/experiment/index.d.ts.map +1 -1
  62. package/dist/experiment/index.js +110 -71
  63. package/dist/experiment/index.js.map +1 -1
  64. package/dist/{exporters-Cl6IeNAu.js → exporters-DWvM16LE.js} +2 -2
  65. package/dist/{exporters-Cl6IeNAu.js.map → exporters-DWvM16LE.js.map} +1 -1
  66. package/dist/{external-optimizer-process-KVFGvYX1.js → external-optimizer-process-wOLfzsCC.js} +2 -2
  67. package/dist/{external-optimizer-process-KVFGvYX1.js.map → external-optimizer-process-wOLfzsCC.js.map} +1 -1
  68. package/dist/{external-optimizer-subprocess-XIHBOSKt.js → external-optimizer-subprocess-D670Oxf2.js} +4 -4
  69. package/dist/{external-optimizer-subprocess-XIHBOSKt.js.map → external-optimizer-subprocess-D670Oxf2.js.map} +1 -1
  70. package/dist/{feedback-trajectory-BWmhRBGu.d.ts → feedback-trajectory-DhB9WzYg.d.ts} +3 -3
  71. package/dist/{feedback-trajectory-BWmhRBGu.d.ts.map → feedback-trajectory-DhB9WzYg.d.ts.map} +1 -1
  72. package/dist/{findings-store-BMVQtEsm.js → findings-store-CvNo712L.js} +6 -6
  73. package/dist/{findings-store-BMVQtEsm.js.map → findings-store-CvNo712L.js.map} +1 -1
  74. package/dist/fuzz.d.ts +1 -1
  75. package/dist/fuzz.js +1 -1
  76. package/dist/{hf-dataset-D9f7-oX7.js → hf-dataset-CKxIJQba.js} +3 -3
  77. package/dist/{hf-dataset-D9f7-oX7.js.map → hf-dataset-CKxIJQba.js.map} +1 -1
  78. package/dist/hosted/index.js +1 -1
  79. package/dist/{index-CX-GAUpw.d.ts → index-CHxwfW5g.d.ts} +2 -2
  80. package/dist/{index-CX-GAUpw.d.ts.map → index-CHxwfW5g.d.ts.map} +1 -1
  81. package/dist/{index-BLGqZ81N.d.ts → index-CVFStrQD.d.ts} +8 -8
  82. package/dist/{index-BLGqZ81N.d.ts.map → index-CVFStrQD.d.ts.map} +1 -1
  83. package/dist/{index-9jJ2fKSX.d.ts → index-CalAsXMR.d.ts} +7 -5
  84. package/dist/index-CalAsXMR.d.ts.map +1 -0
  85. package/dist/{index-CiRwLv2R.d.ts → index-D7fmC-1K.d.ts} +3 -4
  86. package/dist/index-D7fmC-1K.d.ts.map +1 -0
  87. package/dist/{index-BiT6RtNH.d.ts → index-DAXfpVf7.d.ts} +10 -10
  88. package/dist/{index-BiT6RtNH.d.ts.map → index-DAXfpVf7.d.ts.map} +1 -1
  89. package/dist/{index-ZuWx52WG.d.ts → index-Q6DvdcwI.d.ts} +67 -24
  90. package/dist/index-Q6DvdcwI.d.ts.map +1 -0
  91. package/dist/index.d.ts +26 -26
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +615 -692
  94. package/dist/index.js.map +1 -1
  95. package/dist/{integrity-DOd9Q86O.js → integrity-C8oUeB0g.js} +322 -197
  96. package/dist/integrity-C8oUeB0g.js.map +1 -0
  97. package/dist/{integrity-_qgZLA5p.d.ts → integrity-CCwvezWS.d.ts} +2 -2
  98. package/dist/{integrity-_qgZLA5p.d.ts.map → integrity-CCwvezWS.d.ts.map} +1 -1
  99. package/dist/{journal-CR4QikYp.js → journal-C7om8Gum.js} +48 -38
  100. package/dist/journal-C7om8Gum.js.map +1 -0
  101. package/dist/judge-gate-Co5tuh57.js.map +1 -1
  102. package/dist/{judge-gate-DsL0yFcb.d.ts → judge-gate-Dc_mXQsL.d.ts} +2 -2
  103. package/dist/judge-gate-Dc_mXQsL.d.ts.map +1 -0
  104. package/dist/{kind-factory-Gy4fXixd.js → kind-factory-BhxbtUsQ.js} +2 -2
  105. package/dist/{kind-factory-Gy4fXixd.js.map → kind-factory-BhxbtUsQ.js.map} +1 -1
  106. package/dist/ledger-core/index.d.ts +1 -1
  107. package/dist/ledger-core/index.js +2 -2
  108. package/dist/ledger-core/lock-holder.d.ts +2 -0
  109. package/dist/ledger-core/lock-holder.js +181 -0
  110. package/dist/ledger-core/lock-holder.js.map +1 -0
  111. package/dist/{ledger-core-DrJhbms9.js → ledger-core-CAxUdDk0.js} +2 -2
  112. package/dist/{ledger-core-DrJhbms9.js.map → ledger-core-CAxUdDk0.js.map} +1 -1
  113. package/dist/{llm-client-BshCREn6.js → llm-client-DXuOTseU.js} +239 -249
  114. package/dist/llm-client-DXuOTseU.js.map +1 -0
  115. package/dist/{llm-judge-C8jMTNNG.js → llm-judge-Cc8vDJh_.js} +648 -459
  116. package/dist/llm-judge-Cc8vDJh_.js.map +1 -0
  117. package/dist/lock-holder-DaJbfpci.d.ts +86 -0
  118. package/dist/lock-holder-DaJbfpci.d.ts.map +1 -0
  119. package/dist/matrix/index.d.ts +2 -2
  120. package/dist/{matrix-DHe-dwVJ.d.ts → matrix-Cf-AGxGh.d.ts} +4 -4
  121. package/dist/{matrix-DHe-dwVJ.d.ts.map → matrix-Cf-AGxGh.d.ts.map} +1 -1
  122. package/dist/meta-eval/index.d.ts +2 -2
  123. package/dist/{mint-zszyYlpA.js → mint-CbdwjTPW.js} +2 -2
  124. package/dist/{mint-zszyYlpA.js.map → mint-CbdwjTPW.js.map} +1 -1
  125. package/dist/{mint-BRZXuwRi.d.ts → mint-CkzpVPdz.d.ts} +3 -3
  126. package/dist/{mint-BRZXuwRi.d.ts.map → mint-CkzpVPdz.d.ts.map} +1 -1
  127. package/dist/multishot/golden/index.d.ts +1 -1
  128. package/dist/multishot/index.d.ts +2 -2
  129. package/dist/multishot/index.js.map +1 -1
  130. package/dist/openapi.json +1 -1
  131. package/dist/{pareto-BzsxidFD.js → pareto-BiBnQXAE.js} +306 -212
  132. package/dist/pareto-BiBnQXAE.js.map +1 -0
  133. package/dist/pipelines/index.d.ts.map +1 -1
  134. package/dist/pipelines/index.js.map +1 -1
  135. package/dist/{prime-protocol-BWG2DQIk.d.ts → prime-protocol-CckHBxGu.d.ts} +3 -3
  136. package/dist/{prime-protocol-BWG2DQIk.d.ts.map → prime-protocol-CckHBxGu.d.ts.map} +1 -1
  137. package/dist/{promotion-gate-DaY95yU6.d.ts → promotion-gate-CkVZHagC.d.ts} +3 -3
  138. package/dist/{promotion-gate-DaY95yU6.d.ts.map → promotion-gate-CkVZHagC.d.ts.map} +1 -1
  139. package/dist/{proposal-findings-BbWidvUk.js → proposal-findings-E1aSC_cU.js} +2 -2
  140. package/dist/{proposal-findings-BbWidvUk.js.map → proposal-findings-E1aSC_cU.js.map} +1 -1
  141. package/dist/{registry-ssNoHzwD.d.ts → registry-B_yG-1jh.d.ts} +5 -5
  142. package/dist/{registry-ssNoHzwD.d.ts.map → registry-B_yG-1jh.d.ts.map} +1 -1
  143. package/dist/{render-C-w2EZ6p.js → render-Cs34y0iX.js} +404 -208
  144. package/dist/render-Cs34y0iX.js.map +1 -0
  145. package/dist/reporting.d.ts +3 -3
  146. package/dist/{researcher-0ABVIdGa.d.ts → researcher-H0p44OYC.d.ts} +5 -5
  147. package/dist/{researcher-0ABVIdGa.d.ts.map → researcher-H0p44OYC.d.ts.map} +1 -1
  148. package/dist/{reward-DrZ71vnf.d.ts → reward-BeUgVVC_.d.ts} +2 -2
  149. package/dist/{reward-DrZ71vnf.d.ts.map → reward-BeUgVVC_.d.ts.map} +1 -1
  150. package/dist/{reward-hacking-E52wq86n.d.ts → reward-hacking-WTxUbtbb.d.ts} +2 -2
  151. package/dist/{reward-hacking-E52wq86n.d.ts.map → reward-hacking-WTxUbtbb.d.ts.map} +1 -1
  152. package/dist/rl.d.ts +8 -8
  153. package/dist/rl.js +4 -4
  154. package/dist/rollout/index.d.ts +3 -3
  155. package/dist/rollout/index.js +5 -5
  156. package/dist/{rollout-D6C50mfA.js → rollout-Dd1ucT_M.js} +5 -5
  157. package/dist/{rollout-D6C50mfA.js.map → rollout-Dd1ucT_M.js.map} +1 -1
  158. package/dist/{rubric-predictive-validity-DiwT8PbL.d.ts → rubric-predictive-validity-noY7uE03.d.ts} +2 -2
  159. package/dist/{rubric-predictive-validity-DiwT8PbL.d.ts.map → rubric-predictive-validity-noY7uE03.d.ts.map} +1 -1
  160. package/dist/{run-record-CaxbLq6Y.d.ts → run-record-C3awiXPf.d.ts} +2 -2
  161. package/dist/{run-record-CaxbLq6Y.d.ts.map → run-record-C3awiXPf.d.ts.map} +1 -1
  162. package/dist/schema-C-ziyJD7.d.ts.map +1 -1
  163. package/dist/{schema-DxcKTzbi.js → schema-CvhfLjtZ.js} +77 -47
  164. package/dist/schema-CvhfLjtZ.js.map +1 -0
  165. package/dist/search/index.d.ts +2 -2
  166. package/dist/search/index.d.ts.map +1 -1
  167. package/dist/search/index.js +2 -2
  168. package/dist/{search-kernel-DxqjBxA-.d.ts → search-kernel-Dloxd6gs.d.ts} +5 -5
  169. package/dist/{search-kernel-DxqjBxA-.d.ts.map → search-kernel-Dloxd6gs.d.ts.map} +1 -1
  170. package/dist/{search-ledger-TUvB5gWH.js → search-ledger-CZRqtFbW.js} +252 -245
  171. package/dist/search-ledger-CZRqtFbW.js.map +1 -0
  172. package/dist/{search-ledger-file-UKCO2r8a.js → search-ledger-file-Bd5Tioq6.js} +3 -3
  173. package/dist/{search-ledger-file-UKCO2r8a.js.map → search-ledger-file-Bd5Tioq6.js.map} +1 -1
  174. package/dist/{search-shipper-Cw2z3-td.js → search-shipper-Dn3NLsuH.js} +3 -3
  175. package/dist/{search-shipper-Cw2z3-td.js.map → search-shipper-Dn3NLsuH.js.map} +1 -1
  176. package/dist/{search-summary-DQIvJsSB.js → search-summary-D4bwYnAE.js} +3 -3
  177. package/dist/{search-summary-DQIvJsSB.js.map → search-summary-D4bwYnAE.js.map} +1 -1
  178. package/dist/{server-DoVbqqtJ.js → server-8TS8XCvg.js} +3 -3
  179. package/dist/{server-DoVbqqtJ.js.map → server-8TS8XCvg.js.map} +1 -1
  180. package/dist/{single-run-lock-U58yf8N6.js → single-run-lock-Dekd8_Wv.js} +7 -7
  181. package/dist/single-run-lock-Dekd8_Wv.js.map +1 -0
  182. package/dist/{skillopt-optimization-method-kyL94-ri.js → skillopt-optimization-method-DLKqdhcR.js} +1384 -1059
  183. package/dist/skillopt-optimization-method-DLKqdhcR.js.map +1 -0
  184. package/dist/{statistical-heldout-C9AbgREN.d.ts → statistical-heldout-3z3I-kJN.d.ts} +3 -3
  185. package/dist/{statistical-heldout-C9AbgREN.d.ts.map → statistical-heldout-3z3I-kJN.d.ts.map} +1 -1
  186. package/dist/{store-otlp-BteDAbHK.js → store-otlp-dyWE3wAG.js} +2 -2
  187. package/dist/{store-otlp-BteDAbHK.js.map → store-otlp-dyWE3wAG.js.map} +1 -1
  188. package/dist/{store-tool-spans-D5l_OfTJ.js → store-tool-spans-DIUgZbzu.js} +3 -3
  189. package/dist/{store-tool-spans-D5l_OfTJ.js.map → store-tool-spans-DIUgZbzu.js.map} +1 -1
  190. package/dist/{store-tool-spans-DZS0HWVf.d.ts → store-tool-spans-DPwXHQkH.d.ts} +7 -7
  191. package/dist/{store-tool-spans-DZS0HWVf.d.ts.map → store-tool-spans-DPwXHQkH.d.ts.map} +1 -1
  192. package/dist/{summary-report-DM7tlml1.d.ts → summary-report-C8V49Jt3.d.ts} +18 -3
  193. package/dist/summary-report-C8V49Jt3.d.ts.map +1 -0
  194. package/dist/supervisor-run/index.d.ts.map +1 -1
  195. package/dist/supervisor-run/index.js +3 -3
  196. package/dist/{systemone-Bp_Ac0p1.d.ts → systemone-DVA7t76V.d.ts} +6 -6
  197. package/dist/{systemone-Bp_Ac0p1.d.ts.map → systemone-DVA7t76V.d.ts.map} +1 -1
  198. package/dist/{systemone-review-CwE6JGIp.d.ts → systemone-review-CUBMuTLi.d.ts} +2 -2
  199. package/dist/{systemone-review-CwE6JGIp.d.ts.map → systemone-review-CUBMuTLi.d.ts.map} +1 -1
  200. package/dist/systemone.d.ts +3 -3
  201. package/dist/{terminal-record-78g6E4vh.js → terminal-record-D4Rv-j1W.js} +241 -193
  202. package/dist/{terminal-record-78g6E4vh.js.map → terminal-record-D4Rv-j1W.js.map} +1 -1
  203. package/dist/{tool-groups-DyNz2JZ_.d.ts → tool-groups-LISbBWCg.d.ts} +3 -3
  204. package/dist/tool-groups-LISbBWCg.d.ts.map +1 -0
  205. package/dist/{trace-questions-xxwgsuMi.d.ts → trace-questions-C42fYEE4.d.ts} +4 -4
  206. package/dist/{trace-questions-xxwgsuMi.d.ts.map → trace-questions-C42fYEE4.d.ts.map} +1 -1
  207. package/dist/trace-repair/index.d.ts +3 -3
  208. package/dist/traces.d.ts +6 -6
  209. package/dist/traces.js +3 -3
  210. package/dist/trajectory-replay/index.d.ts +4 -1
  211. package/dist/trajectory-replay/index.d.ts.map +1 -1
  212. package/dist/trajectory-replay/index.js +854 -823
  213. package/dist/trajectory-replay/index.js.map +1 -1
  214. package/dist/{tree-BGRglkKd.js → tree-DSqwJpL9.js} +122 -14
  215. package/dist/tree-DSqwJpL9.js.map +1 -0
  216. package/dist/{types-CW8ewATZ.d.ts → types-8yQzNm8u.d.ts} +4 -4
  217. package/dist/{types-CW8ewATZ.d.ts.map → types-8yQzNm8u.d.ts.map} +1 -1
  218. package/dist/{types-D8GhJoHk.d.ts → types-CHfn1zg5.d.ts} +70 -72
  219. package/dist/types-CHfn1zg5.d.ts.map +1 -0
  220. package/dist/{types-DtMbFw6U.d.ts → types-D8GXK9Z5.d.ts} +3 -3
  221. package/dist/{types-DtMbFw6U.d.ts.map → types-D8GXK9Z5.d.ts.map} +1 -1
  222. package/dist/{types-D-mgRzlh.d.ts → types-eMhdacVp.d.ts} +2 -2
  223. package/dist/{types-D-mgRzlh.d.ts.map → types-eMhdacVp.d.ts.map} +1 -1
  224. package/dist/wire/index.d.ts +3 -3
  225. package/dist/wire/index.js +1 -1
  226. package/docs/campaign-proposers.md +16 -0
  227. package/docs/concepts.md +31 -0
  228. package/docs/design/statistics-decisions.md +1 -1
  229. package/docs/eval-surface-map.md +1 -0
  230. package/docs/profile-json-identity.md +1 -2
  231. package/docs/public-api.md +100 -88
  232. package/package.json +8 -6
  233. package/dist/benchmark-command-xQK8nOI6.js.map +0 -1
  234. package/dist/campaign-CJGkxAQ6.js.map +0 -1
  235. package/dist/campaign-evidence-CQYw8_0H.js.map +0 -1
  236. package/dist/cost-ledger-D0352Z4d.js.map +0 -1
  237. package/dist/cost-ledger-Jk62OBfF.d.ts.map +0 -1
  238. package/dist/define-agent-eval-BDxNlP3D.js.map +0 -1
  239. package/dist/eval-campaign-BLEfBGbA.js +0 -343
  240. package/dist/eval-campaign-BLEfBGbA.js.map +0 -1
  241. package/dist/index-9jJ2fKSX.d.ts.map +0 -1
  242. package/dist/index-CiRwLv2R.d.ts.map +0 -1
  243. package/dist/index-ZuWx52WG.d.ts.map +0 -1
  244. package/dist/integrity-DOd9Q86O.js.map +0 -1
  245. package/dist/journal-CR4QikYp.js.map +0 -1
  246. package/dist/judge-gate-DsL0yFcb.d.ts.map +0 -1
  247. package/dist/llm-client-BshCREn6.js.map +0 -1
  248. package/dist/llm-judge-C8jMTNNG.js.map +0 -1
  249. package/dist/pareto-BzsxidFD.js.map +0 -1
  250. package/dist/render-C-w2EZ6p.js.map +0 -1
  251. package/dist/schema-DxcKTzbi.js.map +0 -1
  252. package/dist/search-ledger-TUvB5gWH.js.map +0 -1
  253. package/dist/single-run-lock-U58yf8N6.js.map +0 -1
  254. package/dist/skillopt-optimization-method-kyL94-ri.js.map +0 -1
  255. package/dist/summary-report-DM7tlml1.d.ts.map +0 -1
  256. package/dist/tool-groups-DyNz2JZ_.d.ts.map +0 -1
  257. package/dist/tree-BGRglkKd.js.map +0 -1
  258. package/dist/types-D8GhJoHk.d.ts.map +0 -1
@@ -1,55 +1,12 @@
1
1
  import { a as hashCanonical } from "./canonical-Dq2hOQ8L.js";
2
2
  import { o as summarizeNumberSeries } from "./descriptive-CVNy48rR.js";
3
3
  import { t as roundDecimal } from "./round-decimal-COrKglMh.js";
4
- import { a as nonEmptyString, c as parseSupervisorTree, d as NO_SOURCE_LIMITS, g as unavailable, h as showMeasured, i as asRecord, l as recordOrNull, m as isUnavailable, o as parseJsonRecord, p as SUPERVISOR_RUN_SCHEMA, r as readTerminalRecord, s as parseJsonl, u as workerSourceKey } from "./terminal-record-78g6E4vh.js";
4
+ import { a as nonEmptyString, c as parseSupervisorTree, d as NO_SOURCE_LIMITS, g as unavailable, h as showMeasured, i as asRecord, l as recordOrNull, m as isUnavailable, o as parseJsonRecord, p as SUPERVISOR_RUN_SCHEMA, r as readTerminalRecord, s as parseJsonl, u as workerSourceKey } from "./terminal-record-D4Rv-j1W.js";
5
5
  import { join } from "node:path";
6
6
  import { readFile, readdir, stat } from "node:fs/promises";
7
- //#region src/supervisor-run/patch-stats.ts
8
- /** Unified-diff stats. Counts `+++ b/<path>` targets, body +/- lines, and test-file touches. */
9
- function parsePatch(text) {
10
- const files = /* @__PURE__ */ new Set();
11
- const testFiles = /* @__PURE__ */ new Set();
12
- let added = 0;
13
- let removed = 0;
14
- for (const line of text.split("\n")) {
15
- if (line.startsWith("+++ ")) {
16
- const p = line.slice(4).trim().replace(/^b\//, "");
17
- if (p !== "/dev/null") {
18
- files.add(p);
19
- if (isTestPath(p)) testFiles.add(p);
20
- }
21
- continue;
22
- }
23
- if (line.startsWith("--- ") || line.startsWith("diff --git") || line.startsWith("index ")) continue;
24
- if (line.startsWith("+")) added += 1;
25
- else if (line.startsWith("-")) removed += 1;
26
- }
27
- return {
28
- files: files.size,
29
- linesAdded: added,
30
- linesRemoved: removed,
31
- testFilesTouched: [...testFiles].sort()
32
- };
33
- }
34
- function isTestPath(p) {
35
- const base = p.split("/").pop() ?? p;
36
- return /(^|\/)(tests?|__tests__|testing|spec)(\/|$)/.test(p) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(base) || /^test_.*\.py$/.test(base) || /_test\.py$/.test(base);
37
- }
38
- //#endregion
39
- //#region src/supervisor-run/analyze.ts
40
- /**
41
- * The pure analyzer. Takes already-read bytes (`SupervisorRunSources`) and
42
- * returns the report — every metric derivable from a synthetic journal string
43
- * with no filesystem, no process, and no network. All I/O lives in a reader
44
- * (`reader.ts` is one).
45
- */
46
- const NO_CACHE_COUNTERS = "the journal carries no cache-token counters for this role";
47
- const NO_CACHE_BREAKDOWN = "Runtime recorded cacheBreakdownKnown:false — the provider reported a total without splitting cache reads from writes";
48
- /**
49
- * Analyze already-read supervisor-run bytes. Pure and synchronous: same bytes
50
- * in, same report out (modulo `generatedAt`, which `now` pins in tests).
51
- */
52
- function analyzeSupervisorRunSources(src, now = Date.now) {
7
+ //#region src/supervisor-run/analyze-context.ts
8
+ /** The parsed sources and shared lookups every metric group reads. `gap` records an unavailable measurement on the report. */
9
+ function createAnalysis(src) {
53
10
  const gaps = [];
54
11
  const gap = (what, reason) => {
55
12
  gaps.push(`${what}: ${reason}`);
@@ -84,6 +41,182 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
84
41
  const matches = spawnsForSource(worker);
85
42
  return matches.length === 1 ? matches[0] ?? null : null;
86
43
  };
44
+ return {
45
+ src,
46
+ gaps,
47
+ gap,
48
+ journalMissing,
49
+ haveJournal,
50
+ tree,
51
+ state,
52
+ result,
53
+ judge,
54
+ terminal,
55
+ rootId,
56
+ rootSpawn,
57
+ workerSpawns,
58
+ workerCloses,
59
+ startedAt,
60
+ completedAt,
61
+ spawnsForSource,
62
+ spawnForSource,
63
+ closeById: new Map(workerCloses.map((close) => [close.id, close])),
64
+ workersGapReason: src.workersMissingReason ?? "workers/ directory absent"
65
+ };
66
+ }
67
+ //#endregion
68
+ //#region src/supervisor-run/analyze-decision.ts
69
+ /** Settled verdicts, acceptance and review effort, with a named gap wherever the store never said. */
70
+ function measureDecision(a, m) {
71
+ const { src, gap, journalMissing, haveJournal, tree, workerCloses, spawnForSource, closeById, workersGapReason } = a;
72
+ const { steerQueuedTotal, upLegMessages, queuedGapReason, workerEventsGapReason, observeThenRespawn, respawnWithoutEvidence } = m;
73
+ const settledByStatus = {};
74
+ const settledVerdicts = {};
75
+ for (const c of workerCloses) {
76
+ const key = c.status ?? "unknown";
77
+ settledByStatus[key] = (settledByStatus[key] ?? 0) + 1;
78
+ if (c.verdict !== null) settledVerdicts[c.verdict] = (settledVerdicts[c.verdict] ?? 0) + 1;
79
+ }
80
+ const verdictLimit = src.limits.workerVerdicts;
81
+ const deliverablesLimit = src.limits.deliverables;
82
+ let accepted = 0;
83
+ let emptyPass = 0;
84
+ let evidenceBytes = 0;
85
+ const sourceVerdicts = [];
86
+ for (const w of src.workers ?? []) {
87
+ const f = tree.workerLogs.get(workerSourceKey(w));
88
+ if (f?.finished) evidenceBytes += f.evidenceBytes;
89
+ const spawn = spawnForSource(w);
90
+ const passed = (spawn === null ? null : closeById.get(spawn.id) ?? null)?.valid ?? f?.passed ?? null;
91
+ if (passed !== null) sourceVerdicts.push(passed);
92
+ if (passed === true) {
93
+ if (deliverablesLimit !== null || (w.patchBytes ?? f?.finishedPatchBytes ?? 0) > 0) accepted += 1;
94
+ else emptyPass += 1;
95
+ }
96
+ }
97
+ const settledCloses = workerCloses.filter((close) => close.kind === "settled");
98
+ const structuredVerdicts = settledCloses.map((close) => close.valid).filter((valid) => valid !== null);
99
+ const journalVerdictsComplete = settledCloses.length > 0 && structuredVerdicts.length === settledCloses.length;
100
+ const sourceVerdictsComplete = sourceVerdicts.length > 0 && sourceVerdicts.length >= settledCloses.length;
101
+ const rejected = journalVerdictsComplete ? structuredVerdicts.filter((valid) => !valid).length : sourceVerdictsComplete ? sourceVerdicts.filter((valid) => !valid).length : 0;
102
+ const rejectedLimit = journalVerdictsComplete || sourceVerdictsComplete ? null : settledCloses.length > 0 ? verdictLimit ?? "a settled journal verdict has no validity and no matched worker log" : verdictLimit !== null ? verdictLimit : !haveJournal && src.workers === null ? workersGapReason : null;
103
+ return {
104
+ settledByStatus: haveJournal ? settledByStatus : gap("settledByStatus", journalMissing),
105
+ settledVerdicts: verdictLimit !== null ? unavailable(verdictLimit) : haveJournal ? settledVerdicts : unavailable(journalMissing),
106
+ accepted: verdictLimit !== null ? gap("accepted", verdictLimit) : src.workers === null ? unavailable(workersGapReason) : accepted,
107
+ rejected: rejectedLimit === null ? rejected : unavailable(rejectedLimit),
108
+ emptyPass: verdictLimit !== null ? gap("emptyPass", verdictLimit) : deliverablesLimit !== null ? gap("emptyPass", deliverablesLimit) : src.workers === null ? unavailable(workersGapReason) : emptyPass,
109
+ observeThenRespawn: haveJournal ? observeThenRespawn : unavailable(journalMissing),
110
+ respawnWithoutEvidence: haveJournal ? respawnWithoutEvidence : unavailable(journalMissing),
111
+ reviewActions: src.workers === null ? unavailable(workersGapReason) : queuedGapReason === null ? steerQueuedTotal + upLegMessages : unavailable(queuedGapReason),
112
+ workerEvidenceBytes: src.workers === null ? unavailable(workersGapReason) : workerEventsGapReason === null ? evidenceBytes : unavailable(workerEventsGapReason)
113
+ };
114
+ }
115
+ //#endregion
116
+ //#region src/supervisor-run/analyze-economics.ts
117
+ const NO_CACHE_COUNTERS = "the journal carries no cache-token counters for this role";
118
+ const NO_CACHE_BREAKDOWN = "Runtime recorded cacheBreakdownKnown:false — the provider reported a total without splitting cache reads from writes";
119
+ /** One row per worker log, plus the capture gaps of the root and every worker. */
120
+ function buildPerWorker(a, f, t) {
121
+ const { src, gaps, tree, rootId, spawnsForSource, spawnForSource, closeById } = a;
122
+ const { workerUsdById, workerUsdByLabel } = f;
123
+ const { usdLimit } = t;
124
+ const noteCaptureGaps = (owner, captures) => {
125
+ if (captures === null || captures?.length === 0) gaps.push(`${owner} workspaceCapture: no retained output capture evidence`);
126
+ else if (captures !== void 0) for (const [index, capture] of captures.entries()) {
127
+ const source = `${owner} workspaceCapture[${index + 1}]`;
128
+ if (capture.projectionGap !== null) gaps.push(`${source}: ${capture.projectionGap}`);
129
+ if (capture.coverageComplete === false) gaps.push(`${source}: ${capture.incompleteReason ?? "provider reported incomplete coverage"}`);
130
+ if (capture.coverageComplete === null && capture.projectionGap === null) gaps.push(`${source}: capture coverage was not recorded`);
131
+ }
132
+ };
133
+ noteCaptureGaps(`root ${rootId ?? src.runRef}`, src.rootWorkspaceCaptures);
134
+ return (src.workers ?? []).map((w) => {
135
+ noteCaptureGaps(`worker ${w.workerId ?? w.label}`, w.workspaceCaptures);
136
+ const f = tree.workerLogs.get(workerSourceKey(w));
137
+ const matchingSpawns = spawnsForSource(w);
138
+ const spawn = spawnForSource(w);
139
+ const close = spawn === null ? null : closeById.get(spawn.id) ?? null;
140
+ const passed = close?.valid ?? f?.passed ?? null;
141
+ const matchingRoles = new Set(matchingSpawns.map((candidate) => candidate.role));
142
+ const matchingRuntimes = new Set(matchingSpawns.map((candidate) => candidate.runtime));
143
+ const matchingProfiles = new Set(matchingSpawns.map((candidate) => candidate.profileDigest));
144
+ const journalWallMs = spawn?.at !== null && spawn?.at !== void 0 && close?.at !== null && close?.at !== void 0 && close.at >= spawn.at ? close.at - spawn.at : null;
145
+ return {
146
+ workerId: w.workerId ?? null,
147
+ worker: w.label,
148
+ role: matchingRoles.size === 1 ? matchingSpawns[0]?.role ?? null : null,
149
+ runtime: matchingRuntimes.size === 1 ? matchingSpawns[0]?.runtime ?? null : null,
150
+ profileDigest: matchingProfiles.size === 1 ? matchingSpawns[0]?.profileDigest ?? null : null,
151
+ status: close?.status ?? null,
152
+ failure: close?.reason ?? null,
153
+ infra: close?.infra ?? null,
154
+ wallMs: f?.started != null && f.finishedAt != null ? f.finishedAt - f.started : journalWallMs,
155
+ tokensIn: w.tokensIn ?? (close?.hasSpend === true && close.spend.tokensKnown ? close.spend.tokens.input : null),
156
+ tokensOut: w.tokensOut ?? (close?.hasSpend === true && close.spend.tokensKnown ? close.spend.tokens.output : null),
157
+ usd: usdLimit !== null ? null : w.workerId === void 0 ? workerUsdByLabel.get(w.label) ?? null : workerUsdById.get(w.workerId) ?? null,
158
+ patchBytes: w.patchBytes ?? f?.finishedPatchBytes ?? null,
159
+ passed,
160
+ score: close?.score ?? f?.score ?? null,
161
+ workspaceCaptures: w.workspaceCaptures ?? null
162
+ };
163
+ });
164
+ }
165
+ /** The supervisor brain's tokens, cache and USD. */
166
+ function buildBrainSpend(a, f, t) {
167
+ const { src, gap, journalMissing, haveJournal, tree } = a;
168
+ const { brainTokensUnreported, brainUsdUnreported } = f;
169
+ const { usdLimit } = t;
170
+ const managerTokenLimit = src.limits.managerTokens;
171
+ return {
172
+ tokensIn: managerTokenLimit !== null ? gap("brain.tokensIn", managerTokenLimit) : !haveJournal ? gap("brain.tokensIn", journalMissing) : brainTokensUnreported !== null ? gap("brain.tokensIn", brainTokensUnreported) : tree.brain.tokensIn,
173
+ tokensOut: managerTokenLimit !== null ? unavailable(managerTokenLimit) : !haveJournal ? unavailable(journalMissing) : brainTokensUnreported !== null ? unavailable(brainTokensUnreported) : tree.brain.tokensOut,
174
+ usd: usdLimit !== null ? unavailable(usdLimit) : !haveJournal ? unavailable(journalMissing) : brainUsdUnreported !== null ? unavailable(brainUsdUnreported) : roundDecimal(tree.brain.usd, 6),
175
+ cacheRead: managerTokenLimit !== null ? unavailable(managerTokenLimit) : !haveJournal ? unavailable(journalMissing) : brainTokensUnreported !== null ? unavailable(brainTokensUnreported) : !tree.brain.hasCache ? unavailable(NO_CACHE_COUNTERS) : tree.brain.cacheBreakdownKnown ? tree.brain.cacheRead : unavailable(NO_CACHE_BREAKDOWN),
176
+ cacheWrite: managerTokenLimit !== null ? unavailable(managerTokenLimit) : !haveJournal ? unavailable(journalMissing) : brainTokensUnreported !== null ? unavailable(brainTokensUnreported) : !tree.brain.hasCache ? unavailable(NO_CACHE_COUNTERS) : tree.brain.cacheBreakdownKnown ? tree.brain.cacheWrite : unavailable(NO_CACHE_BREAKDOWN),
177
+ source: managerTokenLimit ?? (haveJournal ? `journal metered events (n=${tree.brain.meteredCount})${tree.brain.usdKnownCount > 0 && tree.brain.usdUnknownCount > 0 ? ` — ${tree.brain.usdUnknownCount} unpriced` : ""}` : journalMissing)
178
+ };
179
+ }
180
+ /** The workers' tokens, cache and USD. */
181
+ function buildWorkerSpend(a, f, t, w) {
182
+ const { src, journalMissing, haveJournal } = a;
183
+ const { rootChildSpends, workerUsdUnknownNodes, journalWorkerUsd, workerUsdUnreported } = f;
184
+ const { usdLimit } = t;
185
+ const { sq, workerTokenLimit, workerIn, workerOut } = w;
186
+ return {
187
+ tokensIn: workerIn,
188
+ tokensOut: workerOut,
189
+ cacheRead: workerTokenLimit !== null ? unavailable(workerTokenLimit) : sq?.cacheRead !== void 0 ? sq.cacheRead : unavailable(NO_CACHE_COUNTERS),
190
+ cacheWrite: workerTokenLimit !== null ? unavailable(workerTokenLimit) : sq?.cacheWrite !== void 0 ? sq.cacheWrite : unavailable(NO_CACHE_COUNTERS),
191
+ usd: usdLimit !== null ? unavailable(usdLimit) : !haveJournal ? unavailable(journalMissing) : workerUsdUnreported !== null ? unavailable(workerUsdUnreported) : roundDecimal(journalWorkerUsd, 6),
192
+ source: `${workerTokenLimit !== null ? workerTokenLimit : sq !== null ? `journal settled spend + ${sq.store} sessions (n=${sq.sessions})` : `journal settled spend only — ${src.harnessMissingReason ?? "harness session store unavailable"}`}${workerUsdUnknownNodes.length > 0 && workerUsdUnknownNodes.length < rootChildSpends.length ? ` — ${workerUsdUnknownNodes.length} unpriced` : ""}`
193
+ };
194
+ }
195
+ function buildEconomics(a, f, t, w, e) {
196
+ const { src, gap, journalMissing, haveJournal, tree, workersGapReason } = a;
197
+ const { rootChildCloses, journalWorkerUsd, usdUnknownRecords } = f;
198
+ const { stateUsd, usdLimit, totalUsd, usdUnreportedReason } = t;
199
+ const { decision, spend, perWorker } = e;
200
+ const wallDistribution = summarizeNumberSeries(perWorker.map((w) => w.wallMs).filter((w) => w !== null));
201
+ const brainCalls = parseJsonl(src.brainLog);
202
+ return {
203
+ resourceRecords: src.journal === null && !tree.resourceRecords?.length ? unavailable(journalMissing) : tree.resourceRecords ?? [],
204
+ brain: buildBrainSpend(a, f, t),
205
+ brainTruncations: src.brainLog === null ? gap("brain.brainTruncations", src.brainLogMissingReason ?? (src.supRunDir === null ? "no Runtime supervisor run directory" : "brain.jsonl absent — this source has no brain-call tap, so truncation cannot be ruled out")) : brainCalls.filter((c) => c.finish_reason === "length").length,
206
+ workers: buildWorkerSpend(a, f, t, w),
207
+ spend,
208
+ totalUsd,
209
+ totalUsdSource: usdLimit !== null ? usdLimit : stateUsd !== null ? `state.json result.spentUsd${rootChildCloses.length > 0 && journalWorkerUsd === 0 ? " — brain-priced only; worker CLI inference is unpriced (see worker token counts)" : ""}` : !haveJournal ? journalMissing : usdUnknownRecords > 0 ? usdUnreportedReason : "journal metered + settled usd",
210
+ costPerAcceptedPatchUsd: isUnavailable(totalUsd) ? unavailable(totalUsd.unavailable) : isUnavailable(decision.accepted) ? unavailable(decision.accepted.unavailable) : decision.accepted === 0 ? unavailable("no accepted worker patch (cost has no denominator)") : roundDecimal(totalUsd / decision.accepted, 6),
211
+ workerWallMsDistribution: wallDistribution === null ? unavailable(src.workers === null ? workersGapReason : "no worker start/finish pairs captured") : wallDistribution,
212
+ perWorker: src.workers === null ? unavailable(workersGapReason) : perWorker
213
+ };
214
+ }
215
+ //#endregion
216
+ //#region src/supervisor-run/analyze-orchestration.ts
217
+ /** Supervisor wall time and where it ends. Explicit stamps win; the journal span is a lower bound; an inverted stamp pair stays unavailable. */
218
+ function measureWall(a) {
219
+ const { gap, journalMissing, haveJournal, tree, startedAt, completedAt } = a;
87
220
  const wallSpanStart = startedAt ?? tree.firstEventAt;
88
221
  const wallSpanEnd = tree.lastEventAt;
89
222
  let supervisorWallMs;
@@ -99,7 +232,15 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
99
232
  supervisorWallMs = gap("supervisorWallMs", reason);
100
233
  supervisorWallSource = unavailable(reason);
101
234
  }
102
- const wallEndAt = completedAt ?? (supervisorWallSource === "journal-span" ? wallSpanEnd : null);
235
+ return {
236
+ supervisorWallMs,
237
+ supervisorWallSource,
238
+ wallEndAt: completedAt ?? (supervisorWallSource === "journal-span" ? wallSpanEnd : null)
239
+ };
240
+ }
241
+ /** Steer counts from worker inboxes and the driver log. */
242
+ function measureSteers(a) {
243
+ const { src, gap, tree, workersGapReason } = a;
103
244
  const steerRows = [];
104
245
  let steerQueuedTotal = 0;
105
246
  let steerDeliveredTotal = 0;
@@ -118,7 +259,6 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
118
259
  if (queued !== null) steerQueuedTotal += queued;
119
260
  if (delivered !== null) steerDeliveredTotal += delivered;
120
261
  }
121
- const workersGapReason = src.workersMissingReason ?? "workers/ directory absent";
122
262
  const unavailableReasons = (pick) => {
123
263
  const reasons = tree.workerLogRows.map((facts) => pick(facts)).filter((reason) => reason !== null);
124
264
  return reasons.length === 0 ? null : `exact steer accounting unavailable for ${reasons.length} worker row(s): ${[...new Set(reasons)].join(" | ")}`;
@@ -126,10 +266,20 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
126
266
  const queuedGapReason = unavailableReasons((facts) => facts.steersQueuedUnavailable);
127
267
  const deliveredGapReason = unavailableReasons((facts) => facts.steersDeliveredUnavailable);
128
268
  const workerEventsGapReason = unavailableReasons((facts) => !facts.eventsCaptured ? "events absent" : facts.eventsInvalidRows > 0 ? "events contain malformed rows" : null);
129
- const steers = src.workers === null ? gap("steers", workersGapReason) : queuedGapReason === null ? steerQueuedTotal : gap("steers", queuedGapReason);
130
- const steersDelivered = src.workers === null ? unavailable(workersGapReason) : deliveredGapReason === null ? steerDeliveredTotal : unavailable(deliveredGapReason);
131
- const steersByWorker = src.workers === null ? unavailable(workersGapReason) : queuedGapReason === null && deliveredGapReason === null ? steerRows : unavailable(queuedGapReason ?? deliveredGapReason ?? workersGapReason);
132
- const driverSteerCalls = src.driverLog === null ? gap("driverSteerCalls", "driver.log absent") : Math.max(0, (src.driverLog.match(/supervisor_steer/g) ?? []).length - registrationMentions(src.driverLog));
269
+ return {
270
+ steers: src.workers === null ? gap("steers", workersGapReason) : queuedGapReason === null ? steerQueuedTotal : gap("steers", queuedGapReason),
271
+ steersDelivered: src.workers === null ? unavailable(workersGapReason) : deliveredGapReason === null ? steerDeliveredTotal : unavailable(deliveredGapReason),
272
+ steersByWorker: src.workers === null ? unavailable(workersGapReason) : queuedGapReason === null && deliveredGapReason === null ? steerRows : unavailable(queuedGapReason ?? deliveredGapReason ?? workersGapReason),
273
+ driverSteerCalls: src.driverLog === null ? gap("driverSteerCalls", "driver.log absent") : Math.max(0, (src.driverLog.match(/supervisor_steer/g) ?? []).length - registrationMentions(src.driverLog)),
274
+ steerQueuedTotal,
275
+ upLegMessages,
276
+ queuedGapReason,
277
+ workerEventsGapReason
278
+ };
279
+ }
280
+ /** Waves, peak concurrency, idle time and summed worker wall from the spawn/close timeline. */
281
+ function measureConcurrency(a, wallEndAt) {
282
+ const { workerSpawns, workerCloses, startedAt } = a;
133
283
  const timeline = [];
134
284
  for (const s of workerSpawns) if (s.at !== null) timeline.push({
135
285
  at: s.at,
@@ -171,8 +321,17 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
171
321
  if (live === 0) idleMs += span;
172
322
  sumWorkerWallMs += span * live;
173
323
  }
174
- const firstWorkerSpawnAt = workerSpawns.reduce((acc, s) => s.at === null ? acc : acc === null ? s.at : Math.min(acc, s.at), null);
175
- const closeById = new Map(workerCloses.map((close) => [close.id, close]));
324
+ return {
325
+ waves,
326
+ waveSizes,
327
+ maxConcurrency,
328
+ idleMs,
329
+ sumWorkerWallMs
330
+ };
331
+ }
332
+ /** Respawn counts per parent, split by whether a sibling closed in between. */
333
+ function measureRespawns(a) {
334
+ const { workerSpawns, closeById } = a;
176
335
  const childSpawnsByParent = /* @__PURE__ */ new Map();
177
336
  for (const spawn of workerSpawns) {
178
337
  if (spawn.parent === null) continue;
@@ -205,6 +364,16 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
205
364
  }
206
365
  }
207
366
  const repeatedLabels = [...repeatedLabelSet];
367
+ return {
368
+ respawns,
369
+ observeThenRespawn,
370
+ respawnWithoutEvidence,
371
+ repeatedLabels
372
+ };
373
+ }
374
+ /** The deepest chain of spawns below the root. */
375
+ function measureDelegationDepth(a) {
376
+ const { tree, rootId, workerSpawns } = a;
208
377
  const parentOf = new Map(tree.spawns.map((s) => [s.id, s.parent]));
209
378
  let delegationDepth = 0;
210
379
  for (const s of workerSpawns) {
@@ -218,7 +387,13 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
218
387
  }
219
388
  if (d > delegationDepth) delegationDepth = d;
220
389
  }
221
- const orchestration = {
390
+ return delegationDepth;
391
+ }
392
+ function buildOrchestration(a, m) {
393
+ const { gap, journalMissing, haveJournal, workerSpawns, workerCloses, startedAt } = a;
394
+ const { supervisorWallMs, supervisorWallSource, steers, steersDelivered, steersByWorker, driverSteerCalls, waves, waveSizes, maxConcurrency, idleMs, sumWorkerWallMs, respawns, repeatedLabels, delegationDepth } = m;
395
+ const firstWorkerSpawnAt = workerSpawns.reduce((acc, s) => s.at === null ? acc : acc === null ? s.at : Math.min(acc, s.at), null);
396
+ return {
222
397
  workersSpawned: haveJournal ? workerSpawns.length : gap("workersSpawned", journalMissing),
223
398
  workersSettled: haveJournal ? workerCloses.filter((c) => c.kind === "settled").length : unavailable(journalMissing),
224
399
  workersCancelled: haveJournal ? workerCloses.filter((c) => c.kind === "cancelled").length : unavailable(journalMissing),
@@ -239,47 +414,89 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
239
414
  idlePct: isUnavailable(supervisorWallMs) || supervisorWallMs === 0 ? isUnavailable(supervisorWallMs) ? unavailable(supervisorWallMs.unavailable) : unavailable("supervisor wall is 0ms") : roundDecimal(idleMs / supervisorWallMs * 100, 1),
240
415
  workerUtilization: isUnavailable(supervisorWallMs) || supervisorWallMs === 0 ? isUnavailable(supervisorWallMs) ? unavailable(supervisorWallMs.unavailable) : unavailable("supervisor wall is 0ms") : roundDecimal(sumWorkerWallMs / supervisorWallMs, 3)
241
416
  };
242
- const settledByStatus = {};
243
- const settledVerdicts = {};
244
- for (const c of workerCloses) {
245
- const key = c.status ?? "unknown";
246
- settledByStatus[key] = (settledByStatus[key] ?? 0) + 1;
247
- if (c.verdict !== null) settledVerdicts[c.verdict] = (settledVerdicts[c.verdict] ?? 0) + 1;
417
+ }
418
+ /** Whether sorted values contain one value in the inclusive interval. */
419
+ function hasNumberBetween(sorted, low, high) {
420
+ let left = 0;
421
+ let right = sorted.length;
422
+ while (left < right) {
423
+ const middle = left + Math.floor((right - left) / 2);
424
+ if (sorted[middle] < low) left = middle + 1;
425
+ else right = middle;
248
426
  }
249
- const verdictLimit = src.limits.workerVerdicts;
250
- const deliverablesLimit = src.limits.deliverables;
251
- let accepted = 0;
252
- let emptyPass = 0;
253
- let evidenceBytes = 0;
254
- const sourceVerdicts = [];
255
- for (const w of src.workers ?? []) {
256
- const f = tree.workerLogs.get(workerSourceKey(w));
257
- if (f?.finished) evidenceBytes += f.evidenceBytes;
258
- const spawn = spawnForSource(w);
259
- const passed = (spawn === null ? null : closeById.get(spawn.id) ?? null)?.valid ?? f?.passed ?? null;
260
- if (passed !== null) sourceVerdicts.push(passed);
261
- if (passed === true) {
262
- if (deliverablesLimit !== null || (w.patchBytes ?? f?.finishedPatchBytes ?? 0) > 0) accepted += 1;
263
- else emptyPass += 1;
427
+ return left < sorted.length && sorted[left] <= high;
428
+ }
429
+ /** `[driver] registered tools: …supervisor_steer…` is a banner, not an invocation. */
430
+ function registrationMentions(driverLog) {
431
+ let n = 0;
432
+ for (const line of driverLog.split("\n")) if (line.includes("registered tools:") && line.includes("supervisor_steer")) n += 1;
433
+ return n;
434
+ }
435
+ //#endregion
436
+ //#region src/supervisor-run/patch-stats.ts
437
+ /** Unified-diff stats. Counts `+++ b/<path>` targets, body +/- lines, and test-file touches. */
438
+ function parsePatch(text) {
439
+ const files = /* @__PURE__ */ new Set();
440
+ const testFiles = /* @__PURE__ */ new Set();
441
+ let added = 0;
442
+ let removed = 0;
443
+ for (const line of text.split("\n")) {
444
+ if (line.startsWith("+++ ")) {
445
+ const p = line.slice(4).trim().replace(/^b\//, "");
446
+ if (p !== "/dev/null") {
447
+ files.add(p);
448
+ if (isTestPath(p)) testFiles.add(p);
449
+ }
450
+ continue;
264
451
  }
452
+ if (line.startsWith("--- ") || line.startsWith("diff --git") || line.startsWith("index ")) continue;
453
+ if (line.startsWith("+")) added += 1;
454
+ else if (line.startsWith("-")) removed += 1;
265
455
  }
266
- const settledCloses = workerCloses.filter((close) => close.kind === "settled");
267
- const structuredVerdicts = settledCloses.map((close) => close.valid).filter((valid) => valid !== null);
268
- const journalVerdictsComplete = settledCloses.length > 0 && structuredVerdicts.length === settledCloses.length;
269
- const sourceVerdictsComplete = sourceVerdicts.length > 0 && sourceVerdicts.length >= settledCloses.length;
270
- const rejected = journalVerdictsComplete ? structuredVerdicts.filter((valid) => !valid).length : sourceVerdictsComplete ? sourceVerdicts.filter((valid) => !valid).length : 0;
271
- const rejectedLimit = journalVerdictsComplete || sourceVerdictsComplete ? null : settledCloses.length > 0 ? verdictLimit ?? "a settled journal verdict has no validity and no matched worker log" : verdictLimit !== null ? verdictLimit : !haveJournal && src.workers === null ? workersGapReason : null;
272
- const decision = {
273
- settledByStatus: haveJournal ? settledByStatus : gap("settledByStatus", journalMissing),
274
- settledVerdicts: verdictLimit !== null ? unavailable(verdictLimit) : haveJournal ? settledVerdicts : unavailable(journalMissing),
275
- accepted: verdictLimit !== null ? gap("accepted", verdictLimit) : src.workers === null ? unavailable(workersGapReason) : accepted,
276
- rejected: rejectedLimit === null ? rejected : unavailable(rejectedLimit),
277
- emptyPass: verdictLimit !== null ? gap("emptyPass", verdictLimit) : deliverablesLimit !== null ? gap("emptyPass", deliverablesLimit) : src.workers === null ? unavailable(workersGapReason) : emptyPass,
278
- observeThenRespawn: haveJournal ? observeThenRespawn : unavailable(journalMissing),
279
- respawnWithoutEvidence: haveJournal ? respawnWithoutEvidence : unavailable(journalMissing),
280
- reviewActions: src.workers === null ? unavailable(workersGapReason) : queuedGapReason === null ? steerQueuedTotal + upLegMessages : unavailable(queuedGapReason),
281
- workerEvidenceBytes: src.workers === null ? unavailable(workersGapReason) : workerEventsGapReason === null ? evidenceBytes : unavailable(workerEventsGapReason)
456
+ return {
457
+ files: files.size,
458
+ linesAdded: added,
459
+ linesRemoved: removed,
460
+ testFilesTouched: [...testFiles].sort()
282
461
  };
462
+ }
463
+ function isTestPath(p) {
464
+ const base = p.split("/").pop() ?? p;
465
+ return /(^|\/)(tests?|__tests__|testing|spec)(\/|$)/.test(p) || /\.(test|spec)\.[cm]?[jt]sx?$/.test(base) || /^test_.*\.py$/.test(base) || /_test\.py$/.test(base);
466
+ }
467
+ //#endregion
468
+ //#region src/supervisor-run/analyze-outcome.ts
469
+ /** Terminal status, verdicts, judge result and the delivered patch. */
470
+ function buildOutcome(a, t) {
471
+ const { src, gap, state, result, judge, terminal } = a;
472
+ const { stateResult } = t;
473
+ const patchStats = src.patch === null ? gap("patch", src.limits.deliverables ?? "delivered patch file absent") : parsePatch(src.patch);
474
+ return {
475
+ supStatus: isUnavailable(terminal.supStatus) ? gap("supStatus", terminal.supStatus.unavailable) : terminal.supStatus,
476
+ supStatusSource: terminal.supStatusSource,
477
+ supReason: terminal.supReason,
478
+ failure: terminal.failure,
479
+ supVerdict: pickString(state, "verdict") ?? pickString(result, "sup_verdict") ?? unavailable("no state.json / result.json verdict"),
480
+ delivered: typeof stateResult.delivered === "boolean" ? stateResult.delivered : typeof result?.delivered === "boolean" ? result.delivered : unavailable("no delivered flag in state.json or result.json"),
481
+ judgeResolved: judge === null ? gap("judge", "judge.json absent") : typeof judge.resolved === "boolean" ? judge.resolved : null,
482
+ judgeScore: judge === null ? unavailable("judge.json absent") : typeof judge.score === "number" ? judge.score : null,
483
+ judgePassed: judge === null ? unavailable("judge.json absent") : typeof judge.passed === "number" ? judge.passed : null,
484
+ judgeTotal: judge === null ? unavailable("judge.json absent") : typeof judge.total === "number" ? judge.total : null,
485
+ verifyPass: typeof result?.verify_pass === "boolean" ? result.verify_pass : gap("verifyPass", "result.json absent or has no verify_pass"),
486
+ verifyRc: typeof result?.verify_rc === "number" ? result.verify_rc : unavailable("result.json absent or has no verify_rc"),
487
+ patch: patchStats,
488
+ judgeSource: src.judgeSource
489
+ };
490
+ }
491
+ function pickString(rec, key) {
492
+ const v = rec?.[key];
493
+ return typeof v === "string" ? v : null;
494
+ }
495
+ //#endregion
496
+ //#region src/supervisor-run/analyze-spend.ts
497
+ /** Spend records of the root and its children, split into reporting and unreporting. */
498
+ function collectSpendFacts(a) {
499
+ const { tree, rootId, workerSpawns, workerCloses } = a;
283
500
  const rootChildIds = new Set(workerSpawns.filter((spawn) => spawn.parent === rootId).map((spawn) => spawn.id));
284
501
  const rootChildCloses = workerCloses.filter((close) => rootChildIds.has(close.id));
285
502
  const rootChildSpends = rootChildCloses.filter((close) => close.hasSpend);
@@ -317,17 +534,49 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
317
534
  };
318
535
  const unpriced = (unknown, total, nodes) => `Runtime recorded usdKnown:false on ${unknown} of ${total} spend record(s)${nameNodes(nodes)}`;
319
536
  const unreportedTokens = (unknown, total, nodes) => `Runtime recorded tokensKnown:false on ${unknown} of ${total} spend record(s)${nameNodes(nodes)}`;
320
- const usdPartial = usdKnownRecords > 0 && usdUnknownRecords > 0;
321
- const usdAllUnknown = usdKnownRecords === 0 && usdUnknownRecords > 0;
322
- const brainTokensUnreported = tree.brain.tokensUnknownCount === 0 ? null : unreportedTokens(tree.brain.tokensUnknownCount, tree.brain.meteredCount, brainTokensUnknownNodes);
323
- const brainUsdUnreported = tree.brain.usdKnownCount > 0 || tree.brain.usdUnknownCount === 0 ? null : unpriced(tree.brain.usdUnknownCount, tree.brain.meteredCount, brainUsdUnknownNodes);
324
- const workerUsdUnreported = workerUsdUnknownNodes.length === 0 || workerUsdUnknownNodes.length < rootChildSpends.length ? null : unpriced(workerUsdUnknownNodes.length, rootChildSpends.length, workerUsdUnknownNodes);
537
+ return {
538
+ rootChildCloses,
539
+ rootChildSpends,
540
+ workerUsdUnknownNodes,
541
+ workerTokensUnknownNodes,
542
+ journalWorkerIn,
543
+ journalWorkerOut,
544
+ journalWorkerUsd,
545
+ workerUsdById,
546
+ workerUsdByLabel,
547
+ usdKnownRecords,
548
+ usdUnknownRecords,
549
+ usdUnknownNodes,
550
+ brainUsdUnknownNodes,
551
+ brainTokensUnknownNodes,
552
+ unpriced,
553
+ unreportedTokens,
554
+ usdPartial: usdKnownRecords > 0 && usdUnknownRecords > 0,
555
+ usdAllUnknown: usdKnownRecords === 0 && usdUnknownRecords > 0,
556
+ brainTokensUnreported: tree.brain.tokensUnknownCount === 0 ? null : unreportedTokens(tree.brain.tokensUnknownCount, tree.brain.meteredCount, brainTokensUnknownNodes),
557
+ brainUsdUnreported: tree.brain.usdKnownCount > 0 || tree.brain.usdUnknownCount === 0 ? null : unpriced(tree.brain.usdUnknownCount, tree.brain.meteredCount, brainUsdUnknownNodes),
558
+ workerUsdUnreported: workerUsdUnknownNodes.length === 0 || workerUsdUnknownNodes.length < rootChildSpends.length ? null : unpriced(workerUsdUnknownNodes.length, rootChildSpends.length, workerUsdUnknownNodes)
559
+ };
560
+ }
561
+ /** Worker token totals: journal spend plus harness session counts, or the reason they are absent. */
562
+ function measureWorkerTokens(a, f) {
563
+ const { src, gap, haveJournal } = a;
564
+ const { rootChildSpends, workerTokensUnknownNodes, journalWorkerIn, journalWorkerOut, unreportedTokens } = f;
325
565
  const sq = src.harnessWorkerTokens;
326
566
  const harnessGapReason = src.harnessMissingReason ?? "harness session store unavailable and journal settled spend is 0";
327
567
  const workerTokenLimit = src.limits.workerTokens;
328
568
  const workerTokensUnreported = workerTokensUnknownNodes.length === 0 ? null : unreportedTokens(workerTokensUnknownNodes.length, rootChildSpends.length, workerTokensUnknownNodes);
329
- const workerIn = workerTokenLimit !== null ? gap("workers.tokensIn", workerTokenLimit) : workerTokensUnreported !== null ? gap("workers.tokensIn", workerTokensUnreported) : sq !== null ? journalWorkerIn + sq.input : haveJournal ? journalWorkerIn : gap("workers.tokensIn", harnessGapReason);
330
- const workerOut = workerTokenLimit !== null ? unavailable(workerTokenLimit) : workerTokensUnreported !== null ? unavailable(workerTokensUnreported) : sq !== null ? journalWorkerOut + sq.output : haveJournal ? journalWorkerOut : unavailable(harnessGapReason);
569
+ return {
570
+ sq,
571
+ workerTokenLimit,
572
+ workerIn: workerTokenLimit !== null ? gap("workers.tokensIn", workerTokenLimit) : workerTokensUnreported !== null ? gap("workers.tokensIn", workerTokensUnreported) : sq !== null ? journalWorkerIn + sq.input : haveJournal ? journalWorkerIn : gap("workers.tokensIn", harnessGapReason),
573
+ workerOut: workerTokenLimit !== null ? unavailable(workerTokenLimit) : workerTokensUnreported !== null ? unavailable(workerTokensUnreported) : sq !== null ? journalWorkerOut + sq.output : haveJournal ? journalWorkerOut : unavailable(harnessGapReason)
574
+ };
575
+ }
576
+ /** Total USD and the close record it is read against. */
577
+ function measureTotalUsd(a, f) {
578
+ const { src, gap, journalMissing, haveJournal, tree, state, result } = a;
579
+ const { journalWorkerUsd, usdKnownRecords, usdUnknownRecords, usdUnknownNodes, unpriced } = f;
331
580
  const stateResult = asRecord(state?.result);
332
581
  const stateUsd = typeof stateResult.spentUsd === "number" ? stateResult.spentUsd : null;
333
582
  const resultSpentTotal = asRecord(result?.spentTotal);
@@ -336,11 +585,24 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
336
585
  const usdLimit = src.limits.spendUsd;
337
586
  const closeUsdUnreported = stateUsd === null && resultCloseUsd !== null && resultSpentTotal.usdKnown === false;
338
587
  const usdUnreportedReason = unpriced(usdUnknownRecords, usdKnownRecords + usdUnknownRecords, usdUnknownNodes);
339
- const totalUsd = usdLimit !== null ? gap("totalUsd", usdLimit) : stateUsd !== null ? roundDecimal(stateUsd, 6) : !haveJournal ? gap("totalUsd", journalMissing) : usdUnknownRecords > 0 ? gap("totalUsd", usdUnreportedReason) : roundDecimal(tree.brain.usd + journalWorkerUsd, 6);
588
+ return {
589
+ stateResult,
590
+ stateUsd,
591
+ usdLimit,
592
+ totalUsd: usdLimit !== null ? gap("totalUsd", usdLimit) : stateUsd !== null ? roundDecimal(stateUsd, 6) : !haveJournal ? gap("totalUsd", journalMissing) : usdUnknownRecords > 0 ? gap("totalUsd", usdUnreportedReason) : roundDecimal(tree.brain.usd + journalWorkerUsd, 6),
593
+ closeUsd,
594
+ closeUsdUnreported,
595
+ usdUnreportedReason
596
+ };
597
+ }
598
+ function buildSpend(a, f, t) {
599
+ const { journalMissing, haveJournal, tree, rootId } = a;
600
+ const { journalWorkerUsd, usdKnownRecords, usdUnknownRecords, usdUnknownNodes, usdPartial, usdAllUnknown } = f;
601
+ const { usdLimit, closeUsd, closeUsdUnreported, usdUnreportedReason } = t;
340
602
  const journalSpendRecords = usdKnownRecords;
341
603
  const journalDerivedAvailable = usdLimit === null && haveJournal && !usdAllUnknown;
342
604
  const closeRecordAvailable = usdLimit === null && closeUsd !== null && !closeUsdUnreported;
343
- const spend = {
605
+ return {
344
606
  journalDerived: {
345
607
  usd: journalDerivedAvailable ? roundDecimal(tree.brain.usd + journalWorkerUsd, 6) : unavailable(usdLimit ?? (haveJournal ? usdUnreportedReason : journalMissing)),
346
608
  records: journalDerivedAvailable ? journalSpendRecords : 0,
@@ -356,92 +618,47 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
356
618
  unknownNodes: closeUsdUnreported && rootId !== null ? [rootId] : []
357
619
  }
358
620
  };
359
- const noteCaptureGaps = (owner, captures) => {
360
- if (captures === null || captures?.length === 0) gaps.push(`${owner} workspaceCapture: no retained output capture evidence`);
361
- else if (captures !== void 0) for (const [index, capture] of captures.entries()) {
362
- const source = `${owner} workspaceCapture[${index + 1}]`;
363
- if (capture.projectionGap !== null) gaps.push(`${source}: ${capture.projectionGap}`);
364
- if (capture.coverageComplete === false) gaps.push(`${source}: ${capture.incompleteReason ?? "provider reported incomplete coverage"}`);
365
- if (capture.coverageComplete === null && capture.projectionGap === null) gaps.push(`${source}: capture coverage was not recorded`);
366
- }
621
+ }
622
+ //#endregion
623
+ //#region src/supervisor-run/analyze.ts
624
+ /**
625
+ * The pure analyzer. Takes already-read bytes (`SupervisorRunSources`) and
626
+ * returns the report — every metric derivable from a synthetic journal string
627
+ * with no filesystem, no process, and no network. All I/O lives in a reader
628
+ * (`reader.ts` is one).
629
+ *
630
+ * The metric groups live in `analyze-*.ts`; this file only runs them in the
631
+ * order the report's `gaps` list is written.
632
+ */
633
+ /**
634
+ * Analyze already-read supervisor-run bytes. Pure and synchronous: same bytes
635
+ * in, same report out (modulo `generatedAt`, which `now` pins in tests).
636
+ */
637
+ function analyzeSupervisorRunSources(src, now = Date.now) {
638
+ const a = createAnalysis(src);
639
+ const { gap, gaps, rootId, rootSpawn, journalMissing } = a;
640
+ const wall = measureWall(a);
641
+ const steerFacts = measureSteers(a);
642
+ const concurrency = measureConcurrency(a, wall.wallEndAt);
643
+ const respawns = measureRespawns(a);
644
+ const steps = {
645
+ ...wall,
646
+ ...steerFacts,
647
+ ...concurrency,
648
+ ...respawns,
649
+ delegationDepth: measureDelegationDepth(a)
367
650
  };
368
- noteCaptureGaps(`root ${rootId ?? src.runRef}`, src.rootWorkspaceCaptures);
369
- const perWorker = (src.workers ?? []).map((w) => {
370
- noteCaptureGaps(`worker ${w.workerId ?? w.label}`, w.workspaceCaptures);
371
- const f = tree.workerLogs.get(workerSourceKey(w));
372
- const matchingSpawns = spawnsForSource(w);
373
- const spawn = spawnForSource(w);
374
- const close = spawn === null ? null : closeById.get(spawn.id) ?? null;
375
- const passed = close?.valid ?? f?.passed ?? null;
376
- const matchingRoles = new Set(matchingSpawns.map((candidate) => candidate.role));
377
- const matchingRuntimes = new Set(matchingSpawns.map((candidate) => candidate.runtime));
378
- const matchingProfiles = new Set(matchingSpawns.map((candidate) => candidate.profileDigest));
379
- const journalWallMs = spawn?.at !== null && spawn?.at !== void 0 && close?.at !== null && close?.at !== void 0 && close.at >= spawn.at ? close.at - spawn.at : null;
380
- return {
381
- workerId: w.workerId ?? null,
382
- worker: w.label,
383
- role: matchingRoles.size === 1 ? matchingSpawns[0]?.role ?? null : null,
384
- runtime: matchingRuntimes.size === 1 ? matchingSpawns[0]?.runtime ?? null : null,
385
- profileDigest: matchingProfiles.size === 1 ? matchingSpawns[0]?.profileDigest ?? null : null,
386
- status: close?.status ?? null,
387
- failure: close?.reason ?? null,
388
- infra: close?.infra ?? null,
389
- wallMs: f?.started != null && f.finishedAt != null ? f.finishedAt - f.started : journalWallMs,
390
- tokensIn: w.tokensIn ?? (close?.hasSpend === true && close.spend.tokensKnown ? close.spend.tokens.input : null),
391
- tokensOut: w.tokensOut ?? (close?.hasSpend === true && close.spend.tokensKnown ? close.spend.tokens.output : null),
392
- usd: usdLimit !== null ? null : w.workerId === void 0 ? workerUsdByLabel.get(w.label) ?? null : workerUsdById.get(w.workerId) ?? null,
393
- patchBytes: w.patchBytes ?? f?.finishedPatchBytes ?? null,
394
- passed,
395
- score: close?.score ?? f?.score ?? null,
396
- workspaceCaptures: w.workspaceCaptures ?? null
397
- };
651
+ const orchestration = buildOrchestration(a, steps);
652
+ const decision = measureDecision(a, steps);
653
+ const spendFacts = collectSpendFacts(a);
654
+ const tokens = measureWorkerTokens(a, spendFacts);
655
+ const totals = measureTotalUsd(a, spendFacts);
656
+ const economics = buildEconomics(a, spendFacts, totals, tokens, {
657
+ decision,
658
+ spend: buildSpend(a, spendFacts, totals),
659
+ perWorker: buildPerWorker(a, spendFacts, totals)
398
660
  });
399
- const wallDistribution = summarizeNumberSeries(perWorker.map((w) => w.wallMs).filter((w) => w !== null));
400
- const brainCalls = parseJsonl(src.brainLog);
401
- const managerTokenLimit = src.limits.managerTokens;
402
- const economics = {
403
- resourceRecords: src.journal === null && !tree.resourceRecords?.length ? unavailable(journalMissing) : tree.resourceRecords ?? [],
404
- brain: {
405
- tokensIn: managerTokenLimit !== null ? gap("brain.tokensIn", managerTokenLimit) : !haveJournal ? gap("brain.tokensIn", journalMissing) : brainTokensUnreported !== null ? gap("brain.tokensIn", brainTokensUnreported) : tree.brain.tokensIn,
406
- tokensOut: managerTokenLimit !== null ? unavailable(managerTokenLimit) : !haveJournal ? unavailable(journalMissing) : brainTokensUnreported !== null ? unavailable(brainTokensUnreported) : tree.brain.tokensOut,
407
- usd: usdLimit !== null ? unavailable(usdLimit) : !haveJournal ? unavailable(journalMissing) : brainUsdUnreported !== null ? unavailable(brainUsdUnreported) : roundDecimal(tree.brain.usd, 6),
408
- cacheRead: managerTokenLimit !== null ? unavailable(managerTokenLimit) : !haveJournal ? unavailable(journalMissing) : brainTokensUnreported !== null ? unavailable(brainTokensUnreported) : !tree.brain.hasCache ? unavailable(NO_CACHE_COUNTERS) : tree.brain.cacheBreakdownKnown ? tree.brain.cacheRead : unavailable(NO_CACHE_BREAKDOWN),
409
- cacheWrite: managerTokenLimit !== null ? unavailable(managerTokenLimit) : !haveJournal ? unavailable(journalMissing) : brainTokensUnreported !== null ? unavailable(brainTokensUnreported) : !tree.brain.hasCache ? unavailable(NO_CACHE_COUNTERS) : tree.brain.cacheBreakdownKnown ? tree.brain.cacheWrite : unavailable(NO_CACHE_BREAKDOWN),
410
- source: managerTokenLimit ?? (haveJournal ? `journal metered events (n=${tree.brain.meteredCount})${tree.brain.usdKnownCount > 0 && tree.brain.usdUnknownCount > 0 ? ` — ${tree.brain.usdUnknownCount} unpriced` : ""}` : journalMissing)
411
- },
412
- brainTruncations: src.brainLog === null ? gap("brain.brainTruncations", src.brainLogMissingReason ?? (src.supRunDir === null ? "no Runtime supervisor run directory" : "brain.jsonl absent — this source has no brain-call tap, so truncation cannot be ruled out")) : brainCalls.filter((c) => c.finish_reason === "length").length,
413
- workers: {
414
- tokensIn: workerIn,
415
- tokensOut: workerOut,
416
- cacheRead: workerTokenLimit !== null ? unavailable(workerTokenLimit) : sq?.cacheRead !== void 0 ? sq.cacheRead : unavailable(NO_CACHE_COUNTERS),
417
- cacheWrite: workerTokenLimit !== null ? unavailable(workerTokenLimit) : sq?.cacheWrite !== void 0 ? sq.cacheWrite : unavailable(NO_CACHE_COUNTERS),
418
- usd: usdLimit !== null ? unavailable(usdLimit) : !haveJournal ? unavailable(journalMissing) : workerUsdUnreported !== null ? unavailable(workerUsdUnreported) : roundDecimal(journalWorkerUsd, 6),
419
- source: `${workerTokenLimit !== null ? workerTokenLimit : sq !== null ? `journal settled spend + ${sq.store} sessions (n=${sq.sessions})` : `journal settled spend only — ${src.harnessMissingReason ?? "harness session store unavailable"}`}${workerUsdUnknownNodes.length > 0 && workerUsdUnknownNodes.length < rootChildSpends.length ? ` — ${workerUsdUnknownNodes.length} unpriced` : ""}`
420
- },
421
- spend,
422
- totalUsd,
423
- totalUsdSource: usdLimit !== null ? usdLimit : stateUsd !== null ? `state.json result.spentUsd${rootChildCloses.length > 0 && journalWorkerUsd === 0 ? " — brain-priced only; worker CLI inference is unpriced (see worker token counts)" : ""}` : !haveJournal ? journalMissing : usdUnknownRecords > 0 ? usdUnreportedReason : "journal metered + settled usd",
424
- costPerAcceptedPatchUsd: isUnavailable(totalUsd) ? unavailable(totalUsd.unavailable) : isUnavailable(decision.accepted) ? unavailable(decision.accepted.unavailable) : decision.accepted === 0 ? unavailable("no accepted worker patch (cost has no denominator)") : roundDecimal(totalUsd / decision.accepted, 6),
425
- workerWallMsDistribution: wallDistribution === null ? unavailable(src.workers === null ? workersGapReason : "no worker start/finish pairs captured") : wallDistribution,
426
- perWorker: src.workers === null ? unavailable(workersGapReason) : perWorker
427
- };
428
- const patchStats = src.patch === null ? gap("patch", src.limits.deliverables ?? "delivered patch file absent") : parsePatch(src.patch);
429
- const outcome = {
430
- supStatus: isUnavailable(terminal.supStatus) ? gap("supStatus", terminal.supStatus.unavailable) : terminal.supStatus,
431
- supStatusSource: terminal.supStatusSource,
432
- supReason: terminal.supReason,
433
- failure: terminal.failure,
434
- supVerdict: pickString(state, "verdict") ?? pickString(result, "sup_verdict") ?? unavailable("no state.json / result.json verdict"),
435
- delivered: typeof stateResult.delivered === "boolean" ? stateResult.delivered : typeof result?.delivered === "boolean" ? result.delivered : unavailable("no delivered flag in state.json or result.json"),
436
- judgeResolved: judge === null ? gap("judge", "judge.json absent") : typeof judge.resolved === "boolean" ? judge.resolved : null,
437
- judgeScore: judge === null ? unavailable("judge.json absent") : typeof judge.score === "number" ? judge.score : null,
438
- judgePassed: judge === null ? unavailable("judge.json absent") : typeof judge.passed === "number" ? judge.passed : null,
439
- judgeTotal: judge === null ? unavailable("judge.json absent") : typeof judge.total === "number" ? judge.total : null,
440
- verifyPass: typeof result?.verify_pass === "boolean" ? result.verify_pass : gap("verifyPass", "result.json absent or has no verify_pass"),
441
- verifyRc: typeof result?.verify_rc === "number" ? result.verify_rc : unavailable("result.json absent or has no verify_rc"),
442
- patch: patchStats,
443
- judgeSource: src.judgeSource
444
- };
661
+ const outcome = buildOutcome(a, totals);
445
662
  return {
446
663
  schema: SUPERVISOR_RUN_SCHEMA,
447
664
  runRef: src.runRef,
@@ -459,27 +676,6 @@ function analyzeSupervisorRunSources(src, now = Date.now) {
459
676
  traceCommand: src.traceCommand ?? "npx --yes @tangle-network/traces@latest analyze --harness opencode --cwd <worker-clone-cwd>"
460
677
  };
461
678
  }
462
- /** Whether sorted values contain one value in the inclusive interval. */
463
- function hasNumberBetween(sorted, low, high) {
464
- let left = 0;
465
- let right = sorted.length;
466
- while (left < right) {
467
- const middle = left + Math.floor((right - left) / 2);
468
- if (sorted[middle] < low) left = middle + 1;
469
- else right = middle;
470
- }
471
- return left < sorted.length && sorted[left] <= high;
472
- }
473
- /** `[driver] registered tools: …supervisor_steer…` is a banner, not an invocation. */
474
- function registrationMentions(driverLog) {
475
- let n = 0;
476
- for (const line of driverLog.split("\n")) if (line.includes("registered tools:") && line.includes("supervisor_steer")) n += 1;
477
- return n;
478
- }
479
- function pickString(rec, key) {
480
- const v = rec?.[key];
481
- return typeof v === "string" ? v : null;
482
- }
483
679
  //#endregion
484
680
  //#region src/supervisor-run/coordination-reader.ts
485
681
  /**
@@ -1433,4 +1629,4 @@ function renderSupervisorRollupMarkdown(rollup, title = "Round rollup") {
1433
1629
  //#endregion
1434
1630
  export { findSupervisorRunDirs as a, analyzeSupervisorRunSources as c, analyzeSupervisorRun as i, parsePatch as l, renderSupervisorRunHeadline as n, isRuntimeSupervisorRunDir as o, renderSupervisorRunMarkdown as r, readRuntimeSupervisorRun as s, renderSupervisorRollupMarkdown as t };
1435
1631
 
1436
- //# sourceMappingURL=render-C-w2EZ6p.js.map
1632
+ //# sourceMappingURL=render-Cs34y0iX.js.map