@kici-dev/orchestrator 0.0.0 → 0.1.1

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 (342) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -6
  3. package/dist/__test-helpers__/mock-db.d.ts +103 -0
  4. package/dist/__test-helpers__/mock-ws.d.ts +13 -0
  5. package/dist/agent/dispatcher.d.ts +231 -0
  6. package/dist/agent/ownership-tracker.d.ts +46 -0
  7. package/dist/agent/registry.d.ts +255 -0
  8. package/dist/agent/token-store.d.ts +96 -0
  9. package/dist/app.d.ts +234 -0
  10. package/dist/audit/access-log.d.ts +92 -0
  11. package/dist/audit/sampling-rate-limiter.d.ts +41 -0
  12. package/dist/cache/build-coordinator.d.ts +42 -0
  13. package/dist/cache/dep-cache.d.ts +51 -0
  14. package/dist/cache/index.d.ts +16 -0
  15. package/dist/cache/pending-builds.d.ts +14 -0
  16. package/dist/cache/pending-dynamics.d.ts +15 -0
  17. package/dist/cache/pending-inits.d.ts +19 -0
  18. package/dist/cache/pending-tracker.d.ts +65 -0
  19. package/dist/cache/source-cache.d.ts +30 -0
  20. package/dist/cli/api-client.d.ts +411 -0
  21. package/dist/cli/commands/access-log.d.ts +30 -0
  22. package/dist/cli/commands/agent-service/index.d.ts +15 -0
  23. package/dist/cli/commands/agent-service/install.d.ts +9 -0
  24. package/dist/cli/commands/agent-service/logs.d.ts +9 -0
  25. package/dist/cli/commands/agent-service/restart.d.ts +8 -0
  26. package/dist/cli/commands/agent-service/start.d.ts +8 -0
  27. package/dist/cli/commands/agent-service/status.d.ts +10 -0
  28. package/dist/cli/commands/agent-service/stop.d.ts +8 -0
  29. package/dist/cli/commands/agent-service/uninstall.d.ts +9 -0
  30. package/dist/cli/commands/agent-service/upgrade.d.ts +11 -0
  31. package/dist/cli/commands/agent.d.ts +10 -0
  32. package/dist/cli/commands/api-key.d.ts +12 -0
  33. package/dist/cli/commands/audit.d.ts +9 -0
  34. package/dist/cli/commands/backend.d.ts +17 -0
  35. package/dist/cli/commands/cold-store-impl.d.ts +101 -0
  36. package/dist/cli/commands/cold-store.d.ts +30 -0
  37. package/dist/cli/commands/config.d.ts +16 -0
  38. package/dist/cli/commands/db.d.ts +19 -0
  39. package/dist/cli/commands/debug-bundle.d.ts +16 -0
  40. package/dist/cli/commands/diagnose.d.ts +15 -0
  41. package/dist/cli/commands/environment.d.ts +24 -0
  42. package/dist/cli/commands/event-dlq.d.ts +19 -0
  43. package/dist/cli/commands/event-log.d.ts +27 -0
  44. package/dist/cli/commands/event.d.ts +4 -0
  45. package/dist/cli/commands/execution.d.ts +17 -0
  46. package/dist/cli/commands/inspect-bundle.d.ts +16 -0
  47. package/dist/cli/commands/maintenance.d.ts +4 -0
  48. package/dist/cli/commands/orchestrator-service/index.d.ts +12 -0
  49. package/dist/cli/commands/orchestrator-service/install.d.ts +10 -0
  50. package/dist/cli/commands/orchestrator-service/logs.d.ts +10 -0
  51. package/dist/cli/commands/orchestrator-service/restart.d.ts +8 -0
  52. package/dist/cli/commands/orchestrator-service/start.d.ts +8 -0
  53. package/dist/cli/commands/orchestrator-service/status.d.ts +10 -0
  54. package/dist/cli/commands/orchestrator-service/stop.d.ts +8 -0
  55. package/dist/cli/commands/orchestrator-service/uninstall.d.ts +9 -0
  56. package/dist/cli/commands/orchestrator-service/upgrade.d.ts +12 -0
  57. package/dist/cli/commands/org-settings.d.ts +17 -0
  58. package/dist/cli/commands/peer.d.ts +13 -0
  59. package/dist/cli/commands/queue.d.ts +16 -0
  60. package/dist/cli/commands/registration.d.ts +18 -0
  61. package/dist/cli/commands/rotate.d.ts +9 -0
  62. package/dist/cli/commands/runs.d.ts +34 -0
  63. package/dist/cli/commands/secret.d.ts +12 -0
  64. package/dist/cli/commands/shared/db.d.ts +16 -0
  65. package/dist/cli/commands/shared/versioned-upgrade.d.ts +38 -0
  66. package/dist/cli/commands/source.d.ts +24 -0
  67. package/dist/cli/commands/token.d.ts +10 -0
  68. package/dist/cli/commands/workflow.d.ts +31 -0
  69. package/dist/cli/join.d.ts +14 -0
  70. package/dist/cli/kici-admin.d.ts +13 -0
  71. package/dist/cli/lazy-deps/cache.d.ts +17 -0
  72. package/dist/cli/lazy-deps/downloader.d.ts +33 -0
  73. package/dist/cli/lazy-deps/registry.d.ts +43 -0
  74. package/dist/cli/service/compose.d.ts +25 -0
  75. package/dist/cli/service/index.d.ts +24 -0
  76. package/dist/cli/service/launchd.d.ts +34 -0
  77. package/dist/cli/service/platform-detect.d.ts +59 -0
  78. package/dist/cli/service/systemd.d.ts +41 -0
  79. package/dist/cli/service/types.d.ts +91 -0
  80. package/dist/cli/service/windows.d.ts +20 -0
  81. package/dist/cli/wizard/agent-wizard.d.ts +24 -0
  82. package/dist/cli/wizard/orchestrator-wizard.d.ts +38 -0
  83. package/dist/cli/wizard/prompts.d.ts +23 -0
  84. package/dist/cli.js +11435 -0
  85. package/dist/cluster/cluster-identity.d.ts +59 -0
  86. package/dist/cluster/coordinator.d.ts +204 -0
  87. package/dist/cluster/health-api.d.ts +30 -0
  88. package/dist/cluster/index.d.ts +24 -0
  89. package/dist/cluster/join-client.d.ts +75 -0
  90. package/dist/cluster/join-handler.d.ts +58 -0
  91. package/dist/cluster/join-token.d.ts +94 -0
  92. package/dist/cluster/orphan-recovery.d.ts +67 -0
  93. package/dist/cluster/peer-client.d.ts +190 -0
  94. package/dist/cluster/peer-credentials.d.ts +108 -0
  95. package/dist/cluster/peer-crypto.d.ts +57 -0
  96. package/dist/cluster/peer-handler.d.ts +97 -0
  97. package/dist/cluster/peer-registry.d.ts +186 -0
  98. package/dist/cluster/raft-state.d.ts +36 -0
  99. package/dist/cluster/raft.d.ts +140 -0
  100. package/dist/cold-store/load-access-log-range.d.ts +73 -0
  101. package/dist/cold-store/load-event-log-range.d.ts +62 -0
  102. package/dist/cold-store/load-secret-audit-log-range.d.ts +38 -0
  103. package/dist/cold-store/orchestrator-cold-store.d.ts +58 -0
  104. package/dist/cold-store/tables/access-log.d.ts +80 -0
  105. package/dist/cold-store/tables/event-log.d.ts +70 -0
  106. package/dist/cold-store/tables/execution-jobs.d.ts +63 -0
  107. package/dist/cold-store/tables/execution-runs.d.ts +81 -0
  108. package/dist/cold-store/tables/execution-steps.d.ts +65 -0
  109. package/dist/cold-store/tables/secret-audit-log.d.ts +77 -0
  110. package/dist/concurrency/dispatch-next-queued.d.ts +63 -0
  111. package/dist/concurrency/group-tracker.d.ts +51 -0
  112. package/dist/concurrency/index.d.ts +3 -0
  113. package/dist/concurrency/queue-manager.d.ts +68 -0
  114. package/dist/concurrency/waiters.d.ts +58 -0
  115. package/dist/config/encryption.d.ts +82 -0
  116. package/dist/config/env-overlay.d.ts +45 -0
  117. package/dist/config/index.d.ts +16 -0
  118. package/dist/config/loader.d.ts +26 -0
  119. package/dist/config/reload.d.ts +113 -0
  120. package/dist/config/resolver.d.ts +47 -0
  121. package/dist/config/schema.d.ts +210 -0
  122. package/dist/config/shared-store.d.ts +142 -0
  123. package/dist/config/types.d.ts +218 -0
  124. package/dist/config.d.ts +249 -0
  125. package/dist/cron/cron-scheduler.d.ts +78 -0
  126. package/dist/cron/cron-store.d.ts +38 -0
  127. package/dist/dashboard/handler.d.ts +243 -0
  128. package/dist/db/client.d.ts +13 -0
  129. package/dist/db/migration-provider.d.ts +9 -0
  130. package/dist/db/migrations/001_initial.d.ts +8 -0
  131. package/dist/db/migrations/002_config_versions_key_version.d.ts +16 -0
  132. package/dist/db/migrations/003_access_log.d.ts +26 -0
  133. package/dist/db/migrations/004_rename_bundle_to_source.d.ts +19 -0
  134. package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +19 -0
  135. package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +38 -0
  136. package/dist/db/migrations/007_audit_logs_archived_at.d.ts +42 -0
  137. package/dist/db/migrations/008_event_log_archived_at.d.ts +40 -0
  138. package/dist/db/migrations/009_access_log_trigram.d.ts +15 -0
  139. package/dist/db/migrations/010_cold_store_chunks.d.ts +34 -0
  140. package/dist/db/migrations/011_drop_source_secrets_notify.d.ts +21 -0
  141. package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +28 -0
  142. package/dist/db/migrations/013_execution_log_bytes.d.ts +21 -0
  143. package/dist/db/migrations/014_kici_events_lease_retry.d.ts +36 -0
  144. package/dist/db/migrations/015_org_settings_customer_scoped.d.ts +30 -0
  145. package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +15 -0
  146. package/dist/db/migrations/017_org_id_widen.d.ts +4 -0
  147. package/dist/db/migrations/018_org_id_prefix_backfill.d.ts +4 -0
  148. package/dist/db/migrator.d.ts +32 -0
  149. package/dist/db/types.d.ts +1266 -0
  150. package/dist/diagnostics/bundle-reader.d.ts +48 -0
  151. package/dist/diagnostics/bundle-writer.d.ts +57 -0
  152. package/dist/diagnostics/checks/agents.d.ts +10 -0
  153. package/dist/diagnostics/checks/certs.d.ts +9 -0
  154. package/dist/diagnostics/checks/config.d.ts +10 -0
  155. package/dist/diagnostics/checks/db.d.ts +9 -0
  156. package/dist/diagnostics/checks/disk.d.ts +9 -0
  157. package/dist/diagnostics/checks/index.d.ts +17 -0
  158. package/dist/diagnostics/checks/ws.d.ts +9 -0
  159. package/dist/diagnostics/index.d.ts +13 -0
  160. package/dist/diagnostics/runner.d.ts +23 -0
  161. package/dist/diagnostics/types.d.ts +38 -0
  162. package/dist/entry-helpers.d.ts +93 -0
  163. package/dist/environments/binding-store.d.ts +27 -0
  164. package/dist/environments/environment-store.d.ts +74 -0
  165. package/dist/environments/held-runs.d.ts +64 -0
  166. package/dist/environments/index.d.ts +10 -0
  167. package/dist/environments/protection/branch-gate.d.ts +5 -0
  168. package/dist/environments/protection/concurrency-gate.d.ts +7 -0
  169. package/dist/environments/protection/pipeline.d.ts +18 -0
  170. package/dist/environments/protection/reviewer-gate.d.ts +7 -0
  171. package/dist/environments/protection/trust-gate.d.ts +7 -0
  172. package/dist/environments/protection/wait-timer-gate.d.ts +7 -0
  173. package/dist/environments/variable-store.d.ts +39 -0
  174. package/dist/events/circuit-breaker.d.ts +33 -0
  175. package/dist/events/event-emitter.d.ts +55 -0
  176. package/dist/events/event-retry-scanner.d.ts +52 -0
  177. package/dist/events/event-router.d.ts +183 -0
  178. package/dist/events/event-store.d.ts +157 -0
  179. package/dist/events/trust-store.d.ts +54 -0
  180. package/dist/events/types.d.ts +61 -0
  181. package/dist/helpers/ip-extraction.d.ts +29 -0
  182. package/dist/helpers/rate-limiter.d.ts +23 -0
  183. package/dist/index.d.ts +7 -0
  184. package/dist/index.js +772 -0
  185. package/dist/lockfile-cache.d.ts +39 -0
  186. package/dist/metrics/agent-metrics-aggregator.d.ts +116 -0
  187. package/dist/metrics/metrics-reporter.d.ts +40 -0
  188. package/dist/metrics/prometheus.d.ts +261 -0
  189. package/dist/metrics/scheduled-jobs.d.ts +20 -0
  190. package/dist/orchestrator-core.d.ts +193 -0
  191. package/dist/pipeline/dispatch-matched-workflow.d.ts +102 -0
  192. package/dist/pipeline/inline-eval.d.ts +28 -0
  193. package/dist/pipeline/install-secrets-resolver.d.ts +73 -0
  194. package/dist/pipeline/manual-schedule.d.ts +21 -0
  195. package/dist/pipeline/needs-scheduler.d.ts +85 -0
  196. package/dist/pipeline/process-webhook.d.ts +38 -0
  197. package/dist/pipeline/processor.d.ts +326 -0
  198. package/dist/pipeline/rerun.d.ts +79 -0
  199. package/dist/pipeline/test-pipeline.d.ts +110 -0
  200. package/dist/provider-registry.d.ts +122 -0
  201. package/dist/providers/generic/index.d.ts +23 -0
  202. package/dist/providers/generic/normalizer.d.ts +112 -0
  203. package/dist/providers/generic/verification.d.ts +47 -0
  204. package/dist/providers/github/auth.d.ts +60 -0
  205. package/dist/providers/github/changed-files.d.ts +51 -0
  206. package/dist/providers/github/check-status-poster.d.ts +35 -0
  207. package/dist/providers/github/contributor-resolver.d.ts +30 -0
  208. package/dist/providers/github/index.d.ts +20 -0
  209. package/dist/providers/github/lock-file.d.ts +32 -0
  210. package/dist/providers/github/normalizer.d.ts +103 -0
  211. package/dist/providers/github/repo-url.d.ts +35 -0
  212. package/dist/providers/internal/index.d.ts +32 -0
  213. package/dist/providers/internal/lock-file-fetcher.d.ts +34 -0
  214. package/dist/providers/internal/normalizer.d.ts +89 -0
  215. package/dist/providers/internal/repo-url-builder.d.ts +42 -0
  216. package/dist/providers/universal-git/changed-files.d.ts +42 -0
  217. package/dist/providers/universal-git/clone-token.d.ts +83 -0
  218. package/dist/providers/universal-git/config.d.ts +192 -0
  219. package/dist/providers/universal-git/index.d.ts +55 -0
  220. package/dist/providers/universal-git/lock-file.d.ts +71 -0
  221. package/dist/providers/universal-git/normalizer.d.ts +90 -0
  222. package/dist/providers/universal-git/repo-url.d.ts +50 -0
  223. package/dist/providers/universal-git/ssh-auth.d.ts +94 -0
  224. package/dist/queue/bootstrap.d.ts +50 -0
  225. package/dist/queue/cleanup.d.ts +41 -0
  226. package/dist/queue/depth-refresher.d.ts +65 -0
  227. package/dist/queue/job-queue.d.ts +343 -0
  228. package/dist/queue/scheduled-job.d.ts +91 -0
  229. package/dist/registration/extractor.d.ts +44 -0
  230. package/dist/registration/registration-index.d.ts +162 -0
  231. package/dist/registration/registration-store.d.ts +111 -0
  232. package/dist/reporting/check-run-summary.d.ts +102 -0
  233. package/dist/reporting/commit-status.d.ts +382 -0
  234. package/dist/reporting/execution-tracker.d.ts +538 -0
  235. package/dist/reporting/fs-log-storage.d.ts +41 -0
  236. package/dist/reporting/log-pull-handler.d.ts +35 -0
  237. package/dist/reporting/log-storage.d.ts +70 -0
  238. package/dist/reporting/log-writer.d.ts +45 -0
  239. package/dist/reporting/s3-log-storage.d.ts +42 -0
  240. package/dist/reporting/step-log-buffer.d.ts +57 -0
  241. package/dist/routes/admin-access-log.d.ts +34 -0
  242. package/dist/routes/admin-backends.d.ts +28 -0
  243. package/dist/routes/admin-config.d.ts +57 -0
  244. package/dist/routes/admin-db.d.ts +20 -0
  245. package/dist/routes/admin-environments.d.ts +42 -0
  246. package/dist/routes/admin-errors.d.ts +4 -0
  247. package/dist/routes/admin-event-dlq.d.ts +39 -0
  248. package/dist/routes/admin-event-log.d.ts +42 -0
  249. package/dist/routes/admin-events.d.ts +46 -0
  250. package/dist/routes/admin-maintenance.d.ts +22 -0
  251. package/dist/routes/admin-org-settings.d.ts +29 -0
  252. package/dist/routes/admin-queue-execution.d.ts +27 -0
  253. package/dist/routes/admin-registrations.d.ts +37 -0
  254. package/dist/routes/admin-runs.d.ts +57 -0
  255. package/dist/routes/admin-scheduled-jobs.d.ts +36 -0
  256. package/dist/routes/admin-sources.d.ts +18 -0
  257. package/dist/routes/admin.d.ts +103 -0
  258. package/dist/routes/capabilities.d.ts +24 -0
  259. package/dist/routes/diagnostics.d.ts +16 -0
  260. package/dist/routes/health.d.ts +20 -0
  261. package/dist/routes/test-trigger.d.ts +41 -0
  262. package/dist/routes/uploads.d.ts +38 -0
  263. package/dist/routes/webhooks.d.ts +36 -0
  264. package/dist/scaler/bare-metal-backend.d.ts +107 -0
  265. package/dist/scaler/config.d.ts +303 -0
  266. package/dist/scaler/container-backend.d.ts +125 -0
  267. package/dist/scaler/file-tail.d.ts +23 -0
  268. package/dist/scaler/firecracker-api.d.ts +100 -0
  269. package/dist/scaler/firecracker-backend.d.ts +263 -0
  270. package/dist/scaler/index.d.ts +24 -0
  271. package/dist/scaler/ip-allocator.d.ts +177 -0
  272. package/dist/scaler/label-matcher.d.ts +73 -0
  273. package/dist/scaler/log-forwarder.d.ts +54 -0
  274. package/dist/scaler/machine-ledger.d.ts +160 -0
  275. package/dist/scaler/manager.d.ts +338 -0
  276. package/dist/scaler/nftables.d.ts +85 -0
  277. package/dist/scaler/types.d.ts +388 -0
  278. package/dist/scaler/warm-pool.d.ts +81 -0
  279. package/dist/secrets/audit-logger.d.ts +65 -0
  280. package/dist/secrets/backend-health.d.ts +60 -0
  281. package/dist/secrets/backend-registry.d.ts +68 -0
  282. package/dist/secrets/backend-sync.d.ts +40 -0
  283. package/dist/secrets/cleanup.d.ts +40 -0
  284. package/dist/secrets/config.d.ts +51 -0
  285. package/dist/secrets/crypto.d.ts +49 -0
  286. package/dist/secrets/ephemeral-keys.d.ts +49 -0
  287. package/dist/secrets/index.d.ts +17 -0
  288. package/dist/secrets/pg-secret-store.d.ts +105 -0
  289. package/dist/secrets/rbac.d.ts +47 -0
  290. package/dist/secrets/secret-output-store.d.ts +46 -0
  291. package/dist/secrets/secret-resolver.d.ts +137 -0
  292. package/dist/secrets/source-credentials.d.ts +61 -0
  293. package/dist/secrets/token-manager.d.ts +63 -0
  294. package/dist/secrets/vault-secret-store.d.ts +85 -0
  295. package/dist/security/comment-handler.d.ts +67 -0
  296. package/dist/security/contributor-cache.d.ts +75 -0
  297. package/dist/security/global-workflow-policy.d.ts +72 -0
  298. package/dist/security/lock-source.d.ts +34 -0
  299. package/dist/security/trust-resolver.d.ts +108 -0
  300. package/dist/security/workflow-diff.d.ts +26 -0
  301. package/dist/server.d.ts +17 -0
  302. package/dist/server.js +48055 -0
  303. package/dist/sources/index.d.ts +10 -0
  304. package/dist/sources/source-manager.d.ts +63 -0
  305. package/dist/sources/source-store.d.ts +79 -0
  306. package/dist/sources/source-validator.d.ts +16 -0
  307. package/dist/stale-detector/stale-run-detector.d.ts +109 -0
  308. package/dist/standalone.d.ts +20 -0
  309. package/dist/standalone.js +41546 -0
  310. package/dist/storage/blob-routes.d.ts +20 -0
  311. package/dist/storage/filesystem.d.ts +60 -0
  312. package/dist/storage/index.d.ts +20 -0
  313. package/dist/storage/s3.d.ts +68 -0
  314. package/dist/storage/sign-url.d.ts +45 -0
  315. package/dist/storage/types.d.ts +98 -0
  316. package/dist/webhook/dedup.d.ts +44 -0
  317. package/dist/webhook/event-log.d.ts +83 -0
  318. package/dist/webhook/generic-sources.d.ts +169 -0
  319. package/dist/webhook/handler.d.ts +23 -0
  320. package/dist/webhook/relay-buffer.d.ts +96 -0
  321. package/dist/webhook/verify-inbound.d.ts +78 -0
  322. package/dist/worker/in-memory-execution-tracker.d.ts +94 -0
  323. package/dist/worker/in-memory-job-queue.d.ts +74 -0
  324. package/dist/worker/static-agent-token-store.d.ts +58 -0
  325. package/dist/worker/worker-status.d.ts +36 -0
  326. package/dist/worker-core.d.ts +74 -0
  327. package/dist/ws/agent-api-registry.d.ts +49 -0
  328. package/dist/ws/agent-handler.d.ts +176 -0
  329. package/dist/ws/agent-heartbeat.d.ts +45 -0
  330. package/dist/ws/dashboard-backends-handler.d.ts +51 -0
  331. package/dist/ws/dashboard-diagnostics-handler.d.ts +56 -0
  332. package/dist/ws/dashboard-env-handler.d.ts +107 -0
  333. package/dist/ws/dashboard-global-workflows-handler.d.ts +72 -0
  334. package/dist/ws/dashboard-registrations-handler.d.ts +84 -0
  335. package/dist/ws/event-buffer.d.ts +16 -0
  336. package/dist/ws/observer-handler.d.ts +42 -0
  337. package/dist/ws/observer-registry.d.ts +88 -0
  338. package/dist/ws/platform-client.d.ts +270 -0
  339. package/dist/ws/server-options.d.ts +15 -0
  340. package/package.json +87 -6
  341. package/sbom.spdx.json +14370 -0
  342. package/index.js +0 -3
