@kici-dev/orchestrator 0.1.26 → 0.2.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 (310) 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 +69 -8
  19. package/dist/approvals/apply-decision.d.ts +1 -1
  20. package/dist/approvals/step-approval-bridge.d.ts +1 -1
  21. package/dist/artifacts/artifact-store.d.ts +233 -0
  22. package/dist/artifacts/failure-messages.d.ts +46 -0
  23. package/dist/audit/access-log.d.ts +18 -1
  24. package/dist/cache/dep-cache.d.ts +15 -0
  25. package/dist/cache/pending-inits.d.ts +4 -4
  26. package/dist/cache/user-cache.d.ts +37 -0
  27. package/dist/cancel/cancel-run.d.ts +10 -3
  28. package/dist/cancel/dashboard-cancel-handler.d.ts +19 -0
  29. package/dist/cli/api-client.d.ts +51 -5
  30. package/dist/cli/commands/agent-package.d.ts +34 -0
  31. package/dist/cli/commands/check-run.d.ts +26 -0
  32. package/dist/cli/commands/cluster-settings.d.ts +55 -0
  33. package/dist/cli/commands/context.d.ts +25 -0
  34. package/dist/cli/commands/dashboard-encryption-key.d.ts +3 -0
  35. package/dist/cli/commands/db-backup.d.ts +71 -0
  36. package/dist/cli/commands/debug-bundle.d.ts +1 -1
  37. package/dist/cli/commands/orchestrator-service/drain.d.ts +31 -0
  38. package/dist/cli/commands/orchestrator-service/index.d.ts +7 -4
  39. package/dist/cli/commands/orchestrator-service/install-env.d.ts +58 -0
  40. package/dist/cli/commands/secret.d.ts +45 -1
  41. package/dist/cli/commands/shared/admin-cli-access-log.d.ts +46 -0
  42. package/dist/cli/commands/shared/versioned-upgrade.d.ts +65 -2
  43. package/dist/cli/commands/signing-key.d.ts +3 -0
  44. package/dist/cli/commands/source.d.ts +12 -0
  45. package/dist/cli/commands/token.d.ts +9 -0
  46. package/dist/cli/commands/trust-policy.d.ts +48 -0
  47. package/dist/cli/commands/variable.d.ts +6 -6
  48. package/dist/cli/join.d.ts +1 -1
  49. package/dist/cli/service/index.d.ts +2 -2
  50. package/dist/cli/service/instance/manifest.d.ts +17 -0
  51. package/dist/cli/service/instance/resolve.d.ts +11 -0
  52. package/dist/cli/service/windows.d.ts +6 -0
  53. package/dist/cli/wizard/orchestrator-wizard.d.ts +39 -11
  54. package/dist/cli.js +10263 -3667
  55. package/dist/cluster/cluster-settings-reader.d.ts +78 -0
  56. package/dist/cluster/coordinator.d.ts +81 -9
  57. package/dist/cluster/join-client.d.ts +1 -1
  58. package/dist/cluster/leader-gated-scheduler.d.ts +50 -0
  59. package/dist/cluster/orphan-recovery.d.ts +14 -0
  60. package/dist/cluster/peer-client.d.ts +12 -2
  61. package/dist/cluster/peer-handler.d.ts +15 -4
  62. package/dist/cluster/peer-registry.d.ts +12 -0
  63. package/dist/cluster/verified-issuer-poller.d.ts +11 -0
  64. package/dist/cluster/verified-issuer.d.ts +63 -0
  65. package/dist/cold-store/tables/access-log.d.ts +1 -1
  66. package/dist/cold-store/tables/event-log.d.ts +1 -1
  67. package/dist/cold-store/tables/execution-jobs.d.ts +1 -1
  68. package/dist/cold-store/tables/execution-runs.d.ts +1 -1
  69. package/dist/cold-store/tables/execution-steps.d.ts +1 -1
  70. package/dist/cold-store/tables/secret-audit-log.d.ts +1 -1
  71. package/dist/config/loader.d.ts +1 -1
  72. package/dist/config/resolver.d.ts +2 -1
  73. package/dist/config/schema.d.ts +8 -6
  74. package/dist/config/types.d.ts +3 -2
  75. package/dist/config.d.ts +372 -46
  76. package/dist/contexts/binding-store.d.ts +36 -0
  77. package/dist/contexts/context-store.d.ts +100 -0
  78. package/dist/contexts/glob-specificity.d.ts +30 -0
  79. package/dist/{environments → contexts}/held-runs.d.ts +64 -32
  80. package/dist/{environments → contexts}/index.d.ts +1 -1
  81. package/dist/contexts/protection/aggregate.d.ts +43 -0
  82. package/dist/contexts/protection/branch-gate.d.ts +5 -0
  83. package/dist/contexts/protection/concurrency-gate.d.ts +4 -0
  84. package/dist/{environments → contexts}/protection/pipeline.d.ts +3 -3
  85. package/dist/contexts/protection/reviewer-gate.d.ts +4 -0
  86. package/dist/{environments → contexts}/protection/satisfiability.d.ts +22 -22
  87. package/dist/contexts/protection/trust-gate.d.ts +4 -0
  88. package/dist/contexts/protection/wait-timer-gate.d.ts +4 -0
  89. package/dist/contexts/variable-store.d.ts +39 -0
  90. package/dist/cron/cron-scheduler.d.ts +24 -4
  91. package/dist/cron/cron-store.d.ts +21 -7
  92. package/dist/dashboard/attestation-filters.d.ts +94 -74
  93. package/dist/dashboard/handler.d.ts +63 -3
  94. package/dist/db/migration-test-harness.d.ts +41 -0
  95. package/dist/db/migrations/067_environments_to_contexts.d.ts +36 -0
  96. package/dist/db/migrations/068_request_idempotency.d.ts +17 -0
  97. package/dist/db/migrations/069_reroute_tunables.d.ts +21 -0
  98. package/dist/db/migrations/070_execution_runs_failure_class.d.ts +4 -0
  99. package/dist/db/migrations/071_batch_accumulation.d.ts +26 -0
  100. package/dist/db/migrations/072_dispatch_queue_run_id_index.d.ts +15 -0
  101. package/dist/db/migrations/073_org_settings_ingest_concurrency.d.ts +13 -0
  102. package/dist/db/migrations/074_normalize_zero_concurrency_limit.d.ts +13 -0
  103. package/dist/db/migrations/075_ingest_overflow_buffer.d.ts +16 -0
  104. package/dist/db/migrations/076_artifacts.d.ts +19 -0
  105. package/dist/db/migrations/077_backup_runs.d.ts +13 -0
  106. package/dist/db/migrations/078_org_settings_backup_staleness.d.ts +12 -0
  107. package/dist/db/migrations/079_org_settings_scaler_spawn_timeout.d.ts +14 -0
  108. package/dist/db/migrations/080_cluster_settings.d.ts +17 -0
  109. package/dist/db/migrations/081_org_settings_queue_timeout.d.ts +19 -0
  110. package/dist/db/migrations/082_host_s3_reachable.d.ts +16 -0
  111. package/dist/db/migrations/083_org_settings_artifact_caps.d.ts +18 -0
  112. package/dist/db/migrations/084_orchestrator_signing_keys.d.ts +20 -0
  113. package/dist/db/migrations/085_cluster_settings_reroute_flap_grace_ms.d.ts +12 -0
  114. package/dist/db/migrations/086_cluster_settings_max_fanout_hosts.d.ts +12 -0
  115. package/dist/db/migrations/087_cluster_settings_event_router_rate_limit.d.ts +12 -0
  116. package/dist/db/migrations/088_cluster_settings_cache_max_tarball_bytes.d.ts +12 -0
  117. package/dist/db/migrations/089_cluster_settings_cache_ttl_days.d.ts +12 -0
  118. package/dist/db/migrations/090_cluster_settings_concurrency_wait_timeout_ms.d.ts +12 -0
  119. package/dist/db/migrations/091_cluster_settings_agent_token_ttl_ms.d.ts +12 -0
  120. package/dist/db/migrations/092_cluster_settings_version.d.ts +16 -0
  121. package/dist/db/migrations/093_org_settings_sandbox_allowlist.d.ts +4 -0
  122. package/dist/db/migrations/094_dashboard_encryption_keys.d.ts +21 -0
  123. package/dist/db/migrations/095_dashboard_write_policy_tristate.d.ts +20 -0
  124. package/dist/db/migrations/096_multi_schedule_cron_last_fired.d.ts +4 -0
  125. package/dist/db/migrations/097_execution_runs_pr_number.d.ts +4 -0
  126. package/dist/db/migrations/098_execution_runs_customer_id.d.ts +4 -0
  127. package/dist/db/migrations/099_cluster_settings_dashboard_verified_issuer.d.ts +21 -0
  128. package/dist/db/migrations/100_held_runs_hold_type_vocabulary.d.ts +31 -0
  129. package/dist/db/migrations/101_contexts_hold_expiry_drop_default.d.ts +31 -0
  130. package/dist/db/migrations/102_dispatch_queue_agent_id.d.ts +20 -0
  131. package/dist/db/migrations/103_cluster_settings_ownership_db_check_timeout_ms.d.ts +20 -0
  132. package/dist/db/migrations/104_check_run_terminal_sent.d.ts +22 -0
  133. package/dist/db/migrations/105_org_trust_policy.d.ts +19 -0
  134. package/dist/db/migrations/106_cluster_settings_check_run_tracking_ttl_days.d.ts +18 -0
  135. package/dist/db/migrations/107_check_run_tracking_updated_at_index.d.ts +23 -0
  136. package/dist/db/repos/dashboard-encryption-keys-repo.d.ts +48 -0
  137. package/dist/db/repos/signing-keys-repo.d.ts +34 -0
  138. package/dist/db/types.d.ts +499 -66
  139. package/dist/deployment/deployment-identity.d.ts +87 -2
  140. package/dist/diagnostics/checks/backup.d.ts +18 -0
  141. package/dist/diagnostics/checks/index.d.ts +2 -1
  142. package/dist/diagnostics/fleet-collector.d.ts +1 -1
  143. package/dist/drain/drain-controller.d.ts +52 -0
  144. package/dist/events/batch-accumulator.d.ts +63 -0
  145. package/dist/events/circuit-breaker.d.ts +9 -3
  146. package/dist/events/event-emitter.d.ts +31 -0
  147. package/dist/events/event-retry-scanner.d.ts +12 -2
  148. package/dist/events/event-router.d.ts +29 -0
  149. package/dist/firecracker/host-network.d.ts +2 -0
  150. package/dist/firecracker/net-interfaces.d.ts +14 -0
  151. package/dist/github-app-name-refresher/github-app-name-refresher.d.ts +19 -9
  152. package/dist/index.d.ts +2 -0
  153. package/dist/index.js +625 -22
  154. package/dist/lockfile-cache.d.ts +4 -0
  155. package/dist/lockfile-validate.d.ts +16 -9
  156. package/dist/metrics/prometheus.d.ts +114 -15
  157. package/dist/oidc/aws-kms-signer.d.ts +37 -0
  158. package/dist/oidc/command-signer.d.ts +23 -0
  159. package/dist/oidc/db-signer.d.ts +48 -0
  160. package/dist/oidc/id-token-claims.d.ts +76 -0
  161. package/dist/oidc/jwt.d.ts +18 -0
  162. package/dist/oidc/local-dev-signer.d.ts +31 -0
  163. package/dist/oidc/local-mint.d.ts +77 -0
  164. package/dist/oidc/oidc-mint-registration.d.ts +65 -0
  165. package/dist/oidc/orchestrator-mint.d.ts +97 -0
  166. package/dist/oidc/orchestrator-signer-factory.d.ts +33 -0
  167. package/dist/oidc/reconcile-signing-key.d.ts +21 -0
  168. package/dist/oidc/signer.d.ts +25 -0
  169. package/dist/oidc/signing-key-status.d.ts +23 -0
  170. package/dist/orchestrator-core.d.ts +42 -2
  171. package/dist/pipeline/decorating-secret-resolver.d.ts +5 -4
  172. package/dist/pipeline/dispatch-matched-workflow.d.ts +44 -3
  173. package/dist/pipeline/inline-eval.d.ts +2 -2
  174. package/dist/pipeline/install-secrets-resolver.d.ts +25 -14
  175. package/dist/pipeline/{job-environments.d.ts → job-contexts.d.ts} +23 -23
  176. package/dist/pipeline/manual-schedule.d.ts +28 -14
  177. package/dist/pipeline/pending-workflow-context.d.ts +1 -1
  178. package/dist/pipeline/process-webhook.d.ts +57 -2
  179. package/dist/pipeline/processor.d.ts +49 -13
  180. package/dist/pipeline/request-idempotency.d.ts +28 -0
  181. package/dist/pipeline/rerun.d.ts +20 -13
  182. package/dist/pipeline/resolve-sandbox-grant.d.ts +28 -0
  183. package/dist/pipeline/resume-workflow.d.ts +1 -1
  184. package/dist/pipeline/route-or-dispatch-jobs.d.ts +71 -0
  185. package/dist/pipeline/sandbox-allowlist-reader.d.ts +33 -0
  186. package/dist/pipeline/test-pipeline.d.ts +2 -2
  187. package/dist/policy/dashboard-write-policy.d.ts +9 -4
  188. package/dist/provenance/backfill-run.d.ts +1 -0
  189. package/dist/provenance/trust-root.d.ts +20 -0
  190. package/dist/provider-registry.d.ts +8 -0
  191. package/dist/providers/generic/normalizer.d.ts +1 -1
  192. package/dist/providers/github/auth.d.ts +1 -1
  193. package/dist/providers/github/changed-files.d.ts +14 -6
  194. package/dist/providers/github/check-status-poster.d.ts +19 -3
  195. package/dist/providers/github/contributor-resolver.d.ts +1 -1
  196. package/dist/providers/github/lock-file.d.ts +1 -1
  197. package/dist/providers/github/normalizer.d.ts +1 -1
  198. package/dist/providers/github/repo-url.d.ts +1 -1
  199. package/dist/providers/local/index.d.ts +1 -0
  200. package/dist/providers/local/local-source-config.d.ts +1 -0
  201. package/dist/providers/local/lock-file-fetcher.d.ts +1 -1
  202. package/dist/providers/local/normalizer.d.ts +1 -1
  203. package/dist/providers/local/repo-url-builder.d.ts +1 -1
  204. package/dist/providers/universal-git/changed-files.d.ts +8 -7
  205. package/dist/providers/universal-git/clone-token.d.ts +1 -1
  206. package/dist/providers/universal-git/config.d.ts +4 -4
  207. package/dist/providers/universal-git/index.d.ts +5 -1
  208. package/dist/providers/universal-git/lock-file.d.ts +6 -1
  209. package/dist/providers/universal-git/normalizer.d.ts +1 -1
  210. package/dist/providers/universal-git/repo-url.d.ts +1 -1
  211. package/dist/queue/cleanup.d.ts +69 -8
  212. package/dist/queue/job-queue.d.ts +94 -14
  213. package/dist/queue/scheduled-job.d.ts +2 -2
  214. package/dist/registration/registration-index.d.ts +1 -1
  215. package/dist/reporting/agent-failure-category.d.ts +4 -1
  216. package/dist/reporting/check-run-reporter.d.ts +34 -14
  217. package/dist/reporting/check-run-tracking-store.d.ts +70 -8
  218. package/dist/reporting/execution-tracker.d.ts +173 -17
  219. package/dist/reporting/fs-log-storage.d.ts +31 -2
  220. package/dist/reporting/job-check-run-completion.d.ts +50 -0
  221. package/dist/reporting/log-chunk-sink.d.ts +47 -0
  222. package/dist/reporting/log-retention.d.ts +16 -0
  223. package/dist/reporting/log-storage.d.ts +64 -4
  224. package/dist/reporting/log-writer.d.ts +22 -7
  225. package/dist/reporting/peer-log-normalize.d.ts +14 -0
  226. package/dist/reporting/run-aggregator.d.ts +36 -36
  227. package/dist/reporting/s3-log-storage.d.ts +102 -8
  228. package/dist/routes/admin-auth.d.ts +90 -0
  229. package/dist/routes/admin-cluster-settings.d.ts +31 -0
  230. package/dist/routes/admin-contexts.d.ts +47 -0
  231. package/dist/routes/admin-events.d.ts +3 -0
  232. package/dist/routes/admin-orchestrator-drain.d.ts +35 -0
  233. package/dist/routes/admin-registrations.d.ts +2 -2
  234. package/dist/routes/admin-runs.d.ts +9 -0
  235. package/dist/routes/admin-sources.d.ts +7 -0
  236. package/dist/routes/admin-trust-policy.d.ts +49 -0
  237. package/dist/routes/admin.d.ts +15 -1
  238. package/dist/routes/github-webhook.d.ts +9 -3
  239. package/dist/routes/provenance-oidc.d.ts +38 -0
  240. package/dist/routes/verify-attestation.d.ts +21 -0
  241. package/dist/scaler/bare-metal-backend.d.ts +9 -2
  242. package/dist/scaler/config.d.ts +25 -4
  243. package/dist/scaler/container-backend.d.ts +9 -1
  244. package/dist/scaler/firecracker-backend.d.ts +29 -2
  245. package/dist/scaler/index.d.ts +1 -1
  246. package/dist/scaler/manager.d.ts +166 -8
  247. package/dist/scaler/pending-scale-sweeper.d.ts +35 -0
  248. package/dist/scaler/types.d.ts +75 -6
  249. package/dist/secrets/backend-registry.d.ts +32 -1
  250. package/dist/secrets/context-secret-resolver.d.ts +30 -0
  251. package/dist/secrets/dashboard-encryption-key.d.ts +48 -0
  252. package/dist/secrets/ephemeral-keys.d.ts +16 -0
  253. package/dist/secrets/index.d.ts +1 -1
  254. package/dist/secrets/pg-secret-store.d.ts +13 -3
  255. package/dist/secrets/rbac.d.ts +5 -1
  256. package/dist/secrets/routing-key-scope.d.ts +6 -0
  257. package/dist/secrets/scope-routing.d.ts +126 -0
  258. package/dist/secrets/secret-resolver.d.ts +19 -32
  259. package/dist/secrets/token-manager.d.ts +5 -1
  260. package/dist/security/comment-handler.d.ts +1 -1
  261. package/dist/security/contributor-cache.d.ts +9 -1
  262. package/dist/security/trust-policy-gate.d.ts +117 -0
  263. package/dist/security/trust-policy-store.d.ts +78 -0
  264. package/dist/server.js +44012 -32721
  265. package/dist/sources/source-manager.d.ts +24 -0
  266. package/dist/stale-detector/stale-run-detector.d.ts +8 -1
  267. package/dist/standalone.js +44106 -33690
  268. package/dist/storage/blob-routes.d.ts +16 -0
  269. package/dist/storage/filesystem.d.ts +17 -0
  270. package/dist/storage/key-discriminator.d.ts +20 -0
  271. package/dist/storage/s3.d.ts +2 -0
  272. package/dist/storage/types.d.ts +16 -0
  273. package/dist/webhook/dedup.d.ts +9 -1
  274. package/dist/webhook/event-log.d.ts +13 -2
  275. package/dist/webhook/generic-sources-listener.d.ts +4 -0
  276. package/dist/webhook/ingest-admission.d.ts +140 -0
  277. package/dist/webhook/ingest-overflow-buffer.d.ts +27 -0
  278. package/dist/webhook/ingest-overflow-replayer.d.ts +49 -0
  279. package/dist/webhook/ingest-overflow-types.d.ts +73 -0
  280. package/dist/webhook/loop-lag-source.d.ts +40 -0
  281. package/dist/webhook/observed-relay-guard.d.ts +40 -0
  282. package/dist/webhook/org-ingest-cap-reader.d.ts +24 -0
  283. package/dist/webhook/register-source-bundle.d.ts +3 -0
  284. package/dist/webhook/relay-reinject.d.ts +43 -0
  285. package/dist/worker/in-memory-job-queue.d.ts +8 -3
  286. package/dist/worker-core.d.ts +10 -0
  287. package/dist/ws/agent-api-registry.d.ts +20 -0
  288. package/dist/ws/agent-handler.d.ts +63 -7
  289. package/dist/ws/bringup-api.d.ts +99 -0
  290. package/dist/ws/{dashboard-env-handler.d.ts → dashboard-context-handler.d.ts} +43 -25
  291. package/dist/ws/dashboard-run-state-handler.d.ts +31 -0
  292. package/dist/ws/failure-messages.d.ts +29 -0
  293. package/dist/ws/oidc-token-relay.d.ts +15 -0
  294. package/dist/ws/ownership-gate.d.ts +22 -0
  295. package/dist/ws/platform-client.d.ts +96 -1
  296. package/dist/ws/replay-chunker.d.ts +37 -0
  297. package/installer-image-digests.json +3 -3
  298. package/package.json +22 -21
  299. package/sbom.spdx.json +1245 -1793
  300. package/dist/cli/commands/environment.d.ts +0 -25
  301. package/dist/environments/binding-store.d.ts +0 -36
  302. package/dist/environments/environment-store.d.ts +0 -87
  303. package/dist/environments/protection/aggregate.d.ts +0 -43
  304. package/dist/environments/protection/branch-gate.d.ts +0 -5
  305. package/dist/environments/protection/concurrency-gate.d.ts +0 -7
  306. package/dist/environments/protection/reviewer-gate.d.ts +0 -7
  307. package/dist/environments/protection/trust-gate.d.ts +0 -7
  308. package/dist/environments/protection/wait-timer-gate.d.ts +0 -7
  309. package/dist/environments/variable-store.d.ts +0 -39
  310. package/dist/routes/admin-environments.d.ts +0 -47
