@kici-dev/orchestrator 0.1.27 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/dist/__test-helpers__/mock-db.d.ts +2 -0
  2. package/dist/agent/dispatcher.d.ts +52 -2
  3. package/dist/agent/host-roster-reaper.d.ts +1 -2
  4. package/dist/agent/host-roster.d.ts +34 -0
  5. package/dist/agent/ownership-refusal.d.ts +12 -0
  6. package/dist/agent/ownership-tracker.d.ts +64 -16
  7. package/dist/agent/token-store.d.ts +13 -0
  8. package/dist/agent-packaging/availability.d.ts +27 -0
  9. package/dist/agent-packaging/build-package.d.ts +16 -0
  10. package/dist/agent-packaging/download.d.ts +30 -0
  11. package/dist/agent-packaging/index.d.ts +9 -0
  12. package/dist/agent-packaging/install-closure.d.ts +30 -0
  13. package/dist/agent-packaging/node-binary.d.ts +26 -0
  14. package/dist/agent-packaging/refresh.d.ts +50 -0
  15. package/dist/agent-packaging/store.d.ts +15 -0
  16. package/dist/agent-packaging/upload.d.ts +24 -0
  17. package/dist/app-on-error.d.ts +29 -0
  18. package/dist/app.d.ts +56 -4
  19. package/dist/artifacts/artifact-store.d.ts +233 -0
  20. package/dist/artifacts/failure-messages.d.ts +46 -0
  21. package/dist/audit/access-log.d.ts +18 -1
  22. package/dist/cache/dep-cache.d.ts +15 -0
  23. package/dist/cache/user-cache.d.ts +37 -0
  24. package/dist/cancel/cancel-run.d.ts +10 -3
  25. package/dist/cancel/dashboard-cancel-handler.d.ts +19 -0
  26. package/dist/cli/api-client.d.ts +44 -1
  27. package/dist/cli/commands/agent-package.d.ts +34 -0
  28. package/dist/cli/commands/check-run.d.ts +26 -0
  29. package/dist/cli/commands/cluster-settings.d.ts +55 -0
  30. package/dist/cli/commands/dashboard-encryption-key.d.ts +3 -0
  31. package/dist/cli/commands/db-backup.d.ts +71 -0
  32. package/dist/cli/commands/orchestrator-service/drain.d.ts +31 -0
  33. package/dist/cli/commands/orchestrator-service/index.d.ts +7 -4
  34. package/dist/cli/commands/orchestrator-service/install-env.d.ts +58 -0
  35. package/dist/cli/commands/secret.d.ts +45 -1
  36. package/dist/cli/commands/shared/admin-cli-access-log.d.ts +46 -0
  37. package/dist/cli/commands/shared/versioned-upgrade.d.ts +65 -2
  38. package/dist/cli/commands/signing-key.d.ts +3 -0
  39. package/dist/cli/commands/source.d.ts +12 -0
  40. package/dist/cli/commands/token.d.ts +9 -0
  41. package/dist/cli/commands/trust-policy.d.ts +48 -0
  42. package/dist/cli/join.d.ts +1 -1
  43. package/dist/cli/service/index.d.ts +2 -2
  44. package/dist/cli/service/instance/manifest.d.ts +17 -0
  45. package/dist/cli/service/instance/resolve.d.ts +11 -0
  46. package/dist/cli/wizard/orchestrator-wizard.d.ts +39 -11
  47. package/dist/cli.js +9921 -3409
  48. package/dist/cluster/cluster-settings-reader.d.ts +78 -0
  49. package/dist/cluster/coordinator.d.ts +81 -9
  50. package/dist/cluster/join-client.d.ts +1 -1
  51. package/dist/cluster/leader-gated-scheduler.d.ts +50 -0
  52. package/dist/cluster/orphan-recovery.d.ts +14 -0
  53. package/dist/cluster/peer-client.d.ts +12 -2
  54. package/dist/cluster/peer-handler.d.ts +15 -4
  55. package/dist/cluster/peer-registry.d.ts +12 -0
  56. package/dist/cluster/verified-issuer-poller.d.ts +11 -0
  57. package/dist/cluster/verified-issuer.d.ts +63 -0
  58. package/dist/cold-store/tables/access-log.d.ts +1 -1
  59. package/dist/cold-store/tables/event-log.d.ts +1 -1
  60. package/dist/cold-store/tables/execution-jobs.d.ts +1 -1
  61. package/dist/cold-store/tables/execution-runs.d.ts +1 -1
  62. package/dist/cold-store/tables/execution-steps.d.ts +1 -1
  63. package/dist/cold-store/tables/secret-audit-log.d.ts +1 -1
  64. package/dist/config/loader.d.ts +1 -1
  65. package/dist/config/resolver.d.ts +2 -1
  66. package/dist/config/schema.d.ts +9 -6
  67. package/dist/config/types.d.ts +5 -2
  68. package/dist/config.d.ts +366 -53
  69. package/dist/contexts/context-store.d.ts +21 -8
  70. package/dist/contexts/glob-specificity.d.ts +30 -0
  71. package/dist/contexts/held-runs.d.ts +51 -19
  72. package/dist/contexts/protection/aggregate.d.ts +2 -2
  73. package/dist/contexts/protection/concurrency-gate.d.ts +0 -3
  74. package/dist/contexts/protection/reviewer-gate.d.ts +0 -3
  75. package/dist/contexts/protection/satisfiability.d.ts +1 -1
  76. package/dist/contexts/protection/trust-gate.d.ts +0 -3
  77. package/dist/contexts/protection/wait-timer-gate.d.ts +0 -3
  78. package/dist/cron/cron-scheduler.d.ts +24 -4
  79. package/dist/cron/cron-store.d.ts +21 -7
  80. package/dist/dashboard/attestation-filters.d.ts +92 -74
  81. package/dist/dashboard/handler.d.ts +35 -1
  82. package/dist/db/migration-test-harness.d.ts +41 -0
  83. package/dist/db/migrations/069_reroute_tunables.d.ts +21 -0
  84. package/dist/db/migrations/070_execution_runs_failure_class.d.ts +4 -0
  85. package/dist/db/migrations/071_batch_accumulation.d.ts +26 -0
  86. package/dist/db/migrations/072_dispatch_queue_run_id_index.d.ts +15 -0
  87. package/dist/db/migrations/073_org_settings_ingest_concurrency.d.ts +13 -0
  88. package/dist/db/migrations/074_normalize_zero_concurrency_limit.d.ts +13 -0
  89. package/dist/db/migrations/075_ingest_overflow_buffer.d.ts +16 -0
  90. package/dist/db/migrations/076_artifacts.d.ts +19 -0
  91. package/dist/db/migrations/077_backup_runs.d.ts +13 -0
  92. package/dist/db/migrations/078_org_settings_backup_staleness.d.ts +12 -0
  93. package/dist/db/migrations/079_org_settings_scaler_spawn_timeout.d.ts +14 -0
  94. package/dist/db/migrations/080_cluster_settings.d.ts +17 -0
  95. package/dist/db/migrations/081_org_settings_queue_timeout.d.ts +19 -0
  96. package/dist/db/migrations/082_host_s3_reachable.d.ts +16 -0
  97. package/dist/db/migrations/083_org_settings_artifact_caps.d.ts +18 -0
  98. package/dist/db/migrations/084_orchestrator_signing_keys.d.ts +20 -0
  99. package/dist/db/migrations/085_cluster_settings_reroute_flap_grace_ms.d.ts +12 -0
  100. package/dist/db/migrations/086_cluster_settings_max_fanout_hosts.d.ts +12 -0
  101. package/dist/db/migrations/087_cluster_settings_event_router_rate_limit.d.ts +12 -0
  102. package/dist/db/migrations/088_cluster_settings_cache_max_tarball_bytes.d.ts +12 -0
  103. package/dist/db/migrations/089_cluster_settings_cache_ttl_days.d.ts +12 -0
  104. package/dist/db/migrations/090_cluster_settings_concurrency_wait_timeout_ms.d.ts +12 -0
  105. package/dist/db/migrations/091_cluster_settings_agent_token_ttl_ms.d.ts +12 -0
  106. package/dist/db/migrations/092_cluster_settings_version.d.ts +16 -0
  107. package/dist/db/migrations/093_org_settings_sandbox_allowlist.d.ts +4 -0
  108. package/dist/db/migrations/094_dashboard_encryption_keys.d.ts +21 -0
  109. package/dist/db/migrations/095_dashboard_write_policy_tristate.d.ts +20 -0
  110. package/dist/db/migrations/096_multi_schedule_cron_last_fired.d.ts +4 -0
  111. package/dist/db/migrations/097_execution_runs_pr_number.d.ts +4 -0
  112. package/dist/db/migrations/098_execution_runs_customer_id.d.ts +4 -0
  113. package/dist/db/migrations/099_cluster_settings_dashboard_verified_issuer.d.ts +21 -0
  114. package/dist/db/migrations/100_held_runs_hold_type_vocabulary.d.ts +31 -0
  115. package/dist/db/migrations/101_contexts_hold_expiry_drop_default.d.ts +31 -0
  116. package/dist/db/migrations/102_dispatch_queue_agent_id.d.ts +20 -0
  117. package/dist/db/migrations/103_cluster_settings_ownership_db_check_timeout_ms.d.ts +20 -0
  118. package/dist/db/migrations/104_check_run_terminal_sent.d.ts +22 -0
  119. package/dist/db/migrations/105_org_trust_policy.d.ts +19 -0
  120. package/dist/db/migrations/106_cluster_settings_check_run_tracking_ttl_days.d.ts +18 -0
  121. package/dist/db/migrations/107_check_run_tracking_updated_at_index.d.ts +23 -0
  122. package/dist/db/migrations/108_unroutable_fast_fail.d.ts +4 -0
  123. package/dist/db/repos/dashboard-encryption-keys-repo.d.ts +48 -0
  124. package/dist/db/repos/signing-keys-repo.d.ts +34 -0
  125. package/dist/db/types.d.ts +441 -7
  126. package/dist/deployment/deployment-identity.d.ts +87 -2
  127. package/dist/diagnostics/checks/backup.d.ts +18 -0
  128. package/dist/diagnostics/checks/index.d.ts +2 -1
  129. package/dist/diagnostics/fleet-collector.d.ts +1 -1
  130. package/dist/drain/drain-controller.d.ts +52 -0
  131. package/dist/events/batch-accumulator.d.ts +63 -0
  132. package/dist/events/circuit-breaker.d.ts +9 -3
  133. package/dist/events/event-emitter.d.ts +31 -0
  134. package/dist/events/event-retry-scanner.d.ts +12 -2
  135. package/dist/events/event-router.d.ts +29 -0
  136. package/dist/firecracker/host-network.d.ts +2 -0
  137. package/dist/firecracker/net-interfaces.d.ts +14 -0
  138. package/dist/github-app-name-refresher/github-app-name-refresher.d.ts +18 -8
  139. package/dist/index.d.ts +2 -0
  140. package/dist/index.js +654 -29
  141. package/dist/lockfile-cache.d.ts +4 -0
  142. package/dist/lockfile-validate.d.ts +16 -9
  143. package/dist/metrics/prometheus.d.ts +113 -15
  144. package/dist/oidc/aws-kms-signer.d.ts +37 -0
  145. package/dist/oidc/command-signer.d.ts +23 -0
  146. package/dist/oidc/db-signer.d.ts +48 -0
  147. package/dist/oidc/id-token-claims.d.ts +22 -9
  148. package/dist/oidc/jwt.d.ts +5 -2
  149. package/dist/oidc/local-dev-signer.d.ts +1 -1
  150. package/dist/oidc/oidc-mint-registration.d.ts +27 -11
  151. package/dist/oidc/orchestrator-mint.d.ts +97 -0
  152. package/dist/oidc/orchestrator-signer-factory.d.ts +33 -0
  153. package/dist/oidc/reconcile-signing-key.d.ts +21 -0
  154. package/dist/oidc/signer.d.ts +25 -0
  155. package/dist/oidc/signing-key-status.d.ts +23 -0
  156. package/dist/orchestrator-core.d.ts +42 -2
  157. package/dist/pipeline/decorating-secret-resolver.d.ts +3 -2
  158. package/dist/pipeline/dispatch-matched-workflow.d.ts +41 -0
  159. package/dist/pipeline/install-secrets-resolver.d.ts +12 -1
  160. package/dist/pipeline/manual-schedule.d.ts +20 -13
  161. package/dist/pipeline/pending-workflow-context.d.ts +1 -1
  162. package/dist/pipeline/process-webhook.d.ts +57 -2
  163. package/dist/pipeline/processor.d.ts +44 -8
  164. package/dist/pipeline/rerun.d.ts +12 -13
  165. package/dist/pipeline/resolve-sandbox-grant.d.ts +28 -0
  166. package/dist/pipeline/route-or-dispatch-jobs.d.ts +71 -0
  167. package/dist/pipeline/sandbox-allowlist-reader.d.ts +33 -0
  168. package/dist/policy/dashboard-write-policy.d.ts +9 -4
  169. package/dist/provenance/backfill-run.d.ts +1 -0
  170. package/dist/provenance/trust-root.d.ts +13 -0
  171. package/dist/providers/generic/normalizer.d.ts +1 -1
  172. package/dist/providers/github/auth.d.ts +1 -1
  173. package/dist/providers/github/changed-files.d.ts +14 -6
  174. package/dist/providers/github/check-status-poster.d.ts +19 -3
  175. package/dist/providers/github/contributor-resolver.d.ts +1 -1
  176. package/dist/providers/github/lock-file.d.ts +1 -1
  177. package/dist/providers/github/normalizer.d.ts +1 -1
  178. package/dist/providers/github/repo-url.d.ts +1 -1
  179. package/dist/providers/local/lock-file-fetcher.d.ts +1 -1
  180. package/dist/providers/local/normalizer.d.ts +1 -1
  181. package/dist/providers/local/repo-url-builder.d.ts +1 -1
  182. package/dist/providers/universal-git/changed-files.d.ts +8 -7
  183. package/dist/providers/universal-git/clone-token.d.ts +1 -1
  184. package/dist/providers/universal-git/config.d.ts +4 -4
  185. package/dist/providers/universal-git/index.d.ts +5 -1
  186. package/dist/providers/universal-git/lock-file.d.ts +6 -1
  187. package/dist/providers/universal-git/normalizer.d.ts +1 -1
  188. package/dist/providers/universal-git/repo-url.d.ts +1 -1
  189. package/dist/queue/bootstrap.d.ts +5 -0
  190. package/dist/queue/cleanup.d.ts +72 -9
  191. package/dist/queue/job-queue.d.ts +141 -14
  192. package/dist/queue/scheduled-job.d.ts +3 -2
  193. package/dist/queue/terminalize-unroutable.d.ts +53 -0
  194. package/dist/queue/unroutable-probe.d.ts +52 -0
  195. package/dist/registration/registration-index.d.ts +1 -1
  196. package/dist/reporting/agent-failure-category.d.ts +4 -1
  197. package/dist/reporting/check-run-reporter.d.ts +34 -14
  198. package/dist/reporting/check-run-tracking-store.d.ts +70 -8
  199. package/dist/reporting/execution-tracker.d.ts +156 -10
  200. package/dist/reporting/fs-log-storage.d.ts +31 -2
  201. package/dist/reporting/job-check-run-completion.d.ts +50 -0
  202. package/dist/reporting/log-chunk-sink.d.ts +47 -0
  203. package/dist/reporting/log-retention.d.ts +16 -0
  204. package/dist/reporting/log-storage.d.ts +64 -4
  205. package/dist/reporting/log-writer.d.ts +22 -7
  206. package/dist/reporting/peer-log-normalize.d.ts +14 -0
  207. package/dist/reporting/run-aggregator.d.ts +50 -33
  208. package/dist/reporting/s3-log-storage.d.ts +102 -8
  209. package/dist/routes/admin-auth.d.ts +90 -0
  210. package/dist/routes/admin-cluster-settings.d.ts +31 -0
  211. package/dist/routes/admin-events.d.ts +3 -0
  212. package/dist/routes/admin-orchestrator-drain.d.ts +35 -0
  213. package/dist/routes/admin-runs.d.ts +9 -0
  214. package/dist/routes/admin-sources.d.ts +7 -0
  215. package/dist/routes/admin-trust-policy.d.ts +49 -0
  216. package/dist/routes/admin.d.ts +15 -1
  217. package/dist/routes/github-webhook.d.ts +9 -3
  218. package/dist/routes/provenance-oidc.d.ts +38 -0
  219. package/dist/routes/verify-attestation.d.ts +21 -0
  220. package/dist/scaler/bare-metal-backend.d.ts +9 -2
  221. package/dist/scaler/config.d.ts +25 -4
  222. package/dist/scaler/container-backend.d.ts +9 -1
  223. package/dist/scaler/firecracker-backend.d.ts +29 -2
  224. package/dist/scaler/index.d.ts +1 -1
  225. package/dist/scaler/manager.d.ts +166 -8
  226. package/dist/scaler/pending-scale-sweeper.d.ts +35 -0
  227. package/dist/scaler/types.d.ts +75 -6
  228. package/dist/secrets/backend-registry.d.ts +32 -1
  229. package/dist/secrets/dashboard-encryption-key.d.ts +48 -0
  230. package/dist/secrets/ephemeral-keys.d.ts +16 -0
  231. package/dist/secrets/pg-secret-store.d.ts +10 -0
  232. package/dist/secrets/rbac.d.ts +5 -1
  233. package/dist/secrets/routing-key-scope.d.ts +6 -0
  234. package/dist/secrets/scope-routing.d.ts +126 -0
  235. package/dist/secrets/secret-resolver.d.ts +1 -14
  236. package/dist/secrets/token-manager.d.ts +5 -1
  237. package/dist/security/contributor-cache.d.ts +9 -1
  238. package/dist/security/trust-policy-gate.d.ts +117 -0
  239. package/dist/security/trust-policy-store.d.ts +78 -0
  240. package/dist/server.js +36074 -25052
  241. package/dist/sources/source-manager.d.ts +24 -0
  242. package/dist/stale-detector/stale-run-detector.d.ts +7 -0
  243. package/dist/standalone.js +35203 -25387
  244. package/dist/storage/filesystem.d.ts +17 -0
  245. package/dist/storage/key-discriminator.d.ts +20 -0
  246. package/dist/storage/s3.d.ts +2 -0
  247. package/dist/storage/types.d.ts +16 -0
  248. package/dist/webhook/dedup.d.ts +9 -1
  249. package/dist/webhook/event-log.d.ts +13 -2
  250. package/dist/webhook/generic-sources-listener.d.ts +4 -0
  251. package/dist/webhook/ingest-admission.d.ts +140 -0
  252. package/dist/webhook/ingest-overflow-buffer.d.ts +27 -0
  253. package/dist/webhook/ingest-overflow-replayer.d.ts +49 -0
  254. package/dist/webhook/ingest-overflow-types.d.ts +73 -0
  255. package/dist/webhook/loop-lag-source.d.ts +40 -0
  256. package/dist/webhook/observed-relay-guard.d.ts +40 -0
  257. package/dist/webhook/org-ingest-cap-reader.d.ts +24 -0
  258. package/dist/webhook/register-source-bundle.d.ts +3 -0
  259. package/dist/webhook/relay-reinject.d.ts +43 -0
  260. package/dist/worker/in-memory-job-queue.d.ts +8 -3
  261. package/dist/worker-core.d.ts +10 -0
  262. package/dist/ws/agent-api-registry.d.ts +20 -0
  263. package/dist/ws/agent-handler.d.ts +63 -7
  264. package/dist/ws/bringup-api.d.ts +99 -0
  265. package/dist/ws/dashboard-context-handler.d.ts +28 -10
  266. package/dist/ws/dashboard-run-state-handler.d.ts +31 -0
  267. package/dist/ws/failure-messages.d.ts +29 -0
  268. package/dist/ws/oidc-token-relay.d.ts +9 -0
  269. package/dist/ws/ownership-gate.d.ts +22 -0
  270. package/dist/ws/platform-client.d.ts +96 -1
  271. package/dist/ws/replay-chunker.d.ts +37 -0
  272. package/installer-image-digests.json +3 -3
  273. package/package.json +22 -21
  274. package/sbom.spdx.json +1240 -1788
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ import type { Signer } from './signer.js';
3
+ /** Custody backend for the orchestrator provenance signing key. */
4
+ export declare const OrchestratorSignerKind: z.ZodEnum<{
5
+ "aws-kms": "aws-kms";
6
+ command: "command";
7
+ db: "db";
8
+ }>;
9
+ export type OrchestratorSignerKind = z.infer<typeof OrchestratorSignerKind>;
10
+ /** The config slice the signer factory reads (subset of the orchestrator config). */
11
+ export interface OrchestratorSignerConfig {
12
+ /** When set, provenance signing is ON (the issuer identity). */
13
+ provenanceSigningIssuer?: string;
14
+ /** Custody kind; defaults to `db` when signing is on. */
15
+ provenanceSignerKind?: string;
16
+ provenanceKmsKeyArn?: string;
17
+ provenanceKmsRegion?: string;
18
+ provenanceKmsAccessKeyId?: string;
19
+ provenanceKmsSecretAccessKey?: string;
20
+ provenanceSignerCommand?: string;
21
+ }
22
+ /** True iff orchestrator-owned provenance signing is configured (issuer set). */
23
+ export declare function isProvenanceSigningEnabled(cfg: OrchestratorSignerConfig): boolean;
24
+ /** Resolve the configured custody kind (defaulting to `db`). Throws on an invalid value. */
25
+ export declare function resolveSignerKind(cfg: OrchestratorSignerConfig): OrchestratorSignerKind;
26
+ /**
27
+ * Build a NON-`db` (external-custody) signer from config. Returns null for `db`
28
+ * custody (whose generate-or-load lives in the boot reconcile, since the private
29
+ * key is created + persisted in the DB) and null when signing is off. Throws
30
+ * when an external kind is selected but its required config is incomplete.
31
+ */
32
+ export declare function buildExternalSigner(cfg: OrchestratorSignerConfig): Promise<Signer | null>;
33
+ //# sourceMappingURL=orchestrator-signer-factory.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { type OrchestratorSignerConfig } from './orchestrator-signer-factory.js';
2
+ import type { Signer } from './signer.js';
3
+ import type { OrchestratorSigningKeyRepo } from '../db/repos/signing-keys-repo.js';
4
+ export interface ReconcileSigningKeyDeps {
5
+ repo: Pick<OrchestratorSigningKeyRepo, 'getActiveRow' | 'upsertActive'>;
6
+ config: OrchestratorSignerConfig;
7
+ isLeader: () => boolean;
8
+ /** The orchestrator master key (`KICI_SECRET_KEY`), for `db` custody wrapping. */
9
+ secretKey: string | undefined;
10
+ /** Called once when a NEW kid is first activated (audit log, system actor). */
11
+ audit: (info: {
12
+ kid: string;
13
+ signerKind: string;
14
+ keyRef: string | null;
15
+ }) => Promise<void> | void;
16
+ }
17
+ /** Reconcile + return the active signer, or null when signing is off / not yet ready. */
18
+ export declare function reconcileOrchestratorSigningKey(deps: ReconcileSigningKeyDeps): Promise<{
19
+ signer: Signer;
20
+ } | null>;
21
+ //# sourceMappingURL=reconcile-signing-key.d.ts.map
@@ -0,0 +1,25 @@
1
+ import { type JWK } from 'jose';
2
+ /**
3
+ * Provider-agnostic signing seam for orchestrator-owned provenance. Verifiers
4
+ * never see which implementation runs (`db` / `aws-kms` / `command`). Ported from
5
+ * the Platform's `oidc/signer.ts` so the two stacks stay byte-compatible.
6
+ */
7
+ export interface Signer {
8
+ /** JOSE alg of the produced signatures. */
9
+ readonly alg: 'ES256';
10
+ /** Backend discriminator persisted on the key row (db | aws-kms | command). */
11
+ readonly signerKind: string;
12
+ /** Provider-neutral key locator persisted on the row (KMS ARN, signer command, or null for db). */
13
+ readonly keyRef: string | null;
14
+ /** Sign `data` and return the JOSE-raw (r||s) ES256 signature. */
15
+ sign(data: Uint8Array): Promise<Uint8Array>;
16
+ /** The public key as a JWK (kty EC, crv P-256, alg ES256, use sig, kid). */
17
+ getPublicJwk(): Promise<JWK>;
18
+ /** RFC 7638 thumbprint of the public JWK. */
19
+ getKid(): Promise<string>;
20
+ }
21
+ /** Convert a DER-encoded ECDSA signature (KMS output) to JOSE-raw r||s of `size`*2 bytes. */
22
+ export declare function derToRawEcdsaSignature(der: Uint8Array, size?: number): Uint8Array;
23
+ /** Build the public JWK (with kid + alg + use) from a DER SPKI public key (KMS GetPublicKey output). */
24
+ export declare function derSpkiToPublicJwk(spkiDer: Uint8Array): Promise<JWK>;
25
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Lifecycle of an orchestrator provenance signing key
4
+ * (orchestrator_signing_keys.status). Mirrors the Platform's status model so the
5
+ * rotation / retire / revoke semantics are identical.
6
+ *
7
+ * - active — the one current signing key.
8
+ * - retiring — just rotated out; still in the JWKS during the overlap window
9
+ * (in-flight short-lived JWTs minted just before rotation verify).
10
+ * - retired — no longer signs, but its public half STAYS in the trust root so
11
+ * historical attestations it signed remain verifiable. retired != removed.
12
+ * - revoked — compromised; REMOVED from the trust root; everything it signed is distrusted.
13
+ */
14
+ export declare const SigningKeyStatus: z.ZodEnum<{
15
+ active: "active";
16
+ retired: "retired";
17
+ retiring: "retiring";
18
+ revoked: "revoked";
19
+ }>;
20
+ export type SigningKeyStatus = z.infer<typeof SigningKeyStatus>;
21
+ /** Statuses served in the JWKS / trusted for verification (everything except revoked). */
22
+ export declare const TRUSTED_STATUSES: readonly SigningKeyStatus[];
23
+ //# sourceMappingURL=signing-key-status.d.ts.map
@@ -21,19 +21,27 @@ import { Dispatcher } from './agent/dispatcher.js';
21
21
  import { LockFileCache } from './lockfile-cache.js';
