@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
@@ -31,6 +31,12 @@ export interface ParameterSpec {
31
31
  readonly required?: boolean;
32
32
  readonly description?: string;
33
33
  readonly schema: JsonSchema;
34
+ /**
35
+ * A segment path, one `key:value` per repeated value, coarse to fine.
36
+ * Emitted as `x-kindgi-segment-path: true`; a generated client takes
37
+ * `{key, value}` steps and writes the values itself.
38
+ */
39
+ readonly segmentPath?: boolean;
34
40
  }
35
41
 
36
42
  export interface ResponseSpec {
@@ -158,6 +164,15 @@ const RunReplaysQueryParam: ParameterSpec = {
158
164
  schema: { type: 'string', enum: ['exclude', 'include', 'only'], default: 'exclude' },
159
165
  };
160
166
 
167
+ const ConversationReplaysQueryParam: ParameterSpec = {
168
+ name: 'replays',
169
+ in: 'query',
170
+ required: false,
171
+ description:
172
+ "Replay conversations (opened by a comparison's replay turn; `metadata.replayOf` names the run it replays). `exclude` (default) leaves them out; `include` lists them with the others; `only` lists just them.",
173
+ schema: { type: 'string', enum: ['exclude', 'include', 'only'], default: 'exclude' },
174
+ };
175
+
161
176
  const RunEvalRunIdQueryParam: ParameterSpec = {
162
177
  name: 'evalRunId',
163
178
  in: 'query',
@@ -167,6 +182,39 @@ const RunEvalRunIdQueryParam: ParameterSpec = {
167
182
  schema: { type: 'string', minLength: 1 },
168
183
  };
169
184
 
185
+ const LiveProjectQueryParam: ParameterSpec = {
186
+ name: 'projectId',
187
+ in: 'query',
188
+ required: false,
189
+ description: "The run's project; omit → only the agent's tenant-wide pin applies.",
190
+ schema: { type: 'string', format: 'uuid' },
191
+ };
192
+
193
+ const SegmentQueryParam: ParameterSpec = {
194
+ name: 'segment',
195
+ in: 'query',
196
+ required: false,
197
+ description: 'One step of the segment path, `key:value`; repeat it in order, coarse to fine.',
198
+ schema: { type: 'array', items: { type: 'string' } },
199
+ segmentPath: true,
200
+ };
201
+
202
+ const PromotionScopeKindQueryParam: ParameterSpec = {
203
+ name: 'scopeKind',
204
+ in: 'query',
205
+ required: false,
206
+ description:
207
+ 'Only one scope: `tenant`, `org` or `project` (with `scopeId`), or `segment` (with `scopeId` and `segment`).',
208
+ schema: { type: 'string', enum: ['tenant', 'org', 'project', 'segment'] },
209
+ };
210
+
211
+ const PromotionIdPathParam: ParameterSpec = {
212
+ name: 'promotionId',
213
+ in: 'path',
214
+ required: true,
215
+ schema: { type: 'string', format: 'uuid' },
216
+ };
217
+
170
218
  const RunIncludeQueryParam: ParameterSpec = {
171
219
  name: 'include',
172
220
  in: 'query',
@@ -201,6 +249,22 @@ const LastEventIdParam: ParameterSpec = {
201
249
  schema: { type: 'string' },
202
250
  };
203
251
 
252
+ const GatePolicyIdPathParam: ParameterSpec = {
253
+ name: 'policyId',
254
+ in: 'path',
255
+ required: true,
256
+ description: 'The gate policy id.',
257
+ schema: { type: 'string' },
258
+ };
259
+
260
+ const GatePolicyVersionPathParam: ParameterSpec = {
261
+ name: 'version',
262
+ in: 'path',
263
+ required: true,
264
+ description: 'A semver version of the gate policy.',
265
+ schema: { type: 'string' },
266
+ };
267
+
204
268
  const AgentIdPathParam: ParameterSpec = {
205
269
  name: 'agentId',
206
270
  in: 'path',
@@ -367,6 +431,38 @@ const SupervisorIdQueryParam: ParameterSpec = {
367
431
  schema: { type: 'string' },
368
432
  };
369
433
 
434
+ const ObservationAgentVersionQueryParam: ParameterSpec = {
435
+ name: 'agentVersion',
436
+ in: 'query',
437
+ required: false,
438
+ description: 'Only the observations of this agent version (with `agentId`).',
439
+ schema: { type: 'string' },
440
+ };
441
+
442
+ const ObservationConversationIdQueryParam: ParameterSpec = {
443
+ name: 'conversationId',
444
+ in: 'query',
445
+ required: false,
446
+ description: 'Only the observations of turns in this conversation.',
447
+ schema: { type: 'string' },
448
+ };
449
+
450
+ const ObservationSinceQueryParam: ParameterSpec = {
451
+ name: 'since',
452
+ in: 'query',
453
+ required: false,
454
+ description: 'Only the observations at or after this time (ISO 8601).',
455
+ schema: { type: 'string', format: 'date-time' },
456
+ };
457
+
458
+ const ObservationUntilQueryParam: ParameterSpec = {
459
+ name: 'until',
460
+ in: 'query',
461
+ required: false,
462
+ description: 'Only the observations at or before this time (ISO 8601).',
463
+ schema: { type: 'string', format: 'date-time' },
464
+ };
465
+
370
466
  const FactIdPathParam: ParameterSpec = {
371
467
  name: 'factId',
372
468
  in: 'path',
@@ -456,7 +552,7 @@ const ProvenanceAgentIdQueryParam: ParameterSpec = {
456
552
  in: 'query',
457
553
  required: false,
458
554
  description:
459
- 'Filter records to those with at least one DAG node whose `actor = <agentId>` (agent-driven turns tag their nodes with the agent id).',
555
+ "Only the records of this agent's turns, at any version: the agent the record's run names, as `GET /v1/runs?agentId=` matches it. Turns that ran before Kindgi 0.1.3 don't name their agent and aren't matched.",
460
556
  schema: { type: 'string' },
461
557
  };
462
558
 
@@ -769,7 +865,7 @@ const PolicyKindFilterQueryParam: ParameterSpec = {
769
865
  in: 'query',
770
866
  required: false,
771
867
  description:
772
- 'Filter to policies of a single kind. Values: `access-control | model-routing | adapter-allowlist | rate-limit | retention | compliance`.',
868
+ 'Filter to policies of a single kind. Values: `access-control | model-routing | adapter-allowlist | rate-limit | retention | compliance | tool-errors | hitl`.',
773
869
  schema: { $ref: '#/components/schemas/PolicyKind' },
774
870
  };
775
871
 
@@ -781,6 +877,32 @@ const PolicyNameFilterQueryParam: ParameterSpec = {
781
877
  schema: { type: 'string' },
782
878
  };
783
879
 
880
+ // Admin plane — retention.
881
+
882
+ const RetentionDomainQueryParam: ParameterSpec = {
883
+ name: 'domain',
884
+ in: 'query',
885
+ required: false,
886
+ description: 'Only this domain. Absent: every domain.',
887
+ schema: { $ref: '#/components/schemas/RetentionDomain' },
888
+ };
889
+
890
+ const RetentionPastGraceOnlyQueryParam: ParameterSpec = {
891
+ name: 'pastGraceOnly',
892
+ in: 'query',
893
+ required: false,
894
+ description: '`true`: only rows past their grace, the ones a sweep would purge now.',
895
+ schema: { type: 'boolean', default: false },
896
+ };
897
+
898
+ const RetentionDomainPathParam: ParameterSpec = {
899
+ name: 'domain',
900
+ in: 'path',
901
+ required: true,
902
+ description: 'The domain to sweep (not `*`).',
903
+ schema: { $ref: '#/components/schemas/RetentionDomain' },
904
+ };
905
+
784
906
  // Admin plane — eval suites.
785
907
 
786
908
  const EvalSuiteIdPathParam: ParameterSpec = {
@@ -1115,8 +1237,13 @@ export const OPERATIONS: readonly OperationSpec[] = [
1115
1237
  schema: ref('Run'),
1116
1238
  },
1117
1239
  ...CommonMutationErrors,
1118
- '404': ErrorResponse('Agent or flow not found.'),
1240
+ '404': ErrorResponse(
1241
+ 'Agent or flow not found; or `projectId` names no project of this tenant (`project-not-found`).',
1242
+ ),
1119
1243
  '422': ErrorResponse('Guardrail violation or budget exceeded.'),
1244
+ '400': ErrorResponse(
1245
+ "Malformed request body, or the body's `projectId` isn't a project id (a UUID).",
1246
+ ),
1120
1247
  },
1121
1248
  },
1122
1249
  {
@@ -1386,6 +1513,12 @@ export const OPERATIONS: readonly OperationSpec[] = [
1386
1513
  '201': { description: 'Token minted.', schema: ref('MintTokenResult') },
1387
1514
  ...CommonMutationErrors,
1388
1515
  '403': ErrorResponse('Not a tenant admin, or a capability the caller does not hold.'),
1516
+ '400': ErrorResponse(
1517
+ "Malformed request body, or the body's `projectId` isn't a project id (a UUID).",
1518
+ ),
1519
+ '404': ErrorResponse(
1520
+ "The body's `projectId` names no project of this tenant (`project-not-found`).",
1521
+ ),
1389
1522
  },
1390
1523
  },
1391
1524
  {
@@ -1576,6 +1709,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1576
1709
  responses: {
1577
1710
  '201': { description: 'Reviewer registered.', schema: ref('Reviewer') },
1578
1711
  ...CommonMutationErrors,
1712
+ '403': ErrorResponse(
1713
+ 'With authorization enforced, the caller is not an admin of the tenant.',
1714
+ ),
1579
1715
  },
1580
1716
  },
1581
1717
  {
@@ -1593,6 +1729,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1593
1729
  '200': { description: 'Unregistered.', schema: ref('UnregisterReviewerResult') },
1594
1730
  ...CommonMutationErrors,
1595
1731
  '404': ErrorResponse('No reviewer with that id under this tenant.'),
1732
+ '403': ErrorResponse(
1733
+ 'With authorization enforced, the caller is not an admin of the tenant.',
1734
+ ),
1596
1735
  },
1597
1736
  },
1598
1737
  {
@@ -1697,9 +1836,11 @@ export const OPERATIONS: readonly OperationSpec[] = [
1697
1836
  "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1698
1837
  ),
1699
1838
  '400': ErrorResponse(
1700
- "`validation-failed`: `from` has no pins, a swap names a block it doesn't reference, or a version that isn't published, active or the right kind (see `details.issues`).",
1839
+ "`validation-failed`: `from` has no pins, a swap names a block it doesn't reference, or a version that isn't published, active or the right kind (see `details.issues`); or `projectId` isn't a project id (a UUID).",
1840
+ ),
1841
+ '404': ErrorResponse(
1842
+ '`agent-not-found`: no agent at `from`; or `projectId` names no project of this tenant (`project-not-found`).',
1701
1843
  ),
1702
- '404': ErrorResponse('`agent-not-found`: no agent at `from`.'),
1703
1844
  },
1704
1845
  },
1705
1846
  {
@@ -1732,10 +1873,15 @@ export const OPERATIONS: readonly OperationSpec[] = [
1732
1873
  responses: {
1733
1874
  '201': { description: 'Agent published.', schema: ref('PublishAgentResult') },
1734
1875
  ...CommonMutationErrors,
1735
- '400': ErrorResponse('Validation failed (see `details.issues`).'),
1876
+ '400': ErrorResponse(
1877
+ "Validation failed (see `details.issues`); or `projectId` isn't a project id (a UUID).",
1878
+ ),
1736
1879
  '409': ErrorResponse(
1737
1880
  "Agent already registered at that (id, version). Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1738
1881
  ),
1882
+ '404': ErrorResponse(
1883
+ "The body's `projectId` names no project of this tenant (`project-not-found`).",
1884
+ ),
1739
1885
  },
1740
1886
  },
1741
1887
  {
@@ -1751,7 +1897,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
1751
1897
  '200': { description: 'Unregistered.', schema: ref('UnregisterAgentResult') },
1752
1898
  ...CommonMutationErrors,
1753
1899
  '409': ErrorResponse(
1754
- "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1900
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead. Or `agent-version-live`: the version is the live version of the scopes in `details.scopes`; roll back, unpin, or promote another version there first.",
1755
1901
  ),
1756
1902
  '404': ErrorResponse('No agent at that (id, version) under this tenant.'),
1757
1903
  },
@@ -1776,6 +1922,322 @@ export const OPERATIONS: readonly OperationSpec[] = [
1776
1922
  '404': ErrorResponse('No agent at that (id, version) under this tenant.'),
1777
1923
  },
1778
1924
  },
1925
+ {
1926
+ method: 'get',
1927
+ honoPath: '/v1/agents/:agentId/live',
1928
+ openapiPath: '/v1/agents/{agentId}/live',
1929
+ operationId: 'agents.live.resolve',
1930
+ summary: 'The version a run would use',
1931
+ description:
1932
+ "Resolves the version a run of this agent would use for a project and segment path: the most specific live version (segment path, project, org, tenant), else the latest registered. A run that names its version, or a follow-up turn in a conversation, isn't resolved this way.",
1933
+ tags: ['agents'],
1934
+ security: 'bearer',
1935
+ parameters: [AgentIdPathParam, LiveProjectQueryParam, SegmentQueryParam],
1936
+ responses: {
1937
+ '200': { description: 'The resolved version.', schema: ref('LiveVersionResolution') },
1938
+ ...CommonAuthErrors,
1939
+ '400': ErrorResponse('A malformed project id or segment, or a segment without a project.'),
1940
+ '404': ErrorResponse('No agent with that id.'),
1941
+ },
1942
+ },
1943
+ {
1944
+ method: 'get',
1945
+ honoPath: '/v1/agents/:agentId/live-versions',
1946
+ openapiPath: '/v1/agents/{agentId}/live-versions',
1947
+ operationId: 'agents.live.list',
1948
+ summary: "List an agent's live versions",
1949
+ description: 'Every scope with a live version pinned, and the promotion that set it.',
1950
+ tags: ['agents'],
1951
+ security: 'bearer',
1952
+ parameters: [AgentIdPathParam],
1953
+ responses: {
1954
+ '200': { description: 'The pins.', schema: ref('LivePinList') },
1955
+ ...CommonAuthErrors,
1956
+ },
1957
+ },
1958
+ {
1959
+ method: 'post',
1960
+ honoPath: '/v1/agents/:agentId/promotions',
1961
+ openapiPath: '/v1/agents/{agentId}/promotions',
1962
+ operationId: 'agents.promotions.create',
1963
+ summary: 'Make a version live for a scope',
1964
+ description:
1965
+ "Pins `version` live for `scope`: runs in that scope that don't name a version use it, from the next run. Open conversations keep their version. The version must be registered and active. Every promotion is recorded, with who asked and why. Needs `promote` on the agent.\n\nWith a gate policy for the scope (`GET …/gate-policy`), the promotion is checked first against the comparison named by `evalRunId`: `201` promoted; `202` the gate passed and the policy wants a reviewer's approval (a HITL approval, subject `agent-promotion`; the live version moves once it's approved, if nothing changed meanwhile); `422 gate-failed` with `details.promotionId`, `details.policy` and every check in `details.checks`. A refused promotion is recorded too.",
1966
+ tags: ['agents'],
1967
+ security: 'bearer',
1968
+ parameters: [AgentIdPathParam, IdempotencyKeyParam],
1969
+ requestBody: { required: true, schema: ref('PromoteBody') },
1970
+ responses: {
1971
+ '201': { description: 'Promoted.', schema: ref('Promotion') },
1972
+ '202': {
1973
+ description: 'The gate passed; the promotion waits for an approval (`approvalId`).',
1974
+ schema: ref('Promotion'),
1975
+ },
1976
+ ...CommonMutationErrors,
1977
+ '404': ErrorResponse(
1978
+ 'The version is not registered, or was unregistered; or the eval run is not found.',
1979
+ ),
1980
+ '409': ErrorResponse(
1981
+ "`promotion-superseded`: the scope's live version changed while the gate ran; check again.",
1982
+ ),
1983
+ '422': ErrorResponse(
1984
+ '`gate-failed`: the gate refused it. `details.checks` has every check; the refusal is recorded (`details.promotionId`).',
1985
+ ),
1986
+ '501': ErrorResponse(
1987
+ "`promotion-gate-unsupported`: a gate policy applies, and the deployment can't record a gated promotion.",
1988
+ ),
1989
+ },
1990
+ },
1991
+ {
1992
+ method: 'post',
1993
+ honoPath: '/v1/agents/:agentId/promotions/check',
1994
+ openapiPath: '/v1/agents/{agentId}/promotions/check',
1995
+ operationId: 'agents.promotions.check',
1996
+ summary: 'Check a promotion against its gate',
1997
+ description:
1998
+ 'What `POST …/promotions` with the same body would do, with nothing recorded: `would-promote`, `needs-approval` (with the approval it needs) or `gate-failed`, with every check. For a pipeline: evaluate, check, promote. Needs `read` on the agent.',
1999
+ tags: ['agents'],
2000
+ security: 'bearer',
2001
+ parameters: [AgentIdPathParam],
2002
+ requestBody: { required: true, schema: ref('PromoteBody') },
2003
+ responses: {
2004
+ '200': { description: "The gate's answer.", schema: ref('PromotionCheck') },
2005
+ ...CommonAuthErrors,
2006
+ '400': ErrorResponse('Malformed body, or the eval run is not a finished comparison.'),
2007
+ '404': ErrorResponse('The version, the agent or the eval run is not found.'),
2008
+ },
2009
+ },
2010
+ {
2011
+ method: 'get',
2012
+ honoPath: '/v1/agents/:agentId/gate-policy',
2013
+ openapiPath: '/v1/agents/{agentId}/gate-policy',
2014
+ operationId: 'agents.gatePolicy.resolve',
2015
+ summary: 'The gate policy for a scope',
2016
+ description:
2017
+ "The gate policy a promotion of the agent for the scope would be checked against: the most specific scope with an active policy (a segment path's longer prefixes first, then its project, the project's org, the tenant), at its latest active version. `policy: null` when none applies.",
2018
+ tags: ['agents'],
2019
+ security: 'bearer',
2020
+ parameters: [
2021
+ AgentIdPathParam,
2022
+ PromotionScopeKindQueryParam,
2023
+ ScopeIdQueryParam,
2024
+ SegmentQueryParam,
2025
+ ],
2026
+ responses: {
2027
+ '200': { description: 'The policy, or null.', schema: ref('GatePolicyResolution') },
2028
+ ...CommonAuthErrors,
2029
+ '400': ErrorResponse('Missing or malformed scope.'),
2030
+ },
2031
+ },
2032
+ {
2033
+ method: 'get',
2034
+ honoPath: '/v1/gate-policies',
2035
+ openapiPath: '/v1/gate-policies',
2036
+ operationId: 'gatePolicies.list',
2037
+ summary: 'List gate policies',
2038
+ description:
2039
+ "Each gate policy's latest active version. `agentId` narrows it to one agent's; `scopeKind` (with `scopeId` and `segment`) to one scope's.",
2040
+ tags: ['gate-policies'],
2041
+ security: 'bearer',
2042
+ parameters: [
2043
+ LimitQueryParam,
2044
+ CursorQueryParam,
2045
+ {
2046
+ name: 'agentId',
2047
+ in: 'query',
2048
+ required: false,
2049
+ description: 'Only the policies gating this agent.',
2050
+ schema: { type: 'string' },
2051
+ },
2052
+ PromotionScopeKindQueryParam,
2053
+ ScopeIdQueryParam,
2054
+ SegmentQueryParam,
2055
+ ],
2056
+ responses: {
2057
+ '200': { description: 'Page of gate policies.', schema: ref('GatePolicyPage') },
2058
+ ...CommonAuthErrors,
2059
+ '400': ErrorResponse('Malformed scope or cursor.'),
2060
+ },
2061
+ },
2062
+ {
2063
+ method: 'post',
2064
+ honoPath: '/v1/gate-policies',
2065
+ openapiPath: '/v1/gate-policies',
2066
+ operationId: 'gatePolicies.publish',
2067
+ summary: 'Publish a gate policy',
2068
+ description:
2069
+ "Registers a gate policy, or a new version of one: what a promotion of `agentId` for `scope` must show. One policy per agent and scope: another policy id for a scope that has one is refused with `409 gate-policy-scope-taken` (`details.heldBy` names it; publish a new version of that one instead), and a new version can't change the agent or scope (`409 gate-policy-scope-changed`). The `spec` is checked strictly: an unknown key is refused (`400 validation-failed`, `details.issues`). Needs `admin` on the tenant: whoever may promote can't loosen their own gate.",
2070
+ tags: ['gate-policies'],
2071
+ security: 'bearer',
2072
+ parameters: [IdempotencyKeyParam],
2073
+ requestBody: { required: true, schema: ref('PublishGatePolicyBody') },
2074
+ responses: {
2075
+ '201': { description: 'Gate policy published.', schema: ref('GatePolicy') },
2076
+ ...CommonMutationErrors,
2077
+ '400': ErrorResponse('Validation failed (see `details.issues`).'),
2078
+ '409': ErrorResponse(
2079
+ '`gate-policy-already-registered`: that (id, version) exists. `gate-policy-scope-taken`: another policy gates the agent for the scope (`details.heldBy`). `gate-policy-scope-changed`: the version would change the agent or scope. `gate-policy-scope-unpinned`: nothing covering the scope is pinned, so a published version would go live there ungated; pin a version for the scope, or one above it, first.',
2080
+ ),
2081
+ },
2082
+ },
2083
+ {
2084
+ method: 'get',
2085
+ honoPath: '/v1/gate-policies/:policyId',
2086
+ openapiPath: '/v1/gate-policies/{policyId}',
2087
+ operationId: 'gatePolicies.get',
2088
+ summary: 'Get a gate policy',
2089
+ description: "The policy's latest active version.",
2090
+ tags: ['gate-policies'],
2091
+ security: 'bearer',
2092
+ parameters: [GatePolicyIdPathParam],
2093
+ responses: {
2094
+ '200': { description: 'The gate policy.', schema: ref('GatePolicy') },
2095
+ ...CommonAuthErrors,
2096
+ '404': ErrorResponse('No active gate policy with that id.'),
2097
+ },
2098
+ },
2099
+ {
2100
+ method: 'get',
2101
+ honoPath: '/v1/gate-policies/:policyId/versions',
2102
+ openapiPath: '/v1/gate-policies/{policyId}/versions',
2103
+ operationId: 'gatePolicies.versions.list',
2104
+ summary: "List a gate policy's versions",
2105
+ description: 'Every version, oldest first, unregistered ones too (with `unregisteredAt`).',
2106
+ tags: ['gate-policies'],
2107
+ security: 'bearer',
2108
+ parameters: [GatePolicyIdPathParam],
2109
+ responses: {
2110
+ '200': { description: 'The versions.', schema: ref('GatePolicyPage') },
2111
+ ...CommonAuthErrors,
2112
+ '404': ErrorResponse('No gate policy with that id.'),
2113
+ },
2114
+ },
2115
+ {
2116
+ method: 'get',
2117
+ honoPath: '/v1/gate-policies/:policyId/versions/:version',
2118
+ openapiPath: '/v1/gate-policies/{policyId}/versions/{version}',
2119
+ operationId: 'gatePolicies.versions.get',
2120
+ summary: 'Get a gate policy version',
2121
+ tags: ['gate-policies'],
2122
+ security: 'bearer',
2123
+ parameters: [GatePolicyIdPathParam, GatePolicyVersionPathParam],
2124
+ responses: {
2125
+ '200': { description: 'The version.', schema: ref('GatePolicy') },
2126
+ ...CommonAuthErrors,
2127
+ '404': ErrorResponse('No such version.'),
2128
+ },
2129
+ },
2130
+ {
2131
+ method: 'post',
2132
+ honoPath: '/v1/gate-policies/:policyId/versions/:version/unregister',
2133
+ openapiPath: '/v1/gate-policies/{policyId}/versions/{version}/unregister',
2134
+ operationId: 'gatePolicies.versions.unregister',
2135
+ summary: 'Unregister a gate policy version',
2136
+ description:
2137
+ "The version stops applying; the policy's latest remaining active version applies, or, with none, the scope above's policy. Promotions keep the version they were checked against. Needs `admin` on the tenant.",
2138
+ tags: ['gate-policies'],
2139
+ security: 'bearer',
2140
+ parameters: [GatePolicyIdPathParam, GatePolicyVersionPathParam],
2141
+ responses: {
2142
+ '200': { description: 'The unregistered version.', schema: ref('GatePolicy') },
2143
+ ...CommonMutationErrors,
2144
+ '404': ErrorResponse('No such version.'),
2145
+ },
2146
+ },
2147
+ {
2148
+ method: 'post',
2149
+ honoPath: '/v1/gate-policies/:policyId/versions/:version/reinstate',
2150
+ openapiPath: '/v1/gate-policies/{policyId}/versions/{version}/reinstate',
2151
+ operationId: 'gatePolicies.versions.reinstate',
2152
+ summary: 'Reinstate a gate policy version',
2153
+ description: 'Needs `admin` on the tenant.',
2154
+ tags: ['gate-policies'],
2155
+ security: 'bearer',
2156
+ parameters: [GatePolicyIdPathParam, GatePolicyVersionPathParam],
2157
+ responses: {
2158
+ '200': { description: 'The reinstated version.', schema: ref('GatePolicy') },
2159
+ ...CommonMutationErrors,
2160
+ '404': ErrorResponse('No such version.'),
2161
+ },
2162
+ },
2163
+ {
2164
+ method: 'get',
2165
+ honoPath: '/v1/agents/:agentId/promotions',
2166
+ openapiPath: '/v1/agents/{agentId}/promotions',
2167
+ operationId: 'agents.promotions.list',
2168
+ summary: "List an agent's promotions",
2169
+ description:
2170
+ 'The history of live-version changes (promotions, rollbacks, unpins), newest first. `scopeKind` (`tenant`, `org`, `project`, `segment`) with `scopeId` and `segment` narrows it to one scope.',
2171
+ tags: ['agents'],
2172
+ security: 'bearer',
2173
+ parameters: [
2174
+ AgentIdPathParam,
2175
+ LimitQueryParam,
2176
+ CursorQueryParam,
2177
+ PromotionScopeKindQueryParam,
2178
+ ScopeIdQueryParam,
2179
+ SegmentQueryParam,
2180
+ ],
2181
+ responses: {
2182
+ '200': { description: 'Page of promotions.', schema: ref('PromotionPage') },
2183
+ ...CommonAuthErrors,
2184
+ '400': ErrorResponse('Malformed scope or cursor.'),
2185
+ },
2186
+ },
2187
+ {
2188
+ method: 'get',
2189
+ honoPath: '/v1/agents/:agentId/promotions/:promotionId',
2190
+ openapiPath: '/v1/agents/{agentId}/promotions/{promotionId}',
2191
+ operationId: 'agents.promotions.get',
2192
+ summary: 'Get a promotion',
2193
+ tags: ['agents'],
2194
+ security: 'bearer',
2195
+ parameters: [AgentIdPathParam, PromotionIdPathParam],
2196
+ responses: {
2197
+ '200': { description: 'The promotion.', schema: ref('Promotion') },
2198
+ ...CommonAuthErrors,
2199
+ '404': ErrorResponse('No such promotion for this agent.'),
2200
+ },
2201
+ },
2202
+ {
2203
+ method: 'post',
2204
+ honoPath: '/v1/agents/:agentId/live/rollback',
2205
+ openapiPath: '/v1/agents/{agentId}/live/rollback',
2206
+ operationId: 'agents.live.rollback',
2207
+ summary: 'Roll a scope back to its previous live version',
2208
+ description:
2209
+ "Back to the scope's previous live version, or `toVersion`. Recorded like a promotion. Needs `promote` on the agent.",
2210
+ tags: ['agents'],
2211
+ security: 'bearer',
2212
+ parameters: [AgentIdPathParam, IdempotencyKeyParam],
2213
+ requestBody: { required: true, schema: ref('RollbackBody') },
2214
+ responses: {
2215
+ '200': { description: 'Rolled back.', schema: ref('Promotion') },
2216
+ ...CommonMutationErrors,
2217
+ '404': ErrorResponse('`toVersion` is not registered, or was unregistered.'),
2218
+ '409': ErrorResponse('The scope has no pin, or no earlier version to go back to.'),
2219
+ },
2220
+ },
2221
+ {
2222
+ method: 'post',
2223
+ honoPath: '/v1/agents/:agentId/live/unpin',
2224
+ openapiPath: '/v1/agents/{agentId}/live/unpin',
2225
+ operationId: 'agents.live.unpin',
2226
+ summary: "Remove a scope's live version",
2227
+ description:
2228
+ "Removes the scope's own pin: its runs use the next scope up (and the latest when nothing is pinned). Recorded like a promotion. Needs `promote` on the agent.",
2229
+ tags: ['agents'],
2230
+ security: 'bearer',
2231
+ parameters: [AgentIdPathParam, IdempotencyKeyParam],
2232
+ requestBody: { required: true, schema: ref('UnpinBody') },
2233
+ responses: {
2234
+ '200': { description: 'Unpinned.', schema: ref('Promotion') },
2235
+ ...CommonMutationErrors,
2236
+ '409': ErrorResponse(
2237
+ '`not-pinned`: the scope has no pin of its own. `gate-policy-needs-pin`: unpinning would leave a scope a gate policy applies to on the latest version, where publishing goes live ungated.',
2238
+ ),
2239
+ },
2240
+ },
1779
2241
 
1780
2242
  // ---------- flows ----------
1781
2243
  {
@@ -1863,10 +2325,15 @@ export const OPERATIONS: readonly OperationSpec[] = [
1863
2325
  responses: {
1864
2326
  '201': { description: 'Flow published.', schema: ref('PublishFlowResult') },
1865
2327
  ...CommonMutationErrors,
1866
- '400': ErrorResponse('Validation failed (see `details.issues`).'),
2328
+ '400': ErrorResponse(
2329
+ "Validation failed (see `details.issues`); or `projectId` isn't a project id (a UUID).",
2330
+ ),
1867
2331
  '409': ErrorResponse(
1868
2332
  "Flow already registered at that (id, version). Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1869
2333
  ),
2334
+ '404': ErrorResponse(
2335
+ "The body's `projectId` names no project of this tenant (`project-not-found`).",
2336
+ ),
1870
2337
  },
1871
2338
  },
1872
2339
  {
@@ -1998,10 +2465,15 @@ export const OPERATIONS: readonly OperationSpec[] = [
1998
2465
  responses: {
1999
2466
  '201': { description: 'Tool registered.', schema: ref('RegisterToolResult') },
2000
2467
  ...CommonMutationErrors,
2001
- '400': ErrorResponse('Validation failed (see `details.issues`).'),
2468
+ '400': ErrorResponse(
2469
+ "Validation failed (see `details.issues`); or `projectId` isn't a project id (a UUID).",
2470
+ ),
2002
2471
  '409': ErrorResponse(
2003
2472
  "Tool already registered at that id. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
2004
2473
  ),
2474
+ '404': ErrorResponse(
2475
+ "The body's `projectId` names no project of this tenant (`project-not-found`).",
2476
+ ),
2005
2477
  },
2006
2478
  },
2007
2479
  {
@@ -2098,10 +2570,15 @@ export const OPERATIONS: readonly OperationSpec[] = [
2098
2570
  responses: {
2099
2571
  '201': { description: 'Guardrail registered.', schema: ref('RegisterGuardrailResult') },
2100
2572
  ...CommonMutationErrors,
2101
- '400': ErrorResponse('Validation failed (see `details.issues`).'),
2573
+ '400': ErrorResponse(
2574
+ "Validation failed (see `details.issues`); or `projectId` isn't a project id (a UUID).",
2575
+ ),
2102
2576
  '409': ErrorResponse(
2103
2577
  "Guardrail already registered at that id. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
2104
2578
  ),
2579
+ '404': ErrorResponse(
2580
+ "The body's `projectId` names no project of this tenant (`project-not-found`).",
2581
+ ),
2105
2582
  },
2106
2583
  },
2107
2584
  {
@@ -2131,7 +2608,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
2131
2608
  operationId: 'conversations.list',
2132
2609
  summary: 'List conversations',
2133
2610
  description:
2134
- "Cursor-paginated. Fixed sort: `openedAt desc, id desc`. Filters: `?agentId=`, `?status=open|closed`, and `scopeKind`/`scopeId` for one project's conversations, or every project's in an org. Conversations from before Kindgi 0.1.3 have no project and are listed only without a scope.",
2611
+ "Cursor-paginated. Fixed sort: `openedAt desc, id desc`. Filters: `?agentId=`, `?status=open|closed`, `?replays=exclude|include|only` (default `exclude`: a comparison's replay conversations are left out), and `scopeKind`/`scopeId` for one project's conversations, or every project's in an org. Conversations from before Kindgi 0.1.3 have no project and are listed only without a scope.",
2135
2612
  tags: ['conversations'],
2136
2613
  security: 'bearer',
2137
2614
  parameters: [
@@ -2141,6 +2618,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
2141
2618
  ScopeIdQueryParam,
2142
2619
  AgentIdQueryParam,
2143
2620
  ConversationStatusQueryParam,
2621
+ ConversationReplaysQueryParam,
2144
2622
  ],
2145
2623
  responses: {
2146
2624
  '200': {
@@ -2163,6 +2641,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
2163
2641
  responses: {
2164
2642
  '200': { description: 'Conversation.', schema: ref('Conversation') },
2165
2643
  ...CommonAuthErrors,
2644
+ '400': ErrorResponse('`conversationId` is not a conversation id (a UUID).'),
2166
2645
  '404': ErrorResponse('No conversation with that id under this tenant.'),
2167
2646
  },
2168
2647
  },
@@ -2200,6 +2679,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
2200
2679
  schema: ref('Conversation'),
2201
2680
  },
2202
2681
  ...CommonMutationErrors,
2682
+ '400': ErrorResponse('`conversationId` is not a conversation id (a UUID).'),
2203
2683
  '404': ErrorResponse('No conversation with that id under this tenant.'),
2204
2684
  },
2205
2685
  },
@@ -2220,7 +2700,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
2220
2700
  schema: ref('ConversationMessageCollectionPage'),
2221
2701
  },
2222
2702
  ...CommonAuthErrors,
2223
- '400': ErrorResponse('Malformed cursor.'),
2703
+ '400': ErrorResponse(
2704
+ 'Malformed cursor, or `conversationId` is not a conversation id (a UUID).',
2705
+ ),
2224
2706
  '404': ErrorResponse('No conversation with that id under this tenant.'),
2225
2707
  },
2226
2708
  },
@@ -2712,7 +3194,11 @@ export const OPERATIONS: readonly OperationSpec[] = [
2712
3194
  CursorQueryParam,
2713
3195
  ObservationStatusQueryParam,
2714
3196
  AgentIdQueryParam,
3197
+ ObservationAgentVersionQueryParam,
2715
3198
  SupervisorIdQueryParam,
3199
+ ObservationConversationIdQueryParam,
3200
+ ObservationSinceQueryParam,
3201
+ ObservationUntilQueryParam,
2716
3202
  ],
2717
3203
  responses: {
2718
3204
  '200': {
@@ -2872,7 +3358,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
2872
3358
  '400': ErrorResponse(
2873
3359
  'Malformed body, or `item-not-found` (the pointer resolves to nothing in the output), or `judge-class-not-applicable`.',
2874
3360
  ),
2875
- '403': ErrorResponse('`permission-denied`: not allowed to judge this run.'),
3361
+ '403': ErrorResponse(
3362
+ '`permission-denied`: not allowed to judge this run. `judge-class-not-allowed`: the judge class is restricted (`assertableBy`) and the caller may not assert it.',
3363
+ ),
2876
3364
  '404': ErrorResponse('`run-not-found`.'),
2877
3365
  '409': ErrorResponse('`run-not-finished`: the run has no output to judge yet.'),
2878
3366
  },
@@ -3441,7 +3929,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
3441
3929
  operationId: 'policies.publish',
3442
3930
  summary: 'Publish a policy',
3443
3931
  description:
3444
- "Body is a full `Policy` — the server validates top-level shape (id, tenantId, semver version, kind ∈ closed enum, spec is an object). Deeper `spec` validation is the runtime consumer's responsibility per kind. Re-publishing an existing `(policyId, version)` returns `409 policy-already-registered`. A known kind that no runtime consumer applies yet (`access-control`, `adapter-allowlist`, `rate-limit`, `compliance`) is refused with `400 kind-not-applied` (`details.appliedKinds` lists the ones that are): publishing it would change nothing. Idempotency-Key applies (retries with the same key replay the original 201).",
3932
+ "Body is a full `Policy` — the server validates top-level shape (id, tenantId, semver version, kind ∈ closed enum, spec is an object), and `spec` for `tool-errors`, `hitl` and `retention` (a retention policy with an unknown domain or `mode: archive` is refused with `400 validation-failed`, naming the field). Other kinds' specs are their runtime consumer's to validate. Re-publishing an existing `(policyId, version)` returns `409 policy-already-registered`. A tenant has one retention policy per domain, plus one for `*`: a second policy id for a covered domain is refused with `409 policy-scope-taken` (`details.heldBy` names the policy that covers it; publish a new version of that one instead), and a new version can't move a policy to another domain (`409 policy-scope-changed`). A known kind that no runtime consumer applies yet (`access-control`, `adapter-allowlist`, `rate-limit`, `compliance`) is refused with `400 kind-not-applied` (`details.appliedKinds` lists the ones that are): publishing it would change nothing. Idempotency-Key applies (retries with the same key replay the original 201).",
3445
3933
  tags: ['policies'],
3446
3934
  security: 'bearer',
3447
3935
  parameters: [IdempotencyKeyParam],
@@ -3452,7 +3940,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
3452
3940
  '400': ErrorResponse(
3453
3941
  'Validation failed (see `details.issues`), or `kind-not-applied`: no runtime consumer applies that kind yet.',
3454
3942
  ),
3455
- '409': ErrorResponse('Policy already registered at that (id, version).'),
3943
+ '409': ErrorResponse(
3944
+ '`policy-already-registered`: that (id, version) exists. `policy-scope-taken`: another policy covers the retention domain (`details.heldBy`). `policy-scope-changed`: the version would move the policy to another domain.',
3945
+ ),
3456
3946
  },
3457
3947
  },