@@ -7,17 +7,18 @@ 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;
13
14
  execution_steps: ExecutionStepTable;
14
15
  raft_state: RaftStateTable;
15
16
  secret_audit_log: SecretAuditLogTable;
16
- environments: EnvironmentsTable;
17
+ contexts: ContextsTable;
17
18
  scoped_secrets: ScopedSecretsTable;
18
- environment_bindings: EnvironmentBindingsTable;
19
- environment_variables: EnvironmentVariablesTable;
20
- environment_source_overrides: EnvironmentSourceOverridesTable;
19
+ context_bindings: ContextBindingsTable;
20
+ context_variables: ContextVariablesTable;
21
+ context_source_overrides: ContextSourceOverridesTable;
21
22
  held_runs: HeldRunsTable;
22
23
  held_run_approvals: HeldRunApprovalsTable;
23
24
  admin_tokens: AdminTokenTable;
@@ -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,10 +52,107 @@ 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;
61
+ request_idempotency: RequestIdempotencyTable;
62
+ batch_accumulation_windows: BatchAccumulationWindowsTable;
63
+ batch_accumulation_items: BatchAccumulationItemsTable;
64
+ backup_runs: BackupRunsTable;
55
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>;
116
+ /**
117
+ * Request idempotency claim table.
118
+ * Keyed on the Platform `requestId`; makes run-minting dashboard requests
119
+ * (`run.rerun.request`, `run.manual_schedule.request`) idempotent across an HA
120
+ * relay failover so a re-sent request returns the first coordinator's
121
+ * `new_run_id` instead of creating a second run. Pruned after 1h.
122
+ */
123
+ export interface RequestIdempotencyTable {
124
+ /** Platform-minted requestId for the run-minting request (primary key / idempotency key). */
125
+ request_id: string;
126
+ /** The run id the winning coordinator created for this requestId. */
127
+ new_run_id: string;
128
+ /** When the claim was recorded. */
129
+ created_at: Generated<Date>;
130
+ }
131
+ export type RequestIdempotency = Selectable<RequestIdempotencyTable>;
132
+ export type NewRequestIdempotency = Insertable<RequestIdempotencyTable>;
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>;
56
156
  /**
57
157
  * Cluster metadata table
58
158
  * Key-value store for cluster-wide configuration (e.g. cluster_id).
@@ -191,6 +291,15 @@ export interface DispatchQueueTable {
191
291
  * to another. NULL for normal label-routed jobs.
192
292
  */
