@kici-dev/orchestrator 0.17.0 → 0.19.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 (592) hide show
  1. package/dist/agent/agent-version.d.ts +12 -21
  2. package/dist/agent/dispatcher.d.ts +283 -437
  3. package/dist/agent/host-roster-reaper.d.ts +8 -10
  4. package/dist/agent/host-roster.d.ts +77 -100
  5. package/dist/agent/ownership-refusal.d.ts +3 -5
  6. package/dist/agent/ownership-tracker.d.ts +42 -76
  7. package/dist/agent/registry.d.ts +137 -230
  8. package/dist/agent/token-store.d.ts +34 -77
  9. package/dist/agent-packaging/availability.d.ts +6 -9
  10. package/dist/agent-packaging/download.d.ts +6 -9
  11. package/dist/agent-packaging/install-closure.d.ts +9 -12
  12. package/dist/agent-packaging/node-binary.d.ts +6 -10
  13. package/dist/agent-packaging/node-runtime-members.d.ts +3 -5
  14. package/dist/agent-packaging/refresh.d.ts +12 -16
  15. package/dist/agent-packaging/store.d.ts +5 -6
  16. package/dist/agent-packaging/upload.d.ts +3 -4
  17. package/dist/app.d.ts +0 -3
  18. package/dist/approvals/apply-decision.d.ts +35 -52
  19. package/dist/approvals/approval-resolver.d.ts +11 -23
  20. package/dist/approvals/held-run-release-wiring.d.ts +14 -21
  21. package/dist/approvals/independent-wiring.d.ts +13 -20
  22. package/dist/approvals/resume-router.d.ts +1 -1
  23. package/dist/approvals/step-approval-bridge.d.ts +11 -21
  24. package/dist/approvals/triggerer-subject.d.ts +8 -10
  25. package/dist/artifacts/artifact-store.d.ts +55 -95
  26. package/dist/artifacts/failure-messages.d.ts +15 -20
  27. package/dist/audit/access-log.d.ts +27 -45
  28. package/dist/audit/sampling-rate-limiter.d.ts +11 -23
  29. package/dist/cache/agent-job-failed-error.d.ts +2 -3
  30. package/dist/cache/build-coordinator.d.ts +5 -28
  31. package/dist/cache/cache-upload-settle.d.ts +11 -11
  32. package/dist/cache/dep-cache.d.ts +32 -60
  33. package/dist/cache/dispatch-cache-ref-tracker.d.ts +15 -23
  34. package/dist/cache/global-eval-round-cache.d.ts +33 -41
  35. package/dist/cache/pending-builds.d.ts +2 -6
  36. package/dist/cache/pending-dynamics.d.ts +2 -7
  37. package/dist/cache/pending-global-evals.d.ts +9 -12
  38. package/dist/cache/pending-inits.d.ts +11 -22
  39. package/dist/cache/pending-precursor-db-watcher.d.ts +24 -32
  40. package/dist/cache/pending-tracker.d.ts +17 -45
  41. package/dist/cache/precursor-result.d.ts +17 -30
  42. package/dist/cache/source-cache.d.ts +36 -65
  43. package/dist/cache/user-cache.d.ts +21 -25
  44. package/dist/cancel/cancel-held-run.d.ts +13 -16
  45. package/dist/cancel/cancel-route-answer.d.ts +1 -2
  46. package/dist/cancel/cancel-run.d.ts +26 -50
  47. package/dist/cancel/dashboard-cancel-handler.d.ts +2 -2
  48. package/dist/cancel/peer-job-cancel.d.ts +11 -14
  49. package/dist/cancel/sweep-stuck-cancelling.d.ts +9 -13
  50. package/dist/cli/api-client.d.ts +25 -76
  51. package/dist/cli/commands/access-log.d.ts +4 -24
  52. package/dist/cli/commands/agent-package.d.ts +7 -15
  53. package/dist/cli/commands/agent-service/agent-env.d.ts +3 -6
  54. package/dist/cli/commands/agent-service/index.d.ts +4 -10
  55. package/dist/cli/commands/agent-service/install.d.ts +4 -11
  56. package/dist/cli/commands/agent-service/status.d.ts +4 -9
  57. package/dist/cli/commands/agent-service/upgrade.d.ts +4 -16
  58. package/dist/cli/commands/agent.d.ts +12 -25
  59. package/dist/cli/commands/api-key.d.ts +5 -12
  60. package/dist/cli/commands/attestations-list.d.ts +7 -17
  61. package/dist/cli/commands/attestations-retry.d.ts +5 -11
  62. package/dist/cli/commands/attestations-reverify.d.ts +4 -5
  63. package/dist/cli/commands/attestations.d.ts +3 -8
  64. package/dist/cli/commands/audit.d.ts +1 -5
  65. package/dist/cli/commands/backend.d.ts +2 -11
  66. package/dist/cli/commands/check-run.d.ts +7 -18
  67. package/dist/cli/commands/cluster-name.d.ts +5 -12
  68. package/dist/cli/commands/cluster-settings.d.ts +28 -53
  69. package/dist/cli/commands/cold-store.d.ts +7 -15
  70. package/dist/cli/commands/config.d.ts +9 -20
  71. package/dist/cli/commands/context.d.ts +8 -20
  72. package/dist/cli/commands/dashboard-encryption-key.d.ts +9 -14
  73. package/dist/cli/commands/db-backup.d.ts +17 -32
  74. package/dist/cli/commands/db.d.ts +3 -4
  75. package/dist/cli/commands/debug-bundle.d.ts +3 -10
  76. package/dist/cli/commands/diagnose.d.ts +3 -14
  77. package/dist/cli/commands/event-dlq.d.ts +4 -12
  78. package/dist/cli/commands/event-log.d.ts +2 -20
  79. package/dist/cli/commands/execution.d.ts +3 -9
  80. package/dist/cli/commands/firecracker/index.d.ts +3 -6
  81. package/dist/cli/commands/held-run.d.ts +23 -37
  82. package/dist/cli/commands/host.d.ts +4 -11
  83. package/dist/cli/commands/inspect-bundle.d.ts +3 -11
  84. package/dist/cli/commands/local-hook.d.ts +2 -10
  85. package/dist/cli/commands/local-trigger.d.ts +2 -2
  86. package/dist/cli/commands/orchestrator-service/drain.d.ts +3 -6
  87. package/dist/cli/commands/orchestrator-service/index.d.ts +6 -14
  88. package/dist/cli/commands/orchestrator-service/install-env.d.ts +25 -49
  89. package/dist/cli/commands/orchestrator-service/install.d.ts +2 -5
  90. package/dist/cli/commands/orchestrator-service/status.d.ts +10 -22
  91. package/dist/cli/commands/orchestrator-service/upgrade.d.ts +6 -15
  92. package/dist/cli/commands/org-settings.d.ts +5 -11
  93. package/dist/cli/commands/peer.d.ts +5 -10
  94. package/dist/cli/commands/queue.d.ts +3 -9
  95. package/dist/cli/commands/registration.d.ts +4 -8
  96. package/dist/cli/commands/remote-source.d.ts +6 -12
  97. package/dist/cli/commands/rotate.d.ts +1 -5
  98. package/dist/cli/commands/runs.d.ts +1 -30
  99. package/dist/cli/commands/scaler.d.ts +5 -12
  100. package/dist/cli/commands/secret.d.ts +1 -9
  101. package/dist/cli/commands/service-health.d.ts +5 -10
  102. package/dist/cli/commands/shared/admin-cli-access-log.d.ts +10 -19
  103. package/dist/cli/commands/shared/bare-metal-binary-check.d.ts +86 -0
  104. package/dist/cli/commands/shared/cli-action.d.ts +1 -4
  105. package/dist/cli/commands/shared/confirm.d.ts +5 -10
  106. package/dist/cli/commands/shared/db.d.ts +1 -12
  107. package/dist/cli/commands/shared/env-file-mode.d.ts +6 -9
  108. package/dist/cli/commands/shared/secret-input.d.ts +7 -21
  109. package/dist/cli/commands/shared/service-verbs.d.ts +6 -12
  110. package/dist/cli/commands/shared/unbound-context-warning.d.ts +2 -4
  111. package/dist/cli/commands/shared/upgrade-hooks.d.ts +7 -16
  112. package/dist/cli/commands/shared/upgrade-safety.d.ts +20 -31
  113. package/dist/cli/commands/shared/versioned-upgrade.d.ts +83 -161
  114. package/dist/cli/commands/signing-key.d.ts +4 -9
  115. package/dist/cli/commands/source-manifest.d.ts +11 -14
  116. package/dist/cli/commands/source.d.ts +7 -32
  117. package/dist/cli/commands/token.d.ts +4 -15
  118. package/dist/cli/commands/trust-policy.d.ts +35 -88
  119. package/dist/cli/commands/variable.d.ts +3 -5
  120. package/dist/cli/commands/workflow.d.ts +3 -24
  121. package/dist/cli/join.d.ts +3 -6
  122. package/dist/cli/kici-admin.d.ts +11 -29
  123. package/dist/cli/lazy-deps/cache.d.ts +1 -14
  124. package/dist/cli/lazy-deps/downloader.d.ts +4 -27
  125. package/dist/cli/lazy-deps/registry.d.ts +5 -25
  126. package/dist/cli/local-github-ingress-url.d.ts +5 -7
  127. package/dist/cli/loopback-callback.d.ts +6 -7
  128. package/dist/cli/open-browser.d.ts +4 -8
  129. package/dist/cli/root-option-routing.d.ts +17 -29
  130. package/dist/cli/service/backup-timer.d.ts +16 -39
  131. package/dist/cli/service/compose-path.d.ts +3 -7
  132. package/dist/cli/service/compose.d.ts +12 -30
  133. package/dist/cli/service/deploy-env.d.ts +6 -18
  134. package/dist/cli/service/entrypoint.d.ts +14 -25
  135. package/dist/cli/service/env-assignment.d.ts +6 -17
  136. package/dist/cli/service/image-digests.d.ts +6 -15
  137. package/dist/cli/service/index.d.ts +2 -18
  138. package/dist/cli/service/instance/index-file.d.ts +9 -16
  139. package/dist/cli/service/instance/manifest.d.ts +60 -60
  140. package/dist/cli/service/instance/resolve.d.ts +32 -68
  141. package/dist/cli/service/instance/types.d.ts +12 -29
  142. package/dist/cli/service/launchd.d.ts +29 -60
  143. package/dist/cli/service/platform-detect.d.ts +13 -68
  144. package/dist/cli/service/privilege.d.ts +12 -25
  145. package/dist/cli/service/shutdown-grace.d.ts +11 -20
  146. package/dist/cli/service/systemd.d.ts +7 -20
  147. package/dist/cli/service/types.d.ts +63 -114
  148. package/dist/cli/service/windows-acl.d.ts +14 -21
  149. package/dist/cli/service/windows-env-file.d.ts +10 -28
  150. package/dist/cli/service/windows.d.ts +15 -31
  151. package/dist/cli/webhook-url-notes.d.ts +4 -6
  152. package/dist/cli/wizard/agent-wizard.d.ts +3 -14
  153. package/dist/cli/wizard/orchestrator-wizard.d.ts +12 -37
  154. package/dist/cli/wizard/prompts.d.ts +6 -16
  155. package/dist/cli.js +8207 -10128
  156. package/dist/cluster/cluster-identity.d.ts +20 -32
  157. package/dist/cluster/cluster-settings-reader.d.ts +50 -77
  158. package/dist/cluster/coordinator-credential.d.ts +4 -5
  159. package/dist/cluster/coordinator.d.ts +76 -148
  160. package/dist/cluster/health-api.d.ts +2 -10
  161. package/dist/cluster/index.d.ts +1 -6
  162. package/dist/cluster/instance-heartbeat.d.ts +26 -42
  163. package/dist/cluster/join-client.d.ts +4 -7
  164. package/dist/cluster/join-handler.d.ts +3 -7
  165. package/dist/cluster/join-token.d.ts +13 -27
  166. package/dist/cluster/leader-gated-scheduler.d.ts +8 -17
  167. package/dist/cluster/orphan-recovery.d.ts +13 -35
  168. package/dist/cluster/peer-auth-coordinator.d.ts +2 -8
  169. package/dist/cluster/peer-client.d.ts +46 -76
  170. package/dist/cluster/peer-credentials.d.ts +24 -70
  171. package/dist/cluster/peer-crypto.d.ts +5 -26
  172. package/dist/cluster/peer-forget.d.ts +3 -3
  173. package/dist/cluster/peer-handler.d.ts +47 -71
  174. package/dist/cluster/peer-registry.d.ts +37 -106
  175. package/dist/cluster/plan-headroom-store.d.ts +4 -6
  176. package/dist/cluster/raft-state.d.ts +4 -13
  177. package/dist/cluster/raft.d.ts +18 -53
  178. package/dist/cluster/reconcile-identity.d.ts +8 -11
  179. package/dist/cluster/rerouted-job-guard.d.ts +7 -11
  180. package/dist/cluster/verified-issuer.d.ts +2 -3
  181. package/dist/cluster/worker-cluster-settings.d.ts +7 -10
  182. package/dist/cluster/worker-eviction.d.ts +16 -26
  183. package/dist/cold-store/load-access-log-range.d.ts +15 -31
  184. package/dist/cold-store/load-event-log-range.d.ts +13 -27
  185. package/dist/cold-store/load-secret-audit-log-range.d.ts +8 -12
  186. package/dist/cold-store/orchestrator-cold-store.d.ts +8 -28
  187. package/dist/cold-store/tables/access-log.d.ts +12 -14
  188. package/dist/cold-store/tables/event-log.d.ts +4 -8
  189. package/dist/cold-store/tables/execution-runs.d.ts +6 -11
  190. package/dist/cold-store/tables/secret-audit-log.d.ts +5 -12
  191. package/dist/concurrency/dispatch-next-queued.d.ts +13 -25
  192. package/dist/concurrency/queue-manager.d.ts +22 -54
  193. package/dist/concurrency/waiters.d.ts +15 -31
  194. package/dist/config/encryption.d.ts +0 -2
  195. package/dist/config/loader.d.ts +0 -1
  196. package/dist/config/reload.d.ts +0 -6
  197. package/dist/config/resolver.d.ts +0 -4
  198. package/dist/config/shared-store.d.ts +0 -2
  199. package/dist/config/types.d.ts +0 -3
  200. package/dist/content-requirements-cache.d.ts +0 -1
  201. package/dist/contexts/context-store.d.ts +0 -2
  202. package/dist/contexts/held-runs.d.ts +0 -2
  203. package/dist/contexts/variable-store.d.ts +0 -2
  204. package/dist/dashboard/attestation-filters.d.ts +13 -18
  205. package/dist/dashboard/handler.d.ts +145 -307
  206. package/dist/db/client.d.ts +2 -6
  207. package/dist/db/deferred-index-build.d.ts +8 -10
  208. package/dist/db/deferred-indexes.d.ts +15 -22
  209. package/dist/db/migration-provider.d.ts +2 -4
  210. package/dist/db/migration-test-harness.d.ts +26 -44
  211. package/dist/db/migrations/001_initial.d.ts +1 -4
  212. package/dist/db/migrations/002_config_versions_key_version.d.ts +5 -8
  213. package/dist/db/migrations/003_access_log.d.ts +10 -15
  214. package/dist/db/migrations/004_rename_bundle_to_source.d.ts +7 -9
  215. package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +4 -10
  216. package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +9 -29
  217. package/dist/db/migrations/007_audit_logs_archived_at.d.ts +11 -30
  218. package/dist/db/migrations/008_event_log_archived_at.d.ts +14 -29
  219. package/dist/db/migrations/009_access_log_trigram.d.ts +4 -8
  220. package/dist/db/migrations/010_cold_store_chunks.d.ts +16 -26
  221. package/dist/db/migrations/011_drop_source_secrets_notify.d.ts +6 -14
  222. package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +9 -14
  223. package/dist/db/migrations/013_execution_log_bytes.d.ts +5 -13
  224. package/dist/db/migrations/014_kici_events_lease_retry.d.ts +14 -27
  225. package/dist/db/migrations/015_org_settings_customer_scoped.d.ts +12 -17
  226. package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +4 -6
  227. package/dist/db/migrations/019_generic_sources_change_notify.d.ts +13 -17
  228. package/dist/db/migrations/020_org_settings_dashboard_write_policy.d.ts +5 -8
  229. package/dist/db/migrations/021_check_run_tracking.d.ts +5 -17
  230. package/dist/db/migrations/022_scaler_manager_state.d.ts +10 -20
  231. package/dist/db/migrations/023_dispatch_queue_recovery_deadline.d.ts +7 -18
  232. package/dist/db/migrations/024_dispatch_queue_provisioning_error.d.ts +5 -11
  233. package/dist/db/migrations/025_init_failure.d.ts +5 -9
  234. package/dist/db/migrations/027_workflow_timeout.d.ts +5 -13
  235. package/dist/db/migrations/029_dispatch_queue_attempts.d.ts +4 -10
  236. package/dist/db/migrations/030_held_runs_env_set_null.d.ts +5 -6
  237. package/dist/db/migrations/031_dispatch_queue_ack_deadline.d.ts +6 -12
  238. package/dist/db/migrations/033_org_settings_approval.d.ts +7 -10
  239. package/dist/db/migrations/034_held_runs_generalize.d.ts +10 -18
  240. package/dist/db/migrations/035_pending_workflow_contexts.d.ts +4 -5
  241. package/dist/db/migrations/037_generic_sources_provider_type_local.d.ts +5 -6
  242. package/dist/db/migrations/038_remote_sources.d.ts +5 -7
  243. package/dist/db/migrations/045_host_properties.d.ts +5 -9
  244. package/dist/db/migrations/046_join_token_consumed_by_instance.d.ts +5 -10
  245. package/dist/db/migrations/048_host_reboot_pending.d.ts +6 -12
  246. package/dist/db/migrations/049_held_runs_payload.d.ts +3 -8
  247. package/dist/db/migrations/050_sources_slug.d.ts +4 -5
  248. package/dist/db/migrations/051_binding_host_pattern.d.ts +7 -10
  249. package/dist/db/migrations/052_host_reach_metadata.d.ts +8 -11
  250. package/dist/db/migrations/053_agent_token_single_use.d.ts +6 -10
  251. package/dist/db/migrations/054_local_working_tree.d.ts +4 -6
  252. package/dist/db/migrations/055_agent_token_mandatory_labels.d.ts +6 -11
  253. package/dist/db/migrations/056_execution_jobs_environments.d.ts +4 -11
  254. package/dist/db/migrations/064_execution_jobs_skipped_environments.d.ts +6 -9
  255. package/dist/db/migrations/065_pending_attestations.d.ts +9 -12
  256. package/dist/db/migrations/066_pending_attestations_rejected.d.ts +4 -7
  257. package/dist/db/migrations/068_request_idempotency.d.ts +7 -9
  258. package/dist/db/migrations/069_reroute_tunables.d.ts +6 -14
  259. package/dist/db/migrations/071_batch_accumulation.d.ts +8 -16
  260. package/dist/db/migrations/072_dispatch_queue_run_id_index.d.ts +3 -9
  261. package/dist/db/migrations/074_normalize_zero_concurrency_limit.d.ts +4 -7
  262. package/dist/db/migrations/076_artifacts.d.ts +7 -8
  263. package/dist/db/migrations/078_org_settings_backup_staleness.d.ts +3 -6
  264. package/dist/db/migrations/079_org_settings_scaler_spawn_timeout.d.ts +4 -8
  265. package/dist/db/migrations/080_cluster_settings.d.ts +6 -10
  266. package/dist/db/migrations/081_org_settings_queue_timeout.d.ts +7 -11
  267. package/dist/db/migrations/082_host_s3_reachable.d.ts +5 -10
  268. package/dist/db/migrations/083_org_settings_artifact_caps.d.ts +6 -8
  269. package/dist/db/migrations/084_orchestrator_signing_keys.d.ts +8 -13
  270. package/dist/db/migrations/085_cluster_settings_reroute_flap_grace_ms.d.ts +4 -5
  271. package/dist/db/migrations/086_cluster_settings_max_fanout_hosts.d.ts +3 -3
  272. package/dist/db/migrations/087_cluster_settings_event_router_rate_limit.d.ts +5 -3
  273. package/dist/db/migrations/088_cluster_settings_cache_max_tarball_bytes.d.ts +3 -3
  274. package/dist/db/migrations/089_cluster_settings_cache_ttl_days.d.ts +3 -5
  275. package/dist/db/migrations/090_cluster_settings_concurrency_wait_timeout_ms.d.ts +3 -6
  276. package/dist/db/migrations/091_cluster_settings_agent_token_ttl_ms.d.ts +3 -6
  277. package/dist/db/migrations/092_cluster_settings_version.d.ts +5 -9
  278. package/dist/db/migrations/094_dashboard_encryption_keys.d.ts +9 -14
  279. package/dist/db/migrations/095_dashboard_write_policy_tristate.d.ts +2 -6
  280. package/dist/db/migrations/099_cluster_settings_dashboard_verified_issuer.d.ts +8 -11
  281. package/dist/db/migrations/101_contexts_hold_expiry_drop_default.d.ts +9 -15
  282. package/dist/db/migrations/102_dispatch_queue_agent_id.d.ts +6 -11
  283. package/dist/db/migrations/103_cluster_settings_ownership_db_check_timeout_ms.d.ts +6 -12
  284. package/dist/db/migrations/104_check_run_terminal_sent.d.ts +8 -14
  285. package/dist/db/migrations/105_org_trust_policy.d.ts +5 -7
  286. package/dist/db/migrations/106_cluster_settings_check_run_tracking_ttl_days.d.ts +4 -12
  287. package/dist/db/migrations/107_check_run_tracking_updated_at_index.d.ts +8 -14
  288. package/dist/db/migrations/113_execution_runs_workflow_repo_index.d.ts +10 -19
  289. package/dist/db/migrations/115_global_workflows_cluster_switch.d.ts +2 -3
  290. package/dist/db/migrations/121_org_settings_allow_untrusted_dockerfile_builds.d.ts +7 -8
  291. package/dist/db/migrations/122_host_roster_scaler_managed.d.ts +9 -16
  292. package/dist/db/migrations/123_workflow_registrations_default_branch.d.ts +8 -16
  293. package/dist/db/migrations/125_org_trust_directory.d.ts +13 -21
  294. package/dist/db/migrations/126_held_runs_posted_pending_check.d.ts +10 -16
  295. package/dist/db/migrations/127_org_trust_policy_approval_expiry_seconds.d.ts +8 -16
  296. package/dist/db/migrations/128_execution_runs_global_eval_round.d.ts +6 -11
  297. package/dist/db/migrations/129_execution_runs_dispatch_routing_key.d.ts +8 -11
  298. package/dist/db/migrations/130_scaler_provision_outcomes.d.ts +13 -20
  299. package/dist/db/migrations/131_execution_jobs_git_credentials.d.ts +12 -22
  300. package/dist/db/migrations/132_execution_runs_trigger_event.d.ts +6 -16
  301. package/dist/db/migrations/133_dispatch_queue_source_tar_digest.d.ts +6 -9
  302. package/dist/db/migrations/140_dispatch_queue_canonical_labels.d.ts +22 -40
  303. package/dist/db/migrations/143_execution_jobs_precursor_result.d.ts +9 -18
  304. package/dist/db/migrations/144_execution_runs_registration_window.d.ts +12 -20
  305. package/dist/db/migrations/147_sealed_job_secrets.d.ts +5 -9
  306. package/dist/db/migrations/148_cluster_settings_sealed_secrets_retry_backoff_ms.d.ts +7 -13
  307. package/dist/db/migrations/150_execution_runs_status_epoch.d.ts +6 -11
  308. package/dist/db/migrations/152_org_settings_cache_upload_settle_timeout.d.ts +5 -8
  309. package/dist/db/migrations/157_host_roster_identity_source.d.ts +9 -13
  310. package/dist/db/migrations/159_org_id_widen_to_source_width.d.ts +5 -0
  311. package/dist/db/migrator.d.ts +17 -25
  312. package/dist/db/notify-listener.d.ts +8 -11
  313. package/dist/db/repos/dashboard-encryption-keys-repo.d.ts +9 -10
  314. package/dist/db/synthetic-job-ids.d.ts +6 -8
  315. package/dist/db/types.d.ts +531 -1058
  316. package/dist/deployment/deployment-identity.d.ts +42 -60
  317. package/dist/diagnostics/bundle-reader.d.ts +3 -15
  318. package/dist/diagnostics/bundle-writer.d.ts +5 -12
  319. package/dist/diagnostics/checks/agents.d.ts +1 -7
  320. package/dist/diagnostics/checks/backup.d.ts +7 -10
  321. package/dist/diagnostics/checks/certs.d.ts +1 -6
  322. package/dist/diagnostics/checks/config.d.ts +2 -5
  323. package/dist/diagnostics/checks/db.d.ts +1 -1
  324. package/dist/diagnostics/checks/disk.d.ts +1 -6
  325. package/dist/diagnostics/checks/firecracker-network.d.ts +3 -3
  326. package/dist/diagnostics/checks/index.d.ts +0 -6
  327. package/dist/diagnostics/checks/retention.d.ts +3 -6
  328. package/dist/diagnostics/checks/scaler.d.ts +3 -7
  329. package/dist/diagnostics/checks/ws.d.ts +1 -6
  330. package/dist/diagnostics/fleet-collector.d.ts +11 -14
  331. package/dist/diagnostics/fleet-constants.d.ts +1 -3
  332. package/dist/diagnostics/fleet-selection.d.ts +3 -7
  333. package/dist/diagnostics/fleet-topology.d.ts +2 -6
  334. package/dist/diagnostics/fleet-wiring.d.ts +6 -12
  335. package/dist/diagnostics/index.d.ts +0 -5
  336. package/dist/diagnostics/runner.d.ts +4 -8
  337. package/dist/diagnostics/types.d.ts +10 -21
  338. package/dist/drain/drain-controller.d.ts +16 -22
  339. package/dist/entry-helpers.d.ts +0 -2
  340. package/dist/events/circuit-breaker.d.ts +0 -3
  341. package/dist/events/event-router.d.ts +1 -2
  342. package/dist/events/event-store.d.ts +0 -9
  343. package/dist/events/trust-store.d.ts +0 -3
  344. package/dist/events/types.d.ts +0 -9
  345. package/dist/firecracker/host-network.d.ts +24 -30
  346. package/dist/firecracker/net-interfaces.d.ts +4 -7
  347. package/dist/helpers/rate-limiter.d.ts +0 -1
  348. package/dist/index.js +240 -482
  349. package/dist/metrics/agent-metrics-aggregator.d.ts +24 -67
  350. package/dist/metrics/metrics-reporter.d.ts +4 -13
  351. package/dist/metrics/prometheus.d.ts +47 -81
  352. package/dist/orchestrator-core.d.ts +3 -7
  353. package/dist/pipeline/content-filter.d.ts +20 -30
  354. package/dist/pipeline/cross-source-tally.d.ts +7 -8
  355. package/dist/pipeline/decorating-secret-resolver.d.ts +4 -8
  356. package/dist/pipeline/degraded-reason.d.ts +3 -4
  357. package/dist/pipeline/direct-ingress-deps.d.ts +15 -24
  358. package/dist/pipeline/dispatch-matched-workflow.d.ts +290 -526
  359. package/dist/pipeline/flatten-lock-steps.d.ts +4 -6
  360. package/dist/pipeline/global-dispatch-identity.d.ts +5 -10
  361. package/dist/pipeline/global-eval-round.d.ts +62 -156
  362. package/dist/pipeline/global-round-hold.d.ts +5 -7
  363. package/dist/pipeline/held-context-data.d.ts +5 -8
  364. package/dist/pipeline/held-round-registrations.d.ts +8 -11
  365. package/dist/pipeline/install-gate.d.ts +15 -25
  366. package/dist/pipeline/install-secrets-resolver.d.ts +24 -34
  367. package/dist/pipeline/internal-event-pipeline.d.ts +45 -62
  368. package/dist/pipeline/invoke-gate.d.ts +27 -40
  369. package/dist/pipeline/job-contexts.d.ts +19 -36
  370. package/dist/pipeline/manual-schedule.d.ts +7 -13
  371. package/dist/pipeline/needs-scheduler.d.ts +29 -46
  372. package/dist/pipeline/pending-workflow-context.d.ts +14 -28
  373. package/dist/pipeline/process-webhook.d.ts +88 -123
  374. package/dist/pipeline/processor.d.ts +209 -355
  375. package/dist/pipeline/remote-source-store.d.ts +5 -8
  376. package/dist/pipeline/request-idempotency.d.ts +10 -13
  377. package/dist/pipeline/rerun-global.d.ts +6 -7
  378. package/dist/pipeline/rerun-inputs.d.ts +23 -37
  379. package/dist/pipeline/rerun.d.ts +34 -57
  380. package/dist/pipeline/resolve-sandbox-grant.d.ts +5 -10
  381. package/dist/pipeline/resume-workflow.d.ts +28 -34
  382. package/dist/pipeline/route-or-dispatch-jobs.d.ts +19 -30
  383. package/dist/pipeline/run-event-context.d.ts +16 -21
  384. package/dist/pipeline/sandbox-allowlist-reader.d.ts +7 -11
  385. package/dist/pipeline/security-hold-check.d.ts +56 -80
  386. package/dist/pipeline/test-pipeline.d.ts +20 -46
  387. package/dist/pipeline/unbound-job-context.d.ts +6 -9
  388. package/dist/pipeline/undispatched-hold-checks.d.ts +4 -6
  389. package/dist/pipeline/wave-scheduler.d.ts +15 -22
  390. package/dist/pipeline/webhook-payload-store.d.ts +3 -10
  391. package/dist/pipeline/workflow-lock-at-sha.d.ts +14 -20
  392. package/dist/policy/dashboard-write-policy.d.ts +1 -1
  393. package/dist/provider-registry.d.ts +0 -19
  394. package/dist/providers/generic/index.d.ts +0 -2
  395. package/dist/providers/generic/normalizer.d.ts +0 -1
  396. package/dist/providers/generic/verification.d.ts +0 -8
  397. package/dist/providers/github/auth.d.ts +0 -1
  398. package/dist/providers/github/changed-files.d.ts +2 -1
  399. package/dist/providers/github/file-contents.d.ts +0 -4
  400. package/dist/providers/github/lock-file.d.ts +0 -4
  401. package/dist/providers/github/normalizer.d.ts +1 -9
  402. package/dist/providers/local/index.d.ts +1 -2
  403. package/dist/providers/local/lock-file-fetcher.d.ts +0 -4
  404. package/dist/providers/local/normalizer.d.ts +0 -10
  405. package/dist/providers/local/repo-url-builder.d.ts +0 -2
  406. package/dist/providers/universal-git/clone-token.d.ts +0 -2
  407. package/dist/providers/universal-git/lock-file.d.ts +0 -2
  408. package/dist/providers/universal-git/normalizer.d.ts +0 -2
  409. package/dist/queue/bootstrap.d.ts +3 -15
  410. package/dist/queue/cleanup.d.ts +29 -50
  411. package/dist/queue/depth-refresher.d.ts +21 -39
  412. package/dist/queue/job-queue.d.ts +112 -163
  413. package/dist/queue/retention.d.ts +23 -36
  414. package/dist/queue/scheduled-job.d.ts +17 -39
  415. package/dist/queue/terminalize-unroutable.d.ts +16 -18
  416. package/dist/queue/unroutable-probe.d.ts +15 -22
  417. package/dist/registration/extractor.d.ts +0 -6
  418. package/dist/registration/registration-index.d.ts +0 -6
  419. package/dist/registration/registration-store.d.ts +0 -9
  420. package/dist/reporting/agent-failure-category.d.ts +3 -5
  421. package/dist/reporting/check-run-reporter.d.ts +142 -316
  422. package/dist/reporting/check-run-summary.d.ts +16 -35
  423. package/dist/reporting/check-run-tracking-store.d.ts +54 -107
  424. package/dist/reporting/execution-tracker.d.ts +356 -526
  425. package/dist/reporting/fs-log-storage.d.ts +31 -33
  426. package/dist/reporting/job-check-run-completion.d.ts +14 -22
  427. package/dist/reporting/log-chunk-sink.d.ts +11 -16
  428. package/dist/reporting/log-pull-handler.d.ts +4 -13
  429. package/dist/reporting/log-retention.d.ts +3 -4
  430. package/dist/reporting/log-storage.d.ts +24 -52
  431. package/dist/reporting/log-writer.d.ts +28 -56
  432. package/dist/reporting/peer-log-normalize.d.ts +4 -8
  433. package/dist/reporting/run-aggregator.d.ts +6 -11
  434. package/dist/reporting/run-summary-fields.d.ts +5 -8
  435. package/dist/reporting/s3-log-storage.d.ts +31 -50
  436. package/dist/reporting/step-display-order.d.ts +11 -21
  437. package/dist/reporting/step-log-buffer.d.ts +7 -28
  438. package/dist/reporting/step-log-reader.d.ts +11 -19
  439. package/dist/routes/admin-access-log.d.ts +4 -6
  440. package/dist/routes/admin-auth.d.ts +17 -38
  441. package/dist/routes/admin-backends.d.ts +3 -14
  442. package/dist/routes/admin-cluster-name.d.ts +13 -21
  443. package/dist/routes/admin-cluster-settings.d.ts +6 -9
  444. package/dist/routes/admin-config.d.ts +7 -19
  445. package/dist/routes/admin-contexts.d.ts +6 -13
  446. package/dist/routes/admin-db.d.ts +5 -10
  447. package/dist/routes/admin-event-dlq.d.ts +3 -5
  448. package/dist/routes/admin-event-inspect.d.ts +3 -4
  449. package/dist/routes/admin-event-log.d.ts +3 -7
  450. package/dist/routes/admin-events.d.ts +16 -30
  451. package/dist/routes/admin-held-runs.d.ts +52 -76
  452. package/dist/routes/admin-maintenance.d.ts +3 -6
  453. package/dist/routes/admin-orchestrator-drain.d.ts +0 -2
  454. package/dist/routes/admin-org-settings.d.ts +8 -14
  455. package/dist/routes/admin-peer-forget.d.ts +0 -1
  456. package/dist/routes/admin-queue-execution.d.ts +3 -3
  457. package/dist/routes/admin-registrations.d.ts +3 -12
  458. package/dist/routes/admin-runs.d.ts +16 -29
  459. package/dist/routes/admin-scaler-orphans.d.ts +4 -4
  460. package/dist/routes/admin-scaler-reload.d.ts +5 -8
  461. package/dist/routes/admin-scheduled-jobs.d.ts +3 -4
  462. package/dist/routes/admin-sources.d.ts +20 -29
  463. package/dist/routes/admin-trust-policy.d.ts +31 -48
  464. package/dist/routes/admin.d.ts +67 -94
  465. package/dist/routes/caller-identity.d.ts +5 -12
  466. package/dist/routes/capabilities.d.ts +8 -13
  467. package/dist/routes/diagnostics.d.ts +2 -10
  468. package/dist/routes/fleet.d.ts +1 -2
  469. package/dist/routes/github-webhook.d.ts +2 -5
  470. package/dist/routes/health.d.ts +6 -19
  471. package/dist/routes/provenance-oidc.d.ts +3 -3
  472. package/dist/routes/uploads.d.ts +5 -11
  473. package/dist/routes/webhooks.d.ts +2 -24
  474. package/dist/scaler/agent-binary-location.d.ts +77 -0
  475. package/dist/scaler/agent-fit.d.ts +2 -2
  476. package/dist/scaler/backend-factory.d.ts +10 -18
  477. package/dist/scaler/bare-metal-backend.d.ts +30 -46
  478. package/dist/scaler/claim-store.d.ts +20 -43
  479. package/dist/scaler/config.d.ts +10 -37
  480. package/dist/scaler/container-backend.d.ts +22 -35
  481. package/dist/scaler/container-hostconfig.d.ts +19 -16
  482. package/dist/scaler/container-routing.d.ts +10 -13
  483. package/dist/scaler/disk-guard.d.ts +2 -3
  484. package/dist/scaler/event-backend.d.ts +33 -58
  485. package/dist/scaler/event-provision-reaper.d.ts +61 -84
  486. package/dist/scaler/failure-tracker.d.ts +6 -13
  487. package/dist/scaler/file-tail.d.ts +6 -19
  488. package/dist/scaler/firecracker-api.d.ts +19 -63
  489. package/dist/scaler/firecracker-backend.d.ts +142 -258
  490. package/dist/scaler/host-access.d.ts +7 -10
  491. package/dist/scaler/index.d.ts +3 -6
  492. package/dist/scaler/ip-allocator.d.ts +30 -82
  493. package/dist/scaler/label-matcher.d.ts +14 -35
  494. package/dist/scaler/log-forwarder.d.ts +6 -25
  495. package/dist/scaler/machine-ledger.d.ts +39 -86
  496. package/dist/scaler/manager.d.ts +517 -787
  497. package/dist/scaler/pending-scale-sweeper.d.ts +8 -11
  498. package/dist/scaler/reap-orphans.d.ts +8 -12
  499. package/dist/scaler/resolve-container-auth.d.ts +12 -21
  500. package/dist/scaler/scaler-events.d.ts +2 -5
  501. package/dist/scaler/scaler-state-store.d.ts +127 -189
  502. package/dist/scaler/spawn-errors.d.ts +1 -4
  503. package/dist/scaler/startup-orphan-sweep.d.ts +3 -4
  504. package/dist/scaler/startup-tools-check.d.ts +21 -0
  505. package/dist/scaler/types.d.ts +142 -255
  506. package/dist/scaler/vm-job-bindings.d.ts +5 -9
  507. package/dist/scaler/warm-pool.d.ts +49 -93
  508. package/dist/secrets/audit-logger.d.ts +0 -3
  509. package/dist/secrets/backend-health.d.ts +0 -9
  510. package/dist/secrets/backend-registry.d.ts +0 -9
  511. package/dist/secrets/cleanup.d.ts +0 -1
  512. package/dist/secrets/config.d.ts +0 -3
  513. package/dist/secrets/ephemeral-keys.d.ts +0 -3
  514. package/dist/secrets/pg-secret-store.d.ts +0 -3
  515. package/dist/secrets/rbac.d.ts +0 -6
  516. package/dist/secrets/secret-output-store.d.ts +0 -6
  517. package/dist/secrets/secret-resolver.d.ts +2 -6
  518. package/dist/secrets/token-manager.d.ts +0 -4
  519. package/dist/secrets/vault-secret-store.d.ts +0 -13
  520. package/dist/security/comment-handler.d.ts +0 -2
  521. package/dist/security/workflow-diff.d.ts +1 -1
  522. package/dist/server.js +8628 -13569
  523. package/dist/sources/source-manager.d.ts +0 -3
  524. package/dist/sources/source-store.d.ts +0 -9
  525. package/dist/sources/source-validator.d.ts +0 -3
  526. package/dist/stale-detector/all-terminal-runs.d.ts +8 -11
  527. package/dist/stale-detector/gate-deadline-detector.d.ts +14 -19
  528. package/dist/stale-detector/reboot-deadline-sweep.d.ts +7 -11
  529. package/dist/stale-detector/stale-dispatch-candidates.d.ts +13 -20
  530. package/dist/stale-detector/stale-run-detector.d.ts +74 -121
  531. package/dist/stale-detector/workflow-deadline-detector.d.ts +15 -43
  532. package/dist/standalone.js +7670 -12402
  533. package/dist/storage/blob-routes.d.ts +10 -19
  534. package/dist/storage/filesystem.d.ts +19 -29
  535. package/dist/storage/index.d.ts +2 -10
  536. package/dist/storage/key-discriminator.d.ts +8 -10
  537. package/dist/storage/loopback-guard.d.ts +27 -45
  538. package/dist/storage/s3.d.ts +25 -52
  539. package/dist/storage/sign-url.d.ts +7 -22
  540. package/dist/storage/types.d.ts +44 -70
  541. package/dist/webhook/event-log.d.ts +0 -2
  542. package/dist/webhook/generic-sources.d.ts +0 -21
  543. package/dist/webhook/ingest-admission.d.ts +0 -1
  544. package/dist/webhook/relay-buffer.d.ts +2 -2
  545. package/dist/webhook/verify-inbound.d.ts +0 -1
  546. package/dist/worker/in-memory-execution-tracker.d.ts +9 -31
  547. package/dist/worker/in-memory-job-queue.d.ts +32 -72
  548. package/dist/worker/peer-outbox.d.ts +5 -8
  549. package/dist/worker/reroute-dispatch.d.ts +4 -6
  550. package/dist/worker/static-agent-token-store.d.ts +6 -27
  551. package/dist/worker/worker-outbox-relay.d.ts +2 -2
  552. package/dist/worker/worker-status.d.ts +3 -20
  553. package/dist/ws/agent-api-registry.d.ts +8 -27
  554. package/dist/ws/agent-handler.d.ts +63 -110
  555. package/dist/ws/agent-heartbeat.d.ts +5 -12
  556. package/dist/ws/bringup-api.d.ts +31 -38
  557. package/dist/ws/dashboard-backends-handler.d.ts +12 -22
  558. package/dist/ws/dashboard-context-handler.d.ts +37 -80
  559. package/dist/ws/dashboard-diagnostics-handler.d.ts +8 -25
  560. package/dist/ws/dashboard-dispatch-guard.d.ts +3 -4
  561. package/dist/ws/dashboard-fleet-handler.d.ts +9 -13
  562. package/dist/ws/dashboard-fleet-write-handler.d.ts +7 -21
  563. package/dist/ws/dashboard-global-workflows-handler.d.ts +22 -44
  564. package/dist/ws/dashboard-registrations-handler.d.ts +10 -27
  565. package/dist/ws/dashboard-run-state-handler.d.ts +10 -13
  566. package/dist/ws/event-buffer.d.ts +3 -6
  567. package/dist/ws/execution-status-frame.d.ts +9 -11
  568. package/dist/ws/failure-messages.d.ts +9 -14
  569. package/dist/ws/fleet-agent-collector.d.ts +6 -12
  570. package/dist/ws/fleet-runs-on-all.d.ts +1 -6
  571. package/dist/ws/git-credential-relay.d.ts +12 -20
  572. package/dist/ws/inventory-api.d.ts +4 -5
  573. package/dist/ws/job-status-forward-frame.d.ts +30 -0
  574. package/dist/ws/observer-registry.d.ts +14 -59
  575. package/dist/ws/outbound-frame-guard.d.ts +4 -0
  576. package/dist/ws/ownership-gate.d.ts +1 -1
  577. package/dist/ws/platform-client.d.ts +32 -31
  578. package/dist/ws/replay-chunker.d.ts +7 -10
  579. package/dist/ws/server-options.d.ts +5 -9
  580. package/dist/ws/test-relay-handlers.d.ts +45 -59
  581. package/dist/ws/test-run-log-cursor.d.ts +18 -0
  582. package/installer-image-digests.json +3 -3
  583. package/package.json +6 -5
  584. package/sbom.spdx.json +53 -53
  585. package/dist/__test-helpers__/fake-scaler-state-store.d.ts +0 -24
  586. package/dist/__test-helpers__/mock-db-query.d.ts +0 -129
  587. package/dist/__test-helpers__/mock-db.d.ts +0 -134
  588. package/dist/__test-helpers__/mock-ws.d.ts +0 -13
  589. package/dist/__test-helpers__/peer-mutual-auth.d.ts +0 -42
  590. package/dist/__test-helpers__/scratch-db.d.ts +0 -16
  591. package/dist/__test-helpers__/test-db.d.ts +0 -34
  592. package/dist/pipeline/dispatch-matched-workflow.test-helpers.d.ts +0 -121
