@tangle-network/agent-eval 0.187.2 → 0.188.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 (219) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-uAIQK3Nr.d.ts → agent-profile-CfbuZk8b.d.ts} +4 -4
  4. package/dist/{agent-profile-uAIQK3Nr.d.ts.map → agent-profile-CfbuZk8b.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +12 -12
  6. package/dist/analyst/index.d.ts.map +1 -1
  7. package/dist/analyst/index.js +6 -6
  8. package/dist/{analyze-runs-DapYZz02.d.ts → analyze-runs-CLz5O01x.d.ts} +5 -5
  9. package/dist/{analyze-runs-DapYZz02.d.ts.map → analyze-runs-CLz5O01x.d.ts.map} +1 -1
  10. package/dist/{benchmark-command-DGokT8zd.js → benchmark-command-CdUGku3W.js} +12 -12
  11. package/dist/benchmark-command-CdUGku3W.js.map +1 -0
  12. package/dist/benchmarks/index.d.ts +4 -4
  13. package/dist/benchmarks/index.js +3 -3
  14. package/dist/builder-eval/index.d.ts +3 -3
  15. package/dist/builder-eval/index.js +1 -1
  16. package/dist/campaign/index.d.ts +5 -5
  17. package/dist/campaign/index.js +5 -5
  18. package/dist/{campaign-DlxdTOvw.js → campaign-DZuysBbS.js} +6 -6
  19. package/dist/{campaign-DlxdTOvw.js.map → campaign-DZuysBbS.js.map} +1 -1
  20. package/dist/{chat-client-DqPqWzVV.js → chat-client-C4dg7Ng_.js} +2 -2
  21. package/dist/{chat-client-DqPqWzVV.js.map → chat-client-C4dg7Ng_.js.map} +1 -1
  22. package/dist/{chat-json-call-C-DnDxEy.js → chat-json-call-JVGbfx95.js} +2 -2
  23. package/dist/{chat-json-call-C-DnDxEy.js.map → chat-json-call-JVGbfx95.js.map} +1 -1
  24. package/dist/cli.js +4 -4
  25. package/dist/{client-DCc7a8ZC.d.ts → client-CFj9dfcn.d.ts} +4 -4
  26. package/dist/{client-DCc7a8ZC.d.ts.map → client-CFj9dfcn.d.ts.map} +1 -1
  27. package/dist/contract/index.d.ts +11 -11
  28. package/dist/contract/index.js +6 -6
  29. package/dist/{counterfactual-CLgrwhkY.d.ts → counterfactual-CPaWN99-.d.ts} +4 -4
  30. package/dist/{counterfactual-CLgrwhkY.d.ts.map → counterfactual-CPaWN99-.d.ts.map} +1 -1
  31. package/dist/{counterfactual-Bjq1mlUu.js → counterfactual-DtMWvn7D.js} +2 -2
  32. package/dist/{counterfactual-Bjq1mlUu.js.map → counterfactual-DtMWvn7D.js.map} +1 -1
  33. package/dist/{default-registry-DMxeb4GD.d.ts → default-registry-BLsGfnoO.d.ts} +6 -6
  34. package/dist/{default-registry-DMxeb4GD.d.ts.map → default-registry-BLsGfnoO.d.ts.map} +1 -1
  35. package/dist/{default-registry-Ca2IWH1X.js → default-registry-BtZ_t-9b.js} +2 -2
  36. package/dist/{default-registry-Ca2IWH1X.js.map → default-registry-BtZ_t-9b.js.map} +1 -1
  37. package/dist/{define-agent-eval-C0EqJ9Gz.js → define-agent-eval-ChtddasD.js} +3 -3
  38. package/dist/{define-agent-eval-C0EqJ9Gz.js.map → define-agent-eval-ChtddasD.js.map} +1 -1
  39. package/dist/{define-agent-eval-CGBwPPaq.d.ts → define-agent-eval-CsicmDxt.d.ts} +7 -7
  40. package/dist/{define-agent-eval-CGBwPPaq.d.ts.map → define-agent-eval-CsicmDxt.d.ts.map} +1 -1
  41. package/dist/diagnosis/index.d.ts +38 -96
  42. package/dist/diagnosis/index.d.ts.map +1 -1
  43. package/dist/diagnosis/index.js +83 -134
  44. package/dist/diagnosis/index.js.map +1 -1
  45. package/dist/{dspy-rlm-engine-BE9lCzzL.js → dspy-rlm-engine-sPX7B5ac.js} +3 -3
  46. package/dist/{dspy-rlm-engine-BE9lCzzL.js.map → dspy-rlm-engine-sPX7B5ac.js.map} +1 -1
  47. package/dist/emitter-DbMXUIVP.js +334 -0
  48. package/dist/emitter-DbMXUIVP.js.map +1 -0
  49. package/dist/{emitter-Cs0egaFd.d.ts → emitter-HcCmFQl_.d.ts} +37 -6
  50. package/dist/emitter-HcCmFQl_.d.ts.map +1 -0
  51. package/dist/{engine-DNlKhIm0.d.ts → engine-Gw2n1irt.d.ts} +15 -5
  52. package/dist/engine-Gw2n1irt.d.ts.map +1 -0
  53. package/dist/{eval-campaign-XFHEpN86.js → eval-campaign-CeotQ1ZR.js} +7 -4
  54. package/dist/{eval-campaign-XFHEpN86.js.map → eval-campaign-CeotQ1ZR.js.map} +1 -1
  55. package/dist/evaluation.d.ts +2 -2
  56. package/dist/{exact-types-BEHN7tnq.d.ts → exact-types-CrhPoDp8.d.ts} +2 -2
  57. package/dist/{exact-types-BEHN7tnq.d.ts.map → exact-types-CrhPoDp8.d.ts.map} +1 -1
  58. package/dist/experiment/index.d.ts +3 -3
  59. package/dist/experiment/index.js +1 -2
  60. package/dist/experiment/index.js.map +1 -1
  61. package/dist/{external-optimizer-process-BbhvXTFx.js → external-optimizer-process-D3BLpZyR.js} +2 -2
  62. package/dist/{external-optimizer-process-BbhvXTFx.js.map → external-optimizer-process-D3BLpZyR.js.map} +1 -1
  63. package/dist/{external-optimizer-subprocess-DMgmqTB6.js → external-optimizer-subprocess-BrfsgL92.js} +2 -2
  64. package/dist/{external-optimizer-subprocess-DMgmqTB6.js.map → external-optimizer-subprocess-BrfsgL92.js.map} +1 -1
  65. package/dist/{failure-cluster-OldNRoAt.d.ts → failure-cluster-CbgEDcFJ.d.ts} +3 -3
  66. package/dist/{failure-cluster-OldNRoAt.d.ts.map → failure-cluster-CbgEDcFJ.d.ts.map} +1 -1
  67. package/dist/failure-taxonomy-CjabTATj.js +538 -0
  68. package/dist/failure-taxonomy-CjabTATj.js.map +1 -0
  69. package/dist/{feedback-trajectory-CytTR7u4.d.ts → feedback-trajectory-BJi4t3Vf.d.ts} +6 -6
  70. package/dist/{feedback-trajectory-CytTR7u4.d.ts.map → feedback-trajectory-BJi4t3Vf.d.ts.map} +1 -1
  71. package/dist/hosted/index.d.ts +2 -2
  72. package/dist/{index-CKZa_rnt.d.ts → index-B-s8qDRJ.d.ts} +2 -2
  73. package/dist/{index-CKZa_rnt.d.ts.map → index-B-s8qDRJ.d.ts.map} +1 -1
  74. package/dist/{index-YZrbnBSV.d.ts → index-BD1oSbHr.d.ts} +11 -11
  75. package/dist/{index-YZrbnBSV.d.ts.map → index-BD1oSbHr.d.ts.map} +1 -1
  76. package/dist/{index-vYNHCV2G.d.ts → index-Ca0_IjFu.d.ts} +7 -7
  77. package/dist/{index-vYNHCV2G.d.ts.map → index-Ca0_IjFu.d.ts.map} +1 -1
  78. package/dist/{index-BRsrfSHT.d.ts → index-eTTnPe3r.d.ts} +9 -9
  79. package/dist/{index-BRsrfSHT.d.ts.map → index-eTTnPe3r.d.ts.map} +1 -1
  80. package/dist/index.d.ts +383 -68
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +1482 -207
  83. package/dist/index.js.map +1 -1
  84. package/dist/{insight-report-DpOo-3iL.d.ts → insight-report-DeE1solA.d.ts} +4 -4
  85. package/dist/{insight-report-DpOo-3iL.d.ts.map → insight-report-DeE1solA.d.ts.map} +1 -1
  86. package/dist/{integrity-Cy9WHAtb.js → integrity-BFP4kjGj.js} +6 -1
  87. package/dist/integrity-BFP4kjGj.js.map +1 -0
  88. package/dist/{integrity-rGOfSUle.d.ts → integrity-CaeNeusS.d.ts} +4 -4
  89. package/dist/integrity-CaeNeusS.d.ts.map +1 -0
  90. package/dist/jev.d.ts +2 -2
  91. package/dist/{kind-factory-V79Hw0AU.js → kind-factory-g1ROw67A.js} +15 -4
  92. package/dist/{kind-factory-V79Hw0AU.js.map → kind-factory-g1ROw67A.js.map} +1 -1
  93. package/dist/{llm-client-DDhZ29Vm.js → llm-client-DF9bPNYA.js} +2 -2
  94. package/dist/{llm-client-DDhZ29Vm.js.map → llm-client-DF9bPNYA.js.map} +1 -1
  95. package/dist/{llm-judge-BVso5x-u.js → llm-judge-DF18J3CR.js} +9 -9
  96. package/dist/llm-judge-DF18J3CR.js.map +1 -0
  97. package/dist/{matrix-CPKsRY8Y.d.ts → matrix-BvA1WUpj.d.ts} +2 -2
  98. package/dist/{matrix-CPKsRY8Y.d.ts.map → matrix-BvA1WUpj.d.ts.map} +1 -1
  99. package/dist/meta-eval/index.d.ts +4 -4
  100. package/dist/{mint-BI14xehJ.d.ts → mint-CJFSYBIU.d.ts} +3 -3
  101. package/dist/{mint-BI14xehJ.d.ts.map → mint-CJFSYBIU.d.ts.map} +1 -1
  102. package/dist/multishot/golden/index.d.ts +1 -1
  103. package/dist/multishot/index.d.ts +2 -2
  104. package/dist/openapi.json +1 -1
  105. package/dist/pipelines/index.d.ts +67 -12
  106. package/dist/pipelines/index.d.ts.map +1 -1
  107. package/dist/pipelines/index.js +178 -41
  108. package/dist/pipelines/index.js.map +1 -1
  109. package/dist/{prime-protocol-CDBcL9NM.d.ts → prime-protocol-CF8Z43Fj.d.ts} +2 -2
  110. package/dist/{prime-protocol-CDBcL9NM.d.ts.map → prime-protocol-CF8Z43Fj.d.ts.map} +1 -1
  111. package/dist/{produced-state-Cn9ECr4v.js → produced-state-xsMMjYVc.js} +3 -3
  112. package/dist/{produced-state-Cn9ECr4v.js.map → produced-state-xsMMjYVc.js.map} +1 -1
  113. package/dist/{query-D6W6MaGx.d.ts → query-DBUQhehH.d.ts} +3 -3
  114. package/dist/{query-D6W6MaGx.d.ts.map → query-DBUQhehH.d.ts.map} +1 -1
  115. package/dist/random-DGEyr3zG.d.ts +83 -0
  116. package/dist/random-DGEyr3zG.d.ts.map +1 -0
  117. package/dist/{raw-provider-sink-BQd7mzyT.js → raw-provider-sink-C96CcqeG.js} +19 -56
  118. package/dist/raw-provider-sink-C96CcqeG.js.map +1 -0
  119. package/dist/redact-DPoH1-OW.d.ts +158 -0
  120. package/dist/redact-DPoH1-OW.d.ts.map +1 -0
  121. package/dist/redact-DxwlUAvh.js +824 -0
  122. package/dist/redact-DxwlUAvh.js.map +1 -0
  123. package/dist/{registry-D5Ly3GRV.d.ts → registry-BM2Kdk8T.d.ts} +4 -4
  124. package/dist/{registry-D5Ly3GRV.d.ts.map → registry-BM2Kdk8T.d.ts.map} +1 -1
  125. package/dist/{release-confidence-CSp3MsU4.d.ts → release-confidence-CG4Z9QLB.d.ts} +4 -4
  126. package/dist/{release-confidence-CSp3MsU4.d.ts.map → release-confidence-CG4Z9QLB.d.ts.map} +1 -1
  127. package/dist/{report-command-CSTjzFGY.js → report-command-DKJ_yAIj.js} +21 -12
  128. package/dist/{report-command-CSTjzFGY.js.map → report-command-DKJ_yAIj.js.map} +1 -1
  129. package/dist/reporting.d.ts +3 -3
  130. package/dist/{researcher-D7E92STT.d.ts → researcher-Bjcd_8T_.d.ts} +7 -7
  131. package/dist/{researcher-D7E92STT.d.ts.map → researcher-Bjcd_8T_.d.ts.map} +1 -1
  132. package/dist/{reward-hacking-BIQ2BWLG.d.ts → reward-hacking-DrKXJtgH.d.ts} +2 -2
  133. package/dist/{reward-hacking-BIQ2BWLG.d.ts.map → reward-hacking-DrKXJtgH.d.ts.map} +1 -1
  134. package/dist/rl.d.ts +8 -8
  135. package/dist/rl.js +1 -1
  136. package/dist/rollout/index.d.ts +2 -2
  137. package/dist/{rubric-predictive-validity-CTU8y8Cv.d.ts → rubric-predictive-validity-B14yBAmM.d.ts} +2 -2
  138. package/dist/{rubric-predictive-validity-CTU8y8Cv.d.ts.map → rubric-predictive-validity-B14yBAmM.d.ts.map} +1 -1
  139. package/dist/{run-record-D9wS35fK.d.ts → run-record-xEULpgML.d.ts} +2 -2
  140. package/dist/{run-record-D9wS35fK.d.ts.map → run-record-xEULpgML.d.ts.map} +1 -1
  141. package/dist/{schema-CR5cpjQ3.d.ts → schema-2g7trUwH.d.ts} +17 -2
  142. package/dist/schema-2g7trUwH.d.ts.map +1 -0
  143. package/dist/schema-CSf6qWgZ.js.map +1 -1
  144. package/dist/{semantic-concept-judge-Cnt0TWp0.js → semantic-concept-judge-70LxrCSL.js} +5 -5
  145. package/dist/{semantic-concept-judge-Cnt0TWp0.js.map → semantic-concept-judge-70LxrCSL.js.map} +1 -1
  146. package/dist/{series-convergence-BnMs_uAr.d.ts → series-convergence-DY7ha0kx.d.ts} +2 -2
  147. package/dist/{series-convergence-BnMs_uAr.d.ts.map → series-convergence-DY7ha0kx.d.ts.map} +1 -1
  148. package/dist/{server-DmpcFiVK.js → server-C8XvqCg8.js} +2 -2
  149. package/dist/{server-DmpcFiVK.js.map → server-C8XvqCg8.js.map} +1 -1
  150. package/dist/{skillopt-optimization-method-Cc9SVLqi.js → skillopt-optimization-method-C60h0Got.js} +5 -5
  151. package/dist/{skillopt-optimization-method-Cc9SVLqi.js.map → skillopt-optimization-method-C60h0Got.js.map} +1 -1
  152. package/dist/spans-W0o8pbEg.d.ts +60 -0
  153. package/dist/spans-W0o8pbEg.d.ts.map +1 -0
  154. package/dist/{statistical-heldout-DTmhTW8P.d.ts → statistical-heldout-CPv-y6sK.d.ts} +3 -3
  155. package/dist/{statistical-heldout-DTmhTW8P.d.ts.map → statistical-heldout-CPv-y6sK.d.ts.map} +1 -1
  156. package/dist/{store-BErPvYBr.d.ts → store-C4avFjIi.d.ts} +2 -2
  157. package/dist/{store-BErPvYBr.d.ts.map → store-C4avFjIi.d.ts.map} +1 -1
  158. package/dist/{store-otlp-2gYCy-v0.js → store-otlp-DPgzSQKS.js} +2 -2
  159. package/dist/{store-otlp-2gYCy-v0.js.map → store-otlp-DPgzSQKS.js.map} +1 -1
  160. package/dist/{store-tool-spans-B3bX9yqn.d.ts → store-tool-spans-C2lLwDzg.d.ts} +9 -54
  161. package/dist/store-tool-spans-C2lLwDzg.d.ts.map +1 -0
  162. package/dist/{store-tool-spans-B1e6Auc2.js → store-tool-spans-ClPxcvh2.js} +4 -4
  163. package/dist/{store-tool-spans-B1e6Auc2.js.map → store-tool-spans-ClPxcvh2.js.map} +1 -1
  164. package/dist/storyboard/index.d.ts +1 -1
  165. package/dist/{summary-report-Iy6kXo8x.d.ts → summary-report-SNvJoAvD.d.ts} +3 -3
  166. package/dist/{summary-report-Iy6kXo8x.d.ts.map → summary-report-SNvJoAvD.d.ts.map} +1 -1
  167. package/dist/supervisor-run/index.d.ts.map +1 -1
  168. package/dist/supervisor-run/index.js +1 -1
  169. package/dist/{tool-groups-veQYPiTy.d.ts → tool-groups-CCQqAa16.d.ts} +3 -3
  170. package/dist/tool-groups-CCQqAa16.d.ts.map +1 -0
  171. package/dist/{tool-waste-nbHPAxei.js → tool-waste-CJDfxH45.js} +3 -537
  172. package/dist/tool-waste-CJDfxH45.js.map +1 -0
  173. package/dist/{tool-waste-D23I0zWm.d.ts → tool-waste-CP5DO383.d.ts} +4 -4
  174. package/dist/{tool-waste-D23I0zWm.d.ts.map → tool-waste-CP5DO383.d.ts.map} +1 -1
  175. package/dist/trace-repair/index.d.ts +2 -2
  176. package/dist/traces.d.ts +12 -11
  177. package/dist/traces.d.ts.map +1 -1
  178. package/dist/traces.js +8 -8
  179. package/dist/{trajectory-D7qrNvaN.d.ts → trajectory-Y1fmdlw7.d.ts} +3 -3
  180. package/dist/{trajectory-D7qrNvaN.d.ts.map → trajectory-Y1fmdlw7.d.ts.map} +1 -1
  181. package/dist/trajectory-replay/index.d.ts +3 -3
  182. package/dist/trajectory-replay/index.js +2 -2
  183. package/dist/{types--18oHwVF.d.ts → types-5ak2PqnJ.d.ts} +3 -3
  184. package/dist/{types--18oHwVF.d.ts.map → types-5ak2PqnJ.d.ts.map} +1 -1
  185. package/dist/{types-BTRcIqFr.d.ts → types-B1vDZ694.d.ts} +4 -4
  186. package/dist/{types-BTRcIqFr.d.ts.map → types-B1vDZ694.d.ts.map} +1 -1
  187. package/dist/{types-CBbLtr2J.d.ts → types-C0bWoSKC.d.ts} +10 -11
  188. package/dist/types-C0bWoSKC.d.ts.map +1 -0
  189. package/dist/{types-BjB2wZM9.d.ts → types-DDp2Mb8Y.d.ts} +3 -3
  190. package/dist/{types-BjB2wZM9.d.ts.map → types-DDp2Mb8Y.d.ts.map} +1 -1
  191. package/dist/wire/index.d.ts +3 -3
  192. package/dist/wire/index.js +1 -1
  193. package/docs/diagnosis.md +2 -3
  194. package/docs/eval-surface-map.md +1 -1
  195. package/docs/experiment.md +0 -1
  196. package/docs/redaction.md +59 -0
  197. package/docs/trace-contracts.md +102 -0
  198. package/docs/verdicts.md +1 -1
  199. package/package.json +3 -2
  200. package/dist/benchmark-command-DGokT8zd.js.map +0 -1
  201. package/dist/emitter-Cs0egaFd.d.ts.map +0 -1
  202. package/dist/emitter-DeQHiDMm.js +0 -257
  203. package/dist/emitter-DeQHiDMm.js.map +0 -1
  204. package/dist/engine-DNlKhIm0.d.ts.map +0 -1
  205. package/dist/experiment-tracker-BKEumQug.js +0 -280
  206. package/dist/experiment-tracker-BKEumQug.js.map +0 -1
  207. package/dist/experiment-tracker-URRGP9ek.d.ts +0 -237
  208. package/dist/experiment-tracker-URRGP9ek.d.ts.map +0 -1
  209. package/dist/integrity-Cy9WHAtb.js.map +0 -1
  210. package/dist/integrity-rGOfSUle.d.ts.map +0 -1
  211. package/dist/llm-judge-BVso5x-u.js.map +0 -1
  212. package/dist/raw-provider-sink-BQd7mzyT.js.map +0 -1
  213. package/dist/redact-7Aq1ukl-.js +0 -107
  214. package/dist/redact-7Aq1ukl-.js.map +0 -1
  215. package/dist/schema-CR5cpjQ3.d.ts.map +0 -1
  216. package/dist/store-tool-spans-B3bX9yqn.d.ts.map +0 -1
  217. package/dist/tool-groups-veQYPiTy.d.ts.map +0 -1
  218. package/dist/tool-waste-nbHPAxei.js.map +0 -1
  219. package/dist/types-CBbLtr2J.d.ts.map +0 -1
@@ -1,6 +1,8 @@
1
- import { n as ExecutionReport } from "../analyze-runs-DapYZz02.js";
2
- import { l as PrimeRawUsage } from "../prime-protocol-CDBcL9NM.js";
1
+ import { o as FailureBlame, s as FailureClassification } from "../failure-cluster-CbgEDcFJ.js";
2
+ import { n as ExecutionReport } from "../analyze-runs-CLz5O01x.js";
3
+ import { l as PrimeRawUsage } from "../prime-protocol-CF8Z43Fj.js";
3
4
  import { i as nodeHttpPrimeBridgeTransport, n as PrimeBridgeTransportRequest, r as PrimeBridgeTransportResult, t as PrimeBridgeTransport } from "../prime-bridge-transport-6feEglLf.js";
5
+ import { a as isContentAttribute, i as ingestSpans, n as IngestReport, r as epochMillis, t as DiagnosisSpan } from "../spans-W0o8pbEg.js";
4
6
  import { SpanKind, TraceValidation } from "@tangle-network/agent-trace-contract";
5
7
  //#region src/diagnosis/findings.d.ts
6
8
  /**
@@ -72,105 +74,43 @@ declare function validateDiagnosisFindings(document: unknown, options?: {
72
74
  spanIds?: ReadonlySet<string>;
73
75
  }): string[];
74
76
  //#endregion
75
- //#region src/diagnosis/secret-filter.d.ts
76
- /**
77
- * The secret filter every diagnosis input passes through before any model or
78
- * report reads it.
79
- *
80
- * Two layers:
81
- * - `secret-assignment` is the line-anchored credential-assignment pattern
82
- * trace-archive uses to keep plaintext-secret files out of the archive
83
- * (`holds_secret` in tangle-tools trace-archive/archive.py). It is ported
84
- * here verbatim so both the archive and the miner refuse the same lines.
85
- * That pattern is line-anchored on purpose, so a secret quoted inside a
86
- * JSON record or a prose line passes it;
87
- * - the token-shape rules close that gap: they match the credential itself
88
- * wherever it appears (`sk-`, `sk-ant-`, GitHub, Slack, AWS, Google, JWT,
89
- * bearer headers, URL passwords, PEM blocks, and JSON `"...key": "..."`).
90
- *
91
- * A redacted value becomes `[REDACTED:<rule id>]`, so a report can state what
92
- * was removed by class without carrying any of it. The filter never throws on
93
- * input shape: non-string leaves pass through unchanged.
94
- */
95
- interface SecretRule {
96
- id: string;
97
- pattern: RegExp;
98
- /** Rebuilds the match with the secret replaced; receives the regex groups. */
99
- replace: (match: string, ...groups: string[]) => string;
100
- }
101
- interface SecretFilterReport {
102
- redactionCount: number;
103
- byRule: Record<string, number>;
104
- }
105
- /**
106
- * The trace-archive `SECRET_ASSIGNMENT` pattern (tangle-tools
107
- * trace-archive/archive.py), with the prefix captured so the key name survives
108
- * and only the value is replaced.
109
- */
110
- declare const SECRET_ASSIGNMENT_PATTERN: RegExp;
111
- declare const DIAGNOSIS_SECRET_RULES: readonly SecretRule[];
112
- /** Redact one string, adding the per-rule counts to `report`. */
113
- declare function redactSecrets(input: string, report?: SecretFilterReport, rules?: readonly SecretRule[]): string;
114
- /** Whether any rule matches: the miner's equivalent of trace-archive `holds_secret`. */
115
- declare function holdsSecret(input: string, rules?: readonly SecretRule[]): boolean;
116
- /** Redact every string leaf of a JSON-like value. Keys are kept; values are filtered. */
117
- declare function redactSecretsDeep(value: unknown, report: SecretFilterReport): unknown;
118
- //#endregion
119
- //#region src/diagnosis/spans.d.ts
120
- type DiagnosisSpanStatus = 'OK' | 'ERROR' | 'UNSET';
121
- interface DiagnosisSpan {
77
+ //#region src/diagnosis/first-failure.d.ts
78
+ /** Span ids listed beside a result; the count carries the rest. */
79
+ declare const MAX_FIRST_FAILURE_IDS = 8;
80
+ type FirstFailureStage = 'error-span' | 'failed-outcome';
81
+ interface FirstFailureFound {
82
+ status: 'found';
122
83
  traceId: string;
84
+ stage: FirstFailureStage;
123
85
  spanId: string;
124
- parentSpanId: string | null;
125
86
  name: string;
126
87
  kind: SpanKind;
127
- startMs: number | null;
128
- endMs: number | null;
129
- status: DiagnosisSpanStatus;
130
- statusMessage: string | null;
131
- toolName: string | null;
132
- model: string | null;
133
- /**
134
- * Keyed fingerprint of the tool call's input, taken before redaction so calls
135
- * that differ only in secret material stay distinct. The key is random per
136
- * ingest, so the fingerprint cannot be matched against a guessed payload or
137
- * joined across diagnoses. Null when the span carries no input.
138
- */
139
- inputDigest: string | null;
140
- attributes: Record<string, unknown>;
88
+ /** The span's status message after secret filtering; null when absent or withheld. */
89
+ message: string | null;
90
+ /** The taxonomy's reading of `message`; null for a failed outcome, which has none. */
91
+ classification: FailureClassification | null;
92
+ blame: FailureBlame;
93
+ /** Other candidates at the same stage, in rank order, capped at {@link MAX_FIRST_FAILURE_IDS}. */
94
+ later: string[];
95
+ laterCount: number;
141
96
  }
142
- interface IngestReport {
143
- received: number;
144
- accepted: number;
145
- /** Lines without a trace id or span id, which no evidence could ever cite. */
146
- unreadable: number;
147
- /** Identical (trace id, span id) pairs seen again; the first occurrence is kept. */
148
- duplicateSpans: number;
149
- /** Span ids that occur in more than one trace, which evidence cannot cite unambiguously. */
150
- ambiguousSpanIds: string[];
151
- secrets: SecretFilterReport;
152
- /** Attribute keys removed because content was not included. */
153
- droppedAttributes: string[];
97
+ interface FirstFailureAmbiguous {
98
+ status: 'ambiguous';
99
+ traceId: string;
100
+ stage: FirstFailureStage;
101
+ /** The candidates the rank could not order, capped at {@link MAX_FIRST_FAILURE_IDS}. */
102
+ candidates: string[];
103
+ candidateCount: number;
104
+ reason: string;
154
105
  }
155
- declare function isContentAttribute(key: string): boolean;
156
- /**
157
- * Filter secrets from every string, drop content attributes unless content is
158
- * included, and normalize each span. Order matters: the input fingerprint is
159
- * keyed and taken before redaction and the content drop, so repeated-call
160
- * detection works on metadata-only runs without the payload itself surviving.
161
- */
162
- declare function ingestSpans(raw: readonly unknown[], options: {
163
- contentIncluded: boolean;
164
- }): {
165
- spans: DiagnosisSpan[];
166
- report: IngestReport;
167
- };
168
- /**
169
- * Epoch milliseconds from OTLP nanoseconds, epoch milliseconds, epoch seconds,
170
- * or ISO-8601. Digit strings are classified by length: 17 or more digits are
171
- * nanoseconds, 15-16 microseconds, 12-14 milliseconds, and fewer are seconds.
172
- */
173
- declare function epochMillis(value: unknown): number | null;
106
+ interface FirstFailureNone {
107
+ status: 'none';
108
+ traceId: string;
109
+ reason: string;
110
+ }
111
+ type FirstFailure = FirstFailureFound | FirstFailureAmbiguous | FirstFailureNone;
112
+ /** Rank the first failure of one trace. Throws when the spans belong to more than one trace. */
113
+ declare function rankFirstFailure(spans: readonly DiagnosisSpan[]): FirstFailure;
174
114
  //#endregion
175
115
  //#region src/diagnosis/deterministic.d.ts
176
116
  interface ExecutionFacts {
@@ -180,6 +120,8 @@ interface ExecutionFacts {
180
120
  errorSpans: number;
181
121
  toolCalls: number;
182
122
  models: string[];
123
+ /** The first failure of each run, in trace id order. See `rankFirstFailure`. */
124
+ firstFailures: FirstFailure[];
183
125
  /** agent-eval execution summary; null with a reason when it could not be computed. */
184
126
  execution: ExecutionReport | null;
185
127
  executionError?: string;
@@ -315,5 +257,5 @@ interface DiagnosisResult {
315
257
  declare const DEFAULT_MAX_MODEL_TRACES = 6;
316
258
  declare function diagnoseSpans(spans: readonly unknown[], context: DiagnosisContext, options: DiagnosisOptions): Promise<DiagnosisResult>;
317
259
  //#endregion
318
- export { DEFAULT_MAX_MODEL_TRACES, DIAGNOSIS_FINDINGS_SCHEMA_ID, DIAGNOSIS_SECRET_RULES, type DiagnosisCapability, type DiagnosisConfidence, type DiagnosisContext, type DiagnosisFinding, type DiagnosisFindingsDocument, type DiagnosisMeasure, type DiagnosisModelOptions, type DiagnosisOptions, type DiagnosisRedaction, type DiagnosisResult, type DiagnosisSeverity, type DiagnosisSkippedAnalysis, type DiagnosisSpan, type DiagnosisUsage, type ExecutionFacts, type IngestReport, type ModelQuestion, type ModelRejection, type ModelRowNote, type ModelRunRecord, type PrimeBridgeTransport, type PrimeBridgeTransportRequest, type PrimeBridgeTransportResult, SECRET_ASSIGNMENT_PATTERN, type SecretFilterReport, type SecretRule, diagnoseSpans, epochMillis, holdsSecret, ingestSpans, isContentAttribute, nodeHttpPrimeBridgeTransport, redactSecrets, redactSecretsDeep, validateDiagnosisFindings };
260
+ export { DEFAULT_MAX_MODEL_TRACES, DIAGNOSIS_FINDINGS_SCHEMA_ID, type DiagnosisCapability, type DiagnosisConfidence, type DiagnosisContext, type DiagnosisFinding, type DiagnosisFindingsDocument, type DiagnosisMeasure, type DiagnosisModelOptions, type DiagnosisOptions, type DiagnosisRedaction, type DiagnosisResult, type DiagnosisSeverity, type DiagnosisSkippedAnalysis, type DiagnosisSpan, type DiagnosisUsage, type ExecutionFacts, type FirstFailure, type FirstFailureAmbiguous, type FirstFailureFound, type FirstFailureNone, type FirstFailureStage, type IngestReport, MAX_FIRST_FAILURE_IDS, type ModelQuestion, type ModelRejection, type ModelRowNote, type ModelRunRecord, type PrimeBridgeTransport, type PrimeBridgeTransportRequest, type PrimeBridgeTransportResult, diagnoseSpans, epochMillis, ingestSpans, isContentAttribute, nodeHttpPrimeBridgeTransport, rankFirstFailure, validateDiagnosisFindings };
319
261
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/diagnosis/findings.ts","../../src/diagnosis/secret-filter.ts","../../src/diagnosis/spans.ts","../../src/diagnosis/deterministic.ts","../../src/diagnosis/model-pass.ts","../../src/diagnosis/engine.ts"],"mappings":";;;;;;;;;;;;;cASa;KAGD;;KAGA;UAEK;EACf;EACA;EACA;;EAEA;;UAGe;EACf;EACA,UAAU;EACV;EACA;EACA,UAAU;;EAEV;EACA;EACA,YAAY;EACZ;;UAGe;EACf;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA,QAAQ;EACR;;UAGe;EACf;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE,cAAc,eAAe;IAC7B,SAAS;IACT,YAAY;;EAEd,UAAU;;;;;;;;iBAiBI,0BACd,mBACA;EAAW,UAAU;;;;;;;;;;;;;;;;;;;;;;;UClEN;EACf;EACA,SAAS;;EAET,UAAU,kBAAkB;;UAGb;EACf;EACA,QAAQ;;;;;;;cAWG,2BAAyB;cAGzB,iCAAiC;;iBA8D9B,cACd,eACA,SAAQ,oBACR,iBAAgB;;iBAwBF,YACd,eACA,iBAAgB;;iBAWF,kBAAkB,gBAAgB,QAAQ;;;KC1H9C;UAEK;EACf;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA,QAAQ;EACR;EACA;EACA;;;;;;;EAOA;EACA,YAAY;;UAGG;EACf;EACA;;EAEA;;EAEA;;EAEA;EACA,SAAS;;EAET;;iBA0Bc,mBAAmB;;;;;;;iBAUnB,YACd,yBACA;EAAW;;EACR,OAAO;EAAiB,QAAQ;;;;;;;iBA+GrB,YAAY;;;UC3JX;EACf;EACA;EACA,aAAa;EACb;EACA;EACA;;EAEA,WAAW;EACX;;UAGe;EACf,YAAY;EACZ,cAAc,eAAe;EAC7B,SAAS;EACT,OAAO;EACP,UAAU;EACV;;;;UC/Ce;;EAEf,WAAW;;EAEX;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;IAAY;IAA4B;;;UAGzB;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;IAAa;IAAiB;IAAkB;;EAChD,OAAO;EACP;;;;UC/Be;;EAEf;;EAEA;;EAEA;;;;;EAKA;;EAEA;;EAEA;IAAa,MAAM;MAAQ;QAAe;MAA6B;;KAG7D;EACN;EAAuB;EAAiB,SAAS;;EACjD;EAAe,OAAO;EAAuB,SAAS;;UAE3C;EACf;EACA;EACA;EACA;;UAGe;;EAEf,UAAU;;EAEV,WAAW;;EAEX,OAAO;;EAEP,WAAW;IAAQ;IAAiB;;EACpC,OAAO;EACP,aAAa;EACb,QAAQ;;EAER,UAAU;EACV;IACE;IACA;IACA,MAAM;IACN;IACA,OAAO;;EAET;IAAU;IAA8B;;;cAG7B;iBAIS,cACpB,2BACA,SAAS,kBACT,SAAS,mBACR,QAAQ"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/diagnosis/findings.ts","../../src/diagnosis/first-failure.ts","../../src/diagnosis/deterministic.ts","../../src/diagnosis/model-pass.ts","../../src/diagnosis/engine.ts"],"mappings":";;;;;;;;;;;;;;;cASa;KAGD;;KAGA;UAEK;EACf;EACA;EACA;;EAEA;;UAGe;EACf;EACA,UAAU;EACV;EACA;EACA,UAAU;;EAEV;EACA;EACA,YAAY;EACZ;;UAGe;EACf;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA,QAAQ;EACR;;UAGe;EACf;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE,cAAc,eAAe;IAC7B,SAAS;IACT,YAAY;;EAEd,UAAU;;;;;;;;iBAiBI,0BACd,mBACA;EAAW,UAAU;;;;;cCnDV;KAID;UAEK;EACf;EACA;EACA,OAAO;EACP;EACA;EACA,MAAM;;EAEN;;EAEA,gBAAgB;EAChB,OAAO;;EAEP;EACA;;UAGe;EACf;EACA;EACA,OAAO;;EAEP;EACA;EACA;;UAGe;EACf;EACA;EACA;;KAGU,eAAe,oBAAoB,wBAAwB;;iBAGvD,iBAAiB,gBAAgB,kBAAkB;;;UCvBlD;EACf;EACA;EACA,aAAa;EACb;EACA;EACA;;EAEA,eAAe;;EAEf,WAAW;EACX;;UAGe;EACf,YAAY;EACZ,cAAc,eAAe;EAC7B,SAAS;EACT,OAAO;EACP,UAAU;EACV;;;;UClDe;;EAEf,WAAW;;EAEX;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;IAAY;IAA4B;;;UAGzB;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;IAAa;IAAiB;IAAkB;;EAChD,OAAO;EACP;;;;UC/Be;;EAEf;;EAEA;;EAEA;;;;;EAKA;;EAEA;;EAEA;IAAa,MAAM;MAAQ;QAAe;MAA6B;;KAG7D;EACN;EAAuB;EAAiB,SAAS;;EACjD;EAAe,OAAO;EAAuB,SAAS;;UAE3C;EACf;EACA;EACA;EACA;;UAGe;;EAEf,UAAU;;EAEV,WAAW;;EAEX,OAAO;;EAEP,WAAW;IAAQ;IAAiB;;EACpC,OAAO;EACP,aAAa;EACb,QAAQ;;EAER,UAAU;EACV;IACE;IACA;IACA,MAAM;IACN;IACA,OAAO;;EAET;IAAU;IAA8B;;;cAG7B;iBAIS,cACpB,2BACA,SAAS,kBACT,SAAS,mBACR,QAAQ"}
@@ -1,137 +1,88 @@
1
1
  import { n as summarizeExecution } from "../analyze-runs-DCY7LMt4.js";
2
+ import { c as emptyRedactionReport, f as redactText, u as redact } from "../redact-DxwlUAvh.js";
2
3
  import { t as packageVersion } from "../package-version-D7lQHt_-.js";
4
+ import { o as classifyFailureReason } from "../failure-taxonomy-CjabTATj.js";
3
5
  import { c as primeProtocolSha256, d as runPrimeExchange, n as buildPrimePrompt } from "../prime-protocol-DcAK9pC8.js";
4
6
  import { t as nodeHttpPrimeBridgeTransport } from "../prime-bridge-transport-Z3cpKGoV.js";
5
7
  import { t as fromOtelSpans } from "../otel-spans-CQY1pNiN.js";
6
8
  import { createHash, createHmac, randomBytes } from "node:crypto";
7
9
  import { MODEL_ATTR_KEYS, SPAN_KINDS, TOOL_NAME_ATTR_KEYS, resolveSpanKind, validateTraceSpans } from "@tangle-network/agent-trace-contract";
8
- //#region src/diagnosis/secret-filter.ts
9
- const marker = (id) => `[REDACTED:${id}]`;
10
- const whole = (id) => () => marker(id);
11
- /**
12
- * The trace-archive `SECRET_ASSIGNMENT` pattern (tangle-tools
13
- * trace-archive/archive.py), with the prefix captured so the key name survives
14
- * and only the value is replaced.
15
- */
16
- const SECRET_ASSIGNMENT_PATTERN = /^([ \t]*(?:export[ \t]+)?["']?(?:[A-Za-z_][A-Za-z0-9_.-]*)?(?:key|token|secret|password|passwd|passphrase|credentials?)[A-Za-z0-9_]*["']?[ \t]*[=:][ \t]*["']?)(?!encrypted:)(?![$`])(?=[^\s"'#,]*[0-9])(?=[^\s"'#,]*[A-Za-z])[^\s"'#,]{16,}(["']?[ \t]*,?[ \t]*(?:#.*)?\r?)$/gim;
17
- const DIAGNOSIS_SECRET_RULES = [
18
- {
19
- id: "pem-block",
20
- pattern: /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g,
21
- replace: whole("pem-block")
22
- },
23
- {
24
- id: "secret-assignment",
25
- pattern: SECRET_ASSIGNMENT_PATTERN,
26
- replace: (_match, prefix, suffix) => `${prefix}${marker("secret-assignment")}${suffix}`
27
- },
28
- {
29
- id: "json-secret",
30
- pattern: /("[A-Za-z0-9_.-]*(?:key|token|secret|password|passwd|passphrase|credentials?)[A-Za-z0-9_]*"[ \t]*:[ \t]*")(?!encrypted:)(?![$`])(?=[^"\s]*[0-9])(?=[^"\s]*[A-Za-z])[^"\s]{16,}(")/gi,
31
- replace: (_match, prefix, suffix) => `${prefix}${marker("json-secret")}${suffix}`
32
- },
33
- {
34
- id: "inline-assignment",
35
- pattern: /\b([A-Za-z0-9_.-]*(?:key|token|secret|password|passwd|passphrase|credentials?)[A-Za-z0-9_]*["']?[ \t]*[=:][ \t]*["']?)(?!encrypted:)(?![$`[])(?=[^\s"'#,&;]*[0-9])(?=[^\s"'#,&;]*[A-Za-z])[^\s"'#,&;]{16,}/gi,
36
- replace: (_match, prefix) => `${prefix}${marker("inline-assignment")}`
37
- },
38
- {
39
- id: "anthropic-key",
40
- pattern: /\bsk-ant-[A-Za-z0-9_-]{20,}/g,
41
- replace: whole("anthropic-key")
42
- },
43
- {
44
- id: "openai-key",
45
- pattern: /\bsk-[A-Za-z0-9_-]{20,}/g,
46
- replace: whole("openai-key")
47
- },
48
- {
49
- id: "github-token",
50
- pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,})/g,
51
- replace: whole("github-token")
52
- },
53
- {
54
- id: "slack-token",
55
- pattern: /\bxox[abeoprs]-[A-Za-z0-9-]{10,}/g,
56
- replace: whole("slack-token")
57
- },
58
- {
59
- id: "aws-access-key",
60
- pattern: /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
61
- replace: whole("aws-access-key")
62
- },
63
- {
64
- id: "google-api-key",
65
- pattern: /\bAIza[0-9A-Za-z_-]{35}/g,
66
- replace: whole("google-api-key")
67
- },
68
- {
69
- id: "jwt",
70
- pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,
71
- replace: whole("jwt")
72
- },
73
- {
74
- id: "bearer",
75
- pattern: /\b(Bearer)[ \t]+[A-Za-z0-9._~+/=-]{16,}/gi,
76
- replace: (_match, word) => `${word} ${marker("bearer")}`
77
- },
78
- {
79
- id: "url-credentials",
80
- pattern: /\b([a-z][a-z0-9+.-]*:\/\/[^\s:/@]+:)[^\s@/]+@/gi,
81
- replace: (_match, prefix) => `${prefix}${marker("url-credentials")}@`
10
+ //#region src/diagnosis/first-failure.ts
11
+ /** Span ids listed beside a result; the count carries the rest. */
12
+ const MAX_FIRST_FAILURE_IDS = 8;
13
+ const OUTCOME_ATTR = "agent.outcome";
14
+ /** Rank the first failure of one trace. Throws when the spans belong to more than one trace. */
15
+ function rankFirstFailure(spans) {
16
+ const traceId = spans[0]?.traceId;
17
+ if (traceId === void 0) throw new TypeError("rankFirstFailure: no spans");
18
+ if (spans.some((span) => span.traceId !== traceId)) throw new TypeError("rankFirstFailure: spans belong to more than one trace");
19
+ const errors = spans.filter(isErrorSpan);
20
+ if (errors.length > 0) {
21
+ const innermost = withoutFailingDescendants(spans, errors);
22
+ if (innermost.length === 0) return ambiguous(traceId, "error-span", errors, "every failing span contains another failing span, so containment is cyclic");
23
+ return rank(traceId, "error-span", innermost);
82
24
  }
83
- ];
84
- /** Redact one string, adding the per-rule counts to `report`. */
85
- function redactSecrets(input, report = emptySecretFilterReport(), rules = DIAGNOSIS_SECRET_RULES) {
86
- let output = input;
87
- for (const rule of rules) {
88
- let hits = 0;
89
- rule.pattern.lastIndex = 0;
90
- output = output.replace(rule.pattern, (match, ...rest) => {
91
- hits += 1;
92
- const captured = rest.slice(0, countGroups(rule.pattern)).map((value) => typeof value === "string" ? value : "");
93
- return rule.replace(match, ...captured);
94
- });
95
- if (hits > 0) {
96
- report.redactionCount += hits;
97
- report.byRule[rule.id] = (report.byRule[rule.id] ?? 0) + hits;
98
- }
99
- }
100
- return output;
25
+ const failed = spans.filter((span) => span.attributes[OUTCOME_ATTR] === "fail");
26
+ if (failed.length > 0) return rank(traceId, "failed-outcome", failed);
27
+ return {
28
+ status: "none",
29
+ traceId,
30
+ reason: `none of ${spans.length} spans has status ERROR or an agent.outcome of error or fail`
31
+ };
101
32
  }
102
- /** Whether any rule matches: the miner's equivalent of trace-archive `holds_secret`. */
103
- function holdsSecret(input, rules = DIAGNOSIS_SECRET_RULES) {
104
- return rules.some((rule) => {
105
- rule.pattern.lastIndex = 0;
106
- const found = rule.pattern.test(input);
107
- rule.pattern.lastIndex = 0;
108
- return found;
109
- });
33
+ function isErrorSpan(span) {
34
+ return span.status === "ERROR" || span.attributes[OUTCOME_ATTR] === "error";
110
35
  }
111
- /** Redact every string leaf of a JSON-like value. Keys are kept; values are filtered. */
112
- function redactSecretsDeep(value, report) {
113
- if (typeof value === "string") return redactSecrets(value, report);
114
- if (Array.isArray(value)) return value.map((item) => redactSecretsDeep(item, report));
115
- if (value !== null && typeof value === "object") {
116
- const next = {};
117
- for (const [key, item] of Object.entries(value)) next[key] = redactSecretsDeep(item, report);
118
- return next;
36
+ /** The failing spans with no failing span beneath them. */
37
+ function withoutFailingDescendants(spans, failing) {
38
+ const parentOf = new Map(spans.map((span) => [span.spanId, span.parentSpanId]));
39
+ const explained = /* @__PURE__ */ new Set();
40
+ for (const span of failing) {
41
+ const seen = /* @__PURE__ */ new Set([span.spanId]);
42
+ let parent = span.parentSpanId;
43
+ while (parent !== null && parentOf.has(parent) && !seen.has(parent)) {
44
+ explained.add(parent);
45
+ seen.add(parent);
46
+ parent = parentOf.get(parent) ?? null;
47
+ }
119
48
  }
120
- return value;
49
+ return failing.filter((span) => !explained.has(span.spanId));
121
50
  }
122
- function emptySecretFilterReport() {
51
+ function rank(traceId, stage, candidates) {
52
+ if (candidates.length > 1) {
53
+ const untimed = candidates.filter((span) => span.endMs === null);
54
+ if (untimed.length > 0) return ambiguous(traceId, stage, candidates, `${untimed.length} of ${candidates.length} candidates have no end time, so their order is unknown`);
55
+ }
56
+ const ordered = [...candidates].sort((a, b) => (a.endMs ?? 0) - (b.endMs ?? 0) || a.spanId.localeCompare(b.spanId));
57
+ const first = ordered[0];
58
+ const tied = ordered.filter((span) => span.endMs === first.endMs);
59
+ if (tied.length > 1) return ambiguous(traceId, stage, tied, `${tied.length} candidates ended at the same instant, so none ranks first`);
60
+ const classification = stage === "error-span" ? classifyFailureReason(first.statusMessage) : null;
61
+ const later = ordered.slice(1);
123
62
  return {
124
- redactionCount: 0,
125
- byRule: {}
63
+ status: "found",
64
+ traceId,
65
+ stage,
66
+ spanId: first.spanId,
67
+ name: first.name,
68
+ kind: first.kind,
69
+ message: first.statusMessage,
70
+ classification,
71
+ blame: classification?.blame ?? "agent",
72
+ later: later.slice(0, 8).map((span) => span.spanId),
73
+ laterCount: later.length
126
74
  };
127
75
  }
128
- const groupCounts = /* @__PURE__ */ new WeakMap();
129
- function countGroups(pattern) {
130
- const cached = groupCounts.get(pattern);
131
- if (cached !== void 0) return cached;
132
- const count = (new RegExp(`${pattern.source}|`).exec("")?.length ?? 1) - 1;
133
- groupCounts.set(pattern, count);
134
- return count;
76
+ function ambiguous(traceId, stage, candidates, reason) {
77
+ const ids = candidates.map((span) => span.spanId).sort();
78
+ return {
79
+ status: "ambiguous",
80
+ traceId,
81
+ stage,
82
+ candidates: ids.slice(0, 8),
83
+ candidateCount: ids.length,
84
+ reason
85
+ };
135
86
  }
136
87
  //#endregion
137
88
  //#region src/diagnosis/spans.ts
@@ -175,10 +126,7 @@ function isContentAttribute(key) {
175
126
  * detection works on metadata-only runs without the payload itself surviving.
176
127
  */
177
128
  function ingestSpans(raw, options) {
178
- const secrets = {
179
- redactionCount: 0,
180
- byRule: {}
181
- };
129
+ const secrets = emptyRedactionReport();
182
130
  const dropped = /* @__PURE__ */ new Set();
183
131
  const seen = /* @__PURE__ */ new Set();
184
132
  const spans = [];
@@ -210,7 +158,7 @@ function ingestSpans(raw, options) {
210
158
  else if (firstTrace !== traceId) ambiguous.add(spanId);
211
159
  const merged = mergedAttributes(record);
212
160
  const inputDigest = digestInput(merged, digestKey);
213
- const attributes = redactSecretsDeep(merged, secrets);
161
+ const attributes = redact(merged, { report: secrets }).value;
214
162
  if (!options.contentIncluded) {
215
163
  for (const [key, value] of Object.entries(attributes)) if (isContentAttribute(key) || value !== null && typeof value === "object") {
216
164
  delete attributes[key];
@@ -218,10 +166,10 @@ function ingestSpans(raw, options) {
218
166
  }
219
167
  }
220
168
  const status = readStatus(record);
221
- const statusMessage = status.message === null ? null : redactSecrets(status.message, secrets);
169
+ const statusMessage = status.message === null ? null : redactText(status.message, { report: secrets });
222
170
  const toolName = firstString(attributes, TOOL_NAME_ATTR_KEYS);
223
171
  const model = firstString(attributes, MODEL_ATTR_KEYS);
224
- const name = redactSecrets(stringOr(record.name, "unknown"), secrets);
172
+ const name = redactText(stringOr(record.name, "unknown"), { report: secrets });
225
173
  spans.push({
226
174
  traceId,
227
175
  spanId,
@@ -413,7 +361,7 @@ function runDeterministicPass(spans) {
413
361
  validation,
414
362
  capabilities,
415
363
  skipped,
416
- facts: executionFacts(spans, traces.size),
364
+ facts: executionFacts(spans, traces),
417
365
  findings,
418
366
  window: timeWindow(spans)
419
367
  };
@@ -524,7 +472,7 @@ function failedRunFindings(traces) {
524
472
  recommendation: "Group the failed runs by their root status message and fix the largest group first."
525
473
  }];
526
474
  }
527
- function executionFacts(spans, runs) {
475
+ function executionFacts(spans, traces) {
528
476
  const spansByKind = {};
529
477
  const models = /* @__PURE__ */ new Set();
530
478
  let errorSpans = 0;
@@ -536,12 +484,13 @@ function executionFacts(spans, runs) {
536
484
  if (span.model) models.add(span.model);
537
485
  }
538
486
  const facts = {
539
- runs,
487
+ runs: traces.size,
540
488
  spans: spans.length,
541
489
  spansByKind,
542
490
  errorSpans,
543
491
  toolCalls,
544
492
  models: [...models].sort(),
493
+ firstFailures: [...traces.keys()].sort().map((traceId) => rankFirstFailure(traces.get(traceId))),
545
494
  execution: null
546
495
  };
547
496
  try {
@@ -1169,7 +1118,7 @@ async function diagnoseSpans(spans, context, options) {
1169
1118
  if (context.subject === "customer" && context.topology !== void 0) throw new TypeError("diagnoseSpans: topology analysis is internal only; a customer context must not carry one");
1170
1119
  const contentIncluded = context.contentIncluded === true;
1171
1120
  const { spans: filtered, report: ingest } = ingestSpans(spans, { contentIncluded });
1172
- const focus = context.focus === void 0 ? void 0 : redactSecrets(context.focus, ingest.secrets);
1121
+ const focus = context.focus === void 0 ? void 0 : redactText(context.focus, { report: ingest.secrets });
1173
1122
  const deterministic = runDeterministicPass(filtered);
1174
1123
  const skipped = [...deterministic.skipped];
1175
1124
  const ambiguous = new Set(ingest.ambiguousSpanIds);
@@ -1224,7 +1173,7 @@ async function diagnoseSpans(spans, context, options) {
1224
1173
  reason: run.failure ?? "failed"
1225
1174
  });
1226
1175
  if (context.subject === "internal" && context.topology) {
1227
- const topology = redactSecretsDeep(context.topology, ingest.secrets);
1176
+ const topology = redact(context.topology, { report: ingest.secrets }).value;
1228
1177
  const reading = await runTopologyPass(topology, new Set((topology.runs ?? []).map((run) => run.id).filter((id) => typeof id === "string")), options.model, options.signal);
1229
1178
  notes.push(...reading.notes);
1230
1179
  questions.push(...reading.questions);
@@ -1241,7 +1190,7 @@ async function diagnoseSpans(spans, context, options) {
1241
1190
  const document = {
1242
1191
  schemaVersion: 1,
1243
1192
  subject: {
1244
- label: redactSecrets(context.label, ingest.secrets),
1193
+ label: redactText(context.label, { report: ingest.secrets }),
1245
1194
  runCount: traces.size,
1246
1195
  window: deterministic.window,
1247
1196
  contentIncluded
@@ -1251,7 +1200,7 @@ async function diagnoseSpans(spans, context, options) {
1251
1200
  skipped,
1252
1201
  redaction: {
1253
1202
  redactionCount: ingest.secrets.redactionCount,
1254
- byRule: { ...ingest.secrets.byRule },
1203
+ byRule: { ...ingest.secrets.byDetector },
1255
1204
  droppedAttributes: ingest.droppedAttributes
1256
1205
  }
1257
1206
  },
@@ -1328,6 +1277,6 @@ function totalUsage(runs, pricing) {
1328
1277
  };
1329
1278
  }
1330
1279
  //#endregion
1331
- export { DEFAULT_MAX_MODEL_TRACES, DIAGNOSIS_FINDINGS_SCHEMA_ID, DIAGNOSIS_SECRET_RULES, SECRET_ASSIGNMENT_PATTERN, diagnoseSpans, epochMillis, holdsSecret, ingestSpans, isContentAttribute, nodeHttpPrimeBridgeTransport, redactSecrets, redactSecretsDeep, validateDiagnosisFindings };
1280
+ export { DEFAULT_MAX_MODEL_TRACES, DIAGNOSIS_FINDINGS_SCHEMA_ID, MAX_FIRST_FAILURE_IDS, diagnoseSpans, epochMillis, ingestSpans, isContentAttribute, nodeHttpPrimeBridgeTransport, rankFirstFailure, validateDiagnosisFindings };
1332
1281
 
1333
1282
  //# sourceMappingURL=index.js.map