@kindgi/api 0.1.4-rc.1 → 0.1.4-rc.2

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 (217) hide show
  1. package/dist/agent-binding.d.ts +12 -2
  2. package/dist/agent-binding.d.ts.map +1 -1
  3. package/dist/agent-pins.d.ts.map +1 -1
  4. package/dist/agent-pins.js +4 -1
  5. package/dist/agent-pins.js.map +1 -1
  6. package/dist/app.d.ts +8 -0
  7. package/dist/app.d.ts.map +1 -1
  8. package/dist/app.js +23 -4
  9. package/dist/app.js.map +1 -1
  10. package/dist/deploy-versions.d.ts +8 -5
  11. package/dist/deploy-versions.d.ts.map +1 -1
  12. package/dist/deploy-versions.js +3 -9
  13. package/dist/deploy-versions.js.map +1 -1
  14. package/dist/errors.d.ts.map +1 -1
  15. package/dist/errors.js +25 -0
  16. package/dist/errors.js.map +1 -1
  17. package/dist/eval-case-binding.d.ts +10 -0
  18. package/dist/eval-case-binding.d.ts.map +1 -1
  19. package/dist/eval-run-binding.d.ts +14 -3
  20. package/dist/eval-run-binding.d.ts.map +1 -1
  21. package/dist/eval-run-binding.js.map +1 -1
  22. package/dist/flow-pins.d.ts +20 -7
  23. package/dist/flow-pins.d.ts.map +1 -1
  24. package/dist/flow-pins.js +36 -11
  25. package/dist/flow-pins.js.map +1 -1
  26. package/dist/gate-policy-binding.d.ts +164 -0
  27. package/dist/gate-policy-binding.d.ts.map +1 -0
  28. package/dist/gate-policy-binding.js +12 -0
  29. package/dist/gate-policy-binding.js.map +1 -0
  30. package/dist/gate.d.ts +56 -0
  31. package/dist/gate.d.ts.map +1 -0
  32. package/dist/gate.js +359 -0
  33. package/dist/gate.js.map +1 -0
  34. package/dist/handler-binding.d.ts +14 -2
  35. package/dist/handler-binding.d.ts.map +1 -1
  36. package/dist/index.d.ts +10 -4
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +3 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/judged-dispatcher.d.ts +16 -1
  41. package/dist/judged-dispatcher.d.ts.map +1 -1
  42. package/dist/judged-dispatcher.js +45 -6
  43. package/dist/judged-dispatcher.js.map +1 -1
  44. package/dist/judgment-binding.d.ts +38 -0
  45. package/dist/judgment-binding.d.ts.map +1 -1
  46. package/dist/judgment-binding.js +19 -0
  47. package/dist/judgment-binding.js.map +1 -1
  48. package/dist/live-version-binding.d.ts +206 -0
  49. package/dist/live-version-binding.d.ts.map +1 -0
  50. package/dist/live-version-binding.js +4 -0
  51. package/dist/live-version-binding.js.map +1 -0
  52. package/dist/middleware/authorize.d.ts.map +1 -1
  53. package/dist/middleware/authorize.js +13 -2
  54. package/dist/middleware/authorize.js.map +1 -1
  55. package/dist/middleware/project-ref.d.ts +25 -0
  56. package/dist/middleware/project-ref.d.ts.map +1 -0
  57. package/dist/middleware/project-ref.js +72 -0
  58. package/dist/middleware/project-ref.js.map +1 -0
  59. package/dist/openapi/generate.d.ts.map +1 -1
  60. package/dist/openapi/generate.js +4 -0
  61. package/dist/openapi/generate.js.map +1 -1
  62. package/dist/openapi/operations.d.ts +6 -0
  63. package/dist/openapi/operations.d.ts.map +1 -1
  64. package/dist/openapi/operations.js +504 -22
  65. package/dist/openapi/operations.js.map +1 -1
  66. package/dist/openapi/schemas.d.ts +37 -0
  67. package/dist/openapi/schemas.d.ts.map +1 -1
  68. package/dist/openapi/schemas.js +709 -5
  69. package/dist/openapi/schemas.js.map +1 -1
  70. package/dist/publish-refused.d.ts +18 -0
  71. package/dist/publish-refused.d.ts.map +1 -0
  72. package/dist/publish-refused.js +22 -0
  73. package/dist/publish-refused.js.map +1 -0
  74. package/dist/retention-binding.d.ts +29 -0
  75. package/dist/retention-binding.d.ts.map +1 -1
  76. package/dist/routes/agent-releases.d.ts +40 -0
  77. package/dist/routes/agent-releases.d.ts.map +1 -0
  78. package/dist/routes/agent-releases.js +462 -0
  79. package/dist/routes/agent-releases.js.map +1 -0
  80. package/dist/routes/agents.d.ts +7 -1
  81. package/dist/routes/agents.d.ts.map +1 -1
  82. package/dist/routes/agents.js +31 -3
  83. package/dist/routes/agents.js.map +1 -1
  84. package/dist/routes/approvals.d.ts.map +1 -1
  85. package/dist/routes/approvals.js +27 -9
  86. package/dist/routes/approvals.js.map +1 -1
  87. package/dist/routes/audit.d.ts.map +1 -1
  88. package/dist/routes/audit.js +7 -0
  89. package/dist/routes/audit.js.map +1 -1
  90. package/dist/routes/auth.js +1 -1
  91. package/dist/routes/auth.js.map +1 -1
  92. package/dist/routes/conversations.d.ts +0 -7
  93. package/dist/routes/conversations.d.ts.map +1 -1
  94. package/dist/routes/conversations.js +19 -3
  95. package/dist/routes/conversations.js.map +1 -1
  96. package/dist/routes/deployments.d.ts +6 -0
  97. package/dist/routes/deployments.d.ts.map +1 -1
  98. package/dist/routes/deployments.js +33 -5
  99. package/dist/routes/deployments.js.map +1 -1
  100. package/dist/routes/env.d.ts.map +1 -1
  101. package/dist/routes/env.js +1 -0
  102. package/dist/routes/env.js.map +1 -1
  103. package/dist/routes/eval-comparison.d.ts +2 -1
  104. package/dist/routes/eval-comparison.d.ts.map +1 -1
  105. package/dist/routes/eval-comparison.js +22 -9
  106. package/dist/routes/eval-comparison.js.map +1 -1
  107. package/dist/routes/flows.d.ts +14 -7
  108. package/dist/routes/flows.d.ts.map +1 -1
  109. package/dist/routes/flows.js +10 -8
  110. package/dist/routes/flows.js.map +1 -1
  111. package/dist/routes/gate-policies.d.ts +19 -0
  112. package/dist/routes/gate-policies.d.ts.map +1 -0
  113. package/dist/routes/gate-policies.js +191 -0
  114. package/dist/routes/gate-policies.js.map +1 -0
  115. package/dist/routes/gate-policy-spec.d.ts +17 -0
  116. package/dist/routes/gate-policy-spec.d.ts.map +1 -0
  117. package/dist/routes/gate-policy-spec.js +192 -0
  118. package/dist/routes/gate-policy-spec.js.map +1 -0
  119. package/dist/routes/gate-policy-wire.d.ts +3 -0
  120. package/dist/routes/gate-policy-wire.d.ts.map +1 -0
  121. package/dist/routes/gate-policy-wire.js +18 -0
  122. package/dist/routes/gate-policy-wire.js.map +1 -0
  123. package/dist/routes/hierarchy-errors.d.ts +11 -0
  124. package/dist/routes/hierarchy-errors.d.ts.map +1 -1
  125. package/dist/routes/hierarchy-errors.js +13 -0
  126. package/dist/routes/hierarchy-errors.js.map +1 -1
  127. package/dist/routes/judged-suites.js +7 -0
  128. package/dist/routes/judged-suites.js.map +1 -1
  129. package/dist/routes/judgments.d.ts +4 -1
  130. package/dist/routes/judgments.d.ts.map +1 -1
  131. package/dist/routes/judgments.js +92 -19
  132. package/dist/routes/judgments.js.map +1 -1
  133. package/dist/routes/live-scope-wire.d.ts +32 -0
  134. package/dist/routes/live-scope-wire.d.ts.map +1 -0
  135. package/dist/routes/live-scope-wire.js +71 -0
  136. package/dist/routes/live-scope-wire.js.map +1 -0
  137. package/dist/routes/policies.d.ts +6 -3
  138. package/dist/routes/policies.d.ts.map +1 -1
  139. package/dist/routes/policies.js +55 -3
  140. package/dist/routes/policies.js.map +1 -1
  141. package/dist/routes/projects.d.ts.map +1 -1
  142. package/dist/routes/projects.js +47 -3
  143. package/dist/routes/projects.js.map +1 -1
  144. package/dist/routes/retention.d.ts.map +1 -1
  145. package/dist/routes/retention.js +18 -2
  146. package/dist/routes/retention.js.map +1 -1
  147. package/dist/routes/reviewers.d.ts +8 -1
  148. package/dist/routes/reviewers.d.ts.map +1 -1
  149. package/dist/routes/reviewers.js +20 -3
  150. package/dist/routes/reviewers.js.map +1 -1
  151. package/dist/routes/runs.d.ts.map +1 -1
  152. package/dist/routes/runs.js +22 -13
  153. package/dist/routes/runs.js.map +1 -1
  154. package/dist/routes/secrets.d.ts.map +1 -1
  155. package/dist/routes/secrets.js +2 -0
  156. package/dist/routes/secrets.js.map +1 -1
  157. package/dist/routes/segments.d.ts +17 -0
  158. package/dist/routes/segments.d.ts.map +1 -0
  159. package/dist/routes/segments.js +68 -0
  160. package/dist/routes/segments.js.map +1 -0
  161. package/dist/routes/teams.d.ts.map +1 -1
  162. package/dist/routes/teams.js +42 -3
  163. package/dist/routes/teams.js.map +1 -1
  164. package/dist/routes/uuid-param.d.ts +11 -0
  165. package/dist/routes/uuid-param.d.ts.map +1 -0
  166. package/dist/routes/uuid-param.js +19 -0
  167. package/dist/routes/uuid-param.js.map +1 -0
  168. package/openapi.json +6995 -3625
  169. package/package.json +21 -21
  170. package/src/agent-binding.ts +12 -2
  171. package/src/agent-pins.ts +3 -1
  172. package/src/app.ts +37 -3
  173. package/src/deploy-versions.ts +11 -14
  174. package/src/errors.ts +25 -0
  175. package/src/eval-case-binding.ts +7 -0
  176. package/src/eval-run-binding.ts +24 -3
  177. package/src/flow-pins.ts +49 -9
  178. package/src/gate-policy-binding.ts +171 -0
  179. package/src/gate.ts +467 -0
  180. package/src/handler-binding.ts +14 -2
  181. package/src/index.ts +46 -1
  182. package/src/judged-dispatcher.ts +74 -6
  183. package/src/judgment-binding.ts +62 -0
  184. package/src/live-version-binding.ts +237 -0
  185. package/src/middleware/authorize.ts +18 -2
  186. package/src/middleware/project-ref.ts +88 -0
  187. package/src/openapi/generate.ts +5 -0
  188. package/src/openapi/operations.ts +609 -22
  189. package/src/openapi/schemas.ts +788 -5
  190. package/src/publish-refused.ts +31 -0
  191. package/src/retention-binding.ts +30 -0
  192. package/src/routes/agent-releases.ts +581 -0
  193. package/src/routes/agents.ts +43 -2
  194. package/src/routes/approvals.ts +36 -8
  195. package/src/routes/audit.ts +10 -0
  196. package/src/routes/auth.ts +1 -1
  197. package/src/routes/conversations.ts +31 -3
  198. package/src/routes/deployments.ts +50 -5
  199. package/src/routes/env.ts +1 -0
  200. package/src/routes/eval-comparison.ts +24 -10
  201. package/src/routes/flows.ts +27 -11
  202. package/src/routes/gate-policies.ts +226 -0
  203. package/src/routes/gate-policy-spec.ts +229 -0
  204. package/src/routes/gate-policy-wire.ts +20 -0
  205. package/src/routes/hierarchy-errors.ts +14 -0
  206. package/src/routes/judged-suites.ts +5 -0
  207. package/src/routes/judgments.ts +107 -23
  208. package/src/routes/live-scope-wire.ts +90 -0
  209. package/src/routes/policies.ts +61 -3
  210. package/src/routes/projects.ts +54 -2
  211. package/src/routes/retention.ts +21 -2
  212. package/src/routes/reviewers.ts +23 -4
  213. package/src/routes/runs.ts +33 -20
  214. package/src/routes/secrets.ts +2 -0
  215. package/src/routes/segments.ts +75 -0
  216. package/src/routes/teams.ts +53 -3
  217. package/src/routes/uuid-param.ts +28 -0