193
293
  pinned_agent_id: ColumnType<string | null, string | null | undefined, string | null>;
294
+ /**
295
+ * Durable owner of a dispatched job: the agent the job was handed to. Written
296
+ * at dispatch, cleared on requeue. Distinct from `ack_agent_id`, which is
297
+ * cleared as soon as the agent answers the dispatch and so cannot resolve
298
+ * ownership later — this column lets a coordinator that never saw the
299
+ * dispatch answer "does this agent own this job?" from the database alone.
300
+ * NULL for pending rows and for rows dispatched before the column existed.
301
+ */
302
+ agent_id: ColumnType<string | null, string | null | undefined, string | null>;
194
303
  }
195
304
  /**
196
305
  * Deduplication cache table
@@ -204,6 +313,39 @@ export interface DedupCacheTable {
204
313
  /** When this cache entry expires (24h TTL) */
205
314
  expires_at: Date;
206
315
  }
316
+ /**
317
+ * Durable overflow buffer for shed webhook-ingest deliveries (migration 075).
318
+ * `status` values come from OverflowStatus, `source_kind` from OverflowSourceKind
319
+ * (packages/orchestrator/src/webhook/ingest-overflow-types.ts). `body` is base64.
320
+ */
321
+ export interface IngestOverflowBufferTable {
322
+ /** Surrogate PK (bigint identity). */
323
+ id: Generated<number>;
324
+ /** Delivery id — the dedup key. */
325
+ delivery_id: string;
326
+ /** Routing key (e.g. "github:42"). */
327
+ routing_key: string;
328
+ /** Ingest boundary: 'direct' (HTTP, verified) | 'relay' (WS, unverified). */
329
+ source_kind: string;
330
+ /** Provider type; null for relay (resolved at replay). */
331
+ provider: string | null;
332
+ /** Provider event type. */
333
+ event: string;
334
+ /** Payload action, or null. */
335
+ action: string | null;
336
+ /** Base64 of the raw delivery bytes. */
337
+ body: string;
338
+ /** Verify-input envelope (relay) or {} (direct). */
339
+ meta: Generated<Record<string, unknown>>;
340
+ /** Capture timestamp (defaults to now()). */
341
+ captured_at: Generated<Date>;
342
+ /** Replay attempt counter. */
343
+ replay_attempts: Generated<number>;
344
+ /** OverflowStatus value. */
345
+ status: Generated<string>;
346
+ /** Last replay error, or null. */
347
+ last_error: string | null;
348
+ }
207
349
  export type DispatchQueueItem = Selectable<DispatchQueueTable>;
