@kici-dev/orchestrator 0.1.27 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) 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 +22 -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 +9818 -3408
  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 +8 -6
  67. package/dist/config/types.d.ts +3 -2
  68. package/dist/config.d.ts +363 -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/repos/dashboard-encryption-keys-repo.d.ts +48 -0
  123. package/dist/db/repos/signing-keys-repo.d.ts +34 -0
  124. package/dist/db/types.d.ts +421 -7
  125. package/dist/deployment/deployment-identity.d.ts +87 -2
  126. package/dist/diagnostics/checks/backup.d.ts +18 -0
  127. package/dist/diagnostics/checks/index.d.ts +2 -1
  128. package/dist/diagnostics/fleet-collector.d.ts +1 -1
  129. package/dist/drain/drain-controller.d.ts +52 -0
  130. package/dist/events/batch-accumulator.d.ts +63 -0
  131. package/dist/events/circuit-breaker.d.ts +9 -3
  132. package/dist/events/event-emitter.d.ts +31 -0
  133. package/dist/events/event-retry-scanner.d.ts +12 -2
  134. package/dist/events/event-router.d.ts +29 -0
  135. package/dist/firecracker/host-network.d.ts +2 -0
  136. package/dist/firecracker/net-interfaces.d.ts +14 -0
  137. package/dist/github-app-name-refresher/github-app-name-refresher.d.ts +18 -8
  138. package/dist/index.d.ts +2 -0
  139. package/dist/index.js +604 -16
  140. package/dist/lockfile-cache.d.ts +4 -0
  141. package/dist/lockfile-validate.d.ts +16 -9
  142. package/dist/metrics/prometheus.d.ts +112 -15
  143. package/dist/oidc/aws-kms-signer.d.ts +37 -0
  144. package/dist/oidc/command-signer.d.ts +23 -0
  145. package/dist/oidc/db-signer.d.ts +48 -0
  146. package/dist/oidc/id-token-claims.d.ts +22 -9
  147. package/dist/oidc/jwt.d.ts +5 -2
  148. package/dist/oidc/local-dev-signer.d.ts +1 -1
  149. package/dist/oidc/oidc-mint-registration.d.ts +27 -11
  150. package/dist/oidc/orchestrator-mint.d.ts +97 -0
  151. package/dist/oidc/orchestrator-signer-factory.d.ts +33 -0
  152. package/dist/oidc/reconcile-signing-key.d.ts +21 -0
  153. package/dist/oidc/signer.d.ts +25 -0
  154. package/dist/oidc/signing-key-status.d.ts +23 -0
  155. package/dist/orchestrator-core.d.ts +42 -2
  156. package/dist/pipeline/decorating-secret-resolver.d.ts +3 -2
  157. package/dist/pipeline/dispatch-matched-workflow.d.ts +41 -0
  158. package/dist/pipeline/install-secrets-resolver.d.ts +12 -1
  159. package/dist/pipeline/manual-schedule.d.ts +20 -13
  160. package/dist/pipeline/pending-workflow-context.d.ts +1 -1
  161. package/dist/pipeline/process-webhook.d.ts +57 -2
  162. package/dist/pipeline/processor.d.ts +44 -8
  163. package/dist/pipeline/rerun.d.ts +12 -13
  164. package/dist/pipeline/resolve-sandbox-grant.d.ts +28 -0
  165. package/dist/pipeline/route-or-dispatch-jobs.d.ts +71 -0
  166. package/dist/pipeline/sandbox-allowlist-reader.d.ts +33 -0
  167. package/dist/policy/dashboard-write-policy.d.ts +9 -4
  168. package/dist/provenance/backfill-run.d.ts +1 -0
  169. package/dist/provenance/trust-root.d.ts +13 -0
  170. package/dist/providers/generic/normalizer.d.ts +1 -1
  171. package/dist/providers/github/auth.d.ts +1 -1
  172. package/dist/providers/github/changed-files.d.ts +14 -6
  173. package/dist/providers/github/check-status-poster.d.ts +19 -3
  174. package/dist/providers/github/contributor-resolver.d.ts +1 -1
  175. package/dist/providers/github/lock-file.d.ts +1 -1
  176. package/dist/providers/github/normalizer.d.ts +1 -1
  177. package/dist/providers/github/repo-url.d.ts +1 -1
  178. package/dist/providers/local/lock-file-fetcher.d.ts +1 -1
  179. package/dist/providers/local/normalizer.d.ts +1 -1
  180. package/dist/providers/local/repo-url-builder.d.ts +1 -1
  181. package/dist/providers/universal-git/changed-files.d.ts +8 -7
  182. package/dist/providers/universal-git/clone-token.d.ts +1 -1
  183. package/dist/providers/universal-git/config.d.ts +4 -4
  184. package/dist/providers/universal-git/index.d.ts +5 -1
  185. package/dist/providers/universal-git/lock-file.d.ts +6 -1
  186. package/dist/providers/universal-git/normalizer.d.ts +1 -1
  187. package/dist/providers/universal-git/repo-url.d.ts +1 -1
  188. package/dist/queue/cleanup.d.ts +69 -8
  189. package/dist/queue/job-queue.d.ts +94 -14
  190. package/dist/queue/scheduled-job.d.ts +2 -2
  191. package/dist/registration/registration-index.d.ts +1 -1
  192. package/dist/reporting/agent-failure-category.d.ts +4 -1
  193. package/dist/reporting/check-run-reporter.d.ts +34 -14
  194. package/dist/reporting/check-run-tracking-store.d.ts +70 -8
  195. package/dist/reporting/execution-tracker.d.ts +156 -10
  196. package/dist/reporting/fs-log-storage.d.ts +31 -2
  197. package/dist/reporting/job-check-run-completion.d.ts +50 -0
  198. package/dist/reporting/log-chunk-sink.d.ts +47 -0
  199. package/dist/reporting/log-retention.d.ts +16 -0
  200. package/dist/reporting/log-storage.d.ts +64 -4
  201. package/dist/reporting/log-writer.d.ts +22 -7
  202. package/dist/reporting/peer-log-normalize.d.ts +14 -0
  203. package/dist/reporting/run-aggregator.d.ts +32 -32
  204. package/dist/reporting/s3-log-storage.d.ts +102 -8
  205. package/dist/routes/admin-auth.d.ts +90 -0
  206. package/dist/routes/admin-cluster-settings.d.ts +31 -0
  207. package/dist/routes/admin-events.d.ts +3 -0
  208. package/dist/routes/admin-orchestrator-drain.d.ts +35 -0
  209. package/dist/routes/admin-runs.d.ts +9 -0
  210. package/dist/routes/admin-sources.d.ts +7 -0
  211. package/dist/routes/admin-trust-policy.d.ts +49 -0
  212. package/dist/routes/admin.d.ts +15 -1
  213. package/dist/routes/github-webhook.d.ts +9 -3
  214. package/dist/routes/provenance-oidc.d.ts +38 -0
  215. package/dist/routes/verify-attestation.d.ts +21 -0
  216. package/dist/scaler/bare-metal-backend.d.ts +9 -2
  217. package/dist/scaler/config.d.ts +25 -4
  218. package/dist/scaler/container-backend.d.ts +9 -1
  219. package/dist/scaler/firecracker-backend.d.ts +29 -2
  220. package/dist/scaler/index.d.ts +1 -1
  221. package/dist/scaler/manager.d.ts +166 -8
  222. package/dist/scaler/pending-scale-sweeper.d.ts +35 -0
  223. package/dist/scaler/types.d.ts +75 -6
  224. package/dist/secrets/backend-registry.d.ts +32 -1
  225. package/dist/secrets/dashboard-encryption-key.d.ts +48 -0
  226. package/dist/secrets/ephemeral-keys.d.ts +16 -0
  227. package/dist/secrets/pg-secret-store.d.ts +10 -0
  228. package/dist/secrets/rbac.d.ts +5 -1
  229. package/dist/secrets/routing-key-scope.d.ts +6 -0
  230. package/dist/secrets/scope-routing.d.ts +126 -0
  231. package/dist/secrets/secret-resolver.d.ts +1 -14
  232. package/dist/secrets/token-manager.d.ts +5 -1
  233. package/dist/security/contributor-cache.d.ts +9 -1
  234. package/dist/security/trust-policy-gate.d.ts +117 -0
  235. package/dist/security/trust-policy-store.d.ts +78 -0
  236. package/dist/server.js +35769 -25052
  237. package/dist/sources/source-manager.d.ts +24 -0
  238. package/dist/stale-detector/stale-run-detector.d.ts +7 -0
  239. package/dist/standalone.js +34831 -25317
  240. package/dist/storage/filesystem.d.ts +17 -0
  241. package/dist/storage/key-discriminator.d.ts +20 -0
  242. package/dist/storage/s3.d.ts +2 -0
  243. package/dist/storage/types.d.ts +16 -0
  244. package/dist/webhook/dedup.d.ts +9 -1
  245. package/dist/webhook/event-log.d.ts +13 -2
  246. package/dist/webhook/generic-sources-listener.d.ts +4 -0
  247. package/dist/webhook/ingest-admission.d.ts +140 -0
  248. package/dist/webhook/ingest-overflow-buffer.d.ts +27 -0
  249. package/dist/webhook/ingest-overflow-replayer.d.ts +49 -0
  250. package/dist/webhook/ingest-overflow-types.d.ts +73 -0
  251. package/dist/webhook/loop-lag-source.d.ts +40 -0
  252. package/dist/webhook/observed-relay-guard.d.ts +40 -0
  253. package/dist/webhook/org-ingest-cap-reader.d.ts +24 -0
  254. package/dist/webhook/register-source-bundle.d.ts +3 -0
  255. package/dist/webhook/relay-reinject.d.ts +43 -0
  256. package/dist/worker/in-memory-job-queue.d.ts +8 -3
  257. package/dist/worker-core.d.ts +10 -0
  258. package/dist/ws/agent-api-registry.d.ts +20 -0
  259. package/dist/ws/agent-handler.d.ts +63 -7
  260. package/dist/ws/bringup-api.d.ts +99 -0
  261. package/dist/ws/dashboard-context-handler.d.ts +28 -10
  262. package/dist/ws/dashboard-run-state-handler.d.ts +31 -0
  263. package/dist/ws/failure-messages.d.ts +29 -0
  264. package/dist/ws/oidc-token-relay.d.ts +9 -0
  265. package/dist/ws/ownership-gate.d.ts +22 -0
  266. package/dist/ws/platform-client.d.ts +96 -1
  267. package/dist/ws/replay-chunker.d.ts +37 -0
  268. package/installer-image-digests.json +3 -3
  269. package/package.json +22 -21
  270. package/sbom.spdx.json +1240 -1788
