@kici-dev/orchestrator 0.16.0 → 0.18.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 +121 -233
  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 +39 -45
  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 +33 -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 +7 -7
  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 +33 -59
  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 +4553 -6556
  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 +143 -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 +251 -486
  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 +289 -525
  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 +65 -151
  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 +21 -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 +21 -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 +19 -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 +45 -0
  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/test-direct.d.ts +46 -0
  473. package/dist/routes/uploads.d.ts +14 -19
  474. package/dist/routes/webhooks.d.ts +2 -24
  475. package/dist/scaler/agent-binary-location.d.ts +77 -0
  476. package/dist/scaler/agent-fit.d.ts +2 -2
  477. package/dist/scaler/backend-factory.d.ts +10 -18
  478. package/dist/scaler/bare-metal-backend.d.ts +28 -45
  479. package/dist/scaler/claim-store.d.ts +20 -43
  480. package/dist/scaler/config.d.ts +10 -37
  481. package/dist/scaler/container-backend.d.ts +22 -35
  482. package/dist/scaler/container-hostconfig.d.ts +10 -16
  483. package/dist/scaler/container-routing.d.ts +10 -13
  484. package/dist/scaler/disk-guard.d.ts +2 -3
  485. package/dist/scaler/event-backend.d.ts +33 -58
  486. package/dist/scaler/event-provision-reaper.d.ts +61 -84
  487. package/dist/scaler/failure-tracker.d.ts +6 -13
  488. package/dist/scaler/file-tail.d.ts +6 -19
  489. package/dist/scaler/firecracker-api.d.ts +19 -63
  490. package/dist/scaler/firecracker-backend.d.ts +142 -258
  491. package/dist/scaler/host-access.d.ts +7 -10
  492. package/dist/scaler/index.d.ts +3 -6
  493. package/dist/scaler/ip-allocator.d.ts +30 -82
  494. package/dist/scaler/label-matcher.d.ts +14 -35
  495. package/dist/scaler/log-forwarder.d.ts +6 -25
  496. package/dist/scaler/machine-ledger.d.ts +39 -86
  497. package/dist/scaler/manager.d.ts +517 -787
  498. package/dist/scaler/pending-scale-sweeper.d.ts +8 -11
  499. package/dist/scaler/reap-orphans.d.ts +8 -12
  500. package/dist/scaler/resolve-container-auth.d.ts +12 -21
  501. package/dist/scaler/scaler-events.d.ts +2 -5
  502. package/dist/scaler/scaler-state-store.d.ts +127 -189
  503. package/dist/scaler/spawn-errors.d.ts +1 -4
  504. package/dist/scaler/startup-orphan-sweep.d.ts +3 -4
  505. package/dist/scaler/startup-tools-check.d.ts +21 -0
  506. package/dist/scaler/types.d.ts +142 -255
  507. package/dist/scaler/vm-job-bindings.d.ts +5 -9
  508. package/dist/scaler/warm-pool.d.ts +46 -93
  509. package/dist/secrets/audit-logger.d.ts +0 -3
  510. package/dist/secrets/backend-health.d.ts +0 -9
  511. package/dist/secrets/backend-registry.d.ts +0 -9
  512. package/dist/secrets/cleanup.d.ts +0 -1
  513. package/dist/secrets/config.d.ts +0 -3
  514. package/dist/secrets/ephemeral-keys.d.ts +0 -3
  515. package/dist/secrets/pg-secret-store.d.ts +0 -3
  516. package/dist/secrets/rbac.d.ts +5 -7
  517. package/dist/secrets/routing-key-scope.d.ts +1 -0
  518. package/dist/secrets/secret-output-store.d.ts +0 -6
  519. package/dist/secrets/secret-resolver.d.ts +2 -6
  520. package/dist/secrets/token-manager.d.ts +1 -4
  521. package/dist/secrets/vault-secret-store.d.ts +0 -13
  522. package/dist/security/comment-handler.d.ts +0 -2
  523. package/dist/security/workflow-diff.d.ts +1 -1
  524. package/dist/server.js +49004 -53782
  525. package/dist/sources/source-manager.d.ts +0 -3
  526. package/dist/sources/source-store.d.ts +0 -9
  527. package/dist/sources/source-validator.d.ts +0 -3
  528. package/dist/stale-detector/all-terminal-runs.d.ts +8 -11
  529. package/dist/stale-detector/gate-deadline-detector.d.ts +14 -19
  530. package/dist/stale-detector/reboot-deadline-sweep.d.ts +7 -11
  531. package/dist/stale-detector/stale-dispatch-candidates.d.ts +13 -20
  532. package/dist/stale-detector/stale-run-detector.d.ts +74 -121
  533. package/dist/stale-detector/workflow-deadline-detector.d.ts +15 -43
  534. package/dist/standalone.js +9342 -13077
  535. package/dist/storage/blob-routes.d.ts +10 -19
  536. package/dist/storage/filesystem.d.ts +19 -29
  537. package/dist/storage/index.d.ts +2 -10
  538. package/dist/storage/key-discriminator.d.ts +8 -10
  539. package/dist/storage/loopback-guard.d.ts +27 -45
  540. package/dist/storage/s3.d.ts +26 -53
  541. package/dist/storage/sign-url.d.ts +7 -22
  542. package/dist/storage/types.d.ts +46 -72
  543. package/dist/webhook/event-log.d.ts +0 -2
  544. package/dist/webhook/generic-sources.d.ts +0 -21
  545. package/dist/webhook/ingest-admission.d.ts +0 -1
  546. package/dist/webhook/relay-buffer.d.ts +2 -2
  547. package/dist/webhook/verify-inbound.d.ts +0 -1
  548. package/dist/worker/in-memory-execution-tracker.d.ts +9 -31
  549. package/dist/worker/in-memory-job-queue.d.ts +32 -72
  550. package/dist/worker/peer-outbox.d.ts +5 -8
  551. package/dist/worker/reroute-dispatch.d.ts +4 -6
  552. package/dist/worker/static-agent-token-store.d.ts +6 -27
  553. package/dist/worker/worker-outbox-relay.d.ts +2 -2
  554. package/dist/worker/worker-status.d.ts +3 -20
  555. package/dist/ws/agent-api-registry.d.ts +8 -27
  556. package/dist/ws/agent-handler.d.ts +63 -110
  557. package/dist/ws/agent-heartbeat.d.ts +5 -12
  558. package/dist/ws/bringup-api.d.ts +31 -38
  559. package/dist/ws/dashboard-backends-handler.d.ts +12 -22
  560. package/dist/ws/dashboard-context-handler.d.ts +37 -80
  561. package/dist/ws/dashboard-diagnostics-handler.d.ts +8 -25
  562. package/dist/ws/dashboard-dispatch-guard.d.ts +3 -4
  563. package/dist/ws/dashboard-fleet-handler.d.ts +9 -13
  564. package/dist/ws/dashboard-fleet-write-handler.d.ts +7 -21
  565. package/dist/ws/dashboard-global-workflows-handler.d.ts +22 -44
  566. package/dist/ws/dashboard-registrations-handler.d.ts +10 -27
  567. package/dist/ws/dashboard-run-state-handler.d.ts +10 -13
  568. package/dist/ws/event-buffer.d.ts +3 -6
  569. package/dist/ws/execution-status-frame.d.ts +7 -10
  570. package/dist/ws/failure-messages.d.ts +9 -14
  571. package/dist/ws/fleet-agent-collector.d.ts +6 -12
  572. package/dist/ws/fleet-runs-on-all.d.ts +1 -6
  573. package/dist/ws/git-credential-relay.d.ts +12 -20
  574. package/dist/ws/inventory-api.d.ts +4 -5
  575. package/dist/ws/observer-registry.d.ts +14 -59
  576. package/dist/ws/ownership-gate.d.ts +1 -1
  577. package/dist/ws/platform-client.d.ts +21 -30
  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 +46 -63
  581. package/installer-image-digests.json +3 -3
  582. package/package.json +6 -5
  583. package/sbom.spdx.json +53 -53
  584. package/dist/__test-helpers__/fake-scaler-state-store.d.ts +0 -24
  585. package/dist/__test-helpers__/mock-db-query.d.ts +0 -129
  586. package/dist/__test-helpers__/mock-db.d.ts +0 -134
  587. package/dist/__test-helpers__/mock-ws.d.ts +0 -13
  588. package/dist/__test-helpers__/peer-mutual-auth.d.ts +0 -42
  589. package/dist/__test-helpers__/scratch-db.d.ts +0 -16
  590. package/dist/__test-helpers__/test-db.d.ts +0 -34
  591. package/dist/pipeline/dispatch-matched-workflow.test-helpers.d.ts +0 -121
  592. package/dist/scaler/container-spawn.d.ts +0 -28
@@ -8,10 +8,8 @@
8
8
  * for jobs with dynamic fields, and deferred dynamic-job-fn dispatch for
9
9
  * `_type:'dynamic'` lock entries.
10
10
  *
11
- * Splits the historic 2438-line `dispatchMatchedWorkflow` into typed phase
12
- * helpers so each piece can be reasoned about independently. The main
13
- * exported function is a narrative orchestrator that threads the typed
14
- * results through the pipeline.
11
+ * The exported `dispatchMatchedWorkflow` threads typed phase-helper results
12
+ * through the pipeline.
15
13
  */
16
14
  import { ExecutionJobStatus, InitFailureCategory, CacheRefScope, HoldScope, TriggerSource } from '@kici-dev/engine';
17
15
  import type { LabelMatcher, LockWorkflow, LockJob, ApprovalRequirement, HostTargetSelector, SimulatedEvent, WorkflowDecision, MaterializedJob, ResolvedHostAgent, UpstreamSnapshot, HostFacts } from '@kici-dev/engine';
@@ -40,44 +38,31 @@ import { type ProcessingDeps } from './processor.js';
40
38
  */