@@ -0,0 +1,1266 @@
1
+ import type { ColumnType, Generated, Insertable, Selectable, Updateable } from 'kysely';
2
+ /**
3
+ * PostgreSQL-only database types.
4
+ * Column names use snake_case matching the actual database column names.
5
+ */
6
+ export interface Database {
7
+ dispatch_queue: DispatchQueueTable;
8
+ dedup_cache: DedupCacheTable;
9
+ ip_allocations: IpAllocationTable;
10
+ execution_runs: ExecutionRunTable;
11
+ execution_jobs: ExecutionJobTable;
12
+ execution_steps: ExecutionStepTable;
13
+ raft_state: RaftStateTable;
14
+ secret_audit_log: SecretAuditLogTable;
15
+ environments: EnvironmentsTable;
16
+ scoped_secrets: ScopedSecretsTable;
17
+ environment_bindings: EnvironmentBindingsTable;
18
+ environment_variables: EnvironmentVariablesTable;
19
+ environment_source_overrides: EnvironmentSourceOverridesTable;
20
+ held_runs: HeldRunsTable;
21
+ admin_tokens: AdminTokenTable;
22
+ agent_tokens: AgentTokenTable;
23
+ config_versions: ConfigVersionTable;
24
+ kici_events: KiciEventTable;
25
+ generic_webhook_sources: GenericWebhookSourceTable;
26
+ cross_repo_trust: CrossRepoTrustTable;
27
+ test_uploads: TestUploadsTable;
28
+ workflow_registrations: WorkflowRegistrationsTable;
29
+ registry_versions: RegistryVersionsTable;
30
+ cron_last_fired: CronLastFiredTable;
31
+ run_ephemeral_keys: RunEphemeralKeysTable;
32
+ run_secret_outputs: RunSecretOutputsTable;
33
+ concurrency_groups: ConcurrencyGroupsTable;
34
+ sources: SourcesTable;
35
+ cluster_meta: ClusterMetaTable;
36
+ join_tokens: JoinTokenTable;
37
+ org_settings: OrgSettingsTable;
38
+ execution_job_needs: ExecutionJobNeedsTable;
39
+ pending_job_contexts: PendingJobContextsTable;
40
+ event_log: EventLogTable;
41
+ access_log: AccessLogTable;
42
+ cold_store_chunk_counts: ColdStoreChunkCountsTable;
43
+ cold_store_chunks: ColdStoreChunksTable;
44
+ }
45
+ /**
46
+ * Cluster metadata table
47
+ * Key-value store for cluster-wide configuration (e.g. cluster_id).
48
+ */
49
+ export interface ClusterMetaTable {
50
+ /** Key identifier (primary key) */
51
+ key: string;
52
+ /** Value */
53
+ value: string;
54
+ /** When this entry was created */
55
+ created_at: Generated<Date>;
56
+ }
57
+ export type ClusterMeta = Selectable<ClusterMetaTable>;
58
+ export type NewClusterMeta = Insertable<ClusterMetaTable>;
59
+ /**
60
+ * Join tokens table
61
+ * Stores hashed join tokens for zero-knowledge cluster bootstrap.
62
+ * Tokens are one-time use (consumed_at set after validation).
63
+ */
64
+ export interface JoinTokenTable {
65
+ /** UUID primary key */
66
+ id: Generated<string>;
67
+ /** SHA-256 hash of the token secret (for lookup) */
68
+ token_hash: string;
69
+ /** Routing info embedded in the token (orgId, routingKey, expiry) */
70
+ routing_info: string;
71
+ /** Who created this token */
72
+ created_by: string;
73
+ /** When this token was created */
74
+ created_at: Generated<Date>;
75
+ /** When this token expires */
76
+ expires_at: Date;
77
+ /** When this token was consumed (null = unused) */
78
+ consumed_at: Date | null;
79
+ /** Who consumed this token (null = unused) */
80
+ consumed_by: string | null;
81
+ }
82
+ export type JoinToken = Selectable<JoinTokenTable>;
83
+ export type NewJoinToken = Insertable<JoinTokenTable>;
84
+ /**
85
+ * Dispatch queue table
86
+ * Holds jobs waiting to be dispatched to agents.
87
+ */
88
+ export interface DispatchQueueTable {
89
+ /** UUID primary key */
90
+ id: Generated<string>;
91
+ /** Unique run identifier for this execution */
92
+ run_id: string;
93
+ /** Workflow name from lock file */
94
+ workflow_name: string;
95
+ /** Job name within the workflow */
96
+ job_name: string;
97
+ /** JSONB array of runs-on labels for agent matching.
98
+ * Insert: JSON.stringify(labels), Select: auto-parsed by pg driver. */
99
+ runs_on_labels: string;
100
+ /** JSON-encoded Record of the full job configuration */
101
+ job_config: string;
102
+ /** Repository clone URL */
103
+ repo_url: string;
104
+ /** Git ref (branch/tag) */
105
+ ref: string;
106
+ /** Git commit SHA */
107
+ sha: string;
108
+ /** Job status: pending | dispatched | expired | failed */
109
+ status: Generated<string>;
110
+ /** When this job was queued */
111
+ created_at: Generated<Date>;
112
+ /** When this job expires (null = wait indefinitely) */
113
+ expires_at: Date | null;
114
+ /** Webhook delivery ID for tracing */
115
+ delivery_id: string;
116
+ /** Provider type (e.g., "github", "gitlab") */
117
+ provider: Generated<string>;
118
+ /** JSON-encoded provider-specific context (e.g., {"installationId": 42}) */
119
+ provider_context: Generated<string>;
120
+ /** Pre-packed `.kici/` source tarball URL (from cache). Nullable. */
121
+ source_tar_url: string | null;
122
+ /** SHA-256 hash of the source tarball bytes for integrity verification. Nullable. */
123
+ source_tar_hash: string | null;
124
+ /** Pre-built dependency tarball URL (from dep cache). Nullable. */
125
+ deps_url: string | null;
126
+ /** SHA-256 hash of the dependency tarball. Nullable. */
127
+ deps_hash: string | null;
128
+ /** Request trace ID for cross-tier correlation. Nullable for background ops. */
129
+ request_id: string | null;
130
+ /** JSONB array of exclusion labels. Default '[]'. */
131
+ exclude_labels: Generated<string>;
132
+ /** Routing key (e.g. "github:12345") so dispatch can pick the right
133
+ * per-app provider bundle in multi-app setups. Required (NOT NULL). */
134
+ routing_key: string;
135
+ }
136
+ /**
137
+ * Deduplication cache table
138
+ * Tracks recently processed webhook delivery IDs to prevent reprocessing.
139
+ */
140
+ export interface DedupCacheTable {
141
+ /** Webhook delivery ID (primary key) */
142
+ delivery_id: string;
143
+ /** When this delivery was first received */
144
+ received_at: Generated<Date>;
145
+ /** When this cache entry expires (24h TTL) */
146
+ expires_at: Date;
147
+ }
148
+ export type DispatchQueueItem = Selectable<DispatchQueueTable>;
149
+ export type NewDispatchQueueItem = Insertable<DispatchQueueTable>;
150
+ export type DispatchQueueItemUpdate = Updateable<DispatchQueueTable>;
151
+ /**
152
+ * IP allocation table for Firecracker VM networking.
153
+ * Tracks assigned IPs from the CIDR pool. DB-backed to survive restarts.
154
+ */
155
+ export interface IpAllocationTable {
156
+ /** Allocated IP address (primary key), e.g. "10.0.0.5" */
157
+ ip: string;
158
+ /** Firecracker VM ID (= agentId) */
159
+ vm_id: string;
160
+ /** Which scaler backend owns this allocation */
161
+ scaler_name: string;
162
+ /** TAP device name on the host */
163
+ tap_device: string;
164
+ /** Guest MAC address */
165
+ mac_address: string;
166
+ /** When this IP was allocated */
167
+ allocated_at: Generated<Date>;
168
+ }
169
+ /**
170
+ * Execution run table
171
+ * Top-level workflow runs (one per webhook trigger).
172
+ * Stores status, timing, and trigger decision metadata.
173
+ */
174
+ export interface ExecutionRunTable {
175
+ /** UUID primary key */
176
+ id: Generated<string>;
177
+ /** Unique run identifier matching runId in protocol messages */
178
+ run_id: string;
179
+ /** Routing key (e.g. github:appId) for Platform StaleOrchDetector when sharing DB */
180
+ routing_key: string | null;
181
+ /** Workflow name from lock file */
182
+ workflow_name: string;
183
+ /** Run status: running | success | failed | cancelled */
184
+ status: Generated<string>;
185
+ /** Provider type (e.g. "github", "gitlab") */
186
+ provider: string;
187
+ /** Repository identifier (e.g. "owner/repo") */
188
+ repo_identifier: string;
189
+ /** Git ref (branch/tag) */
190
+ ref: string;
191
+ /** Git commit SHA */
192
+ sha: string;
193
+ /** Webhook delivery ID for tracing */
194
+ delivery_id: string | null;
195
+ /** Serialized WorkflowDecision (trigger decision trace) */
196
+ trigger_decision: string | null;
197
+ /** When the run started */
198
+ started_at: Generated<Date>;
199
+ /** When the run completed */
200
+ completed_at: Date | null;
201
+ /** Total execution duration in milliseconds */
202
+ duration_ms: number | null;
203
+ /**
204
+ * Total raw log bytes accumulated across all jobs of this run. Sum of the
205
+ * agent-side `LogStreamer.getTotalBytes()` reported on terminal
206
+ * `step.status` for every step in every job. Default 0 for pre-migration
207
+ * rows. Powers the operator-side `kici_org_log_bytes` capacity-planning
208
+ * gauge on the Platform. Postgres BIGINT — pg returns string; cast at
209
+ * read sites.
210
+ */
211
+ log_bytes: Generated<number>;
212
+ /** Provider-specific context (e.g. {"installationId": 42}) */
213
+ provider_context: Generated<string>;
214
+ /** Whether this is a CLI-initiated test run */
215
+ is_test_run: Generated<boolean>;
216
+ /** Fixture ID for test runs (null for real webhook runs) */
217
+ fixture_id: string | null;
218
+ /** Parent run ID for re-run lineage (null for original runs). */
219
+ parent_run_id: string | null;
220
+ /** Root ancestor run ID for re-run lineage (null for original runs). Always points to the first run in the chain. */
221
+ original_run_id: string | null;
222
+ /** User identity that triggered this re-run (null for webhook-triggered). Format: "user:email" or "key:name". */
223
+ triggered_by: string | null;
224
+ /** User identity that cancelled this run (null for non-cancelled). */
225
+ cancelled_by: string | null;
226
+ /** Environment name for this run (null if no environment applies) */
227
+ environment: string | null;
228
+ /** Trust tier of the contributor for PR runs (null for non-PR events) */
229
+ trust_tier: string | null;
230
+ /** Lock file source: 'head' or 'base' (null for non-PR events) */
231
+ lock_file_source: string | null;
232
+ /** Username of the contributor (null for non-PR events) */
233
+ contributor_username: string | null;
234
+ /** Human-readable reason why the run failed (null for non-failed runs). */
235
+ failure_reason: string | null;
236
+ /** When this record was created */
237
+ created_at: Generated<Date>;
238
+ /**
239
+ * Set inside the cold-store archive transaction before the row is
240
+ * DELETEd. Survivors carry NULL. Exists so a future
241
+ * "promote-chunk-back-into-PG" path (Phase F) can restore rows with
242
+ * their original archive pointer.
243
+ */
244
+ archived_at: Date | null;
245
+ /** S3 object key of the chunk that carried this row; see `archived_at`. */
246
+ archive_object_key: string | null;
247
+ }
248
+ /**
249
+ * Execution job table
250
+ * Individual jobs within a run (including matrix expansions).
251
+ */
252
+ export interface ExecutionJobTable {
253
+ /** UUID primary key */
254
+ id: Generated<string>;
255
+ /** References execution_runs.run_id */
256
+ run_id: string;
257
+ /** Job identifier from dispatch */
258
+ job_id: string;
259
+ /** Job name (e.g. "test", "test[node-18]") */
260
+ job_name: string;
261
+ /** Job status: pending | running | success | failed | cancelled | skipped */
262
+ status: Generated<string>;
263
+ /** Matrix values JSON (e.g. {"node": "18"}) */
264
+ matrix_values: string | null;
265
+ /** Agent ID that ran this job */
266
+ agent_id: string | null;
267
+ /** When the job started */
268
+ started_at: Date | null;
269
+ /** When the job completed */
270
+ completed_at: Date | null;
271
+ /** Job execution duration in milliseconds */
272
+ duration_ms: number | null;
273
+ /**
274
+ * Total raw log bytes accumulated across all steps of this job. Sum of the
275
+ * agent-side `LogStreamer.getTotalBytes()` reported on terminal
276
+ * `step.status` for every step. Default 0 for pre-migration rows.
277
+ * Postgres BIGINT — pg returns string; cast at read sites.
278
+ */
279
+ log_bytes: Generated<number>;
280
+ /** Error info if failed */
281
+ error_message: string | null;
282
+ /** Labels used for agent routing (e.g. ["kici:os:linux", "kici:arch:x64"]). JSONB. */
283
+ runs_on_labels: string | null;
284
+ /** Last heartbeat received from agent (for stale run detection) */
285
+ last_heartbeat_at: Date | null;
286
+ /** JSON array of secret context names dispatched with this job */
287
+ dispatched_contexts: Generated<string>;
288
+ /** Aggregated step outputs JSONB (step-keyed map of outputs). Populated on job success. */
289
+ outputs: string | null;
290
+ /** Whether all upstream needs edges are satisfied (dispatch gate). */
291
+ needs_satisfied: Generated<boolean>;
292
+ /** Timestamp when needs_satisfied first flipped to true. */
293
+ ready_at: Date | null;
294
+ /** Dynamic group membership tag (NULL for static jobs). */
295
+ group_name: string | null;
296
+ /** When this record was created */
297
+ created_at: Generated<Date>;
298
+ /**
299
+ * Denormalized routing_key copied from execution_runs at insert time.
300
+ * Used by cold-store as the partition tenant. NULLable for safety —
301
+ * if an insert site doesn't populate it, the cold-store adapter
302
+ * skips the row.
303
+ */
304
+ routing_key: string | null;
305
+ /** Cold-store archive marker — see ExecutionRunTable.archived_at. */
306
+ archived_at: Date | null;
307
+ /** S3 object key of the chunk that carried this row. */
308
+ archive_object_key: string | null;
309
+ }
310
+ /**
311
+ * Execution step table
312
+ * Individual steps within a job.
313
+ */
314
+ export interface ExecutionStepTable {
315
+ /** UUID primary key */
316
+ id: Generated<string>;
317
+ /** References execution_runs.run_id */
318
+ run_id: string;
319
+ /** Job identifier */
320
+ job_id: string;
321
+ /** Step index within the job (0-based) */
322
+ step_index: number;
323
+ /** Step name */
324
+ step_name: string;
325
+ /** Step status: pending | running | success | failed | skipped */
326
+ status: Generated<string>;
327
+ /** When the step started */
328
+ started_at: Date | null;
329
+ /** When the step completed */
330
+ completed_at: Date | null;
331
+ /** Step execution duration in milliseconds */
332
+ duration_ms: number | null;
333
+ /** Process exit code */
334
+ exit_code: number | null;
335
+ /** Error info if failed */
336
+ error_message: string | null;
337
+ /** Path in storage backend (e.g. "executions/{runId}/job-test/step-0.log") */
338
+ log_path: string | null;
339
+ /** Step type: 'step' for regular steps, 'hook:onCancel', 'hook:cleanup', etc. for hooks */
340
+ step_type: Generated<string>;
341
+ /** JSON array of secret context names accessed by this step. NULL = tracking not available (old runs). */
342
+ secrets_accessed: string | null;
343
+ /** When this record was created */
344
+ created_at: Generated<Date>;
345
+ /**
346
+ * Denormalized routing_key copied from execution_runs at insert time.
347
+ * Used by cold-store as the partition tenant. NULLable for safety.
348
+ */
349
+ routing_key: string | null;
350
+ /** Cold-store archive marker — see ExecutionRunTable.archived_at. */
351
+ archived_at: Date | null;
352
+ /** S3 object key of the chunk that carried this row. */
353
+ archive_object_key: string | null;
354
+ }
355
+ export type ExecutionRun = Selectable<ExecutionRunTable>;
356
+ export type NewExecutionRun = Insertable<ExecutionRunTable>;
357
+ export type ExecutionRunUpdate = Updateable<ExecutionRunTable>;
358
+ export type ExecutionJob = Selectable<ExecutionJobTable>;
359
+ export type NewExecutionJob = Insertable<ExecutionJobTable>;
360
+ export type ExecutionJobUpdate = Updateable<ExecutionJobTable>;
361
+ export type ExecutionStep = Selectable<ExecutionStepTable>;
362
+ export type NewExecutionStep = Insertable<ExecutionStepTable>;
363
+ export type ExecutionStepUpdate = Updateable<ExecutionStepTable>;
364
+ /**
365
+ * Execution job needs edge table.
366
+ * One row per concrete dependency edge within a run.
367
+ * Static-to-static edges inserted at run start; group edges after resolution.
368
+ */
369
+ export interface ExecutionJobNeedsTable {
370
+ /** References execution_runs.run_id */
371
+ run_id: string;
372
+ /** Downstream job name (the job that depends on the upstream) */
373
+ job_name: string;
374
+ /** Upstream job name (the job that must complete first) */
375
+ upstream_name: string;
376
+ /** Per-edge failure policy: 'skip' (default) or 'run' */
377
+ if_failed: Generated<string>;
378
+ }
379
+ export type ExecutionJobNeeds = Selectable<ExecutionJobNeedsTable>;
380
+ export type NewExecutionJobNeeds = Insertable<ExecutionJobNeedsTable>;
381
+ /**
382
+ * Raft consensus state table
383
+ * Persistent state for Raft leader election across orchestrator cluster.
384
+ * Single row per cluster (default cluster_id = 'default').
385
+ */
386
+ export interface RaftStateTable {
387
+ /** Cluster identifier (primary key). Default 'default'. */
388
+ cluster_id: Generated<string>;
389
+ /** Current Raft term */
390
+ current_term: Generated<number>;
391
+ /** Instance ID this node voted for in the current term */
392
+ voted_for: string | null;
393
+ /** Current known leader instance ID */
394
+ leader_id: string | null;
395
+ /** When this state was last updated */
396
+ updated_at: Generated<Date>;
397
+ }
398
+ export type RaftState = Selectable<RaftStateTable>;
399
+ export type RaftStateUpdate = Updateable<RaftStateTable>;
400
+ /**
401
+ * Environments table
402
+ * Named deployment environments with concurrency, branch restrictions, and approval rules.
403
+ * Scoped to an organization.
404
+ */
405
+ export interface EnvironmentsTable {
406
+ /** UUID primary key */
407
+ id: Generated<string>;
408
+ /** Organization ID */
409
+ org_id: string;
410
+ /** Environment name (unique within org) */
411
+ name: string;
412
+ /** Environment type: 'fixed' | 'dynamic' */
413
+ type: Generated<string>;
414
+ /** Glob pattern for dynamic environments (null for fixed) */
415
+ glob_pattern: string | null;
416
+ /** JSONB array of branch restriction patterns */
417
+ branch_restrictions: Generated<string>;
418
+ /** JSONB array of trigger type filters */
419
+ trigger_type_filters: Generated<string>;
420
+ /** JSONB array of repo patterns */
421
+ repo_patterns: Generated<string>;
422
+ /** Max concurrent runs (null = unlimited) */
423
+ concurrency_limit: number | null;
424
+ /** Strategy when concurrency exceeded: 'queue' | 'cancel-pending' */
425
+ concurrency_strategy: Generated<string>;
426
+ /** Timeout for queued runs in milliseconds */
427
+ concurrency_timeout_ms: Generated<number>;
428
+ /** JSONB array of required reviewer identities (null = no approval required) */
429
+ required_reviewers: string | null;
430
+ /** Seconds to wait before deploying (null = no wait timer) */
431
+ wait_timer_seconds: number | null;
432
+ /** Seconds before a held run expires */
433
+ hold_expiry_seconds: Generated<number>;
434
+ /** Minimum trust tier required for CI execution (null = no trust requirement) */
435
+ minimum_trust: string | null;
436
+ /** Whether this environment allows local (no-remote) executions. Default false. */
437
+ allow_local_execution: Generated<boolean>;
438
+ /** Whether this environment is active */
439
+ enabled: Generated<boolean>;
440
+ /** When this environment was created */
441
+ created_at: Generated<Date>;
442
+ /** When this environment was last updated */
443
+ updated_at: Generated<Date>;
444
+ /** Who created this environment */
445
+ created_by: string | null;
446
+ }
447
+ export type Environment = Selectable<EnvironmentsTable>;
448
+ export type NewEnvironment = Insertable<EnvironmentsTable>;
449
+ export type EnvironmentUpdate = Updateable<EnvironmentsTable>;
450
+ /**
451
+ * Scoped secrets table
452
+ * Encrypted key-value pairs scoped to org + scope (e.g. environment name, repo pattern).
453
+ */
454
+ export interface ScopedSecretsTable {
455
+ /** UUID primary key */
456
+ id: Generated<string>;
457
+ /** Organization ID */
458
+ org_id: string;
459
+ /** Scope identifier (e.g. environment name, repo pattern) */
460
+ scope: string;
461
+ /** Secret key name */
462
+ key: string;
463
+ /** Encrypted secret value */
464
+ encrypted_value: string;
465
+ /** Backend type for secret storage (e.g. 'pg', 'vault') */
466
+ backend_type: Generated<string>;
467
+ /** Version of the encryption key used */
468
+ key_version: Generated<number>;
469
+ /** When this secret was created */
470
+ created_at: Generated<Date>;
471
+ /** When this secret was last updated */
472
+ updated_at: Generated<Date>;
473
+ }
474
+ export type ScopedSecret = Selectable<ScopedSecretsTable>;
475
+ export type NewScopedSecret = Insertable<ScopedSecretsTable>;
476
+ export type ScopedSecretUpdate = Updateable<ScopedSecretsTable>;
477
+ /**
478
+ * Environment bindings table
479
+ * Links environments to scope patterns (e.g. workflow names, repo identifiers).
480
+ */
481
+ export interface EnvironmentBindingsTable {
482
+ /** UUID primary key */
483
+ id: Generated<string>;
484
+ /** Organization ID */
485
+ org_id: string;
486
+ /** Environment ID (FK to environments.id, cascade delete) */
487
+ environment_id: string;
488
+ /** Scope pattern for matching (e.g. workflow name glob, repo pattern) */
489
+ scope_pattern: string;
490
+ /** When this binding was created */
491
+ created_at: Generated<Date>;
492
+ }
493
+ export type EnvironmentBinding = Selectable<EnvironmentBindingsTable>;
494
+ export type NewEnvironmentBinding = Insertable<EnvironmentBindingsTable>;
495
+ /**
496
+ * Environment variables table
497
+ * Non-secret key-value pairs attached to an environment.
498
+ */
499
+ export interface EnvironmentVariablesTable {
500
+ /** UUID primary key */
501
+ id: Generated<string>;
502
+ /** Organization ID */
503
+ org_id: string;
504
+ /** Environment ID (FK to environments.id, cascade delete) */
505
+ environment_id: string;
506
+ /** Variable key name */
507
+ key: string;
508
+ /** Variable value */
509
+ value: string;
510
+ /** Whether this variable is locked (cannot be overridden by workflow) */
511
+ locked: Generated<boolean>;
512
+ /** When this variable was created */
513
+ created_at: Generated<Date>;
514
+ /** When this variable was last updated */
515
+ updated_at: Generated<Date>;
516
+ }
517
+ export type EnvironmentVariable = Selectable<EnvironmentVariablesTable>;
518
+ export type NewEnvironmentVariable = Insertable<EnvironmentVariablesTable>;
519
+ export type EnvironmentVariableUpdate = Updateable<EnvironmentVariablesTable>;
520
+ /**
521
+ * Environment source overrides table
522
+ * Per-source (routing key) variable overrides within an environment.
523
+ */
524
+ export interface EnvironmentSourceOverridesTable {
525
+ /** UUID primary key */
526
+ id: Generated<string>;
527
+ /** Organization ID */
528
+ org_id: string;
529
+ /** Environment ID (FK to environments.id, cascade delete) */
530
+ environment_id: string;
531
+ /** Routing key for the source */
532
+ routing_key: string;
533
+ /** Override key name */
534
+ key: string;
535
+ /** Override value */
536
+ value: string;
537
+ /** When this override was created */
538
+ created_at: Generated<Date>;
539
+ /** When this override was last updated */
540
+ updated_at: Generated<Date>;
541
+ }
542
+ export type EnvironmentSourceOverride = Selectable<EnvironmentSourceOverridesTable>;
543
+ export type NewEnvironmentSourceOverride = Insertable<EnvironmentSourceOverridesTable>;
544
+ export type EnvironmentSourceOverrideUpdate = Updateable<EnvironmentSourceOverridesTable>;
545
+ /**
546
+ * Held runs table
547
+ * Tracks runs waiting for approval, wait timer, or concurrency slot.
548
+ */
549
+ export interface HeldRunsTable {
550
+ /** UUID primary key */
551
+ id: Generated<string>;
552
+ /** Organization ID */
553
+ org_id: string;
554
+ /** Run ID (references execution_runs) */
555
+ run_id: string;
556
+ /** Job ID within the run */
557
+ job_id: string;
558
+ /** Environment ID (FK to environments.id) */
559
+ environment_id: string;
560
+ /** Hold type: 'approval' | 'wait_timer' | 'concurrency' */
561
+ hold_type: string;
562
+ /** Hold status: 'pending' | 'approved' | 'rejected' | 'expired' | 'released' */
563
+ status: Generated<string>;
564
+ /** Queue type: 'environment' | 'security' */
565
+ queue_type: Generated<string>;
566
+ /** Reason for hold or resolution */
567
+ reason: string | null;
568
+ /** Who approved/rejected this hold */
569
+ approved_by: string | null;
570
+ /** When this hold was created */
571
+ created_at: Generated<Date>;
572
+ /** When this hold expires */
573
+ expires_at: Date;
574
+ /** When this hold was resolved */
575
+ resolved_at: Date | null;
576
+ }
577
+ export type HeldRun = Selectable<HeldRunsTable>;
578
+ export type NewHeldRun = Insertable<HeldRunsTable>;
579
+ export type HeldRunUpdate = Updateable<HeldRunsTable>;
580
+ /**
581
+ * Secret audit log table
582
+ * Immutable log of secret access and denial events.
583
+ */
584
+ export interface SecretAuditLogTable {
585
+ /** UUID primary key */
586
+ id: Generated<string>;
587
+ /** When the event occurred */
588
+ timestamp: Generated<Date>;
589
+ /** The action performed (e.g., 'getSecrets', 'setSecret') */
590
+ action: string;
591
+ /** The context name involved */
592
+ context_name: string;
593
+ /** Routing key scope */
594
+ routing_key: string | null;
595
+ /** Secret keys involved (JSON array) */
596
+ secret_keys: string | null;
597
+ /** Whether the operation was allowed or denied */
598
+ outcome: string;
599
+ /** CI run ID if applicable */
600
+ run_id: string | null;
601
+ /** Job ID if applicable */
602
+ job_id: string | null;
603
+ /** User ID if applicable */
604
+ user_id: string | null;
605
+ /** User role if applicable */
606
+ role: string | null;
607
+ /** Additional metadata (JSON) */
608
+ metadata: string | null;
609
+ /**
610
+ * Set inside the archive transaction before the row is DELETEd.
611
+ * Survivors carry NULL. See cold-storage Phase D notes.
612
+ */
613
+ archived_at: Date | null;
614
+ /** S3 object key of the chunk that carried this row; see `archived_at`. */
615
+ archive_object_key: string | null;
616
+ }
617
+ export type SecretAuditLogRow = Selectable<SecretAuditLogTable>;
618
+ export type NewSecretAuditLogRow = Insertable<SecretAuditLogTable>;
619
+ /**
620
+ * Access log table.
621
+ * One row per read or orchestrator-admin mutation attributable to an
622
+ * ActorPrincipal (user / api_key / service_account / platform_operator /
623
+ * system). TTL-pruned via expires_at by the cleanup job.
624
+ */
625
+ export interface AccessLogTable {
626
+ id: Generated<string>;
627
+ org_id: string | null;
628
+ routing_key: string | null;
629
+ actor_type: string;
630
+ actor_id: string;
631
+ actor_meta: ColumnType<Record<string, unknown> | null, unknown, unknown>;
632
+ action: string;
633
+ target_type: string | null;
634
+ target_id: string | null;
635
+ request_id: string | null;
636
+ source: string;
637
+ outcome: string;
638
+ error_message: string | null;
639
+ created_at: Generated<Date>;
640
+ /**
641
+ * Set inside the archive transaction before the row is DELETEd.
642
+ * Survivors carry NULL. See cold-storage Phase D notes.
643
+ * Phase D removed the previous `expires_at`-based TTL — rows older
644
+ * than 30 days are archived to S3 instead of hard-deleted.
645
+ */
646
+ archived_at: Date | null;
647
+ /** S3 object key of the chunk that carried this row; see `archived_at`. */
648
+ archive_object_key: string | null;
649
+ }
650
+ export type AccessLogRow = Selectable<AccessLogTable>;
651
+ export type NewAccessLogRow = Insertable<AccessLogTable>;
652
+ /**
653
+ * Admin tokens table
654
+ * Hashed tokens for admin API authentication with role-based access.
655
+ */
656
+ export interface AdminTokenTable {
657
+ /** UUID primary key */
658
+ id: Generated<string>;
659
+ /** SHA-256 hash of the token */
660
+ token_hash: string;
661
+ /** Human-readable label */
662
+ label: string;
663
+ /** Role (e.g. 'admin', 'reader') */
664
+ role: string;
665
+ /** Routing key scope (null = all) */
666
+ routing_key: string | null;
667
+ /** When this token was created */
668
+ created_at: Generated<Date>;
669
+ /** When this token expires (null = never) */
670
+ expires_at: Date | null;
671
+ /** When this token was last used */
672
+ last_used_at: Date | null;
673
+ /** Whether this token has been revoked */
674
+ revoked: Generated<boolean>;
675
+ }
676
+ export type AdminTokenRow = Selectable<AdminTokenTable>;
677
+ export type NewAdminTokenRow = Insertable<AdminTokenTable>;
678
+ /**
679
+ * Agent tokens table
680
+ * Hashed tokens for agent authentication (PSK-based).
681
+ * Supports static (long-lived, CLI-created) and ephemeral (scaler-issued, TTL-bound) tokens.
682
+ */
683
+ export interface AgentTokenTable {
684
+ /** UUID primary key */
685
+ id: Generated<string>;
686
+ /** SHA-256 hash of the token */
687
+ token_hash: string;
688
+ /** Token prefix for identification (e.g. "kat_a1b2c3d4") */
689
+ token_prefix: string;
690
+ /** JSON-encoded string[] of agent labels (null = any) */
691
+ labels: string | null;
692
+ /** Token type: 'ephemeral' (scaler-issued) or 'static' (CLI-created) */
693
+ agent_type: string;
694
+ /** When this token was created */
695
+ created_at: Generated<Date>;
696
+ /** When this token was last used for authentication */
697
+ last_seen_at: Date | null;
698
+ /** Who/what created this token (e.g. "cli:admin", "scaler:container-linux-x64") */
699
+ created_by: string | null;
700
+ /** When this token was revoked (null = active) */
701
+ revoked_at: Date | null;
702
+ /** When this token expires (null = never, static tokens) */
703
+ expires_at: Date | null;
704
+ }
705
+ export type AgentTokenRow = Selectable<AgentTokenTable>;
706
+ export type NewAgentTokenRow = Insertable<AgentTokenTable>;
707
+ /**
708
+ * Config versions table
709
+ * Stores versioned JSONB config snapshots with audit trail.
710
+ * Each config change creates a new version with auto-incrementing version number.
711
+ * Sensitive fields are encrypted and tracked via encrypted_paths array.
712
+ */
713
+ export interface ConfigVersionTable {
714
+ /** UUID primary key */
715
+ id: Generated<string>;
716
+ /** Auto-incrementing version number (SERIAL) */
717
+ version: Generated<number>;
718
+ /** Full config snapshot as JSONB */
719
+ config: string;
720
+ /** When this version was created */
721
+ created_at: Generated<Date>;
722
+ /** Who created this version (e.g. "cli:seed", "api:set", "api:rollback") */
723
+ created_by: string;
724
+ /** Human-readable description of the change */
725
+ description: string | null;
726
+ /** JSONB paths that contain encrypted values */
727
+ encrypted_paths: Generated<string[]>;
728
+ /**
729
+ * Master-key generation used to encrypt this row's sensitive fields.
730
+ * Bumped atomically by `kici-admin rotate-key`; decrypt path accepts
731
+ * both the current and the previous generation during a grace window.
732
+ */
733
+ key_version: Generated<number>;
734
+ }
735
+ export type ConfigVersionRow = Selectable<ConfigVersionTable>;
736
+ export type NewConfigVersionRow = Insertable<ConfigVersionTable>;
737
+ /**
738
+ * Internal events table (kici_events)
739
+ * Persists internal events (system + custom) for routing, circuit-breaking, and audit.
740
+ * Events have a TTL-based expiry for automatic cleanup.
741
+ */
742
+ export interface KiciEventTable {
743
+ /** UUID primary key */
744
+ id: Generated<string>;
745
+ /** Event name (e.g. 'deploy-complete', '__workflow_complete', '__job_complete') */
746
+ event_name: string;
747
+ /** Event payload (JSONB) */
748
+ payload: string;
749
+ /** Source repo identifier (null for non-repo events) */
750
+ source_repo: string | null;
751
+ /** Source routing key */
752
+ source_routing_key: string | null;
753
+ /** Run ID that emitted this event */
754
+ source_run_id: string | null;
755
+ /** Job ID that emitted this event */
756
+ source_job_id: string | null;
757
+ /** Event chain depth for circuit breaker (0 = original, incremented at each hop) */
758
+ chain_depth: Generated<number>;
759
+ /** Whether all subscribers have processed this event */
760
+ processed: Generated<boolean>;
761
+ /** When this event was created */
762
+ created_at: Generated<Date>;
763
+ /** When this event expires (TTL-based cleanup) */
764
+ expires_at: Date;
765
+ /** Optional target repos for cross-repo event targeting (JSONB string[] or null) */
766
+ target_repos: string | null;
767
+ /** When the current lease was taken (NULL = unleased / available for claim) */
768
+ claimed_at: Date | null;
769
+ /** Node id holding the current lease (for diagnostics; not part of the lease check) */
770
+ claimed_by: string | null;
771
+ /** Number of times this event has been leased for processing */
772
+ attempts: Generated<number>;
773
+ /** Most recent dispatch failure message (truncated to 4 KB by application code) */
774
+ last_error: string | null;
775
+ /** Earliest moment the leader-only retry scanner should re-publish pg_notify */
776
+ next_retry_at: Date | null;
777
+ /** When the event entered the DLQ (NULL = not in DLQ) */
778
+ dlq_at: Date | null;
779
+ /** Short DLQ reason: 'exhausted_retries' | 'non_retryable' */
780
+ dlq_reason: string | null;
781
+ }
782
+ export type KiciEvent = Selectable<KiciEventTable>;
783
+ export type NewKiciEvent = Insertable<KiciEventTable>;
784
+ export type KiciEventUpdate = Updateable<KiciEventTable>;
785
+ /**
786
+ * Generic webhook sources table (generic_webhook_sources)
787
+ * Stores per-source verification config, event extraction rules, and rate limits
788
+ * for non-GitHub webhook sources.
789
+ */
790
+ export interface GenericWebhookSourceTable {
791
+ /** UUID primary key */
792
+ id: Generated<string>;
793
+ /** Customer/tenant identifier */
794
+ customer_id: string;
795
+ /** Human-readable source name (unique within customer when not deleted) */
796
+ name: string;
797
+ /** Routing key for this source (e.g. 'generic:<customer_id>:<source_id>') */
798
+ routing_key: string;
799
+ /** Verification method: 'hmac_sha256' | 'bearer_token' | 'ip_allowlist' | 'none' */
800
+ verification_method: Generated<string>;
801
+ /** Verification config (JSONB): { secret, algorithm } | { token } | { allowlist } | {} */
802
+ verification_config: Generated<string>;
803
+ /** Header name to extract event type from (default: 'X-Event-Type') */
804
+ event_type_header: string | null;
805
+ /** JSONPath expression to extract event type from payload body */
806
+ event_type_path: string | null;
807
+ /** Header name for idempotency key */
808
+ idempotency_key_header: string | null;
809
+ /** JSONPath expression for idempotency key from body */
810
+ idempotency_key_path: string | null;
811
+ /** Dedup window in seconds (default: 300 = 5 min) */
812
+ dedup_window_seconds: Generated<number>;
813
+ /** Maximum payload size in bytes (default: 1048576 = 1MB) */
814
+ max_payload_bytes: Generated<number>;
815
+ /** JSON array of allowed event types (null = all) */
816
+ allowed_events: string | null;
817
+ /** JSON array of sensitive headers to strip (default: auth-related headers) */
818
+ strip_headers: Generated<string>;
819
+ /** Whether this source is active */
820
+ enabled: Generated<boolean>;
821
+ /** Token bucket rate limit: requests per minute */
822
+ rate_limit_rpm: Generated<number>;
823
+ /** When this source was created */
824
+ created_at: Generated<Date>;
825
+ /** When this source was last updated */
826
+ updated_at: Generated<Date>;
827
+ /** Soft-delete marker (null = active) */
828
+ deleted_at: Date | null;
829
+ /** Provider implementation to route this source through.
830
+ * 'generic' (default) → GenericWebhookNormalizer (Stripe-shaped payloads).
831
+ * 'internal' → InternalWebhookNormalizer (github-shaped push/PR payloads
832
+ * for E2E tests and the staging smoke test). */
833
+ provider_type: Generated<string>;
834
+ /** Universal-git config (JSONB) for sources that also know how to build
835
+ * clone URLs, fetch lock files, and issue clone credentials against a
836
+ * user-supplied git server (Forgejo / Gitea / Gogs / GitLab repo-webhook /
837
+ * plain GitHub repo-webhook). null for legacy generic / internal sources
838
+ * that don't drive git operations. Shape validated by
839
+ * `UniversalGitConfigSchema` at the application layer. */
840
+ git_config: ColumnType<string | Record<string, unknown> | null, string | null, string | null>;
841
+ }
842
+ export type GenericWebhookSource = Selectable<GenericWebhookSourceTable>;
843
+ export type NewGenericWebhookSource = Insertable<GenericWebhookSourceTable>;
844
+ export type GenericWebhookSourceUpdate = Updateable<GenericWebhookSourceTable>;
845
+ /**
846
+ * Cross-repo trust table (cross_repo_trust)
847
+ * Bidirectional trust relationships for cross-repo event delivery.
848
+ * Both source and target must declare trust for delivery to proceed.
849
+ */
850
+ export interface CrossRepoTrustTable {
851
+ /** UUID primary key */
852
+ id: Generated<string>;
853
+ /** Source repo that is trusted to emit events */
854
+ source_repo: string;
855
+ /** Source routing key */
856
+ source_routing_key: string;
857
+ /** Target repo that accepts events from source */
858
+ target_repo: string;
859
+ /** Target routing key */
860
+ target_routing_key: string;
861
+ /** JSON array of event name glob patterns allowed (null = all) */
862
+ allowed_events: string | null;
863
+ /** Whether this trust relationship is active */
864
+ enabled: Generated<boolean>;
865
+ /** When this trust relationship was created */
866
+ created_at: Generated<Date>;
867
+ }
868
+ export type CrossRepoTrust = Selectable<CrossRepoTrustTable>;
869
+ export type NewCrossRepoTrust = Insertable<CrossRepoTrustTable>;
870
+ export type CrossRepoTrustUpdate = Updateable<CrossRepoTrustTable>;
871
+ /**
872
+ * Test uploads table (test_uploads)
873
+ * Tracks CLI code uploads for remote test runs.
874
+ * Uploads are temporary (24h TTL) and cleaned up by a periodic job.
875
+ */
876
+ export interface TestUploadsTable {
877
+ /** UUID primary key */
878
+ id: Generated<string>;
879
+ /** Client-facing upload ID */
880
+ upload_id: string;
881
+ /** Routing key for this upload */
882
+ routing_key: string;
883
+ /** Git SHA from the upload */
884
+ sha: string | null;
885
+ /** Number of files in the upload */
886
+ file_count: number | null;
887
+ /** Compressed size in bytes */
888
+ compressed_size: number | null;
889
+ /** S3 object key for the uploaded tarball */
890
+ storage_key: string;
891
+ /** Ephemeral private key for decryption (stored encrypted with master key) */
892
+ encryption_private_key: string | null;
893
+ /** Upload status: pending | uploaded | dispatched | expired */
894
+ status: Generated<string>;
895
+ /** When this upload was created */
896
+ created_at: Generated<Date>;
897
+ /** When this upload expires (24h from creation) */
898
+ expires_at: Date;
899
+ /** Token identifier of the uploader */
900
+ created_by: string | null;
901
+ }
902
+ export type TestUpload = Selectable<TestUploadsTable>;
903
+ export type NewTestUpload = Insertable<TestUploadsTable>;
904
+ export type TestUploadUpdate = Updateable<TestUploadsTable>;
905
+ /**
906
+ * Workflow registrations table
907
+ * Per-workflow rows with full lock entry and trigger type index.
908
+ * Each registration is unique per (routing_key, repo, workflow).
909
+ */
910
+ export interface WorkflowRegistrationsTable {
911
+ /** UUID primary key */
912
+ id: Generated<string>;
913
+ /** Repository identifier (e.g. "owner/repo") */
914
+ repo_identifier: string;
915
+ /** Workflow name from lock file */
916
+ workflow_name: string;
917
+ /** Full workflow lock file entry (JSONB) */
918
+ lock_entry: string;
919
+ /** Array of trigger type strings for GIN index queries */
920
+ trigger_types: string[];
921
+ /** Routing key that created this registration (e.g. "github:42") */
922
+ routing_key: Generated<string>;
923
+ /** Provider-specific context captured at registration time (e.g. { installationId }) */
924
+ provider_context: Generated<string>;
925
+ /** Whether this workflow registration is disabled (skipped during trigger matching) */
926
+ disabled: ColumnType<boolean, boolean | undefined, boolean>;
927
+ /** Git commit SHA from the push that last updated this registration */
928
+ commit_sha: ColumnType<string | null, string | null | undefined, string | null>;
929
+ /** Source file path for this workflow (e.g. ".kici/workflows/deploy.ts") */
930
+ source_file: ColumnType<string | null, string | null | undefined, string | null>;
931
+ /** Whether this is a global workflow (triggers across all repos under same routing key) */
932
+ is_global: ColumnType<boolean, boolean | undefined, boolean>;
933
+ /**
934
+ * Customer/org ID that owns this registration. Backfilled from the source row
935
+ * (sources or generic_webhook_sources joined on routing_key) by migration 020,
936
+ * NOT NULL after backfill. Used by the cross-source webhook lookup index
937
+ * (RegistrationIndex.byOrgAndEvent) to enforce org isolation.
938
+ *
939
+ * Required on insert (no DB default — migration 020 enforces NOT NULL);
940
+ * Updateable type allows omission so the existing replaceAll UPDATE branch
941
+ * (which preserves the existing customer_id alongside the rest of the row)
942
+ * can keep its current shape.
943
+ */
944
+ customer_id: ColumnType<string, string, string | undefined>;
945
+ /** When this registration was created */
946
+ created_at: Generated<Date>;
947
+ /** When this registration was last updated */
948
+ updated_at: Generated<Date>;
949
+ }
950
+ export type WorkflowRegistration = Selectable<WorkflowRegistrationsTable>;
951
+ export type NewWorkflowRegistration = Insertable<WorkflowRegistrationsTable>;
952
+ export type WorkflowRegistrationUpdate = Updateable<WorkflowRegistrationsTable>;
953
+ /**
954
+ * Registry versions table
955
+ * Cluster sync version counter. Incremented on registration changes.
956
+ * Default row with id='default' inserted by migration.
957
+ */
958
+ export interface RegistryVersionsTable {
959
+ /** Version identifier (default: 'default') */
960
+ id: Generated<string>;
961
+ /** Monotonically increasing version counter */
962
+ version: Generated<number>;
963
+ /** When the version was last bumped */
964
+ updated_at: Generated<Date>;
965
+ }
966
+ export type RegistryVersion = Selectable<RegistryVersionsTable>;
967
+ export type RegistryVersionUpdate = Updateable<RegistryVersionsTable>;
968
+ /**
969
+ * Cron last-fired table
970
+ * Tracks the last time each cron-triggered workflow registration fired.
971
+ * Used for fire-once-on-recovery after orchestrator restart.
972
+ */
973
+ export interface CronLastFiredTable {
974
+ /** References workflow_registrations.id (cascade delete) */
975
+ registration_id: string;
976
+ /** When this cron trigger last fired */
977
+ last_fired_at: Date;
978
+ /** When this record was last updated */
979
+ updated_at: Generated<Date>;
980
+ }
981
+ export type CronLastFired = Selectable<CronLastFiredTable>;
982
+ export type NewCronLastFired = Insertable<CronLastFiredTable>;
983
+ export type CronLastFiredUpdate = Updateable<CronLastFiredTable>;
984
+ /**
985
+ * Run ephemeral keys table (run_ephemeral_keys)
986
+ * Stores per-run X25519 key pairs for cross-job secret output encryption.
987
+ * Private keys are encrypted with the orchestrator PSK (AES-256-GCM).
988
+ */
989
+ export interface RunEphemeralKeysTable {
990
+ /** Run ID (primary key, references execution_runs.run_id) */
991
+ run_id: string;
992
+ /** Base64-encoded AES-256-GCM encrypted private key */
993
+ encrypted_private_key: string;
994
+ /** Base64-encoded DER public key (X25519 SPKI format) */
995
+ public_key: string;
996
+ /** When this key pair was created */
997
+ created_at: Generated<Date>;
998
+ }
999
+ export type RunEphemeralKey = Selectable<RunEphemeralKeysTable>;
1000
+ export type NewRunEphemeralKey = Insertable<RunEphemeralKeysTable>;
1001
+ /**
1002
+ * Run secret outputs table (run_secret_outputs)
1003
+ * Stores encrypted secret output values produced by jobs for cross-job consumption.
1004
+ * Values are encrypted with the run's ephemeral public key via ECDH + AES-256-GCM.
1005
+ */
1006
+ export interface RunSecretOutputsTable {
1007
+ /** UUID primary key */
1008
+ id: Generated<string>;
1009
+ /** Run ID (references execution_runs.run_id) */
1010
+ run_id: string;
1011
+ /** Job ID that produced this output */
1012
+ job_id: string;
1013
+ /** Output key name */
1014
+ output_key: string;
1015
+ /** Base64-encoded encrypted value (agent-encrypted ECDH envelope) */
1016
+ encrypted_value: string;
1017
+ /** When this output was stored */
1018
+ created_at: Generated<Date>;
1019
+ }
1020
+ export type RunSecretOutput = Selectable<RunSecretOutputsTable>;
1021
+ export type NewRunSecretOutput = Insertable<RunSecretOutputsTable>;
1022
+ /**
1023
+ * Concurrency groups table (concurrency_groups)
1024
+ * Tracks active and queued runs per concurrency group for slot management.
1025
+ * Persists across orchestrator restarts; hydrated into in-memory tracker on startup.
1026
+ */
1027
+ export interface ConcurrencyGroupsTable {
1028
+ /** UUID primary key */
1029
+ id: Generated<string>;
1030
+ /** Concurrency group key (e.g. "deploy-main") */
1031
+ group_key: string;
1032
+ /** Run ID that owns this slot or is queued */
1033
+ run_id: string;
1034
+ /** Job ID within the run */
1035
+ job_id: string;
1036
+ /** Routing key for scoping (e.g. "github:42") */
1037
+ routing_key: string;
1038
+ /** Status: 'active' | 'queued' | 'completed' | 'cancelled' */
1039
+ status: Generated<string>;
1040
+ /** When this entry was created */
1041
+ created_at: Generated<Date>;
1042
+ /** When this entry was completed/cancelled */
1043
+ completed_at: Date | null;
1044
+ }
1045
+ export type ConcurrencyGroup = Selectable<ConcurrencyGroupsTable>;
1046
+ export type NewConcurrencyGroup = Insertable<ConcurrencyGroupsTable>;
1047
+ export type ConcurrencyGroupUpdate = Updateable<ConcurrencyGroupsTable>;
1048
+ /**
1049
+ * Sources table
1050
+ * Stores webhook source configurations (e.g. GitHub Apps) with routing keys.
1051
+ * Secrets (private key, webhook secret) are stored separately in PgSecretStore.
1052
+ */
1053
+ export interface SourcesTable {
1054
+ /** UUID primary key */
1055
+ id: Generated<string>;
1056
+ /** Provider type (e.g. 'github') */
1057
+ provider: string;
1058
+ /** Human-readable source name */
1059
+ name: string;
1060
+ /** Routing key (e.g. 'github:12345') */
1061
+ routing_key: string;
1062
+ /** JSONB config (non-sensitive, e.g. { appId: '12345' }) */
1063
+ config: string;
1064
+ /** Customer/org identifier for secret and environment scoping */
1065
+ customer_id: Generated<string>;
1066
+ /** When this source was created */
1067
+ created_at: Generated<Date>;
1068
+ /** When this source was last updated */
1069
+ updated_at: Generated<Date>;
1070
+ }
1071
+ export type Source = Selectable<SourcesTable>;
1072
+ export type NewSource = Insertable<SourcesTable>;
1073
+ export type SourceUpdate = Updateable<SourcesTable>;
1074
+ /**
1075
+ * Repo-pattern entry stored inside the three jsonb list columns of
1076
+ * `org_settings`. `routingKey` is optional — when undefined the entry
1077
+ * applies to any source in the org; when set, it qualifies the entry to
1078
+ * one specific webhook source.
1079
+ */
1080
+ export interface OrgSettingsRepoPatternEntry {
1081
+ routingKey?: string;
1082
+ pattern: string;
1083
+ }
1084
+ /**
1085
+ * Org settings table (org_settings)
1086
+ * Per-org (customer_id) global workflow permissions. Each list column
1087
+ * holds a jsonb array of {routingKey?, pattern} entries — entries without
1088
+ * a `routingKey` apply to any source in the org, entries with a routing
1089
+ * key are scoped to that source only.
1090
+ */
1091
+ export interface OrgSettingsTable {
1092
+ /** Customer/org identifier (primary key) */
1093
+ customer_id: string;
1094
+ /** Whether global workflows are enabled for this org */
1095
+ global_workflows_enabled: ColumnType<boolean, boolean | undefined, boolean>;
1096
+ /** Repos allowed to author global workflows (null = any repo can author) */
1097
+ global_workflow_allowed_repos: ColumnType<OrgSettingsRepoPatternEntry[] | null, OrgSettingsRepoPatternEntry[] | null | undefined | string, OrgSettingsRepoPatternEntry[] | null | string>;
1098
+ /** Repos with elevated trust for global workflow execution (null = none) */
1099
+ global_workflow_elevated_repos: ColumnType<OrgSettingsRepoPatternEntry[] | null, OrgSettingsRepoPatternEntry[] | null | undefined | string, OrgSettingsRepoPatternEntry[] | null | string>;
1100
+ /**
1101
+ * Repos explicitly denied as event sources for global workflows.
1102
+ * Deny takes precedence over the allow-list (null = no deny patterns).
1103
+ */
1104
+ global_workflow_denied_repos: ColumnType<OrgSettingsRepoPatternEntry[] | null, OrgSettingsRepoPatternEntry[] | null | undefined | string, OrgSettingsRepoPatternEntry[] | null | string>;
1105
+ /**
1106
+ * When true, workflow `registries:` URLs may use plain `http://` to any host.
1107
+ * When false (default), only `https://` and loopback / `*.local` `http://`
1108
+ * URLs are accepted; arbitrary `http://` registries are rejected at dispatch.
1109
+ */
1110
+ allow_http_npm_registries: ColumnType<boolean, boolean | undefined, boolean>;
1111
+ /** When this setting was created */
1112
+ created_at: Generated<Date>;
1113
+ /** When this setting was last updated */
1114
+ updated_at: Generated<Date>;
1115
+ }
1116
+ export type OrgSettings = Selectable<OrgSettingsTable>;
1117
+ export type NewOrgSettings = Insertable<OrgSettingsTable>;
1118
+ export type OrgSettingsUpdate = Updateable<OrgSettingsTable>;
1119
+ /**
1120
+ * Pending job contexts table
1121
+ * Persists PendingJobContext for crash-recovery of needs-gated jobs.
1122
+ * Keyed by (run_id, job_name) matching the in-memory Map key format.
1123
+ * Rows are created at storePendingJobContext time, deleted on consume or run completion.
1124
+ */
1125
+ export interface PendingJobContextsTable {
1126
+ /** Run identifier */
1127
+ run_id: string;
1128
+ /** Job name within the workflow */
1129
+ job_name: string;
1130
+ /** Full QueuedJobInput serialized as JSONB */
1131
+ job_input: ColumnType<Record<string, unknown>, string, string>;
1132
+ /** string[] of labels serialized as JSONB */
1133
+ runs_on_labels: ColumnType<string[], string, string>;
1134
+ /** When this context was stored */
1135
+ created_at: Generated<Date>;
1136
+ }
1137
+ export type PendingJobContextRow = Selectable<PendingJobContextsTable>;
1138
+ export type NewPendingJobContext = Insertable<PendingJobContextsTable>;
1139
+ /**
1140
+ * Inbound webhook delivery event log table.
1141
+ * One row per inbound webhook delivery (relay or direct), regardless of
1142
+ * outcome. Joins with the Platform-side `event_log` on `(org_id, delivery_id)`.
1143
+ *
1144
+ * Payload bytes live in object storage (LogStorage) at `payload_key`. When
1145
+ * `payload_omitted=true`, the payload was not stored (size cap or upload
1146
+ * failure) -- the metadata + hash + size are still durable for correlation.
1147
+ *
1148
+ * Retention: 30 days, cleaned by queue/cleanup.ts.
1149
+ */
1150
+ export interface EventLogTable {
1151
+ /** UUID primary key */
1152
+ id: Generated<string>;
1153
+ /** Tenant ID (12-char NanoID) */
1154
+ org_id: string;
1155
+ /** Provider delivery ID (unique within org) */
1156
+ delivery_id: string;
1157
+ /** Routing key (e.g. "github:42", "generic:<org>:<src>", "internal:...") */
1158
+ routing_key: string;
1159
+ /** Provider event name (X-GitHub-Event / X-Event-Type / 'default') */
1160
+ event: string;
1161
+ /** payload.action when present */
1162
+ action: string | null;
1163
+ /** Where the delivery arrived: 'relay' (Platform WS) or 'direct' (HTTP) */
1164
+ source: string;
1165
+ /** Provider type ('github' / 'generic' / 'internal') */
1166
+ provider: string;
1167
+ /** owner/repo when extractable */
1168
+ repo_identifier: string | null;
1169
+ /** Best-effort ref/branch */
1170
+ ref: string | null;
1171
+ /** Object-storage key under LogStorage. NULL when payload_omitted=true. */
1172
+ payload_key: string | null;
1173
+ /** True when payload was not stored (size cap or upload failure) */
1174
+ payload_omitted: Generated<boolean>;
1175
+ /** 'size_exceeded' | 'storage_failed' | NULL */
1176
+ payload_omitted_reason: string | null;
1177
+ /** Actual body byte size (pre-gzip) */
1178
+ payload_size_bytes: number;
1179
+ /** SHA-256 of raw body, identical algorithm to Platform event_log.payload_hash */
1180
+ payload_hash: string;
1181
+ /** Workflows matched by trigger evaluation (0 = no match) */
1182
+ matched_count: Generated<number>;
1183
+ /** 'received' | 'processed' | 'duplicate' | 'lockfile_missing' | 'failed' */
1184
+ status: string;
1185
+ /** First run spawned by this delivery (if any) */
1186
+ run_id: string | null;
1187
+ /** Failure reason when status='failed' */
1188
+ error_message: string | null;
1189
+ /** When the delivery was received */
1190
+ received_at: Generated<Date>;
1191
+ /** Phase E cold-store: set inside the archive transaction; NULL for hot rows. */
1192
+ archived_at: Date | null;
1193
+ /** Phase E cold-store: chunk object key when row is archived. */
1194
+ archive_object_key: string | null;
1195
+ }
1196
+ export type EventLogRow = Selectable<EventLogTable>;
1197
+ export type NewEventLogRow = Insertable<EventLogTable>;
1198
+ export type EventLogRowUpdate = Updateable<EventLogTable>;
1199
+ /**
1200
+ * Cold-store chunk counts table (cold_store_chunk_counts).
1201
+ * Tracks per-(db, table, tenant) archived-chunk metadata so the
1202
+ * `cold_store_chunks_total` gauge and the `kici-admin cold-store list-chunks`
1203
+ * CLI can report totals without S3 LIST calls. Phase A creates the table
1204
+ * empty; Phase B+ populates it transactionally on each chunk write.
1205
+ */
1206
+ export interface ColdStoreChunkCountsTable {
1207
+ /** DbKind identifier ('orchestrator' on this side). */
1208
+ db: string;
1209
+ /** Source Postgres table name. */
1210
+ table_name: string;
1211
+ /** org_id for Platform tables, routing_key for Orchestrator tables. */
1212
+ tenant_id: string;
1213
+ /** Number of chunks written for this (db, table, tenant). */
1214
+ chunk_count: Generated<ColumnType<string, string | number, string | number>>;
1215
+ /** Total uncompressed bytes archived. */
1216
+ total_bytes: Generated<ColumnType<string, string | number, string | number>>;
1217
+ /** Total rows archived. */
1218
+ total_rows: Generated<ColumnType<string, string | number, string | number>>;
1219
+ /** Most recent chunk archive time; null until first chunk lands. */
1220
+ last_archived_at: Date | null;
1221
+ }
1222
+ export type ColdStoreChunkCountsRow = Selectable<ColdStoreChunkCountsTable>;
1223
+ export type NewColdStoreChunkCountsRow = Insertable<ColdStoreChunkCountsTable>;
1224
+ export type ColdStoreChunkCountsUpdate = Updateable<ColdStoreChunkCountsTable>;
1225
+ /**
1226
+ * Cold-store chunk index (cold_store_chunks). Phase 2.
1227
+ *
1228
+ * One row per archived chunk that the GC sweep can later purge from S3.
1229
+ * Inserted inside `markArchivedAndDelete`'s transaction by adapters that
1230
+ * opt into the per-bucket layout via `coldTtlDays(row)`. Pre-Phase-2
1231
+ * (v1) chunks are NOT in this table — they're treated as
1232
+ * `'forever'` and never purged.
1233
+ */
1234
+ export interface ColdStoreChunksTable {
1235
+ /** DbKind identifier ('orchestrator' on this side). */
1236
+ db: string;
1237
+ /** Source Postgres table name. */
1238
+ table_name: string;
1239
+ /** org_id for Platform-keyed adapters, routing_key for Orchestrator. */
1240
+ tenant_id: string;
1241
+ /** Deterministic 16-hex chunk filename stem (matches the S3 object). */
1242
+ chunk_id: string;
1243
+ /** S3 prefix segment ('30d' / '180d' / '1y' / '2y' / 'forever'). */
1244
+ bucket: string;
1245
+ /** YYYY-MM-DD partition the chunk's rows came from. */
1246
+ partition_date: ColumnType<Date, string, string>;
1247
+ /** When the chunk landed in S3 + this row was inserted. */
1248
+ archived_at: Generated<Date>;
1249
+ /** Compressed size of the data chunk (bytes). */
1250
+ gzip_bytes: ColumnType<string, string | number, string | number>;
1251
+ /** Number of rows in the chunk. */
1252
+ row_count: ColumnType<string, string | number, string | number>;
1253
+ /**
1254
+ * Row-level cold-retention horizon — TEXT to accommodate both numeric
1255
+ * day-counts and the literal `'forever'`. The GC sweep checks
1256
+ * `max_cold_days != 'forever' AND now() > archived_at + max_cold_days
1257
+ * * INTERVAL '1 day'`.
1258
+ */
1259
+ max_cold_days: string;
1260
+ /** Full S3 key of the data chunk (used by the GC sweep's DeleteObject). */
1261
+ object_key: string;
1262
+ }
1263
+ export type ColdStoreChunksRow = Selectable<ColdStoreChunksTable>;
1264
+ export type NewColdStoreChunksRow = Insertable<ColdStoreChunksTable>;
1265
+ export type ColdStoreChunksUpdate = Updateable<ColdStoreChunksTable>;
1266
+ //# sourceMappingURL=types.d.ts.map