22
22
  import { DedupCache } from './webhook/dedup.js';
23
23
  import { ObserverRegistry } from './ws/observer-registry.js';
24
+ import { IngestAdmissionController } from './webhook/ingest-admission.js';
25
+ import { type OrgIngestCapReader } from './webhook/org-ingest-cap-reader.js';
26
+ import { type SandboxAllowListReader } from './pipeline/sandbox-allowlist-reader.js';
27
+ import { IngestOverflowBuffer } from './webhook/ingest-overflow-buffer.js';
28
+ import { IngestOverflowReplayer } from './webhook/ingest-overflow-replayer.js';
24
29
  import { AgentMetricsAggregator } from './metrics/agent-metrics-aggregator.js';
25
30
  import { SourceLocationStore } from './app.js';
26
- import { ExecutionJobStatus, type LabelMatcher, type PeerHeartbeat, type PeerLogsCollectRequest, type PeerToPeerMessage } from '@kici-dev/engine';
31
+ import { ExecutionJobStatus, type LabelMatcher, type PeerHeartbeat, type PeerLogsCollectRequest, type PeerToPeerMessage, type ResolvedSandboxGrant } from '@kici-dev/engine';
27
32
  import { ScalerManager } from './scaler/index.js';
28
33
  import type { ScalerConfig } from './scaler/index.js';