208
350
  export type NewDispatchQueueItem = Insertable<DispatchQueueTable>;
209
351
  export type DispatchQueueItemUpdate = Updateable<DispatchQueueTable>;
@@ -237,6 +379,12 @@ export interface ExecutionRunTable {
237
379
  run_id: string;
238
380
  /** Routing key (e.g. github:appId) for Platform StaleOrchDetector when sharing DB */
239
381
  routing_key: string | null;
382
+ /**
383
+ * Owning org (customer_id), denormalized from routing_key at insert time so
384
+ * the concurrency-gate running count can be scoped per tenant. Defaults to
385
+ * '__default__' (the no-source fallback org) via the column DEFAULT.
386
+ */
387
+ customer_id: Generated<string>;
240
388
  /** Workflow name from lock file */
241
389
  workflow_name: string;
242
390
  /** Run status: running | success | failed | cancelled */
@@ -288,16 +436,18 @@ export interface ExecutionRunTable {
288
436
  cancelled_by: string | null;
289
437
  /** Agent provenance label when the run was cancelled through an agent credential (null otherwise). */
290
438
  cancelled_by_agent_label: string | null;
291
- /** Environment name for this run (null if no environment applies) */
292
- environment: string | null;
293
- /** Matched environment id for this run (null if no/unresolved environment). */
294
- environment_id: string | null;
439
+ /** Context name for this run (null if no context applies) */
440
+ context: string | null;
441
+ /** Matched context id for this run (null if no/unresolved context). */
442
+ context_id: string | null;
295
443
  /** Trust tier of the contributor for PR runs (null for non-PR events) */
296
444
  trust_tier: string | null;
297
445
  /** Lock file source: 'head' or 'base' (null for non-PR events) */
298
446
  lock_file_source: string | null;
299
447
  /** Username of the contributor (null for non-PR events) */
300
448
  contributor_username: string | null;
449
+ /** Pull-request number for PR-triggered runs (null for non-PR events). Scopes `/kici approve|reject` hold selection to the comment's PR. */
450
+ pr_number: number | null;
301
451
  /**
302
452
  * Origin provider of the triggering actor (`github` today). Provider-generic
303
453
  * so GitLab/Bitbucket extend later. Null when no actor was captured.
@@ -316,6 +466,12 @@ export interface ExecutionRunTable {
316
466
  trigger_actor_user_id: string | null;
317
467
  /** Human-readable reason why the run failed (null for non-failed runs). */
318
468
  failure_reason: string | null;
469
+ /**
470
+ * Why the run failed (`RunFailureClass` from `@kici-dev/engine`): never_started
471
+ * / timed_out / dead_orchestrator / step_failure / cancelled. Derived at run
472
+ * completion from the terminal job statuses. NULL for success / not-yet-terminal.
473
+ */
474
+ failure_class: string | null;
319
475
  /**
320
476
  * Structured init-phase failure detail (shape: `InitFailure` from
321
477
  * `@kici-dev/engine`). Non-null means the run never executed a step
@@ -397,17 +553,17 @@ export interface ExecutionJobTable {
397
553
  /** Aggregated step outputs JSONB (step-keyed map of outputs). Populated on job success. */
398
554
  outputs: string | null;
399
555
  /**
400
- * Ordered bound deployment-environment names for this job, JSON-encoded
556
+ * Ordered bound deployment-context names for this job, JSON-encoded
401
557
  * `string[]` (null when the job binds none). Written at dispatch and
402
- * overwritten with the agent-resolved list for dynamic environments.
558
+ * overwritten with the agent-resolved list for dynamic contexts.
403
559
  */
404
- environments: string | null;
560
+ contexts: string | null;
405
561
  /**
406
- * Bound environments skipped on a test/local run (non-test or unconfigured),
562
+ * Bound contexts skipped on a test/local run (non-test or unconfigured),
407
563
  * JSON-encoded `string[]`. NULL = nothing skipped.
408
564
  */
409
- skipped_environments: string | null;
410
- /** User-visible warning naming the skipped test-run environments. NULL = none. */
565
+ skipped_contexts: string | null;
566
+ /** User-visible warning naming the skipped test-run contexts. NULL = none. */
411
567
  env_warning: string | null;
412
568
  /** Whether all upstream needs edges are satisfied (dispatch gate). */
413
569
  needs_satisfied: Generated<boolean>;
@@ -561,20 +717,20 @@ export interface RaftStateTable {
561
717
  export type RaftState = Selectable<RaftStateTable>;
562
718
  export type RaftStateUpdate = Updateable<RaftStateTable>;
563
719
  /**
564
- * Environments table
565
- * Named deployment environments with concurrency, branch restrictions, and approval rules.
720
+ * Contexts table
721
+ * Named deployment contexts with concurrency, branch restrictions, and approval rules.
566
722
  * Scoped to an organization.
567
723
  */
568
- export interface EnvironmentsTable {
724
+ export interface ContextsTable {
569
725
  /** UUID primary key */
570
726
  id: Generated<string>;
571
727
  /** Organization ID */
572
728
  org_id: string;
573
- /** Environment name (unique within org) */
729
+ /** Context name (unique within org) */
574
730
  name: string;
575
- /** Environment type: 'fixed' | 'dynamic' */
731
+ /** Context type: 'fixed' | 'dynamic' */
576
732
  type: Generated<string>;
577
- /** Glob pattern for dynamic environments (null for fixed) */
733
+ /** Glob pattern for dynamic contexts (null for fixed) */
578
734
  glob_pattern: string | null;
579
735
  /** JSONB array of branch restriction patterns */
580
736
  branch_restrictions: Generated<string>;
@@ -584,42 +740,46 @@ export interface EnvironmentsTable {
584
740
  repo_patterns: Generated<string>;
585
741
  /** Max concurrent runs (null = unlimited) */
586
742
  concurrency_limit: number | null;
587
- /** Strategy when concurrency exceeded: 'queue' | 'cancel-pending' */
588
- concurrency_strategy: Generated<string>;
743
+ /**
744
+ * Strategy when concurrency exceeded; see `ConcurrencyStrategy` in
745
+ * `@kici-dev/engine` for the vocabulary. Stays a plain `string` so a row
746
+ * written by another orchestrator version always maps (null = unset).
747
+ */
748
+ concurrency_strategy: Generated<string | null>;
589
749
  /** Timeout for queued runs in milliseconds */
590
750
  concurrency_timeout_ms: Generated<number>;
591
751
  /** JSONB array of required reviewer identities (null = no approval required) */
592
752
  required_reviewers: string | null;
593
753
  /** Seconds to wait before deploying (null = no wait timer) */
594
754
  wait_timer_seconds: number | null;
595
- /** Seconds before a held run expires */
596
- hold_expiry_seconds: Generated<number>;
755
+ /** Seconds before a held run expires (null = unset, the default window applies) */
756
+ hold_expiry_seconds: Generated<number | null>;
597
757
  /** Minimum trust tier required for CI execution (null = no trust requirement) */
598
758
  minimum_trust: string | null;
599
- /** Whether this environment allows local (no-remote) executions. Default false. */
759
+ /** Whether this context allows local (no-remote) executions. Default false. */
600
760
  allow_local_execution: Generated<boolean>;
601
- /** Whether this environment is active */
761
+ /** Whether this context is active */
602
762
  enabled: Generated<boolean>;
603
- /** When this environment was created */
763
+ /** When this context was created */
604
764
  created_at: Generated<Date>;
605
- /** When this environment was last updated */
765
+ /** When this context was last updated */
606
766
  updated_at: Generated<Date>;
607
- /** Who created this environment */
767
+ /** Who created this context */
608
768
  created_by: string | null;
609
769
  }
610
- export type Environment = Selectable<EnvironmentsTable>;
611
- export type NewEnvironment = Insertable<EnvironmentsTable>;
612
- export type EnvironmentUpdate = Updateable<EnvironmentsTable>;
770
+ export type Context = Selectable<ContextsTable>;
771
+ export type NewContext = Insertable<ContextsTable>;
772
+ export type ContextUpdate = Updateable<ContextsTable>;
613
773
  /**
614
774
  * Scoped secrets table
615
- * Encrypted key-value pairs scoped to org + scope (e.g. environment name, repo pattern).
775
+ * Encrypted key-value pairs scoped to org + scope (e.g. context name, repo pattern).
616
776
  */
617
777
  export interface ScopedSecretsTable {
618
778
  /** UUID primary key */
619
779
  id: Generated<string>;
620
780
  /** Organization ID */
621
781
  org_id: string;
622
- /** Scope identifier (e.g. environment name, repo pattern) */
782
+ /** Scope identifier (e.g. context name, repo pattern) */
623
783
  scope: string;
624
784
  /** Secret key name */
625
785
  key: string;
@@ -638,16 +798,16 @@ export type ScopedSecret = Selectable<ScopedSecretsTable>;
638
798
  export type NewScopedSecret = Insertable<ScopedSecretsTable>;
639
799
  export type ScopedSecretUpdate = Updateable<ScopedSecretsTable>;
640
800
  /**
641
- * Environment bindings table
642
- * Links environments to scope patterns (e.g. workflow names, repo identifiers).
801
+ * Context bindings table
802
+ * Links contexts to scope patterns (e.g. workflow names, repo identifiers).
643
803
  */
644
- export interface EnvironmentBindingsTable {
804
+ export interface ContextBindingsTable {
645
805
  /** UUID primary key */
646
806
  id: Generated<string>;
647
807
  /** Organization ID */
648
808
  org_id: string;
649
- /** Environment ID (FK to environments.id, cascade delete) */
650
- environment_id: string;
809
+ /** Context ID (FK to contexts.id, cascade delete) */
810
+ context_id: string;
651
811
  /** Scope pattern for matching (e.g. workflow name glob, repo pattern) */
652
812
  scope_pattern: string;
653
813
  /**
@@ -659,19 +819,19 @@ export interface EnvironmentBindingsTable {
659
819
  /** When this binding was created */
660
820
  created_at: Generated<Date>;
661
821
  }
662
- export type EnvironmentBinding = Selectable<EnvironmentBindingsTable>;
663
- export type NewEnvironmentBinding = Insertable<EnvironmentBindingsTable>;
822
+ export type ContextBinding = Selectable<ContextBindingsTable>;
823
+ export type NewContextBinding = Insertable<ContextBindingsTable>;
664
824
  /**
665
- * Environment variables table
666
- * Non-secret key-value pairs attached to an environment.
825
+ * Context variables table
826
+ * Non-secret key-value pairs attached to a context.
667
827
  */
668
- export interface EnvironmentVariablesTable {
828
+ export interface ContextVariablesTable {
669
829
  /** UUID primary key */
670
830
  id: Generated<string>;
671
831
  /** Organization ID */
672
832
  org_id: string;
673
- /** Environment ID (FK to environments.id, cascade delete) */
674
- environment_id: string;
833
+ /** Context ID (FK to contexts.id, cascade delete) */
834
+ context_id: string;
675
835
  /** Variable key name */
676
836
  key: string;
677
837
  /** Variable value */
@@ -683,20 +843,20 @@ export interface EnvironmentVariablesTable {
683
843
  /** When this variable was last updated */
684
844
  updated_at: Generated<Date>;
685
845
  }
686
- export type EnvironmentVariable = Selectable<EnvironmentVariablesTable>;
687
- export type NewEnvironmentVariable = Insertable<EnvironmentVariablesTable>;
688
- export type EnvironmentVariableUpdate = Updateable<EnvironmentVariablesTable>;
846
+ export type ContextVariable = Selectable<ContextVariablesTable>;
847
+ export type NewContextVariable = Insertable<ContextVariablesTable>;
848
+ export type ContextVariableUpdate = Updateable<ContextVariablesTable>;
689
849
  /**
690
- * Environment source overrides table
691
- * Per-source (routing key) variable overrides within an environment.
850
+ * Context source overrides table
851
+ * Per-source (routing key) variable overrides within a context.
692
852
  */
693
- export interface EnvironmentSourceOverridesTable {
853
+ export interface ContextSourceOverridesTable {
694
854
  /** UUID primary key */
695
855
  id: Generated<string>;
696
856
  /** Organization ID */
697
857
  org_id: string;
698
- /** Environment ID (FK to environments.id, cascade delete) */
699
- environment_id: string;
858
+ /** Context ID (FK to contexts.id, cascade delete) */
859
+ context_id: string;
700
860
  /** Routing key for the source */
701
861
  routing_key: string;
702
862
  /** Override key name */
@@ -708,9 +868,9 @@ export interface EnvironmentSourceOverridesTable {
708
868
  /** When this override was last updated */
709
869
  updated_at: Generated<Date>;
710
870
  }
711
- export type EnvironmentSourceOverride = Selectable<EnvironmentSourceOverridesTable>;
712
- export type NewEnvironmentSourceOverride = Insertable<EnvironmentSourceOverridesTable>;
713
- export type EnvironmentSourceOverrideUpdate = Updateable<EnvironmentSourceOverridesTable>;
871
+ export type ContextSourceOverride = Selectable<ContextSourceOverridesTable>;
872
+ export type NewContextSourceOverride = Insertable<ContextSourceOverridesTable>;
873
+ export type ContextSourceOverrideUpdate = Updateable<ContextSourceOverridesTable>;
714
874
  /**
715
875
  * Held runs table
716
876
  * Tracks runs waiting for approval, wait timer, or concurrency slot.
@@ -724,13 +884,18 @@ export interface HeldRunsTable {
724
884
  run_id: string;
725
885
  /** Job ID within the run */
726
886
  job_id: string;
727
- /** Environment ID (FK to environments.id); null once the environment is deleted */
728
- environment_id: string | null;
729
- /** Hold type: 'approval' | 'wait_timer' | 'concurrency' */
887
+ /** Context ID (FK to contexts.id); null once the context is deleted */
888
+ context_id: string | null;
889
+ /**
890
+ * Hold type — an engine `HoldType` member ('reviewer' | 'timer' |
891
+ * 'concurrency' | 'security'). Stays `string` so a row written by a
892
+ * different orchestrator version is never rejected; read it through
893
+ * `normalizePersistedHoldType`.
894
+ */
730
895
  hold_type: string;
731
896
  /** Hold status: 'pending' | 'approved' | 'rejected' | 'expired' | 'released' */
732
897
  status: Generated<string>;
733
- /** Queue type: 'environment' | 'security' */
898
+ /** Queue type: 'context' | 'security' */
734
899
  queue_type: Generated<string>;
735
900
  /** Reason for hold or resolution */
736
901
  reason: string | null;
@@ -744,13 +909,13 @@ export interface HeldRunsTable {
744
909
  resolved_at: Date | null;
745
910
  /**
746
911
  * Hold granularity: 'workflow' | 'job' | 'step' (engine `HoldScope`).
747
- * Existing environment holds are job-scoped, hence the 'job' default.
912
+ * Existing context holds are job-scoped, hence the 'job' default.
748
913
  */
749
914
  hold_scope: Generated<string>;
750
915
  /** Step index within the job for step-scoped holds; null otherwise. */
751
916
  step_index: number | null;
752
917
  /**
753
- * What created the hold: 'environment' (mandatory env policy) | 'explicit'
918
+ * What created the hold: 'context' (mandatory env policy) | 'explicit'
754
919
  * (SDK `approval`). Engine `TriggerSource`.
755
920
  */
756
921
  trigger_source: Generated<string>;
@@ -1209,6 +1374,8 @@ export type RegistryVersionUpdate = Updateable<RegistryVersionsTable>;
1209
1374
  export interface CronLastFiredTable {
1210
1375
  /** References workflow_registrations.id (cascade delete) */
1211
1376
  registration_id: string;
1377
+ /** Per-schedule identity: `${cronExpression}\n${timezone}` (see scheduleTriggerKey) */
1378
+ schedule_key: string;
1212
1379
  /** When this cron trigger last fired */
1213
1380
  last_fired_at: Date;
1214
1381
  /** When this record was last updated */
@@ -1303,7 +1470,7 @@ export interface SourcesTable {
1303
1470
  * is the source of truth for both `name` and `slug` on GitHub-App sources.
1304
1471
  */
1305
1472
  slug: string | null;
1306
- /** Customer/org identifier for secret and environment scoping */
1473
+ /** Customer/org identifier for secret and context scoping */
1307
1474
  customer_id: Generated<string>;
1308
1475
  /** When this source was created */
1309
1476
  created_at: Generated<Date>;
@@ -1371,12 +1538,80 @@ export interface OrgSettingsTable {
1371
1538
  * pg returns a string on select; accept a number on insert/update.
1372
1539
  */
1373
1540
  user_cache_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1541
+ /**
1542
+ * Per-org byte quota for user-facing artifacts (ArtifactStore). NULL = use the
1543
+ * cluster-wide default (`KICI_ARTIFACT_QUOTA_BYTES`, 20 GiB). Postgres BIGINT —
1544
+ * pg returns a string on select; accept a number on insert/update.
1545
+ */
1546
+ artifact_quota_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1547
+ /**
1548
+ * Per-artifact TTL (ms) for user-facing artifacts (ArtifactStore). NULL = use
1549
+ * the cluster-wide default (`KICI_ARTIFACT_TTL_MS`, 30 days). Postgres BIGINT —
1550
+ * pg returns a string on select; accept a number on insert/update.
1551
+ */
1552
+ artifact_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1553
+ /**
1554
+ * Per-org per-artifact size cap (bytes) for user-facing artifacts
1555
+ * (ArtifactStore). NULL = use the cluster-wide default
1556
+ * (`KICI_ARTIFACT_MAX_BYTES`, 1 GiB). Postgres BIGINT — pg returns a string on
1557
+ * select; accept a number on insert/update.
1558
+ */
1559
+ artifact_max_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1560
+ /**
1561
+ * Per-org per-run artifact count cap for user-facing artifacts
1562
+ * (ArtifactStore). NULL = use the cluster-wide default
1563
+ * (`KICI_ARTIFACT_MAX_PER_RUN`, 50). Postgres BIGINT — pg returns a string on
1564
+ * select; accept a number on insert/update.
1565
+ */
1566
+ artifact_max_per_run: ColumnType<string | null, number | null | undefined, number | null>;
1374
1567
  /**
1375
1568
  * Per-org dispatch-acknowledgment deadline (ms); null = cluster default
1376
1569
  * (config.dispatchAckTimeoutMs / KICI_DISPATCH_ACK_TIMEOUT_MS). Postgres
1377
1570
  * BIGINT — pg returns a string on select; accept a number on insert/update.
1378
1571
  */
1379
1572
  dispatch_ack_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1573
+ /**
1574
+ * Per-org webhook-ingest concurrency cap; null = cluster default
1575
+ * (config.ingestOrgMaxConcurrency / KICI_INGEST_ORG_MAX_CONCURRENCY). Postgres
1576
+ * BIGINT — pg returns a string on select; accept a number on insert/update.
1577
+ */
1578
+ ingest_max_concurrency: ColumnType<string | null, number | null | undefined, number | null>;
1579
+ /**
1580
+ * Per-org scaler spawn deadline (ms) for a single `backend.spawn` (image pull
1581
+ * + container create + start); null = cluster default
1582
+ * (config.scalerSpawnTimeoutMs / KICI_SCALER_SPAWN_TIMEOUT_MS). Postgres
1583
+ * BIGINT — pg returns a string on select; accept a number on insert/update.
1584
+ */
1585
+ scaler_spawn_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1586
+ /**
1587
+ * Per-org reroute spawn window (ms): how long the coordinator waits after a
1588
+ * peer ACKs a reroute before treating "accepted but no progress" as a spawn
1589
+ * failure and re-dispatching. Null = cluster default (config.rerouteSpawnWindowMs).
1590
+ * BIGINT — pg returns a string on select; accept a number on insert/update.
1591
+ */
1592
+ reroute_spawn_window_ms: ColumnType<string | null, number | null | undefined, number | null>;
1593
+ /**
1594
+ * Per-org reroute ACK timeout (ms) for the reroute sendAndWaitAck deadline.
1595
+ * Null = cluster default (config.rerouteAckTimeoutMs). BIGINT.
1596
+ */
1597
+ reroute_ack_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1598
+ /**
1599
+ * Per-org maximum peer hops for a rerouted job. Null = cluster default
1600
+ * (config.rerouteMaxHops). Plain INTEGER — pg returns a number on select.
1601
+ */
1602
+ reroute_max_hops: ColumnType<number | null, number | null | undefined, number | null>;
1603
+ /**
1604
+ * Per-org staleness threshold (hours) for the DB-backup freshness diagnostic.
1605
+ * Null = cluster default (config.backupStalenessWarnHours). Plain INTEGER.
1606
+ */
1607
+ backup_staleness_warn_hours: ColumnType<number | null, number | null | undefined, number | null>;
1608
+ /**
1609
+ * Per-org dispatch-queue job timeout (ms). A queued job's deadline is
1610
+ * `job.timeoutMs ?? <this> ?? config.queueTimeoutMs`. Null = cluster default
1611
+ * (config.queueTimeoutMs / KICI_QUEUE_TIMEOUT_MS). Postgres BIGINT — pg
1612
+ * returns a string on select; accept a number on insert/update.
1613
+ */
1614
+ queue_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1380
1615
  /**
1381
1616
  * Per-org expiry (seconds) for a held approval element before it is rejected
1382
1617
  * and its run/job/step fails. NOT NULL, default 86400 (one day). An SDK
@@ -1388,6 +1623,18 @@ export interface OrgSettingsTable {
1388
1623
  * NOT NULL, default true. Operators turn it off to enforce four-eyes review.
1389
1624
  */
1390
1625
  allow_self_approval: ColumnType<boolean, boolean | undefined, boolean>;
1626
+ /**
1627
+ * Container-sandbox escape-hatch allow-list: the Linux capabilities a workflow
1628
+ * may request via the SDK `sandbox: { capabilities }` field. NULL / absent
1629
+ * reads as `[]` (deny every capability request). Postgres TEXT[].
1630
+ */
1631
+ sandbox_allowed_capabilities: ColumnType<string[] | null, string[] | null | undefined, string[] | null>;
1632
+ /**
1633
+ * Container-sandbox escape-hatch allow-list: whether a workflow may request
1634
+ * `sandbox: { network: 'host' }`. NULL / absent reads as `false` (deny host
1635
+ * networking). Postgres BOOLEAN.
1636
+ */
1637
+ sandbox_allow_host_network: ColumnType<boolean | null, boolean | null | undefined, boolean | null>;
1391
1638
  /** When this setting was created */
1392
1639
  created_at: Generated<Date>;
1393
1640
  /** When this setting was last updated */
@@ -1396,6 +1643,88 @@ export interface OrgSettingsTable {
1396
1643
  export type OrgSettings = Selectable<OrgSettingsTable>;
1397
1644
  export type NewOrgSettings = Insertable<OrgSettingsTable>;
1398
1645
  export type OrgSettingsUpdate = Updateable<OrgSettingsTable>;
1646
+ /**
1647
+ * Org trust policy (org_trust_policy) — the orchestrator's cache of the
1648
+ * Platform-owned per-org trust policy delivered on `trust_policy.update`.
1649
+ * Distinct from `org_settings`, which holds operator-owned config: the operator
1650
+ * tunes org_settings, the Platform owns this. `source` records which of the two
1651
+ * wrote the row.
1652
+ *
1653
+ * The three policy columns are plain `string`, not the Zod enums that name the
1654
+ * known vocabulary — same reasoning as `held_runs.hold_type`: a value written by
1655
+ * a newer Platform must still be readable rather than failing the row.
1656
+ */
1657
+ export interface OrgTrustPolicyTable {
1658
+ /** Customer/org identifier (primary key) */
1659
+ customer_id: string;
1660
+ /** How to treat a pull request opened from a fork: hold | reject | allow */
1661
+ fork_policy: string;
1662
+ /** How to treat a PR from a contributor with no resolved identity: hold | reject */
1663
+ unknown_contributor_policy: string;
1664
+ /** How to treat a PR that modifies workflow files: hold | reject | allow */
1665
+ workflow_change_policy: string;
1666
+ /** How long a security hold stays approvable before it expires */
1667
+ approval_expiry_hours: number;
1668
+ /** Which side last wrote this row: platform | local */
1669
+ source: string;
1670
+ /** When this policy was last written */
1671
+ updated_at: ColumnType<Date, Date | undefined, Date>;
1672
+ }
1673
+ export type OrgTrustPolicy = Selectable<OrgTrustPolicyTable>;
1674
+ export type NewOrgTrustPolicy = Insertable<OrgTrustPolicyTable>;
1675
+ export type OrgTrustPolicyUpdate = Updateable<OrgTrustPolicyTable>;
1676
+ /**
1677
+ * Cluster-global settings (cluster_settings) — a single row (id='default') of
1678
+ * fleet-wide operator tunables. Each knob is nullable; NULL = use the cluster
1679
+ * default from config.ts. Read via ClusterSettingsReader. Distinct from
1680
+ * org_settings (per customer_id) — these knobs have no per-tenant meaning.
1681
+ * Byte-valued knobs are Postgres BIGINT (pg returns a string on select); count
1682
+ * / seconds knobs are INTEGER (pg returns a number).
1683
+ */
1684
+ export interface ClusterSettingsTable {
1685
+ id: ColumnType<string, string | undefined, never>;
1686
+ max_github_payload_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1687
+ event_log_max_payload_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1688
+ lock_file_max_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1689
+ webhook_dedup_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1690
+ contributor_cache_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1691
+ event_router_event_ttl_seconds: ColumnType<number | null, number | null | undefined, number | null>;
1692
+ event_router_max_dispatch_attempts: ColumnType<number | null, number | null | undefined, number | null>;
1693
+ queue_max_depth: ColumnType<number | null, number | null | undefined, number | null>;
1694
+ reroute_flap_grace_ms: ColumnType<string | null, number | null | undefined, number | null>;
1695
+ max_fanout_hosts: ColumnType<number | null, number | null | undefined, number | null>;
1696
+ event_router_rate_limit_per_workflow_per_minute: ColumnType<number | null, number | null | undefined, number | null>;
1697
+ cache_max_tarball_bytes: ColumnType<string | null, number | null | undefined, number | null>;
1698
+ cache_ttl_days: ColumnType<number | null, number | null | undefined, number | null>;
1699
+ /**
1700
+ * Retention window in days for `check_run_tracking` rows. The hourly cleanup
1701
+ * sweep deletes rows untouched for longer than this; 0 disables the sweep.
1702
+ * NULL ⇒ the orchestrator's configured default.
1703
+ */
1704
+ check_run_tracking_ttl_days: ColumnType<number | null, number | null | undefined, number | null>;
1705
+ concurrency_wait_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1706
+ agent_token_ttl_ms: ColumnType<string | null, number | null | undefined, number | null>;
1707
+ /**
1708
+ * Deadline for one database-backed agent-ownership lookup. Past it the lookup
1709
+ * resolves as undecided and the frame is refused without counting a
1710
+ * violation. NULL ⇒ the orchestrator's configured default.
1711
+ */
1712
+ ownership_db_check_timeout_ms: ColumnType<string | null, number | null | undefined, number | null>;
1713
+ /**
1714
+ * Verified-tier origin the dashboard fetches the orchestrator's X25519
1715
+ * dashboard-encryption public key from (and always displays) under the
1716
+ * `encrypted` dashboard-write posture. The tier is explicit opt-in: NULL ⇒ it
1717
+ * is not offered and the convenient tier is used.
1718
+ */
1719
+ dashboard_verified_issuer: ColumnType<string | null, string | null | undefined, string | null>;
1720
+ /** Monotonic settings version; bumped on each real settings change, advertised to workers. */
1721
+ version: ColumnType<string | number, number | undefined, number>;
1722
+ created_at: Generated<Date>;
1723
+ updated_at: Generated<Date>;
1724
+ }
1725
+ export type ClusterSettings = Selectable<ClusterSettingsTable>;
1726
+ export type NewClusterSettings = Insertable<ClusterSettingsTable>;
1727
+ export type ClusterSettingsUpdate = Updateable<ClusterSettingsTable>;
1399
1728
  /**
1400
1729
  * Pending job contexts table
1401
1730
  * Persists PendingJobContext for crash-recovery of needs-gated jobs.
@@ -1607,8 +1936,21 @@ export interface CheckRunTrackingTable {
1607
1936
  */
1608
1937
  in_progress_sent_at: ColumnType<Date | null, Date | null | undefined, Date | null>;
1609
1938
  /**
1610
- * KiCI run identifier this check-run belongs to. Indexed (partial, NOT
1611
- * NULL) to power `cleanupRun(runId)` without scanning the table.
1939
+ * When the terminal (`completed`) check-run update was accepted by the
1940
+ * provider. NULL means we have no record of sending it — either it never
1941
+ * happened, or the best-effort write failed. Never treat NULL as proof the
1942
+ * update failed.
1943
+ *
1944
+ * `check_run_id` is written at create time, while the check run is still
1945
+ * `queued`, so it proves creation and never completion. This column is the
1946
+ * completion signal.
1947
+ */
1948
+ terminal_sent_at: ColumnType<Date | null, Date | null | undefined, Date | null>;
1949
+ /**
1950
+ * KiCI run identifier this check-run belongs to, written at create time.
1951
+ * Indexed (partial, NOT NULL) so a per-run lookup never scans the table.
1952
+ * It is an attribution key, not a retention key — rows are reclaimed by
1953
+ * the `updated_at`-age sweep, which deliberately ignores this column.
1612
1954
  */
1613
1955
  run_id: ColumnType<string | null, string | null | undefined, string | null>;
1614
1956
  /** When this row was first inserted. */
@@ -1657,6 +1999,91 @@ export interface AttestationsTable {
1657
1999
  }
1658
2000
  export type AttestationRow = Selectable<AttestationsTable>;
1659
2001
  export type NewAttestationRow = Insertable<AttestationsTable>;
2002
+ /**
2003
+ * Cluster-scoped ES256 provenance signing keys. The orchestrator signs its own
2004
+ * build attestations with the one `active` key and serves the public halves of
2005
+ * every non-`revoked` key at `/.well-known/jwks.json`.
2006
+ */
2007
+ export interface OrchestratorSigningKeysTable {
2008
+ /** RFC 7638 thumbprint of the public JWK (primary key, also the token `kid`). */
2009
+ kid: string;
2010
+ /** The non-secret public JWK (JSONB) served in the JWKS. */
2011
+ public_jwk: unknown;
2012
+ /**
2013
+ * AES-256-GCM-wrapped private JWK for `db` custody (master-key wrapped). NULL
2014
+ * for `aws-kms` / `command` custody where the private key never lives here.
2015
+ */
2016
+ encrypted_private_jwk: string | null;
2017
+ key_version: Generated<number>;
2018
+ /** JOSE alg (always `ES256`). */
2019
+ alg: string;
2020
+ /** Custody backend discriminator (`db` | `aws-kms` | `command`). */
2021
+ signer_kind: string;
2022
+ /** External key locator (KMS ARN / signer command) for non-`db` custody; NULL for `db`. */
2023
+ key_ref: string | null;
2024
+ /** Lifecycle status (`SigningKeyStatus`: active | retiring | retired | revoked). */
2025
+ status: Generated<string>;
2026
+ revocation_reason: string | null;
2027
+ created_at: Generated<Date>;
2028
+ activated_at: Date | null;
2029
+ retired_at: Date | null;
2030
+ revoked_at: Date | null;
2031
+ }
2032
+ export type OrchestratorSigningKeyRow = Selectable<OrchestratorSigningKeysTable>;
2033
+ export type NewOrchestratorSigningKeyRow = Insertable<OrchestratorSigningKeysTable>;
2034
+ /**
2035
+ * The orchestrator's X25519 dashboard-encryption keys — the trust root for
2036
+ * browser-sealed dashboard writes under the `encrypted` posture. One `active`
2037
+ * key seals; rotated-out keys go `revoked` and leave the published JWKS, while
2038
+ * their rows stay so envelopes already sealed to the old `kid` still decrypt.
2039
+ */
2040
+ export interface DashboardEncryptionKeysTable {
2041
+ /** RFC 7638 thumbprint of the public JWK (primary key, also the `kid`). */
2042
+ kid: string;
2043
+ /** The non-secret OKP/X25519 public JWK (`use:'enc'`) served in the JWKS. */
2044
+ public_jwk: unknown;
2045
+ /** AES-256-GCM-wrapped DER private key (master-key wrapped under KICI_SECRET_KEY). */
2046
+ encrypted_private_key: string;
2047
+ /** Lifecycle status (`active` | `revoked`). */
2048
+ status: Generated<string>;
2049
+ revocation_reason: string | null;
2050
+ created_at: Generated<Date>;
2051
+ activated_at: Date | null;
2052
+ revoked_at: Date | null;
2053
+ }
2054
+ export type DashboardEncryptionKeyRow = Selectable<DashboardEncryptionKeysTable>;
2055
+ export type NewDashboardEncryptionKeyRow = Insertable<DashboardEncryptionKeysTable>;
2056
+ /**
2057
+ * A user-facing build artifact (`ctx.artifacts.upload`). Named + immutable per
2058
+ * run: `UNIQUE (run_id, name)` enforces the first-upload-wins semantics at the
2059
+ * DB layer. `customer_id` scopes the row to an org for quota accounting; the
2060
+ * tarball lives at `storage_key` (`artifacts/{run_id}/{name}-{discriminator}.tar.gz`,
2061
+ * where the discriminator is a hash of the exact name). Reads go through the
2062
+ * stored key rather than re-deriving it, so a row written under an earlier key
2063
+ * format resolves unchanged.
2064
+ */
2065
+ export interface ArtifactsTable {
2066
+ /** Random id (primary key). */
2067
+ id: string;
2068
+ /** Owning customer/org id (quota-accounting scope). */
2069
+ customer_id: string;
2070
+ /** KiCI run this artifact belongs to. */
2071
+ run_id: string;
2072
+ /** KiCI job that produced this artifact. */
2073
+ job_id: string;
2074
+ /** Caller-supplied artifact name (unique within the run). */
2075
+ name: string;
2076
+ /** Packed tarball size in bytes. Postgres BIGINT — pg returns a string on select. */
2077
+ size_bytes: ColumnType<string, number, number>;
2078
+ /** SHA-256 (hex) of the tarball bytes. */
2079
+ sha256: string;
2080
+ /** Object-storage key the tarball was written to. */
2081
+ storage_key: string;
2082
+ /** When this row was inserted. */
2083
+ created_at: Generated<Date>;
2084
+ }
2085
+ export type ArtifactRow = Selectable<ArtifactsTable>;
2086
+ export type NewArtifactRow = Insertable<ArtifactsTable>;
1660
2087
  /**
1661
2088
  * Deferred-attestation outbox: a build whose provenance mint failed transiently
1662
2089
  * freezes its DSSE-signed statement here; a leader-only retrier mints the token
@@ -1775,6 +2202,12 @@ export interface HostRosterTable {
1775
2202
  ssh_port: ColumnType<number | null, number | null | undefined, number | null>;
1776
2203
  /** Scoped-secret ref (`scope/key`) holding the bring-up private key. */
1777
2204
  ssh_key_secret: ColumnType<string | null, string | null | undefined, string | null>;
2205
+ /**
2206
+ * Delivery hint: when true, the box can reach the orchestrator's object
2207
+ * storage, so bring-up picks `s3-direct` (the box pulls the payload via a
2208
+ * presigned URL). NULL / false ⇒ the conservative `ssh-push` fallback.
2209
+ */
2210
+ s3_reachable: ColumnType<boolean | null, boolean | null | undefined, boolean | null>;
1778
2211
  created_at: Generated<Date>;
1779
2212
  updated_at: ColumnType<Date, Date | string | undefined, Date | string>;
1780
2213
  }