@kici-dev/orchestrator 0.0.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 -7
  341. package/sbom.spdx.json +14370 -0
  342. package/index.js +0 -3
@@ -0,0 +1,326 @@
1
+ /**
2
+ * Core webhook processing pipeline.
3
+ *
4
+ * Connects all orchestrator modules into a complete processing flow:
5
+ * dedup -> normalize event -> fetch lock file -> get changed files ->
6
+ * match triggers -> cache check -> dispatch jobs
7
+ *
8
+ * Uses the ProviderRegistry for all provider-specific operations.
9
+ * No direct GitHub/Octokit references -- fully provider-agnostic.
10
+ *
11
+ * Decision traces are forwarded to Platform via platformClient.send() (which buffers
12
+ * internally when disconnected -- the caller does NOT check connection state).
13
+ */
14
+ import { type Kysely } from 'kysely';
15
+ import type { Database } from '../db/types.js';
16
+ import type { WebhookInfo } from '../webhook/handler.js';
17
+ import type { DedupCache } from '../webhook/dedup.js';
18
+ import type { ProviderRegistry, ProviderBundle } from '../provider-registry.js';
19
+ import type { LockFileCache } from '../lockfile-cache.js';
20
+ import type { Dispatcher } from '../agent/dispatcher.js';
21
+ import type { PlatformClient } from '../ws/platform-client.js';
22
+ import type { QueuedJobInput } from '../queue/job-queue.js';
23
+ import type { SourceCache } from '../cache/index.js';
24
+ import type { BuildCoordinator } from '../cache/index.js';
25
+ import type { DepCache } from '../cache/index.js';
26
+ import type { PendingBuildTracker } from '../cache/index.js';
27
+ import type { PendingInitTracker } from '../cache/pending-inits.js';
28
+ import type { PendingDynamicTracker } from '../cache/pending-dynamics.js';
29
+ import type { CommitStatusReporter } from '../reporting/commit-status.js';
30
+ import type { ExecutionTracker } from '../reporting/execution-tracker.js';
31
+ import type { AgentRegistry } from '../agent/registry.js';
32
+ import type { RunCoordinator } from '../cluster/coordinator.js';
33
+ import type { LogStorage } from '../reporting/log-storage.js';
34
+ import type { SecretResolver } from '../secrets/secret-resolver.js';
35
+ import type { ContributorCache } from '../security/contributor-cache.js';
36
+ import type { LockFile as FullLockFile, LockWorkflow, SimulatedEvent, WebhookNormalizer } from '@kici-dev/engine';
37
+ import type { EventRouter } from '../events/event-router.js';
38
+ import type { RegistrationStore } from '../registration/registration-store.js';
39
+ import type { RegistrationIndex } from '../registration/registration-index.js';
40
+ import type { CronScheduler } from '../cron/cron-scheduler.js';
41
+ import type { GlobalWorkflowPolicy } from '../security/global-workflow-policy.js';
42
+ import type { EventLogWriter } from '../webhook/event-log.js';
43
+ import { EventLogSource } from '@kici-dev/engine';
44
+ import type { LockJob } from '@kici-dev/engine';
45
+ import type { EnvironmentStore } from '../environments/environment-store.js';
46
+ import type { VariableStore } from '../environments/variable-store.js';
47
+ import type { TrustResolver, IdentityLink, PermissionLevel } from '../security/trust-resolver.js';
48
+ import type { HeldRunStore } from '../environments/held-runs.js';
49
+ import type { WorkflowDecision } from '@kici-dev/engine';
50
+ /**
51
+ * Pending dispatch context for jobs gated by the needs scheduler.
52
+ * Keyed by `${runId}:${jobName}`. Populated at processWebhook time for all
53
+ * non-root static jobs. Consumed by the onJobReady callback when the scheduler
54
+ * determines a job's upstreams are all satisfied.
55
+ *
56
+ * Entries are cleaned up after dispatch or when the run completes.
57
+ */
58
+ interface PendingJobContext {
59
+ jobInput: QueuedJobInput;
60
+ runsOnLabels: string[];
61
+ }
62
+ /**
63
+ * Store a pending dispatch context for a job that will be dispatched later
64
+ * by the needs scheduler. The key is `${runId}:${jobName}`.
65
+ * Writes to both in-memory Map and DB table for crash recovery.
66
+ * @internal Exported for testing
67
+ */
68
+ export declare function storePendingJobContext(db: Kysely<Database> | undefined, runId: string, jobName: string, ctx: PendingJobContext): Promise<void>;
69
+ /**
70
+ * Consume and remove a pending dispatch context for a job.
71
+ * Returns undefined if no context is stored (e.g. job was already dispatched).
72
+ * Deletes from both in-memory Map and DB table.
73
+ *
74
+ * Cluster correctness: `storePendingJobContext` writes to both the local
75
+ * in-memory Map and the shared DB. In an HA cluster the peer that ingested
76
+ * the webhook stores the context, but `onJobReady` fires on whichever peer
77
+ * tracked the upstream job's completion — which, for a rerouted upstream,
78
+ * is a different peer whose Map is empty. Falling through to an atomic
79
+ * `DELETE ... RETURNING` ensures exactly one peer claims the context.
80
+ * @internal Exported for testing
81
+ */
82
+ export declare function consumePendingJobContext(db: Kysely<Database> | undefined, runId: string, jobName: string): Promise<PendingJobContext | undefined>;
83
+ /**
84
+ * Clean up all pending dispatch contexts for a run (called on run completion).
85
+ * Deletes from both in-memory Map and DB table.
86
+ */
87
+ export declare function cleanupPendingJobContexts(db: Kysely<Database> | undefined, runId: string): Promise<void>;
88
+ /**
89
+ * Restore all pending job contexts from DB into the in-memory Map.
90
+ * Called on startup before the needs scheduler recovery loop so that
91
+ * dispatchReadyJob has context available for recovered jobs.
92
+ */
93
+ export declare function restorePendingJobContexts(db: Kysely<Database>): Promise<number>;
94
+ /**
95
+ * Clear all entries from the in-memory pending job contexts Map.
96
+ * @internal Exported for testing only.
97
+ */
98
+ export declare function clearPendingJobContextsMap(): void;
99
+ /**
100
+ * Determine if a lock job is a "root" job (no concrete needs and no dependsOnGroups).
101
+ * Root jobs can be dispatched immediately; non-root jobs wait for the scheduler.
102
+ */
103
+ export declare function isRootJob(lockJob: LockJob): boolean;
104
+ /**
105
+ * Attempt to resolve a lock file for (repoIdentifier, ref) using the inbound
106
+ * webhook's provider bundle first, then falling back to other provider bundles
107
+ * registered against the SAME customer's registrations for the SAME repo.
108
+ *
109
+ * Why this exists
110
+ * ----------------
111
+ * The webhook pipeline binds `lockFileFetcher` to the inbound webhook's
112
+ * provider bundle. When an internal-sourced webhook (e.g., the staging
113
+ * stg-ha-smoke failover-dispatch test) arrives for a repo whose lock file
114
+ * is only accessible via a different provider (e.g., github), the inbound
115
+ * fetcher returns null and trigger matching silently drops the webhook.
116
+ * This resolver lets the pipeline consult OTHER bundles whose registrations
117
+ * prove they own the repo for the same tenant.
118
+ *
119
+ * Tenant boundary (security-critical)
120
+ * -----------------------------------
121
+ * The fallback iterates ONLY registrations returned by
122
+ * `registrationIndex.getByOrgAndRepo(customerId, repoIdentifier)`. That
123
+ * index is keyed by `${customerId}|${repoIdentifier}`, so cross-customer
124
+ * leakage is structurally impossible — a customer-B registration for
125
+ * `owner/repo` will never be returned when we pass `customerId = 'custA'`.
126
+ * The resolver also skips any registration whose `routingKey` matches the
127
+ * inbound routing key (no self-recursion) and dedupes by routing key so a
128
+ * repo with many workflows registered through the same source only
129
+ * triggers one fallback fetch.
130
+ *
131
+ * Ordering
132
+ * --------
133
+ * Registrations are consulted in the order returned by the index (which
134
+ * preserves insertion order = createdAt ascending). The first non-null
135
+ * lock file wins. If all fallbacks return null the function returns null
136
+ * and the caller falls through to the existing `Lock file not found`
137
+ * global-workflow-matching path.
138
+ *
139
+ * Credentials
140
+ * -----------
141
+ * Each fallback fetcher is invoked with the REGISTRATION'S
142
+ * `providerContext`, NOT the inbound normalizer's credentials. This is
143
+ * load-bearing: the InternalWebhookNormalizer returns `{}` as
144
+ * credentials, which would never satisfy a github fetcher that requires
145
+ * `installationId`. The registration carries the correct credentials
146
+ * because it was created via the owning provider's source.
147
+ */
148
+ export declare function resolveLockFileWithFallback(args: {
149
+ inboundBundle: ProviderBundle;
150
+ inboundRoutingKey: string;
151
+ repoIdentifier: string;
152
+ ref: string;
153
+ inboundCredentials: unknown;
154
+ customerId: string;
155
+ providerRegistry: ProviderRegistry;
156
+ registrationIndex: RegistrationIndex | undefined;
157
+ lockFileCache: LockFileCache;
158
+ deliveryId: string;
159
+ }): Promise<{
160
+ lockFile: FullLockFile | null;
161
+ resolvedVia: 'inbound' | 'fallback' | 'miss';
162
+ fallbackRoutingKey?: string;
163
+ /** The winning provider bundle when resolvedVia='fallback'. Used by the dispatch
164
+ * site to swap repoUrlBuilder and cloneTokenProvider (Layer 4 cross-provider fix). */
165
+ fallbackBundle?: ProviderBundle;
166
+ /** The winning registration's providerContext when resolvedVia='fallback'.
167
+ * Carries installationId etc. for clone token issuance. */
168
+ fallbackCredentials?: Record<string, unknown>;
169
+ }>;
170
+ /**
171
+ * Resolve the customer/org ID for a routing key.
172
+ *
173
+ * Checks the `sources` table first (GitHub App sources), then
174
+ * `generic_webhook_sources` (generic webhook sources). Falls back to
175
+ * '__default__' if neither table has the routing key.
176
+ */
177
+ export declare function resolveOrgId(db: Kysely<Database>, routingKey: string): Promise<string>;
178
+ /**
179
+ * Map GitHub webhook event types to lock file trigger type strings.
180
+ * Used for global workflow matching via RegistrationIndex.getGlobalByTriggerType().
181
+ */
182
+ export declare function eventTypeToTriggerType(eventType: string): string;
183
+ /**
184
+ * Extract a human-readable trigger event string from webhook info.
185
+ * Combines event type with action (e.g. "push", "pull_request:opened").
186
+ */
187
+ export declare function buildTriggerEvent(event: string, action: string | null | undefined): string;
188
+ /**
189
+ * Extract the first line of the commit message from a webhook payload.
190
+ * Handles push (head_commit.message) and PR (pull_request.title) events.
191
+ */
192
+ /**
193
+ * Best-effort extraction of a repository identifier from a generic webhook
194
+ * payload for cross-source dispatch (phase 28.5). Generic webhooks have no
195
+ * canonical repo shape, so we probe the conventions a sender is most likely
196
+ * to use:
197
+ *
198
+ * 1. GitHub-style `repository.full_name` (`owner/repo`)
199
+ * 2. GitHub-style `repository.owner.login` + `repository.name`
200
+ * 3. Flat `repository` string (e.g. `{"repository": "owner/repo"}`)
201
+ *
202
+ * Returns null when no recognisable repo field is present, in which case the
203
+ * cross-source repo lookup is skipped (event-name fan-out still runs).
204
+ */
205
+ export declare function extractInboundRepoIdentifier(payload: unknown): string | null;
206
+ export declare function extractCommitMessage(event: string, payload: unknown): string | undefined;
207
+ /**
208
+ * Build a human-readable summary for a security hold check.
209
+ */
210
+ export declare function buildSecurityHoldSummary(reason: string, tier: string, contributorUsername?: string): string;
211
+ /**
212
+ * Dependencies for the processing pipeline.
213
+ * All injected for testability. Fully provider-agnostic.
214
+ *
215
+ * sourceCache and buildCoordinator are optional for backward compatibility --
216
+ * existing tests and deployments without cache configured still work.
217
+ */
218
+ export interface ProcessingDeps {
219
+ dedup: DedupCache;
220
+ providerRegistry: ProviderRegistry;
221
+ lockFileCache: LockFileCache;
222
+ dispatcher: Dispatcher;
223
+ /** Null/undefined in Independent mode. send() buffers when disconnected. */
224
+ platformClient?: PlatformClient;
225
+ /** Directory for writing raw webhook payloads. If set, writes {dir}/{repo}/{deliveryId}/payload.json. */
226
+ webhookPayloadDir?: string;
227
+ /** Bundle cache for compiled workflow bundles. Optional -- if not set, cache is bypassed. */
228
+ sourceCache?: SourceCache;
229
+ /** Build coordinator for deduplicating concurrent builds. Optional -- if not set, cache is bypassed. */
230
+ buildCoordinator?: BuildCoordinator;
231
+ /** Dep cache for dependency tarballs. Optional -- if not set, dep caching is bypassed. */
232
+ depCache?: DepCache;
233
+ /** Pending build tracker -- waits for build agents to finish before dispatching execution jobs. */
234
+ pendingBuilds?: PendingBuildTracker;
235
+ /** Pending init tracker -- waits for init agents to resolve dynamic fields before static dispatch. */
236
+ pendingInits?: PendingInitTracker;
237
+ /** Pending dynamic tracker -- waits for agents to evaluate DynamicJobFn and return generated LockJob[]. */
238
+ pendingDynamics?: PendingDynamicTracker;
239
+ /** Commit status reporter for setting pending/success/failure/error on commits. Optional. */
240
+ commitStatusReporter?: CommitStatusReporter;
241
+ /** Execution tracker for DB persistence. Optional -- if not set, execution tracking is skipped. */
242
+ executionTracker?: ExecutionTracker;
243
+ /** Agent registry for determining execution target platform/arch. Optional -- if not set, defaults to linux/x64. */
244
+ agentRegistry?: AgentRegistry;
245
+ /** Run coordinator for multi-orchestrator job routing. Optional -- if not set, all jobs dispatch locally (single-orchestrator mode). */
246
+ coordinator?: RunCoordinator;
247
+ /** Secret resolver for dispatch-time secret resolution. Optional -- if not set, secrets are not resolved. */
248
+ secretResolver?: SecretResolver;
249
+ /** Optional callback when source locations are extracted from a lock file workflow. */
250
+ onSourceLocationsExtracted?: (workflowName: string, jobName: string, sourceLocations: Array<{
251
+ file: string;
252
+ line: number;
253
+ column: number;
254
+ } | undefined>) => void;
255
+ /** Event router for registering lock file event subscriptions. Optional -- if not set, event routing is inactive. */
256
+ eventRouter?: EventRouter;
257
+ /** Registration store for persisting workflow registrations. Optional -- if not set, registration is skipped. */
258
+ registrationStore?: RegistrationStore;
259
+ /** Registration index for in-memory lookup. Optional -- if not set, registration is skipped. */
260
+ registrationIndex?: RegistrationIndex;
261
+ /** Cron scheduler for cache refresh after registration changes. Optional -- if not set, cron cache refresh is skipped. */
262
+ cronScheduler?: CronScheduler;
263
+ /** Database connection for ephemeral key storage. Optional -- if not set, cross-job secret output support is inactive. */
264
+ db?: Kysely<Database>;
265
+ /** Secret key (KICI_SECRET_KEY) for encrypting ephemeral private keys. Required when db is set. */
266
+ secretKey?: string;
267
+ /** Log storage backend for persisting webhook payloads. Optional -- if not set, payload storage is skipped. */
268
+ logStorage?: LogStorage;
269
+ /** Environment store for looking up deployment environments. Optional -- if not set, environment features are inactive. */
270
+ environmentStore?: EnvironmentStore;
271
+ /** Variable store for resolving environment variables. Optional -- if not set, environment vars are not merged. */
272
+ variableStore?: VariableStore;
273
+ /** Held run store for persisting protection rule holds. Optional -- if not set, holds are not persisted. */
274
+ heldRunStore?: HeldRunStore;
275
+ /** Trust resolver for determining contributor trust tiers. Optional -- if not set, trust resolution is skipped. */
276
+ trustResolver?: TrustResolver;
277
+ /** Identity links pushed from Platform for trust resolution. Optional -- defaults to empty. */
278
+ identityLinks?: IdentityLink[];
279
+ /** ci_trust permission levels per user ID from Platform push. Optional -- defaults to empty. */
280
+ orgMemberPermissions?: Map<string, PermissionLevel>;
281
+ /** Global workflow policy for org-level permission enforcement. Optional -- if not set, global workflows are unrestricted. */
282
+ globalWorkflowPolicy?: GlobalWorkflowPolicy;
283
+ /** Inbound webhook delivery log writer. Optional -- if not set, deliveries are not persisted to event_log. */
284
+ eventLog?: EventLogWriter;
285
+ /** Where this delivery arrived: 'relay' (Platform WS) or 'direct' (HTTP).
286
+ * Used by the eventLog writer to populate the source column. Defaults to
287
+ * 'direct' when omitted (independent / direct paths). */
288
+ eventLogSource?: EventLogSource;
289
+ /** Contributor permission cache. Optional -- if not set, membership-webhook
290
+ * invalidations silently no-op. In platform/hybrid mode the singleton is
291
+ * created in server.ts and threaded through both the Platform-relay WS
292
+ * path and the generic webhook HTTP path. */
293
+ contributorCache?: ContributorCache;
294
+ }
295
+ /**
296
+ * Check if any trigger in the lock file workflows uses path filters.
297
+ * Used to skip the changedFilesFetcher call when no path patterns are configured,
298
+ * saving one provider API call per webhook.
299
+ */
300
+ export declare function anyTriggerHasPathPatterns(workflows: LockWorkflow[]): boolean;
301
+ export { processWebhook } from './process-webhook.js';
302
+ /**
303
+ * Dispatch a job that has become ready via the needs scheduler.
304
+ *
305
+ * Called by the onJobReady callback registered on the execution tracker.
306
+ * Consumes the pending dispatch context stored at processWebhook time,
307
+ * dispatches the job through the normal dispatcher path, and updates the
308
+ * execution tracker with the real job ID.
309
+ */
310
+ export declare function dispatchReadyJob(runId: string, jobName: string, dispatcher: Dispatcher, executionTracker?: ExecutionTracker, coordinator?: RunCoordinator, db?: Kysely<Database>): Promise<void>;
311
+ /**
312
+ * Check whether a webhook event is a push to the repository's default branch.
313
+ * Used to trigger registration extraction for workflow event subscriptions.
314
+ *
315
+ * Resolution order for the default branch:
316
+ * 1. `normalizer.extractDefaultBranch?(payload)` — provider-specific hook
317
+ * (universal-git reads a JSONPath from the source's `payloadPaths.defaultBranch`).
318
+ * 2. Fallback to `payload.repository.default_branch` — the GitHub-shaped
319
+ * default that most forges mirror.
320
+ */
321
+ export declare function isDefaultBranchPush(info: WebhookInfo, event: SimulatedEvent, payload: Record<string, unknown>, normalizer: WebhookNormalizer): boolean;
322
+ /**
323
+ * Create a serializable summary of a workflow decision for Platform forwarding.
324
+ */
325
+ export declare function summarizeDecision(decision: WorkflowDecision): Record<string, unknown>;
326
+ //# sourceMappingURL=processor.d.ts.map
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Re-run handler for the orchestrator.
3
+ *
4
+ * Loads an original completed run, retrieves its webhook payload from
5
+ * object storage, re-fetches the lock file at the original SHA, and
6
+ * dispatches a new run with parent_run_id linkage.
7
+ *
8
+ * This is NOT a reuse of processWebhook -- it's a separate, simpler function
9
+ * that skips dedup, normalization, trigger matching, and changed files fetching.
10
+ * It goes directly to: lock file parse -> job expansion -> dispatch.
11
+ */
12
+ import { type ColdStore } from '@kici-dev/shared';
13
+ import type { Kysely } from 'kysely';
14
+ import type { Database } from '../db/types.js';
15
+ import type { LogStorage } from '../reporting/log-storage.js';
16
+ import type { ProviderRegistry } from '../provider-registry.js';
17
+ import type { Dispatcher } from '../agent/dispatcher.js';
18
+ import type { ExecutionTracker } from '../reporting/execution-tracker.js';
19
+ import type { JobQueue } from '../queue/job-queue.js';
20
+ import type { PlatformClient } from '../ws/platform-client.js';
21
+ import type { CommitStatusReporter } from '../reporting/commit-status.js';
22
+ import type { RunCoordinator } from '../cluster/coordinator.js';
23
+ import type { SecretResolver } from '../secrets/secret-resolver.js';
24
+ import type { EventRouter } from '../events/event-router.js';
25
+ import type { AgentRegistry } from '../agent/registry.js';
26
+ import type { SourceCache } from '../cache/index.js';
27
+ import type { BuildCoordinator } from '../cache/index.js';
28
+ import type { DepCache } from '../cache/index.js';
29
+ import type { PendingBuildTracker } from '../cache/index.js';
30
+ /**
31
+ * Thrown when a rerun is attempted on an archived run AND the cold-store
32
+ * replay path failed (chunk missing, contentHash mismatch, S3 outage, or
33
+ * cold-store probe disabled). Phase F replaced the Phase-C "rerun is
34
+ * blocked" semantics with a real replay path; this error now signals
35
+ * a genuine "we tried to bring the row back and could not".
36
+ *
37
+ * The WS dashboard handler maps this to a structured response that the
38
+ * Platform proxy surfaces as HTTP 410 (`errorCode: 'runArchivedNotRerunnable'`).
39
+ */
40
+ export declare class RunArchivedNotRerunnableError extends Error {
41
+ readonly runId: string;
42
+ readonly code: "runArchivedNotRerunnable";
43
+ constructor(runId: string);
44
+ }
45
+ export interface RerunDeps {
46
+ db: Kysely<Database>;
47
+ logStorage: LogStorage;
48
+ providerRegistry: ProviderRegistry;
49
+ executionTracker: ExecutionTracker;
50
+ dispatcher: Dispatcher;
51
+ jobQueue: JobQueue;
52
+ platformClient: PlatformClient | null;
53
+ commitStatusReporter: CommitStatusReporter | null;
54
+ coordinator: RunCoordinator | null;
55
+ secretResolver: SecretResolver | null;
56
+ eventRouter: EventRouter | null;
57
+ agentRegistry: AgentRegistry;
58
+ sourceCache: SourceCache | null;
59
+ depCache: DepCache | null;
60
+ buildCoordinator: BuildCoordinator | null;
61
+ pendingBuilds: PendingBuildTracker | null;
62
+ /**
63
+ * Phase F — when set, a PG miss on `originalRunId` triggers a
64
+ * cold-store replay of the chunk containing the row, then a re-read.
65
+ * `null` keeps the legacy "throw RunArchivedNotRerunnableError on PG
66
+ * miss" path for deployments without cold-store wired up.
67
+ */
68
+ coldStore: ColdStore | null;
69
+ }
70
+ export declare function handleRerun(originalRunId: string, triggeredBy: string | null, deps: RerunDeps,
71
+ /**
72
+ * Phase F — routing key for the original run, forwarded by Platform
73
+ * via the WS `run.rerun.request` payload. Required to address the
74
+ * cold-store chunk under the right tenant prefix.
75
+ */
76
+ routingKeyHint?: string): Promise<{
77
+ newRunId: string;
78
+ }>;
79
+ //# sourceMappingURL=rerun.d.ts.map
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Test pipeline processor for CLI-initiated test runs.
3
+ *
4
+ * Reuses the existing webhook processing pipeline steps (lock file fetch,
5
+ * trigger matching, job dispatch) but injects a synthetic event instead
6
+ * of processing a real webhook. This avoids the anti-pattern of calling
7
+ * processWebhook() directly (which expects WebhookInfo from a real webhook).
8
+ *
9
+ * Key differences from processWebhook():
10
+ * - Skips dedup check (test runs are always unique)
11
+ * - Skips webhook normalization (event is already in SimulatedEvent shape)
12
+ * - Skips repo extraction from payload (routing key is provided directly)
13
+ * - deliveryId has `test:` prefix for identification
14
+ * - Execution runs are marked with is_test_run=true and fixture_id
15
+ * - Supports direct workflow execution (bypass trigger matching)
16
+ */
17
+ import type { LockFileCache } from '../lockfile-cache.js';
18
+ import type { Dispatcher } from '../agent/dispatcher.js';
19
+ import type { CommitStatusReporter } from '../reporting/commit-status.js';
20
+ import type { ExecutionTracker } from '../reporting/execution-tracker.js';
21
+ import type { AgentRegistry } from '../agent/registry.js';
22
+ import type { ProviderRegistry } from '../provider-registry.js';
23
+ import type { SourceCache } from '../cache/index.js';
24
+ import type { BuildCoordinator } from '../cache/index.js';
25
+ import type { DepCache } from '../cache/index.js';
26
+ import type { PendingBuildTracker } from '../cache/index.js';
27
+ import type { SecretResolver } from '../secrets/secret-resolver.js';
28
+ import type { LogStorage } from '../reporting/log-storage.js';
29
+ import type { Kysely } from 'kysely';
30
+ import type { Database } from '../db/types.js';
31
+ /**
32
+ * Input for a test trigger request.
33
+ */
34
+ export interface TestTriggerInput {
35
+ /** Unique fixture identifier from the CLI. */
36
+ fixtureId: string;
37
+ /** The simulated event to inject into the pipeline. */
38
+ event: {
39
+ type: string;
40
+ action?: string;
41
+ targetBranch: string;
42
+ sourceBranch?: string;
43
+ payload: Record<string, unknown>;
44
+ changedFiles?: string[];
45
+ };
46
+ /** Routing key for provider lookup and lock file fetch. */
47
+ routingKey: string;
48
+ /** Reference to uploaded tarball (optional). */
49
+ uploadId?: string;
50
+ /** Fixture secret context mappings (optional). */
51
+ secrets?: Record<string, string>;
52
+ /** Direct workflow run -- bypass triggers (optional). */
53
+ workflowName?: string;
54
+ /** Resolved overlay metadata for tarball download + decryption. */
55
+ resolvedOverlay?: {
56
+ tarballUrl: string;
57
+ cliPublicKey: string;
58
+ orchestratorPrivateKey: string;
59
+ };
60
+ /** Request trace ID from the HTTP request. */
61
+ requestId: string;
62
+ /** JSON-stringified lock file content for local repos with no remote. */
63
+ inlineLockFile?: string;
64
+ /** When true, repo has no remote -- skip provider lookup, skip clone. */
65
+ fullRepo?: boolean;
66
+ }
67
+ /**
68
+ * Result of processing a test trigger.
69
+ */
70
+ interface TestTriggerResult {
71
+ /** Unique run identifier. */
72
+ runId: string;
73
+ /** Whether the test trigger was accepted or rejected. */
74
+ status: 'accepted' | 'rejected';
75
+ /** Reason for rejection (if rejected). */
76
+ reason?: string;
77
+ /** Dispatched job IDs. */
78
+ jobIds: string[];
79
+ }
80
+ /**
81
+ * Dependencies for the test pipeline processor.
82
+ * All injected for testability.
83
+ */
84
+ export interface TestPipelineDeps {
85
+ lockFileCache: LockFileCache;
86
+ dispatcher: Dispatcher;
87
+ executionTracker?: ExecutionTracker;
88
+ commitStatusReporter?: CommitStatusReporter;
89
+ sourceCache?: SourceCache;
90
+ buildCoordinator?: BuildCoordinator;
91
+ depCache?: DepCache;
92
+ pendingBuilds?: PendingBuildTracker;
93
+ secretResolver?: SecretResolver;
94
+ agentRegistry: AgentRegistry;
95
+ providerRegistry: ProviderRegistry;
96
+ /** Log storage for persisting test fixture payloads. Optional -- if not set, payload storage is skipped. */
97
+ logStorage?: LogStorage;
98
+ /** Database connection for environment protection checks. Optional. */
99
+ db?: Kysely<Database>;
100
+ }
101
+ /**
102
+ * Process a test trigger through the existing pipeline.
103
+ *
104
+ * Reuses pipeline steps starting from lock file fetch, skipping webhook
105
+ * normalization and dedup. Supports both trigger-matched and direct
106
+ * workflow execution modes.
107
+ */
108
+ export declare function processTestTrigger(input: TestTriggerInput, deps: TestPipelineDeps): Promise<TestTriggerResult>;
109
+ export {};
110
+ //# sourceMappingURL=test-pipeline.d.ts.map
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Provider registry for the orchestrator.
3
+ *
4
+ * Maps routing keys to implementation bundles containing all provider capabilities.
5
+ * Static registration (no dynamic loading) -- providers are registered at startup.
6
+ *
7
+ * Each routing key (e.g., "github:12345") maps to its own ProviderBundle instance
8
+ * with per-app credentials. This supports multiple GitHub Apps (or other providers)
9
+ * registered simultaneously, each with its own appId/privateKey pair.
10
+ *
11
+ * The registry is the single entry point for all provider-specific operations:
12
+ * webhook normalization, lock file fetching, changed files retrieval,
13
+ * clone token creation, and URL building.
14
+ */
15
+ import type { WebhookNormalizer, LockFileFetcher, ChangedFilesFetcher, CloneTokenProvider, RepoUrlBuilder, ContributorResolver, CheckStatusPoster, ProviderType } from '@kici-dev/engine';
16
+ /**
17
+ * Complete set of provider capabilities.
18
+ *
19
+ * Only normalizer is required -- non-Git providers (e.g., generic webhooks)
20
+ * don't need lock file fetching, changed files, clone tokens, or URL building.
21
+ * The pipeline processor already handles missing provider capabilities by
22
+ * skipping operations.
23
+ */
24
+ export interface ProviderBundle {
25
+ normalizer: WebhookNormalizer;
26
+ lockFileFetcher?: LockFileFetcher;
27
+ changedFilesFetcher?: ChangedFilesFetcher;
28
+ cloneTokenProvider?: CloneTokenProvider;
29
+ repoUrlBuilder?: RepoUrlBuilder;
30
+ contributorResolver?: ContributorResolver;
31
+ checkStatusPoster?: CheckStatusPoster;
32
+ }
33
+ /**
34
+ * Registry mapping routing keys to their implementation bundles.
35
+ *
36
+ * Routing keys have the format "{provider}:{id}" (e.g., "github:12345").
37
+ * Each routing key gets its own ProviderBundle with per-app credentials.
38
+ *
39
+ * Usage (multi-app):
40
+ * const registry = new ProviderRegistry();
41
+ * registry.registerByRoutingKey('github:12345', bundleForApp1);
42
+ * registry.registerByRoutingKey('github:67890', bundleForApp2);
43
+ * const bundle = registry.getByRoutingKey('github:12345');
44
+ *
45
+ * Usage (backward-compatible single-app):
46
+ * registry.register('github', bundle);
47
+ * const bundle = registry.get('github');
48
+ */
49
+ export declare class ProviderRegistry {
50
+ private readonly bundles;
51
+ /**
52
+ * Register a provider bundle by routing key.
53
+ *
54
+ * Each routing key gets its own bundle with per-app credentials.
55
+ * Routing keys have the format "{provider}:{id}" (e.g., "github:12345").
56
+ */
57
+ registerByRoutingKey(routingKey: string, bundle: ProviderBundle): void;
58
+ /**
59
+ * Register a provider implementation bundle by provider type.
60
+ *
61
+ * Backward-compatible: stores the bundle under a synthetic routing key
62
+ * "{type}:default". Only works for single-app scenarios.
63
+ *
64
+ * For multi-app support, use registerByRoutingKey() instead.
65
+ */
66
+ register(type: ProviderType, bundle: ProviderBundle): void;
67
+ /**
68
+ * Get the provider bundle for a given type.
69
+ *
70
+ * Backward-compatible: returns the first bundle matching the provider type
71
+ * prefix. For multi-app, use getByRoutingKey() instead.
72
+ */
73
+ get(type: ProviderType): ProviderBundle | undefined;
74
+ /**
75
+ * Get the provider bundle by routing key.
76
+ * Routing keys have the format "{provider}:{id}" (e.g., "github:12345").
77
+ *
78
+ * Falls back to get(providerType) if exact key is not found,
79
+ * for backward compatibility with single-app registration.
80
+ */
81
+ getByRoutingKey(routingKey: string): ProviderBundle | undefined;
82
+ /**
83
+ * Get just the normalizer for a routing key.
84
+ * Convenience method for webhook handling.
85
+ */
86
+ getNormalizerByRoutingKey(routingKey: string): WebhookNormalizer | undefined;
87
+ /**
88
+ * Iterate over all registered bundles.
89
+ */
90
+ getAll(): IterableIterator<[string, ProviderBundle]>;
91
+ /**
92
+ * Check if a provider type has at least one registered bundle.
93
+ */
94
+ has(type: ProviderType): boolean;
95
+ /**
96
+ * Get all registered routing keys.
97
+ */
98
+ getRoutingKeys(): string[];
99
+ /**
100
+ * Get routing keys matching a specific provider type.
101
+ *
102
+ * @param type - Provider type (e.g., "github")
103
+ * @returns Array of routing keys matching the type prefix
104
+ */
105
+ getRoutingKeysForProvider(type: ProviderType): string[];
106
+ /**
107
+ * Remove a routing key and its bundle.
108
+ * Used during config reload when apps are removed.
109
+ */
110
+ unregister(routingKey: string): boolean;
111
+ /**
112
+ * Check if a routing key is for a generic webhook source.
113
+ * Generic routing keys have the format "generic:{orgId}:{sourceId}".
114
+ */
115
+ static isGenericRoutingKey(routingKey: string): boolean;
116
+ /**
117
+ * Remove all registered bundles.
118
+ * Used during full config rebuild on reload.
119
+ */
120
+ clear(): void;
121
+ }
122
+ //# sourceMappingURL=provider-registry.d.ts.map
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Generic webhook provider implementations for KiCI.
3
+ *
4
+ * Unlike Git providers (GitHub, GitLab, Bitbucket), the generic provider
5
+ * only implements WebhookNormalizer. Git-related methods (lock file fetching,
6
+ * changed files, clone tokens, URL building) are not applicable for
7
+ * arbitrary webhook sources.
8
+ */
9
+ import type { ProviderBundle } from '../../provider-registry.js';
10
+ import type { GenericSourceManager } from '../../webhook/generic-sources.js';
11
+ export { GenericWebhookNormalizer } from './normalizer.js';
12
+ export { verifyGenericWebhook, type VerificationMethod, type VerificationConfig, type HmacVerificationConfig, type BearerVerificationConfig, type IpAllowlistVerificationConfig, type NoneVerificationConfig, } from './verification.js';
13
+ /**
14
+ * Create a ProviderBundle for generic webhook sources.
15
+ *
16
+ * Only provides a normalizer -- no git-related methods.
17
+ * The pipeline processor handles missing capabilities gracefully.
18
+ *
19
+ * @param sourceManager - GenericSourceManager for source config lookup
20
+ * @returns ProviderBundle with normalizer only
21
+ */
22
+ export declare function createGenericProviderBundle(sourceManager: GenericSourceManager): ProviderBundle;
23
+ //# sourceMappingURL=index.d.ts.map