@@ -12,9 +12,6 @@ import type pg from 'pg';
12
12
  import { ProviderRegistry } from '../provider-registry.js';
13
13
  import type { ProviderSource } from '../entry-helpers.js';
14
14
  import type { SourceStore } from './source-store.js';
15
- /**
16
- * Options for creating a SourceManager.
17
- */
18
15
  export interface SourceManagerOptions {
19
16
  /** Raw pg pool for LISTEN/NOTIFY subscriber. */
20
17
  pool: pg.Pool;
@@ -9,9 +9,6 @@
9
9
  import { type Kysely } from 'kysely';
10
10
  import type { Database, Source } from '../db/types.js';
11
11
  import type { PgSecretStore } from '../secrets/pg-secret-store.js';
12
- /**
13
- * Parameters for adding a new source.
14
- */
15
12
  export interface AddSourceParams {
16
13
  /** Provider type (e.g. 'github') */
17
14
  provider: string;
@@ -30,9 +27,6 @@ export interface AddSourceParams {
30
27
  /** Customer/org identifier for secret and environment scoping */
31
28
  customerId?: string;
32
29
  }
33
- /**
34
- * A source with its decrypted secrets.
35
- */
36
30
  export interface SourceWithSecrets extends Source {
37
31
  privateKey: string;
38
32
  webhookSecret?: string;
@@ -54,9 +48,6 @@ export declare class SourceStore {
54
48
  * List all sources (no secrets exposed).
55
49
  */
56
50
  listSources(): Promise<Source[]>;
57
- /**
58
- * Get a single source by routing key, or null if not found.
59
- */
60
51
  getSource(routingKey: string): Promise<Source | null>;
61
52
  /**
62
53
  * Get a single source by its UUID primary key, or null if not found. Used by
@@ -1,6 +1,3 @@
1
- /**
2
- * Result of a source credential validation.
3
- */
4
1
  export interface ValidationResult {
5
2
  valid: boolean;
6
3
  appName?: string;
@@ -3,22 +3,19 @@ import type { Database } from '../db/types.js';
3
3
  /**
4
4
  * Runs whose every job row is terminal while the run row is not.
5
5
  *
6
- * Every coordinator finalizes a run from its own in-memory view when the
7
- * last job it hears about finishes, and defers while a sibling still has a
8
- * registration window open on the run. So one shape reaches no finalizer at
9
- * all: the coordinator that saw the last job deferred to a live window holder,
10
- * and that holder then died before releasing it — its stale id reads as no
11
- * window, but nothing re-drives the check on the coordinator that deferred.
12
- * The same shape appears when a coordinator dies between its jobs going
13
- * terminal and its own finalization.
6
+ * A coordinator finalizes a run from its in-memory view when the last job it
7
+ * hears about finishes, but defers while a sibling holds a registration window
8
+ * on the run. If that holder dies before releasing it, its stale id reads as no
9
+ * window, yet nothing re-drives the check on the deferring coordinator. A
10
+ * coordinator dying between its jobs going terminal and its own finalization
11
+ * leaves the same shape.
14
12
  *
15
13
  * This sweep is the backstop: every job row terminal, the run row still
16
14
  * `pending` or `running`, the last completion older than the stale threshold
17
15
  * (so a normal completion in flight is not raced), and no LIVE registration
18
16
  * window holder. The caller finishes each candidate through the tracker's
19
- * DB-fallback completion, which is clobber-guarded and computes the status
20
- * from the rows — so a run a coordinator finishes in the meantime is left as
21
- * that coordinator wrote it.
17
+ * clobber-guarded DB-fallback completion, which computes the status from the
18
+ * rows, so a run a coordinator finishes in the meantime keeps what it wrote.
22
19
  */
23
20
  export declare function selectAllTerminalRunCandidates(db: Kysely<Database>, opts: {
24
21
  /** Runs whose last job completed before this instant qualify. */
@@ -1,17 +1,14 @@
1
1
  /**
2
- * GateDeadlineDetector: periodic DB scanner enforcing an invoke gate's own
3
- * job-level `timeout`.
2
+ * Periodic DB scanner enforcing an invoke gate's own job-level `timeout`.
4
3
  *
5
- * A gate runs no steps on an agent, so the agent-side job timeout can never fire
6
- * for it. Instead the orchestrator owns the gate deadline: this scanner finds
7
- * non-terminal `gate` jobs whose `timeout_ms` has elapsed since the gate began
8
- * summoning and fails each one. Failing the gate drives its downstream `needs`
9
- * cascade through the normal job-status path; the summoned source-repo runs are
10
- * the repos' own runs and are left untouched.
4
+ * A gate runs no steps on an agent, so the agent-side job timeout never fires for it;
5
+ * the orchestrator fails non-terminal `gate` jobs whose `timeout_ms` has elapsed since
6
+ * the gate began summoning. Failing drives the downstream `needs` cascade through the
7
+ * normal job-status path; the summoned source-repo runs are the repos' own and are left
8
+ * untouched.
11
9
  *
12
- * The gate's timeout clock is `ready_at` (when the needs scheduler released it to
13
- * summon), falling back to `created_at` for a root gate that never carried a
14
- * `ready_at`.
10
+ * The clock is `ready_at` (when the needs scheduler released the gate to summon),
11
+ * falling back to `created_at` for a root gate that never carried a `ready_at`.
15
12
  */
16
13
  import { type Kysely } from 'kysely';
17
14
  import type { Database } from '../db/types.js';
@@ -24,9 +21,9 @@ import type { ExecutionTracker } from '../reporting/execution-tracker.js';
24
21
  export declare const GATE_DEADLINE_RECENCY_WINDOW_MS: number;
25
22
  export interface GateDeadlineDetectorDeps {
26
23
  db: Kysely<Database>;
27
- /** Used to fail an overdue gate through the canonical job-status path. */
24
+ /** Fails an overdue gate through the canonical job-status path. */
28
25
  executionTracker: Pick<ExecutionTracker, 'onJobStatus'>;
29
- /** How often to scan in ms (reuses the stale-detector interval). */
26
+ /** Scan interval in ms (reuses the stale-detector interval). */
30
27
  scanIntervalMs: number;
31
28
  }
32
29
  export declare class GateDeadlineDetector {
@@ -35,16 +32,14 @@ export declare class GateDeadlineDetector {
35
32
  private readonly scanIntervalMs;
36
33
  private interval;
37
34
  constructor(deps: GateDeadlineDetectorDeps);
38
- /** Start the detector: an immediate crash-recovery scan, then periodic scans. */
35
+ /** An immediate crash-recovery scan, then periodic scans. */
39
36
  start(): Promise<void>;
40
37
  stop(): void;
41
- /** Find non-terminal gates past their timeout and fail each one. */
42
38
  scan(): Promise<void>;
43
39
  /**
44
- * Build the SELECT for overdue gates. Extracted so a unit test can compile the
45
- * exact predicate set (Kysely `.compile()`) without a live database. A gate is
46
- * overdue when `coalesce(ready_at, created_at) + timeout_ms` is in the past;
47
- * the recency bound keeps the scan off ancient history each tick.
40
+ * Extracted so a unit test can compile the exact predicate set (Kysely `.compile()`)
41
+ * without a live database. Overdue means `coalesce(ready_at, created_at) + timeout_ms`
42
+ * is in the past; the recency bound keeps each tick off ancient history.
48
43
  */
49
44
  private buildOverdueQuery;
50
45
  private failOverdueGate;
@@ -1,21 +1,18 @@
1
1
  /**
2
- * RebootDeadlineSweep: clears expired host-reboot-pending flags.
2
+ * Clears expired host-reboot-pending flags.
3
3
  *
4
- * When a workflow's `restartHost()` step runs, the orchestrator sets a
5
- * `host_roster.reboot_pending_until` deadline and holds the pinned post-restart
6
- * job until the host completes a reboot cycle. If the host never returns by the
7
- * deadline, this sweep clears the stale flag. With the flag cleared and the
8
- * agent still gone, the held post-restart job hits the existing dispatch-queue
9
- * timeout and the run fails — the "host did not return after reboot" outcome.
4
+ * A `restartHost()` step sets `host_roster.reboot_pending_until` and holds the pinned
5
+ * post-restart job until the host completes a reboot cycle. If the host misses the deadline,
6
+ * this clears the flag; with the agent still gone, the held job hits the dispatch-queue timeout
7
+ * and the run fails — the "host did not return after reboot" outcome.
10
8
  *
11
- * Driven by the leader-only host-roster reaper's tick (one timer, one leader),
12
- * so this class owns no timer of its own — just a testable `scan()`.
9
+ * Driven by the leader-only host-roster reaper's tick (one timer, one leader), so it owns no
10
+ * timer — just a testable `scan()`.
13
11
  */
14
12
  /** Narrow roster slice the sweep needs (set on the full HostRosterStore). */
15
13
  export interface RebootDeadlineRosterStore {
16
14
  /** Agent ids whose reboot-pending deadline has passed at `nowMs`. */
17
15
  listExpiredRebootPending(nowMs: number): Promise<string[]>;
18
- /** Clear the reboot-pending flag for an agent. */
19
16
  clearRebootPending(agentId: string): Promise<void>;
20
17
  }
21
18
  export declare class RebootDeadlineSweep {
@@ -23,7 +20,6 @@ export declare class RebootDeadlineSweep {
23
20
  constructor(deps: {
24
21
  rosterStore: RebootDeadlineRosterStore;
25
22
  });
26
- /** Clear every reboot-pending flag whose deadline has passed. */
27
23
  scan(): Promise<void>;
28
24
  }
29
25
  //# sourceMappingURL=reboot-deadline-sweep.d.ts.map
@@ -17,27 +17,20 @@ export interface StaleDispatchCandidate {
17
17
  routing_key: string | null;
18
18
  }
19
19
  /**
20
- * The dispatch rows that have gone unacknowledged long enough to reap.
20
+ * The dispatch rows that have gone unacknowledged long enough to reap. Separate from the
21
+ * detector so its raw-SQL predicates are asserted against a real Postgres, not a mock.
21
22
  *
22
- * Split out of the detector so the three predicates that decide the verdict can
23
- * be asserted against a real Postgres — they are raw SQL, and a mock records
24
- * them without evaluating them.
25
- *
26
- * - **Both bounds read the DISPATCH clock**, not the enqueue clock.
27
- * `created_at` is when the job was queued, so keying on it measured "enqueued
28
- * more than two minutes ago and not yet reported running" — true of every job
29
- * that waited behind a busy fleet. A job claimed at 3:00 after a scaler cold
30
- * start, then cloning its repo and installing dependencies, was reaped at 3:30
31
- * with "dispatch never acknowledged" while the agent ran it to completion for
32
- * nothing.
33
- * - **The COALESCE is the rolling-upgrade bridge.** A row dispatched before
34
- * `dispatched_at` existed carries NULL and keeps exactly the previous
35
- * behaviour. That is also what makes startup recovery's decision to spare an
36
- * unknown-owner row safe: a spared orphan is still reaped here.
37
- * - **An acked dispatch is never reaped.** A row whose `ack_deadline` was
38
- * cleared while `ack_agent_id` is stamped was acknowledged, and the ack path
39
- * owns it. This scan's residual job is the never-acked, crashed-coordinator
40
- * case; the heartbeat sub-scans cover a job that acked and then went quiet.
23
+ * - **Both bounds read the DISPATCH clock**, not the enqueue clock. `created_at` measures
24
+ * "enqueued long ago and not yet running", true of every job that waited behind a busy
25
+ * fleet: a job claimed after a scaler cold start would be reaped mid-clone with "dispatch
26
+ * never acknowledged" while the agent ran it to completion for nothing.
27
+ * - **The COALESCE is the rolling-upgrade bridge.** A row dispatched before `dispatched_at`
28
+ * existed carries NULL and falls back to `created_at`. That also makes startup recovery's
29
+ * sparing of an unknown-owner row safe: a spared orphan is still reaped here.
30
+ * - **An acked dispatch is never reaped.** A row with `ack_deadline` cleared and
31
+ * `ack_agent_id` stamped was acknowledged, and the ack path owns it. This scan covers the
32
+ * never-acked, crashed-coordinator case; the heartbeat sub-scans cover a job that acked and
33
+ * then went quiet.
41
34
  */
42
35
  export declare function selectStaleDispatchCandidates(db: Kysely<Database>, threshold: Date, timeBound: Date): Promise<StaleDispatchCandidate[]>;
43
36
  //# sourceMappingURL=stale-dispatch-candidates.d.ts.map
@@ -1,22 +1,18 @@
1
1
  /**
2
- * StaleRunDetector: periodic DB scanner for stale execution jobs.
2
+ * Periodic DB scanner that marks jobs whose heartbeats stopped (agent died, network
3
+ * partition, container killed) as timed_out_stale, and fails dispatch_queue entries
4
+ * that were dispatched but never acknowledged.
3
5
  *
4
- * Detects jobs that have stopped sending heartbeats (agent died, network partition,
5
- * container killed, etc.) and marks them as timed_out_stale. Also detects stale
6
- * dispatch_queue entries that were dispatched but never acknowledged.
7
- *
8
- * Key behaviors:
9
- * - Immediate startup scan for crash recovery (finds stale jobs from before restart)
10
- * - Periodic scans at configurable interval (default 60s)
11
- * - Uses timed_out_stale as distinct DB status (not just 'failed')
12
- * - Optimistic concurrency: WHERE status='running' prevents race with agent completion
13
- * - Does NOT call executionTracker.onJobStatus() to avoid redundant DB writes
14
- * - Updates in-memory state and calls completeRunIfAllJobsTerminal for run completion
6
+ * - Scans once at startup for crash recovery, then every scan interval (default 60s).
7
+ * - timed_out_stale is a distinct DB status, not 'failed'.
8
+ * - Optimistic concurrency: WHERE status='running' prevents a race with agent completion.
9
+ * - Does NOT call executionTracker.onJobStatus(), to avoid redundant DB writes; it
10
+ * updates in-memory state and calls completeRunIfAllJobsTerminal instead.
15
11
  * - Finishes a run whose every job is terminal but whose finalizer never ran
16
12
  * (a coordinator that died mid-way, or a registration-window holder that
17
- * died after a sibling deferred to it)
18
- * - Force-terminates stale agents via scaler manager
19
- * - Updates GitHub check runs with timed_out conclusion
13
+ * died after a sibling deferred to it).
14
+ * - Force-terminates stale agents via the scaler manager and completes their GitHub
15
+ * check runs as timed_out.
20
16
  */
21
17
  import { type Kysely } from 'kysely';
22
18
  import type { Database } from '../db/types.js';
@@ -39,18 +35,17 @@ export interface StaleRunDetectorDeps {
39
35
  dispatcher: Dispatcher;
40
36
  registry: AgentRegistry;
41
37
  /**
42
- * Peer registry used to defer failing a job that was rerouted to a remote
43
- * worker peer while that peer is still connected — its terminal status may
44
- * still be replayed from the worker's durable outbox.
38
+ * Defers failing a job rerouted to a remote worker peer while that peer is still
39
+ * connected — its terminal status may still be replayed from the worker's durable outbox.
45
40
  */
46
41
  peerRegistry: PeerRegistry;
47
- /** Reader for fleet-wide cluster tunables (reroute flap-grace override). */
42
+ /** Fleet-wide cluster tunables (reroute flap-grace override). */
48
43
  clusterSettings: ClusterSettingsReader;
49
44
  /** Cluster default for the reroute flap-grace window (config.rerouteFlapGraceMs). */
50
45
  rerouteFlapGraceFallbackMs: number;
51
- /** Threshold in ms after which a job is considered stale. Default: heartbeatIntervalMs * multiplier */
46
+ /** Ms after which a job is stale. Default: heartbeatIntervalMs * multiplier */
52
47
  staleThresholdMs: number;
53
- /** How often to scan for stale jobs in ms. Default: 60_000 */
48
+ /** Scan interval in ms. Default: 60_000 */
54
49
  scanIntervalMs: number;
55
50
  /**
56
51
  * How stale a `cluster_instances` heartbeat may be and still read as live,
@@ -58,42 +53,37 @@ export interface StaleRunDetectorDeps {
58
53
  * {@link instanceLivenessGraceMs} at the default recovery grace period.
59
54
  */
60
55
  instanceLivenessGraceMs?: number;
61
- /** Held run store for expiring overdue held runs. Optional -- if not set, held run cleanup is skipped. */
56
+ /** Expires overdue held runs. If not set, held run cleanup is skipped. */
62
57
  heldRunStore?: HeldRunStore;
63
- /** Step-approval bridge — notified when a step-scoped hold expires so the waiting agent fails the step. Optional. */
58
+ /** Notified when a step-scoped hold expires, so the waiting agent fails the step. */
64
59
  stepApprovalBridge?: StepApprovalBridge;
65
- /** Fail a whole run when a job/workflow-scoped approval hold expires. Optional. */
60
+ /** Fails a whole run when a job/workflow-scoped approval hold expires. */
66
61
  failRun?: (runId: string, reason: string) => Promise<void>;
67
62
  /**
68
- * Resume a workflow whose install-gate wait-timer hold has elapsed. Wired to
69
- * the same `resumeWorkflow` path as reviewer approvals. Optional -- if not
70
- * set, wait-timer workflow holds are not auto-released.
63
+ * Resumes a workflow whose install-gate wait-timer hold has elapsed, via the same
64
+ * `resumeWorkflow` path as reviewer approvals. If not set, wait-timer workflow holds
65
+ * are not auto-released.
71
66
  */
72
67
  onWorkflowRelease?: (signal: ReleaseSignal) => Promise<void>;
73
68
  /**
74
- * Resume a released JOB-scoped hold by re-dispatching the job. A job-scoped
75
- * wait-timer hold has a pending job context, not a pending workflow context,
76
- * so it cannot go through `onWorkflowRelease`.
69
+ * Re-dispatches the job of a released JOB-scoped hold. Such a hold has a pending job
70
+ * context, not a pending workflow context, so it cannot go through `onWorkflowRelease`.
77
71
  */
78
72
  onJobRelease?: (signal: ReleaseSignal) => Promise<void>;
79
73
  /**
80
- * Resolve a context by name, for the queued-concurrency sweep — it needs each
81
- * group's configured `concurrency_limit` to know how many holds a freed slot
82
- * lets through. `ContextStore.matchContext`.
74
+ * `ContextStore.matchContext`: the queued-concurrency sweep needs each group's
75
+ * `concurrency_limit` to know how many holds a freed slot lets through.
83
76
  */
84
77
  matchContext?: (orgId: string, name: string) => Promise<{
85
78
  concurrency_limit: number | null;
86
79
  } | null>;
87
- /** Access-log writer for the orchestrator audit stream. Optional -- if not set, expiry audit rows (`held_run.expire`) are skipped. */
80
+ /** If not set, expiry audit rows (`held_run.expire`) are skipped. */
88
81
  accessLogWriter?: AccessLogWriter;
89
82
  /**
90
- * Resolve the check poster of the provider bundle serving a routing key, so an
91
- * expiring security hold's `KiCI Security` check can be completed. A function
92
- * rather than the registry itself because the registry instance is replaced
93
- * when sources are (re)loaded, and this detector outlives that.
94
- *
95
- * Optional -- if not set, an expiring security hold's check is left alone,
96
- * which is the pre-existing behaviour rather than a wrong one.
83
+ * Resolves the check poster serving a routing key, so an expiring security hold's
84
+ * `KiCI Security` check can be completed. A function rather than the registry, because
85
+ * the registry instance is replaced when sources are (re)loaded and this detector
86
+ * outlives that. If not set, an expiring security hold's check is left alone.
97
87
  */
98
88
  resolveCheckStatusPoster?: ResolveCheckStatusPoster;
99
89
  }
@@ -123,123 +113,86 @@ export declare class StaleRunDetector {
123
113
  /**
124
114
  * Release queued concurrency holds whose group now has a free slot.
125
115
  *
126
- * A context's concurrency gate returns `queue` when its limit is met, holding
127
- * the job. Nothing released those holds: they sat pending until the expiry
128
- * sweep marked them expired and their jobs never ran. This is the release
129
- * half.
116
+ * This is the release half of a context's concurrency gate, which returns `queue` and
117
+ * holds the job when its limit is met; without it, holds sit pending until the expiry
118
+ * sweep expires them and their jobs never run.
130
119
  *
131
- * Driven from the periodic scan rather than from job completion: the
132
- * completion callback is constructed before the dispatcher, coordinator and
133
- * context store exist, so wiring it there would mean threading four refs
134
- * through a hot path. The cost is up to one scan interval of latency before a
135
- * freed slot is reused, which for a throughput control is an acceptable
136
- * trade — and every release still re-checks the limit, so the bound is never
137
- * exceeded regardless of when the sweep runs.
120
+ * Driven from the periodic scan rather than from job completion: the completion
121
+ * callback is constructed before the dispatcher, coordinator and context store exist,
122
+ * so wiring it there would thread four refs through a hot path. The cost is up to one
123
+ * scan interval before a freed slot is reused, acceptable for a throughput control —
124
+ * and every release re-checks the limit, so the bound is never exceeded.
138
125
  */
139
126
  private releaseFreedConcurrencyHolds;
140
127
  /**
141
- * Release wait-timer holds whose timer has elapsed, at ANY scope, and route
142
- * each to the resume path its shape requires: a workflow install-gate hold
143
- * rebuilds its workflow dispatch context, a job-scoped hold re-dispatches the
144
- * one job it held.
128
+ * Release elapsed wait-timer holds at ANY scope: a workflow install-gate hold
129
+ * rebuilds its workflow dispatch context, a job-scoped hold re-dispatches its job.
145
130
  *
146
- * Runs BEFORE `expireOverdueHolds` so a wait hold resumes rather than being
147
- * failed by the expire-and-fail sweep — that sweep is not scope-filtered, so
148
- * the ordering is load-bearing.
131
+ * Runs BEFORE `expireOverdueHolds` so a wait hold resumes rather than being failed;
132
+ * that sweep is not scope-filtered, so the ordering is load-bearing.
149
133
  */
150
134
  private releaseDueWaitHolds;
151
135
  /**
152
- * Expire overdue approval holds. Routes each overdue hold by scope BEFORE the
153
- * bulk status flip: step-scoped holds notify the waiting agent (which fails
154
- * the step), job/workflow-scoped holds fail the whole run. Then the bulk
155
- * `expireOverdue()` flips every overdue row to `expired`.
136
+ * Routes each overdue approval hold by scope BEFORE the bulk `expireOverdue()` flip:
137
+ * step-scoped holds notify the waiting agent (which fails the step), job/workflow-scoped
138
+ * holds fail the whole run.
156
139
  *
157
- * Every overdue row's id is excluded from the security check's contention
158
- * query for the whole loop, because `expireOverdue()` has not run yet: each
159
- * of them is still `pending` in the database while its siblings are being
160
- * routed, and without the exclusion a commit whose two holds both expired
161
- * would see each hold refuse on account of the other and leave the check
162
- * pending forever. The commits already settled are tracked so one sweep
163
- * writes each shared check once.
140
+ * Every overdue id is excluded from the security check's contention query for the whole
141
+ * loop: until `expireOverdue()` runs each is still `pending`, so a commit whose two holds
142
+ * both expired would see each refuse on account of the other and leave the check pending
143
+ * forever. Settled commits are tracked so one sweep writes each shared check once.
164
144
  */
165
145
  private expireOverdueHolds;
166
146
  /**
167
- * Clean up orphaned jobs left in 'recovering' state from a previous orchestrator instance.
147
+ * Fail jobs left in 'recovering' state by a previous orchestrator instance.
168
148
  *
169
- * Recovery timers are in-memory (Dispatcher) and lost on restart. Any jobs still
170
- * in 'recovering' state after a restart have no timer and no path to completion,
171
- * so they must be failed immediately.
172
- *
173
- * Call this during startup, before the first periodic scan.
149
+ * Recovery timers are in-memory (Dispatcher) and lost on restart, so such jobs have
150
+ * no path to completion. Call during startup, before the first periodic scan.
174
151
  */
175
152
  cleanupOrphanedRecoveryJobs(): Promise<void>;
176
- /**
177
- * Start the stale run detector.
178
- * Runs an immediate scan for crash recovery, then starts periodic scans.
179
- */
153
+ /** Runs an immediate scan for crash recovery, then starts periodic scans. */
180
154
  start(): Promise<void>;
181
- /**
182
- * Stop the stale run detector.
183
- */
184
155
  stop(): void;
185
156
  /**
186
- * Run a single stale detection scan.
187
- *
188
- * Three sub-scans:
157
+ * Run a single stale detection scan:
189
158
  * A. Running jobs with old heartbeat (last_heartbeat_at < threshold)
190
159
  * B. Running jobs with NULL heartbeat (created_at < threshold, pre-heartbeat jobs)
191
160
  * C. Dispatched queue entries that were never acknowledged
161
+ * then checks run completion for affected runs.
192
162
  *
193
- * After all sub-scans, checks run completion for affected runs.
194
- *
195
- * Note: jobs in 'recovering' state are NOT scanned -- they have their own
196
- * per-job recovery timers managed by the Dispatcher.
197
- * All sub-scans filter on status='running' or status='dispatched',
198
- * so recovering jobs are naturally excluded.
163
+ * Jobs in 'recovering' state are NOT scanned: the Dispatcher owns their per-job
164
+ * recovery timers, and every sub-scan filters on status='running' or 'dispatched'.
199
165
  */
200
166
  scan(): Promise<void>;
201
167
  /**
202
168
  * Sub-scan F: runs left non-terminal after every job row went terminal.
203
169
  *
204
- * The coordinator that saw the last job finish defers finalization while a
205
- * live sibling still has a registration window open on the run; a holder
206
- * that then dies leaves nothing to re-drive that check. A coordinator that
207
- * dies between its jobs going terminal and its own finalization leaves the
208
- * same shape. Both are finished here from the rows.
170
+ * Two causes, both finished here from the rows: the coordinator that saw the last job
171
+ * finish defers finalization while a live sibling holds a registration window open, and
172
+ * a holder that then dies leaves nothing to re-drive the check; or a coordinator dies
173
+ * between its jobs going terminal and its own finalization.
209
174
  */
210
175
  private scanAllTerminalRuns;
211
- /**
212
- * Sub-scan A: Find running jobs with stale heartbeats.
213
- */
176
+ /** Sub-scan A: running jobs with stale heartbeats. */
214
177
  private scanStaleRunningJobs;
215
178
  /**
216
- * Sub-scan B: Find running jobs with NULL heartbeat and old created_at.
217
- * These are jobs that started before the heartbeat system existed or where
218
- * the initial heartbeat was never set.
179
+ * Sub-scan B: running jobs with NULL heartbeat and old created_at — started before the
180
+ * heartbeat system existed, or the initial heartbeat was never set.
219
181
  */
220
182
  private scanStaleRunningJobsNullHeartbeat;
221
183
  /**
222
- * Sub-scan C: Find dispatched entries that were never acknowledged.
184
+ * Sub-scan C: dispatches the agent never started — the dispatch_queue row is still
185
+ * 'dispatched' AND no execution_jobs row is 'running'. Once the agent reports the job
186
+ * running, sub-scans A and B supervise `execution_jobs.last_heartbeat_at`. Without this
187
+ * filter, a job whose first step legitimately exceeds the dispatch threshold (e.g. an
188
+ * inline `npm install` for a workflow that imports `@kici-dev/sdk`) would be marked
189
+ * stale before sub-scan A's heartbeat path could keep it alive.
223
190
  *
224
- * Only catches dispatches that the agent never started — i.e., the
225
- * dispatch_queue row is still 'dispatched' AND there is no
226
- * execution_jobs row in 'running' state. When the agent has reported
227
- * the job as running (so execution_jobs.status='running'), heartbeat
228
- * supervision falls to sub-scans A and B, which look at
229
- * `execution_jobs.last_heartbeat_at`. Without this filter, a long
230
- * job whose first step legitimately exceeds the dispatch threshold
231
- * (e.g. an inline `npm install` for a workflow that imports
232
- * `@kici-dev/sdk`) would be marked stale here before sub-scan A's
233
- * heartbeat path has a chance to keep it alive.
234
- *
235
- * 'queued' jobs are legitimately waiting for agents and handled by
236
- * the queue timeout in {@link JobQueue.markExpired} instead.
191
+ * 'queued' jobs are legitimately waiting for agents; the queue timeout in
192
+ * {@link JobQueue.markExpired} handles them.
237
193
  */
238
194
  private scanStaleDispatchedJobs;
239
- /**
240
- * Mark a single running job as timed_out_stale.
241
- * Shared by sub-scans A and B.
242
- */
195
+ /** Mark a running job timed_out_stale. Shared by sub-scans A and B. */
243
196
  private markJobStale;
244
197
  }
245
198
  //# sourceMappingURL=stale-run-detector.d.ts.map
@@ -1,39 +1,26 @@
1
1
  /**
2
- * WorkflowDeadlineDetector: periodic DB scanner enforcing the workflow-level
3
- * run deadline.
4
- *
5
- * A workflow `timeout` caps the whole run's wall-clock across all jobs.
6
- * Because jobs span multiple agents, the cap is a run-level deadline owned by
7
- * the orchestrator. This scanner finds non-terminal runs whose
8
- * `started_at + workflow_timeout_ms` has passed and cancels them through the
9
- * canonical run-cancel path, recording the distinct
10
- * TimeoutReason.workflow_timeout so the dashboard labels the run "timed out"
11
- * rather than a generic cancel.
2
+ * Periodic DB scanner enforcing the workflow `timeout`: a run-level wall-clock deadline the
3
+ * orchestrator owns because jobs span multiple agents. It cancels non-terminal runs past
4
+ * `started_at + workflow_timeout_ms` through the canonical run-cancel path with
5
+ * TimeoutReason.workflow_timeout, so the dashboard labels the run "timed out", not cancelled.
12
6
  */
13
7
  import { type Kysely } from 'kysely';
14
8
  import type { Database } from '../db/types.js';
15
9
  import type { JobQueue } from '../queue/job-queue.js';
16
10
  /**
17
- * Recency window for the deadline-bounded scan: a run stays in scope while its
18
- * deadline (`started_at + workflow_timeout_ms`) lapsed within this window. 24h is
19
- * the crash-recovery horizon — a run whose deadline lapsed while the orchestrator
20
- * was down for less than this is still caught by the immediate `start()` scan; a
21
- * deadline that lapsed longer ago is out of scope (separate stale-recovery concern).
22
- * The window bounds the DEADLINE, not `started_at`, so timeouts >= 24h are enforced.
11
+ * A run is in scope while its deadline lapsed within this window: the 24h crash-recovery
12
+ * horizon for the immediate `start()` scan; older lapses are a separate stale-recovery
13
+ * concern. It bounds the DEADLINE, not `started_at`, so timeouts >= 24h are enforced.
23
14
  */
24
15
  export declare const DEADLINE_RECENCY_WINDOW_MS: number;
25
16
  export interface WorkflowDeadlineDetectorDeps {
26
17
  db: Kysely<Database>;
27
- /**
28
- * Canonical "cancel this whole run with a reason" callback — the same
29
- * implementation the user-initiated `kici cancel` route uses
30
- * (cancelRunWithReason bound to the orchestrator's deps).
31
- */
18
+ /** cancelRunWithReason bound to the orchestrator's deps, as the `kici cancel` route uses. */
32
19
  cancelRun: (runId: string, reason: string, options: {
33
20
  force: boolean;
34
21
  }) => Promise<unknown>;
35
22
  jobQueue: JobQueue;
36
- /** How often to scan in ms. Default supplied by the caller (reuses the stale-detector interval). */
23
+ /** Milliseconds; the caller reuses the stale-detector interval. */
37
24
  scanIntervalMs: number;
38
25
  }
39
26
  export declare class WorkflowDeadlineDetector {
@@ -43,32 +30,17 @@ export declare class WorkflowDeadlineDetector {
43
30
  private readonly scanIntervalMs;
44
31
  private interval;
45
32
  constructor(deps: WorkflowDeadlineDetectorDeps);
46
- /**
47
- * Start the detector: an immediate scan (crash recovery — catch runs that
48
- * blew their deadline while the orchestrator was down), then periodic scans.
49
- */
33
+ /** An immediate scan catches deadlines that lapsed while the orchestrator was down. */
50
34
  start(): Promise<void>;
51
35
  stop(): void;
52
- /**
53
- * Run a single deadline scan: find non-terminal runs with a configured
54
- * workflow timeout whose `started_at + workflow_timeout_ms` has passed and
55
- * cancel each one.
56
- */
57
36
  scan(): Promise<void>;
58
37
  /**
59
- * Build the SELECT for overdue runs. Extracted so a unit test can compile the
60
- * exact predicate set (Kysely `.compile()`) and assert the deadline-recency
61
- * bound without a live database.
38
+ * Separate so a unit test can `.compile()` the exact predicates without a live database.
62
39
  *
63
- * Bound the scan to runs whose DEADLINE lapsed within the recency window:
64
- * overdue (deadline < now) AND recent (deadline > now - window). Bounding by
65
- * the deadline (`started_at + workflow_timeout_ms`) rather than `started_at`
66
- * keeps long-timeout runs (timeout >= the window, e.g. >= 24h) in scope once
67
- * overdue — a `started_at > (now - window)` guard silently excluded those
68
- * forever because their deadline only lapses after `started_at` has already
69
- * aged past the window — while still skipping runs whose deadline passed long
70
- * ago (already handled), preserving the "don't re-scan ancient history every
71
- * tick" performance intent.
40
+ * Overdue (deadline < now) AND recent (deadline > now - window). A
41
+ * `started_at > (now - window)` guard would exclude timeouts >= the window forever, since
42
+ * their deadline lapses only after `started_at` aged past it; the deadline bound still skips
43
+ * long-past deadlines, so ancient history is not re-scanned every tick.
72
44
  */
73
45
  private buildOverdueQuery;
74
46
  /**