41
39
  export declare function deriveCacheRefScope(trust: TrustResolution | undefined): CacheRefScope;
42
40
  /**
43
- * Context for dispatching a single matched workflow.
44
- *
45
- * Captures every per-workflow closure dependency so the dispatch body is
46
- * callable from BOTH the same-source path AND the cross-source delegation
47
- * shell. `crossSource` is the discriminator the helper uses to override the
48
- * dispatch `deliveryId` so fan-out targets land on their composite dedup
49
- * slot (`${inbound.deliveryId}:${reg.id}`) instead of the inbound delivery
50
- * id.
41
+ * Context for dispatching a single matched workflow, from both the same-source
42
+ * path and the cross-source delegation shell. `crossSource` overrides the
43
+ * dispatch `deliveryId` so fan-out targets land on their composite dedup slot
44
+ * (`${inbound.deliveryId}:${reg.id}`).
51
45
  */
52
46
  export interface WorkflowDispatchContext {
53
47
  info: WebhookInfo;
54
48
  deps: ProcessingDeps;
55
49
  /**
56
- * Provider bundle for the matched source. Undefined for local-repo test runs
57
- * (`kici run` against an inline lock file with no remote provider): in that
58
- * mode there is no clone-url builder / check-status poster / clone-token
59
- * provider, and `repoUrl` falls back to `''` (the agent treats a missing url
60
- * as a local/`fullRepo` clone). The webhook adapter always passes a defined
61
- * bundle, so its dispatch behavior is unchanged.
50
+ * Undefined only for local-repo test runs (`kici run` with an inline lock
51
+ * file and no remote provider): no clone-url builder, check poster or
52
+ * clone-token provider, and `repoUrl` is `''`, which the agent treats as a
53
+ * local/`fullRepo` clone. The webhook adapter always passes one.
62
54
  */
63
55
  bundle?: ProviderBundle;
64
56
  payload: unknown;
65
57
  repoIdentifier: string;
66
58
  /**
67
- * The repository that defines the workflow. Equals `repoIdentifier` unless
68
- * `global` is set.
69
- *
70
- * REQUIRED, for the same reason `securityDecision` is: a dispatch path that
71
- * does not state it must not compile. Left optional, a new caller omits it
72
- * silently and every row it records claims the workflow lives in the
73
- * repository the run acted on — a null marker is read as that fact, not as
59
+ * The repository that defines the workflow; equals `repoIdentifier` unless
60
+ * `global` is set. REQUIRED so a dispatch path that omits it does not
61
+ * compile: a null marker is read as "the repository the run acted on", not
74
62
  * "unknown" (`registration/registration-run-match.ts`).
75
63
  */
76
64
  workflowRepoIdentifier: string;
77
- /**
78
- * Set when the workflow is defined in another repository; `repoIdentifier`
79
- * is then the event's source repository.
80
- */
65
+ /** Set when another repository defines the workflow; `repoIdentifier` is then the event's source. */
81
66
  global?: GlobalDispatchIdentity;
82
67
  credentials: Record<string, unknown>;
83
68
  event: SimulatedEvent;
@@ -94,24 +79,19 @@ export interface WorkflowDispatchContext {
94
79
  };
95
80
  resolvedOrgId: string;
96
81
  /**
97
- * The NAMES of the jobs this dispatch pass has admitted against a context
98
- * concurrency limit, keyed by {@link concurrencyAdmissionKey}.
82
+ * NAMES of the jobs this pass admitted against a context concurrency limit,
83
+ * keyed by {@link concurrencyAdmissionKey}. The DB count cannot see a job
84
+ * just admitted, so without it every fan-out child is admitted against one
85
+ * slot.
99
86
  *
100
- * The database count cannot see a job this pass has only just admitted, so
101
- * without this tally every child of a fan-out is evaluated against that one
102
- * blind value and all N are admitted against a single slot.
87
+ * Names, not a counter, so the two terms stay DISJOINT: the count query
88
+ * excludes exactly these names ({@link countOccupyingJobs}). A counter summed
89
+ * with a count that already sees the row double-counts a sibling on the
90
+ * deferred-init path and spuriously holds a job.
103
91
  *
104
- * Names rather than a counter, because the two terms have to be DISJOINT: the
105
- * count query excludes exactly the names held here (see
106
- * {@link countOccupyingJobs}), so a job whose row has already landed
107
- * contributes its tally entry and nothing else. A counter cannot express that
108
- * exclusion, and summing it with a count that already sees the row is how the
109
- * deferred-init path double-counts a sibling and spuriously holds a job.
110
- *
111
- * Created lazily on first use and dropped with the ctx. It is per-pass state,
112
- * never persisted and never shared between passes; two actors arriving in the
113
- * same millisecond still race between the count and the insert, which is
114
- * accepted — this is a throughput control, not an isolation boundary.
92
+ * Lazy, per-pass, never persisted or shared. Two actors in the same
93
+ * millisecond still race between count and insert — accepted, as this is a
94
+ * throughput control, not an isolation boundary.
115
95
  */
116
96
  concurrencyAdmissions?: Map<string, Set<string>>;
117
97
  workflow: LockWorkflow;
@@ -122,117 +102,83 @@ export interface WorkflowDispatchContext {
122
102
  /** True when this run executes an uploaded local working tree (CLI remote run). */
123
103
  localWorkingTree: boolean;
124
104
  /**
125
- * Identity that initiated this run, for `execution_runs.triggered_by`.
126
- *
127
- * Set by the CLI remote-run path, which knows its caller: the Platform relays
128
- * the developer's actor on `test.relay.trigger` and the test pipeline renders
129
- * it here. Undefined on the webhook path, where the initiator is a provider
130
- * account rather than a KiCI principal — that attribution is carried by
131
- * `triggerActorUsername` / `triggerActorUserId` instead.
105
+ * `execution_runs.triggered_by`. Set by the CLI remote-run path from the
106
+ * actor the Platform relays on `test.relay.trigger`. Undefined on the webhook
107
+ * path, whose provider-account initiator is in `triggerActorUsername` /
108
+ * `triggerActorUserId`.
132
109
  */
133
110
  triggeredBy?: string | null;
134
111
  /** Agent provenance label when the run was initiated through an agent credential. */
135
112
  triggeredByAgentLabel?: string | null;
136
113
  /**
137
- * Re-run lineage for `execution_runs.parent_run_id` / `original_run_id`: the
138
- * run this one re-runs and the root of its re-run chain. Set by the re-run of
139
- * an organization-wide run; absent for every first run.
114
+ * `execution_runs.parent_run_id` / `original_run_id`. Set by the re-run of an
115
+ * organization-wide run; absent for every first run.
140
116
  */
141
117
  rerunLineage?: RerunLineage;
142
118
  /**
143
- * The trigger event the run's OIDC subject derives from, when it is not the
144
- * run's own `triggerEvent`. A re-run records `rerun` as its trigger event,
145
- * which carries no pull-request dimension, so it states the original run's
146
- * event here to keep the subject a re-run of a fork pull request presents.
119
+ * The trigger event the OIDC subject derives from, when not the run's own.
120
+ * A re-run records `rerun`, which has no pull-request dimension, so it
121
+ * states the original event here to keep a fork pull request's subject.
147
122
  */
148
123
  subjectTriggerEvent?: string;
149
124
  /** True only when invoked from the cross-source dispatch shell. */
150
125
  crossSource: boolean;
151
126
  /**
152
- * Trigger-event string for the run's `triggerEvent`, stated explicitly rather
153
- * than derived from `event.type`.
154
- *
155
- * The internal-event adapter needs this because a user `kiciEvent()` renders
156
- * two different values: `jobConfig.event.type` is the literal `kici_event`,
157
- * while the run carries the raw event name. `event.type` carries the former,
158
- * so the latter has to be stated.
159
- *
160
- * Absent ⇒ the value derived from the event, unchanged for the webhook,
161
- * CLI-remote-run and resume callers.
127
+ * The run's `triggerEvent`, stated instead of derived from `event.type`. A
128
+ * user `kiciEvent()` has `event.type` = `kici_event` while the run carries
129
+ * the raw event name. Absent ⇒ derived from the event.
162
130
  */
163
131
  triggerEventOverride?: string;
164
132
  /**
165
- * The exact `jobConfig.event` envelope to ship, stated explicitly instead of
166
- * spreading the `SimulatedEvent` this dispatch matched against.
167
- *
168
- * Same reason as `triggerEventOverride`: the matcher's event shape and the
169
- * shape user code observes are not the same object. `SimulatedEvent` requires
170
- * `targetBranch` and carries `changedFiles`; the envelope omits both. An
171
- * internally triggered run genuinely has no changed files, and its branch is
172
- * provenance the orchestrator evaluates (the trigger matcher and the context
173
- * branch gate) rather than a field user code asked for — the envelope becomes
174
- * `RuleContext.event` on the agent and the `event` half of
175
- * `buildConcurrencyGroupContext`, so publishing the branch would silently
176
- * re-key the documented `ctx.event.targetBranch ?? 'default'` concurrency
177
- * group of every existing internal workflow.
178
- *
179
- * Absent ⇒ the envelope derived from the event, unchanged for the webhook,
180
- * CLI-remote-run and resume callers.
133
+ * The exact `jobConfig.event` envelope, instead of spreading the matched
134
+ * `SimulatedEvent`. The envelope omits `targetBranch` and `changedFiles`: an
135
+ * internal run has no changed files, and its branch is provenance for the
136
+ * trigger matcher and context branch gate. The envelope becomes
137
+ * `RuleContext.event` and the `event` half of `buildConcurrencyGroupContext`,
138
+ * so publishing the branch would silently re-key the documented
139
+ * `ctx.event.targetBranch ?? 'default'` group of every internal workflow.
140
+ * Absent ⇒ derived from the event.
181
141
  */
182
142
  eventEnvelopeOverride?: Record<string, unknown>;
183
143
  /**
184
- * Chain depth to stamp on the started run. A run summoned by an invoke gate
185
- * carries its summoner's depth + 1, which is what bounds the chain-depth
186
- * circuit breaker. Absent ⇒ 0, the column default (a webhook-triggered run
187
- * starts a chain).
144
+ * Chain depth to stamp: an invoke-gate summon carries its summoner's depth +
145
+ * 1, which bounds the chain-depth circuit breaker. Absent ⇒ 0.
188
146
  *
189
- * Threading this is load-bearing: the breaker fails OPEN if the value is
190
- * lost, so an unbounded summon recursion would go undetected. It is stamped
191
- * as soon as the run row exists, because `releaseInvokeGate` reads the column
192
- * back at gate-release time — which happens inside this same dispatch.
147
+ * Load-bearing: the breaker fails OPEN if this is lost. Stamped as soon as
148
+ * the run row exists, because `releaseInvokeGate` reads it back inside this
149
+ * same dispatch.
193
150
  */
194
151
  chainDepth?: number;
195
152
  /**
196
153
  * Marks a run dispatched by a failure-lifecycle trigger, so its own
197
154
  * completion is excluded from batch accumulation and a broken notifier
198
- * cannot re-trigger itself (`EventRouter.isFailureLifecycleRun`).
199
- *
200
- * Persisted as a field INSIDE the `trigger_decision` JSON blob, merged onto
201
- * the decision summary rather than replacing it.
155
+ * cannot re-trigger itself (`EventRouter.isFailureLifecycleRun`). Persisted
156
+ * as a field merged INTO the `trigger_decision` JSON blob.
202
157
  */
203
158
  dispatchedByFailureLifecycle?: boolean;
204
159
  /**
205
- * Marks a run the orchestrator triggered itself — a schedule fire, a
206
- * workflow/job completion, a failure batch, a user `kiciEvent()`, or an
207
- * invoke-gate summon — as opposed to one a provider webhook triggered.
160
+ * Marks a run the orchestrator triggered itself (schedule fire, workflow/job
161
+ * completion, failure batch, user `kiciEvent()`, invoke-gate summon). Absent
162
+ * ⇒ webhook-triggered.
208
163
  *
209
- * Read by the context branch gate, and by nothing else. Such a run usually
210
- * carries a real branch in `event.targetBranch` — a schedule fire presents
211
- * its registration's default branch, every other internal trigger inherits
212
- * the branch of the run that emitted its event — and the gate matches it like
213
- * any other run's. The flag singles out the runs whose `targetBranch` is
214
- * EMPTY: a failure batch or a scaler event (many runs behind it, or none), a
215
- * registration whose default branch has never been captured, an emitting run
216
- * that is gone. The gate rejects those naming that cause, instead of quoting
217
- * an empty value as though it were a branch name. It does NOT weaken the
218
- * gate — a run with no branch cannot satisfy a restriction, `*` included.
219
- *
220
- * Absent ⇒ webhook-triggered, unchanged for the webhook, CLI-remote-run and
221
- * resume callers.
164
+ * Read only by the context branch gate. Such a run usually has a real
165
+ * `targetBranch` (a schedule's registration default branch, or the emitting
166
+ * run's branch) and is matched normally. The flag lets the gate name the
167
+ * cause when `targetBranch` is EMPTY (failure batch, scaler event, uncaptured
168
+ * default branch, emitting run gone) instead of quoting an empty branch. It
169
+ * does NOT weaken the gate: a run with no branch satisfies no restriction,
170
+ * `*` included.
222
171
  */
223
172
  internallyTriggered?: boolean;
224
173
  /**
225
- * Outcome of the org trust-policy gate for this PR event. `pass` dispatches
226
- * normally; `hold` parks the run in the security queue; `reject` fails it
227
- * before any job starts. Computed once per PR event in the webhook pipeline
228
- * and threaded down; the dispatch gate acts on it directly, see
229
- * `holdRunForSecurityPolicy` / `rejectRunForSecurityPolicy`.
174
+ * Org trust-policy gate outcome for this PR event: `pass` dispatches, `hold`
175
+ * parks the run in the security queue, `reject` fails it before any job
176
+ * starts (`holdRunForSecurityPolicy` / `rejectRunForSecurityPolicy`).
177
+ * Computed once per PR event in the webhook pipeline.
230
178
  *
231
- * REQUIRED: a dispatch path that does not state a decision must not compile.
232
- * This field was optional once and the gate read `if (!decision) return
233
- * null`, so forgetting to thread it meant the run passed the security gate —
234
- * fail-open by omission inside a fail-closed control. A `pass` is stated
235
- * explicitly.
179
+ * REQUIRED so a path that omits it does not compile: an optional field read
180
+ * as `if (!decision) return null` passes the gate on omission — fail-open
181
+ * inside a fail-closed control. A `pass` is stated explicitly.
236
182
  */
237
183
  securityDecision: TrustPolicyOutcome;
238
184
  /**
@@ -253,139 +199,110 @@ export interface WorkflowDispatchContext {
253
199
  */
254
200
  runRegisteredBeforeDispatch?: boolean;
255
201
  /**
256
- * Set once `setupDispatchContext` has posted this dispatch's queued
257
- * `kici/<workflow>` check and one `kici/<workflow>/job/<name>` per static job.
258
- *
259
- * Those checks go up BEFORE anything decides whether the run will start, so
260
- * every exit after setup owes them a conclusion. The named early exits each
261
- * complete their own; a THROW does not, and nothing else can — the workflow
262
- * check keys off a run whose jobs never registered, and the stale sweep only
263
- * touches check runs already `in_progress`. Left alone they stay `queued`
264
- * forever, which on a pull request is a check that never finishes and a
265
- * branch-protection blocker.
202
+ * Set once `setupDispatchContext` posted the queued `kici/<workflow>` check
203
+ * and one `kici/<workflow>/job/<name>` per static job. They go up BEFORE the
204
+ * start decision, so every exit owes them a conclusion. Named early exits
205
+ * complete their own; a THROW does not, and nothing else can (the stale
206
+ * sweep only touches `in_progress` checks), so they stay `queued` forever —
207
+ * a branch-protection blocker on a pull request.
266
208
  */
267
209
  pendingChecksPosted?: boolean;
268
210
  /** Composite dedup key `${info.deliveryId}:${reg.id}` (cross-source only). */
269
211
  crossSourceDeliveryId?: string;
270
212
  /**
271
- * Routing key to use for dispatched QueuedJobInput + log / tracker rows.
272
- * Same-source: equal to `info.routingKey`. Cross-source: equal to
273
- * `reg.routingKey` (the registration's owning source, NOT the inbound
274
- * generic routing key).
213
+ * Routing key for dispatched jobs and log / tracker rows: `info.routingKey`
214
+ * same-source; `reg.routingKey` cross-source (the registration's owning
215
+ * source, NOT the inbound generic key).
275
216
  */
276
217
  effectiveRoutingKey?: string;
277
218
  /**
278
- * Provider identifier to use for dispatched QueuedJobInput + tracker rows.
279
- * Same-source: equal to `info.provider`. Cross-source: equal to
280
- * `regBundle.normalizer.provider` (the registration's provider type,
281
- * e.g. 'github').
219
+ * Provider for dispatched jobs and tracker rows: `info.provider`
220
+ * same-source; `regBundle.normalizer.provider` cross-source.
282
221
  */
283
222
  effectiveProvider?: string;
284
223
  /**
285
- * Extra jobConfig fields merged into every dispatched QueuedJobInput by
286
- * this helper. Cross-source callers use this to inject provenance fields
287
- * (`crossSource: true`, `inboundRoutingKey`, `inboundEventName`,
288
- * `workflowRepoUrl`, `workflowRef`, `workflowSha`,
289
- * `workflowRepoIdentifier`) that downstream agents / dashboards need for
290
- * correct clone + logging.
224
+ * jobConfig fields merged into every dispatched job. Cross-source callers
225
+ * inject provenance (`crossSource: true`, `inboundRoutingKey`,
226
+ * `inboundEventName`, `workflowRepoUrl`, `workflowRef`, `workflowSha`,
227
+ * `workflowRepoIdentifier`) that agents and dashboards need to clone and log.
291
228
  */
292
229
  extraJobConfig?: Record<string, unknown>;
293
230
  /**
294
- * Test-run provenance. Present only for `kici run` / test-trigger dispatches.
295
- * When set, `recordRunStart` stamps `is_test_run = true` and
296
- * `fixture_id = testRun.fixtureId` on the `execution_runs` row. Undefined for
297
- * webhook runs (the stamp block is skipped).
231
+ * Set only for `kici run` / test-trigger dispatches: `recordRunStart` stamps
232
+ * `is_test_run = true` and `fixture_id` on the `execution_runs` row.
298
233
  */
299
234
  testRun?: {
300
235
  fixtureId: string;
301
236
  };
302
237
  /**
303
- * Run-wide flat secrets layered onto EVERY dispatched job's `jobConfig.secrets`
304
- * (env-declaring or not). Used by the test path to deliver `kici run --secret`
305
- * / `--env` CLI flat secrets, which must reach a job regardless of whether it
306
- * declares an `context:`. Merged UNDER the per-job env-resolved secrets so
307
- * the CLI value wins on a key collision (matching the prior B1-env -> A-CLI
308
- * precedence). Undefined for webhook runs.
238
+ * `kici run --secret` / `--env` flat secrets, layered onto EVERY job's
239
+ * `jobConfig.secrets` whether or not it declares a `context:`. The CLI value
240
+ * wins on a key collision with per-job context secrets. Undefined for webhook
241
+ * runs.
309
242
  */
310
243
  runWideFlatSecrets?: Record<string, string>;
311
244
  /**
312
- * Runtime host narrowing from `kici run --target` (Ansible `--limit`). Applied
313
- * as a post-filter over each runsOnAll job's matched roster: effective hosts =
314
- * runsOnAll ∩ target. Narrow-only. Undefined for webhook runs (no narrowing).
245
+ * `kici run --target` (Ansible `--limit`): narrow-only post-filter, effective
246
+ * hosts = runsOnAll ∩ target. Undefined for webhook runs.
315
247
  */
316
248
  target?: HostTargetSelector;
317
249
  /**
318
- * Resolved (coerced + defaulted + validated) workflow-dispatch inputs from
319
- * `kici run --input`. Carried onto every dispatched job's request so the agent
320
- * exposes them as `ctx.dispatchInputs`. Undefined for webhook runs.
250
+ * Resolved (coerced, defaulted, validated) `kici run --input` values, exposed
251
+ * to every job as `ctx.dispatchInputs`. Undefined for webhook runs.
321
252
  */
322
253
  dispatchInputs?: Record<string, unknown>;
323
254
  /**
324
- * What the workflow install gate recorded when it held this dispatch: the
325
- * contexts that held, which the hold's approval covers, and the ones it
326
- * admitted. Stored with the held dispatch and read by its release, which
327
- * gates every context the approval did not cover. Unset on any other
328
- * dispatch.
255
+ * Set only on an install-gate-held dispatch: the contexts that held (covered
256
+ * by the hold's approval) and the ones admitted. Its release gates every
257
+ * context the approval did not cover.
329
258
  */
330
259
  installGateRecord?: InstallGateRecord;
331
260
  }
332
261
  /**
333
- * The minimal slice of a dispatch context the needs catch-up + ready-recompute
334
- * helpers read. Both the per-repository `WorkflowDispatchContext` and the
335
- * global-workflow dispatch path (which builds its own inputs and never
336
- * constructs a full `WorkflowDispatchContext`) can drive the needs scheduler
337
- * through this narrow shape.
262
+ * The slice the needs catch-up and ready-recompute helpers read, so the
263
+ * global-workflow path (which never builds a full `WorkflowDispatchContext`)
264
+ * can drive the needs scheduler too.
338
265
  */
339
266
  export type NeedsSchedulingContext = Pick<WorkflowDispatchContext, 'deps' | 'runId'>;
340
267
  /**
341
- * Build the dispatch-envelope event, carrying the orchestrator's already-fetched
342
- * changed-files list + status from `eventWithFiles` as a fast-path (the agent
343
- * recomputes from the clone when status !== 'fetched', so this only forfeits the
344
- * optimization when a path is missed — correctness comes from the agent).
268
+ * The dispatch-envelope event, carrying the already-fetched changed files as a
269
+ * fast path. The agent recomputes from the clone when status !== 'fetched', so
270
+ * correctness comes from the agent.
345
271
  */
346
272
  export declare function envelopeEvent(baseEvent: SimulatedEvent, eventWithFiles: SimulatedEvent): SimulatedEvent;
347
273
  export interface DispatchMatchedWorkflowResult {
348
- /** Number of jobs successfully dispatched (non-rejected). */
274
+ /** Non-rejected jobs dispatched. */
349
275
  dispatchedJobCount: number;
350
- /** Execution job ids of every dispatched/tracked job (root, gated, synthetic). */
276
+ /** Every dispatched/tracked job id (root, gated, synthetic). */
351
277
  dispatchedJobIds: string[];
352
278
  /**
353
- * Jobs whose dispatch is deferred to the agent init round (a dynamic context
354
- * or a deferred-init job) and therefore not yet in `dispatchedJobIds`. These
355
- * still run — they are dispatched asynchronously by `startDeferredPhases` —
356
- * so a caller must not treat a run with pending deferred work as "nothing
357
- * dispatched". Absent/0 on the early-return paths.
279
+ * Jobs deferred to the agent init round, not yet in `dispatchedJobIds`. They
280
+ * still run (`startDeferredPhases`), so a run with deferred work is not
281
+ * "nothing dispatched". Absent/0 on early returns.
358
282
  */
359
283
  deferredJobCount?: number;
360
- /** True when the workflow install gate paused the dispatch (held run). */
284
+ /** True when the workflow install gate held the run. */
361
285
  held?: boolean;
362
286
  /**
363
- * User-visible warnings aggregated from dispatched jobs — today, one per job
364
- * whose bound test-run context(s) were unavailable and skipped. Surfaced
365
- * on the accepted trigger response so the CLI can print them.
287
+ * One warning per job whose bound test-run contexts were skipped, surfaced
288
+ * on the trigger response for the CLI to print.
366
289
  */
367
290
  envWarnings?: string[];
368
291
  }
369
292
  /** Options controlling a (re-)dispatch of a matched workflow. */
370
293
  export interface DispatchMatchedWorkflowOptions {
371
- /**
372
- * Resume path: skip the workflow install protection gate (already satisfied)
373
- * so secrets resolve directly and the dispatch flows into job dispatch.
374
- */
294
+ /** Resume path: the install protection gate is already satisfied. */
375
295
  skipInstallProtectionGate?: boolean;
376
- /**
377
- * The run id whose `held` execution_runs row should be reused (flipped to
378
- * pending) instead of inserting a fresh row.
379
- */
296
+ /** Run id whose `held` row is flipped to pending instead of inserting a new one. */
380
297
  reuseRunId?: string;
381
298
  }
382
299
  type DispatchFn = (input: QueuedJobInput) => ReturnType<Dispatcher['dispatch']>;
383
300
  interface DispatchSetup {
384
- /** Wrapped dispatcher that injects ctx.extraJobConfig into every dispatch. */
301
+ /** Injects ctx.extraJobConfig into every dispatch. */
385
302
  dispatcher: {
386
303
  dispatch: DispatchFn;
387
304
  };
388
- /** WebhookInfo overlaid with effective routing key + provider. */
305
+ /** Overlaid with the effective routing key and provider. */
389
306
  info: WebhookInfo;
390
307
  /** Composite delivery id on cross-source, otherwise info.deliveryId. */
391
308
  effectiveDeliveryId: string;
@@ -395,11 +312,9 @@ interface DispatchSetup {
395
312
  } | undefined;
396
313
  workflowTimeoutMs: number | undefined;
397
314
  /**
398
- * Run mode for idempotent steps (`apply` | `check` | `check-fail-on-drift`),
399
- * carried on `ctx.extraJobConfig` by the test-trigger / `kici run --check`
400
- * path. Persisted onto the `execution_runs` row so `computeRunStatus` can
401
- * fail a `check-fail-on-drift` run that detected drift. Undefined for the
402
- * default apply-mode webhook path.
315
+ * Idempotent-step mode (`apply` | `check` | `check-fail-on-drift`) from the
316
+ * `kici run --check` path; persisted so `computeRunStatus` fails a
317
+ * `check-fail-on-drift` run with drift. Undefined for apply-mode webhooks.
403
318
  */
404
319
  checkMode: string | undefined;
405
320
  }
@@ -417,9 +332,9 @@ interface BuildPrepResult {
417
332
  }>>;
418
333
  staticJobs: readonly LockJob[];
419
334
  /**
420
- * Static jobs expanded into dispatchable children (matrix fan-out). Non-matrix
421
- * jobs pass through 1:1. Every dispatch phase iterates this list, keying by
422
- * `expandedName`. Dynamic-matrix jobs are flagged `pendingDynamicMatrix`.
335
+ * Static jobs after matrix fan-out (non-matrix 1:1), keyed by
336
+ * `expandedName` in every phase. Dynamic-matrix jobs carry
337
+ * `pendingDynamicMatrix`.
423
338
  */
424
339
  materializedJobs: readonly MaterializedJob[];
425
340
  /** baseName -> expanded child names; drives needs-edge expansion. */
@@ -432,12 +347,11 @@ interface BuildPrepResult {
432
347
  buildJobName: string | undefined;
433
348
  buildJobLabels: string[] | undefined;
434
349
  buildJobTrackedEarly: boolean;
435
- /** True when the build failed but dynamic entries can still proceed. */
350
+ /** The build failed but dynamic entries can still proceed. */
436
351
  buildFailed: boolean;
437
352
  /**
438
- * True when the helper has fully short-circuited the dispatch (build failed
439
- * and no dynamic entries to fall back on, or build job rejected). Caller
440
- * MUST early-return with `dispatchedJobCount: 0`.
353
+ * Dispatch short-circuited (build failed with no dynamic entries, or build
354
+ * job rejected). Caller MUST return `dispatchedJobCount: 0`.
441
355
  */
442
356
  abort: boolean;
443
357
  }
@@ -446,9 +360,8 @@ interface JobEnvData {
446
360
  /** Configured env id matched for the first declared context name. */
447
361
  contextId?: string;
448
362
  /**
449
- * Ordered bound-context names persisted on the job row (`(dynamic)`
450
- * placeholder for elements unresolved at dispatch; overwritten with the
451
- * agent-resolved list for dynamic contexts). Empty/undefined = no binding.
363
+ * Ordered bound-context names for the job row; `(dynamic)` marks an element
364
+ * the agent resolves later, which then overwrites the list.
452
365
  */
453
366
  contextNames?: string[];
454
367
  contextVars?: Record<string, string>;
@@ -456,9 +369,9 @@ interface JobEnvData {
456
369
  jobSecrets?: Record<string, string>;
457
370
  jobNamespacedSecrets?: Record<string, Record<string, string>>;
458
371
  /**
459
- * Registry credentials for this job's container image, resolved from the
460
- * secret NAMES the lock carries. Lifted to a top-level dispatch field (and
461
- * stripped from jobConfig) before the message reaches the agent.
372
+ * Container registry credentials resolved from the lock's secret NAMES;
373
+ * lifted to a top-level dispatch field (stripped from jobConfig) before the
374
+ * agent sees it.
462
375
  */
463
376
  containerRegistryAuth?: {
464
377
  username: string;
@@ -467,24 +380,21 @@ interface JobEnvData {
467
380
  };
468
381
  held?: boolean;
469
382
  /**
470
- * Set when the job's bound contexts admitted its reject rules: what a later
471
- * dispatch resolves the context data from when the job is stored as a
472
- * pending dispatch context (held, waiting on upstream jobs, or outside its
473
- * wave window) instead of dispatching now. Carries no secret value.
383
+ * Set when the bound contexts admitted the job's reject rules: what a later
384
+ * dispatch resolves context data from when the job is stored pending (held,
385
+ * awaiting upstream, outside its wave). Carries no secret value.
474
386
  */
475
387
  contextResolution?: DeferredContextResolution;
476
388
  /**
477
- * Pending approval hold for this job, set when a context policy or
478
- * explicit lock `approval` requires human sign-off. The dispatch loop turns
479
- * this into a `held_runs` row + a stored pending job context so `release()`
480
- * can re-dispatch after approval.
389
+ * Set when a context policy or lock `approval` needs sign-off; the dispatch
390
+ * loop turns it into a `held_runs` row plus a stored pending job context so
391
+ * `release()` can re-dispatch.
481
392
  */
482
393
  approvalHold?: PendingApprovalHold;
483
394
  /**
484
- * A non-reviewer hold (security / wait-timer / concurrency-queue) decided by a
485
- * context's protection rules. Carried rather than written on the spot so
486
- * `holdJobForApproval` can create the row and the job's resume path in ONE
487
- * transaction — the reviewer branch uses `approvalHold` for the same purpose.
395
+ * A non-reviewer hold (security / wait-timer / concurrency-queue) from
396
+ * protection rules. Carried, not written on the spot, so
397
+ * `holdJobForApproval` creates the row and resume path in ONE transaction.
488
398
  */
489
399
  nonApprovalHold?: CreateHeldRunData;
490
400
  rejected?: boolean;
@@ -492,11 +402,7 @@ interface JobEnvData {
492
402
  pendingInit?: boolean;
493
403
  /** Bound contexts skipped on a test/local run because they disallow local execution. */
494
404
  skippedEnvs?: string[];
495
- /**
496
- * User-visible warning set whenever any bound context was unavailable for
497
- * a test run (non-test or unconfigured) and skipped — surfaced on the CLI run
498
- * output and the dashboard run view.
499
- */
405
+ /** Warning naming test-run contexts skipped as non-test or unconfigured; shown in CLI and dashboard. */
500
406
  envWarning?: string;
501
407
  }
502
408
  /** A resolved approval requirement awaiting hold creation in the dispatch loop. */
@@ -518,14 +424,11 @@ interface JobEnvEvalResult {
518
424
  runContextId: string | undefined;
519
425
  }
520
426
  /**
521
- * Synthetic job-id prefix every needs-gate site stamps on a job it holds back.
522
- * The release path (`dispatchReadyJob` → `findSyntheticJobId` → `addJobsToRun`)
523
- * keys on it, so it is load-bearing rather than cosmetic — which is what makes
524
- * it a sound way to recover the gated set without threading a parallel list
525
- * through both the single-orchestrator and cluster dispatch paths.
526
- *
527
- * Re-exported from `db/synthetic-job-ids.ts`, which owns it so the concurrency
528
- * sweep in `contexts/` can exclude these rows without importing this module.
427
+ * Synthetic job-id prefix every needs-gate site stamps on a held-back job. The
428
+ * release path (`dispatchReadyJob` → `findSyntheticJobId` → `addJobsToRun`)
429
+ * keys on it, so it soundly recovers the gated set without threading a parallel
430
+ * list through both the single-orch and cluster paths. Owned by `db/synthetic-job-ids.ts` so the `contexts/`
431
+ * concurrency sweep need not import this module.
529
432
  */
530
433
  export { NEEDS_PENDING_JOB_ID_PREFIX };
531
434
  interface RejectedJob {
@@ -535,29 +438,19 @@ interface RejectedJob {
535
438
  /** Explicit init-failure category override; inferred from reason when absent. */
536
439
  category?: InitFailureCategory;
537
440
  /**
538
- * Terminal status to record for this job. Defaults to `failed`. A zeroed
539
- * `runsOnAll` that intentionally narrowed to no hosts is recorded as `skipped`
540
- * (no init-failure) so its downstreams' `when` sets govern propagation.
441
+ * Default `failed`. A `runsOnAll` deliberately narrowed to no hosts records
442
+ * `skipped` (no init-failure) so downstream `when` sets govern propagation.
541
443
  */
542
444
  terminalStatus?: ExecutionJobStatus;
543
445
  }
544
446
  /**
545
- * Whether this dispatch must run a `__build__` job before its real jobs.
546
- *
547
- * Either cache missing is a reason to build. The two are keyed on different
548
- * things — the source cache on the workflow source's contentHash, the dep cache
549
- * on the lockfile hash — so they miss independently, and a dependency bump is
550
- * exactly the case that leaves the source warm and the deps cold. Gating only on
551
- * the source miss made that state permanent: no build job ran, so nothing ever
552
- * uploaded the dep tarball, so every agent fell back to installing from the
553
- * registry on every job — and an agent with no route to that registry (a
554
- * cloud-hosted one-shot agent, an air-gapped runner) could not run the job at
555
- * all. The `__build__` job already carries `buildSourceNeeded` /
556
- * `buildDepsNeeded` separately and the agent already honors both, so a
557
- * deps-only build was implemented and unreachable.
447
+ * Whether a `__build__` job must run first. Either cache missing is a reason:
448
+ * source (keyed on contentHash) and deps (keyed on lockfile hash) miss
449
+ * independently, and a dependency bump leaves source warm and deps cold.
450
+ * Gating on the source miss alone never uploads the dep tarball, so agents
451
+ * with no registry route (cloud one-shot, air-gapped) cannot run at all.
558
452
  *
559
- * A hash is required alongside its miss: with no hash there is no cache key to
560
- * write, so building would produce an artifact nothing could ever look up.
453
+ * A miss counts only with its hash: no hash means no cache key to write.
561
454
  */
562
455
  export declare function buildIsNeeded(args: {
563
456
  /** False when there is nothing to cache into (no bundle, no coordinator, …). */
@@ -568,13 +461,11 @@ export declare function buildIsNeeded(args: {
568
461
  lockfileHash: string | undefined;
569
462
  }): boolean;
570
463
  /**
571
- * Build the QueuedJobInput for a synthetic `__bringup__` job: the orchestrator
572
- * dispatches one per declared-but-un-agented `includeUninitialized` child to an
573
- * agent holding `kici:capability:ssh-transport`, which runs the agent-side
574
- * `ensureInitRunner(targetAgentId)` over SSH. The init-runner then connects
575
- * under `targetAgentId`, and the child's pinned-hold (already queued with that
576
- * pin) drains its bootstrap steps onto it. The bring-up job clones nothing and
577
- * runs no sandbox (`bringupOnly`).
464
+ * A synthetic `__bringup__` job, one per un-agented `includeUninitialized`
465
+ * child, sent to a `kici:capability:ssh-transport` agent that runs
466
+ * `ensureInitRunner(targetAgentId)` over SSH. The init-runner connects under
467
+ * `targetAgentId` and the child's pinned hold drains onto it. Clones nothing,
468
+ * no sandbox (`bringupOnly`).
578
469
  */
579
470
  export declare function buildBringupJobInput(args: {
580
471
  ctx: WorkflowDispatchContext;
@@ -582,23 +473,10 @@ export declare function buildBringupJobInput(args: {
582
473
  targetAgentId: string;
583
474
  }): QueuedJobInput;
584
475
  /**
585
- * Phase B orchestrator: probe caches, dispatch the build job (if needed),
586
- * and surface enough state for downstream phases to skip / continue
587
- * appropriately.
588
- */
589
- /**
590
- * Materialize each static job's matrix into dispatchable children. A job whose
591
- * matrix is invalid (zero combinations / over the cap) is dropped from the
592
- * dispatch list and recorded as a `matrix_expansion` matrix failure so the run's
593
- * other jobs still proceed. Dynamic-matrix jobs pass through with a
594
- * `pendingDynamicMatrix` marker for the eval flow.
595
- */
596
- /**
597
- * Resolve a `runsOnAll` lock job against the declared host roster and partition
598
- * the matched hosts into the target set per the `onUnreachable` policy (R2):
599
- * `ready` hosts always run; unreachable durable (`static`) hosts hold / fail /
600
- * skip; stale ephemeral hosts are always skipped. Throws {@link FanoutError}
601
- * when the run can't proceed (fail policy with an absent host, or zero targets).
476
+ * Resolve a `runsOnAll` job against the host roster and apply `onUnreachable`:
477
+ * `ready` hosts run; unreachable `static` hosts hold / fail / skip; stale
478
+ * ephemeral hosts are skipped. Throws {@link FanoutError} when the run cannot
479
+ * proceed (fail policy with an absent host, or zero targets).
602
480
  */
603
481
  export declare function resolveHostFanoutTargets(lockJob: LockJob, deps: ProcessingDeps, target?: HostTargetSelector): Promise<ResolvedHostAgent[]>;
604
482
  /** Exact labels + regex patterns partitioned from a lock job's selectors. */
@@ -608,64 +486,44 @@ interface JobRoutingSelectors {
608
486
  excludeLabels: string[];
609
487
  excludePatterns: LabelMatcher[];
610
488
  /**
611
- * The `runsOn` exact values exactly as the lock file spells them, before the
612
- * canonical fold `partitionMatchers` applies.
613
- *
614
- * Only {@link resolveRosterAgentPin} reads this. A bare agent id in `runsOn`
615
- * is the documented inventory fan-out pattern (`runsOn: [h.agentId]`), and an
616
- * agent id is not a label: `host_roster.agent_id` is case-sensitive, so the
617
- * folded form misses every host whose id carries a capital.
489
+ * `runsOn` exact values as spelled, before `partitionMatchers` folds them.
490
+ * For {@link resolveRosterAgentPin} only: `host_roster.agent_id` is
491
+ * case-sensitive, so the folded form misses ids with a capital.
618
492
  */
619
493
  runsOnExactRaw: string[];
620
494
  }
621
495
  /**
622
- * Partition a lock job's runsOn / excludeLabels matchers into exact labels (SQL
623
- * `@>` prefilter + registry index) and regex patterns (JS post-filter). A
624
- * `runsOnAll` host-fanout job has no `runsOn`; its pinned children carry no
625
- * routing (the pin targets the resolved agent directly).
496
+ * Partition runsOn / excludeLabels into exact labels (SQL `@>` prefilter +
497
+ * registry index) and regex patterns (JS post-filter). A `runsOnAll` job has
498
+ * no `runsOn`; its children route by pin.
626
499
  */
627
500
  export declare function runsOnSelectorsForLockJob(lockJob: {
628
501
  runsOn?: readonly LabelMatcher[];
629
502
  excludeLabels?: readonly LabelMatcher[];
630
503
  }): JobRoutingSelectors;
631
504
  /**
632
- * Runtime facts a job's own shape demands of the host that runs it.
633
- *
634
- * Only a `container.dockerfile` job gets one. Building shells out to a
635
- * `docker` / `podman` CLI, so a host without one cannot run the job at all, and
636
- * the agent self-reports `kici:runtime:container-build` when it has one.
505
+ * Runtime labels a job's shape demands of its host. Only a
506
+ * `container.dockerfile` job gets one: building needs a `docker` / `podman`
507
+ * CLI, which the agent self-reports as `kici:runtime:container-build`.
637
508
  *
638
- * A job that names a finalized `image` deliberately gets NOTHING added. Adding
639
- * an implicit requirement to jobs that already work is how container jobs were
640
- * stranded once before: they had been running fine, and a routing gate the
641
- * orchestrator could not actually evaluate made them match nothing. A dockerfile
642
- * job is new, so requiring the fact strands no existing workflow — and an agent
643
- * old enough not to report the fact is an agent that cannot build anyway.
509
+ * A finalized `image` job deliberately gets NOTHING: an implicit requirement
510
+ * on working jobs strands them. An agent too old to report the label cannot
511
+ * build anyway.
644
512
  *
645
- * Applied when matching REGISTERED agents (the dispatcher), and deliberately
646
- * NOT when consulting the scaler. A scaler backend is chosen by exact label-set
647
- * containment, so a required label the operator never wrote in a pool's label
648
- * set matches no backend at all — the job would be stranded `queued-no-backend`
649
- * rather than spawned. The pool's hosts are the operator's to describe; what an
650
- * agent can actually do is known only once it registers and says so.
513
+ * Applied to REGISTERED agents only, NOT the scaler: backends match by exact
514
+ * label-set containment, so a label absent from the pool's set strands the job
515
+ * `queued-no-backend`. What an agent can do is known once it registers.
651
516
  */
652
517
  export declare function requiredRuntimeLabelsFor(container: unknown): string[];
653
518
  /**
654
- * Resolve a generated job's single bare-`agentId` `runsOn` into a host pin.
655
- *
656
- * The documented inventory fan-out pattern is `runsOn: [h.agentId]`. A bare
657
- * agentId is not a label any agent advertises, so the normal label path leaves
658
- * the job `queued-no-backend`. When the single exact label names a known roster
659
- * host, resolve it to a `pinnedAgentId` dispatch (+ the host's coordinator for
660
- * cross-cluster reroute) — exact parity with how `runsOnAll` children pin. Any
661
- * other shape (multi-label, a regex pattern, a non-roster label, or no roster
662
- * store) returns null and the caller keeps normal label routing.
663
- *
664
- * `runsOnExact` takes the values the lock file spells, NOT the canonical labels
665
- * every other routing path uses: this looks the value up as an agent id, and
666
- * agent ids are case-sensitive. Handing it folded labels strands every host
667
- * whose id carries a capital on the normal label path, where a bare agent id
668
- * matches nothing.
519
+ * Resolve the documented inventory pattern `runsOn: [h.agentId]` into a host
520
+ * pin. A bare agentId is no advertised label, so label routing leaves it
521
+ * `queued-no-backend`. When the single exact label names a roster host, pin it
522
+ * (plus its coordinator for reroute), as `runsOnAll` children pin. Any other
523
+ * shape returns null and keeps label routing.
524
+ *
525
+ * `runsOnExact` takes the lock's spelling, NOT folded labels: agent ids are
526
+ * case-sensitive.
669
527
  */
670
528
  export declare function resolveRosterAgentPin(args: {
671
529
  runsOnExact: string[];
@@ -686,19 +544,18 @@ export interface WavePlan {
686
544
  }>;
687
545
  }
688
546
  /**
689
- * Compute the rolling-wave plan for a materialized job set.
690
- *
691
- * For each base job declaring `maxParallel` whose fan-out produced more than one
692
- * child, children are ordered deterministically by `fanoutIndex` (the
693
- * agentId / variant-label rank assigned at materialization; falling back to
694
- * `expandedName` for children with no index) and every child at index `>=
695
- * maxParallel` is held (`wave_gated=true`). The first `maxParallel` dispatch
696
- * immediately; held children release one-per-terminal via the wave-scheduler.
697
- * Every child of a bounded-wave base — held or not — gets a `policy` entry so
698
- * the wave-scheduler can read the width/failFast at terminal time. A non-fan-out
699
- * job (single child) or one without `maxParallel` contributes nothing.
547
+ * Rolling-wave plan. For a `maxParallel` base with more than one child,
548
+ * children sort by `fanoutIndex` (else `expandedName`) and index `>=
549
+ * maxParallel` is held (`wave_gated=true`); held children release
550
+ * one-per-terminal via the wave-scheduler. Every child of a bounded base gets
551
+ * a `policy` entry for the scheduler to read at terminal time.
700
552
  */
701
553
  export declare function computeWavePlan(materializedJobs: readonly MaterializedJob[]): WavePlan;
554
+ /**
555
+ * Materialize each static job's fan-out. An invalid fan-out (zero combinations,
556
+ * over the cap) is recorded as a failure so the run's other jobs proceed.
557
+ * Dynamic-matrix jobs pass through marked `pendingDynamicMatrix`.
558
+ */
702
559
  export declare function materializeStaticJobsSafe(staticJobs: readonly LockJob[], deps: ProcessingDeps, target?: HostTargetSelector): Promise<{
703
560
  materializedJobs: MaterializedJob[];
704
561
  expansionMap: Map<string, readonly string[]>;
@@ -707,10 +564,9 @@ export declare function materializeStaticJobsSafe(staticJobs: readonly LockJob[]
707
564
  /** The `paths` lists this workflow's matching left to the agent, or undefined. */
708
565
  export declare function deferredPathsOf(ctx: Pick<WorkflowDispatchContext, 'decision'>): string[][] | undefined;
709
566
  /**
710
- * Scan a lock workflow's always-mode approval timeouts (workflow-level +
711
- * each static job) for a non-positive / non-finite `timeoutSeconds`. Returns the
712
- * first offender or null. Step-scope approvals ride the validated
713
- * `step.approval-request` wire schema and are not checked here.
567
+ * First workflow- or job-level approval with an invalid `timeoutSeconds`, or
568
+ * null. Step-scope approvals are validated by the `step.approval-request`
569
+ * wire schema instead.
714
570
  */
715
571
  export declare function findInvalidApprovalTimeout(workflow: LockWorkflow): {
716
572
  scope: 'workflow' | 'job';
@@ -718,30 +574,21 @@ export declare function findInvalidApprovalTimeout(workflow: LockWorkflow): {
718
574
  value: number;
719
575
  } | null;
720
576
  /**
721
- * Build the per-host secret-resolution context for a materialized child. A
722
- * `runsOnAll` host child carries its identity on `mat.agent` (preferred) or
723
- * `mat.pinnedAgentId`/`mat.host`; a non-host child (matrix/static) has none, so
724
- * resolution stays fleet-wide (`'**'`-only). Returns `undefined` when there are
725
- * no host facts to scope by.
577
+ * Per-host secret-resolution facts for a host child (`mat.agent` preferred,
578
+ * else `pinnedAgentId`/`host`). Undefined for a non-host child, whose
579
+ * resolution stays fleet-wide (`'**'`-only).
726
580
  */
727
581
  export declare function hostCtxFromMat(mat: MaterializedJob): HostFacts | undefined;
728
582
  /**
729
- * Key for the in-pass admission tally.
730
- *
731
- * The org id is part of the key so the tally inherits the cross-tenant scoping
732
- * the running-count query already enforces on `execution_runs.customer_id`: a
733
- * context name shared across tenants must not leak concurrency between them.
734
- * One dispatch pass carries a single `resolvedOrgId`, so the org component is a
735
- * standing invariant rather than a live discriminator — it is here so a future
736
- * pass dispatching for more than one org cannot silently merge two orgs'
737
- * tallies. `JSON.stringify` over the pair is used rather than string
738
- * concatenation so no separator character can make two different pairs collide.
583
+ * In-pass admission tally key. The org id mirrors the count query's
584
+ * `customer_id` scoping so a shared context name never leaks concurrency
585
+ * across tenants — a standing invariant, since one pass has one org.
586
+ * `JSON.stringify`, not concatenation, so no separator makes pairs collide.
739
587
  */
740
588
  export declare function concurrencyAdmissionKey(orgId: string, concurrencyGroup: string): string;
741
589
  /**
742
- * Phase D — evaluate static jobs' context data, queue deferred-init jobs
743
- * for jobs with dynamic fields, and pick the first `runContextName` for
744
- * the run.
590
+ * Phase D — evaluate static jobs' context data, queue deferred-init jobs for
591
+ * dynamic fields, and pick the run's `runContextName`.
745
592
  */
746
593
  export declare function evaluateJobContexts(args: {
747
594
  ctx: WorkflowDispatchContext;
@@ -749,24 +596,15 @@ export declare function evaluateJobContexts(args: {
749
596
  buildPrep: BuildPrepResult;
750
597
  }): Promise<JobEnvEvalResult>;
751
598
  /**
752
- * Refuse a Dockerfile build on an untrusted ref, unless the org opted in.
753
- *
754
- * A job may build its container image from a Dockerfile in the repository. That
755
- * build runs arbitrary `RUN` commands on the agent host's daemon, OUTSIDE the
756
- * hardened posture the job's own steps get — `docker build` cannot be
757
- * capability-restricted the way a container run can. So an untrusted ref (a fork
758
- * PR, an unresolved contributor, or an internally-triggered run without a
759
- * trusted emitter — the same classification the user-cache write scope uses)
760
- * reaches it only where the operator said so.
761
- *
762
- * "Without a trusted emitter" covers both halves of the internal case: a
763
- * `kiciEvent()` subscriber that inherited an `unknown` tier, and one
764
- * that inherited nothing at all (no emitting run, no persisted tier, a lookup
765
- * that failed) — the strict fallback, which is not an "untrusted emitter".
766
- *
767
- * Enforced here, at dispatch, and nowhere else: the agent applies only what
768
- * dispatch authorized, exactly as it does for the sandbox capability grant. Deny
769
- * is loud and total — the build never starts.
599
+ * Refuse a Dockerfile build on an untrusted ref unless the org opted in. The
600
+ * build runs arbitrary `RUN` commands on the host daemon, OUTSIDE the hardened
601
+ * posture (`docker build` cannot be capability-restricted). Untrusted = fork
602
+ * PR, unresolved contributor, or internal run without a trusted emitter (the
603
+ * user-cache write-scope classification) — including a `kiciEvent()`
604
+ * subscriber that inherited an `unknown` tier or nothing at all.
605
+ *
606
+ * Enforced only here, at dispatch; the agent applies what dispatch authorized,
607
+ * as for sandbox grants. Deny is loud and total.
770
608
  */
771
609
  export declare function resolveWorkflowDockerfileBuilds(workflow: LockWorkflow, opts: {
772
610
  scope: CacheRefScope;
@@ -778,55 +616,37 @@ export declare function resolveWorkflowDockerfileBuilds(workflow: LockWorkflow,
778
616
  reason: string;
779
617
  };
780
618
  };
781
- /**
782
- * Post the pending `KiCI Security` status, and record on every hold that gates
783
- * this commit's check that the commit now carries it.
784
- *
785
- * The record is what a settle reads to decide whether a hold has a check to
786
- * terminalize. Deriving that from the row's shape instead answers what the code
787
- * INTENDED, and `postCheckStatus` CREATES the named run when it finds none — so
788
- * a post the provider refused left a shape saying "posted" and a settle that
789
- * put a completed `KiCI Security` run on a commit which never had one.
790
- *
791
- * `heldRunIds` is plural because the commit carries ONE check run: a job held on
792
- * two independent requirements has both of them gating it, and marking only the
793
- * one whose summary was rendered would let the first to end resolve a check the
794
- * other is still gating.
795
- *
796
- * Awaited, where the post used to be fire-and-forget: the record can only be
797
- * written once the provider has accepted, and a record racing the settle is a
798
- * record the settle may not see. A failed post is still swallowed — the dispatch
799
- * loop is never blocked by a provider error — but the round-trip is now
800
- * serial and inside the per-job loop, so N held jobs cost N of them.
801
- *
802
- * On success and then a failed record the commit keeps a pending check the
803
- * settle will decline to close. That is the residue the fire-and-forget post
804
- * could already leave, now narrowed to whatever can fail between the accepted
805
- * post and ONE statement. The record is therefore retried
806
- * {@link PENDING_CHECK_MARK_ATTEMPTS} times before it is given up on, which
807
- * closes the half of that window the doc above names as reachable without a
808
- * process dying — a lost connection, a statement timeout, a deadlock. What is
809
- * left is a process death inside the retry window, and nothing in reach closes
810
- * that: a sweeper would have to ask the provider whether the check exists, and
811
- * `CheckStatusPoster` has no read method. Adding one means a new method on a
812
- * compat-protected engine interface, every implementation and every hand-built
813
- * bundle, to recover a window measured in milliseconds — against a recovery
814
- * that already exists, since pushing a new commit re-posts. A sweeper without
815
- * that read could only guess, and a wrong guess FABRICATES a check, which is
816
- * the worse direction either way: a fabricated failing check on a pull request
817
- * is worse than a stuck one.
818
- *
819
- * The record is one statement over every id, never one per id. A partial mark
820
- * would leave an unmarked hold uncounted by the contention query, so the first
821
- * hold to end would terminalize the shared check while the other still gates
822
- * the job — a fabricated PASSING check, the worse direction, and reachable
823
- * without any process dying. See `markPendingCheckPosted`.
824
- */
825
619
  /**
826
620
  * How many times {@link postPendingHoldCheck} tries to record an accepted post
827
621
  * on the hold rows before giving up and leaving the check unclosable.
828
622
  */
829
623
  export declare const PENDING_CHECK_MARK_ATTEMPTS = 3;
624
+ /**
625
+ * Post the pending `KiCI Security` status, then record on every hold gating
626
+ * this commit's check that the commit carries it.
627
+ *
628
+ * A settle reads the record, not the row's shape, to decide whether there is a
629
+ * check to terminalize: `postCheckStatus` CREATES a missing run, so a shape
630
+ * saying "posted" after a refused post put a completed check on a commit that
631
+ * never had one.
632
+ *
633
+ * `heldRunIds` is plural because the commit carries ONE check run: with two
634
+ * requirements gating a job, marking one lets the first to end resolve a check
635
+ * the other still gates. Marked in one statement, never per id — a partial
636
+ * mark lets the contention query miss a hold and fabricate a PASSING check
637
+ * (`markPendingCheckPosted`).
638
+ *
639
+ * Awaited so the record lands before a settle can race it; a failed post is
640
+ * swallowed so the dispatch loop never blocks, at one serial round-trip per
641
+ * held job.
642
+ *
643
+ * A failed record after a successful post leaves a pending check no settle
644
+ * closes; retried {@link PENDING_CHECK_MARK_ATTEMPTS} times to cover a lost
645
+ * connection, statement timeout or deadlock. A process death mid-retry stays
646
+ * open: a sweeper would need a read on `CheckStatusPoster`, a compat-protected
647
+ * engine interface, to recover milliseconds that a new commit already
648
+ * recovers — and guessing FABRICATES checks, worse than a stuck one.
649
+ */
830
650
  export declare function postPendingHoldCheck(args: {
831
651
  poster: NonNullable<NonNullable<WorkflowDispatchContext['bundle']>['checkStatusPoster']>;
832
652
  store: NonNullable<ProcessingDeps['heldRunStore']>;
@@ -842,34 +662,15 @@ export declare function postPendingHoldCheck(args: {
842
662
  postFailureMessage: string;
843
663
  }): Promise<void>;
844
664
  /**
845
- * Open the needs gate for any job whose upstreams already reached terminal
846
- * before this run's edges existed.
847
- *
848
- * **The race this closes.** Root jobs are dispatched to agents inside the
849
- * dispatch loop, but `execution_job_needs` is only written afterwards, here. An
850
- * agent that reports a root job terminal in that window drives
851
- * `evaluateDownstreams`, which reads zero edges, returns an empty result, and
852
- * the gate never fires again — the downstream stays `pending` forever and the
853
- * run hangs with no error anywhere. Nothing re-evaluates on its own: the
854
- * scheduler is purely event-driven off job completion, and that event has
855
- * already been consumed.
856
- *
857
- * The window is small (single-digit milliseconds) but entirely reachable: a job
858
- * that fails immediately on arrival — a rejected dispatch, an init failure, a
859
- * capability mismatch — reports terminal in about the time one DB write takes.
860
- * It was invisible for as long as the webhook route answered only after the
861
- * whole pipeline had run, because the caller could not learn a job had been
862
- * dispatched until every edge was already committed.
863
- *
864
- * Recomputing here is the same guard the deferred result-aware eval registration
865
- * already applies for its own edges, and it is safe to run unconditionally: the
866
- * claim inside `recomputeNeedsSatisfied` is a conditional UPDATE, so a job the
867
- * normal completion path already claimed is skipped rather than dispatched
868
- * twice.
869
- *
870
- * Wave-held jobs share the synthetic-id prefix but are gated by the rolling-wave
871
- * scheduler, not by needs, so they are excluded — opening their gate here would
872
- * bypass the `maxParallel` window.
665
+ * Open the needs gate for jobs whose upstreams went terminal before the edges
666
+ * existed. Edges are written after the loop; a root job terminal on arrival
667
+ * drives `evaluateDownstreams` against zero edges, and the event-driven
668
+ * scheduler never re-fires, so the downstream stays `pending` forever.
669
+ *
670
+ * The same guard the deferred result-aware eval registration applies for its own
671
+ * edges. Safe unconditionally: `recomputeNeedsSatisfied` claims with a conditional
672
+ * UPDATE, so an already-claimed job is not dispatched twice. Wave-held jobs
673
+ * share the prefix but are excluded, or the `maxParallel` window is bypassed.
873
674
  */
874
675
  export declare function catchUpNeedsGatedJobs(args: {
875
676
  ctx: NeedsSchedulingContext;
@@ -889,40 +690,25 @@ export declare enum InitDispatchSuppression {
889
690
  Gated = "gated"
890
691
  }
891
692
  /**
892
- * Decide whether an arrived init result may dispatch its job.
693
+ * Whether an arrived init result may dispatch its job.
893
694
  *
894
- * `Paths` is checked first: a workflow whose deferred `paths` did not match
895
- * never triggered, whatever its filter says. Only an explicit `false`
896
- * suppresses — an agent that predates deferred paths reports no verdict, and
897
- * that absence dispatches.
695
+ * `Paths` first: unmatched deferred `paths` never triggered, whatever the
696
+ * filter says. Only an explicit `false` suppresses; an older agent's missing
697
+ * verdict dispatches.
898
698
  *
899
- * `Filter` requires the workflow to actually declare a filter as well as the
900
- * agent to have reported `false`: a buggy or rogue agent must not be able to
901
- * suppress a filter-less workflow by inventing the field, and an agent that
902
- * predates the filter reports no verdict at all — reading that absence as
903
- * "suppress" would silently stop every dispatch it handles.
699
+ * `Filter` needs both a declared filter and a reported `false`: a rogue agent
700
+ * cannot suppress a filter-less workflow, and an older agent's missing verdict
701
+ * must not stop every dispatch.
904
702
  *
905
- * `Gated` covers a job that is already rejected or held. Its two halves now have
906
- * very different reachability, and saying so is the point of this paragraph:
703
+ * `Gated`: **rejected** is load-bearing — the flow-back's
704
+ * `suppression === Gated && jobEnvData.rejected` branch stops it. **held** is
705
+ * NOT consumed here: a held job gets its init round (only it resolves dynamic
706
+ * values) and the flow-back routes it to `holdExecutionAfterInit`. The no-
707
+ * dispatch guarantee for a held job lives at the call site's `held` branch,
708
+ * `dispatchReadyJob`'s pending-hold check, and the cluster path's
709
+ * `holdJobForApproval`.
907
710
  *
908
- * - **rejected** is live and load-bearing. The flow-back consumes it (that is
909
- * the `suppression === Gated && jobEnvData.rejected` branch) to stop a job its
910
- * context rules rejected from dispatching.
911
- * - **held** is NOT consumed here any more. A held job deliberately DOES get an
912
- * init job — nothing else can resolve a dynamic value, so suppressing the
913
- * round would make the job undispatchable rather than merely gated. The
914
- * flow-back handles it after resolution instead, routing it to
915
- * `holdExecutionAfterInit` so the hold and its resolved dispatch context are
916
- * stored together.
917
- *
918
- * So do not read this as a guarantee that a held job cannot dispatch: that
919
- * guarantee lives at the call site's `jobEnvData.held` branch, and — for the
920
- * needs-scheduler and cluster paths, which reach a job by other routes — in
921
- * `dispatchReadyJob`'s pending-hold check and the cluster path's own
922
- * `holdJobForApproval` call.
923
- *
924
- * Exported for its own test: inline, the second branch could not be exercised at
925
- * all, and an untestable security check is one nobody can prove still works.
711
+ * Exported so the security check is testable.
926
712
  */
927
713
  export declare function initDispatchSuppression(workflow: Pick<LockWorkflow, 'hasFilter'>, initResult: {
928
714
  filterPassed?: boolean;
@@ -930,43 +716,34 @@ export declare function initDispatchSuppression(workflow: Pick<LockWorkflow, 'ha
930
716
  }, jobEnvData: Pick<JobEnvData, 'rejected' | 'held'>): InitDispatchSuppression | null;
931
717
  export interface GeneratedJobConfig {
932
718
  /**
933
- * The generated lock job with its `name` and `needs` rewritten to expanded
934
- * matrix-child names (identical to the base job for non-matrix generated
935
- * jobs). Downstream dispatch / needs-edge / tracking code keys on this name.
719
+ * `name` and `needs` rewritten to expanded matrix-child names; dispatch,
720
+ * needs edges and tracking key on this name.
936
721
  */
937
722
  genJob: LockJob;
938
723
  genJobConfig: Record<string, unknown>;
939
724
  runsOnLabels: string[];
940
- /** Regex matchers the agent's labels must satisfy (JS post-filter). */
725
+ /** JS post-filter. */
941
726
  runsOnPatterns: LabelMatcher[];
942
- /** Exact labels the dispatched agent must NOT have. */
943
727
  excludeLabels: string[];
944
- /** Regex matchers that disqualify an agent (JS post-filter). */
728
+ /** JS post-filter. */
945
729
  excludePatterns: LabelMatcher[];
946
- /** Host-fanout pin: when runsOn resolved to a roster host, route only to it. */
730
+ /** Set when runsOn resolved to a roster host. */
947
731
  pinnedAgentId?: string;
948
- /** The host's current coordinator (cross-cluster reroute hint); null = not connected. */
732
+ /** Cross-cluster reroute hint; null = not connected. */
949
733
  connectedInstanceId?: string | null;
950
- /** The matrix combination for this child; absent for non-matrix generated jobs. */
951
734
  matrixValues?: Record<string, unknown>;
952
735
  /**
953
- * The `gitCredentials` map the generator's LOCK entry declared, inherited by
954
- * this child. Persisted to `execution_jobs.git_credentials` at every dispatch
955
- * site below, which is what the credential relay authorizes a request against.
736
+ * Inherited from the generator's LOCK entry; persisted to
737
+ * `execution_jobs.git_credentials` at every dispatch site for the relay.
956
738
  */
957
739
  gitCredentials?: Readonly<Record<string, Readonly<Record<string, string>>>>;
958
- /**
959
- * What a later dispatch resolves the job's context data from, when the job
960
- * binds a context. A generated job stored as a pending dispatch context
961
- * carries no context data at rest.
962
- */
740
+ /** Context-data source for a later dispatch; no context data rests in storage. */
963
741
  contextResolution?: DeferredContextResolution;
964
742
  }
965
743
  /**
966
- * Split generated configs into pinned (host-pin dispatch) and unpinned (normal
967
- * label routing). A pinned config always rides the dispatcher pin path because
968
- * the coordinator's `JobToRoute` shape carries no pin field — routing it via the
969
- * coordinator would silently drop the pin.
744
+ * Split generated configs into pinned and unpinned. Pinned always use the
745
+ * dispatcher pin path: `JobToRoute` has no pin field, so the coordinator would
746
+ * silently drop it.
970
747
  */
971
748
  export declare function partitionGeneratedConfigsByPin(configs: readonly GeneratedJobConfig[]): {
972
749
  pinnedConfigs: GeneratedJobConfig[];
@@ -982,42 +759,33 @@ interface ResolveGeneratedJobConfigsArgs {
982
759
  installEnvSecrets: Record<string, string> | undefined;
983
760
  generatedJobs: LockJob[];
984
761
  dynamicEntry: BuildPrepResult['dynamicEntries'][number];
985
- /** Frozen upstream snapshot threaded into each generated job's dynamicSource for re-eval. */
762
+ /** Threaded into each job's dynamicSource for re-eval. */
986
763
  upstreamSnapshot?: UpstreamSnapshot;
987
764
  }
988
- /** A generated job its contexts' protection gates held, with the hold they decided. */
765
+ /** A generated job its contexts' gates held. */
989
766
  export interface HeldGeneratedJob {
990
767
  config: GeneratedJobConfig;
991
768
  envData: JobEnvData;
992
769
  }
993
770
  /**
994
- * The generated jobs split by their context gate verdict. A job the gates
995
- * rejected, or whose resolution threw, appears in neither list: it is recorded
996
- * on the run as failed.
771
+ * Generated jobs by gate verdict. Rejected or thrown jobs are in neither list;
772
+ * they are recorded on the run as failed.
997
773
  */
998
774
  export interface GeneratedJobResolution {
999
- /** Jobs cleared to dispatch, carrying their resolved context data. */
775
+ /** Carrying their resolved context data. */
1000
776
  dispatchable: GeneratedJobConfig[];
1001
- /** Jobs to hold; their context secrets are not resolved. */
777
+ /** Context secrets not resolved. */
1002
778
  held: HeldGeneratedJob[];
1003
779
  }
1004
780
  /**
1005
- * Gate each generated job on its bound contexts and build the job configs.
1006
- *
1007
- * A job the context rules reject is recorded on the run as failed and returned
1008
- * in neither list. A job whose resolution throws is recorded on the run as
1009
- * failed too, and dropped from both lists.
781
+ * Gate each generated job and build its config. Rejected or thrown jobs are
782
+ * recorded on the run as failed and returned in neither list.
1010
783
  */
1011
784
  export declare function resolveGeneratedJobConfigs(args: ResolveGeneratedJobConfigsArgs): Promise<GeneratedJobResolution>;
1012
785
  /**
1013
- * Recompute the needs gate for `jobNames` and act on whatever became ready:
1014
- * open the gate for a satisfied job, terminalize a job an upstream's status
1015
- * excluded.
1016
- *
1017
- * `recomputeNeedsSatisfied` claims each job with a conditional
1018
- * `needs_satisfied = false → true` UPDATE, so a job a concurrent
1019
- * `evaluateDownstreams` already claimed is not returned here and cannot be
1020
- * dispatched twice.
786
+ * Recompute the needs gate for `jobNames`: open satisfied jobs, terminalize
787
+ * excluded ones. The conditional `needs_satisfied = false → true` claim means
788
+ * a job a concurrent `evaluateDownstreams` claimed is never dispatched twice.
1021
789
  */
1022
790
  export declare function recomputeAndApplyReady(ctx: NeedsSchedulingContext, jobNames: readonly string[]): Promise<void>;
1023
791
  export { gatherInvokeResults };
@@ -1041,11 +809,7 @@ export declare function buildSecurityHoldData(runId: string, decision: Extract<T
1041
809
  triggerSource: "context";
1042
810
  };
1043
811
  /**
1044
- * Dispatch a single matched workflow.
1045
- *
1046
- * Narrative orchestrator: each phase is a typed helper that returns a typed
1047
- * result the next phase consumes. The function reads top-to-bottom as the
1048
- * pipeline:
812
+ * Dispatch a single matched workflow, phase by phase:
1049
813
  * A. setup → wrapped dispatcher + overlaid info
1050
814
  * B. cache + build → buildPrep with cache URLs and build-job state
1051
815
  * C. workflow secrets + ephemeral key → secret bundle