3458
3948
  {
@@ -3485,6 +3975,70 @@ export const OPERATIONS: readonly OperationSpec[] = [
3485
3975
  '200': { description: 'Reinstated.', schema: ref('ReinstatePolicyVersionResult') },
3486
3976
  ...CommonMutationErrors,
3487
3977
  '404': ErrorResponse('No policy at that (id, version) under this tenant.'),
3978
+ '409': ErrorResponse(
3979
+ "`policy-scope-taken`: another policy now covers the version's retention domain (`details.heldBy`); unregister it first. `policy-scope-changed`: the version covers a different domain from the policy's other versions.",
3980
+ ),
3981
+ },
3982
+ },
3983
+
3984
+ // ---------- retention (admin plane) ----------
3985
+ {
3986
+ method: 'get',
3987
+ honoPath: '/v1/retention/scheduled',
3988
+ openapiPath: '/v1/retention/scheduled',
3989
+ operationId: 'retention.scheduled',
3990
+ summary: 'List deleted rows scheduled for purging',
3991
+ description:
3992
+ "Tombstoned rows in every domain a retention policy covers, with when each is purged (`purgeAt`) and the policy that decides it. `domainsMissingAdapter` names the covered domains this deployment can't purge; `unpolicedDomains` the ones no policy covers, whose tombstones are kept; `conflicts` the domains two policies cover (stored before one policy per domain was enforced). `limit` caps the rows **per domain**; `hasMore` says some domain has more than it returned, and `nextCursor` (when the runtime can continue) is the `cursor` for the next page. Requires `admin` on the tenant.",
3993
+ tags: ['retention'],
3994
+ security: 'bearer',
3995
+ parameters: [
3996
+ RetentionDomainQueryParam,
3997
+ RetentionPastGraceOnlyQueryParam,
3998
+ LimitQueryParam,
3999
+ CursorQueryParam,
4000
+ ],
4001
+ responses: {
4002
+ '200': { description: 'Scheduled rows.', schema: ref('RetentionScheduledPage') },
4003
+ ...CommonAuthErrors,
4004
+ '403': ErrorResponse('Not a tenant admin.'),
4005
+ '400': ErrorResponse('Unknown `domain`.'),
4006
+ },
4007
+ },
4008
+ {
4009
+ method: 'post',
4010
+ honoPath: '/v1/retention/sweep',
4011
+ openapiPath: '/v1/retention/sweep',
4012
+ operationId: 'retention.sweep',
4013
+ summary: 'Purge the deleted rows past their grace',
4014
+ description:
4015
+ "Purges, for good, every tombstoned row past the grace of the retention policy that covers its domain (or only `domain`'s), up to `maxPerDomain` per domain; `remaining` counts what is left for the next call. Nothing sweeps on its own: call this (or `POST /v1/retention/sweep/{domain}`) from a schedule. A hold (`graceSeconds: -1`) keeps its domain's rows. Idempotent: a second call purges nothing new. Requires `admin` on the tenant.",
4016
+ tags: ['retention'],
4017
+ security: 'bearer',
4018
+ requestBody: { required: false, schema: ref('RetentionSweepBody') },
4019
+ responses: {
4020
+ '200': { description: 'What was purged, per domain.', schema: ref('RetentionSweepResult') },
4021
+ ...CommonMutationErrors,
4022
+ '403': ErrorResponse('Not a tenant admin.'),
4023
+ '400': ErrorResponse('Unknown `domain`, or `maxPerDomain` outside 1..10000.'),
4024
+ },
4025
+ },
4026
+ {
4027
+ method: 'post',
4028
+ honoPath: '/v1/retention/sweep/:domain',
4029
+ openapiPath: '/v1/retention/sweep/{domain}',
4030
+ operationId: 'retention.sweepDomain',
4031
+ summary: "Purge one domain's deleted rows past their grace",
4032
+ description: 'As `POST /v1/retention/sweep`, for one domain. Requires `admin` on the tenant.',
4033
+ tags: ['retention'],
4034
+ security: 'bearer',
4035
+ parameters: [RetentionDomainPathParam],
4036
+ requestBody: { required: false, schema: ref('RetentionSweepDomainBody') },
4037
+ responses: {
4038
+ '200': { description: 'What was purged.', schema: ref('RetentionSweepResult') },
4039
+ ...CommonMutationErrors,
4040
+ '403': ErrorResponse('Not a tenant admin.'),
4041
+ '400': ErrorResponse('Unknown `domain` (or `*`), or `maxPerDomain` outside 1..10000.'),
3488
4042
  },
3489
4043
  },
