@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
@@ -10,11 +10,13 @@
10
10
  import { type LockFileFetcher, type LockFile } from '@kici-dev/engine';
11
11
  export declare class LockFileCache {
12
12
  private readonly cache;
13
+ private readonly inFlight;
13
14
  private hits;
14
15
  private misses;
15
16
  constructor(options: {
16
17
  max: number;
17
18
  ttl: number;
19
+ maxBytes?: number;
18
20
  });
19
21
  /**
20
22
  * Fetch the lock file for a repository at a specific ref,
@@ -27,6 +29,7 @@ export declare class LockFileCache {
27
29
  * @returns Parsed lock file, or null if not found
28
30
  */
29
31
  get(fetcher: LockFileFetcher, repoIdentifier: string, ref: string, credentials: unknown): Promise<LockFile | null>;
32
+ private fetchAndValidate;
30
33
  /**
31
34
  * Get cache statistics for metrics/monitoring.
32
35
  */
@@ -34,6 +37,7 @@ export declare class LockFileCache {
34
37
  hits: number;
35
38
  misses: number;
36
39
  size: number;
40
+ calculatedSize: number;
37
41
  };
38
42
  }
39
43
  //# sourceMappingURL=lockfile-cache.d.ts.map
@@ -1,19 +1,26 @@
1
1
  /**
2
2
  * Lock-load shape + compatibility validation.
3
3
  *
4
- * A fetched lock must be a valid JSON document whose schemaVersion matches this
5
- * orchestrator's engine SCHEMA_VERSION exactly, and whose routing matchers are
6
- * well-formed LabelMatcher objects. A lock compiled by an older engine stored
7
- * `runsOn` as a plain string array; without this gate those strings would parse
8
- * past the dispatch path as an empty label set and mis-route jobs to an
9
- * arbitrary scaler. These checks run at the cache choke point and surface as a
10
- * `LockFileParseError` (the established corrupt-lock signal).
4
+ * A fetched lock must be a valid JSON document whose schemaVersion falls within
5
+ * this orchestrator's compatibility window (at or above BREAKING_FLOOR, and
6
+ * requiring a reader no newer than SCHEMA_VERSION), and whose routing matchers
7
+ * are well-formed LabelMatcher objects. A lock compiled by an older engine
8
+ * stored `runsOn` as a plain string array; without the floor gate those strings
9
+ * would parse past the dispatch path as an empty label set and mis-route jobs to
10
+ * an arbitrary scaler. These checks run at the cache choke point and surface as
11
+ * a `LockFileParseError` (the established corrupt-lock signal).
11
12
  */
12
13
  import { type LockFile } from '@kici-dev/engine';
13
14
  /** Parse the raw lock JSON and assert the minimal document shape. */
14
15
  export declare function parseLockDocument(raw: string, repoIdentifier: string, ref: string): LockFile;
15
- /** Reject a lock whose schemaVersion does not exactly match this orchestrator. */
16
- export declare function assertLockFileSchemaCompatible(lockFile: LockFile): void;
16
+ /**
17
+ * Enforce the two-sided lock-schema compatibility window. Accept any lock whose
18
+ * `schemaVersion` is at or above this codebase's `BREAKING_FLOOR` and whose
19
+ * required reader version is at or below this orchestrator's `SCHEMA_VERSION`.
20
+ * Both out-of-window cases throw a `LockFileParseError` (the established
21
+ * corrupt-lock signal) carrying operator-actionable guidance.
22
+ */
23
+ export declare function assertLockFileSchemaCompatible(lockFile: LockFile, repoIdentifier: string, ref: string): void;
17
24
  /**
18
25
  * Walk every static job's runsOn / excludeLabels / runsOnAll matchers and throw
19
26
  * if any element is not a valid LabelMatcher. Dynamic job generators carry no
@@ -1,7 +1,10 @@
1
+ import type { ScalerRedispatchTrigger } from '../scaler/types.js';
1
2
  /** Set the current number of active agents. */
2
3
  export declare function setAgentsActive(value: number): void;
3
4
  /** Set the current config version number. */
4
5
  export declare function setConfigVersion(value: number): void;
6
+ /** Set whether this coordinator is draining (1) or accepting new jobs (0). */
7
+ export declare function setDraining(value: boolean): void;
5
8
  /** Set the current number of declared (static) roster hosts that are unreachable. */
