@kici-dev/orchestrator 0.1.27 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/dist/__test-helpers__/mock-db.d.ts +2 -0
  2. package/dist/agent/dispatcher.d.ts +52 -2
  3. package/dist/agent/host-roster-reaper.d.ts +1 -2
  4. package/dist/agent/host-roster.d.ts +34 -0
  5. package/dist/agent/ownership-refusal.d.ts +12 -0
  6. package/dist/agent/ownership-tracker.d.ts +64 -16
  7. package/dist/agent/token-store.d.ts +13 -0
  8. package/dist/agent-packaging/availability.d.ts +27 -0
  9. package/dist/agent-packaging/build-package.d.ts +16 -0
  10. package/dist/agent-packaging/download.d.ts +30 -0
  11. package/dist/agent-packaging/index.d.ts +9 -0
  12. package/dist/agent-packaging/install-closure.d.ts +30 -0
  13. package/dist/agent-packaging/node-binary.d.ts +26 -0
  14. package/dist/agent-packaging/refresh.d.ts +50 -0
  15. package/dist/agent-packaging/store.d.ts +15 -0
  16. package/dist/agent-packaging/upload.d.ts +24 -0
  17. package/dist/app-on-error.d.ts +29 -0
  18. package/dist/app.d.ts +56 -4
  19. package/dist/artifacts/artifact-store.d.ts +233 -0
  20. package/dist/artifacts/failure-messages.d.ts +46 -0
  21. package/dist/audit/access-log.d.ts +18 -1
  22. package/dist/cache/dep-cache.d.ts +15 -0
  23. package/dist/cache/user-cache.d.ts +37 -0
  24. package/dist/cancel/cancel-run.d.ts +10 -3
  25. package/dist/cancel/dashboard-cancel-handler.d.ts +19 -0
  26. package/dist/cli/api-client.d.ts +44 -1
  27. package/dist/cli/commands/agent-package.d.ts +34 -0
  28. package/dist/cli/commands/check-run.d.ts +26 -0
  29. package/dist/cli/commands/cluster-settings.d.ts +55 -0
  30. package/dist/cli/commands/dashboard-encryption-key.d.ts +3 -0
  31. package/dist/cli/commands/db-backup.d.ts +71 -0
  32. package/dist/cli/commands/orchestrator-service/drain.d.ts +31 -0
  33. package/dist/cli/commands/orchestrator-service/index.d.ts +7 -4
  34. package/dist/cli/commands/orchestrator-service/install-env.d.ts +58 -0
  35. package/dist/cli/commands/secret.d.ts +45 -1
  36. package/dist/cli/commands/shared/admin-cli-access-log.d.ts +46 -0
  37. package/dist/cli/commands/shared/versioned-upgrade.d.ts +65 -2
  38. package/dist/cli/commands/signing-key.d.ts +3 -0
  39. package/dist/cli/commands/source.d.ts +12 -0
  40. package/dist/cli/commands/token.d.ts +9 -0
  41. package/dist/cli/commands/trust-policy.d.ts +48 -0
  42. package/dist/cli/join.d.ts +1 -1
  43. package/dist/cli/service/index.d.ts +2 -2
  44. package/dist/cli/service/instance/manifest.d.ts +17 -0
  45. package/dist/cli/service/instance/resolve.d.ts +11 -0
  46. package/dist/cli/wizard/orchestrator-wizard.d.ts +39 -11
  47. package/dist/cli.js +9921 -3409
  48. package/dist/cluster/cluster-settings-reader.d.ts +78 -0
  49. package/dist/cluster/coordinator.d.ts +81 -9
  50. package/dist/cluster/join-client.d.ts +1 -1
  51. package/dist/cluster/leader-gated-scheduler.d.ts +50 -0
  52. package/dist/cluster/orphan-recovery.d.ts +14 -0
  53. package/dist/cluster/peer-client.d.ts +12 -2
  54. package/dist/cluster/peer-handler.d.ts +15 -4
  55. package/dist/cluster/peer-registry.d.ts +12 -0
  56. package/dist/cluster/verified-issuer-poller.d.ts +11 -0
  57. package/dist/cluster/verified-issuer.d.ts +63 -0
  58. package/dist/cold-store/tables/access-log.d.ts +1 -1
  59. package/dist/cold-store/tables/event-log.d.ts +1 -1
  60. package/dist/cold-store/tables/execution-jobs.d.ts +1 -1
  61. package/dist/cold-store/tables/execution-runs.d.ts +1 -1
  62. package/dist/cold-store/tables/execution-steps.d.ts +1 -1
  63. package/dist/cold-store/tables/secret-audit-log.d.ts +1 -1
  64. package/dist/config/loader.d.ts +1 -1
  65. package/dist/config/resolver.d.ts +2 -1
  66. package/dist/config/schema.d.ts +9 -6
  67. package/dist/config/types.d.ts +5 -2
  68. package/dist/config.d.ts +366 -53
  69. package/dist/contexts/context-store.d.ts +21 -8
  70. package/dist/contexts/glob-specificity.d.ts +30 -0
  71. package/dist/contexts/held-runs.d.ts +51 -19
  72. package/dist/contexts/protection/aggregate.d.ts +2 -2
  73. package/dist/contexts/protection/concurrency-gate.d.ts +0 -3
  74. package/dist/contexts/protection/reviewer-gate.d.ts +0 -3
  75. package/dist/contexts/protection/satisfiability.d.ts +1 -1
  76. package/dist/contexts/protection/trust-gate.d.ts +0 -3
  77. package/dist/contexts/protection/wait-timer-gate.d.ts +0 -3
  78. package/dist/cron/cron-scheduler.d.ts +24 -4
  79. package/dist/cron/cron-store.d.ts +21 -7
  80. package/dist/dashboard/attestation-filters.d.ts +92 -74
  81. package/dist/dashboard/handler.d.ts +35 -1
  82. package/dist/db/migration-test-harness.d.ts +41 -0
  83. package/dist/db/migrations/069_reroute_tunables.d.ts +21 -0
  84. package/dist/db/migrations/070_execution_runs_failure_class.d.ts +4 -0
  85. package/dist/db/migrations/071_batch_accumulation.d.ts +26 -0
  86. package/dist/db/migrations/072_dispatch_queue_run_id_index.d.ts +15 -0
  87. package/dist/db/migrations/073_org_settings_ingest_concurrency.d.ts +13 -0
  88. package/dist/db/migrations/074_normalize_zero_concurrency_limit.d.ts +13 -0
  89. package/dist/db/migrations/075_ingest_overflow_buffer.d.ts +16 -0
  90. package/dist/db/migrations/076_artifacts.d.ts +19 -0
  91. package/dist/db/migrations/077_backup_runs.d.ts +13 -0
  92. package/dist/db/migrations/078_org_settings_backup_staleness.d.ts +12 -0
  93. package/dist/db/migrations/079_org_settings_scaler_spawn_timeout.d.ts +14 -0
  94. package/dist/db/migrations/080_cluster_settings.d.ts +17 -0
  95. package/dist/db/migrations/081_org_settings_queue_timeout.d.ts +19 -0
  96. package/dist/db/migrations/082_host_s3_reachable.d.ts +16 -0
  97. package/dist/db/migrations/083_org_settings_artifact_caps.d.ts +18 -0
  98. package/dist/db/migrations/084_orchestrator_signing_keys.d.ts +20 -0
  99. package/dist/db/migrations/085_cluster_settings_reroute_flap_grace_ms.d.ts +12 -0
  100. package/dist/db/migrations/086_cluster_settings_max_fanout_hosts.d.ts +12 -0
  101. package/dist/db/migrations/087_cluster_settings_event_router_rate_limit.d.ts +12 -0
  102. package/dist/db/migrations/088_cluster_settings_cache_max_tarball_bytes.d.ts +12 -0
  103. package/dist/db/migrations/089_cluster_settings_cache_ttl_days.d.ts +12 -0
  104. package/dist/db/migrations/090_cluster_settings_concurrency_wait_timeout_ms.d.ts +12 -0
  105. package/dist/db/migrations/091_cluster_settings_agent_token_ttl_ms.d.ts +12 -0
  106. package/dist/db/migrations/092_cluster_settings_version.d.ts +16 -0
  107. package/dist/db/migrations/093_org_settings_sandbox_allowlist.d.ts +4 -0
  108. package/dist/db/migrations/094_dashboard_encryption_keys.d.ts +21 -0
  109. package/dist/db/migrations/095_dashboard_write_policy_tristate.d.ts +20 -0
  110. package/dist/db/migrations/096_multi_schedule_cron_last_fired.d.ts +4 -0
  111. package/dist/db/migrations/097_execution_runs_pr_number.d.ts +4 -0
  112. package/dist/db/migrations/098_execution_runs_customer_id.d.ts +4 -0
  113. package/dist/db/migrations/099_cluster_settings_dashboard_verified_issuer.d.ts +21 -0
  114. package/dist/db/migrations/100_held_runs_hold_type_vocabulary.d.ts +31 -0
  115. package/dist/db/migrations/101_contexts_hold_expiry_drop_default.d.ts +31 -0
  116. package/dist/db/migrations/102_dispatch_queue_agent_id.d.ts +20 -0
  117. package/dist/db/migrations/103_cluster_settings_ownership_db_check_timeout_ms.d.ts +20 -0
  118. package/dist/db/migrations/104_check_run_terminal_sent.d.ts +22 -0
  119. package/dist/db/migrations/105_org_trust_policy.d.ts +19 -0
  120. package/dist/db/migrations/106_cluster_settings_check_run_tracking_ttl_days.d.ts +18 -0
  121. package/dist/db/migrations/107_check_run_tracking_updated_at_index.d.ts +23 -0
  122. package/dist/db/migrations/108_unroutable_fast_fail.d.ts +4 -0
  123. package/dist/db/repos/dashboard-encryption-keys-repo.d.ts +48 -0
  124. package/dist/db/repos/signing-keys-repo.d.ts +34 -0
  125. package/dist/db/types.d.ts +441 -7
  126. package/dist/deployment/deployment-identity.d.ts +87 -2
  127. package/dist/diagnostics/checks/backup.d.ts +18 -0
  128. package/dist/diagnostics/checks/index.d.ts +2 -1
  129. package/dist/diagnostics/fleet-collector.d.ts +1 -1
  130. package/dist/drain/drain-controller.d.ts +52 -0
  131. package/dist/events/batch-accumulator.d.ts +63 -0
  132. package/dist/events/circuit-breaker.d.ts +9 -3
  133. package/dist/events/event-emitter.d.ts +31 -0
  134. package/dist/events/event-retry-scanner.d.ts +12 -2
  135. package/dist/events/event-router.d.ts +29 -0
  136. package/dist/firecracker/host-network.d.ts +2 -0
  137. package/dist/firecracker/net-interfaces.d.ts +14 -0
  138. package/dist/github-app-name-refresher/github-app-name-refresher.d.ts +18 -8
  139. package/dist/index.d.ts +2 -0
  140. package/dist/index.js +654 -29
  141. package/dist/lockfile-cache.d.ts +4 -0
  142. package/dist/lockfile-validate.d.ts +16 -9
  143. package/dist/metrics/prometheus.d.ts +113 -15
  144. package/dist/oidc/aws-kms-signer.d.ts +37 -0
  145. package/dist/oidc/command-signer.d.ts +23 -0
  146. package/dist/oidc/db-signer.d.ts +48 -0
  147. package/dist/oidc/id-token-claims.d.ts +22 -9
  148. package/dist/oidc/jwt.d.ts +5 -2
  149. package/dist/oidc/local-dev-signer.d.ts +1 -1
  150. package/dist/oidc/oidc-mint-registration.d.ts +27 -11
  151. package/dist/oidc/orchestrator-mint.d.ts +97 -0
  152. package/dist/oidc/orchestrator-signer-factory.d.ts +33 -0
  153. package/dist/oidc/reconcile-signing-key.d.ts +21 -0
  154. package/dist/oidc/signer.d.ts +25 -0
  155. package/dist/oidc/signing-key-status.d.ts +23 -0
  156. package/dist/orchestrator-core.d.ts +42 -2
  157. package/dist/pipeline/decorating-secret-resolver.d.ts +3 -2
  158. package/dist/pipeline/dispatch-matched-workflow.d.ts +41 -0
  159. package/dist/pipeline/install-secrets-resolver.d.ts +12 -1
  160. package/dist/pipeline/manual-schedule.d.ts +20 -13
  161. package/dist/pipeline/pending-workflow-context.d.ts +1 -1
  162. package/dist/pipeline/process-webhook.d.ts +57 -2
  163. package/dist/pipeline/processor.d.ts +44 -8
  164. package/dist/pipeline/rerun.d.ts +12 -13
  165. package/dist/pipeline/resolve-sandbox-grant.d.ts +28 -0
  166. package/dist/pipeline/route-or-dispatch-jobs.d.ts +71 -0
  167. package/dist/pipeline/sandbox-allowlist-reader.d.ts +33 -0
  168. package/dist/policy/dashboard-write-policy.d.ts +9 -4
  169. package/dist/provenance/backfill-run.d.ts +1 -0
  170. package/dist/provenance/trust-root.d.ts +13 -0
  171. package/dist/providers/generic/normalizer.d.ts +1 -1
  172. package/dist/providers/github/auth.d.ts +1 -1
  173. package/dist/providers/github/changed-files.d.ts +14 -6
  174. package/dist/providers/github/check-status-poster.d.ts +19 -3
  175. package/dist/providers/github/contributor-resolver.d.ts +1 -1
  176. package/dist/providers/github/lock-file.d.ts +1 -1
  177. package/dist/providers/github/normalizer.d.ts +1 -1
  178. package/dist/providers/github/repo-url.d.ts +1 -1
  179. package/dist/providers/local/lock-file-fetcher.d.ts +1 -1
  180. package/dist/providers/local/normalizer.d.ts +1 -1
  181. package/dist/providers/local/repo-url-builder.d.ts +1 -1
  182. package/dist/providers/universal-git/changed-files.d.ts +8 -7
  183. package/dist/providers/universal-git/clone-token.d.ts +1 -1
  184. package/dist/providers/universal-git/config.d.ts +4 -4
  185. package/dist/providers/universal-git/index.d.ts +5 -1
  186. package/dist/providers/universal-git/lock-file.d.ts +6 -1
  187. package/dist/providers/universal-git/normalizer.d.ts +1 -1
  188. package/dist/providers/universal-git/repo-url.d.ts +1 -1
  189. package/dist/queue/bootstrap.d.ts +5 -0
  190. package/dist/queue/cleanup.d.ts +72 -9
  191. package/dist/queue/job-queue.d.ts +141 -14
  192. package/dist/queue/scheduled-job.d.ts +3 -2
  193. package/dist/queue/terminalize-unroutable.d.ts +53 -0
  194. package/dist/queue/unroutable-probe.d.ts +52 -0
  195. package/dist/registration/registration-index.d.ts +1 -1
  196. package/dist/reporting/agent-failure-category.d.ts +4 -1
  197. package/dist/reporting/check-run-reporter.d.ts +34 -14
  198. package/dist/reporting/check-run-tracking-store.d.ts +70 -8
  199. package/dist/reporting/execution-tracker.d.ts +156 -10
  200. package/dist/reporting/fs-log-storage.d.ts +31 -2
  201. package/dist/reporting/job-check-run-completion.d.ts +50 -0
  202. package/dist/reporting/log-chunk-sink.d.ts +47 -0
  203. package/dist/reporting/log-retention.d.ts +16 -0
  204. package/dist/reporting/log-storage.d.ts +64 -4
  205. package/dist/reporting/log-writer.d.ts +22 -7
  206. package/dist/reporting/peer-log-normalize.d.ts +14 -0
  207. package/dist/reporting/run-aggregator.d.ts +50 -33
  208. package/dist/reporting/s3-log-storage.d.ts +102 -8
  209. package/dist/routes/admin-auth.d.ts +90 -0
  210. package/dist/routes/admin-cluster-settings.d.ts +31 -0
  211. package/dist/routes/admin-events.d.ts +3 -0
  212. package/dist/routes/admin-orchestrator-drain.d.ts +35 -0
  213. package/dist/routes/admin-runs.d.ts +9 -0
  214. package/dist/routes/admin-sources.d.ts +7 -0
  215. package/dist/routes/admin-trust-policy.d.ts +49 -0
  216. package/dist/routes/admin.d.ts +15 -1
  217. package/dist/routes/github-webhook.d.ts +9 -3
  218. package/dist/routes/provenance-oidc.d.ts +38 -0
  219. package/dist/routes/verify-attestation.d.ts +21 -0
  220. package/dist/scaler/bare-metal-backend.d.ts +9 -2
  221. package/dist/scaler/config.d.ts +25 -4
  222. package/dist/scaler/container-backend.d.ts +9 -1
  223. package/dist/scaler/firecracker-backend.d.ts +29 -2
  224. package/dist/scaler/index.d.ts +1 -1
  225. package/dist/scaler/manager.d.ts +166 -8
  226. package/dist/scaler/pending-scale-sweeper.d.ts +35 -0
  227. package/dist/scaler/types.d.ts +75 -6
  228. package/dist/secrets/backend-registry.d.ts +32 -1
  229. package/dist/secrets/dashboard-encryption-key.d.ts +48 -0
  230. package/dist/secrets/ephemeral-keys.d.ts +16 -0
  231. package/dist/secrets/pg-secret-store.d.ts +10 -0
  232. package/dist/secrets/rbac.d.ts +5 -1
  233. package/dist/secrets/routing-key-scope.d.ts +6 -0
  234. package/dist/secrets/scope-routing.d.ts +126 -0
  235. package/dist/secrets/secret-resolver.d.ts +1 -14
  236. package/dist/secrets/token-manager.d.ts +5 -1
  237. package/dist/security/contributor-cache.d.ts +9 -1
  238. package/dist/security/trust-policy-gate.d.ts +117 -0
  239. package/dist/security/trust-policy-store.d.ts +78 -0
  240. package/dist/server.js +36074 -25052
  241. package/dist/sources/source-manager.d.ts +24 -0
  242. package/dist/stale-detector/stale-run-detector.d.ts +7 -0
  243. package/dist/standalone.js +35203 -25387
  244. package/dist/storage/filesystem.d.ts +17 -0
  245. package/dist/storage/key-discriminator.d.ts +20 -0
  246. package/dist/storage/s3.d.ts +2 -0
  247. package/dist/storage/types.d.ts +16 -0
  248. package/dist/webhook/dedup.d.ts +9 -1
  249. package/dist/webhook/event-log.d.ts +13 -2
  250. package/dist/webhook/generic-sources-listener.d.ts +4 -0
  251. package/dist/webhook/ingest-admission.d.ts +140 -0
  252. package/dist/webhook/ingest-overflow-buffer.d.ts +27 -0
  253. package/dist/webhook/ingest-overflow-replayer.d.ts +49 -0
  254. package/dist/webhook/ingest-overflow-types.d.ts +73 -0
  255. package/dist/webhook/loop-lag-source.d.ts +40 -0
  256. package/dist/webhook/observed-relay-guard.d.ts +40 -0
  257. package/dist/webhook/org-ingest-cap-reader.d.ts +24 -0
  258. package/dist/webhook/register-source-bundle.d.ts +3 -0
  259. package/dist/webhook/relay-reinject.d.ts +43 -0
  260. package/dist/worker/in-memory-job-queue.d.ts +8 -3
  261. package/dist/worker-core.d.ts +10 -0
  262. package/dist/ws/agent-api-registry.d.ts +20 -0
  263. package/dist/ws/agent-handler.d.ts +63 -7
  264. package/dist/ws/bringup-api.d.ts +99 -0
  265. package/dist/ws/dashboard-context-handler.d.ts +28 -10
  266. package/dist/ws/dashboard-run-state-handler.d.ts +31 -0
  267. package/dist/ws/failure-messages.d.ts +29 -0
  268. package/dist/ws/oidc-token-relay.d.ts +9 -0
  269. package/dist/ws/ownership-gate.d.ts +22 -0
  270. package/dist/ws/platform-client.d.ts +96 -1
  271. package/dist/ws/replay-chunker.d.ts +37 -0
  272. package/installer-image-digests.json +3 -3
  273. package/package.json +22 -21
  274. package/sbom.spdx.json +1240 -1788
