@tangle-network/agent-eval 0.215.0 → 0.216.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 (192) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/adapters/http.d.ts +3 -3
  3. package/dist/{agent-profile-BGyt2z8U.d.ts → agent-profile-CIA2Atnt.d.ts} +5 -5
  4. package/dist/{agent-profile-BGyt2z8U.d.ts.map → agent-profile-CIA2Atnt.d.ts.map} +1 -1
  5. package/dist/agreement-irr-DsTURxdr.js +186 -0
  6. package/dist/agreement-irr-DsTURxdr.js.map +1 -0
  7. package/dist/analyst/index.d.ts +487 -14
  8. package/dist/analyst/index.d.ts.map +1 -1
  9. package/dist/analyst/index.js +1545 -10
  10. package/dist/analyst/index.js.map +1 -1
  11. package/dist/{analyze-runs-BlslTkOJ.d.ts → analyze-runs-CSDAh8A7.d.ts} +4 -4
  12. package/dist/{analyze-runs-BlslTkOJ.d.ts.map → analyze-runs-CSDAh8A7.d.ts.map} +1 -1
  13. package/dist/{benchmark-command-CMmeV-_Z.js → benchmark-command-CByl9dxG.js} +18 -34
  14. package/dist/benchmark-command-CByl9dxG.js.map +1 -0
  15. package/dist/benchmarks/index.d.ts +5 -5
  16. package/dist/benchmarks/index.js +3 -3
  17. package/dist/campaign/index.d.ts +7 -7
  18. package/dist/campaign/index.js +5 -5
  19. package/dist/{campaign-Cuw3DQKF.js → campaign-BQ-Jujuj.js} +7 -7
  20. package/dist/{campaign-Cuw3DQKF.js.map → campaign-BQ-Jujuj.js.map} +1 -1
  21. package/dist/{chat-client-Bnx8NZe4.js → chat-client-DthPOYGd.js} +2 -2
  22. package/dist/{chat-client-Bnx8NZe4.js.map → chat-client-DthPOYGd.js.map} +1 -1
  23. package/dist/{chat-json-call-CZI1NoGZ.js → chat-json-call-BrKsyspg.js} +2 -2
  24. package/dist/{chat-json-call-CZI1NoGZ.js.map → chat-json-call-BrKsyspg.js.map} +1 -1
  25. package/dist/cli.js +4 -4
  26. package/dist/cluster-bootstrap-B3JywQQn.js +66 -0
  27. package/dist/cluster-bootstrap-B3JywQQn.js.map +1 -0
  28. package/dist/contract/index.d.ts +11 -11
  29. package/dist/contract/index.js +8 -8
  30. package/dist/{cost-ledger-DbQdN3nO.d.ts → cost-ledger-CO7UyEcQ.d.ts} +3 -8
  31. package/dist/{cost-ledger-DbQdN3nO.d.ts.map → cost-ledger-CO7UyEcQ.d.ts.map} +1 -1
  32. package/dist/{cost-ledger-DFOeLeJi.js → cost-ledger-D2FnJPBF.js} +27 -23
  33. package/dist/cost-ledger-D2FnJPBF.js.map +1 -0
  34. package/dist/{default-registry-BAiTePcB.d.ts → default-registry-BrWh62zf.d.ts} +6 -6
  35. package/dist/{default-registry-BAiTePcB.d.ts.map → default-registry-BrWh62zf.d.ts.map} +1 -1
  36. package/dist/{default-registry-BhYGMVbV.js → default-registry-Cn1LQ2Ve.js} +742 -757
  37. package/dist/default-registry-Cn1LQ2Ve.js.map +1 -0
  38. package/dist/{define-agent-eval-CZdBPUkk.d.ts → define-agent-eval-CEWkX5wZ.d.ts} +8 -8
  39. package/dist/{define-agent-eval-CZdBPUkk.d.ts.map → define-agent-eval-CEWkX5wZ.d.ts.map} +1 -1
  40. package/dist/{define-agent-eval-FGtpqnh4.js → define-agent-eval-Ch3MWX6k.js} +3 -3
  41. package/dist/{define-agent-eval-FGtpqnh4.js.map → define-agent-eval-Ch3MWX6k.js.map} +1 -1
  42. package/dist/diagnosis/index.d.ts +2 -2
  43. package/dist/{dspy-rlm-engine-OMBXVN0u.js → dspy-rlm-engine-D-KX_e64.js} +3 -3
  44. package/dist/{dspy-rlm-engine-OMBXVN0u.js.map → dspy-rlm-engine-D-KX_e64.js.map} +1 -1
  45. package/dist/{engine-BzOR5Ygn.d.ts → engine-C_zNWfM8.d.ts} +5 -5
  46. package/dist/{engine-BzOR5Ygn.d.ts.map → engine-C_zNWfM8.d.ts.map} +1 -1
  47. package/dist/evaluation-Cn2dRZIz.d.ts +75 -0
  48. package/dist/evaluation-Cn2dRZIz.d.ts.map +1 -0
  49. package/dist/evaluation.d.ts +2 -74
  50. package/dist/evaluation.js +1 -1
  51. package/dist/{exact-types-DjhfZglz.d.ts → exact-types-CD0lf5Qd.d.ts} +2 -2
  52. package/dist/{exact-types-DjhfZglz.d.ts.map → exact-types-CD0lf5Qd.d.ts.map} +1 -1
  53. package/dist/experiment/index.d.ts +1 -1
  54. package/dist/{external-optimizer-process-DCZx5PdG.js → external-optimizer-process-nnsY5D_4.js} +2 -2
  55. package/dist/{external-optimizer-process-DCZx5PdG.js.map → external-optimizer-process-nnsY5D_4.js.map} +1 -1
  56. package/dist/{external-optimizer-subprocess-CA3aXT8I.js → external-optimizer-subprocess-DcerlZSG.js} +263 -4
  57. package/dist/external-optimizer-subprocess-DcerlZSG.js.map +1 -0
  58. package/dist/{feedback-trajectory-CX01700m.d.ts → feedback-trajectory-DkaDj0dj.d.ts} +3 -3
  59. package/dist/{feedback-trajectory-CX01700m.d.ts.map → feedback-trajectory-DkaDj0dj.d.ts.map} +1 -1
  60. package/dist/fuzz.d.ts +1 -1
  61. package/dist/fuzz.js +1 -1
  62. package/dist/{index-D0_l25We.d.ts → index-CPJJr98o.d.ts} +2 -2
  63. package/dist/{index-D0_l25We.d.ts.map → index-CPJJr98o.d.ts.map} +1 -1
  64. package/dist/{index-DNgf5gyG.d.ts → index-Ch9VxCpK.d.ts} +2 -2
  65. package/dist/{index-DNgf5gyG.d.ts.map → index-Ch9VxCpK.d.ts.map} +1 -1
  66. package/dist/{index-BTwxP7L0.d.ts → index-DlH0Y9gI.d.ts} +10 -10
  67. package/dist/{index-BTwxP7L0.d.ts.map → index-DlH0Y9gI.d.ts.map} +1 -1
  68. package/dist/{index-D_rfXep9.d.ts → index-NvGBiO8H.d.ts} +10 -10
  69. package/dist/{index-D_rfXep9.d.ts.map → index-NvGBiO8H.d.ts.map} +1 -1
  70. package/dist/{index-BWiAAWrk.d.ts → index-oQ4aHziK.d.ts} +9 -9
  71. package/dist/{index-BWiAAWrk.d.ts.map → index-oQ4aHziK.d.ts.map} +1 -1
  72. package/dist/index.d.ts +25 -25
  73. package/dist/index.js +16 -15
  74. package/dist/index.js.map +1 -1
  75. package/dist/{integrity-zloavsM_.d.ts → integrity-CCAxGVK6.d.ts} +2 -2
  76. package/dist/{integrity-zloavsM_.d.ts.map → integrity-CCAxGVK6.d.ts.map} +1 -1
  77. package/dist/{judge-gate-B1_O0QIs.d.ts → judge-gate-DNcUrRFA.d.ts} +2 -2
  78. package/dist/{judge-gate-B1_O0QIs.d.ts.map → judge-gate-DNcUrRFA.d.ts.map} +1 -1
  79. package/dist/{kind-factory-CMlOx08-.js → kind-factory-CbZ-6tvu.js} +3 -3
  80. package/dist/{kind-factory-CMlOx08-.js.map → kind-factory-CbZ-6tvu.js.map} +1 -1
  81. package/dist/{llm-client-C_o62yG1.js → llm-client-DQveoxSM.js} +2 -2
  82. package/dist/{llm-client-C_o62yG1.js.map → llm-client-DQveoxSM.js.map} +1 -1
  83. package/dist/{llm-judge-Dw0rDpve.js → llm-judge-PXV7Xljl.js} +5 -5
  84. package/dist/{llm-judge-Dw0rDpve.js.map → llm-judge-PXV7Xljl.js.map} +1 -1
  85. package/dist/matrix/index.d.ts +2 -2
  86. package/dist/{matrix-CQwid3kj.d.ts → matrix-CHMiebFx.d.ts} +4 -4
  87. package/dist/{matrix-CQwid3kj.d.ts.map → matrix-CHMiebFx.d.ts.map} +1 -1
  88. package/dist/meta-eval/index.d.ts +2 -2
  89. package/dist/meta-eval/index.js +1 -62
  90. package/dist/meta-eval/index.js.map +1 -1
  91. package/dist/{mint-CDy-brUR.d.ts → mint-DCGoBYhB.d.ts} +2 -2
  92. package/dist/{mint-CDy-brUR.d.ts.map → mint-DCGoBYhB.d.ts.map} +1 -1
  93. package/dist/multishot/golden/index.d.ts +1 -1
  94. package/dist/multishot/index.d.ts +2 -2
  95. package/dist/openapi.json +1 -1
  96. package/dist/pipelines/index.js +1 -1
  97. package/dist/{prime-protocol-B7et3tI7.d.ts → prime-protocol-CEE4BR9N.d.ts} +3 -3
  98. package/dist/{prime-protocol-B7et3tI7.d.ts.map → prime-protocol-CEE4BR9N.d.ts.map} +1 -1
  99. package/dist/{produced-state-C1cTYK6w.js → produced-state-ZCtDBxAE.js} +4 -4
  100. package/dist/{produced-state-C1cTYK6w.js.map → produced-state-ZCtDBxAE.js.map} +1 -1
  101. package/dist/{proposal-findings-CXblsskH.js → proposal-findings-BZiMTzAF.js} +2 -36
  102. package/dist/proposal-findings-BZiMTzAF.js.map +1 -0
  103. package/dist/{registry-BL7H33tj.d.ts → registry-JYfPxcVz.d.ts} +11 -13
  104. package/dist/registry-JYfPxcVz.d.ts.map +1 -0
  105. package/dist/{release-confidence-C4kI7lQi.d.ts → release-confidence-BK2QCB5M.d.ts} +3 -3
  106. package/dist/{release-confidence-C4kI7lQi.d.ts.map → release-confidence-BK2QCB5M.d.ts.map} +1 -1
  107. package/dist/{report-command-CtIIsQKP.js → report-command-y8H6RSX8.js} +23 -7
  108. package/dist/report-command-y8H6RSX8.js.map +1 -0
  109. package/dist/reporting.d.ts +3 -3
  110. package/dist/{researcher-DuIJ9IaA.d.ts → researcher-f6mZhh58.d.ts} +5 -5
  111. package/dist/{researcher-DuIJ9IaA.d.ts.map → researcher-f6mZhh58.d.ts.map} +1 -1
  112. package/dist/{reward-hacking-C6Kp54Av.d.ts → reward-hacking-DHA7c1l8.d.ts} +2 -2
  113. package/dist/{reward-hacking-C6Kp54Av.d.ts.map → reward-hacking-DHA7c1l8.d.ts.map} +1 -1
  114. package/dist/rl.d.ts +8 -8
  115. package/dist/rl.js +1 -1
  116. package/dist/rollout/index.d.ts +2 -2
  117. package/dist/{rubric-predictive-validity-BiNNEjpG.d.ts → rubric-predictive-validity-2SgHxoa5.d.ts} +2 -2
  118. package/dist/{rubric-predictive-validity-BiNNEjpG.d.ts.map → rubric-predictive-validity-2SgHxoa5.d.ts.map} +1 -1
  119. package/dist/{run-record-p2AYTrCn.d.ts → run-record-D1Hw-Jml.d.ts} +2 -2
  120. package/dist/{run-record-p2AYTrCn.d.ts.map → run-record-D1Hw-Jml.d.ts.map} +1 -1
  121. package/dist/search/index.d.ts +2 -2
  122. package/dist/{search-kernel-BWp7hfJn.d.ts → search-kernel-CpcKH5Ih.d.ts} +4 -4
  123. package/dist/{search-kernel-BWp7hfJn.d.ts.map → search-kernel-CpcKH5Ih.d.ts.map} +1 -1
  124. package/dist/{semantic-concept-judge-sDBNg_mI.js → semantic-concept-judge-zQBG9hHU.js} +6 -6
  125. package/dist/{semantic-concept-judge-sDBNg_mI.js.map → semantic-concept-judge-zQBG9hHU.js.map} +1 -1
  126. package/dist/{server-BRpadnVt.js → server-DbcC7xMl.js} +3 -3
  127. package/dist/{server-BRpadnVt.js.map → server-DbcC7xMl.js.map} +1 -1
  128. package/dist/{skillopt-optimization-method-CvaFGm95.js → skillopt-optimization-method-CCtzralq.js} +5 -5
  129. package/dist/{skillopt-optimization-method-CvaFGm95.js.map → skillopt-optimization-method-CCtzralq.js.map} +1 -1
  130. package/dist/{statistical-heldout-DZaTo3gZ.d.ts → statistical-heldout-BeR4bOdg.d.ts} +3 -3
  131. package/dist/{statistical-heldout-DZaTo3gZ.d.ts.map → statistical-heldout-BeR4bOdg.d.ts.map} +1 -1
  132. package/dist/{store-otlp-0AiS29kg.js → store-otlp-DtB4Slsr.js} +2 -2
  133. package/dist/{store-otlp-0AiS29kg.js.map → store-otlp-DtB4Slsr.js.map} +1 -1
  134. package/dist/{store-tool-spans-DuvZ4YWb.d.ts → store-tool-spans-DR1SrCLK.d.ts} +7 -7
  135. package/dist/{store-tool-spans-DuvZ4YWb.d.ts.map → store-tool-spans-DR1SrCLK.d.ts.map} +1 -1
  136. package/dist/{store-tool-spans-BAcBBSM8.js → store-tool-spans-fZIigrpP.js} +3 -3
  137. package/dist/{store-tool-spans-BAcBBSM8.js.map → store-tool-spans-fZIigrpP.js.map} +1 -1
  138. package/dist/{summary-report-CK0ueoJd.d.ts → summary-report-C-CtItCN.d.ts} +2 -2
  139. package/dist/{summary-report-CK0ueoJd.d.ts.map → summary-report-C-CtItCN.d.ts.map} +1 -1
  140. package/dist/supervisor-run/index.d.ts +1 -1
  141. package/dist/supervisor-run/index.d.ts.map +1 -1
  142. package/dist/supervisor-run/index.js +1 -1
  143. package/dist/systemone-CpTLAlqb.d.ts +135 -0
  144. package/dist/systemone-CpTLAlqb.d.ts.map +1 -0
  145. package/dist/{systemone-review-DTClwgmE.js → systemone-review-BZWfrtq1.js} +2 -2
  146. package/dist/{systemone-review-DTClwgmE.js.map → systemone-review-BZWfrtq1.js.map} +1 -1
  147. package/dist/{systemone-review-BReh3mvm.d.ts → systemone-review-B_yo1xsd.d.ts} +2 -2
  148. package/dist/{systemone-review-BReh3mvm.d.ts.map → systemone-review-B_yo1xsd.d.ts.map} +1 -1
  149. package/dist/systemone.d.ts +4 -134
  150. package/dist/systemone.js +1 -1
  151. package/dist/terminal-record-BHocwFw1.js.map +1 -1
  152. package/dist/{tool-groups-DOriCbkR.d.ts → tool-groups-mcxOXVlb.d.ts} +3 -3
  153. package/dist/tool-groups-mcxOXVlb.d.ts.map +1 -0
  154. package/dist/{tool-waste-BYt5rdt8.js → tool-waste-D52PqU9Q.js} +3 -156
  155. package/dist/tool-waste-D52PqU9Q.js.map +1 -0
  156. package/dist/{trace-questions-RCaYLkwH.d.ts → trace-questions-DG7nqLQ7.d.ts} +4 -4
  157. package/dist/{trace-questions-RCaYLkwH.d.ts.map → trace-questions-DG7nqLQ7.d.ts.map} +1 -1
  158. package/dist/trace-repair/index.d.ts +3 -3
  159. package/dist/traces.d.ts +6 -6
  160. package/dist/traces.js +3 -3
  161. package/dist/{types-CMnPcbW5.d.ts → types-B4C5nFw6.d.ts} +6 -6
  162. package/dist/{types-CMnPcbW5.d.ts.map → types-B4C5nFw6.d.ts.map} +1 -1
  163. package/dist/{types-DjOMwGY_.d.ts → types-BqkVmHfv.d.ts} +7 -1
  164. package/dist/types-BqkVmHfv.d.ts.map +1 -0
  165. package/dist/{types-Dj0Qv2qi.d.ts → types-CfZMIzB_.d.ts} +3 -3
  166. package/dist/{types-Dj0Qv2qi.d.ts.map → types-CfZMIzB_.d.ts.map} +1 -1
  167. package/dist/{types-Lub7o6bN.d.ts → types-DBZ7keha.d.ts} +2 -2
  168. package/dist/{types-Lub7o6bN.d.ts.map → types-DBZ7keha.d.ts.map} +1 -1
  169. package/dist/{types-CW5b90JH.js → types-IXD2HJzu.js} +16 -3
  170. package/dist/types-IXD2HJzu.js.map +1 -0
  171. package/dist/{types-KEkKkETv.d.ts → types-oKRhQAde.d.ts} +347 -6
  172. package/dist/types-oKRhQAde.d.ts.map +1 -0
  173. package/dist/wire/index.d.ts +3 -3
  174. package/dist/wire/index.js +1 -1
  175. package/docs/campaign-proposers.md +3 -0
  176. package/docs/concepts.md +1 -0
  177. package/docs/finding-layers.md +69 -0
  178. package/package.json +1 -1
  179. package/dist/benchmark-command-CMmeV-_Z.js.map +0 -1
  180. package/dist/cost-ledger-DFOeLeJi.js.map +0 -1
  181. package/dist/default-registry-BhYGMVbV.js.map +0 -1
  182. package/dist/evaluation.d.ts.map +0 -1
  183. package/dist/external-optimizer-subprocess-CA3aXT8I.js.map +0 -1
  184. package/dist/proposal-findings-CXblsskH.js.map +0 -1
  185. package/dist/registry-BL7H33tj.d.ts.map +0 -1
  186. package/dist/report-command-CtIIsQKP.js.map +0 -1
  187. package/dist/systemone.d.ts.map +0 -1
  188. package/dist/tool-groups-DOriCbkR.d.ts.map +0 -1
  189. package/dist/tool-waste-BYt5rdt8.js.map +0 -1
  190. package/dist/types-CW5b90JH.js.map +0 -1
  191. package/dist/types-DjOMwGY_.d.ts.map +0 -1
  192. package/dist/types-KEkKkETv.d.ts.map +0 -1