29
34
  import type { CacheStorage } from './storage/index.js';
30
35
  import { type ProvenanceTrustRoot } from './provenance/trust-root.js';
36
+ import { type ResolvedDashboardEncryptionKey } from './secrets/dashboard-encryption-key.js';
31
37
  import { SourceCache, BuildCoordinator, DepCache, UserCache, DispatchCacheRefTracker, PendingBuildTracker, PendingInitTracker, PendingDynamicTracker } from './cache/index.js';
38
+ import { ArtifactStore } from './artifacts/artifact-store.js';
32
39
  import { CheckRunReporter } from './reporting/check-run-reporter.js';
33
40
  import { StepLogBuffer } from './reporting/step-log-buffer.js';
34
41
  import { type LogStorage } from './reporting/log-storage.js';
35
42
  import { ExecutionTracker, type ExecutionTrackerDeps } from './reporting/execution-tracker.js';
36
43
  import { LogWriter } from './reporting/log-writer.js';
44
+ import { type NormalizedLogChunk } from './reporting/log-chunk-sink.js';
37
45
  import { PeerRegistry, PeerClient, createPeerHandler, RaftNode, OrphanRecovery, RunCoordinator } from './cluster/index.js';
38
46
  import { SourceStore, SourceManager } from './sources/index.js';