3490
4044
 
@@ -3578,8 +4132,13 @@ export const OPERATIONS: readonly OperationSpec[] = [
3578
4132
  responses: {
3579
4133
  '201': { description: 'Eval suite published.', schema: ref('PublishEvalSuiteResult') },
3580
4134
  ...CommonMutationErrors,
3581
- '400': ErrorResponse('Validation failed (see `details.issues`).'),
4135
+ '400': ErrorResponse(
4136
+ "Validation failed (see `details.issues`); or `projectId` isn't a project id (a UUID).",
4137
+ ),
3582
4138
  '409': ErrorResponse('Eval suite already registered at that (id, version).'),
4139
+ '404': ErrorResponse(
4140
+ "The body's `projectId` names no project of this tenant (`project-not-found`).",
4141
+ ),
3583
4142
  },
3584
4143
  },
3585
4144
  {
@@ -3597,10 +4156,13 @@ export const OPERATIONS: readonly OperationSpec[] = [
3597
4156
  responses: {
3598
4157
  '201': { description: 'Version published.', schema: ref('BuildJudgedSuiteResult') },
3599
4158
  ...CommonMutationErrors,
3600
- '400': ErrorResponse('Malformed body.'),
4159
+ '400': ErrorResponse("Malformed body; or `projectId` isn't a project id (a UUID)."),
3601
4160
  '403': ErrorResponse('`permission-denied`.'),
3602
4161
  '409': ErrorResponse('Eval suite already registered at that (id, version).'),
3603
4162
  '501': ErrorResponse('`test-sets-not-supported`: this deployment cannot build test sets.'),
4163
+ '404': ErrorResponse(
4164
+ "The body's `projectId` names no project of this tenant (`project-not-found`).",
4165
+ ),
3604
4166
  },
3605
4167
  },
3606
4168
  {
@@ -3750,10 +4312,13 @@ export const OPERATIONS: readonly OperationSpec[] = [
3750
4312
  '201': { description: 'Published.', schema: ref('PublishBlockResult') },
3751
4313
  ...CommonMutationErrors,
3752
4314
  '400': ErrorResponse(
3753
- '`validation-failed` (see `details.issues`), or an unknown `projectId`.',
4315
+ "`validation-failed` (see `details.issues`), or an unknown `projectId`; or `projectId` isn't a project id (a UUID).",
3754
4316
  ),
3755
4317
  '403': ErrorResponse('`permission-denied`: no `write` on the project.'),
3756
4318
  '409': ErrorResponse('`block-already-registered` or `block-project-mismatch`.'),
4319
+ '404': ErrorResponse(
4320
+ "The body's `projectId` names no project of this tenant (`project-not-found`).",
4321
+ ),
3757
4322
  },
3758
4323
  },
3759
4324
  {
@@ -3807,9 +4372,11 @@ export const OPERATIONS: readonly OperationSpec[] = [
3807
4372
  '201': { description: 'Eval run started.', schema: ref('StartEvalRunResult') },
3808
4373
  ...CommonMutationErrors,
3809
4374
  '400': ErrorResponse(
3810
- 'Malformed body (both / neither of `agentRef` / `flowRef`, dispatcher-input-invalid).',
4375
+ "Malformed body (both / neither of `agentRef` / `flowRef`, dispatcher-input-invalid); or `projectId` isn't a project id (a UUID).",
4376
+ ),
4377
+ '404': ErrorResponse(
4378
+ 'No eval suite with that id under this tenant; or `projectId` names no project of this tenant (`project-not-found`).',
3811
4379
  ),
3812
- '404': ErrorResponse('No eval suite with that id under this tenant.'),
3813
4380
  '422': ErrorResponse('No dispatcher registered for the suite kind.'),
3814
4381
  },
3815
4382
  },
@@ -4392,7 +4959,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
4392
4959
  operationId: 'audit.authz.list',
4393
4960
  summary: 'List authz decision audit events',
4394
4961
  description:
4395
- 'Cursor-paginated read of `authz-decision` audit events for the tenant. Filters (all AND-composed): `?actorSubject=` / `?onBehalfOf=` / `?action=` / `?resource=` / `?outcome=` / `?runId=` / `?from=` / `?to=`. Admin@tenant only. Only mounted when `CreateAppInput.auditEvents` is wired.',
4962
+ 'Cursor-paginated read of `authz-decision` audit events for the tenant. Filters (all AND-composed): `?actorSubject=` / `?onBehalfOf=` / `?action=` / `?resource=` / `?outcome=` / `?runId=` / `?from=` / `?to=`. Oldest first; `?order=desc` for newest first. Admin@tenant only. Only mounted when `CreateAppInput.auditEvents` is wired.',
4396
4963
  tags: ['audit'],
4397
4964
  security: 'bearer',
4398
4965
  parameters: [
@@ -4454,6 +5021,14 @@ export const OPERATIONS: readonly OperationSpec[] = [
4454
5021
  description: 'ISO 8601 upper bound (inclusive) on `timestamp`.',
4455
5022
  schema: { type: 'string', format: 'date-time' },
4456
5023
  },
5024
+ {
5025
+ name: 'order',
5026
+ in: 'query',
5027
+ required: false,
5028
+ description:
5029
+ '`asc` (the default): oldest first. `desc`: newest first. `nextCursor` continues in the same order.',
5030
+ schema: { type: 'string', enum: ['asc', 'desc'] },
5031
+ },
4457
5032
  ],
4458
5033
  responses: {
4459
5034
  '200': {
@@ -4500,7 +5075,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
4500
5075
  },
4501
5076
  },
4502
5077
  ...CommonAuthErrors,
4503
- '400': ErrorResponse('Malformed cursor, `from`, `to`, or `outcome`.'),
5078
+ '400': ErrorResponse('Malformed cursor, `from`, `to`, `outcome`, or `order`.'),
4504
5079
  },