@@ -1,9 +1,11 @@
1
1
  import { t as canonicalJson } from "./verdict-cache-BQEsVy9n.js";
2
- import { c as costForTokenPricing, i as CostLedger } from "./cost-ledger-DFOeLeJi.js";
2
+ import { c as costForTokenPricing, i as CostLedger } from "./cost-ledger-D2FnJPBF.js";
3
3
  import { n as appendSearchLedgerLine, r as tryWithSearchLedgerFileLock } from "./search-ledger-file-BqOo-bVo.js";
4
- import { f as ModelSubstitutionError, g as assertServedModelPolicy, h as assertServedModel } from "./llm-client-C_o62yG1.js";
4
+ import { n as ANALYST_SEVERITIES, r as FINDING_SCOPE_FIELDS } from "./types-IXD2HJzu.js";
5
+ import { f as ModelSubstitutionError, g as assertServedModelPolicy, h as assertServedModel } from "./llm-client-DQveoxSM.js";
5
6
  import { createRequire } from "node:module";
6
7
  import { randomBytes } from "node:crypto";
8
+ import { z } from "zod";
7
9
  import { isAbsolute, join, resolve } from "node:path";
8
10
  import { tmpdir } from "node:os";
9
11
  import { spawn } from "node:child_process";
@@ -112,6 +114,263 @@ function createRunCostLedger(input) {
112
114
  });