@@ -34,12 +34,6 @@ export interface RunDetailStepRow {
34
34
  }
35
35
  /** Map a step row to the dashboard run-detail step shape (epoch-ms timestamps). */
36
36
  export declare function mapRunDetailStep(step: RunDetailStepRow): {
37
- groupId?: string | undefined;
38
- concurrencyKind?: string | undefined;
39
- driftSummary?: string | undefined;
40
- checkOutcome?: string | undefined;
41
- secretsAccessed: string | null;
42
- stepType?: string | undefined;
43
37
  stepIndex: number;
44
38
  stepName: string;
45
39
  status: string;
@@ -48,6 +42,12 @@ export declare function mapRunDetailStep(step: RunDetailStepRow): {
48
42
  durationMs: number | null;
49
43
  exitCode: number | null;
50
44
  errorMessage: string | null;
45
+ stepType?: string | undefined;
46
+ secretsAccessed: string | null;
47
+ checkOutcome?: string | undefined;
48
+ driftSummary?: string | undefined;
49
+ concurrencyKind?: string | undefined;
50
+ groupId?: string | undefined;
51
51
  };
52
52
  /** A run-detail job row as queried from execution_jobs (warm + cold paths). */
53
53
  export interface RunDetailJobRow {
@@ -81,32 +81,6 @@ export interface RunDetailJobLookups {
81
81
  }
82
82
  /** Map queried job + step rows into the dashboard run-detail job DTO shape. */
83
83
  export declare function buildRunDetailJobs(jobs: RunDetailJobRow[], lookups: RunDetailJobLookups): {
84
- needs: {
85
- upstreamName: string;
86
- runOn: ExecutionJobStatus[];
87
- }[] | null;
88
- steps: {
89
- groupId?: string | undefined;
90
- concurrencyKind?: string | undefined;
91
- driftSummary?: string | undefined;
92
- checkOutcome?: string | undefined;
93
- secretsAccessed: string | null;
94
- stepType?: string | undefined;
95
- stepIndex: number;
96
- stepName: string;
97
- status: string;
98
- startedAt: number | null;
99
- completedAt: number | null;
100
- durationMs: number | null;
101
- exitCode: number | null;
102
- errorMessage: string | null;
103
- }[];
104
- initFailure?: {
105
- scope: "job" | "run";
106
- category: "secret_resolution" | "install_secrets" | "lock_resolution" | "build_coordination" | "context_rules" | "dynamic_eval" | "no_agent" | "matrix_expansion";
107
- message: string;
108
- jobName?: string | undefined;
109
- } | undefined;
110
84
  jobId: string;
111
85
  jobName: string;
112
86
  status: string;
@@ -126,6 +100,32 @@ export declare function buildRunDetailJobs(jobs: RunDetailJobRow[], lookups: Run
126
100
  envWarning: string | null;
127
101
  outputs: any;
128
102
  secretOutputKeys: string[] | null;
103
+ initFailure?: {
104
+ scope: "job" | "run";
105
+ category: "approval_misconfig" | "build_coordination" | "context_rules" | "dynamic_eval" | "install_secrets" | "lock_resolution" | "matrix_expansion" | "no_agent" | "sandbox_denied" | "secret_resolution" | "trust_policy";
106
+ message: string;
107
+ jobName?: string | undefined;
108
+ } | undefined;
109
+ needs: {
110
+ upstreamName: string;
111
+ runOn: ExecutionJobStatus[];
112
+ }[] | null;
113
+ steps: {
114
+ stepIndex: number;
115
+ stepName: string;
116
+ status: string;
117
+ startedAt: number | null;
118
+ completedAt: number | null;
119
+ durationMs: number | null;
120
+ exitCode: number | null;
121
+ errorMessage: string | null;
122
+ stepType?: string | undefined;
123
+ secretsAccessed: string | null;
124
+ checkOutcome?: string | undefined;
125
+ driftSummary?: string | undefined;
126
+ concurrencyKind?: string | undefined;
127
+ groupId?: string | undefined;
128
+ }[];
129
129
  }[];
130
130
  /** A dashboard-shaped run-detail job (epoch-ms timestamps). */
131
131
  export type CanonicalRunDetailJob = ReturnType<typeof buildRunDetailJobs>[number];
@@ -1,14 +1,37 @@
1
1
  /**
2
2
  * S3-backed log storage.
3
3
  *
4
- * Stores execution logs in S3. No TTL -- logs persist indefinitely.
4
+ * Stores execution logs in S3. Retention is bounded by the orchestrator cleanup
5
+ * sweep, which bulk-deletes objects older than `KICI_STEP_LOG_TTL_DAYS` (default
6
+ * 90; 0 disables the sweep for operators running their own bucket lifecycle).
5
7
  *
6
- * Implementation notes:
7
- * - append() reads existing content + concatenates + puts back (acceptable
8
- * for the sequential step model where max ~10MB per step)
9
- * - read() uses Range header for cursor-based pagination
10
- * - exists() uses HeadObject
11
- * - list() uses ListObjectsV2 with prefix
8
+ * Two write verbs with different durability contracts:
9
+ *
10
+ * - append() is an immediately-durable read-modify-write: GetObject the whole
11
+ * object, concatenate, PutObject it back. Correct for single-shot writers
12
+ * (webhook delivery payloads, rerun payloads, orchestration logs) that write
13
+ * once and read back without any finalize — N=1 means no amplification and no
14
+ * race. Its content is a plain single object at objectKey(path).
15
+ * - appendStreaming() is the high-frequency step-log verb. S3 has no native
16
+ * append primitive, so it buffers chunks per step key in memory and seals an
17
+ * immutable `{objectKey(path)}/seg-NNNNNN` object (one PutObject, unique key)
18
+ * once the buffer reaches segmentFlushBytes OR its oldest byte reaches
19
+ * segmentFlushMs. Each byte is written exactly once (no O(N^2) amplification)
20
+ * and the unique seal key means concurrent appends to the same step can never
21
+ * overwrite one another. Durability of the final tail is guaranteed by
22
+ * finalize(path) at run completion.
23
+ *
24
+ * - finalize() seals the remaining tail buffer for a step key.
25
+ * - read() lists sealed segments (plus any legacy/single object written by
26
+ * append()) and streams them via the byte-offset cursor.
27
+ * - exists()/list() are segment-aware: `exists` is true when a single object or
28
+ * any segment is present; `list` collapses segment keys to their logical step
29
+ * path.
30
+ *
31
+ * All appendStreaming/finalize operations for one step key run through a
32
+ * sequential execution chain so the in-memory buffer and seq counter are the
33
+ * authoritative single writer even when the caller fires appends without
34
+ * awaiting.
12
35
  *
13
36
  * Uses AWS SDK v3 modular imports -- only loaded when S3 storage is configured.
14
37
  */
@@ -21,22 +44,93 @@ interface S3LogStorageOptions {
21
44
  endpoint?: string;
22
45
  /** Use path-style access instead of virtual-hosted-style (required for most S3-compatible services) */
23
46
  forcePathStyle?: boolean;
47
+ /** Seal a step-log segment once the in-memory buffer reaches this many bytes. */
48
+ segmentFlushBytes: number;
49
+ /** Seal a step-log segment once the oldest buffered byte reaches this age (ms). */
50
+ segmentFlushMs: number;
24
51
  }
25
52
  export declare class S3LogStorage implements LogStorage {
26
53
  private readonly client;
27
54
  private readonly bucket;
28
55
  private readonly prefix;
56
+ private readonly segmentFlushBytes;
57
+ private readonly segmentFlushMs;
58
+ /** Per-key in-memory tail buffers awaiting seal (appendStreaming path). */
59
+ private readonly buffers;
60
+ /** Per-key sequential execution chain (serializes appendStreaming/finalize). */
61
+ private readonly locks;
29
62
  constructor(options: S3LogStorageOptions);
30
- /** Build the full S3 object key from a log path. */
63
+ /**
64
+ * Build the full S3 object key from a log path.
65
+ *
66
+ * The assert is not traversal protection — S3 keys are opaque byte strings,
67
+ * so `..` is a literal segment and this concatenation cannot escape the
68
+ * prefix. It refuses to mint a malformed key at all: `list()` and
69
+ * `listWithMetadata()` rebuild storage-relative paths by slicing the prefix
70
+ * off, so a key carrying `..` or a leading `/` would be handed back to the
71
+ * caller as an odd relative path — and on a filesystem-backed peer that path
72
+ * reaches a resolve. Keep it; it is deliberate.
73
+ *
74
+ * Removals do NOT go through here: see {@link S3LogStorage.deleteKey}.
75
+ */
31
76
  private objectKey;
77
+ /**
78
+ * Object key for a removal, built without the minting assert.
79
+ *
80
+ * `deleteMany` consumes this store's own `listWithMetadata()` output, which
81
+ * reports whatever keys the bucket actually holds — including a legacy
82
+ * malformed one written before `objectKey()` began refusing them. Routing a
83
+ * removal through the minting assert would throw while building the batch,
84
+ * so one such object would abort the whole retention sweep and leave every
85
+ * expired object in place forever. There is no protection to lose: an S3 key
86
+ * is an opaque byte string, so a `..` segment is literal and this
87
+ * concatenation addresses an object inside the prefix or nothing at all.
88
+ */
89
+ private deleteKey;
90
+ /** Segment object key for a given sequence number (zero-padded to 6 digits). */
91
+ private segKey;
32
92
  /** Check if an error is a "not found" error (NoSuchKey, NotFound, 404). */
33
93
  private isNotFoundError;
34
94
  /** Read the full content of an S3 object as a string. Returns null if not found. */
35
95
  private getContent;
96
+ /**
97
+ * Run `fn` after every previously-queued operation for `key` has settled, so
98
+ * all appendStreaming/finalize calls for one step key execute strictly in
99
+ * order. The chain swallows prior errors (they are surfaced to their own
100
+ * caller) so one failed op does not wedge the key.
101
+ */
102
+ private runExclusive;
36
103
  append(path: string, data: string): Promise<void>;
104
+ /**
105
+ * Highest existing segment number under a key (for mid-run redeploy
106
+ * continuity), + 1. Returns 0 when no segments exist yet.
107
+ */
108
+ private nextSeq;
109
+ /** Seal the buffer as the next immutable segment object. */
110
+ private seal;
111
+ appendStreaming(path: string, data: string): Promise<void>;
112
+ finalize(path: string): Promise<void>;
113
+ /**
114
+ * Single-object size (or null) + sealed segments in ascending seq order for a
115
+ * key. The single object is the content written by append() (single-shot
116
+ * writers) or any legacy step log written before the append-only change.
117
+ */
118
+ private layout;
119
+ /** Fetch an inclusive byte range from one object. */
120
+ private getRange;
121
+ /**
122
+ * Map a global byte cursor + limit onto per-object range reads across an
123
+ * ordered entry list. Returns the reads to perform and the total byte size.
124
+ */
125
+ private planReads;
37
126
  read(path: string, options?: LogReadOptions): Promise<LogReadResult>;
38
127
  exists(path: string): Promise<boolean>;
39
128
  list(prefix: string): Promise<string[]>;
129
+ listWithMetadata(prefix: string): Promise<Array<{
130
+ path: string;
131
+ lastModified: Date;
132
+ }>>;
133
+ deleteMany(paths: string[]): Promise<number>;
40
134
  }
41
135
  export {};
42
136
  //# sourceMappingURL=s3-log-storage.d.ts.map
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Shared Bearer-token auth middleware for the orchestrator's admin routes.
3
+ *
4
+ * One factory serves every DB-backed admin router, which is what makes the
5
+ * error boundary universal: a router that forgets to wrap `validate()` cannot
6
+ * exist, because no router writes that call itself.
7
+ *
8
+ * Three outcomes, deliberately distinct:
9
+ * - header absent / not `Bearer <token>` -> 401 AUTH_ERROR.missing
10
+ * - token unknown / revoked / expired -> 401 AUTH_ERROR.invalid
11
+ * - validation could not be completed -> 503 AUTH_ERROR.unavailable
12
+ *
13
+ * The third is the reason this file exists. `validate()` returns `null` for a
14
+ * bad credential, so it only throws when the lookup itself fails (unreachable
15
+ * DB, exhausted pool, failover). That is not the caller's fault and is not a
16
+ * bug in this request: the server cannot authenticate anyone right now, which
17
+ * is what 503 means. It also keeps a DB blip out of the 5xx error-rate signal
18
+ * that alerting reads as an application outage.
19
+ *
20
+ * The boundary fails closed: an unresolvable auth decision is a rejection with
21
+ * a 5xx, never a fall-through to the protected handler.
22
+ */
23
+ import type { Context, MiddlewareHandler } from 'hono';
24
+ import type { Role } from '../secrets/rbac.js';
25
+ /**
26
+ * The three admin-auth response bodies.
27
+ *
28
+ * A single map rather than string literals repeated across every admin router:
29
+ * the 401 wordings are observed by operators and by E2E assertions, so they are
30
+ * pinned in exactly one place.
31
+ */
32
+ export declare const AUTH_ERROR: {
33
+ readonly missing: 'Missing authorization';
34
+ readonly invalid: 'Invalid or expired token';
35
+ readonly unavailable: 'Authentication unavailable';
36
+ };
37
+ /** What a successful admin-token validation yields. */
38
+ export interface AuthTokenInfo {
39
+ id: string;
40
+ role: Role;
41
+ routingKey: string | null;
42
+ label: string;
43
+ }
44
+ /** The slice of TokenManager this middleware needs (keeps tests trivial to fake). */
45
+ export interface AuthTokenValidator {
46
+ validate(token: string): Promise<AuthTokenInfo | null>;
47
+ }
48
+ /**
49
+ * The result of resolving one `Authorization` header.
50
+ *
51
+ * Failures carry the status and body rather than a `Response` so a caller that
52
+ * is not a middleware (the inline run-cancel route on the coordinator app) can
53
+ * answer with the identical shape.
54
+ */
55
+ export type BearerAuthOutcome = {
56
+ ok: true;
57
+ tokenInfo: AuthTokenInfo;
58
+ } | {
59
+ ok: false;
60
+ status: 401 | 503;
61
+ error: string;
62
+ };
63
+ export interface BearerAuthDeps {
64
+ tokenManager: AuthTokenValidator;
65
+ /** Route-family label recorded on the 503 log line (e.g. 'admin-runs'). */
66
+ scope: string;
67
+ /** Overridable for tests; defaults to the module logger. */
68
+ logger?: {
69
+ error(msg: string, meta?: Record<string, unknown>): void;
70
+ };
71
+ }
72
+ /**
73
+ * Resolve one request's `Authorization` header into an authenticated token or
74
+ * a rejection. This is the boundary itself; the middleware below is a thin
75
+ * wrapper so a route that needs the token info inline can share it.
76
+ *
77
+ * @param c - The request context (only the header, method, and path are read).
78
+ * @param deps - Token validator, a scope label for logs, and an optional logger.
79
+ * @returns The token info, or the status + body to answer with.
80
+ */
81
+ export declare function resolveBearerAuth(c: Context<any>, deps: BearerAuthDeps): Promise<BearerAuthOutcome>;
82
+ /**
83
+ * Build the bearer-auth middleware for one admin route family.
84
+ *
85
+ * @param deps - Token validator, a scope label for logs, and an optional logger.
86
+ * @returns A Hono middleware that authenticates or rejects; it never calls
87
+ * `next()` on an unresolved credential.
88
+ */
89
+ export declare function createBearerAuthMiddleware(deps: BearerAuthDeps): MiddlewareHandler<any>;
90
+ //# sourceMappingURL=admin-auth.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Admin API routes for cluster-global (fleet-wide) orchestrator tunables.
3
+ *
4
+ * Exposes GET / PATCH `/api/v1/admin/cluster-settings` so `kici-admin
5
+ * cluster-settings` can read and write the single `cluster_settings` row
6
+ * (id='default') without going through the Platform dashboard proxy — the CLI
7
+ * stays operable even when Platform is unavailable.
8
+ *
9
+ * These knobs are fleet-wide, not per-tenant, so the route is deliberately NOT
10
+ * under `/orgs/:customerId/*`. Mutations require the `secret.write` RBAC
11
+ * capability (already granted to admin / owner roles), matching the gating
12
+ * posture used by `admin-org-settings.ts`.
13
+ */
14
+ import { Hono } from 'hono';
15
+ import { type Kysely } from 'kysely';
16
+ import type { Database } from '../db/types.js';
17
+ import type { RbacEnforcer, Role } from '../secrets/rbac.js';
18
+ interface ClusterSettingsRouteDeps {
19
+ db: Kysely<Database>;
20
+ rbac: RbacEnforcer;
21
+ }
22
+ type AdminEnv = {
23
+ Variables: {
24
+ role: Role;
25
+ userId: string;
26
+ routingKey: string | null;
27
+ };
28
+ };
29
+ export declare function createClusterSettingsRoutes(deps: ClusterSettingsRouteDeps): Hono<AdminEnv>;
30
+ export {};
31
+ //# sourceMappingURL=admin-cluster-settings.d.ts.map
@@ -16,6 +16,7 @@ import type { RbacEnforcer, Role } from '../secrets/rbac.js';
16
16
  import type { AppConfig } from '../config.js';
17
17
  import type { ProviderRegistry } from '../provider-registry.js';
18
18
  import type { SecretResolver } from '../secrets/secret-resolver.js';
19
+ import type { ClusterSettingsReader } from '../cluster/cluster-settings-reader.js';
19
20
  /**
20
21
  * Dependencies for admin event routes.
21
22
  */
@@ -38,6 +39,8 @@ interface AdminEventRouteDeps {
38
39
  /** Required for universal-git source registration — `null` is allowed;
39
40
  * rows with `git_config` are skipped + metric-bumped in that case. */
40
41
  secretResolver: SecretResolver | null;
42
+ /** Fleet-wide settings reader; threads the live lock-file cap into newly-registered universal-git sources. */
43
+ clusterSettings?: ClusterSettingsReader;
41
44
  /**
42
45
  * Optional — when provided, the `POST /api/v1/admin/events/emit` route is
43
46
  * mounted so operators can INSERT into `kici_events` + `pg_notify` via HTTP.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Orchestrator drain admin routes.
3
+ *
4
+ * Backs the `kici-admin orchestrator drain` / `resume` / `drain --status`
5
+ * verbs used to quiesce a coordinator before an upgrade. Mounted inside
6
+ * `createAdminRoutes` at `/api/v1/admin/orchestrator/drain`, so it inherits the
7
+ * Bearer-token auth middleware (which resolves the caller's role) and gates on
8
+ * the `orchestrator.drain` RBAC permission (owner + admin).
9
+ *
10
+ * - `GET /api/v1/admin/orchestrator/drain` → current `{ draining, jobsRunning }`.
11
+ * - `POST /api/v1/admin/orchestrator/drain { action: 'drain' | 'resume' }` →
12
+ * flips the drain flag and returns the new snapshot.
13
+ */
14
+ import { Hono } from 'hono';
15
+ import { z } from 'zod';
16
+ import type { DrainController } from '../drain/drain-controller.js';
17
+ import type { RbacEnforcer, Role } from '../secrets/rbac.js';
18
+ export declare const DrainActionSchema: z.ZodEnum<{
19
+ drain: "drain";
20
+ resume: "resume";
21
+ }>;
22
+ export type DrainAction = z.infer<typeof DrainActionSchema>;
23
+ type AdminEnv = {
24
+ Variables: {
25
+ role: Role;
26
+ userId: string;
27
+ routingKey: string | null;
28
+ };
29
+ };
30
+ export declare function createOrchestratorDrainRoutes(deps: {
31
+ drainController: DrainController;
32
+ rbac: RbacEnforcer;
33
+ }): Hono<AdminEnv>;
34
+ export {};
35
+ //# sourceMappingURL=admin-orchestrator-drain.d.ts.map
@@ -25,6 +25,15 @@ import type { TokenManager } from '../secrets/token-manager.js';
25
25
  import type { RbacEnforcer, Role } from '../secrets/rbac.js';
26
26
  import type { AuditLogger } from '../secrets/audit-logger.js';
27
27
  import type { LogStorage } from '../reporting/log-storage.js';
28
+ /**
29
+ * Statuses accepted by the `?status=` filter.
30
+ *
31
+ * The full canonical union rather than just `ExecutionRunStatus.options`: only
32
+ * run statuses can appear in `execution_runs.status`, but the job-only members
33
+ * were accepted before and simply match no row, so keeping them avoids turning
34
+ * an empty result into a rejected request.
35
+ */
36
+ export declare const RUN_STATUSES: ReadonlySet<string>;
28
37
  /**
29
38
  * Dependencies for admin run routes.
30
39
  */
@@ -9,6 +9,7 @@
9
9
  * the admin auth middleware in admin.ts.
10
10
  */
11
11
  import { Hono } from 'hono';
12
+ import { OrchestratorMode } from '@kici-dev/engine';
12
13
  import type { SourceStore } from '../sources/source-store.js';
13
14
  import type { Role } from '../secrets/rbac.js';
14
15
  import { type FetchGithubAppIdentity } from '../github-app-name-refresher/github-app-name-refresher.js';
@@ -46,6 +47,12 @@ interface SourceRouteDeps {
46
47
  * `source refresh` route.
47
48
  */
48
49
  fetchAppIdentity?: FetchGithubAppIdentity;
50
+ /**
51
+ * Orchestrator operating mode. `observed` refuses GitHub-App source creation:
52
+ * those sources are ingested through the Platform relay, and an observed
53
+ * orchestrator never accepts a relay. Omitted (undefined) behaves as before.
54
+ */
55
+ mode?: OrchestratorMode;
49
56
  }
50
57
  type AdminSourcesEnv = {
51
58
  Variables: {
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Admin API routes for the org trust policy.
3
+ *
4
+ * Exposes GET / PATCH `/api/v1/admin/trust-policy` so `kici-admin` can read the
5
+ * enforced policy and, on an independent orchestrator, set it.
6
+ *
7
+ * The policy is Platform-owned wherever a Platform is attached: the Platform
8
+ * pushes it on `trust_policy.update` and the next push would clobber a local
9
+ * write. PATCH therefore refuses on any Platform-attached orchestrator, and the
10
+ * refusal is server-side so it cannot be bypassed by calling the API directly.
11
+ */
12
+ import { Hono } from 'hono';
13
+ import type { OrchestratorMode } from '@kici-dev/engine';
14
+ import type { TrustPolicyStore } from '../security/trust-policy-store.js';
15
+ import type { RbacEnforcer, Role } from '../secrets/rbac.js';
16
+ import type { AccessLogWriter } from '../audit/access-log.js';
17
+ /**
18
+ * Wording for the Platform-managed refusal. Shared with the CLI through the
19
+ * response body — the CLI surfaces this verbatim rather than inventing its own.
20
+ */
21
+ export declare const PLATFORM_MANAGED_MESSAGE: string;
22
+ interface TrustPolicyRouteDeps {
23
+ store: TrustPolicyStore;
24
+ rbac: RbacEnforcer;
25
+ /** This orchestrator's mode; decides whether PATCH is permitted at all. */
26
+ mode: OrchestratorMode;
27
+ /**
28
+ * Audit sink for the PATCH, written inside the policy transaction.
29
+ *
30
+ * REQUIRED, not optional. The guarantee this route makes is that a loosened
31
+ * `forkPolicy` can never land unattributed; an optional sink would leave that
32
+ * resting on every construction site remembering to pass one, and a route
33
+ * built without one would accept the write and silently skip the audit. A
34
+ * required dependency moves the guarantee from convention to the compiler —
35
+ * and `admin.ts` skips mounting the route entirely rather than mounting an
36
+ * unauditable one.
37
+ */
38
+ accessLog: AccessLogWriter;
39
+ }
40
+ type AdminEnv = {
41
+ Variables: {
42
+ role: Role;
43
+ userId: string;
44
+ routingKey: string | null;
45
+ };
46
+ };
47
+ export declare function createTrustPolicyRoutes(deps: TrustPolicyRouteDeps): Hono<AdminEnv>;
48
+ export {};
49
+ //# sourceMappingURL=admin-trust-policy.d.ts.map
@@ -16,11 +16,12 @@ import type { AuditLogger } from '../secrets/audit-logger.js';
16
16
  import type { AgentTokenStore } from '../agent/token-store.js';
17
17
  import type { AgentRegistry } from '../agent/registry.js';
18
18
  import type { SharedConfigStore } from '../config/shared-store.js';
19
+ import type { DrainController } from '../drain/drain-controller.js';
19
20
  import type { SourceStore } from '../sources/source-store.js';
20
21
  import type { JoinTokenManager } from '../cluster/join-token.js';
21
22
  import type { BackendRegistry } from '../secrets/backend-registry.js';
22
23
  import type { BackendHealthChecker } from '../secrets/backend-health.js';
23
- import type { BackendSyncManager } from '@kici-dev/engine';
24
+ import type { BackendSyncManager, OrchestratorMode } from '@kici-dev/engine';
24
25
  import type { Kysely } from 'kysely';
25
26
  import type pg from 'pg';
26
27
  import type { AccessLogWriter } from '../audit/access-log.js';
@@ -29,9 +30,22 @@ import type { AccessLogWriter } from '../audit/access-log.js';
29
30
  */
30
31
  export interface AdminRouteDeps {
31
32
  tokenManager: TokenManager;
33
+ /**
34
+ * Orchestrator operating mode. Gates mode-specific admin behavior — today the
35
+ * `observed`-mode refusal of GitHub-App source creation (those sources are
36
+ * Platform-relayed by nature, and an observed orchestrator never accepts a
37
+ * relay). Optional so WS-only / test admins can omit it.
38
+ */
39
+ mode?: OrchestratorMode;
32
40
  rbac: RbacEnforcer;
33
41
  secretStore: PgSecretStore;
34
42
  auditLogger: AuditLogger;
43
+ /**
44
+ * Optional -- the coordinator drain controller. When provided, the
45
+ * `POST`/`GET /api/v1/admin/orchestrator/drain` routes are mounted (backing
46
+ * the `kici-admin orchestrator drain` verbs). Omitted on WS-only admins.
47
+ */
48
+ drainController?: DrainController;
35
49
  /** Optional -- for agent token CRUD endpoints. */
36
50
  tokenStore?: AgentTokenStore;
37
51
  /**
@@ -1,6 +1,8 @@
1
1
  import { Hono } from 'hono';
2
+ import type { OrchestratorMode } from '@kici-dev/engine';
2
3
  import type { WebhookInfo } from '../webhook/handler.js';
3
4
  import type { SourceStore } from '../sources/source-store.js';
5
+ import type { ClusterSettingsReader } from '../cluster/cluster-settings-reader.js';
4
6
  import { type VerifyInboundDeps } from '../webhook/verify-inbound.js';
5
7
  import { WebhookIngestOutcome } from '../pipeline/process-webhook.js';
6
8
  /** Dependencies for the direct GitHub webhook ingress route. */
@@ -11,13 +13,17 @@ export interface GithubWebhookRoutesDeps {
11
13
  verifyDeps: VerifyInboundDeps;
12
14
  /** Pipeline entry — owns the atomic dedup claim + dispatch. */
13
15
  onWebhook: (info: WebhookInfo) => Promise<WebhookIngestOutcome>;
16
+ /** Fleet-wide settings reader; overrides the payload cap per request. */
17
+ clusterSettings?: ClusterSettingsReader;
18
+ /** Cluster default payload cap (bytes) when no cluster_settings override is set. */
19
+ maxGithubPayloadBytes?: number;
14
20
  }
15
21
  /**
16
22
  * Whether the orchestrator serves the direct GitHub ingress route for a given
17
- * operating mode. Hybrid and independent modes serve a local GitHub source
18
- * config; platform mode is relay-only (no local GitHub source to serve).
23
+ * operating mode. Hybrid, independent, and observed modes serve their own
24
+ * ingress; platform mode is relay-only (no local GitHub source to serve).
19
25
  */
20
- export declare function shouldServeGithubIngress(mode: 'platform' | 'hybrid' | 'independent'): boolean;
26
+ export declare function shouldServeGithubIngress(mode: OrchestratorMode): boolean;
21
27
  /**
22
28
  * Direct GitHub-App webhook ingress: `POST /webhook/:orgId/github/:sourceId`.
23
29
  *
@@ -0,0 +1,38 @@
1
+ import { Hono } from 'hono';
2
+ import type { OrchestratorSigningKeyRepo } from '../db/repos/signing-keys-repo.js';
3
+ import type { DashboardEncryptionKeyRepo } from '../db/repos/dashboard-encryption-keys-repo.js';
4
+ /** OIDC discovery document for the orchestrator provenance issuer. */
5
+ export interface OpenidConfiguration {
6
+ issuer: string;
7
+ jwks_uri: string;
8
+ id_token_signing_alg_values_supported: string[];
9
+ response_types_supported: string[];
10
+ subject_types_supported: string[];
11
+ claims_supported: string[];
12
+ }
13
+ /** Build the `/.well-known/openid-configuration` document for the orchestrator issuer. */
14
+ export declare function buildOpenidConfiguration(issuer: string): OpenidConfiguration;
15
+ export interface ProvenanceOidcRoutesDeps {
16
+ /** The orchestrator's own provenance issuer (config.provenanceSigningIssuer). */
17
+ issuer: string | undefined;
18
+ repo: Pick<OrchestratorSigningKeyRepo, 'listTrusted'>;
19
+ /** Whether orchestrator-owned signing is configured. */
20
+ enabled: boolean;
21
+ /**
22
+ * Dashboard-encryption key repo. When present, the JWKS additionally serves
23
+ * the non-revoked X25519 `use:'enc'` key(s) for browser-sealed dashboard
24
+ * writes (the Verified tier's trust root). Independent of provenance signing.
25
+ */
26
+ dashboardEncryptionRepo?: Pick<DashboardEncryptionKeyRepo, 'listNonRevoked'>;
27
+ }
28
+ /**
29
+ * Public, unauthenticated OIDC discovery + JWKS endpoints for the orchestrator
30
+ * provenance issuer. Serves ONLY the public key halves (safe to expose).
31
+ *
32
+ * The discovery document returns 503 when orchestrator-owned signing is not
33
+ * configured. The JWKS does not: it also carries the X25519 dashboard-encryption
34
+ * key, which is unrelated to build attestations, and returns 503 only when there
35
+ * is no key of either kind to publish.
36
+ */
37
+ export declare function createProvenanceOidcRoutes(deps: ProvenanceOidcRoutesDeps): Hono;
38
+ //# sourceMappingURL=provenance-oidc.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { Hono } from 'hono';
2
+ import type { OrchestratorSigningKeyRepo } from '../db/repos/signing-keys-repo.js';
3
+ export interface VerifyAttestationRoutesDeps {
4
+ /** The orchestrator's own provenance issuer (config.provenanceSigningIssuer). */
5
+ issuer: string | undefined;
6
+ repo: Pick<OrchestratorSigningKeyRepo, 'listTrusted'>;
7
+ /** Whether orchestrator-owned signing is configured. */
8
+ enabled: boolean;
9
+ }
10
+ /**
11
+ * Native online verify endpoint: a third party POSTs a bundle and the
12
+ * orchestrator verifies it against its LIVE key set (fresh rotations /
13
+ * revocations included), returning a structured verdict. No Platform involved.
14
+ *
15
+ * The token `iss` is ALWAYS pinned out-of-band to the orchestrator's configured
16
+ * issuer — the bundle can never name its own trusted issuer. Never throws on a
17
+ * verification failure (returns `verified:false`); the shared engine core owns
18
+ * all crypto (ES256 pinned; no alg-confusion / alg:none).
19
+ */
20
+ export declare function createVerifyAttestationRoutes(deps: VerifyAttestationRoutesDeps): Hono;
21
+ //# sourceMappingURL=verify-attestation.d.ts.map
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { type ToolRequirement } from '@kici-dev/shared';
9
9
  import type { AgentTokenStore } from '../agent/token-store.js';
10
- import type { ScalerBackend, ScalerEntry, ManagedAgent, LabelSetConfig, LogCapture, ResourceRequest, ScalerEventCallback, ValidationResult, EffectiveLimits } from './types.js';
10
+ import type { ScalerBackend, ScalerEntry, ManagedAgent, LabelSetConfig, LogCapture, ResourceRequest, ScalerEventCallback, ValidationResult, EffectiveLimits, SpawnContext } from './types.js';
11
11
  export interface BareMetalScalerBackendOptions {
12
12
  /** Human-readable name for this scaler */
13
13
  name: string;
@@ -21,6 +21,12 @@ export interface BareMetalScalerBackendOptions {
21
21
  tokenStore?: AgentTokenStore;
22
22
  /** TTL for ephemeral agent tokens in ms. Default: 1 hour. */
23
23
  tokenTtlMs?: number;
24
+ /**
25
+ * Live resolver for the ephemeral agent-token TTL (ms). When set, called per
26
+ * spawn so the leader can serve the fleet-wide
27
+ * `cluster_settings.agent_token_ttl_ms` override; falls back to `tokenTtlMs`.
28
+ */
29
+ tokenTtlProvider?: () => Promise<number>;
24
30
  /** Agent roles for this scaler. undefined = all, [] = execution only. */
25
31
  roles?: string[];
26
32
  /**
@@ -47,6 +53,7 @@ export declare class BareMetalScalerBackend implements ScalerBackend {
47
53
  private readonly defaultResources?;
48
54
  private readonly tokenStore?;
49
55
  private readonly tokenTtlMs;
56
+ private readonly tokenTtlProvider?;
50
57
  private readonly roles;
51
58
  private readonly enforceCgroups;
52
59
  /** Tracks all managed agent processes */
@@ -72,7 +79,7 @@ export declare class BareMetalScalerBackend implements ScalerBackend {
72
79
  static getRequiredTools(entry: ScalerEntry): ToolRequirement[];
73
80
  get labelSets(): LabelSetConfig[];
74
81
  getActiveCount(): number;
75
- spawn(labelSet: string[], agentId: string, orchestratorUrl: string, onEvent?: ScalerEventCallback, effectiveLimits?: EffectiveLimits): Promise<ManagedAgent>;
82
+ spawn(labelSet: string[], agentId: string, orchestratorUrl: string, onEvent?: ScalerEventCallback, effectiveLimits?: EffectiveLimits, _spawnContext?: SpawnContext, _signal?: AbortSignal): Promise<ManagedAgent>;
76
83
  getScalerContext(agentId: string): Record<string, unknown> | undefined;
77
84
  destroy(managedId: string): Promise<void>;
78
85
  /**