@@ -64,7 +64,14 @@
64
64
  */
65
65
 
66
66
  import { EVIDENCE_KINDS } from '@kindgi/compliance';
67
- import { MAX_TOOL_ERROR_RETRIES, POLICY_KINDS, TOOL_ERROR_KINDS } from '@kindgi/policy-contract';
67
+ import {
68
+ MAX_TOOL_ERROR_RETRIES,
69
+ POLICY_KINDS,
70
+ RETENTION_DOMAINS,
71
+ TOOL_ERROR_KINDS,
72
+ } from '@kindgi/policy-contract';
73
+
74
+ import { ERROR_CODE_TO_STATUS } from '../errors.js';
68
75
 
69
76
  export type JsonSchema = Record<string, unknown>;
70
77
 
@@ -74,6 +81,11 @@ export const WireErrorSchema: JsonSchema = {
74
81
  type: 'object',
75
82
  additionalProperties: false,
76
83
  required: ['error'],
84
+ // Every code the API answers with, and its HTTP status. Not a closed
85
+ // list for clients (a newer server may add codes); the clients' tests
86
+ // read it to check that each 4xx code maps to a typed error, not to a
87
+ // server error. Generators and validators ignore `x-` keys.
88
+ 'x-error-codes': ERROR_CODE_TO_STATUS,
77
89
  properties: {
78
90
  error: {
79
91
  type: 'object',
@@ -142,6 +154,430 @@ export const RunAgentSchema: JsonSchema = {
142
154
  id: { type: 'string', description: 'The agent id.' },
143
155
  version: { type: 'string', description: 'The agent version that ran (semver).' },
144
156
  conversationId: { type: 'string', format: 'uuid' },
157
+ via: {
158
+ type: 'string',
159
+ enum: ['explicit', 'flow-pin', 'conversation', 'live', 'latest'],
160
+ description:
161
+ "Why this version ran: named by the caller (`explicit`); held by the flow version a flow's agent step runs in (`flow-pin`: the node's `config.version`, else the version the flow version pinned when it was published); the conversation's own (`conversation`); the version live for the run's scope (`live`); or the latest, nothing being live (`latest`). Absent on runs from before Kindgi 0.1.4.",
162
+ },
163
+ liveScope: {
164
+ $ref: '#/components/schemas/LiveScope',
165
+ description: 'The pin that chose the version, when `via` is `live`.',
166
+ },
167
+ },
168
+ };
169
+
170
+ export const ScopeSegmentSchema: JsonSchema = {
171
+ type: 'object',
172
+ additionalProperties: false,
173
+ required: ['key', 'value'],
174
+ properties: {
175
+ key: {
176
+ type: 'string',
177
+ pattern: '^[a-z][a-z0-9_-]{0,63}$',
178
+ description: 'Lowercase, like an identifier: `company`, `contact-role`.',
179
+ },
180
+ value: { type: 'string', minLength: 1, maxLength: 256 },
181
+ },
182
+ };
183
+
184
+ const liveScopeVariant = (
185
+ kind: string,
186
+ description: string,
187
+ properties: Record<string, JsonSchema>,
188
+ ): JsonSchema => ({
189
+ type: 'object',
190
+ additionalProperties: false,
191
+ required: ['kind', ...Object.keys(properties)],
192
+ description,
193
+ properties: { kind: { type: 'string', enum: [kind] }, ...properties },
194
+ });
195
+
196
+ export const LiveScopeTenantSchema = liveScopeVariant(
197
+ 'tenant',
198
+ "The agent's default for the whole tenant.",
199
+ {},
200
+ );
201
+ export const LiveScopeOrgSchema = liveScopeVariant('org', "An org's projects.", {
202
+ orgId: { type: 'string', format: 'uuid' },
203
+ });
204
+ export const LiveScopeProjectSchema = liveScopeVariant('project', 'One project.', {
205
+ projectId: { type: 'string', format: 'uuid' },
206
+ });
207
+ export const LiveScopeSegmentSchema = liveScopeVariant(
208
+ 'segment',
209
+ 'A segment path within a project: it covers every run whose path starts with it.',
210
+ {
211
+ projectId: { type: 'string', format: 'uuid' },
212
+ path: {
213
+ type: 'array',
214
+ minItems: 1,
215
+ maxItems: 8,
216
+ items: { $ref: '#/components/schemas/ScopeSegment' },
217
+ },
218
+ },
219
+ );
220
+
221
+ export const LiveScopeSchema: JsonSchema = {
222
+ description:
223
+ 'Where a live version is pinned, from least to most specific: tenant, org, project, segment path. A run takes the most specific pin that covers it.',
224
+ oneOf: [
225
+ { $ref: '#/components/schemas/LiveScopeTenant' },
226
+ { $ref: '#/components/schemas/LiveScopeOrg' },
227
+ { $ref: '#/components/schemas/LiveScopeProject' },
228
+ { $ref: '#/components/schemas/LiveScopeSegment' },
229
+ ],
230
+ discriminator: { propertyName: 'kind' },
231
+ };
232
+
233
+ export const LiveVersionResolutionSchema: JsonSchema = {
234
+ type: 'object',
235
+ additionalProperties: false,
236
+ required: ['agentId', 'version', 'via'],
237
+ properties: {
238
+ agentId: { type: 'string' },
239
+ version: { type: 'string', description: 'The version a run would use (semver).' },
240
+ via: {
241
+ type: 'string',
242
+ enum: ['live', 'latest'],
243
+ description: 'A live pin chose it, or nothing is live on the way up and it is the latest.',
244
+ },
245
+ liveScope: { $ref: '#/components/schemas/LiveScope' },
246
+ },
247
+ };
248
+
249
+ export const LivePinSchema: JsonSchema = {
250
+ type: 'object',
251
+ additionalProperties: false,
252
+ required: ['agentId', 'scope', 'version', 'promotionId', 'setAt'],
253
+ properties: {
254
+ agentId: { type: 'string' },
255
+ scope: { $ref: '#/components/schemas/LiveScope' },
256
+ version: { type: 'string' },
257
+ promotionId: { type: 'string', format: 'uuid', description: 'The promotion that set it.' },
258
+ setAt: { type: 'string', format: 'date-time' },
259
+ },
260
+ };
261
+
262
+ export const LivePinListSchema: JsonSchema = {
263
+ type: 'object',
264
+ additionalProperties: false,
265
+ required: ['data'],
266
+ properties: { data: { type: 'array', items: { $ref: '#/components/schemas/LivePin' } } },
267
+ };
268
+
269
+ export const PromotionSchema: JsonSchema = {
270
+ type: 'object',
271
+ additionalProperties: false,
272
+ required: [
273
+ 'id',
274
+ 'agentId',
275
+ 'scope',
276
+ 'action',
277
+ 'fromVersion',
278
+ 'toVersion',
279
+ 'requestedBy',
280
+ 'createdAt',
281
+ ],
282
+ description:
283
+ "One change of a scope's live version, kept for good: what was live before, what is after, who asked and why.",
284
+ properties: {
285
+ id: { type: 'string', format: 'uuid' },
286
+ agentId: { type: 'string' },
287
+ scope: { $ref: '#/components/schemas/LiveScope' },
288
+ action: { type: 'string', enum: ['promote', 'rollback', 'unpin'] },
289
+ fromVersion: {
290
+ type: ['string', 'null'],
291
+ description: "The scope's own pin before; null when it had none.",
292
+ },
293
+ toVersion: {
294
+ type: ['string', 'null'],
295
+ description: "The scope's own pin after; null after an unpin.",
296
+ },
297
+ requestedBy: {
298
+ type: 'object',
299
+ additionalProperties: false,
300
+ required: ['kind', 'id'],
301
+ properties: {
302
+ kind: { type: 'string', enum: ['user', 'service'] },
303
+ id: { type: 'string' },
304
+ },
305
+ },
306
+ reason: { type: 'string' },
307
+ evalRunId: { type: 'string', description: 'The comparison the change was judged on.' },
308
+ createdAt: { type: 'string', format: 'date-time' },
309
+ status: {
310
+ type: 'string',
311
+ enum: ['promoted', 'pending-approval', 'refused', 'superseded', 'rejected', 'expired'],
312
+ description:
313
+ "A `promote` row's state: it changes once, from `pending-approval` to its final state. Absent on rollback and unpin rows, and on promotions made before gates (`promoted`).",
314
+ },
315
+ policy: {
316
+ oneOf: [{ $ref: '#/components/schemas/GatePolicyRef' }, { type: 'null' }],
317
+ description: 'The gate policy that applied; null when none did. Absent before gates.',
318
+ },
319
+ checks: { type: 'array', items: { $ref: '#/components/schemas/GateCheck' } },
320
+ approvalId: {
321
+ type: 'string',
322
+ description: 'The approval a `pending-approval` promotion waits on (kept once decided).',
323
+ },
324
+ resolvedAt: {
325
+ type: 'string',
326
+ format: 'date-time',
327
+ description: 'When a `pending-approval` promotion reached its final state.',
328
+ },
329
+ },
330
+ };
331
+
332
+ export const PromotionPageSchema: JsonSchema = {
333
+ type: 'object',
334
+ additionalProperties: false,
335
+ required: ['data', 'hasMore'],
336
+ properties: {
337
+ data: { type: 'array', items: { $ref: '#/components/schemas/Promotion' } },
338
+ hasMore: { type: 'boolean' },
339
+ nextCursor: { type: 'string' },
340
+ },
341
+ };
342
+
343
+ // ---------------- the promotion gate (evals step 4b) ----------------
344
+
345
+ export const GateCheckSchema: JsonSchema = {
346
+ type: 'object',
347
+ additionalProperties: false,
348
+ required: ['name', 'passed', 'message'],
349
+ description: "One of a gate's checks, as the promotion records it.",
350
+ properties: {
351
+ name: {
352
+ type: 'string',
353
+ description:
354
+ 'Stable: `comparison.required`, `comparison.status`, `comparison.freshness`, `comparison.suite`, `sameContents`, `baselineIsLive`, `scopeCovered`, `evidence.<metric>.minCases|minWeight|baselineMinCases|baselineMinWeight`, `metric.<metric>.k|minCandidate|maxDrop`, `replay.maxDiverged|maxErrors|maxRefusedWrites|maxStopped`, `classWeights.restrictedOnly`.',
355
+ },
356
+ passed: { type: 'boolean' },
357
+ message: {
358
+ type: 'string',
359
+ description: 'A plain sentence: what was found against what the policy asks.',
360
+ },
361
+ value: { type: ['number', 'string'] },
362
+ threshold: { type: ['number', 'string'] },
363
+ },
364
+ };
365
+
366
+ export const GatePolicyRefSchema: JsonSchema = {
367
+ type: 'object',
368
+ additionalProperties: false,
369
+ required: ['id', 'version'],
370
+ properties: { id: { type: 'string' }, version: { type: 'string' } },
371
+ };
372
+
373
+ export const GateApprovalSchema: JsonSchema = {
374
+ type: 'object',
375
+ additionalProperties: false,
376
+ required: ['role', 'count', 'separateApprover'],
377
+ description: 'The approval a passing promotion waits for.',
378
+ properties: {
379
+ role: { type: 'string', enum: ['standard', 'senior', 'admin'] },
380
+ count: { type: 'integer', minimum: 1 },
381
+ separateApprover: {
382
+ type: 'boolean',
383
+ description: 'Whoever asked for the promotion may not approve it.',
384
+ },
385
+ },
386
+ };
387
+
388
+ const GateMetricSpecSchema: JsonSchema = {
389
+ type: 'object',
390
+ additionalProperties: false,
391
+ required: ['name'],
392
+ properties: {
393
+ name: { type: 'string', enum: ['weightedYesShare', 'judgedCoverage', 'weightedPrecisionAtK'] },
394
+ k: {
395
+ type: 'integer',
396
+ minimum: 1,
397
+ maximum: 100,
398
+ description: "`weightedPrecisionAtK` only: the summary's `k` must be this.",
399
+ },
400
+ minCandidate: { type: 'number', minimum: 0, maximum: 1 },
401
+ maxDrop: {
402
+ type: 'number',
403
+ minimum: 0,
404
+ maximum: 1,
405
+ description: 'How far the candidate may fall below the baseline (the live version).',
406
+ },
407
+ },
408
+ };
409
+
410
+ export const GatePolicySpecSchema: JsonSchema = {
411
+ type: 'object',
412
+ additionalProperties: false,
413
+ description:
414
+ 'What a promotion must show. Every part is optional; an empty spec checks nothing. A promotion must name a comparison (`evalRunId`) exactly when the spec has `comparison`, `evidence`, `metrics`, `replay` or `onlyRestrictedClasses`. Unknown keys are refused.',
415
+ properties: {
416
+ comparison: {
417
+ type: 'object',
418
+ additionalProperties: false,
419
+ properties: {
420
+ maxAgeHours: { type: 'number', exclusiveMinimum: 0 },
421
+ suite: {
422
+ type: 'object',
423
+ additionalProperties: false,
424
+ required: ['id'],
425
+ properties: { id: { type: 'string' }, version: { type: 'string' } },
426
+ },
427
+ },
428
+ },
429
+ evidence: {
430
+ type: 'object',
431
+ additionalProperties: false,
432
+ description:
433
+ "The judged evidence behind each gated metric; for a metric with `maxDrop`, the baseline's too.",
434
+ properties: {
435
+ minCases: { type: 'integer', minimum: 0 },
436
+ minWeight: { type: 'number', minimum: 0 },
437
+ },
438
+ },
439
+ metrics: { type: 'array', items: GateMetricSpecSchema },
440
+ replay: {
441
+ type: 'object',
442
+ additionalProperties: false,
443
+ description: 'Each knob left out of the block is 0. No block: no replay checks.',
444
+ properties: {
445
+ maxDiverged: { type: 'integer', minimum: 0 },
446
+ maxErrors: { type: 'integer', minimum: 0 },
447
+ maxRefusedWrites: { type: 'integer', minimum: 0 },
448
+ maxStopped: { type: 'integer', minimum: 0 },
449
+ },
450
+ },
451
+ approvals: {
452
+ type: 'object',
453
+ additionalProperties: false,
454
+ description: 'A passing promotion waits for a reviewer.',
455
+ properties: {
456
+ role: {
457
+ type: 'string',
458
+ enum: ['standard', 'senior', 'admin'],
459
+ description: 'Default `senior`.',
460
+ },
461
+ separateApprover: { type: 'boolean', description: 'Default `true`.' },
462
+ },
463
+ },
464
+ onlyRestrictedClasses: {
465
+ type: 'boolean',
466
+ description:
467
+ "Only restricted judge classes count: the comparison must be weighted `restricted-only`, so a class anyone may assert can't move the gate.",
468
+ },
469
+ },
470
+ };
471
+
472
+ export const GatePolicySchema: JsonSchema = {
473
+ type: 'object',
474
+ additionalProperties: false,
475
+ required: ['id', 'version', 'agentId', 'scope', 'spec', 'createdAt'],
476
+ properties: {
477
+ id: { type: 'string' },
478
+ version: { type: 'string' },
479
+ agentId: { type: 'string' },
480
+ scope: { $ref: '#/components/schemas/LiveScope' },
481
+ spec: { $ref: '#/components/schemas/GatePolicySpec' },
482
+ description: { type: 'string' },
483
+ createdAt: { type: 'string', format: 'date-time' },
484
+ unregisteredAt: { type: 'string', format: 'date-time' },
485
+ },
486
+ };
487
+
488
+ export const GatePolicyPageSchema: JsonSchema = {
489
+ type: 'object',
490
+ additionalProperties: false,
491
+ required: ['data', 'hasMore'],
492
+ properties: {
493
+ data: { type: 'array', items: { $ref: '#/components/schemas/GatePolicy' } },
494
+ hasMore: { type: 'boolean' },
495
+ nextCursor: { type: 'string' },
496
+ },
497
+ };
498
+
499
+ export const PublishGatePolicyBodySchema: JsonSchema = {
500
+ type: 'object',
501
+ additionalProperties: false,
502
+ required: ['id', 'version', 'agentId', 'scope', 'spec'],
503
+ properties: {
504
+ id: {
505
+ type: 'string',
506
+ pattern: '^[a-z0-9][a-z0-9._-]{0,127}$',
507
+ description: 'Yours to choose, e.g. `acme.drafting-prod`.',
508
+ },
509
+ version: { type: 'string', pattern: '^\\d+\\.\\d+\\.\\d+$' },
510
+ agentId: { type: 'string' },
511
+ scope: { $ref: '#/components/schemas/LiveScope' },
512
+ spec: { $ref: '#/components/schemas/GatePolicySpec' },
513
+ description: { type: 'string' },
514
+ },
515
+ };
516
+
517
+ export const GatePolicyResolutionSchema: JsonSchema = {
518
+ type: 'object',
519
+ additionalProperties: false,
520
+ required: ['policy'],
521
+ properties: {
522
+ policy: {
523
+ oneOf: [{ $ref: '#/components/schemas/GatePolicy' }, { type: 'null' }],
524
+ description: 'The policy that gates a promotion for the scope; null when none does.',
525
+ },
526
+ },
527
+ };
528
+
529
+ export const PromotionCheckSchema: JsonSchema = {
530
+ type: 'object',
531
+ additionalProperties: false,
532
+ required: ['outcome', 'policy', 'checks'],
533
+ description: 'What the gate would say about a promotion. Nothing is recorded.',
534
+ properties: {
535
+ outcome: { type: 'string', enum: ['would-promote', 'needs-approval', 'gate-failed'] },
536
+ policy: {
537
+ oneOf: [{ $ref: '#/components/schemas/GatePolicyRef' }, { type: 'null' }],
538
+ description: 'The policy that applies; null when none does.',
539
+ },
540
+ checks: { type: 'array', items: { $ref: '#/components/schemas/GateCheck' } },
541
+ approval: { $ref: '#/components/schemas/GateApproval' },
542
+ },
543
+ };
544
+
545
+ export const PromoteBodySchema: JsonSchema = {
546
+ type: 'object',
547
+ additionalProperties: false,
548
+ required: ['version', 'scope'],
549
+ properties: {
550
+ version: {
551
+ type: 'string',
552
+ description: 'The agent version to make live (registered, active).',
553
+ },
554
+ scope: { $ref: '#/components/schemas/LiveScope' },
555
+ reason: { type: 'string', maxLength: 2000 },
556
+ evalRunId: { type: 'string', description: 'The comparison this promotion was judged on.' },
557
+ },
558
+ };
559
+
560
+ export const RollbackBodySchema: JsonSchema = {
561
+ type: 'object',
562
+ additionalProperties: false,
563
+ required: ['scope'],
564
+ properties: {
565
+ scope: { $ref: '#/components/schemas/LiveScope' },
566
+ toVersion: {
567
+ type: 'string',
568
+ description: "An earlier version to go back to; omit → the scope's previous live version.",
569
+ },
570
+ reason: { type: 'string', maxLength: 2000 },
571
+ },
572
+ };
573
+
574
+ export const UnpinBodySchema: JsonSchema = {
575
+ type: 'object',
576
+ additionalProperties: false,
577
+ required: ['scope'],
578
+ properties: {
579
+ scope: { $ref: '#/components/schemas/LiveScope' },
580
+ reason: { type: 'string', maxLength: 2000 },
145
581
  },
146
582
  };
147
583
 
@@ -195,6 +631,12 @@ export const RunSchema: JsonSchema = {
195
631
  description: 'Set on a replay run: the eval run that started it.',
196
632
  },
197
633
  versions: { $ref: '#/components/schemas/FlowVersionOverrides' },
634
+ segments: {
635
+ type: 'array',
636
+ items: { $ref: '#/components/schemas/ScopeSegment' },
637
+ description:
638
+ "The segment path the run was started with (coarse to fine), which picks live agent versions. A child run has its parent's. Absent when there was none.",
639
+ },
198
640
  publicAccessToken: {
199
641
  type: 'string',
200
642
  description:
@@ -253,12 +695,23 @@ export const StartRunBodySchema: JsonSchema = {
253
695
  required: ['agent', 'input'],
254
696
  properties: {
255
697
  agent: { type: 'string', description: 'AgentId.' },
256
- agentVersion: { type: 'string', description: 'Semver; omit → latest.' },
698
+ agentVersion: {
699
+ type: 'string',
700
+ description:
701
+ "Semver. Omit → the conversation's own version for a follow-up turn, else the version live for the run's scope, else the latest.",
702
+ },
257
703
  projectId: {
258
704
  type: 'string',
259
705
  format: 'uuid',
260
706
  description: "Project to run under; omit → the tenant's Default project.",
261
707
  },
708
+ segments: {
709
+ type: 'array',
710
+ maxItems: 8,
711
+ items: { $ref: '#/components/schemas/ScopeSegment' },
712
+ description:
713
+ "The run's segment path below its project, coarse to fine (an app-defined finer scope, e.g. company then role). A version live on a prefix of it serves the run.",
714
+ },
262
715
  input: {
263
716
  description: 'Opaque payload forwarded to the agent binding.',
264
717
  },
@@ -277,6 +730,13 @@ export const StartRunBodySchema: JsonSchema = {
277
730
  format: 'uuid',
278
731
  description: "Project to run under; omit → the tenant's Default project.",
279
732
  },
733
+ segments: {
734
+ type: 'array',
735
+ maxItems: 8,
736
+ items: { $ref: '#/components/schemas/ScopeSegment' },
737
+ description:
738
+ "The run's segment path below its project, coarse to fine (an app-defined finer scope, e.g. company then role). A version live on a prefix of it serves the run.",
739
+ },
280
740
  input: {
281
741
  description: 'Opaque payload forwarded to the flow runtime.',
282
742
  },
@@ -795,6 +1255,28 @@ export const CompleteApprovalResultSchema: JsonSchema = {
795
1255
  description:
796
1256
  'True when the approval had a `waitTokenId` + terminal accept/reject and the run waitpoint was completed as part of this call.',
797
1257
  },
1258
+ resume: {
1259
+ description:
1260
+ "How the run went on, when this call resumed it (the runtime resumes inline): `ok`, or `failed` with the run's error, e.g. `tool-version-unresolvable` when a tool version the turn started with is gone. The decision stands either way.",
1261
+ oneOf: [
1262
+ {
1263
+ type: 'object',
1264
+ additionalProperties: false,
1265
+ required: ['kind'],
1266
+ properties: { kind: { type: 'string', const: 'ok' } },
1267
+ },
1268
+ {
1269
+ type: 'object',
1270
+ additionalProperties: false,
1271
+ required: ['kind', 'code', 'message'],
1272
+ properties: {
1273
+ kind: { type: 'string', const: 'failed' },
1274
+ code: { type: 'string' },
1275
+ message: { type: 'string' },
1276
+ },
1277
+ },
1278
+ ],
1279
+ },
798
1280
  },
799
1281
  };
800
1282
 
@@ -2102,6 +2584,34 @@ export const JudgeClassScopeSchema: JsonSchema = {
2102
2584
  ],
2103
2585
  };
2104
2586
 
2587
+ export const JudgeClassAssertableBySchema: JsonSchema = {
2588
+ type: 'object',
2589
+ additionalProperties: false,
2590
+ minProperties: 1,
2591
+ description:
2592
+ 'Who may assert the class: every part that is set must hold. A class with one is restricted: a judgment recorded while it is carries `restricted`, and a comparison weighted `restricted-only` counts only those.',
2593
+ properties: {
2594
+ minReviewerRole: {
2595
+ type: 'string',
2596
+ enum: ['standard', 'senior', 'admin'],
2597
+ description: "The caller's reviewer role is at least this (its token's, or the roster's).",
2598
+ },
2599
+ principalKinds: {
2600
+ type: 'array',
2601
+ minItems: 1,
2602
+ items: { type: 'string', enum: ['user', 'service'] },
2603
+ description: 'Users, service tokens, or both.',
2604
+ },
2605
+ principalIds: {
2606
+ type: 'array',
2607
+ minItems: 1,
2608
+ maxItems: 100,
2609
+ items: { type: 'string', minLength: 1 },
2610
+ description: 'Only these principals: user ids, or service token ids.',
2611
+ },
2612
+ },
2613
+ };
2614
+
2105
2615
  export const JudgeClassSchema: JsonSchema = {
2106
2616
  type: 'object',
2107
2617
  additionalProperties: false,
@@ -2120,6 +2630,7 @@ export const JudgeClassSchema: JsonSchema = {
2120
2630
  description: 'How much a judgment of this class counts, relative to the others.',
2121
2631
  },
2122
2632
  description: { type: 'string' },
2633
+ assertableBy: { $ref: '#/components/schemas/JudgeClassAssertableBy' },
2123
2634
  createdAt: { type: 'string', format: 'date-time' },
2124
2635
  updatedAt: { type: 'string', format: 'date-time' },
2125
2636
  unregisteredAt: {
@@ -2150,6 +2661,7 @@ export const CreateJudgeClassBodySchema: JsonSchema = {
2150
2661
  name: { type: 'string', minLength: 1, maxLength: 100 },
2151
2662
  weight: { type: 'number', minimum: 0 },
2152
2663
  description: { type: 'string' },
2664
+ assertableBy: { $ref: '#/components/schemas/JudgeClassAssertableBy' },
2153
2665
  },
2154
2666
  };
2155
2667
 
@@ -2160,6 +2672,10 @@ export const UpdateJudgeClassBodySchema: JsonSchema = {
2160
2672
  properties: {
2161
2673
  weight: { type: 'number', minimum: 0 },
2162
2674
  description: { type: 'string' },
2675
+ assertableBy: {
2676
+ oneOf: [{ $ref: '#/components/schemas/JudgeClassAssertableBy' }, { type: 'null' }],
2677
+ description: 'Who may assert the class; `null` lifts the restriction.',
2678
+ },
2163
2679
  },
2164
2680
  };
2165
2681
 
@@ -2247,6 +2763,12 @@ export const JudgmentSchema: JsonSchema = {
2247
2763
  description:
2248
2764
  'The judge class the judgment is recorded under. Absent when unclassified (counts with weight 1).',
2249
2765
  },
2766
+ restricted: {
2767
+ type: 'boolean',
2768
+ enum: [true],
2769
+ description:
2770
+ "Present (true) when the judge class was restricted (`assertableBy`) when the judgment was recorded, so the judge was checked against it. A restriction added or lifted later doesn't change it.",
2771
+ },
2250
2772
  assertedBy: { $ref: '#/components/schemas/JudgmentAssertedBy' },
2251
2773
  participantId: {
2252
2774
  type: 'string',
@@ -2437,6 +2959,14 @@ export const JudgedItemSummarySchema: JsonSchema = {
2437
2959
  description: 'The weight behind "yes" (an unclassified judgment counts 1).',
2438
2960
  },
2439
2961
  totalWeight: { type: 'number', description: 'The weight behind all judgments of the item.' },
2962
+ restricted: {
2963
+ type: 'object',
2964
+ additionalProperties: false,
2965
+ required: ['yesWeight', 'totalWeight'],
2966
+ description:
2967
+ 'The same weights, counting only judgments recorded while their class was restricted (`Judgment.restricted`), for a comparison weighted `restricted-only`. Absent from a test set built before restrictions.',
2968
+ properties: { yesWeight: { type: 'number' }, totalWeight: { type: 'number' } },
2969
+ },
2440
2970
  reasons: {
2441
2971
  type: 'array',
2442
2972
  description: 'The reasons given, newest first.',
@@ -4358,7 +4888,7 @@ export const PolicySchema: JsonSchema = {
4358
4888
  type: 'object',
4359
4889
  additionalProperties: true,
4360
4890
  description:
4361
- "Kind-specific policy body. For `access-control`, matches `@kindgi/specs/policy.schema.json` (rules + defaults). For `model-routing`, matches `TenantPolicy` from `@kindgi/capabilities` (providers.allow / providers.deny / models.allow / models.deny / regionAllow / maxCostPerCallUsd / maxTokensPerCall). For `tool-errors`, `ToolErrorsSpec` (maxRetries / retryOn). For `hitl`, `HitlSpec` from `@kindgi/policy-contract` (maxTimeoutMs / minReviewerRole / tools — per tool id a mode or `{ mode, requiredRole }`); it only tightens an agent's approvals. `tool-errors` and `hitl` specs are validated on publish. For other kinds, the shape is defined by the runtime consumer.",
4891
+ "Kind-specific policy body. For `access-control`, matches `@kindgi/specs/policy.schema.json` (rules + defaults). For `model-routing`, matches `TenantPolicy` from `@kindgi/capabilities` (providers.allow / providers.deny / models.allow / models.deny / regionAllow / maxCostPerCallUsd / maxTokensPerCall). For `tool-errors`, `ToolErrorsSpec` (maxRetries / retryOn). For `hitl`, `HitlSpec` from `@kindgi/policy-contract` (maxTimeoutMs / minReviewerRole / tools — per tool id a mode or `{ mode, requiredRole }`); it only tightens an agent's approvals. For `retention`, `{ v: 1, doc: RetentionSpec }` from `@kindgi/policy-contract` (domain / graceSeconds / mode, which must be `purge`); a tenant has one retention policy per domain, plus one for `*`. `tool-errors`, `hitl` and `retention` specs are validated on publish. For other kinds, the shape is defined by the runtime consumer.",
4362
4892
  },
4363
4893
  },
4364
4894
  };
@@ -4464,6 +4994,180 @@ export const ReinstatePolicyVersionResultSchema: JsonSchema = {
4464
4994
  },
4465
4995
  };
4466
4996
 
4997
+ // ---------------- retention (admin plane) ----------------
4998
+
4999
+ /** A tombstoning domain a retention policy can cover; `*` is the tenant-wide default. */
5000
+ export const RetentionDomainSchema: JsonSchema = {
5001
+ type: 'string',
5002
+ enum: [...RETENTION_DOMAINS],
5003
+ };
5004
+
5005
+ /**
5006
+ * A domain more than one retention policy covers. Publishing refuses a
5007
+ * second policy for a domain, so only policies stored before that rule
5008
+ * can do this.
5009
+ */
5010
+ export const RetentionPolicyConflictSchema: JsonSchema = {
5011
+ type: 'object',
5012
+ additionalProperties: false,
5013
+ required: ['domain', 'policyIds', 'appliedPolicyId'],
5014
+ properties: {
5015
+ domain: { $ref: '#/components/schemas/RetentionDomain' },
5016
+ policyIds: {
5017
+ type: 'array',
5018
+ items: { type: 'string' },
5019
+ minItems: 2,
5020
+ description: 'Every policy id that covers the domain, sorted.',
5021
+ },
5022
+ appliedPolicyId: {
5023
+ type: 'string',
5024
+ description:
5025
+ 'The one that applies: the policy whose latest version is highest, and on equal versions the lower policy id. Unregister the others.',
5026
+ },
5027
+ },
5028
+ };
5029
+
5030
+ export const RetentionScheduledItemSchema: JsonSchema = {
5031
+ type: 'object',
5032
+ additionalProperties: false,
5033
+ required: [
5034
+ 'domain',
5035
+ 'id',
5036
+ 'unregisteredAt',
5037
+ 'purgeAt',
5038
+ 'pastGrace',
5039
+ 'policyId',
5040
+ 'policyVersion',
5041
+ 'graceSeconds',
5042
+ ],
5043
+ properties: {
5044
+ domain: { $ref: '#/components/schemas/RetentionDomain' },
5045
+ id: { type: 'string', description: "The tombstoned row's id in its domain." },
5046
+ unregisteredAt: { type: 'string', format: 'date-time' },
5047
+ purgeAt: {
5048
+ type: 'string',
5049
+ format: 'date-time',
5050
+ description: "`unregisteredAt` plus the policy's grace: when a sweep purges the row.",
5051
+ },
5052
+ pastGrace: {
5053
+ type: 'boolean',
5054
+ description: 'Whether a sweep would purge the row now.',
5055
+ },
5056
+ policyId: { type: 'string', description: 'The retention policy that applies.' },
5057
+ policyVersion: { type: 'string' },
5058
+ graceSeconds: {
5059
+ type: 'integer',
5060
+ description: "The policy's grace, in seconds (`-1`: a hold, never purged).",
5061
+ },
5062
+ },
5063
+ };
5064
+
5065
+ export const RetentionScheduledPageSchema: JsonSchema = {
5066
+ type: 'object',
5067
+ additionalProperties: false,
5068
+ required: ['data', 'domainsMissingAdapter', 'unpolicedDomains'],
5069
+ properties: {
5070
+ data: {
5071
+ type: 'array',
5072
+ items: { $ref: '#/components/schemas/RetentionScheduledItem' },
5073
+ },
5074
+ hasMore: {
5075
+ type: 'boolean',
5076
+ description:
5077
+ 'Some domain has more scheduled rows than this page returned (`limit` is per domain). Always sent from 0.1.4; a runtime before it sends none.',
5078
+ },
5079
+ nextCursor: {
5080
+ type: 'string',
5081
+ description:
5082
+ 'The `cursor` for the next page. Absent when `hasMore: false`, or when the runtime cannot continue a page.',
5083
+ },
5084
+ domainsMissingAdapter: {
5085
+ type: 'array',
5086
+ items: { $ref: '#/components/schemas/RetentionDomain' },
5087
+ description:
5088
+ "Domains a retention policy covers that this deployment can't purge (no adapter is wired).",
5089
+ },
5090
+ unpolicedDomains: {
5091
+ type: 'array',
5092
+ items: { $ref: '#/components/schemas/RetentionDomain' },
5093
+ description: 'Domains no retention policy covers: their tombstones are kept.',
5094
+ },
5095
+ conflicts: {
5096
+ type: 'array',
5097
+ items: { $ref: '#/components/schemas/RetentionPolicyConflict' },
5098
+ description: 'Domains more than one retention policy covers. Absent or empty: none.',
5099
+ },
5100
+ },
5101
+ };
5102
+
5103
+ export const RetentionSweepBodySchema: JsonSchema = {
5104
+ type: 'object',
5105
+ additionalProperties: false,
5106
+ properties: {
5107
+ domain: {
5108
+ $ref: '#/components/schemas/RetentionDomain',
5109
+ description: 'Sweep only this domain. Absent: every domain.',
5110
+ },
5111
+ maxPerDomain: {
5112
+ type: 'integer',
5113
+ minimum: 1,
5114
+ maximum: 10000,
5115
+ description:
5116
+ 'The most rows one call purges per domain (default 500); the rest are `remaining`.',
5117
+ },
5118
+ },
5119
+ };
5120
+
5121
+ export const RetentionSweepDomainBodySchema: JsonSchema = {
5122
+ type: 'object',
5123
+ additionalProperties: false,
5124
+ properties: {
5125
+ maxPerDomain: {
5126
+ type: 'integer',
5127
+ minimum: 1,
5128
+ maximum: 10000,
5129
+ description: 'The most rows this call purges (default 500); the rest are `remaining`.',
5130
+ },
5131
+ },
5132
+ };
5133
+
5134
+ export const RetentionSweepResultSchema: JsonSchema = {
5135
+ type: 'object',
5136
+ additionalProperties: false,
5137
+ required: ['perDomain', 'totalPurged'],
5138
+ properties: {
5139
+ perDomain: {
5140
+ type: 'array',
5141
+ items: {
5142
+ type: 'object',
5143
+ additionalProperties: false,
5144
+ required: ['domain', 'purged', 'remaining'],
5145
+ properties: {
5146
+ domain: { $ref: '#/components/schemas/RetentionDomain' },
5147
+ purged: { type: 'integer', minimum: 0 },
5148
+ remaining: {
5149
+ type: 'integer',
5150
+ minimum: 0,
5151
+ description: 'Rows past grace this call left (the `maxPerDomain` cap); sweep again.',
5152
+ },
5153
+ policyId: { type: 'string', description: 'The retention policy that applied.' },
5154
+ missingAdapter: {
5155
+ type: 'boolean',
5156
+ const: true,
5157
+ description: "Present when this deployment can't purge the domain (no adapter).",
5158
+ },
5159
+ },
5160
+ },
5161
+ },
5162
+ totalPurged: { type: 'integer', minimum: 0 },
5163
+ conflicts: {
5164
+ type: 'array',
5165
+ items: { $ref: '#/components/schemas/RetentionPolicyConflict' },
5166
+ description: 'Domains more than one retention policy covers. Absent or empty: none.',
5167
+ },
5168
+ },
5169
+ };
5170
+
4467
5171
  // ---------------- eval suites (admin plane) ----------------
4468
5172
 
4469
5173
  /**
@@ -4740,7 +5444,7 @@ export const EvalRunFlowRefSchema: JsonSchema = {
4740
5444
 
4741
5445
  export const EvalBaselineSchema: JsonSchema = {
4742
5446
  description:
4743
- "What a comparison compares the candidate against: `'recorded'` (each case's recorded output, what was judged), a version (`{ agentId, version }`, replayed under the same rules), or the version live in a scope (`{ live: { projectId?, segments? } }`). Only `'recorded'` runs today; the others are refused when the run starts.",
5447
+ "What a comparison compares the candidate against: `'recorded'` (each case's recorded output, what was judged), a version (`{ agentId, version }`, replayed under the same rules), or the version live in a scope (`{ live: { projectId?, segments? } }`, `segments` a path in the project, coarse to fine). Only `'recorded'` runs today; the others are refused when the run starts.",
4744
5448
  oneOf: [
4745
5449
  { type: 'string', enum: ['recorded'] },
4746
5450
  {
@@ -4759,7 +5463,13 @@ export const EvalBaselineSchema: JsonSchema = {
4759
5463
  additionalProperties: false,
4760
5464
  properties: {
4761
5465
  projectId: { type: 'string' },
4762
- segments: { type: 'object', additionalProperties: { type: 'string' } },
5466
+ segments: {
5467
+ type: 'array',
5468
+ items: { $ref: '#/components/schemas/ScopeSegment' },
5469
+ maxItems: 8,
5470
+ description:
5471
+ 'A segment path in `projectId`, coarse to fine, as live versions resolve it. Needs `projectId`.',
5472
+ },
4763
5473
  },
4764
5474
  },
4765
5475
  },
@@ -4783,6 +5493,12 @@ export const EvalComparisonSchema: JsonSchema = {
4783
5493
  repetitions: { type: 'integer', minimum: 1, maximum: 10 },
4784
5494
  k: { type: 'integer', minimum: 1, maximum: 100 },
4785
5495
  versions: { $ref: '#/components/schemas/FlowVersionOverrides' },
5496
+ classWeights: {
5497
+ type: 'string',
5498
+ enum: ['as-recorded', 'restricted-only'],
5499
+ description:
5500
+ "Which judgments count: each at its class's weight (`as-recorded`, the default), or only those recorded while their class was restricted (`Judgment.restricted`), the others weighing 0 (`restricted-only`).",
5501
+ },
4786
5502
  },
4787
5503
  };
4788
5504
 
@@ -4838,6 +5554,11 @@ export const ComparisonCandidateSchema: JsonSchema = {
4838
5554
  kind: { type: 'string', enum: ['agent'] },
4839
5555
  agentId: { type: 'string' },
4840
5556
  version: { type: 'string' },
5557
+ pinsDigest: {
5558
+ type: 'string',
5559
+ description:
5560
+ "The version's pinsDigest: what it ran, as a promotion gate checks. Absent for a version published before pins, and from a comparison recorded before it.",
5561
+ },
4841
5562
  },
4842
5563
  },
4843
5564
  {
@@ -4953,6 +5674,12 @@ export const JudgedComparisonSummarySchema: JsonSchema = {
4953
5674
  "Flow cases that stopped at a write the replay refused: no output to score, so they're left out of the metrics.",
4954
5675
  },
4955
5676
  reads: { type: 'string', enum: ['recorded', 'live'] },
5677
+ classWeights: {
5678
+ type: 'string',
5679
+ enum: ['as-recorded', 'restricted-only'],
5680
+ description:
5681
+ 'Which judgments counted. Absent from a comparison recorded before restricted classes: `as-recorded`.',
5682
+ },
4956
5683
  sampling: {
4957
5684
  type: 'object',
4958
5685
  additionalProperties: false,
@@ -5184,6 +5911,12 @@ export const StartEvalRunBodySchema: JsonSchema = {
5184
5911
  repetitions: { type: 'integer', minimum: 1, maximum: 10 },
5185
5912
  k: { type: 'integer', minimum: 1, maximum: 100 },
5186
5913
  versions: { $ref: '#/components/schemas/FlowVersionOverrides' },
5914
+ classWeights: {
5915
+ type: 'string',
5916
+ enum: ['as-recorded', 'restricted-only'],
5917
+ description:
5918
+ "Which judgments count: each at its class's weight (`as-recorded`, the default), or only those recorded while their class was restricted (`Judgment.restricted`), the others weighing 0 (`restricted-only`).",
5919
+ },
5187
5920
  },
5188
5921
  description:
5189
5922
  "Exactly one of `agentRef` or `flowRef` MUST be supplied. `dryRun: true` returns a plan preview without invoking the subject. For a `judged` suite (a test set), the run is a comparison: `agentRef` or `flowRef` with its `version` is the candidate, replayed on each case without doing anything the past run didn't (a flow stops at a write the replay refuses); `baseline` (default `'recorded'`), `reads` (default `recorded`), `repetitions` (default 1) and `k` (default 10) set how. With `flowRef`, `versions` runs the flow with some of its agents or tools at other versions; an id the flow doesn't use, or a version that isn't published, is refused (`400 validation-failed`, each under `details.issues`).",
@@ -5276,6 +6009,10 @@ export const IdentityProviderCollectionPageSchema: JsonSchema = {
5276
6009
  required: ['data'],
5277
6010
  properties: {
5278
6011
  data: { type: 'array', items: { $ref: '#/components/schemas/IdentityProviderConfig' } },
6012
+ hasMore: {
6013
+ type: 'boolean',
6014
+ description: 'Always `false`: the list comes whole. Absent from older servers.',
6015
+ },
5279
6016
  },
5280
6017
  };
5281
6018
 
@@ -6651,6 +7388,11 @@ export const EnvCollectionPageSchema: JsonSchema = {
6651
7388
  required: ['data'],
6652
7389
  properties: {
6653
7390
  data: { type: 'array', items: { $ref: '#/components/schemas/EnvRecord' } },
7391
+ hasMore: {
7392
+ type: 'boolean',
7393
+ description:
7394
+ "Whether there's another page. Absent from older servers: there is one when `nextCursor` is set.",
7395
+ },
6654
7396
  nextCursor: { type: 'string' },
6655
7397
  },
6656
7398
  };
@@ -6688,6 +7430,11 @@ export const SecretCollectionPageSchema: JsonSchema = {
6688
7430
  required: ['data'],
6689
7431
  properties: {
6690
7432
  data: { type: 'array', items: { $ref: '#/components/schemas/SecretRecord' } },
7433
+ hasMore: {
7434
+ type: 'boolean',
7435
+ description:
7436
+ "Whether there's another page. Absent from older servers: there is one when `nextCursor` is set.",
7437
+ },
6691
7438
  nextCursor: { type: 'string' },
6692
7439
  },
6693
7440
  };
@@ -6698,6 +7445,11 @@ export const SecretVersionCollectionPageSchema: JsonSchema = {
6698
7445
  required: ['data'],
6699
7446
  properties: {
6700
7447
  data: { type: 'array', items: { $ref: '#/components/schemas/SecretVersionRecord' } },
7448
+ hasMore: {
7449
+ type: 'boolean',
7450
+ description:
7451
+ "Whether there's another page. Absent from older servers: there is one when `nextCursor` is set.",
7452
+ },
6701
7453
  nextCursor: { type: 'string' },
6702
7454
  },
6703
7455
  };
@@ -7463,6 +8215,29 @@ export const COMPONENT_SCHEMAS: ReadonlyArray<readonly [string, JsonSchema]> = [
7463
8215
  ['HealthResult', HealthResultSchema],
7464
8216
  ['RunStatus', RunStatusSchema],
7465
8217
  ['RunAgent', RunAgentSchema],
8218
+ ['ScopeSegment', ScopeSegmentSchema],
8219
+ ['LiveScopeTenant', LiveScopeTenantSchema],
8220
+ ['LiveScopeOrg', LiveScopeOrgSchema],
8221
+ ['LiveScopeProject', LiveScopeProjectSchema],
8222
+ ['LiveScopeSegment', LiveScopeSegmentSchema],
8223
+ ['LiveScope', LiveScopeSchema],
8224
+ ['LiveVersionResolution', LiveVersionResolutionSchema],
8225
+ ['LivePin', LivePinSchema],
8226
+ ['LivePinList', LivePinListSchema],
8227
+ ['Promotion', PromotionSchema],
8228
+ ['PromotionPage', PromotionPageSchema],
8229
+ ['GateCheck', GateCheckSchema],
8230
+ ['GatePolicyRef', GatePolicyRefSchema],
8231
+ ['GateApproval', GateApprovalSchema],
8232
+ ['GatePolicySpec', GatePolicySpecSchema],
8233
+ ['GatePolicy', GatePolicySchema],
8234
+ ['GatePolicyPage', GatePolicyPageSchema],
8235
+ ['PublishGatePolicyBody', PublishGatePolicyBodySchema],
8236
+ ['GatePolicyResolution', GatePolicyResolutionSchema],
8237
+ ['PromotionCheck', PromotionCheckSchema],
8238
+ ['PromoteBody', PromoteBodySchema],
8239
+ ['RollbackBody', RollbackBodySchema],
8240
+ ['UnpinBody', UnpinBodySchema],
7466
8241
  ['Run', RunSchema],
7467
8242
  ['StartRunOptions', StartRunOptionsSchema],
7468
8243
  ['StartRunBody', StartRunBodySchema],
@@ -7521,6 +8296,7 @@ export const COMPONENT_SCHEMAS: ReadonlyArray<readonly [string, JsonSchema]> = [
7521
8296
  ['CreateJudgmentBody', CreateJudgmentBodySchema],
7522
8297
  ['UnregisterJudgmentResult', UnregisterJudgmentResultSchema],
7523
8298
  ['JudgedItemSummary', JudgedItemSummarySchema],
8299
+ ['JudgeClassAssertableBy', JudgeClassAssertableBySchema],
7524
8300
  ['JudgedEvalCase', JudgedEvalCaseSchema],
7525
8301
  ['JudgedEvalCaseCollectionPage', JudgedEvalCaseCollectionPageSchema],
7526
8302
  ['BuildJudgedSuiteBody', BuildJudgedSuiteBodySchema],
@@ -7685,6 +8461,13 @@ export const COMPONENT_SCHEMAS: ReadonlyArray<readonly [string, JsonSchema]> = [
7685
8461
  ['PublishPolicyResult', PublishPolicyResultSchema],
7686
8462
  ['UnregisterPolicyResult', UnregisterPolicyResultSchema],
7687
8463
  ['ReinstatePolicyVersionResult', ReinstatePolicyVersionResultSchema],
8464
+ ['RetentionDomain', RetentionDomainSchema],
8465
+ ['RetentionPolicyConflict', RetentionPolicyConflictSchema],
8466
+ ['RetentionScheduledItem', RetentionScheduledItemSchema],
8467
+ ['RetentionScheduledPage', RetentionScheduledPageSchema],
8468
+ ['RetentionSweepBody', RetentionSweepBodySchema],
8469
+ ['RetentionSweepDomainBody', RetentionSweepDomainBodySchema],
8470
+ ['RetentionSweepResult', RetentionSweepResultSchema],
7688
8471
  ['EvalKind', EvalKindSchema],
7689
8472
  ['EvalSuite', EvalSuiteSchema],
7690
8473
  ['EvalSuiteCollectionPage', EvalSuiteCollectionPageSchema],