6
9
  export declare function setDeclaredHostsUnreachable(value: number): void;
7
10
  /** Set the current number of stale runs detected. */
@@ -33,6 +36,12 @@ interface ScalerUsageRow {
33
36
  export declare function setScalerUsageBreakdown(rows: ScalerUsageRow[]): void;
34
37
  /** Increment the spawn-refusal counter (called by ScalerManager when a request fails the cap check). */
35
38
  export declare function incScalerSpawnRefusals(): void;
39
+ /**
40
+ * Record `count` pending jobs re-driven through the scaler by `trigger`
41
+ * (`hook` = capacity-freed callback, `sweep` = leader-gated backstop).
42
+ * Called by the dispatcher's metrics facade.
43
+ */
44
+ export declare function incScalerRedispatch(trigger: ScalerRedispatchTrigger, count: number): void;
36
45
  /**
37
46
  * Merge current per-label counts with explicit `0`s for previously-seen labels
38
47
  * whose queue has drained. Mutates `everSeen` to include the current labels.
@@ -54,6 +63,48 @@ export declare function setDispatchQueueDepthBreakdown(snapshot: {
54
63
  byStatus: Partial<Record<'pending' | 'dispatched', number>>;
55
64
  byLabel: Record<string, number>;
56
65
  }): void;
66
+ interface IngestMetricState {
67
+ inflight: number;
68
+ queueDepth: number;
69
+ sheddingActive: boolean;
70
+ loopDelayP99Ms: number;
71
+ loopDelayMaxMs: number;
72
+ }
73
+ export declare function setIngestAdmissionState(s: IngestMetricState): void;
74
+ export declare function getIngestMetricState(): IngestMetricState;
75
+ interface IngestLimitState {
76
+ maxConcurrency: number;
77
+ maxQueueDepth: number;
78
+ orgMaxConcurrency: number;
79
+ loopLagShedMs: number;
80
+ loopLagResumeMs: number;
81
+ overflowMax: number;
82
+ }
83
+ export declare function setIngestAdmissionLimits(l: IngestLimitState): void;
84
+ /** Reset ingest metric state (test helper). */
85
+ export declare function resetIngestMetricState(): void;
86
+ /**
87
+ * Total webhook-ingest admissions shed by the admission controller.
88
+ * Labels:
89
+ * - reason: loop_overload | codel_drop | queue_full | max_sojourn
90
+ */
91
+ export declare const ingestShedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
92
+ /** Total times the state.replay circuit breaker opened, skipping replay on connect. */
93
+ export declare const stateReplayBreakerTripsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
94
+ /** Total webhook-ingest admissions granted. */
95
+ export declare const ingestAdmittedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
96
+ /** Set the current buffered-row depth (called by the buffer + replayer). */
97
+ export declare function setIngestOverflowBuffered(value: number): void;
98
+ /** Current buffered-row depth (test helper). */
99
+ export declare function getIngestOverflowBuffered(): number;
100
+ /** Reset overflow metric state (test helper). */
101
+ export declare function resetIngestOverflowMetricState(): void;
102
+ /** Deliveries captured into the durable overflow buffer. */
103
+ export declare const ingestOverflowCapturedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
104
+ /** Buffered deliveries successfully replayed through normal ingest. */
105
+ export declare const ingestOverflowReplayedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
106
+ /** Buffered deliveries permanently dropped. Labels: reason (cap_full|max_attempts). */
107
+ export declare const ingestOverflowDroppedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
57
108
  /**
58
109
  * Total webhooks received by the orchestrator.
59
110
  * Labels:
@@ -67,6 +118,16 @@ export declare const webhooksReceivedTotal: import("@opentelemetry/api").Counter
67
118
  * - result: matched (triggered workflow) | skipped (no match) | error (processing failure)
68
119
  */
69
120
  export declare const webhooksProcessedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
121
+ /**
122
+ * Org trust-policy gate decisions.
123
+ * Labels:
124
+ * - arm: which policy arm decided — workflow_modification | fork_pr | unknown_contributor | none (the PR passed)
125
+ * - action: pass | hold | reject
126
+ *
127
+ * Incremented once per evaluated PR event, including passes, so the ratio of
128
+ * gated to ungated PRs is visible rather than only the gated ones.
129
+ */
130
+ export declare const trustPolicyDecisionsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
70
131
  /**
71
132
  * Duration of trigger matching operations (lock file evaluation).
72
133
  * Buckets: 1ms to 5s covering fast rejects through complex evaluations.
@@ -131,10 +192,14 @@ export declare const stepsTotal: import("@opentelemetry/api").Counter<import("@o
131
192
  export declare const githubCheckRunTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
132
193
  /**
133
194
  * Total log chunks received from agents.
195
+ * Labels:
196
+ * - source: local (directly-connected agent) | peer (relayed by a worker orchestrator)
134
197
  */
135
198
  export declare const logChunksReceivedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
136
199
  /**
137
200
  * Total log bytes written to storage backend.
201
+ * Labels:
202
+ * - source: local (directly-connected agent) | peer (relayed by a worker orchestrator)
138
203
  */
139
204
  export declare const logBytesStoredTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
140
205
  /**
@@ -149,8 +214,8 @@ export declare const scalerConfigReloadsTotal: import("@opentelemetry/api").Coun
149
214
  * - `false` — a warm-pool / unbound pre-spawn (no run impact yet; fleet-health signal).
150
215
  */
151
216
  export declare const ScalerSpawnFailureBound: {
152
- readonly Bound: "true";
153
- readonly Unbound: "false";
217
+ readonly Bound: 'true';
218
+ readonly Unbound: 'false';
154
219
  };
155
220
  export type ScalerSpawnFailureBound = (typeof ScalerSpawnFailureBound)[keyof typeof ScalerSpawnFailureBound];
156
221
  /**
@@ -198,7 +263,7 @@ export declare const crossSourceFanoutSize: import("@opentelemetry/api").Histogr
198
263
  * provider bundle not found in registry)
199
264
  *
200
265
  * NOTE: dashboard panel for `kici_cross_source_errors_total` not yet added —
201
- * follow-up per .claude/rules/monitoring.md (out of scope for plan 28.4-02).
266
+ * follow-up per the dashboards 1:1 invariant in the monitoring rule.
202
267
  */
203
268
  export declare const crossSourceErrorsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
204
269
  /**
@@ -267,17 +332,17 @@ export declare function setEventDlqDepth(value: number): void;
267
332
  * constants, so adding a new reject path requires extending the union here.
268
333
  */
269
334
  export declare const InstallSecretsDecisionReason: {
270
- readonly Ok: "ok";
271
- readonly MalformedRef: "malformed_ref";
272
- readonly InvalidUrlScheme: "invalid_url_scheme";
273
- readonly MissingEnvStore: "missing_env_store";
274
- readonly MissingSecretResolver: "missing_secret_resolver";
275
- readonly EnvNotFound: "env_not_found";
276
- readonly ProtectionRuleBlock: "protection_rule_block";
277
- readonly MissingToken: "missing_token";
278
- readonly MissingInstallEnv: "missing_install_env";
335
+ readonly Ok: 'ok';
336
+ readonly MalformedRef: 'malformed_ref';
337
+ readonly InvalidUrlScheme: 'invalid_url_scheme';
338
+ readonly MissingEnvStore: 'missing_env_store';
339
+ readonly MissingSecretResolver: 'missing_secret_resolver';
340
+ readonly EnvNotFound: 'env_not_found';
341
+ readonly ProtectionRuleBlock: 'protection_rule_block';
342
+ readonly MissingToken: 'missing_token';
343
+ readonly MissingInstallEnv: 'missing_install_env';
279
344
  /** A protection gate held the workflow install (hold / wait / queue). */
280
- readonly Held: "held";
345
+ readonly Held: 'held';
281
346
  };
282
347
  export type InstallSecretsDecisionReason = (typeof InstallSecretsDecisionReason)[keyof typeof InstallSecretsDecisionReason];
283
348
  /**
@@ -286,8 +351,8 @@ export type InstallSecretsDecisionReason = (typeof InstallSecretsDecisionReason)
286
351
  * - `install_env` is Option C (committed `.kici/.npmrc` + `installEnv:`).
287
352
  */
288
353
  export declare const InstallSecretsChannel: {
289
- readonly Registries: "registries";
290
- readonly InstallEnv: "install_env";
354
+ readonly Registries: 'registries';
355
+ readonly InstallEnv: 'install_env';
291
356
  };
292
357
  export type InstallSecretsChannel = (typeof InstallSecretsChannel)[keyof typeof InstallSecretsChannel];
293
358
  /**
@@ -334,6 +399,38 @@ export declare const installSecretsContributorStrippedTotal: import("@openteleme
334
399
  * - environment: the environment name referenced in the qualified `<environment>:<secret>` ref (per-org count is typically <10)
335
400
  */
336
401
  export declare const installSecretsTokenResolutionDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
402
+ /**
403
+ * Terminal dispatch_queue rows deleted by the retention sweep (the cleanup
404
+ * tick's `pruneTerminalDispatchRows`).
405
+ */
406
+ export declare const dispatchQueueRowsPrunedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
407
+ /**
408
+ * Step-log objects deleted by the retention sweep (the cleanup tick's
409
+ * `pruneExpiredLogs`, S3 backend only).
410
+ */
411
+ export declare const stepLogsPrunedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
412
+ /**
413
+ * `check_run_tracking` rows deleted by the retention sweep (the cleanup tick's
414
+ * `pruneStale`).
415
+ */
416
+ export declare const checkRunTrackingRowsPrunedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
417
+ /**
418
+ * Unsupported-message NACKs the orchestrator SENT back to the Platform — an
419
+ * inbound frame whose type this orchestrator build does not understand
420
+ * (Platform is ahead). Labelled by `received_type`.
421
+ */
422
+ export declare const wsUnsupportedMessageSentTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
423
+ /**
424
+ * NACKs the orchestrator RECEIVED from the Platform — the Platform could not
425
+ * process a frame we sent (this orchestrator is ahead). Labelled by
426
+ * `received_type`.
427
+ */
428
+ export declare const wsNackReceivedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
429
+ /**
430
+ * Feature-gated sends the orchestrator SUPPRESSED because the Platform advertised
431
+ * a capability set that lacks the required flag. Labelled by `capability` + `type`.
432
+ */
433
+ export declare const wsPlatformCapabilityGapTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
337
434
  /**
338
435
  * Register every queued orchestrator observable gauge on the real meter.
339
436
  *
@@ -0,0 +1,37 @@
1
+ import type { JWK } from 'jose';
2
+ import { type Signer } from './signer.js';
3
+ /** Minimal surface of the KMS client we use (so tests can inject a fake). */
4
+ export interface KmsLike {
5
+ send(command: unknown): Promise<{
6
+ PublicKey?: Uint8Array;
7
+ Signature?: Uint8Array;
8
+ }>;
9
+ }
10
+ export interface AwsKmsSignerOptions {
11
+ client: KmsLike;
12
+ keyArn: string;
13
+ }
14
+ /**
15
+ * Signs with an AWS KMS asymmetric ECC_NIST_P256 key (ES256). The private key
16
+ * never leaves KMS; sign() is a kms:Sign call. getPublicJwk() resolves once via
17
+ * kms:GetPublicKey and is cached. Ported verbatim from the Platform.
18
+ */
19
+ export declare class AwsKmsSigner implements Signer {
20
+ private readonly opts;
21
+ readonly alg: 'ES256';
22
+ readonly signerKind = "aws-kms";
23
+ readonly keyRef: string;
24
+ private cachedJwk?;
25
+ constructor(opts: AwsKmsSignerOptions);
26
+ /** Build a KMS client with explicit, dedicated AWS creds (NOT the ambient AWS_* chain). */
27
+ static fromCredentials(opts: {
28
+ keyArn: string;
29
+ region: string;
30
+ accessKeyId: string;
31
+ secretAccessKey: string;
32
+ }): AwsKmsSigner;
33
+ sign(data: Uint8Array): Promise<Uint8Array>;
34
+ getPublicJwk(): Promise<JWK>;
35
+ getKid(): Promise<string>;
36
+ }
37
+ //# sourceMappingURL=aws-kms-signer.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { type JWK } from 'jose';
2
+ import type { Signer } from './signer.js';
3
+ export declare class CommandSigner implements Signer {
4
+ private readonly command;
5
+ private readonly publicJwk;
6
+ readonly alg: 'ES256';
7
+ readonly signerKind = "command";
8
+ readonly keyRef: string;
9
+ private constructor();
10
+ /** Resolve the public JWK once (via `<command> get-public-jwk`) and build the signer. */
11
+ static create(opts: {
12
+ command: string;
13
+ }): Promise<CommandSigner>;
14
+ /** Build directly from a known public JWK (tests / preloaded material). */
15
+ static fromPublicJwk(opts: {
16
+ command: string;
17
+ publicJwk: JWK;
18
+ }): Promise<CommandSigner>;
19
+ sign(data: Uint8Array): Promise<Uint8Array>;
20
+ getPublicJwk(): Promise<JWK>;
21
+ getKid(): Promise<string>;
22
+ }
23
+ //# sourceMappingURL=command-signer.d.ts.map
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Persistent ES256 signer whose private JWK lives AES-256-GCM-wrapped in the
3
+ * orchestrator DB (`orchestrator_signing_keys.encrypted_private_jwk`), wrapped
4
+ * with the orchestrator's `KICI_SECRET_KEY` master key — the same posture as
5
+ * `scoped_secrets` and the run ephemeral keys. The master key lives in env / KMS
6
+ * and never in the DB, so a DB backup alone cannot sign.
7
+ *
8
+ * The in-memory private key is imported NON-EXTRACTABLE (`extractable: false`),
9
+ * so once loaded the raw private material can never be read back out of the
10
+ * process — the only export path is the public JWK. This is what makes the
11
+ * private key "non-exportable by design" (design spec § A / § H).
12
+ */
13
+ import { type JWK } from 'jose';
14
+ import type { Signer } from './signer.js';
15
+ /** AAD binding the wrapped private JWK to its purpose (AES-GCM authenticated data). */
16
+ export declare const SIGNING_KEY_AAD = "orchestrator-signing-key";
17
+ /** Encrypt a private JWK with the master key. Returns the base64 wrapped blob. */
18
+ export declare function wrapPrivateJwk(privateJwk: JWK, secretKey: string): string;
19
+ /** Decrypt a wrapped private JWK with the master key. Throws on wrong key / tamper. */
20
+ export declare function unwrapPrivateJwk(encrypted: string, secretKey: string): JWK;
21
+ export declare class DbSigner implements Signer {
22
+ private readonly privateKey;
23
+ private readonly publicJwk;
24
+ readonly alg: 'ES256';
25
+ readonly signerKind = "db";
26
+ readonly keyRef: null;
27
+ private constructor();
28
+ /** Import an EC P-256 private JWK NON-EXTRACTABLE and derive its public half. */
29
+ private static fromPrivateJwk;
30
+ /**
31
+ * Generate a fresh ES256 keypair, wrap the private half with the master key,
32
+ * and return the signer + the artifacts to persist. The generated private key
33
+ * is extractable only long enough to serialize + wrap it; the returned signer
34
+ * re-imports it non-extractable.
35
+ */
36
+ static generate(secretKey: string): Promise<{
37
+ signer: DbSigner;
38
+ publicJwk: JWK;
39
+ encryptedPrivateJwk: string;
40
+ kid: string;
41
+ }>;
42
+ /** Reconstruct a signer from a wrapped private JWK. */
43
+ static fromEncrypted(encryptedPrivateJwk: string, secretKey: string): Promise<DbSigner>;
44
+ sign(data: Uint8Array): Promise<Uint8Array>;
45
+ getPublicJwk(): Promise<JWK>;
46
+ getKid(): Promise<string>;
47
+ }
48
+ //# sourceMappingURL=db-signer.d.ts.map
@@ -1,10 +1,12 @@
1
1
  /**
2
- * OIDC ID-token claims for the local dev-signed identity. Mirrors the Platform's
3
- * `oidc/id-token-claims.ts` so a dev-signed bundle carries the exact same claim
4
- * shape the agent's statement builder + the engine verifier already expect — the
5
- * cross-check between the in-toto statement and the token claims is identical to
6
- * the Platform-minted path. The only differences are the local sentinel issuer
7
- * (`kici-local`) and the org anchor (`__default__`, the plane's default org).
2
+ * OIDC ID-token claims for orchestrator-side minting shared by the
3
+ * production orchestrator-owned mint (`orchestrator-mint.ts`) and the local
4
+ * dev-signed identity (`local-mint.ts`). Mirrors the Platform's claim shape so
5
+ * every bundle carries the exact same claims the agent's statement builder +
6
+ * the engine verifier expect the cross-check between the in-toto statement
7
+ * and the token claims is identical across all minters. The dev-signed path
8
+ * differs only in the local sentinel issuer (`kici-local`) and the org anchor
9
+ * (`__default__`, the plane's default org).
8
10
  */
9
11
  import { AttestationOrigin, SourceOrigin } from '@kici-dev/engine';
10
12
  /** The subset of an execution_runs row the claims need. */
@@ -31,6 +33,16 @@ export interface BuildClaimsOpts {
31
33
  audience: string;
32
34
  nowSeconds: number;
33
35
  ttlSeconds: number;
36
+ /**
37
+ * Deferred-fulfilment marker: binds the frozen DSSE statement hash + the
38
+ * mint-timing origin. Absent for a live (synchronous) mint. The local dev
39
+ * plane never sets this; the orchestrator-owned mint sets it when re-minting
40
+ * for a completed job bound to a frozen statement.
41
+ */
42
+ deferred?: {
43
+ statementHash: string;
44
+ origin: 'deferred' | 'offline-backfill';
45
+ };
34
46
  }
35
47
  export interface IdTokenClaims {
36
48
  iss: string;
@@ -55,9 +67,10 @@ export interface IdTokenClaims {
55
67
  }
56
68
  /**
57
69
  * Build the OIDC ID-token claims for a build job from the orchestrator's own
58
- * execution_runs/execution_jobs rows. The local dev plane only ever mints for a
59
- * live (running) job, so `attestation_origin` is always `live` and
60
- * `statement_hash` is null (the statement is cross-checked field-by-field).
70
+ * execution_runs/execution_jobs rows. A live (synchronous) mint leaves
71
+ * `attestation_origin=live` and `statement_hash=null` (the statement is
72
+ * cross-checked field-by-field); a deferred fulfilment stamps the frozen
73
+ * statement hash + origin marker via `opts.deferred`.
61
74
  */
62
75
  export declare function buildIdTokenClaims(run: RunClaimSource, job: JobClaimSource, opts: BuildClaimsOpts): IdTokenClaims;
63
76
  //# sourceMappingURL=id-token-claims.d.ts.map
@@ -4,12 +4,15 @@
4
4
  * returns the JOSE-raw r||s ES256 signature directly, so we base64url-assemble
5
5
  * the compact JWS (`header.payload.signature`) by hand.
6
6
  */
7
- import type { LocalSigner } from './local-dev-signer.js';
8
7
  export interface JwsProtectedHeader {
9
8
  alg: 'ES256';
10
9
  kid: string;
11
10
  typ: 'JWT';
12
11
  }
12
+ /** The minimal signing surface `signCompactJws` needs (both `LocalSigner` and `Signer` satisfy it). */
13
+ export interface CompactJwsSigner {
14
+ sign(data: Uint8Array): Promise<Uint8Array>;
15
+ }
13
16
  /** Assemble a compact JWS from a protected header + payload, signed by `signer`. */
14
- export declare function signCompactJws(signer: LocalSigner, protectedHeader: JwsProtectedHeader, payload: Record<string, unknown>): Promise<string>;
17
+ export declare function signCompactJws(signer: CompactJwsSigner, protectedHeader: JwsProtectedHeader, payload: Record<string, unknown>): Promise<string>;
15
18
  //# sourceMappingURL=jwt.d.ts.map
@@ -18,7 +18,7 @@ export interface LocalSigner {
18
18
  export declare class LocalDevSigner implements LocalSigner {
19
19
  private readonly privateKey;
20
20
  private readonly publicJwk;
21
- readonly alg: "ES256";
21
+ readonly alg: 'ES256';
22
22
  private constructor();
23
23
  /** Build a signer from an EC P-256 private JWK (`{ kty, crv, x, y, d }`). */
24
24
  static fromPrivateJwk(jwk: JWK): Promise<LocalDevSigner>;
@@ -1,19 +1,23 @@
1
1
  /**
2
2
  * Selects which OIDC-mint handler backs `OIDC_TOKEN_REQUEST_METHOD` — the
3
- * anti-forgery choke point for dev-signed identity.
3
+ * anti-forgery choke point for signed identity.
4
4
  *
5
5
  * The rule (enforced here, unit-tested in `oidc-mint-registration.test.ts`):
6
6
  *
7
- * 1. **Platform-connected** (platformUrl + token + client) the **relay**
8
- * handler, minting via the hosted Platform exactly as today.
9
- * 2. **Offline local dev plane** (independent identity + a local signer, AND
7
+ * 1. **Orchestrator-owned signing** (a resolved signer + the orchestrator's own
8
+ * provenance issuer) the **orchestrator** handler, minting + signing
9
+ * locally. Wins whenever signing is configured even Platform-connected
10
+ * because the orchestrator is now the root of trust.
11
+ * 2. **Platform-connected** (platformUrl + token + client), no signer → the
12
+ * **relay** handler, minting via the hosted Platform (the DEPRECATED path,
13
+ * kept for orchestrators with no signer configured).
14
+ * 3. **Offline local dev plane** (independent identity + a local signer, AND
10
15
  * NOT Platform-connected) → the **local** dev-signed handler (`kici-local`).
11
- * 3. Neither → **no** registration (the method returns "unknown method").
16
+ * 4. None → **no** registration (the method returns "unknown method").
12
17
  *
13
- * Case 1 is checked FIRST, so the local signer is UNREACHABLE whenever a
14
- * Platform connection existseven if `KICI_INDEPENDENT_IDENTITY` is somehow
15
- * also set. This guarantees no new forgeable mint path appears on a
16
- * Platform-connected orchestrator.
18
+ * The identity claims are always read SERVER-SIDE from the orchestrator's own
19
+ * rows and job ownership from dispatch state no forgeable agent-asserted mint
20
+ * path appears in any case.
17
21
  */
18
22
  import type { Kysely } from 'kysely';
19
23
  import type { OidcTokenResult } from '@kici-dev/engine/protocol/messages/oidc-token-relay';
@@ -21,10 +25,14 @@ import type { Database } from '../db/types.js';
21
25
  import { type MintPlatformClient } from '../ws/oidc-token-relay.js';
22
26
  import { type LocalMintOwnershipResolver } from './local-mint.js';
23
27
  import type { LocalSigner } from './local-dev-signer.js';
28
+ import type { Signer } from './signer.js';
24
29
  export type OidcMintHandler = (agentId: string, params: Record<string, unknown>) => Promise<OidcTokenResult>;
25
30
  export interface OidcMintRegistration {
26
- /** `relay` = Platform-minted; `local` = offline dev-signed (`kici-local`). */
27
- kind: 'relay' | 'local';
31
+ /**
32
+ * `orchestrator` = orchestrator-owned signing (the new root of trust);
33
+ * `relay` = Platform-minted (deprecated); `local` = offline dev-signed.
34
+ */
35
+ kind: 'orchestrator' | 'relay' | 'local';
28
36
  handler: OidcMintHandler;
29
37
  }
30
38
  export interface OidcMintRegistrationInput {
@@ -33,6 +41,14 @@ export interface OidcMintRegistrationInput {
33
41
  platformClient?: MintPlatformClient;
34
42
  independentIdentity: boolean;
35
43
  localOidcSigner?: LocalSigner;
44
+ /**
45
+ * Lazily resolve the orchestrator's own provenance signer (Task 7 reconcile).
46
+ * Present whenever orchestrator-owned signing is configured; the signer itself
47
+ * is resolved on first mint (leader-election-race-safe).
48
+ */
49
+ resolveOrchestratorSigner?: () => Promise<Signer | null>;
50
+ /** The orchestrator's own provenance issuer identity (config.provenanceSigningIssuer). */
51
+ provenanceSigningIssuer?: string;
36
52
  dispatcher: LocalMintOwnershipResolver & {
37
53
  resolveOwnedJob(agentId: string, jobId: string): {
38
54
  runId: string;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Orchestrator-owned OIDC identity mint (production).
3
+ *
4
+ * Production sibling of `local-mint.ts`: the orchestrator mints the short-lived
5
+ * ES256 ID token for a build job LOCALLY from its own execution_runs/
6
+ * execution_jobs rows, signed with its own long-lived signing key (`Signer`),
7
+ * issued under its own real issuer. Zero hosted-Platform dependency.
8
+ *
9
+ * Anti-forgery is identical to the Platform-minted path and the local dev plane:
10
+ * every identity claim (run/job/repo/ref/sha/org) is read SERVER-SIDE from the
11
+ * orchestrator's own rows — never from the agent's wire input — and job ownership
12
+ * is resolved from dispatch state, never agent-asserted. The token is never
13
+ * logged.
14
+ */
15
+ import type { Kysely } from 'kysely';
16
+ import { type OidcTokenResult } from '@kici-dev/engine/protocol/messages/oidc-token-relay';
17
+ import type { Database } from '../db/types.js';
18
+ import { type IdTokenClaims } from './id-token-claims.js';
19
+ import type { Signer } from './signer.js';
20
+ /** The org anchor stamped when a run has no routing key (sourceless / local plane). */
21
+ export declare const DEFAULT_ORG_ID = "__default__";
22
+ /** ID-token lifetime (seconds). Matches the Platform's 10-minute cap. */
23
+ export declare const ORCHESTRATOR_ID_TOKEN_TTL_SECONDS = 600;
24
+ export declare class OrchestratorMintRunNotFoundError extends Error {
25
+ }
26
+ export declare class OrchestratorMintJobNotFoundError extends Error {
27
+ }
28
+ export declare class OrchestratorMintJobNotActiveError extends Error {
29
+ }
30
+ export interface OrchestratorMintDeps {
31
+ db: Kysely<Database>;
32
+ signer: Signer;
33
+ /** The orchestrator's own provenance issuer identity (real URL). */
34
+ issuer: string;
35
+ orchestratorId: string;
36
+ ttlSeconds?: number;
37
+ /** Injectable clock (seconds). Defaults to wall-clock. */
38
+ nowSeconds?: () => number;
39
+ }
40
+ export interface OrchestratorMintInput {
41
+ runId: string;
42
+ jobId: string;
43
+ audience: string;
44
+ /**
45
+ * Deferred-fulfilment mint: knowingly targets a completed (terminal) job and
46
+ * binds the frozen statement hash + origin so the terminal-job check is
47
+ * relaxed and the mint-timing marker is stamped. The live agent path never
48
+ * sets this.
49
+ */
50
+ deferred?: {
51
+ statementHash: string;
52
+ origin: 'deferred' | 'offline-backfill';
53
+ };
54
+ }
55
+ export interface OrchestratorMintResult {
56
+ token: string;
57
+ expiresIn: number;
58
+ jti: string;
59
+ claims: IdTokenClaims;
60
+ }
61
+ /**
62
+ * Mint a short-lived ES256 ID token for (run, job) from the orchestrator's own
63
+ * rows, signed with the orchestrator's signing key.
64
+ */
65
+ export declare function mintOrchestratorIdToken(deps: OrchestratorMintDeps, input: OrchestratorMintInput): Promise<OrchestratorMintResult>;
66
+ /** Job-ownership resolver surface (the dispatcher's `resolveOwnedJob`). */
67
+ export interface OrchestratorMintOwnershipResolver {
68
+ resolveOwnedJob(agentId: string, jobId: string): {
69
+ runId: string;
70
+ } | undefined;
71
+ }
72
+ export declare class OrchestratorMintRejectedError extends Error {
73
+ }
74
+ /** unavailable: the signing key is not yet resolvable (leader election / cold start). */
75
+ export declare class OrchestratorMintSignerUnavailableError extends Error {
76
+ }
77
+ export interface OrchestratorOidcTokenHandlerDeps {
78
+ dispatcher: OrchestratorMintOwnershipResolver;
79
+ /**
80
+ * Lazily resolve the orchestrator's signing key. Resolved on first token
81
+ * request (not at boot) so it is unaffected by the Raft leader-election race —
82
+ * by the time an agent requests a token the cluster has a leader and the key
83
+ * exists. May return null while the key is still being reconciled.
84
+ */
85
+ resolveSigner: () => Promise<Signer | null>;
86
+ /** Mint deps except the signer (supplied lazily via `resolveSigner`). */
87
+ mint: Omit<OrchestratorMintDeps, 'signer'>;
88
+ }
89
+ /**
90
+ * Build the agent.api handler for `OIDC_TOKEN_REQUEST_METHOD` when the
91
+ * orchestrator owns its signing key. Verifies the agent owns the named job
92
+ * (resolving its runId from the dispatcher — never an agent-asserted value),
93
+ * resolves the signing key lazily, then mints locally. A job the agent does not
94
+ * own is rejected without minting; an unresolved signer defers (never crashes).
95
+ */
96
+ export declare function createOrchestratorOidcTokenHandler(deps: OrchestratorOidcTokenHandlerDeps): (agentId: string, params: Record<string, unknown>) => Promise<OidcTokenResult>;
97
+ //# sourceMappingURL=orchestrator-mint.d.ts.map