@@ -7,6 +7,7 @@ import type { ApprovalRequirement, ApproverClause, InitFailure, StepApprovalPayl
7
7
  export interface Database {
8
8
  dispatch_queue: DispatchQueueTable;
9
9
  dedup_cache: DedupCacheTable;
10
+ ingest_overflow_buffer: IngestOverflowBufferTable;
10
11
  ip_allocations: IpAllocationTable;
11
12
  execution_runs: ExecutionRunTable;
12
13
  execution_jobs: ExecutionJobTable;
@@ -37,6 +38,8 @@ export interface Database {
37
38
  cluster_meta: ClusterMetaTable;
38
39
  join_tokens: JoinTokenTable;
39
40
  org_settings: OrgSettingsTable;
41
+ org_trust_policy: OrgTrustPolicyTable;
42
+ cluster_settings: ClusterSettingsTable;
40
43
  execution_job_needs: ExecutionJobNeedsTable;
41
44
  pending_job_contexts: PendingJobContextsTable;
42
45
  pending_workflow_contexts: PendingWorkflowContextsTable;
@@ -49,11 +52,67 @@ export interface Database {
49
52
  scaler_agent_jobs: ScalerAgentJobsTable;
50
53
  scaler_reservations: ScalerReservationsTable;
51
54
  attestations: AttestationsTable;
55
+ orchestrator_signing_keys: OrchestratorSigningKeysTable;
56
+ dashboard_encryption_keys: DashboardEncryptionKeysTable;
52
57
  pending_attestations: PendingAttestationsTable;
58
+ artifacts: ArtifactsTable;
53
59
  remote_sources: RemoteSourcesTable;
54
60
  host_roster: HostRosterTable;
55
61
  request_idempotency: RequestIdempotencyTable;
62
+ batch_accumulation_windows: BatchAccumulationWindowsTable;
63
+ batch_accumulation_items: BatchAccumulationItemsTable;
64
+ backup_runs: BackupRunsTable;
56
65
  }
66
+ /**
67
+ * Open accumulation window for a `workflowsFailedBatch` registration.
68
+ * One live window per subscribing workflow (`registration_id` is unique);
69
+ * the first matching failure opens it and the leader sweep closes it once
70
+ * `expires_at` passes, emitting a single `__workflows_failed_batch` event.
71
+ */
72
+ export interface BatchAccumulationWindowsTable {
73
+ /** Window id (primary key). */
74
+ id: string;
75
+ /** Owning customer/org id. */
76
+ customer_id: string;
77
+ /** Subscribing registration id (unique — open-once). */
78
+ registration_id: string;
79
+ /** Routing key captured at open time so the sweep can emit without the index. */
80
+ routing_key: string;
81
+ /** Repo identifier captured at open time. */
82
+ repo_identifier: string;
83
+ /** Accumulation window length in milliseconds. */
84
+ accumulate_for_ms: number;
85
+ /** When the window opened (first failure). */
86
+ opened_at: Generated<Date>;
87
+ /** When the window is due for the leader sweep. */
88
+ expires_at: Date;
89
+ }
90
+ export type BatchAccumulationWindow = Selectable<BatchAccumulationWindowsTable>;
91
+ export type NewBatchAccumulationWindow = Insertable<BatchAccumulationWindowsTable>;
92
+ /**
93
+ * A single failed run buffered into a batch-accumulation window.
94
+ * Deleted with its window via `ON DELETE CASCADE` when the window is swept.
95
+ */
96
+ export interface BatchAccumulationItemsTable {
97
+ /** Item id (primary key). */
98
+ id: string;
99
+ /** Owning window id (FK, cascade-deleted). */
100
+ window_id: string;
101
+ /** The failed run's id. */
102
+ run_id: string;
103
+ /** Repo identifier of the failed run. */
104
+ repo_identifier: string;
105
+ /** Workflow name of the failed run. */
106
+ workflow_name: string;
107
+ /** Failure class (`RunFailureClass`) when known. */
108
+ failure_class: string | null;
109
+ /** Triggering actor username when known. */
110
+ sender_username: string | null;
111
+ /** When the item was buffered. */
112
+ created_at: Generated<Date>;
113
+ }
114
+ export type BatchAccumulationItem = Selectable<BatchAccumulationItemsTable>;
115
+ export type NewBatchAccumulationItem = Insertable<BatchAccumulationItemsTable>;
57
116
  /**
58
117
  * Request idempotency claim table.
59
118
  * Keyed on the Platform `requestId`; makes run-minting dashboard requests
@@ -72,6 +131,28 @@ export interface RequestIdempotencyTable {
72
131
  export type RequestIdempotency = Selectable<RequestIdempotencyTable>;
73
132
  export type NewRequestIdempotency = Insertable<RequestIdempotencyTable>;
74
133
  export type RequestIdempotencyUpdate = Updateable<RequestIdempotencyTable>;
134
+ /**
135
+ * Backup run log. One row per successful `kici-admin db backup`. Read by the
136
+ * `checkBackupFreshness` diagnostic (`MAX(created_at)`).
137
+ */
138
+ export interface BackupRunsTable {
139
+ id: Generated<string>;
140
+ created_at: Generated<Date>;
141
+ /** Local path the dump was written to (informational). */
142
+ dump_path: string;
143
+ /** Size of the dump file in bytes. */
144
+ byte_size: string | bigint;
145
+ /** Secret-key generation the DB's encrypted config was under (null when no encrypted config). */
146
+ secret_key_version: number | null;
147
+ /** Server version string the dump was taken from (e.g. "160003"). */
148
+ pg_server_version: string;
149
+ /** Bundled-migrations content hash at backup time. */
150
+ migrations_hash: string;
151
+ /** Host that ran the backup. */
152
+ hostname: string;
153
+ }
154
+ export type BackupRun = Selectable<BackupRunsTable>;
155
+ export type NewBackupRun = Insertable<BackupRunsTable>;
75
156
  /**
76
157
  * Cluster metadata table
77
158
  * Key-value store for cluster-wide configuration (e.g. cluster_id).
@@ -193,6 +274,13 @@ export interface DispatchQueueTable {
193
274
  * real provisioning cause; cleared on dispatch. NULL when none recorded.
194
275
  */
195
276
  last_provisioning_error: ColumnType<string | null, string | null | undefined, string | null>;
277
+ /**
278
+ * When this job first read unroutable — no registered agent and no scaler
279
+ * backend matched its selectors. NULL once it reads routable again, so the
280
+ * grace clock only ever measures a CONTINUOUS unroutable window. Persisted
281
+ * rather than in-memory so a restart mid-grace resumes the same clock.
282
+ */
283
+ unroutable_since: ColumnType<Date | null, Date | string | null | undefined, Date | string | null>;
196
284
  /** Times this job was returned to pending for re-dispatch (job.reject / pre-start agent loss). */
197
285
  dispatch_attempts: Generated<number>;
198
286
  /**
@@ -210,6 +298,15 @@ export interface DispatchQueueTable {
210
298
  * to another. NULL for normal label-routed jobs.
211
299
  */
212
300
  pinned_agent_id: ColumnType<string | null, string | null | undefined, string | null>;
301
+ /**
302
+ * Durable owner of a dispatched job: the agent the job was handed to. Written
303
+ * at dispatch, cleared on requeue. Distinct from `ack_agent_id`, which is
304
+ * cleared as soon as the agent answers the dispatch and so cannot resolve
305
+ * ownership later — this column lets a coordinator that never saw the
306
+ * dispatch answer "does this agent own this job?" from the database alone.
307
+ * NULL for pending rows and for rows dispatched before the column existed.
308
+ */
309
+ agent_id: ColumnType<string | null, string | null | undefined, string | null>;
213
310
  }
214
311
  /**
215
312
  * Deduplication cache table
@@ -223,6 +320,39 @@ export interface DedupCacheTable {
223
320
  /** When this cache entry expires (24h TTL) */
224
321
  expires_at: Date;
225
322
  }
323
+ /**
324
+ * Durable overflow buffer for shed webhook-ingest deliveries (migration 075).
325
+ * `status` values come from OverflowStatus, `source_kind` from OverflowSourceKind
326
+ * (packages/orchestrator/src/webhook/ingest-overflow-types.ts). `body` is base64.
327
+ */
328
+ export interface IngestOverflowBufferTable {
329
+ /** Surrogate PK (bigint identity). */
330
+ id: Generated<number>;
331
+ /** Delivery id — the dedup key. */
332
+ delivery_id: string;
333
+ /** Routing key (e.g. "github:42"). */
334
+ routing_key: string;
335
+ /** Ingest boundary: 'direct' (HTTP, verified) | 'relay' (WS, unverified). */
336
+ source_kind: string;
337
+ /** Provider type; null for relay (resolved at replay). */
338
+ provider: string | null;
339
+ /** Provider event type. */
340
+ event: string;
341
+ /** Payload action, or null. */
342
+ action: string | null;
343
+ /** Base64 of the raw delivery bytes. */
344
+ body: string;
345
+ /** Verify-input envelope (relay) or {} (direct). */
346
+ meta: Generated<Record<string, unknown>>;
347
+ /** Capture timestamp (defaults to now()). */
348
+ captured_at: Generated<Date>;
349
+ /** Replay attempt counter. */
350
+ replay_attempts: Generated<number>;
351
+ /** OverflowStatus value. */
352
+ status: Generated<string>;
353
+ /** Last replay error, or null. */
354
+ last_error: string | null;
355
+ }
226
356
  export type DispatchQueueItem = Selectable<DispatchQueueTable>;
227
357
  export type NewDispatchQueueItem = Insertable<DispatchQueueTable>;
228
358
  export type DispatchQueueItemUpdate = Updateable<DispatchQueueTable>;
@@ -256,6 +386,12 @@ export interface ExecutionRunTable {
256
386
  run_id: string;
257
387
  /** Routing key (e.g. github:appId) for Platform StaleOrchDetector when sharing DB */
258
388
  routing_key: string | null;
389
+ /**
390
+ * Owning org (customer_id), denormalized from routing_key at insert time so
391
+ * the concurrency-gate running count can be scoped per tenant. Defaults to
392
+ * '__default__' (the no-source fallback org) via the column DEFAULT.
393
+ */
394
+ customer_id: Generated<string>;
259
395
  /** Workflow name from lock file */
260
396
  workflow_name: string;
261
397
  /** Run status: running | success | failed | cancelled */
@@ -317,6 +453,8 @@ export interface ExecutionRunTable {
317
453
  lock_file_source: string | null;
318
454
  /** Username of the contributor (null for non-PR events) */
319
455
  contributor_username: string | null;
456
+ /** Pull-request number for PR-triggered runs (null for non-PR events). Scopes `/kici approve|reject` hold selection to the comment's PR. */
457
+ pr_number: number | null;
320
458
  /**
321
459
  * Origin provider of the triggering actor (`github` today). Provider-generic
322
460
  * so GitLab/Bitbucket extend later. Null when no actor was captured.
@@ -335,6 +473,12 @@ export interface ExecutionRunTable {
335
473
  trigger_actor_user_id: string | null;
336
474
  /** Human-readable reason why the run failed (null for non-failed runs). */
337
475
  failure_reason: string | null;
476
+ /**
477
+ * Why the run failed (`RunFailureClass` from `@kici-dev/engine`): never_started
478
+ * / timed_out / dead_orchestrator / step_failure / cancelled. Derived at run
479
+ * completion from the terminal job statuses. NULL for success / not-yet-terminal.
480
+ */
481
+ failure_class: string | null;
338
482
  /**
339
483
  * Structured init-phase failure detail (shape: `InitFailure` from
340
484
  * `@kici-dev/engine`). Non-null means the run never executed a step
@@ -381,6 +525,13 @@ export interface ExecutionJobTable {
381
525
  job_name: string;
382
526
  /** Job status: pending | running | success | failed | cancelled | skipped */
383
527
  status: Generated<string>;
528
+ /**
529
+ * Operator-facing reason this job cannot currently be routed to any agent.
530
+ * Written by the unroutable probe while the job is still queued, so the cause
531
+ * is visible long before the job terminalizes; cleared when a matching agent
532
+ * or scaler backend appears. NULL whenever the job is routable.
533
+ */
534
+ routing_reason: ColumnType<string | null, string | null | undefined, string | null>;
384
535
  /** Matrix values JSON (e.g. {"node": "18"}) */
385
536
  matrix_values: string | null;
386
537
  /** Agent ID that ran this job */
@@ -603,16 +754,20 @@ export interface ContextsTable {
603
754
  repo_patterns: Generated<string>;
604
755
  /** Max concurrent runs (null = unlimited) */
605
756
  concurrency_limit: number | null;
606
- /** Strategy when concurrency exceeded: 'queue' | 'cancel-pending' */
607
- concurrency_strategy: Generated<string>;
757
+ /**
758
+ * Strategy when concurrency exceeded; see `ConcurrencyStrategy` in
759
+ * `@kici-dev/engine` for the vocabulary. Stays a plain `string` so a row
760
+ * written by another orchestrator version always maps (null = unset).
761
+ */
762
+ concurrency_strategy: Generated<string | null>;
608
763
  /** Timeout for queued runs in milliseconds */
609
764
  concurrency_timeout_ms: Generated<number>;
610
765
  /** JSONB array of required reviewer identities (null = no approval required) */
611
766
  required_reviewers: string | null;
612
767
  /** Seconds to wait before deploying (null = no wait timer) */
613
768
  wait_timer_seconds: number | null;
614
- /** Seconds before a held run expires */
615
- hold_expiry_seconds: Generated<number>;
769
+ /** Seconds before a held run expires (null = unset, the default window applies) */
770
+ hold_expiry_seconds: Generated<number | null>;
616
771
  /** Minimum trust tier required for CI execution (null = no trust requirement) */
617
772
  minimum_trust: string | null;
618
773
  /** Whether this context allows local (no-remote) executions. Default false. */
@@ -745,7 +900,12 @@ export interface HeldRunsTable {
745
900
  job_id: string;
746
901
  /** Context ID (FK to contexts.id); null once the context is deleted */
747
902
  context_id: string | null;
748
- /** Hold type: 'approval' | 'wait_timer' | 'concurrency' */
903
+ /**
904
+ * Hold type — an engine `HoldType` member ('reviewer' | 'timer' |
905
+ * 'concurrency' | 'security'). Stays `string` so a row written by a
906
+ * different orchestrator version is never rejected; read it through
907
+ * `normalizePersistedHoldType`.
908
+ */
749
909
  hold_type: string;
750
910
  /** Hold status: 'pending' | 'approved' | 'rejected' | 'expired' | 'released' */
751
911
  status: Generated<string>;
@@ -1228,6 +1388,8 @@ export type RegistryVersionUpdate = Updateable<RegistryVersionsTable>;
1228
1388
  export interface CronLastFiredTable {
1229
1389
  /** References workflow_registrations.id (cascade delete) */
1230
1390
  registration_id: string;
1391
+ /** Per-schedule identity: `${cronExpression}\n${timezone}` (see scheduleTriggerKey) */
1392
+ schedule_key: string;
1231
1393
  /** When this cron trigger last fired */
1232
1394
  last_fired_at: Date;
1233
1395
  /** When this record was last updated */
@@ -1390,12 +1552,80 @@ export interface OrgSettingsTable {
1390
1552
  * pg returns a string on select; accept a number on insert/update.
1391
1553
  */
1392
1554
  user_cache_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1555
+ /**
1556
+ * Per-org byte quota for user-facing artifacts (ArtifactStore). NULL = use the
1557
+ * cluster-wide default (`KICI_ARTIFACT_QUOTA_BYTES`, 20 GiB). Postgres BIGINT —
1558
+ * pg returns a string on select; accept a number on insert/update.
1559
+ */
1560
+ artifact_quota_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1561
+ /**
1562
+ * Per-artifact TTL (ms) for user-facing artifacts (ArtifactStore). NULL = use
1563
+ * the cluster-wide default (`KICI_ARTIFACT_TTL_MS`, 30 days). Postgres BIGINT —
1564
+ * pg returns a string on select; accept a number on insert/update.
1565
+ */
1566
+ artifact_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1567
+ /**
1568
+ * Per-org per-artifact size cap (bytes) for user-facing artifacts
1569
+ * (ArtifactStore). NULL = use the cluster-wide default
1570
+ * (`KICI_ARTIFACT_MAX_BYTES`, 1 GiB). Postgres BIGINT — pg returns a string on
1571
+ * select; accept a number on insert/update.
1572
+ */
1573
+ artifact_max_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1574
+ /**
1575
+ * Per-org per-run artifact count cap for user-facing artifacts
1576
+ * (ArtifactStore). NULL = use the cluster-wide default
1577
+ * (`KICI_ARTIFACT_MAX_PER_RUN`, 50). Postgres BIGINT — pg returns a string on
1578
+ * select; accept a number on insert/update.
1579
+ */
1580
+ artifact_max_per_run: ColumnType<string | null, number | null | undefined, number | null>;
1393
1581
  /**
1394
1582
  * Per-org dispatch-acknowledgment deadline (ms); null = cluster default
1395
1583
  * (config.dispatchAckTimeoutMs / KICI_DISPATCH_ACK_TIMEOUT_MS). Postgres
1396
1584
  * BIGINT — pg returns a string on select; accept a number on insert/update.
1397
1585
  */
1398
1586
  dispatch_ack_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1587
+ /**
1588
+ * Per-org webhook-ingest concurrency cap; null = cluster default
1589
+ * (config.ingestOrgMaxConcurrency / KICI_INGEST_ORG_MAX_CONCURRENCY). Postgres
1590
+ * BIGINT — pg returns a string on select; accept a number on insert/update.
1591
+ */
1592
+ ingest_max_concurrency: ColumnType<string | null, number | null | undefined, number | null>;
1593
+ /**
1594
+ * Per-org scaler spawn deadline (ms) for a single `backend.spawn` (image pull
1595
+ * + container create + start); null = cluster default
1596
+ * (config.scalerSpawnTimeoutMs / KICI_SCALER_SPAWN_TIMEOUT_MS). Postgres
1597
+ * BIGINT — pg returns a string on select; accept a number on insert/update.
1598
+ */
1599
+ scaler_spawn_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1600
+ /**
1601
+ * Per-org reroute spawn window (ms): how long the coordinator waits after a
1602
+ * peer ACKs a reroute before treating "accepted but no progress" as a spawn
1603
+ * failure and re-dispatching. Null = cluster default (config.rerouteSpawnWindowMs).
1604
+ * BIGINT — pg returns a string on select; accept a number on insert/update.
1605
+ */
1606
+ reroute_spawn_window_ms: ColumnType<string | null, number | null | undefined, number | null>;
1607
+ /**
1608
+ * Per-org reroute ACK timeout (ms) for the reroute sendAndWaitAck deadline.
1609
+ * Null = cluster default (config.rerouteAckTimeoutMs). BIGINT.
1610
+ */
1611
+ reroute_ack_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1612
+ /**
1613
+ * Per-org maximum peer hops for a rerouted job. Null = cluster default
1614
+ * (config.rerouteMaxHops). Plain INTEGER — pg returns a number on select.
1615
+ */
1616
+ reroute_max_hops: ColumnType<number | null, number | null | undefined, number | null>;
1617
+ /**
1618
+ * Per-org staleness threshold (hours) for the DB-backup freshness diagnostic.
1619
+ * Null = cluster default (config.backupStalenessWarnHours). Plain INTEGER.
1620
+ */
1621
+ backup_staleness_warn_hours: ColumnType<number | null, number | null | undefined, number | null>;
1622
+ /**
1623
+ * Per-org dispatch-queue job timeout (ms). A queued job's deadline is
1624
+ * `job.timeoutMs ?? <this> ?? config.queueTimeoutMs`. Null = cluster default
1625
+ * (config.queueTimeoutMs / KICI_QUEUE_TIMEOUT_MS). Postgres BIGINT — pg
1626
+ * returns a string on select; accept a number on insert/update.
1627
+ */
1628
+ queue_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1399
1629
  /**
1400
1630
  * Per-org expiry (seconds) for a held approval element before it is rejected
1401
1631
  * and its run/job/step fails. NOT NULL, default 86400 (one day). An SDK
@@ -1407,6 +1637,18 @@ export interface OrgSettingsTable {
1407
1637
  * NOT NULL, default true. Operators turn it off to enforce four-eyes review.
1408
1638
  */
1409
1639
  allow_self_approval: ColumnType<boolean, boolean | undefined, boolean>;
1640
+ /**
1641
+ * Container-sandbox escape-hatch allow-list: the Linux capabilities a workflow
1642
+ * may request via the SDK `sandbox: { capabilities }` field. NULL / absent
1643
+ * reads as `[]` (deny every capability request). Postgres TEXT[].
1644
+ */
1645
+ sandbox_allowed_capabilities: ColumnType<string[] | null, string[] | null | undefined, string[] | null>;
1646
+ /**
1647
+ * Container-sandbox escape-hatch allow-list: whether a workflow may request
1648
+ * `sandbox: { network: 'host' }`. NULL / absent reads as `false` (deny host
1649
+ * networking). Postgres BOOLEAN.
1650
+ */
1651
+ sandbox_allow_host_network: ColumnType<boolean | null, boolean | null | undefined, boolean | null>;
1410
1652
  /** When this setting was created */
1411
1653
  created_at: Generated<Date>;
1412
1654
  /** When this setting was last updated */
@@ -1415,6 +1657,94 @@ export interface OrgSettingsTable {
1415
1657
  export type OrgSettings = Selectable<OrgSettingsTable>;
1416
1658
  export type NewOrgSettings = Insertable<OrgSettingsTable>;
1417
1659
  export type OrgSettingsUpdate = Updateable<OrgSettingsTable>;
1660
+ /**
1661
+ * Org trust policy (org_trust_policy) — the orchestrator's cache of the
1662
+ * Platform-owned per-org trust policy delivered on `trust_policy.update`.
1663
+ * Distinct from `org_settings`, which holds operator-owned config: the operator
1664
+ * tunes org_settings, the Platform owns this. `source` records which of the two
1665
+ * wrote the row.
1666
+ *
1667
+ * The three policy columns are plain `string`, not the Zod enums that name the
1668
+ * known vocabulary — same reasoning as `held_runs.hold_type`: a value written by
1669
+ * a newer Platform must still be readable rather than failing the row.
1670
+ */
1671
+ export interface OrgTrustPolicyTable {
1672
+ /** Customer/org identifier (primary key) */
1673
+ customer_id: string;
1674
+ /** How to treat a pull request opened from a fork: hold | reject | allow */
1675
+ fork_policy: string;
1676
+ /** How to treat a PR from a contributor with no resolved identity: hold | reject */
1677
+ unknown_contributor_policy: string;
1678
+ /** How to treat a PR that modifies workflow files: hold | reject | allow */
1679
+ workflow_change_policy: string;
1680
+ /** How long a security hold stays approvable before it expires */
1681
+ approval_expiry_hours: number;
1682
+ /** Which side last wrote this row: platform | local */
1683
+ source: string;
1684
+ /** When this policy was last written */
1685
+ updated_at: ColumnType<Date, Date | undefined, Date>;
1686
+ }
1687
+ export type OrgTrustPolicy = Selectable<OrgTrustPolicyTable>;
1688
+ export type NewOrgTrustPolicy = Insertable<OrgTrustPolicyTable>;
1689
+ export type OrgTrustPolicyUpdate = Updateable<OrgTrustPolicyTable>;
1690
+ /**
1691
+ * Cluster-global settings (cluster_settings) — a single row (id='default') of
1692
+ * fleet-wide operator tunables. Each knob is nullable; NULL = use the cluster
1693
+ * default from config.ts. Read via ClusterSettingsReader. Distinct from
1694
+ * org_settings (per customer_id) — these knobs have no per-tenant meaning.
1695
+ * Byte-valued knobs are Postgres BIGINT (pg returns a string on select); count
1696
+ * / seconds knobs are INTEGER (pg returns a number).
1697
+ */
1698
+ export interface ClusterSettingsTable {
1699
+ id: ColumnType<string, string | undefined, never>;
1700
+ max_github_payload_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1701
+ event_log_max_payload_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1702
+ lock_file_max_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1703
+ webhook_dedup_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1704
+ contributor_cache_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1705
+ event_router_event_ttl_seconds: ColumnType<number | null, number | null | undefined, number | null>;
1706
+ event_router_max_dispatch_attempts: ColumnType<number | null, number | null | undefined, number | null>;
1707
+ queue_max_depth: ColumnType<number | null, number | null | undefined, number | null>;
1708
+ reroute_flap_grace_ms: ColumnType<string | null, number | null | undefined, number | null>;
1709
+ max_fanout_hosts: ColumnType<number | null, number | null | undefined, number | null>;
1710
+ event_router_rate_limit_per_workflow_per_minute: ColumnType<number | null, number | null | undefined, number | null>;
1711
+ cache_max_tarball_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1712
+ cache_ttl_days: ColumnType<number | null, number | null | undefined, number | null>;
1713
+ /**
1714
+ * Retention window in days for `check_run_tracking` rows. The hourly cleanup
1715
+ * sweep deletes rows untouched for longer than this; 0 disables the sweep.
1716
+ * NULL ⇒ the orchestrator's configured default.
1717
+ */
1718
+ check_run_tracking_ttl_days: ColumnType<number | null, number | null | undefined, number | null>;
1719
+ /**
1720
+ * Grace window (ms) a job may stay continuously unroutable before it is
1721
+ * terminalized as `unroutable`. NULL = the orchestrator's configured default;
1722
+ * 0 disables fast-fail, leaving `queue_timeout_ms` as the only backstop.
1723
+ */
1724
+ unroutable_grace_ms: ColumnType<number | null, number | null | undefined, number | null>;
1725
+ concurrency_wait_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1726
+ agent_token_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1727
+ /**
1728
+ * Deadline for one database-backed agent-ownership lookup. Past it the lookup
1729
+ * resolves as undecided and the frame is refused without counting a
1730
+ * violation. NULL ⇒ the orchestrator's configured default.
1731
+ */
1732
+ ownership_db_check_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1733
+ /**
1734
+ * Verified-tier origin the dashboard fetches the orchestrator's X25519
1735
+ * dashboard-encryption public key from (and always displays) under the
1736
+ * `encrypted` dashboard-write posture. The tier is explicit opt-in: NULL ⇒ it
1737
+ * is not offered and the convenient tier is used.
1738
+ */
1739
+ dashboard_verified_issuer: ColumnType<string | null, string | null | undefined, string | null>;
1740
+ /** Monotonic settings version; bumped on each real settings change, advertised to workers. */
1741
+ version: ColumnType<string | number, number | undefined, number>;
1742
+ created_at: Generated<Date>;
1743
+ updated_at: Generated<Date>;
1744
+ }
1745
+ export type ClusterSettings = Selectable<ClusterSettingsTable>;
1746
+ export type NewClusterSettings = Insertable<ClusterSettingsTable>;
1747
+ export type ClusterSettingsUpdate = Updateable<ClusterSettingsTable>;
1418
1748
  /**
1419
1749
  * Pending job contexts table
1420
1750
  * Persists PendingJobContext for crash-recovery of needs-gated jobs.
@@ -1626,8 +1956,21 @@ export interface CheckRunTrackingTable {
1626
1956
  */
1627
1957
  in_progress_sent_at: ColumnType<Date | null, Date | null | undefined, Date | null>;
1628
1958
  /**
1629
- * KiCI run identifier this check-run belongs to. Indexed (partial, NOT
1630
- * NULL) to power `cleanupRun(runId)` without scanning the table.
1959
+ * When the terminal (`completed`) check-run update was accepted by the
1960
+ * provider. NULL means we have no record of sending it — either it never
1961
+ * happened, or the best-effort write failed. Never treat NULL as proof the
1962
+ * update failed.
1963
+ *
1964
+ * `check_run_id` is written at create time, while the check run is still
1965
+ * `queued`, so it proves creation and never completion. This column is the
1966
+ * completion signal.
1967
+ */
1968
+ terminal_sent_at: ColumnType<Date | null, Date | null | undefined, Date | null>;
1969
+ /**
1970
+ * KiCI run identifier this check-run belongs to, written at create time.
1971
+ * Indexed (partial, NOT NULL) so a per-run lookup never scans the table.
1972
+ * It is an attribution key, not a retention key — rows are reclaimed by
1973
+ * the `updated_at`-age sweep, which deliberately ignores this column.
1631
1974
  */
1632
1975
  run_id: ColumnType<string | null, string | null | undefined, string | null>;
1633
1976
  /** When this row was first inserted. */
@@ -1676,6 +2019,91 @@ export interface AttestationsTable {
1676
2019
  }
1677
2020
  export type AttestationRow = Selectable<AttestationsTable>;
1678
2021
  export type NewAttestationRow = Insertable<AttestationsTable>;
2022
+ /**
2023
+ * Cluster-scoped ES256 provenance signing keys. The orchestrator signs its own
2024
+ * build attestations with the one `active` key and serves the public halves of
2025
+ * every non-`revoked` key at `/.well-known/jwks.json`.
2026
+ */
2027
+ export interface OrchestratorSigningKeysTable {
2028
+ /** RFC 7638 thumbprint of the public JWK (primary key, also the token `kid`). */
2029
+ kid: string;
2030
+ /** The non-secret public JWK (JSONB) served in the JWKS. */
2031
+ public_jwk: unknown;
2032
+ /**
2033
+ * AES-256-GCM-wrapped private JWK for `db` custody (master-key wrapped). NULL
2034
+ * for `aws-kms` / `command` custody where the private key never lives here.
2035
+ */
2036
+ encrypted_private_jwk: string | null;
2037
+ key_version: Generated<number>;
2038
+ /** JOSE alg (always `ES256`). */
2039
+ alg: string;
2040
+ /** Custody backend discriminator (`db` | `aws-kms` | `command`). */
2041
+ signer_kind: string;
2042
+ /** External key locator (KMS ARN / signer command) for non-`db` custody; NULL for `db`. */
2043
+ key_ref: string | null;
2044
+ /** Lifecycle status (`SigningKeyStatus`: active | retiring | retired | revoked). */
2045
+ status: Generated<string>;
2046
+ revocation_reason: string | null;
2047
+ created_at: Generated<Date>;
2048
+ activated_at: Date | null;
2049
+ retired_at: Date | null;
2050
+ revoked_at: Date | null;
2051
+ }
2052
+ export type OrchestratorSigningKeyRow = Selectable<OrchestratorSigningKeysTable>;
2053
+ export type NewOrchestratorSigningKeyRow = Insertable<OrchestratorSigningKeysTable>;
2054
+ /**
2055
+ * The orchestrator's X25519 dashboard-encryption keys — the trust root for
2056
+ * browser-sealed dashboard writes under the `encrypted` posture. One `active`
2057
+ * key seals; rotated-out keys go `revoked` and leave the published JWKS, while
2058
+ * their rows stay so envelopes already sealed to the old `kid` still decrypt.
2059
+ */
2060
+ export interface DashboardEncryptionKeysTable {
2061
+ /** RFC 7638 thumbprint of the public JWK (primary key, also the `kid`). */
2062
+ kid: string;
2063
+ /** The non-secret OKP/X25519 public JWK (`use:'enc'`) served in the JWKS. */
2064
+ public_jwk: unknown;
2065
+ /** AES-256-GCM-wrapped DER private key (master-key wrapped under KICI_SECRET_KEY). */
2066
+ encrypted_private_key: string;
2067
+ /** Lifecycle status (`active` | `revoked`). */
2068
+ status: Generated<string>;
2069
+ revocation_reason: string | null;
2070
+ created_at: Generated<Date>;
2071
+ activated_at: Date | null;
2072
+ revoked_at: Date | null;
2073
+ }
2074
+ export type DashboardEncryptionKeyRow = Selectable<DashboardEncryptionKeysTable>;
2075
+ export type NewDashboardEncryptionKeyRow = Insertable<DashboardEncryptionKeysTable>;
2076
+ /**
2077
+ * A user-facing build artifact (`ctx.artifacts.upload`). Named + immutable per
2078
+ * run: `UNIQUE (run_id, name)` enforces the first-upload-wins semantics at the
2079
+ * DB layer. `customer_id` scopes the row to an org for quota accounting; the
2080
+ * tarball lives at `storage_key` (`artifacts/{run_id}/{name}-{discriminator}.tar.gz`,
2081
+ * where the discriminator is a hash of the exact name). Reads go through the
2082
+ * stored key rather than re-deriving it, so a row written under an earlier key
2083
+ * format resolves unchanged.
2084
+ */
2085
+ export interface ArtifactsTable {
2086
+ /** Random id (primary key). */
2087
+ id: string;
2088
+ /** Owning customer/org id (quota-accounting scope). */
2089
+ customer_id: string;
2090
+ /** KiCI run this artifact belongs to. */
2091
+ run_id: string;
2092
+ /** KiCI job that produced this artifact. */
2093
+ job_id: string;
2094
+ /** Caller-supplied artifact name (unique within the run). */
2095
+ name: string;
2096
+ /** Packed tarball size in bytes. Postgres BIGINT — pg returns a string on select. */
2097
+ size_bytes: ColumnType<string, number, number>;
2098
+ /** SHA-256 (hex) of the tarball bytes. */
2099
+ sha256: string;
2100
+ /** Object-storage key the tarball was written to. */
2101
+ storage_key: string;
2102
+ /** When this row was inserted. */
2103
+ created_at: Generated<Date>;
2104
+ }
2105
+ export type ArtifactRow = Selectable<ArtifactsTable>;
2106
+ export type NewArtifactRow = Insertable<ArtifactsTable>;
1679
2107
  /**
1680
2108
  * Deferred-attestation outbox: a build whose provenance mint failed transiently
1681
2109
  * freezes its DSSE-signed statement here; a leader-only retrier mints the token
@@ -1794,6 +2222,12 @@ export interface HostRosterTable {
1794
2222
  ssh_port: ColumnType<number | null, number | null | undefined, number | null>;
1795
2223
  /** Scoped-secret ref (`scope/key`) holding the bring-up private key. */
1796
2224
  ssh_key_secret: ColumnType<string | null, string | null | undefined, string | null>;
2225
+ /**
2226
+ * Delivery hint: when true, the box can reach the orchestrator's object
2227
+ * storage, so bring-up picks `s3-direct` (the box pulls the payload via a
2228
+ * presigned URL). NULL / false ⇒ the conservative `ssh-push` fallback.
2229
+ */
2230
+ s3_reachable: ColumnType<boolean | null, boolean | null | undefined, boolean | null>;
1797
2231
  created_at: Generated<Date>;
1798
2232
  updated_at: ColumnType<Date, Date | string | undefined, Date | string>;
1799
2233
  }