39
47
  import { PgSecretStore, AuditLogger, SecretResolver } from './secrets/index.js';
@@ -51,6 +59,7 @@ import { RegistrationStore } from './registration/registration-store.js';
51
59
  import { RegistrationIndex } from './registration/registration-index.js';
52
60
  import { CronScheduler } from './cron/cron-scheduler.js';
53
61
  import { ProviderRegistry } from './provider-registry.js';
62
+ import { ClusterSettingsReader } from './cluster/cluster-settings-reader.js';
54
63
  import { JoinHandler } from './cluster/join-handler.js';
55
64
  import type { Kysely } from 'kysely';
56
65
  import type { Database } from './db/types.js';
@@ -63,6 +72,8 @@ export interface OrchestratorSubsystems {
63
72
  config: AppConfig;
64
73
  db: Kysely<Database>;
65
74
  pool: pg.Pool;
75
+ /** Cluster-global settings reader (fleet-wide tunables on cluster_settings). */
76
+ clusterSettings: ClusterSettingsReader;
66
77
  providerRegistry: ProviderRegistry;
67
78
  agentRegistry: AgentRegistry;
68
79
  hostRosterStore: HostRosterStore;
@@ -80,6 +91,7 @@ export interface OrchestratorSubsystems {
80
91
  sourceCache: SourceCache | undefined;
81
92
  depCache: DepCache | undefined;
82
93
  userCache: UserCache | undefined;
94
+ artifactStore: ArtifactStore | undefined;
83
95
  /** Server-side jobId -> user-cache-namespace store, written at dispatch, read by the agent-WS handler. */
84
96
  dispatchCacheRefs: DispatchCacheRefTracker;
85
97
  buildCoordinator: BuildCoordinator | undefined;
@@ -96,6 +108,14 @@ export interface OrchestratorSubsystems {
96
108
  secretResolver: SecretResolver | null;
97
109
  adminDeps: AdminRouteDeps | undefined;
98
110
  pgSecretStore: PgSecretStore | undefined;
111
+ /**
112
+ * Dashboard-encryption (X25519) key resolver for browser-sealed dashboard
113
+ * writes under the `encrypted` posture. Present whenever KICI_SECRET_KEY is
114
+ * configured; absent ⇒ `encrypted` writes fail closed at the WS handler.
115
+ */
116
+ dashboardEncryption: {
117
+ resolve: () => Promise<ResolvedDashboardEncryptionKey | null>;
118
+ } | undefined;
99
119
  tokenStore: AgentTokenStore;
100
120
  ownershipTracker: OwnershipTracker;
101
121
  lockFileCache: LockFileCache;
@@ -163,6 +183,16 @@ export interface OrchestratorSubsystems {
163
183
  * no-op.
164
184
  */
165
185
  fleetCollectResponder: (msg: PeerLogsCollectRequest, send: (out: PeerToPeerMessage) => boolean) => Promise<void>;
186
+ /** Shared webhook-ingest admission controller (HTTP + WS relay paths). */
187
+ ingestController: IngestAdmissionController;
188
+ /** Cached per-org ingest cap reader for admission fairness keying. */
189
+ ingestCapReader: OrgIngestCapReader;
190
+ /** Cached per-org container-sandbox escape-hatch allow-list reader (dispatch). */
191
+ sandboxAllowListReader: SandboxAllowListReader;
192
+ /** Durable overflow buffer capturing shed deliveries (HTTP + WS relay). */
193
+ ingestOverflowBuffer: IngestOverflowBuffer;
194
+ /** Background replayer draining the overflow buffer once capacity recovers. */
195
+ ingestOverflowReplayer: IngestOverflowReplayer;
166
196
  }
167
197
  /**
168
198
  * Mode-specific hooks injected by each entry point.
@@ -179,8 +209,15 @@ export interface OrchestratorHooks {
179
209
  onStepStatusForward?: ExecutionTrackerDeps['onStepStatusForward'];
180
210
  onJobStatusChange?: ExecutionTrackerDeps['onJobStatusChange'];
181
211
  onRunEventEmit?: ExecutionTrackerDeps['onRunEventEmit'];
212
+ onOrchLog?: ExecutionTrackerDeps['onOrchLog'];
182
213
  orgId?: string;
183
214
  };
215
+ /**
216
+ * Forward a step-log chunk to the Platform for browser fan-out. Implemented
217
+ * by modes that hold a Platform connection; left undefined in independent
218
+ * mode, where logs are persisted but not relayed.
219
+ */
220
+ forwardLogChunk?: (chunk: NormalizedLogChunk) => void;
184
221
  /**
185
222
  * Called after the secrets subsystem is initialized.
186
223
  * Server.ts uses this to create SecretResolver; standalone doesn't.
@@ -322,7 +359,10 @@ export declare function mergeUpstreamOutputs(db: Kysely<Database>, runId: string
322
359
  upstreamJobOutputs: Record<string, Record<string, unknown>> | undefined;
323
360
  upstreamJobStatuses: Record<string, ExecutionJobStatus> | undefined;
324
361
  }>;
325
- export declare function buildInternalJobConfigForWorkflow(workflow: any, job: any): Record<string, unknown>;
362
+ export declare function buildInternalJobConfigForWorkflow(workflow: any, job: any, sandboxGrant?: ResolvedSandboxGrant, firedSchedule?: {
363
+ cronExpression?: string;
364
+ timezone?: string;
365
+ }): Record<string, unknown>;
326
366
  export declare function bootstrapOrchestrator(config: AppConfig, hooks: OrchestratorHooks, options?: {
327
367
  otelSdk?: {
328
368
  shutdown(): Promise<void>;
@@ -11,6 +11,7 @@
11
11
  * → CLI flat. The CLI flat overlay is applied last so a CLI flat key always
12
12
  * wins.
13
13
  */
14
+ import type { HostFacts } from '@kici-dev/engine';
14
15
  import type { SecretResolverApi, ResolvedSecretMeta } from '../secrets/secret-resolver.js';
15
16
  /** Decrypted CLI-uploaded local secrets: flat keys + per-context namespaces. */
16
17
  export interface CliSecrets {
@@ -21,12 +22,12 @@ export declare class DecoratingSecretResolver implements SecretResolverApi {
21
22
  private readonly base;
22
23
  private readonly cli;
23
24
  constructor(base: SecretResolverApi, cli: CliSecrets);
24
- resolveForJob(orgId: string, contextName: string): Promise<Record<string, string>>;
25
+ resolveForJob(orgId: string, contextName: string, hostCtx?: HostFacts): Promise<Record<string, string>>;
25
26
  resolveNamed(orgId: string, scope: string, key: string, opts?: {
26
27
  store?: string;
27
28
  runId?: string;
28
29
  jobId?: string;
29
30
  }): Promise<string | null>;
30
- resolveForJobWithMeta(orgId: string, contextName: string): Promise<Record<string, ResolvedSecretMeta>>;
31
+ resolveForJobWithMeta(orgId: string, contextName: string, hostCtx?: HostFacts): Promise<Record<string, ResolvedSecretMeta>>;
31
32
  }
32
33
  //# sourceMappingURL=decorating-secret-resolver.d.ts.map
@@ -21,6 +21,7 @@ import type { ProviderBundle } from '../provider-registry.js';
21
21
  import type { Dispatcher } from '../agent/dispatcher.js';
22
22
  import type { QueuedJobInput } from '../queue/job-queue.js';
23
23
  import type { TrustResolution } from '../security/trust-resolver.js';
24
+ import type { TrustPolicyOutcome } from '../security/trust-policy-gate.js';
24
25
  import { type ProcessingDeps } from './processor.js';
25
26
  /**
26
27
  * Trusted refs (write+ contributor, default-branch) get the org-shared cache
@@ -75,6 +76,28 @@ export interface WorkflowDispatchContext {
75
76
  localWorkingTree: boolean;
76
77
  /** True only when invoked from the cross-source dispatch shell. */
77
78
  crossSource: boolean;
79
+ /**
80
+ * Outcome of the org trust-policy gate for this PR event. `pass` dispatches
81
+ * normally; `hold` parks the run in the security queue; `reject` fails it
82
+ * before any job starts. Computed once per PR event in the webhook pipeline
83
+ * and threaded down; the dispatch gate acts on it directly, see
84
+ * `holdRunForSecurityPolicy` / `rejectRunForSecurityPolicy`.
85
+ *
86
+ * REQUIRED: a dispatch path that does not state a decision must not compile.
87
+ * This field was optional once and the gate read `if (!decision) return
88
+ * null`, so forgetting to thread it meant the run passed the security gate —
89
+ * fail-open by omission inside a fail-closed control. A `pass` is stated
90
+ * explicitly.
91
+ */
92
+ securityDecision: TrustPolicyOutcome;
93
+ /**
94
+ * Set when this dispatch call took a pending-jobs token for the source-pack
95
+ * build window. Tokens are fungible, so the `finally` must release only one
96
+ * it actually took — an unpaired release would consume a token held by a
97
+ * deferred init / dynamic task and un-hold the run while its jobs are still
98
+ * being registered.
99
+ */
100
+ buildWindowTokenHeld?: boolean;
78
101
  /** Composite dedup key `${info.deliveryId}:${reg.id}` (cross-source only). */
79
102
  crossSourceDeliveryId?: string;
80
103
  /**
@@ -131,6 +154,13 @@ export interface WorkflowDispatchContext {
131
154
  */
132
155
  dispatchInputs?: Record<string, unknown>;
133
156
  }
157
+ /**
158
+ * Build the dispatch-envelope event, carrying the orchestrator's already-fetched
159
+ * changed-files list + status from `eventWithFiles` as a fast-path (the agent
160
+ * recomputes from the clone when status !== 'fetched', so this only forfeits the
161
+ * optimization when a path is missed — correctness comes from the agent).
162
+ */
163
+ export declare function envelopeEvent(baseEvent: SimulatedEvent, eventWithFiles: SimulatedEvent): SimulatedEvent;
134
164
  export interface DispatchMatchedWorkflowResult {
135
165
  /** Number of jobs successfully dispatched (non-rejected). */
136
166
  dispatchedJobCount: number;
@@ -296,6 +326,17 @@ export declare function materializeStaticJobsSafe(staticJobs: readonly LockJob[]
296
326
  expansionMap: Map<string, readonly string[]>;
297
327
  matrixFailures: RejectedJob[];
298
328
  }>;
329
+ /**
330
+ * Scan a lock workflow's always-mode approval timeouts (workflow-level +
331
+ * each static job) for a non-positive / non-finite `timeoutSeconds`. Returns the
332
+ * first offender or null. Step-scope approvals ride the validated
333
+ * `step.approval-request` wire schema and are not checked here.
334
+ */
335
+ export declare function findInvalidApprovalTimeout(workflow: LockWorkflow): {
336
+ scope: 'workflow' | 'job';
337
+ jobName?: string;
338
+ value: number;
339
+ } | null;
299
340
  /**
300
341
  * Build the per-host secret-resolution context for a materialized child. A
301
342
  * `runsOnAll` host child carries its identity on `mat.agent` (preferred) or
@@ -79,7 +79,7 @@ export type ResolveInstallSecretsResult = {
79
79
  envName: string;
80
80
  /** Resolved context id (for the held row). */
81
81
  contextId: string;
82
- /** Discriminates the release trigger: 'reviewer' | 'wait_timer' | 'concurrency' | 'security'. */
82
+ /** Discriminates the release trigger an engine `HoldType` member. */
83
83
  holdType: string;
84
84
  queueType: 'context' | 'security';
85
85
  requirement: InstallHoldRequirement;
@@ -96,5 +96,16 @@ export declare function validateRegistryUrlScheme(url: string, allowHttp: boolea
96
96
  ok: false;
97
97
  reason: string;
98
98
  };
99
+ /**
100
+ * The held-run `hold_type` for a gate outcome — the gate's own `holdType` when
101
+ * it set one, otherwise the `HoldType` member its action implies. Column and
102
+ * gate share one vocabulary, so nothing is translated here.
103
+ *
104
+ * Distinct from the engine's `normalizePersistedHoldType`, which maps a value
105
+ * read back OUT of the column onto that same vocabulary.
106
+ *
107
+ * Exported for tests.
108
+ */
109
+ export declare function resolveHoldType(action: 'hold' | 'wait' | 'queue', raw: string | undefined): string;
99
110
  export declare function resolveInstallSecrets(args: ResolveInstallSecretsArgs): Promise<ResolveInstallSecretsResult>;
100
111
  //# sourceMappingURL=install-secrets-resolver.d.ts.map
@@ -9,7 +9,7 @@
9
9
  * eventRouter fire-and-forget. The manual path needs request/response
10
10
  * correlation to return the newRunId to the dashboard.
11
11
  */
12
- import type { LockWorkflow, MaterializedJob } from '@kici-dev/engine';
12
+ import type { LockScheduleTrigger, LockWorkflow, MaterializedJob } from '@kici-dev/engine';
13
13
  import type { RerunDeps } from './rerun.js';
14
14
  import type { RegistrationIndex } from '../registration/registration-index.js';
15
15
  interface ManualScheduleDeps extends RerunDeps {
@@ -25,19 +25,14 @@ export declare function handleManualSchedule(registrationId: string, triggeredBy
25
25
  requestId: string): Promise<{
26
26
  newRunId: string;
27
27
  }>;
28
+ /**
29
+ * A manual "fire now" targets no specific schedule, so merge the declared
30
+ * default inputs across ALL of the workflow's schedule triggers (later triggers
31
+ * win on key collision) rather than arbitrarily taking the first. Returns
32
+ * undefined when no schedule declares resolvable inputs.
33
+ */
34
+ export declare function mergeScheduleInputs(scheduleTriggers: LockScheduleTrigger[]): Record<string, unknown> | undefined;
28
35
  export declare function buildManualJobConfig(workflow: LockWorkflow, mat: MaterializedJob): {
29
- resolvedHashFiles?: string[] | undefined;
30
- contentHash?: string | undefined;
31
- dispatchInputs?: Record<string, unknown> | undefined;
32
- steps: readonly import("@kici-dev/engine").LockStepEntry[];
33
- needs: readonly (string | {
34
- name: string;
35
- runOn: ("success" | "pending" | "failed" | "recovering" | "running" | "queued" | "skipped" | "cancelled" | "cancelling" | "timed_out_stale" | "drift_dropped")[];
36
- } | {
37
- group: string;
38
- runOn: ("success" | "pending" | "failed" | "recovering" | "running" | "queued" | "skipped" | "cancelled" | "cancelling" | "timed_out_stale" | "drift_dropped")[];
39
- })[];
40
- rules: readonly import("@kici-dev/engine").LockRule[] | undefined;
41
36
  name: string;
42
37
  baseJobName: string;
43
38
  matrixValues?: import("@kici-dev/engine").MatrixValues;
@@ -45,6 +40,18 @@ export declare function buildManualJobConfig(workflow: LockWorkflow, mat: Materi
45
40
  fanoutTotal?: number;
46
41
  source: import("@kici-dev/engine").LockSource | undefined;
47
42
  workflowName: string;
43
+ steps: readonly import("@kici-dev/engine").LockStepEntry[];
44
+ needs: readonly (string | {
45
+ name: string;
46
+ runOn: ("cancelled" | "cancelling" | "drift_dropped" | "failed" | "pending" | "queued" | "recovering" | "running" | "skipped" | "success" | "timed_out_stale" | "unroutable")[];
47
+ } | {
48
+ group: string;
49
+ runOn: ("cancelled" | "cancelling" | "drift_dropped" | "failed" | "pending" | "queued" | "recovering" | "running" | "skipped" | "success" | "timed_out_stale" | "unroutable")[];
50
+ })[];
51
+ rules: readonly import("@kici-dev/engine").LockRule[] | undefined;
52
+ dispatchInputs?: Record<string, unknown> | undefined;
53
+ contentHash?: string | undefined;
54
+ resolvedHashFiles?: string[] | undefined;
48
55
  };
49
56
  export {};
50
57
  //# sourceMappingURL=manual-schedule.d.ts.map
@@ -12,7 +12,7 @@
12
12
  * Writes to both an in-memory Map (fast read on the same process) and the DB
13
13
  * (crash recovery + cross-orchestrator read), mirroring the pending-job store.
14
14
  */
15
- import type { Kysely } from 'kysely';
15
+ import { type Kysely } from 'kysely';
16
16
  import type { Database } from '../db/types.js';
17
17
  import type { WorkflowDispatchContext } from './dispatch-matched-workflow.js';
18
18
  /**
@@ -17,10 +17,13 @@
17
17
  * top-level export is `processWebhook`, callable from server.ts / app.ts.
18
18
  */
19
19
  import { z } from 'zod';
20
- import type { SimulatedEvent } from '@kici-dev/engine';
20
+ import type { LockFile as FullLockFile, SimulatedEvent } from '@kici-dev/engine';
21
+ import type { OrchestratorMode } from '@kici-dev/engine';
21
22
  import type { WebhookInfo } from '../webhook/handler.js';
22
23
  import type { ProviderBundle } from '../provider-registry.js';
23
24
  import type { TrustResolution } from '../security/trust-resolver.js';
25
+ import { type TrustPolicyOutcome } from '../security/trust-policy-gate.js';
26
+ import { type WorkflowModification } from '../security/workflow-diff.js';
24
27
  import { type ProcessingDeps } from './processor.js';
25
28
  /**
26
29
  * Outcome of a single inbound-webhook ingestion. `duplicate` lets a direct-
@@ -29,9 +32,10 @@ import { type ProcessingDeps } from './processor.js';
29
32
  * `processed` means the pipeline matched and dispatched (or recorded a run).
30
33
  */
31
34
  export declare const WebhookIngestOutcome: z.ZodEnum<{
35
+ duplicate: "duplicate";
32
36
  processed: "processed";
37
+ shed: "shed";
33
38
  skipped: "skipped";
34
- duplicate: "duplicate";
35
39
  }>;
36
40
  export type WebhookIngestOutcome = z.infer<typeof WebhookIngestOutcome>;
37
41
  interface TrustOutcome {
@@ -49,6 +53,57 @@ export declare function resolveTrustForPR(args: {
49
53
  repoIdentifier: string;
50
54
  credentials: Record<string, unknown>;
51
55
  }): Promise<TrustOutcome>;
56
+ interface SecurityState {
57
+ workflowModifications: WorkflowModification[];
58
+ /**
59
+ * True when this PR changes `.kici/` workflow definitions. A *signal*, not a
60
+ * decision — the trust-policy gate turns it into an outcome, which the
61
+ * dispatch gate then enforces as a held run or a rejected run.
62
+ */
63
+ hasWorkflowModifications: boolean;
64
+ }
65
+ /**
66
+ * Phase G — On PR events evaluated against the base lock file, detect workflow
67
+ * modifications by diffing base vs. head and post a neutral informational check
68
+ * (on its own dedicated check name).
69
+ *
70
+ * Detection only. Whether a modification gates the run is the org trust policy's
71
+ * call, evaluated in `evaluateSecurityPolicy` and enforced by the dispatch gate
72
+ * — which creates the real `held_runs` row and posts the pending
73
+ * "Held for approval" check, so `/kici approve` / reject / expiry can resolve it.
74
+ */
75
+ export declare function applyWorkflowModificationsAndSecurityHold(args: {
76
+ info: WebhookInfo;
77
+ bundle: ProviderBundle;
78
+ event: SimulatedEvent;
79
+ fullLockFile: FullLockFile;
80
+ headLockFileForDiff: FullLockFile | undefined;
81
+ isPREvent: boolean;
82
+ lockFileSource: 'head' | 'base';
83
+ trustResolution: TrustResolution | undefined;
84
+ repoIdentifier: string;
85
+ ref: string;
86
+ credentials: Record<string, unknown>;
87
+ }): SecurityState;
88
+ /**
89
+ * Evaluate the org trust policy for a PR event.
90
+ *
91
+ * Scoped to providers with a contributor model — the same condition trust
92
+ * resolution uses. A source without a `ContributorResolver` (generic, local,
93
+ * universal-git) is trusted by construction, so it passes regardless of policy;
94
+ * in particular, universal-git computes an `isForkPR` signal that must NOT gate
95
+ * those sources.
96
+ */
97
+ export declare function evaluateSecurityPolicy(args: {
98
+ deps: ProcessingDeps;
99
+ bundle: ProviderBundle;
100
+ isPREvent: boolean;
101
+ resolvedOrgId: string;
102
+ mode: OrchestratorMode;
103
+ trustResolution: TrustResolution | undefined;
104
+ isForkPR: boolean;
105
+ hasWorkflowModifications: boolean;
106
+ }): Promise<TrustPolicyOutcome>;
52
107
  /**
53
108
  * Process a webhook through the complete pipeline.
54
109
  *
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { type Kysely } from 'kysely';
15
15
  import type { Database } from '../db/types.js';
16
+ import type { SandboxAllowListReader } from './sandbox-allowlist-reader.js';
16
17
  import type { WebhookInfo } from '../webhook/handler.js';
17
18
  import type { DedupCache } from '../webhook/dedup.js';
18
19
  import type { ProviderRegistry, ProviderBundle } from '../provider-registry.js';
@@ -31,6 +32,7 @@ import type { ExecutionTracker } from '../reporting/execution-tracker.js';
31
32
  import type { AgentRegistry } from '../agent/registry.js';
32
33
  import type { HostRosterStore } from '../agent/host-roster.js';
33
34
  import type { RunCoordinator } from '../cluster/coordinator.js';
35
+ import type { ClusterSettingsReader } from '../cluster/cluster-settings-reader.js';
34
36
  import type { TeamMembershipLookup } from '../approvals/team-membership-lookup.js';
35
37
  import type { LogStorage } from '../reporting/log-storage.js';
36
38
  import type { SecretResolverApi } from '../secrets/secret-resolver.js';
@@ -49,8 +51,9 @@ import type { LockJob } from '@kici-dev/engine';
49
51
  import type { ContextStore } from '../contexts/context-store.js';
50
52
  import type { VariableStore } from '../contexts/variable-store.js';
51
53
  import type { TrustResolver, IdentityLink, PermissionLevel } from '../security/trust-resolver.js';
52
- import type { HeldRunStore } from '../contexts/held-runs.js';
53
- import type { WorkflowDecision } from '@kici-dev/engine';
54
+ import { type HeldRunStore } from '../contexts/held-runs.js';
55
+ import type { OrchestratorMode, WorkflowDecision } from '@kici-dev/engine';
56
+ import type { TrustPolicyStore } from '../security/trust-policy-store.js';
54
57
  /**
55
58
  * Pending dispatch context for jobs gated by the needs scheduler.
56
59
  * Keyed by `${runId}:${jobName}`. Populated at processWebhook time for all
@@ -210,13 +213,9 @@ export declare function eventTypeToTriggerType(eventType: string): string;
210
213
  * Combines event type with action (e.g. "push", "pull_request:opened").
211
214
  */
212
215
  export declare function buildTriggerEvent(event: string, action: string | null | undefined): string;
213
- /**
214
- * Extract the first line of the commit message from a webhook payload.
215
- * Handles push (head_commit.message) and PR (pull_request.title) events.
216
- */
217
216
  /**
218
217
  * Best-effort extraction of a repository identifier from a generic webhook
219
- * payload for cross-source dispatch (phase 28.5). Generic webhooks have no
218
+ * payload for cross-source dispatch. Generic webhooks have no
220
219
  * canonical repo shape, so we probe the conventions a sender is most likely
221
220
  * to use:
222
221
  *
@@ -228,11 +227,25 @@ export declare function buildTriggerEvent(event: string, action: string | null |
228
227
  * cross-source repo lookup is skipped (event-name fan-out still runs).
229
228
  */
230
229
  export declare function extractInboundRepoIdentifier(payload: unknown): string | null;
230
+ /**
231
+ * Extract the first line of the commit message from a webhook payload.
232
+ * Handles push (head_commit.message) and PR (pull_request.title) events.
233
+ */
231
234
  export declare function extractCommitMessage(event: string, payload: unknown): string | undefined;
232
235
  /**
233
236
  * Build a human-readable summary for a security hold check.
234
237
  */
235
238
  export declare function buildSecurityHoldSummary(reason: string, tier: string, contributorUsername?: string): string;
239
+ /**
240
+ * Build the failure check-run description for a run the org trust policy
241
+ * REJECTED.
242
+ *
243
+ * Deliberately not `buildSecurityHoldSummary`: a rejected run creates no
244
+ * `held_runs` row, so telling the contributor to seek "approval from a user
245
+ * with ci_trust:write or higher" points at a queue the run will never appear
246
+ * in. Only an org policy change can unblock it.
247
+ */
248
+ export declare function buildSecurityRejectionSummary(reason: string, message: string, tier: string, contributorUsername?: string): string;
236
249
  /**
237
250
  * Build the pending check-run description for a job/workflow approval hold,
238
251
  * naming the clauses an approver must satisfy. `{team:X}` renders as
@@ -282,6 +295,12 @@ export interface ProcessingDeps {
282
295
  coordinator?: RunCoordinator;
283
296
  /** Secret resolver for dispatch-time secret resolution. Optional -- if not set, secrets are not resolved. */
284
297
  secretResolver?: SecretResolverApi;
298
+ /**
299
+ * Cached per-org container-sandbox escape-hatch allow-list reader. Optional --
300
+ * when absent, dispatch defaults to the safe deny-all allow-list, so no
301
+ * workflow can escalate capabilities / host networking.
302
+ */
303
+ sandboxAllowListReader?: SandboxAllowListReader;
285
304
  /** Optional callback when source locations are extracted from a lock file workflow. */
286
305
  onSourceLocationsExtracted?: (workflowName: string, jobName: string, sourceLocations: Array<{
287
306
  file: string;
@@ -310,6 +329,20 @@ export interface ProcessingDeps {
310
329
  heldRunStore?: HeldRunStore;
311
330
  /** Trust resolver for determining contributor trust tiers. Optional -- if not set, trust resolution is skipped. */
312
331
  trustResolver?: TrustResolver;
332
+ /**
333
+ * Cache of the Platform-owned org trust policy. Read per PR event by the
334
+ * trust-policy gate. Optional so existing tests and independent deployments
335
+ * that construct deps by hand keep working.
336
+ */
337
+ trustPolicyStore?: TrustPolicyStore;
338
+ /**
339
+ * This orchestrator's mode. The trust-policy gate needs it to decide what an
340
+ * absent policy means: Platform-attached modes fail closed (a push is
341
+ * imminent), independent mode has no upstream authority and keeps legacy
342
+ * behavior. Defaults to `'platform'` at the read site — the fail-closed side —
343
+ * so a hand-built deps object never accidentally opens the gate.
344
+ */
345
+ orchestratorMode?: OrchestratorMode;
313
346
  /** Identity links pushed from Platform for trust resolution. Optional -- defaults to empty. */
314
347
  identityLinks?: IdentityLink[];
315
348
  /** ci_trust permission levels per user ID from Platform push. Optional -- defaults to empty. */
@@ -343,8 +376,11 @@ export interface ProcessingDeps {
343
376
  instanceId?: string;
344
377
  /** Static-host grace before a disconnected static host reads unreachable (ms). */
345
378
  rosterGraceMs?: number;
346
- /** Cap on runsOnAll per-host children (default 1024). */
379
+ /** Cap on runsOnAll per-host children (default 1024). Cluster default; the
380
+ * live per-cluster override is read from `cluster_settings.max_fanout_hosts`. */
347
381
  maxFanoutHosts?: number;
382
+ /** Reader for fleet-wide cluster tunables (max_fanout_hosts live override). */
383
+ clusterSettings?: ClusterSettingsReader;
348
384
  }
349
385
  /**
350
386
  * Check if any trigger in the lock file workflows uses path filters.
@@ -28,18 +28,17 @@ import type { BuildCoordinator } from '../cache/index.js';
28
28
  import type { DepCache } from '../cache/index.js';
29
29
  import type { PendingBuildTracker } from '../cache/index.js';
30
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".
31
+ * Thrown when a rerun is attempted on a run whose row is absent from PG AND
32
+ * the cold-store replay path failed or is unavailable (chunk missing,
33
+ * contentHash mismatch, S3 outage, or cold-store probe disabled). Signals a
34
+ * genuine "we tried to bring the row back and could not".
36
35
  *
37
36
  * The WS dashboard handler maps this to a structured response that the
38
37
  * Platform proxy surfaces as HTTP 410 (`errorCode: 'runArchivedNotRerunnable'`).
39
38
  */
40
39
  export declare class RunArchivedNotRerunnableError extends Error {
41
40
  readonly runId: string;
42
- readonly code: "runArchivedNotRerunnable";
41
+ readonly code: 'runArchivedNotRerunnable';
43
42
  constructor(runId: string);
44
43
  }
45
44
  export interface RerunDeps {
@@ -60,10 +59,10 @@ export interface RerunDeps {
60
59
  buildCoordinator: BuildCoordinator | null;
61
60
  pendingBuilds: PendingBuildTracker | null;
62
61
  /**
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.
62
+ * When set, a PG miss on `originalRunId` triggers a cold-store replay of
63
+ * the chunk containing the row, then a re-read. `null` keeps the "throw
64
+ * RunArchivedNotRerunnableError on PG miss" path for deployments without
65
+ * cold-store wired up.
67
66
  */
68
67
  coldStore: ColdStore | null;
69
68
  }
@@ -77,9 +76,9 @@ export declare function handleRerun(originalRunId: string, triggeredBy: string |
77
76
  */
78
77
  requestId: string,
79
78
  /**
80
- * Phase F — routing key for the original run, forwarded by Platform
81
- * via the WS `run.rerun.request` payload. Required to address the
82
- * cold-store chunk under the right tenant prefix.
79
+ * Routing key for the original run, forwarded by Platform via the WS
80
+ * `run.rerun.request` payload. Required to address the cold-store chunk
81
+ * under the right tenant prefix.
83
82
  */
84
83
  routingKeyHint?: string): Promise<{
85
84
  newRunId: string;