113
115
  }
114
116
  //#endregion
117
+ //#region src/analyst/finding-scope.ts
118
+ /**
119
+ * What a finding is about and what it was measured on — AnalystFinding 1.1.0.
120
+ *
121
+ * A 1.0.0 finding states a claim with no layer and no population, so "a flat
122
+ * team beat a deep hierarchy", measured on 4 runs of one play where run 2
123
+ * inherited run 1's code, reads exactly like a lab-wide rule. Schema 1.1.0
124
+ * makes the population part of the record:
125
+ *
126
+ * - `layer` names the level the claim is about, on one ladder from a single
127
+ * event up to the whole lab, plus `meta` for findings about the measurement
128
+ * itself (a judge, a ruler, an analyst).
129
+ * - `scope` names the measured population, its size and time window, and the
130
+ * domain path it was drawn from.
131
+ * - `method` says whether the claim was computed, measured or judged; a
132
+ * judged claim without calibration reads as uncalibrated.
133
+ * - `evidence_units` lists the measured units with their lineage. When it is
134
+ * present the stored `scope.n` and `scope.population` must equal it, so the
135
+ * declared population cannot drift from the evidence.
136
+ *
137
+ * A claim moves above the layer it was measured at only through `promote`.
138
+ */
139
+ /**
140
+ * The layer ladder, lowest first. `problem` is what discovery-lab calls a
141
+ * theatre. `meta` sits outside the ladder: it is about the instrument, not the
142
+ * agents, so it never promotes and never bounds another layer.
143
+ */
144
+ const FINDING_LAYERS = [
145
+ "event",
146
+ "turn",
147
+ "agent",
148
+ "team",
149
+ "run",
150
+ "play",
151
+ "problem",
152
+ "domain",
153
+ "lab",
154
+ "meta"
155
+ ];
156
+ /** Rank on the ladder; `meta` has none. */
157
+ function findingLayerRank(layer) {
158
+ return layer === "meta" ? null : FINDING_LAYERS.indexOf(layer);
159
+ }
160
+ const nonEmpty = z.string().refine((value) => value.trim().length > 0, { message: "must be a non-empty string" });
161
+ const timestamp = z.string().refine((value) => Number.isFinite(Date.parse(value)), { message: "must be a valid timestamp" });
162
+ const finite = z.number().refine(Number.isFinite, { message: "must be finite" });
163
+ const unitRate = finite.refine((value) => value >= 0 && value <= 1, { message: "must be in [0,1]" });
164
+ const layerSchema = z.enum(FINDING_LAYERS);
165
+ const scopeSchema = z.object({
166
+ population: z.array(nonEmpty),
167
+ n: z.number().int().nonnegative(),
168
+ window: z.object({
169
+ from: timestamp,
170
+ to: timestamp
171
+ }).strict(),
172
+ domain_path: z.array(nonEmpty).min(1).optional()
173
+ }).strict();
174
+ const methodSchema = z.object({
175
+ kind: z.enum([
176
+ "computed",
177
+ "measured",
178
+ "judged"
179
+ ]),
180
+ name: nonEmpty,
181
+ version: nonEmpty,
182
+ calibration: z.object({
183
+ gold_n: z.number().int().positive(),
184
+ agreement: unitRate,
185
+ kappa: finite.refine((value) => value >= -1 && value <= 1, { message: "must be in [-1,1]" })
186
+ }).strict().optional()
187
+ }).strict();
188
+ const measureSchema = z.object({
189
+ name: nonEmpty,
190
+ value: finite,
191
+ unit: z.string(),
192
+ interval: z.tuple([finite, finite]).optional(),
193
+ level: finite.refine((value) => value > 0 && value < 1, { message: "must be in (0,1)" }).optional()
194
+ }).strict();
195
+ const evidenceUnitSchema = z.object({
196
+ id: nonEmpty,
197
+ layer: layerSchema,
198
+ derived_from: nonEmpty.nullable().optional()
199
+ }).strict();
200
+ const findingObject = z.object({
201
+ schema_version: z.enum(["1.0.0", "1.1.0"]),
202
+ finding_id: nonEmpty,
203
+ analyst_id: nonEmpty,
204
+ produced_at: timestamp,
205
+ severity: z.enum(ANALYST_SEVERITIES),
206
+ area: nonEmpty,
207
+ claim: nonEmpty,
208
+ rationale: z.string().optional(),
209
+ evidence_refs: z.array(z.object({
210
+ kind: z.enum([
211
+ "span",
212
+ "event",
213
+ "artifact",
214
+ "finding",
215
+ "metric"
216
+ ]),
217
+ uri: nonEmpty,
218
+ excerpt: z.string().optional()
219
+ }).strict()),
220
+ recommended_action: z.string().optional(),
221
+ validation_plan: z.string().optional(),
222
+ confidence: unitRate,
223
+ subject: z.string().optional(),
224
+ derived_from_judge: z.boolean().optional(),
225
+ metadata: z.record(z.string(), z.unknown()).optional(),
226
+ layer: layerSchema.optional(),
227
+ scope: scopeSchema.optional(),
228
+ method: methodSchema.optional(),
229
+ measure: measureSchema.optional(),
230
+ confounders: z.array(nonEmpty).optional(),
231
+ valid_for: nonEmpty.optional(),
232
+ claim_id: nonEmpty.optional(),
233
+ evidence_units: z.array(evidenceUnitSchema).min(1).optional()
234
+ }).strict();
235
+ function checkFinding(finding, context) {
236
+ const issue = (path, message) => context.addIssue({
237
+ code: "custom",
238
+ path,
239
+ message
240
+ });
241
+ if (finding.schema_version === "1.0.0") {
242
+ for (const field of FINDING_SCOPE_FIELDS) if (finding[field] !== void 0) issue([field], `${field} requires schema_version 1.1.0`);
243
+ return;
244
+ }
245
+ if (finding.layer === void 0) issue(["layer"], "1.1.0 findings require a layer");
246
+ if (finding.scope === void 0) issue(["scope"], "1.1.0 findings require a scope");
247
+ if (finding.method === void 0) issue(["method"], "1.1.0 findings require a method");
248
+ const { scope, measure, evidence_units: units } = finding;
249
+ if (scope) {
250
+ if (Date.parse(scope.window.from) > Date.parse(scope.window.to)) issue(["scope", "window"], "window.from must not be after window.to");
251
+ if (new Set(scope.population).size !== scope.population.length) issue(["scope", "population"], "population ids must be unique");
252
+ if (scope.population.length > 0 && scope.population.length !== scope.n) issue(["scope", "n"], `n ${scope.n} does not match ${scope.population.length} population ids`);
253
+ }
254
+ if (measure?.interval && measure.interval[0] > measure.interval[1]) issue(["measure", "interval"], "interval lower bound exceeds its upper bound");
255
+ if (measure?.level !== void 0 && measure.interval === void 0) issue(["measure", "level"], "level describes an interval; none is present");
256
+ if (finding.method?.kind !== "judged" && finding.method?.calibration !== void 0) issue(["method", "calibration"], "only judged findings carry a calibration");
257
+ if (!units) return;
258
+ const ids = units.map((unit) => unit.id);
259
+ if (new Set(ids).size !== ids.length) issue(["evidence_units"], "unit ids must be unique");
260
+ if (scope) {
261
+ if (scope.n !== ids.length) issue(["scope", "n"], `n ${scope.n} does not match ${ids.length} evidence units`);
262
+ const population = [...scope.population].sort();
263
+ const unitIds = [...ids].sort();
264
+ if (population.length !== unitIds.length || population.some((id, index) => id !== unitIds[index])) issue(["scope", "population"], "population must name exactly the evidence units");
265
+ }
266
+ const findingRank = finding.layer === void 0 ? null : findingLayerRank(finding.layer);
267
+ if (findingRank === null) return;
268
+ for (const [index, unit] of units.entries()) {
269
+ const unitRank = findingLayerRank(unit.layer);
270
+ if (unitRank !== null && unitRank > findingRank) issue([
271
+ "evidence_units",
272
+ index,
273
+ "layer"
274
+ ], `a ${finding.layer} finding cannot rest on a ${unit.layer} unit`);
275
+ }
276
+ }
277
+ /** The one validator for stored findings of either schema version. Unknown fields fail. */
278
+ const AnalystFindingSchema = findingObject.superRefine(checkFinding);
279
+ /** A finding admitted as candidate-generation input; same rules plus its origin. */
280
+ const ProposalFindingSchema = findingObject.extend({ proposal_origin: z.enum(["search", "production"]) }).strict().superRefine(checkFinding);
281
+ /** Validate one stored finding of schema 1.0.0 or 1.1.0. */
282
+ function parseAnalystFinding(value) {
283
+ const parsed = AnalystFindingSchema.safeParse(value);
284
+ if (parsed.success) return {
285
+ succeeded: true,
286
+ value: parsed.data
287
+ };
288
+ const issue = parsed.error.issues[0];
289
+ return {
290
+ succeeded: false,
291
+ error: {
292
+ path: (issue?.path ?? []).map(String).join("."),
293
+ message: issue?.message ?? "finding does not match the schema"
294
+ }
295
+ };
296
+ }
297
+ function readFindingScope(finding) {
298
+ if (finding.schema_version === "1.0.0" || !finding.scope || !finding.layer) return {
299
+ layer: "unknown",
300
+ n: "unknown",
301
+ independent_n: "unknown",
302
+ domain_path: null,
303
+ labels: ["unscoped"]
304
+ };
305
+ const labels = [];
306
+ if (finding.scope.n < 2) labels.push("anecdote");
307
+ if (finding.method?.kind === "judged" && finding.method.calibration === void 0) labels.push("uncalibrated");
308
+ const units = finding.evidence_units;
309
+ if (units?.some((unit) => unit.derived_from === void 0)) labels.push("lineage-unknown");
310
+ return {
311
+ layer: finding.layer,
312
+ n: finding.scope.n,
313
+ independent_n: units ? independentUnitCount(units) : "unknown",
314
+ domain_path: finding.scope.domain_path ?? null,
315
+ labels
316
+ };
317
+ }
318
+ /** Root token shared by every unit whose lineage was not recorded. */
319
+ const UNKNOWN_LINEAGE = "?unknown-lineage";
320
+ /**
321
+ * Lineage root of each unit, keyed by unit id. A unit derived from another
322
+ * unit in the list shares that unit's root; a unit derived from an id outside
323
+ * the list takes that id as its root; unknown lineage maps to one shared root.
324
+ */
325
+ function lineageRoots(units) {
326
+ const byId = new Map(units.map((unit) => [unit.id, unit]));
327
+ const roots = /* @__PURE__ */ new Map();
328
+ for (const unit of units) {
329
+ let current = unit;
330
+ let root = unit.id;
331
+ const seen = /* @__PURE__ */ new Set();
332
+ while (current && !seen.has(current.id)) {
333
+ seen.add(current.id);
334
+ if (current.derived_from === void 0) {
335
+ root = UNKNOWN_LINEAGE;
336
+ break;
337
+ }
338
+ if (current.derived_from === null) {
339
+ root = current.id;
340
+ break;
341
+ }
342
+ root = current.derived_from;
343
+ current = byId.get(current.derived_from);
344
+ }
345
+ roots.set(unit.id, root);
346
+ }
347
+ return roots;
348
+ }
349
+ /** Units with distinct lineage roots. */
350
+ function independentUnitCount(units) {
351
+ return new Set(lineageRoots(units).values()).size;
352
+ }
353
+ /** One entry per unit id, sorted; a later copy that records lineage fills an earlier unknown. */
354
+ function mergeEvidenceUnits(units) {
355
+ const byId = /* @__PURE__ */ new Map();
356
+ for (const unit of units) {
357
+ const existing = byId.get(unit.id);
358
+ if (!existing || existing.derived_from === void 0 && unit.derived_from !== void 0) byId.set(unit.id, { ...unit });
359
+ }
360
+ return [...byId.values()].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
361
+ }
362
+ /** The window spanning every finding's scope window. */
363
+ function spanningWindow(findings) {
364
+ const windows = findings.map((finding) => finding.scope.window);
365
+ return {
366
+ from: windows.map((w) => w.from).reduce((a, b) => Date.parse(b) < Date.parse(a) ? b : a),
367
+ to: windows.map((w) => w.to).reduce((a, b) => Date.parse(b) > Date.parse(a) ? b : a)
368
+ };
369
+ }
370
+ function mostSevere(findings) {
371
+ return ANALYST_SEVERITIES[Math.min(...findings.map((finding) => ANALYST_SEVERITIES.indexOf(finding.severity)))];
372
+ }
373
+ //#endregion
115
374
  //#region src/campaign/external-optimizer-contracts.ts