4505
5080
  },
4506
5081
 
@@ -4835,6 +5410,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
4835
5410
  responses: {
4836
5411
  '204': { description: 'Removed (or already absent). No body.' },
4837
5412
  ...CommonAuthErrors,
5413
+ '501': ErrorResponse(
5414
+ "With authorization enforced, a runtime whose tenant-hierarchy binding can't change the membership together with its authorization tuple refuses with `authz-membership-unsupported`; nothing is changed.",
5415
+ ),
4838
5416
  },
4839
5417
  },
4840
5418
  {
@@ -4869,6 +5447,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
4869
5447
  '404': ErrorResponse(
4870
5448
  'No membership for that (team, user) pair, or no such team under this tenant.',
4871
5449
  ),
5450
+ '501': ErrorResponse(
5451
+ "With authorization enforced, a runtime whose tenant-hierarchy binding can't change the membership together with its authorization tuple refuses with `authz-membership-unsupported`; nothing is changed.",
5452
+ ),
4872
5453
  },
4873
5454
  },
4874
5455
 
@@ -5106,6 +5687,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
5106
5687
  responses: {
5107
5688
  '204': { description: 'Removed (or already absent). No body.' },
5108
5689
  ...CommonAuthErrors,
5690
+ '501': ErrorResponse(
5691
+ "With authorization enforced, a runtime whose tenant-hierarchy binding can't change the membership together with its authorization tuple refuses with `authz-membership-unsupported`; nothing is changed.",
5692
+ ),
5109
5693
  },
5110
5694
  },
5111
5695
  {
@@ -5140,6 +5724,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
5140
5724
  '404': ErrorResponse(
5141
5725
  'No membership for that (project, user) pair, or no such project under this tenant.',
5142
5726
  ),
5727
+ '501': ErrorResponse(
5728
+ "With authorization enforced, a runtime whose tenant-hierarchy binding can't change the membership together with its authorization tuple refuses with `authz-membership-unsupported`; nothing is changed.",
5729
+ ),
5143
5730
  },
5144
5731
  },
5145
5732