116
375
  const MAX_TIMER_DELAY_MS$1 = 2147483647;
117
376
  const MAXIMUM_JSON_BYTES = Math.min(constants$1.MAX_LENGTH - 1, constants$1.MAX_STRING_LENGTH);
@@ -1901,6 +2160,6 @@ function summarizeProcessOutput(capture, max = 4e3) {
1901
2160
  return `${compact.slice(0, headChars)}...[${compact.length - max} chars omitted]...${compact.slice(-tailChars)}`;
1902
2161
  }
1903
2162
  //#endregion
1904
- export { inMemoryCampaignStorage as C, fsCampaignStorage as S, removeCredentialEnvironment as _, closeServer as a, safePathComponent as b, waitForActiveHandlers as c, assertExternalOptimizerModelBudget as d, assertJsonValue as f, isRecord as g, isExternalTextCandidate as h, startExternalOptimizerModelProxy as i, DEFAULT_EXTERNAL_OPTIMIZER_CALLBACK_LIMITS as l, isCandidateText as m, closeExternalOptimizerResources as n, listenLocal as o, assertNoCredentialValues as p, runWithCleanup as r, sendJsonIfOpen as s, runExternalOptimizerProcess as t, DEFAULT_EXTERNAL_OPTIMIZER_PROCESS_LIMITS as u, resolveExternalOptimizerCallbackLimits as v, createRunCostLedger as x, resolveExternalOptimizerProcessLimits as y };
2163
+ export { parseAnalystFinding as A, ProposalFindingSchema as C, lineageRoots as D, independentUnitCount as E, inMemoryCampaignStorage as F, spanningWindow as M, createRunCostLedger as N, mergeEvidenceUnits as O, fsCampaignStorage as P, FINDING_LAYERS as S, findingLayerRank as T, removeCredentialEnvironment as _, closeServer as a, safePathComponent as b, waitForActiveHandlers as c, assertExternalOptimizerModelBudget as d, assertJsonValue as f, isRecord as g, isExternalTextCandidate as h, startExternalOptimizerModelProxy as i, readFindingScope as j, mostSevere as k, DEFAULT_EXTERNAL_OPTIMIZER_CALLBACK_LIMITS as l, isCandidateText as m, closeExternalOptimizerResources as n, listenLocal as o, assertNoCredentialValues as p, runWithCleanup as r, sendJsonIfOpen as s, runExternalOptimizerProcess as t, DEFAULT_EXTERNAL_OPTIMIZER_PROCESS_LIMITS as u, resolveExternalOptimizerCallbackLimits as v, UNKNOWN_LINEAGE as w, AnalystFindingSchema as x, resolveExternalOptimizerProcessLimits as y };
1905
2164
 
1906
- //# sourceMappingURL=external-optimizer-subprocess-CA3aXT8I.js.map
2165
+ //# sourceMappingURL=external-optimizer-subprocess-DcerlZSG.js.map