@kici-dev/orchestrator 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent-version.d.ts +12 -21
- package/dist/agent/dispatcher.d.ts +283 -437
- package/dist/agent/host-roster-reaper.d.ts +8 -10
- package/dist/agent/host-roster.d.ts +77 -100
- package/dist/agent/ownership-refusal.d.ts +3 -5
- package/dist/agent/ownership-tracker.d.ts +42 -76
- package/dist/agent/registry.d.ts +137 -230
- package/dist/agent/token-store.d.ts +34 -77
- package/dist/agent-packaging/availability.d.ts +6 -9
- package/dist/agent-packaging/download.d.ts +6 -9
- package/dist/agent-packaging/install-closure.d.ts +9 -12
- package/dist/agent-packaging/node-binary.d.ts +6 -10
- package/dist/agent-packaging/node-runtime-members.d.ts +3 -5
- package/dist/agent-packaging/refresh.d.ts +12 -16
- package/dist/agent-packaging/store.d.ts +5 -6
- package/dist/agent-packaging/upload.d.ts +3 -4
- package/dist/app.d.ts +0 -3
- package/dist/approvals/apply-decision.d.ts +35 -52
- package/dist/approvals/approval-resolver.d.ts +11 -23
- package/dist/approvals/held-run-release-wiring.d.ts +14 -21
- package/dist/approvals/independent-wiring.d.ts +13 -20
- package/dist/approvals/resume-router.d.ts +1 -1
- package/dist/approvals/step-approval-bridge.d.ts +11 -21
- package/dist/approvals/triggerer-subject.d.ts +8 -10
- package/dist/artifacts/artifact-store.d.ts +55 -95
- package/dist/artifacts/failure-messages.d.ts +15 -20
- package/dist/audit/access-log.d.ts +27 -45
- package/dist/audit/sampling-rate-limiter.d.ts +11 -23
- package/dist/cache/agent-job-failed-error.d.ts +2 -3
- package/dist/cache/build-coordinator.d.ts +5 -28
- package/dist/cache/cache-upload-settle.d.ts +11 -11
- package/dist/cache/dep-cache.d.ts +32 -60
- package/dist/cache/dispatch-cache-ref-tracker.d.ts +15 -23
- package/dist/cache/global-eval-round-cache.d.ts +33 -41
- package/dist/cache/pending-builds.d.ts +2 -6
- package/dist/cache/pending-dynamics.d.ts +2 -7
- package/dist/cache/pending-global-evals.d.ts +9 -12
- package/dist/cache/pending-inits.d.ts +11 -22
- package/dist/cache/pending-precursor-db-watcher.d.ts +24 -32
- package/dist/cache/pending-tracker.d.ts +17 -45
- package/dist/cache/precursor-result.d.ts +17 -30
- package/dist/cache/source-cache.d.ts +36 -65
- package/dist/cache/user-cache.d.ts +21 -25
- package/dist/cancel/cancel-held-run.d.ts +13 -16
- package/dist/cancel/cancel-route-answer.d.ts +1 -2
- package/dist/cancel/cancel-run.d.ts +26 -50
- package/dist/cancel/dashboard-cancel-handler.d.ts +2 -2
- package/dist/cancel/peer-job-cancel.d.ts +11 -14
- package/dist/cancel/sweep-stuck-cancelling.d.ts +9 -13
- package/dist/cli/api-client.d.ts +25 -76
- package/dist/cli/commands/access-log.d.ts +4 -24
- package/dist/cli/commands/agent-package.d.ts +7 -15
- package/dist/cli/commands/agent-service/agent-env.d.ts +3 -6
- package/dist/cli/commands/agent-service/index.d.ts +4 -10
- package/dist/cli/commands/agent-service/install.d.ts +4 -11
- package/dist/cli/commands/agent-service/status.d.ts +4 -9
- package/dist/cli/commands/agent-service/upgrade.d.ts +4 -16
- package/dist/cli/commands/agent.d.ts +12 -25
- package/dist/cli/commands/api-key.d.ts +5 -12
- package/dist/cli/commands/attestations-list.d.ts +7 -17
- package/dist/cli/commands/attestations-retry.d.ts +5 -11
- package/dist/cli/commands/attestations-reverify.d.ts +4 -5
- package/dist/cli/commands/attestations.d.ts +3 -8
- package/dist/cli/commands/audit.d.ts +1 -5
- package/dist/cli/commands/backend.d.ts +2 -11
- package/dist/cli/commands/check-run.d.ts +7 -18
- package/dist/cli/commands/cluster-name.d.ts +5 -12
- package/dist/cli/commands/cluster-settings.d.ts +28 -53
- package/dist/cli/commands/cold-store.d.ts +7 -15
- package/dist/cli/commands/config.d.ts +9 -20
- package/dist/cli/commands/context.d.ts +8 -20
- package/dist/cli/commands/dashboard-encryption-key.d.ts +9 -14
- package/dist/cli/commands/db-backup.d.ts +17 -32
- package/dist/cli/commands/db.d.ts +3 -4
- package/dist/cli/commands/debug-bundle.d.ts +3 -10
- package/dist/cli/commands/diagnose.d.ts +3 -14
- package/dist/cli/commands/event-dlq.d.ts +4 -12
- package/dist/cli/commands/event-log.d.ts +2 -20
- package/dist/cli/commands/execution.d.ts +3 -9
- package/dist/cli/commands/firecracker/index.d.ts +3 -6
- package/dist/cli/commands/held-run.d.ts +23 -37
- package/dist/cli/commands/host.d.ts +4 -11
- package/dist/cli/commands/inspect-bundle.d.ts +3 -11
- package/dist/cli/commands/local-hook.d.ts +2 -10
- package/dist/cli/commands/local-trigger.d.ts +2 -2
- package/dist/cli/commands/orchestrator-service/drain.d.ts +3 -6
- package/dist/cli/commands/orchestrator-service/index.d.ts +6 -14
- package/dist/cli/commands/orchestrator-service/install-env.d.ts +25 -49
- package/dist/cli/commands/orchestrator-service/install.d.ts +2 -5
- package/dist/cli/commands/orchestrator-service/status.d.ts +10 -22
- package/dist/cli/commands/orchestrator-service/upgrade.d.ts +6 -15
- package/dist/cli/commands/org-settings.d.ts +5 -11
- package/dist/cli/commands/peer.d.ts +5 -10
- package/dist/cli/commands/queue.d.ts +3 -9
- package/dist/cli/commands/registration.d.ts +4 -8
- package/dist/cli/commands/remote-source.d.ts +6 -12
- package/dist/cli/commands/rotate.d.ts +1 -5
- package/dist/cli/commands/runs.d.ts +1 -30
- package/dist/cli/commands/scaler.d.ts +5 -12
- package/dist/cli/commands/secret.d.ts +1 -9
- package/dist/cli/commands/service-health.d.ts +5 -10
- package/dist/cli/commands/shared/admin-cli-access-log.d.ts +10 -19
- package/dist/cli/commands/shared/bare-metal-binary-check.d.ts +86 -0
- package/dist/cli/commands/shared/cli-action.d.ts +1 -4
- package/dist/cli/commands/shared/confirm.d.ts +5 -10
- package/dist/cli/commands/shared/db.d.ts +1 -12
- package/dist/cli/commands/shared/env-file-mode.d.ts +6 -9
- package/dist/cli/commands/shared/secret-input.d.ts +7 -21
- package/dist/cli/commands/shared/service-verbs.d.ts +6 -12
- package/dist/cli/commands/shared/unbound-context-warning.d.ts +2 -4
- package/dist/cli/commands/shared/upgrade-hooks.d.ts +7 -16
- package/dist/cli/commands/shared/upgrade-safety.d.ts +20 -31
- package/dist/cli/commands/shared/versioned-upgrade.d.ts +83 -161
- package/dist/cli/commands/signing-key.d.ts +4 -9
- package/dist/cli/commands/source-manifest.d.ts +11 -14
- package/dist/cli/commands/source.d.ts +7 -32
- package/dist/cli/commands/token.d.ts +4 -15
- package/dist/cli/commands/trust-policy.d.ts +35 -88
- package/dist/cli/commands/variable.d.ts +3 -5
- package/dist/cli/commands/workflow.d.ts +3 -24
- package/dist/cli/join.d.ts +3 -6
- package/dist/cli/kici-admin.d.ts +11 -29
- package/dist/cli/lazy-deps/cache.d.ts +1 -14
- package/dist/cli/lazy-deps/downloader.d.ts +4 -27
- package/dist/cli/lazy-deps/registry.d.ts +5 -25
- package/dist/cli/local-github-ingress-url.d.ts +5 -7
- package/dist/cli/loopback-callback.d.ts +6 -7
- package/dist/cli/open-browser.d.ts +4 -8
- package/dist/cli/root-option-routing.d.ts +17 -29
- package/dist/cli/service/backup-timer.d.ts +16 -39
- package/dist/cli/service/compose-path.d.ts +3 -7
- package/dist/cli/service/compose.d.ts +12 -30
- package/dist/cli/service/deploy-env.d.ts +6 -18
- package/dist/cli/service/entrypoint.d.ts +14 -25
- package/dist/cli/service/env-assignment.d.ts +6 -17
- package/dist/cli/service/image-digests.d.ts +6 -15
- package/dist/cli/service/index.d.ts +2 -18
- package/dist/cli/service/instance/index-file.d.ts +9 -16
- package/dist/cli/service/instance/manifest.d.ts +60 -60
- package/dist/cli/service/instance/resolve.d.ts +32 -68
- package/dist/cli/service/instance/types.d.ts +12 -29
- package/dist/cli/service/launchd.d.ts +29 -60
- package/dist/cli/service/platform-detect.d.ts +13 -68
- package/dist/cli/service/privilege.d.ts +12 -25
- package/dist/cli/service/shutdown-grace.d.ts +11 -20
- package/dist/cli/service/systemd.d.ts +7 -20
- package/dist/cli/service/types.d.ts +63 -114
- package/dist/cli/service/windows-acl.d.ts +14 -21
- package/dist/cli/service/windows-env-file.d.ts +10 -28
- package/dist/cli/service/windows.d.ts +15 -31
- package/dist/cli/webhook-url-notes.d.ts +4 -6
- package/dist/cli/wizard/agent-wizard.d.ts +3 -14
- package/dist/cli/wizard/orchestrator-wizard.d.ts +12 -37
- package/dist/cli/wizard/prompts.d.ts +6 -16
- package/dist/cli.js +8207 -10128
- package/dist/cluster/cluster-identity.d.ts +20 -32
- package/dist/cluster/cluster-settings-reader.d.ts +50 -77
- package/dist/cluster/coordinator-credential.d.ts +4 -5
- package/dist/cluster/coordinator.d.ts +76 -148
- package/dist/cluster/health-api.d.ts +2 -10
- package/dist/cluster/index.d.ts +1 -6
- package/dist/cluster/instance-heartbeat.d.ts +26 -42
- package/dist/cluster/join-client.d.ts +4 -7
- package/dist/cluster/join-handler.d.ts +3 -7
- package/dist/cluster/join-token.d.ts +13 -27
- package/dist/cluster/leader-gated-scheduler.d.ts +8 -17
- package/dist/cluster/orphan-recovery.d.ts +13 -35
- package/dist/cluster/peer-auth-coordinator.d.ts +2 -8
- package/dist/cluster/peer-client.d.ts +46 -76
- package/dist/cluster/peer-credentials.d.ts +24 -70
- package/dist/cluster/peer-crypto.d.ts +5 -26
- package/dist/cluster/peer-forget.d.ts +3 -3
- package/dist/cluster/peer-handler.d.ts +47 -71
- package/dist/cluster/peer-registry.d.ts +37 -106
- package/dist/cluster/plan-headroom-store.d.ts +4 -6
- package/dist/cluster/raft-state.d.ts +4 -13
- package/dist/cluster/raft.d.ts +18 -53
- package/dist/cluster/reconcile-identity.d.ts +8 -11
- package/dist/cluster/rerouted-job-guard.d.ts +7 -11
- package/dist/cluster/verified-issuer.d.ts +2 -3
- package/dist/cluster/worker-cluster-settings.d.ts +7 -10
- package/dist/cluster/worker-eviction.d.ts +16 -26
- package/dist/cold-store/load-access-log-range.d.ts +15 -31
- package/dist/cold-store/load-event-log-range.d.ts +13 -27
- package/dist/cold-store/load-secret-audit-log-range.d.ts +8 -12
- package/dist/cold-store/orchestrator-cold-store.d.ts +8 -28
- package/dist/cold-store/tables/access-log.d.ts +12 -14
- package/dist/cold-store/tables/event-log.d.ts +4 -8
- package/dist/cold-store/tables/execution-runs.d.ts +6 -11
- package/dist/cold-store/tables/secret-audit-log.d.ts +5 -12
- package/dist/concurrency/dispatch-next-queued.d.ts +13 -25
- package/dist/concurrency/queue-manager.d.ts +22 -54
- package/dist/concurrency/waiters.d.ts +15 -31
- package/dist/config/encryption.d.ts +0 -2
- package/dist/config/loader.d.ts +0 -1
- package/dist/config/reload.d.ts +0 -6
- package/dist/config/resolver.d.ts +0 -4
- package/dist/config/shared-store.d.ts +0 -2
- package/dist/config/types.d.ts +0 -3
- package/dist/content-requirements-cache.d.ts +0 -1
- package/dist/contexts/context-store.d.ts +0 -2
- package/dist/contexts/held-runs.d.ts +0 -2
- package/dist/contexts/variable-store.d.ts +0 -2
- package/dist/dashboard/attestation-filters.d.ts +13 -18
- package/dist/dashboard/handler.d.ts +145 -307
- package/dist/db/client.d.ts +2 -6
- package/dist/db/deferred-index-build.d.ts +8 -10
- package/dist/db/deferred-indexes.d.ts +15 -22
- package/dist/db/migration-provider.d.ts +2 -4
- package/dist/db/migration-test-harness.d.ts +26 -44
- package/dist/db/migrations/001_initial.d.ts +1 -4
- package/dist/db/migrations/002_config_versions_key_version.d.ts +5 -8
- package/dist/db/migrations/003_access_log.d.ts +10 -15
- package/dist/db/migrations/004_rename_bundle_to_source.d.ts +7 -9
- package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +4 -10
- package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +9 -29
- package/dist/db/migrations/007_audit_logs_archived_at.d.ts +11 -30
- package/dist/db/migrations/008_event_log_archived_at.d.ts +14 -29
- package/dist/db/migrations/009_access_log_trigram.d.ts +4 -8
- package/dist/db/migrations/010_cold_store_chunks.d.ts +16 -26
- package/dist/db/migrations/011_drop_source_secrets_notify.d.ts +6 -14
- package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +9 -14
- package/dist/db/migrations/013_execution_log_bytes.d.ts +5 -13
- package/dist/db/migrations/014_kici_events_lease_retry.d.ts +14 -27
- package/dist/db/migrations/015_org_settings_customer_scoped.d.ts +12 -17
- package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +4 -6
- package/dist/db/migrations/019_generic_sources_change_notify.d.ts +13 -17
- package/dist/db/migrations/020_org_settings_dashboard_write_policy.d.ts +5 -8
- package/dist/db/migrations/021_check_run_tracking.d.ts +5 -17
- package/dist/db/migrations/022_scaler_manager_state.d.ts +10 -20
- package/dist/db/migrations/023_dispatch_queue_recovery_deadline.d.ts +7 -18
- package/dist/db/migrations/024_dispatch_queue_provisioning_error.d.ts +5 -11
- package/dist/db/migrations/025_init_failure.d.ts +5 -9
- package/dist/db/migrations/027_workflow_timeout.d.ts +5 -13
- package/dist/db/migrations/029_dispatch_queue_attempts.d.ts +4 -10
- package/dist/db/migrations/030_held_runs_env_set_null.d.ts +5 -6
- package/dist/db/migrations/031_dispatch_queue_ack_deadline.d.ts +6 -12
- package/dist/db/migrations/033_org_settings_approval.d.ts +7 -10
- package/dist/db/migrations/034_held_runs_generalize.d.ts +10 -18
- package/dist/db/migrations/035_pending_workflow_contexts.d.ts +4 -5
- package/dist/db/migrations/037_generic_sources_provider_type_local.d.ts +5 -6
- package/dist/db/migrations/038_remote_sources.d.ts +5 -7
- package/dist/db/migrations/045_host_properties.d.ts +5 -9
- package/dist/db/migrations/046_join_token_consumed_by_instance.d.ts +5 -10
- package/dist/db/migrations/048_host_reboot_pending.d.ts +6 -12
- package/dist/db/migrations/049_held_runs_payload.d.ts +3 -8
- package/dist/db/migrations/050_sources_slug.d.ts +4 -5
- package/dist/db/migrations/051_binding_host_pattern.d.ts +7 -10
- package/dist/db/migrations/052_host_reach_metadata.d.ts +8 -11
- package/dist/db/migrations/053_agent_token_single_use.d.ts +6 -10
- package/dist/db/migrations/054_local_working_tree.d.ts +4 -6
- package/dist/db/migrations/055_agent_token_mandatory_labels.d.ts +6 -11
- package/dist/db/migrations/056_execution_jobs_environments.d.ts +4 -11
- package/dist/db/migrations/064_execution_jobs_skipped_environments.d.ts +6 -9
- package/dist/db/migrations/065_pending_attestations.d.ts +9 -12
- package/dist/db/migrations/066_pending_attestations_rejected.d.ts +4 -7
- package/dist/db/migrations/068_request_idempotency.d.ts +7 -9
- package/dist/db/migrations/069_reroute_tunables.d.ts +6 -14
- package/dist/db/migrations/071_batch_accumulation.d.ts +8 -16
- package/dist/db/migrations/072_dispatch_queue_run_id_index.d.ts +3 -9
- package/dist/db/migrations/074_normalize_zero_concurrency_limit.d.ts +4 -7
- package/dist/db/migrations/076_artifacts.d.ts +7 -8
- package/dist/db/migrations/078_org_settings_backup_staleness.d.ts +3 -6
- package/dist/db/migrations/079_org_settings_scaler_spawn_timeout.d.ts +4 -8
- package/dist/db/migrations/080_cluster_settings.d.ts +6 -10
- package/dist/db/migrations/081_org_settings_queue_timeout.d.ts +7 -11
- package/dist/db/migrations/082_host_s3_reachable.d.ts +5 -10
- package/dist/db/migrations/083_org_settings_artifact_caps.d.ts +6 -8
- package/dist/db/migrations/084_orchestrator_signing_keys.d.ts +8 -13
- package/dist/db/migrations/085_cluster_settings_reroute_flap_grace_ms.d.ts +4 -5
- package/dist/db/migrations/086_cluster_settings_max_fanout_hosts.d.ts +3 -3
- package/dist/db/migrations/087_cluster_settings_event_router_rate_limit.d.ts +5 -3
- package/dist/db/migrations/088_cluster_settings_cache_max_tarball_bytes.d.ts +3 -3
- package/dist/db/migrations/089_cluster_settings_cache_ttl_days.d.ts +3 -5
- package/dist/db/migrations/090_cluster_settings_concurrency_wait_timeout_ms.d.ts +3 -6
- package/dist/db/migrations/091_cluster_settings_agent_token_ttl_ms.d.ts +3 -6
- package/dist/db/migrations/092_cluster_settings_version.d.ts +5 -9
- package/dist/db/migrations/094_dashboard_encryption_keys.d.ts +9 -14
- package/dist/db/migrations/095_dashboard_write_policy_tristate.d.ts +2 -6
- package/dist/db/migrations/099_cluster_settings_dashboard_verified_issuer.d.ts +8 -11
- package/dist/db/migrations/101_contexts_hold_expiry_drop_default.d.ts +9 -15
- package/dist/db/migrations/102_dispatch_queue_agent_id.d.ts +6 -11
- package/dist/db/migrations/103_cluster_settings_ownership_db_check_timeout_ms.d.ts +6 -12
- package/dist/db/migrations/104_check_run_terminal_sent.d.ts +8 -14
- package/dist/db/migrations/105_org_trust_policy.d.ts +5 -7
- package/dist/db/migrations/106_cluster_settings_check_run_tracking_ttl_days.d.ts +4 -12
- package/dist/db/migrations/107_check_run_tracking_updated_at_index.d.ts +8 -14
- package/dist/db/migrations/113_execution_runs_workflow_repo_index.d.ts +10 -19
- package/dist/db/migrations/115_global_workflows_cluster_switch.d.ts +2 -3
- package/dist/db/migrations/121_org_settings_allow_untrusted_dockerfile_builds.d.ts +7 -8
- package/dist/db/migrations/122_host_roster_scaler_managed.d.ts +9 -16
- package/dist/db/migrations/123_workflow_registrations_default_branch.d.ts +8 -16
- package/dist/db/migrations/125_org_trust_directory.d.ts +13 -21
- package/dist/db/migrations/126_held_runs_posted_pending_check.d.ts +10 -16
- package/dist/db/migrations/127_org_trust_policy_approval_expiry_seconds.d.ts +8 -16
- package/dist/db/migrations/128_execution_runs_global_eval_round.d.ts +6 -11
- package/dist/db/migrations/129_execution_runs_dispatch_routing_key.d.ts +8 -11
- package/dist/db/migrations/130_scaler_provision_outcomes.d.ts +13 -20
- package/dist/db/migrations/131_execution_jobs_git_credentials.d.ts +12 -22
- package/dist/db/migrations/132_execution_runs_trigger_event.d.ts +6 -16
- package/dist/db/migrations/133_dispatch_queue_source_tar_digest.d.ts +6 -9
- package/dist/db/migrations/140_dispatch_queue_canonical_labels.d.ts +22 -40
- package/dist/db/migrations/143_execution_jobs_precursor_result.d.ts +9 -18
- package/dist/db/migrations/144_execution_runs_registration_window.d.ts +12 -20
- package/dist/db/migrations/147_sealed_job_secrets.d.ts +5 -9
- package/dist/db/migrations/148_cluster_settings_sealed_secrets_retry_backoff_ms.d.ts +7 -13
- package/dist/db/migrations/150_execution_runs_status_epoch.d.ts +6 -11
- package/dist/db/migrations/152_org_settings_cache_upload_settle_timeout.d.ts +5 -8
- package/dist/db/migrations/157_host_roster_identity_source.d.ts +9 -13
- package/dist/db/migrations/159_org_id_widen_to_source_width.d.ts +5 -0
- package/dist/db/migrator.d.ts +17 -25
- package/dist/db/notify-listener.d.ts +8 -11
- package/dist/db/repos/dashboard-encryption-keys-repo.d.ts +9 -10
- package/dist/db/synthetic-job-ids.d.ts +6 -8
- package/dist/db/types.d.ts +531 -1058
- package/dist/deployment/deployment-identity.d.ts +42 -60
- package/dist/diagnostics/bundle-reader.d.ts +3 -15
- package/dist/diagnostics/bundle-writer.d.ts +5 -12
- package/dist/diagnostics/checks/agents.d.ts +1 -7
- package/dist/diagnostics/checks/backup.d.ts +7 -10
- package/dist/diagnostics/checks/certs.d.ts +1 -6
- package/dist/diagnostics/checks/config.d.ts +2 -5
- package/dist/diagnostics/checks/db.d.ts +1 -1
- package/dist/diagnostics/checks/disk.d.ts +1 -6
- package/dist/diagnostics/checks/firecracker-network.d.ts +3 -3
- package/dist/diagnostics/checks/index.d.ts +0 -6
- package/dist/diagnostics/checks/retention.d.ts +3 -6
- package/dist/diagnostics/checks/scaler.d.ts +3 -7
- package/dist/diagnostics/checks/ws.d.ts +1 -6
- package/dist/diagnostics/fleet-collector.d.ts +11 -14
- package/dist/diagnostics/fleet-constants.d.ts +1 -3
- package/dist/diagnostics/fleet-selection.d.ts +3 -7
- package/dist/diagnostics/fleet-topology.d.ts +2 -6
- package/dist/diagnostics/fleet-wiring.d.ts +6 -12
- package/dist/diagnostics/index.d.ts +0 -5
- package/dist/diagnostics/runner.d.ts +4 -8
- package/dist/diagnostics/types.d.ts +10 -21
- package/dist/drain/drain-controller.d.ts +16 -22
- package/dist/entry-helpers.d.ts +0 -2
- package/dist/events/circuit-breaker.d.ts +0 -3
- package/dist/events/event-router.d.ts +1 -2
- package/dist/events/event-store.d.ts +0 -9
- package/dist/events/trust-store.d.ts +0 -3
- package/dist/events/types.d.ts +0 -9
- package/dist/firecracker/host-network.d.ts +24 -30
- package/dist/firecracker/net-interfaces.d.ts +4 -7
- package/dist/helpers/rate-limiter.d.ts +0 -1
- package/dist/index.js +240 -482
- package/dist/metrics/agent-metrics-aggregator.d.ts +24 -67
- package/dist/metrics/metrics-reporter.d.ts +4 -13
- package/dist/metrics/prometheus.d.ts +47 -81
- package/dist/orchestrator-core.d.ts +3 -7
- package/dist/pipeline/content-filter.d.ts +20 -30
- package/dist/pipeline/cross-source-tally.d.ts +7 -8
- package/dist/pipeline/decorating-secret-resolver.d.ts +4 -8
- package/dist/pipeline/degraded-reason.d.ts +3 -4
- package/dist/pipeline/direct-ingress-deps.d.ts +15 -24
- package/dist/pipeline/dispatch-matched-workflow.d.ts +290 -526
- package/dist/pipeline/flatten-lock-steps.d.ts +4 -6
- package/dist/pipeline/global-dispatch-identity.d.ts +5 -10
- package/dist/pipeline/global-eval-round.d.ts +62 -156
- package/dist/pipeline/global-round-hold.d.ts +5 -7
- package/dist/pipeline/held-context-data.d.ts +5 -8
- package/dist/pipeline/held-round-registrations.d.ts +8 -11
- package/dist/pipeline/install-gate.d.ts +15 -25
- package/dist/pipeline/install-secrets-resolver.d.ts +24 -34
- package/dist/pipeline/internal-event-pipeline.d.ts +45 -62
- package/dist/pipeline/invoke-gate.d.ts +27 -40
- package/dist/pipeline/job-contexts.d.ts +19 -36
- package/dist/pipeline/manual-schedule.d.ts +7 -13
- package/dist/pipeline/needs-scheduler.d.ts +29 -46
- package/dist/pipeline/pending-workflow-context.d.ts +14 -28
- package/dist/pipeline/process-webhook.d.ts +88 -123
- package/dist/pipeline/processor.d.ts +209 -355
- package/dist/pipeline/remote-source-store.d.ts +5 -8
- package/dist/pipeline/request-idempotency.d.ts +10 -13
- package/dist/pipeline/rerun-global.d.ts +6 -7
- package/dist/pipeline/rerun-inputs.d.ts +23 -37
- package/dist/pipeline/rerun.d.ts +34 -57
- package/dist/pipeline/resolve-sandbox-grant.d.ts +5 -10
- package/dist/pipeline/resume-workflow.d.ts +28 -34
- package/dist/pipeline/route-or-dispatch-jobs.d.ts +19 -30
- package/dist/pipeline/run-event-context.d.ts +16 -21
- package/dist/pipeline/sandbox-allowlist-reader.d.ts +7 -11
- package/dist/pipeline/security-hold-check.d.ts +56 -80
- package/dist/pipeline/test-pipeline.d.ts +20 -46
- package/dist/pipeline/unbound-job-context.d.ts +6 -9
- package/dist/pipeline/undispatched-hold-checks.d.ts +4 -6
- package/dist/pipeline/wave-scheduler.d.ts +15 -22
- package/dist/pipeline/webhook-payload-store.d.ts +3 -10
- package/dist/pipeline/workflow-lock-at-sha.d.ts +14 -20
- package/dist/policy/dashboard-write-policy.d.ts +1 -1
- package/dist/provider-registry.d.ts +0 -19
- package/dist/providers/generic/index.d.ts +0 -2
- package/dist/providers/generic/normalizer.d.ts +0 -1
- package/dist/providers/generic/verification.d.ts +0 -8
- package/dist/providers/github/auth.d.ts +0 -1
- package/dist/providers/github/changed-files.d.ts +2 -1
- package/dist/providers/github/file-contents.d.ts +0 -4
- package/dist/providers/github/lock-file.d.ts +0 -4
- package/dist/providers/github/normalizer.d.ts +1 -9
- package/dist/providers/local/index.d.ts +1 -2
- package/dist/providers/local/lock-file-fetcher.d.ts +0 -4
- package/dist/providers/local/normalizer.d.ts +0 -10
- package/dist/providers/local/repo-url-builder.d.ts +0 -2
- package/dist/providers/universal-git/clone-token.d.ts +0 -2
- package/dist/providers/universal-git/lock-file.d.ts +0 -2
- package/dist/providers/universal-git/normalizer.d.ts +0 -2
- package/dist/queue/bootstrap.d.ts +3 -15
- package/dist/queue/cleanup.d.ts +29 -50
- package/dist/queue/depth-refresher.d.ts +21 -39
- package/dist/queue/job-queue.d.ts +112 -163
- package/dist/queue/retention.d.ts +23 -36
- package/dist/queue/scheduled-job.d.ts +17 -39
- package/dist/queue/terminalize-unroutable.d.ts +16 -18
- package/dist/queue/unroutable-probe.d.ts +15 -22
- package/dist/registration/extractor.d.ts +0 -6
- package/dist/registration/registration-index.d.ts +0 -6
- package/dist/registration/registration-store.d.ts +0 -9
- package/dist/reporting/agent-failure-category.d.ts +3 -5
- package/dist/reporting/check-run-reporter.d.ts +142 -316
- package/dist/reporting/check-run-summary.d.ts +16 -35
- package/dist/reporting/check-run-tracking-store.d.ts +54 -107
- package/dist/reporting/execution-tracker.d.ts +356 -526
- package/dist/reporting/fs-log-storage.d.ts +31 -33
- package/dist/reporting/job-check-run-completion.d.ts +14 -22
- package/dist/reporting/log-chunk-sink.d.ts +11 -16
- package/dist/reporting/log-pull-handler.d.ts +4 -13
- package/dist/reporting/log-retention.d.ts +3 -4
- package/dist/reporting/log-storage.d.ts +24 -52
- package/dist/reporting/log-writer.d.ts +28 -56
- package/dist/reporting/peer-log-normalize.d.ts +4 -8
- package/dist/reporting/run-aggregator.d.ts +6 -11
- package/dist/reporting/run-summary-fields.d.ts +5 -8
- package/dist/reporting/s3-log-storage.d.ts +31 -50
- package/dist/reporting/step-display-order.d.ts +11 -21
- package/dist/reporting/step-log-buffer.d.ts +7 -28
- package/dist/reporting/step-log-reader.d.ts +11 -19
- package/dist/routes/admin-access-log.d.ts +4 -6
- package/dist/routes/admin-auth.d.ts +17 -38
- package/dist/routes/admin-backends.d.ts +3 -14
- package/dist/routes/admin-cluster-name.d.ts +13 -21
- package/dist/routes/admin-cluster-settings.d.ts +6 -9
- package/dist/routes/admin-config.d.ts +7 -19
- package/dist/routes/admin-contexts.d.ts +6 -13
- package/dist/routes/admin-db.d.ts +5 -10
- package/dist/routes/admin-event-dlq.d.ts +3 -5
- package/dist/routes/admin-event-inspect.d.ts +3 -4
- package/dist/routes/admin-event-log.d.ts +3 -7
- package/dist/routes/admin-events.d.ts +16 -30
- package/dist/routes/admin-held-runs.d.ts +52 -76
- package/dist/routes/admin-maintenance.d.ts +3 -6
- package/dist/routes/admin-orchestrator-drain.d.ts +0 -2
- package/dist/routes/admin-org-settings.d.ts +8 -14
- package/dist/routes/admin-peer-forget.d.ts +0 -1
- package/dist/routes/admin-queue-execution.d.ts +3 -3
- package/dist/routes/admin-registrations.d.ts +3 -12
- package/dist/routes/admin-runs.d.ts +16 -29
- package/dist/routes/admin-scaler-orphans.d.ts +4 -4
- package/dist/routes/admin-scaler-reload.d.ts +5 -8
- package/dist/routes/admin-scheduled-jobs.d.ts +3 -4
- package/dist/routes/admin-sources.d.ts +20 -29
- package/dist/routes/admin-trust-policy.d.ts +31 -48
- package/dist/routes/admin.d.ts +67 -94
- package/dist/routes/caller-identity.d.ts +5 -12
- package/dist/routes/capabilities.d.ts +8 -13
- package/dist/routes/diagnostics.d.ts +2 -10
- package/dist/routes/fleet.d.ts +1 -2
- package/dist/routes/github-webhook.d.ts +2 -5
- package/dist/routes/health.d.ts +6 -19
- package/dist/routes/provenance-oidc.d.ts +3 -3
- package/dist/routes/uploads.d.ts +5 -11
- package/dist/routes/webhooks.d.ts +2 -24
- package/dist/scaler/agent-binary-location.d.ts +77 -0
- package/dist/scaler/agent-fit.d.ts +2 -2
- package/dist/scaler/backend-factory.d.ts +10 -18
- package/dist/scaler/bare-metal-backend.d.ts +30 -46
- package/dist/scaler/claim-store.d.ts +20 -43
- package/dist/scaler/config.d.ts +10 -37
- package/dist/scaler/container-backend.d.ts +22 -35
- package/dist/scaler/container-hostconfig.d.ts +19 -16
- package/dist/scaler/container-routing.d.ts +10 -13
- package/dist/scaler/disk-guard.d.ts +2 -3
- package/dist/scaler/event-backend.d.ts +33 -58
- package/dist/scaler/event-provision-reaper.d.ts +61 -84
- package/dist/scaler/failure-tracker.d.ts +6 -13
- package/dist/scaler/file-tail.d.ts +6 -19
- package/dist/scaler/firecracker-api.d.ts +19 -63
- package/dist/scaler/firecracker-backend.d.ts +142 -258
- package/dist/scaler/host-access.d.ts +7 -10
- package/dist/scaler/index.d.ts +3 -6
- package/dist/scaler/ip-allocator.d.ts +30 -82
- package/dist/scaler/label-matcher.d.ts +14 -35
- package/dist/scaler/log-forwarder.d.ts +6 -25
- package/dist/scaler/machine-ledger.d.ts +39 -86
- package/dist/scaler/manager.d.ts +517 -787
- package/dist/scaler/pending-scale-sweeper.d.ts +8 -11
- package/dist/scaler/reap-orphans.d.ts +8 -12
- package/dist/scaler/resolve-container-auth.d.ts +12 -21
- package/dist/scaler/scaler-events.d.ts +2 -5
- package/dist/scaler/scaler-state-store.d.ts +127 -189
- package/dist/scaler/spawn-errors.d.ts +1 -4
- package/dist/scaler/startup-orphan-sweep.d.ts +3 -4
- package/dist/scaler/startup-tools-check.d.ts +21 -0
- package/dist/scaler/types.d.ts +142 -255
- package/dist/scaler/vm-job-bindings.d.ts +5 -9
- package/dist/scaler/warm-pool.d.ts +49 -93
- package/dist/secrets/audit-logger.d.ts +0 -3
- package/dist/secrets/backend-health.d.ts +0 -9
- package/dist/secrets/backend-registry.d.ts +0 -9
- package/dist/secrets/cleanup.d.ts +0 -1
- package/dist/secrets/config.d.ts +0 -3
- package/dist/secrets/ephemeral-keys.d.ts +0 -3
- package/dist/secrets/pg-secret-store.d.ts +0 -3
- package/dist/secrets/rbac.d.ts +0 -6
- package/dist/secrets/secret-output-store.d.ts +0 -6
- package/dist/secrets/secret-resolver.d.ts +2 -6
- package/dist/secrets/token-manager.d.ts +0 -4
- package/dist/secrets/vault-secret-store.d.ts +0 -13
- package/dist/security/comment-handler.d.ts +0 -2
- package/dist/security/workflow-diff.d.ts +1 -1
- package/dist/server.js +8628 -13569
- package/dist/sources/source-manager.d.ts +0 -3
- package/dist/sources/source-store.d.ts +0 -9
- package/dist/sources/source-validator.d.ts +0 -3
- package/dist/stale-detector/all-terminal-runs.d.ts +8 -11
- package/dist/stale-detector/gate-deadline-detector.d.ts +14 -19
- package/dist/stale-detector/reboot-deadline-sweep.d.ts +7 -11
- package/dist/stale-detector/stale-dispatch-candidates.d.ts +13 -20
- package/dist/stale-detector/stale-run-detector.d.ts +74 -121
- package/dist/stale-detector/workflow-deadline-detector.d.ts +15 -43
- package/dist/standalone.js +7670 -12402
- package/dist/storage/blob-routes.d.ts +10 -19
- package/dist/storage/filesystem.d.ts +19 -29
- package/dist/storage/index.d.ts +2 -10
- package/dist/storage/key-discriminator.d.ts +8 -10
- package/dist/storage/loopback-guard.d.ts +27 -45
- package/dist/storage/s3.d.ts +25 -52
- package/dist/storage/sign-url.d.ts +7 -22
- package/dist/storage/types.d.ts +44 -70
- package/dist/webhook/event-log.d.ts +0 -2
- package/dist/webhook/generic-sources.d.ts +0 -21
- package/dist/webhook/ingest-admission.d.ts +0 -1
- package/dist/webhook/relay-buffer.d.ts +2 -2
- package/dist/webhook/verify-inbound.d.ts +0 -1
- package/dist/worker/in-memory-execution-tracker.d.ts +9 -31
- package/dist/worker/in-memory-job-queue.d.ts +32 -72
- package/dist/worker/peer-outbox.d.ts +5 -8
- package/dist/worker/reroute-dispatch.d.ts +4 -6
- package/dist/worker/static-agent-token-store.d.ts +6 -27
- package/dist/worker/worker-outbox-relay.d.ts +2 -2
- package/dist/worker/worker-status.d.ts +3 -20
- package/dist/ws/agent-api-registry.d.ts +8 -27
- package/dist/ws/agent-handler.d.ts +63 -110
- package/dist/ws/agent-heartbeat.d.ts +5 -12
- package/dist/ws/bringup-api.d.ts +31 -38
- package/dist/ws/dashboard-backends-handler.d.ts +12 -22
- package/dist/ws/dashboard-context-handler.d.ts +37 -80
- package/dist/ws/dashboard-diagnostics-handler.d.ts +8 -25
- package/dist/ws/dashboard-dispatch-guard.d.ts +3 -4
- package/dist/ws/dashboard-fleet-handler.d.ts +9 -13
- package/dist/ws/dashboard-fleet-write-handler.d.ts +7 -21
- package/dist/ws/dashboard-global-workflows-handler.d.ts +22 -44
- package/dist/ws/dashboard-registrations-handler.d.ts +10 -27
- package/dist/ws/dashboard-run-state-handler.d.ts +10 -13
- package/dist/ws/event-buffer.d.ts +3 -6
- package/dist/ws/execution-status-frame.d.ts +9 -11
- package/dist/ws/failure-messages.d.ts +9 -14
- package/dist/ws/fleet-agent-collector.d.ts +6 -12
- package/dist/ws/fleet-runs-on-all.d.ts +1 -6
- package/dist/ws/git-credential-relay.d.ts +12 -20
- package/dist/ws/inventory-api.d.ts +4 -5
- package/dist/ws/job-status-forward-frame.d.ts +30 -0
- package/dist/ws/observer-registry.d.ts +14 -59
- package/dist/ws/outbound-frame-guard.d.ts +4 -0
- package/dist/ws/ownership-gate.d.ts +1 -1
- package/dist/ws/platform-client.d.ts +32 -31
- package/dist/ws/replay-chunker.d.ts +7 -10
- package/dist/ws/server-options.d.ts +5 -9
- package/dist/ws/test-relay-handlers.d.ts +45 -59
- package/dist/ws/test-run-log-cursor.d.ts +18 -0
- package/installer-image-digests.json +3 -3
- package/package.json +6 -5
- package/sbom.spdx.json +53 -53
- package/dist/__test-helpers__/fake-scaler-state-store.d.ts +0 -24
- package/dist/__test-helpers__/mock-db-query.d.ts +0 -129
- package/dist/__test-helpers__/mock-db.d.ts +0 -134
- package/dist/__test-helpers__/mock-ws.d.ts +0 -13
- package/dist/__test-helpers__/peer-mutual-auth.d.ts +0 -42
- package/dist/__test-helpers__/scratch-db.d.ts +0 -16
- package/dist/__test-helpers__/test-db.d.ts +0 -34
- package/dist/pipeline/dispatch-matched-workflow.test-helpers.d.ts +0 -121
|
@@ -5,12 +5,9 @@ import type { ResolvedContainerSpawn } from '../scaler/types.js';
|
|
|
5
5
|
import { type ScalerAgentView } from '../scaler/agent-fit.js';
|
|
6
6
|
import type { ResourceRequest } from '@kici-dev/engine';
|
|
7
7
|
/**
|
|
8
|
-
* Why a freed agent's queue drain claimed nothing
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* field of the drain-declined log line and the assertion subject of the tests
|
|
12
|
-
* that pin each exit. The five members are the five ways
|
|
13
|
-
* `Dispatcher.drainForAgent` can return without a dispatch.
|
|
8
|
+
* Why a freed agent's queue drain claimed nothing: one member per way
|
|
9
|
+
* `Dispatcher.drainForAgent` returns without a dispatch. Named because the value
|
|
10
|
+
* travels: it is the drain-declined log line's `reason` and the tests' subject.
|
|
14
11
|
*/
|
|
15
12
|
export declare enum AgentDrainDecline {
|
|
16
13
|
/** The agent id is not in the in-memory registry (already disconnected). */
|
|
@@ -25,30 +22,22 @@ export declare enum AgentDrainDecline {
|
|
|
25
22
|
NoMatchingJob = "no-matching-job"
|
|
26
23
|
}
|
|
27
24
|
/**
|
|
28
|
-
* Default per-pass cap on
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* job that gets `at-capacity` again stays pending for the next tick.
|
|
25
|
+
* Default per-pass cap on pending jobs a capacity-freed re-drive re-offers, so
|
|
26
|
+
* one free event cannot storm the scaler. The per-backend spawn semaphore bounds
|
|
27
|
+
* provisioning; a job that gets `at-capacity` again stays pending for the next tick.
|
|
32
28
|
*/
|
|
33
29
|
export declare const DEFAULT_REDRIVE_BATCH = 10;
|
|
34
|
-
/**
|
|
35
|
-
* Metrics interface for dispatch operations.
|
|
36
|
-
* Allows the dispatcher to update Prometheus counters without
|
|
37
|
-
* directly importing the metrics module (dependency injection).
|
|
38
|
-
*/
|
|
30
|
+
/** Dispatch metrics, injected so the dispatcher does not import the metrics module. */
|
|
39
31
|
export interface DispatchMetrics {
|
|
40
|
-
/** Increment the jobs dispatched counter by status. */
|
|
41
32
|
incJobsDispatched(status: 'dispatched' | 'queued' | 'rejected'): void;
|
|
42
|
-
/** Set the queue depth gauge. */
|
|
43
33
|
setQueueDepth(depth: number): void;
|
|
44
34
|
/** Record `count` pending jobs re-driven through the scaler by `trigger`. */
|
|
45
35
|
incScalerRedispatch(trigger: ScalerRedispatchTrigger, count: number): void;
|
|
46
36
|
}
|
|
47
37
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* with a tiny in-memory stub.
|
|
38
|
+
* Slice of `HostRosterStore` for the host-restart flow: an interface so the
|
|
39
|
+
* dispatcher avoids importing the full store (it pulls in engine label matchers)
|
|
40
|
+
* and the reboot logic is testable with an in-memory stub.
|
|
52
41
|
*/
|
|
53
42
|
export interface HostRosterRebootStore {
|
|
54
43
|
/** True when the host's reboot-pending deadline is still in the future. */
|
|
@@ -57,13 +46,10 @@ export interface HostRosterRebootStore {
|
|
|
57
46
|
clearRebootPending(agentId: string): Promise<void>;
|
|
58
47
|
}
|
|
59
48
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* released and onDispatch is NOT called). The reroute caller should treat the
|
|
65
|
-
* job as already handled. Only reachable on a reroute re-dispatch — first-
|
|
66
|
-
* dispatch paths use a fresh UUID that can never collide.
|
|
49
|
+
* `duplicate`: the dispatch_queue row for a preassigned (rerouted) jobId already
|
|
50
|
+
* existed, so the claimed slot is released, onDispatch is NOT called, and the
|
|
51
|
+
* reroute caller treats the job as handled. Only a reroute re-dispatch reaches
|
|
52
|
+
* it; first dispatch uses a fresh UUID that cannot collide.
|
|
67
53
|
*
|
|
68
54
|
* `queued` also answers a direct dispatch refused because the job's run has
|
|
69
55
|
* stopped: the queue row is recorded `expired` and the job cancelled, the
|
|
@@ -86,6 +72,17 @@ type DispatchResult = {
|
|
|
86
72
|
status: 'rejected';
|
|
87
73
|
reason: string;
|
|
88
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* The job's container spawn, from what dispatch already resolved on `jobConfig`:
|
|
77
|
+
* `container` from the lock, `containerRegistryAuth` orchestrator-side. Nothing
|
|
78
|
+
* is re-resolved — a second resolution is a second chance to disagree.
|
|
79
|
+
*
|
|
80
|
+
* A job that BUILDS its image (`container.dockerfile`) carries no `image`, so this
|
|
81
|
+
* returns `undefined` and no per-job-image spawn happens. Load bearing: the image
|
|
82
|
+
* does not exist until an agent clones and builds it, so an ordinary agent must
|
|
83
|
+
* run the job and nest the container. Exported so `dispatcher.test.ts` pins this
|
|
84
|
+
* routing decision.
|
|
85
|
+
*/
|
|
89
86
|
export declare function containerSpawnFor(jobConfig: Record<string, unknown> | undefined): {
|
|
90
87
|
image: string;
|
|
91
88
|
authconfig?: {
|
|
@@ -104,6 +101,14 @@ export interface DispatchRefusal {
|
|
|
104
101
|
}
|
|
105
102
|
/** The callback that sends a dispatched job to its agent. */
|
|
106
103
|
export type OnDispatch = (agentId: string, job: QueuedJob) => void | DispatchRefusal | Promise<void | DispatchRefusal>;
|
|
104
|
+
/**
|
|
105
|
+
* Dispatch coordinator: routes jobs to label-matching agents, falling back to the
|
|
106
|
+
* persistent queue, and handles agent connect, disconnect and job completion.
|
|
107
|
+
*
|
|
108
|
+
* It never touches WebSocket connections: the caller (orchestrator-core.ts or worker-core.ts)
|
|
109
|
+
* provides an onDispatch that looks up the agent's WS in the registry and sends
|
|
110
|
+
* the job.dispatch message.
|
|
111
|
+
*/
|
|
107
112
|
export declare class Dispatcher {
|
|
108
113
|
private readonly registry;
|
|
109
114
|
private readonly queue;
|
|
@@ -113,142 +118,120 @@ export declare class Dispatcher {
|
|
|
113
118
|
/** See the constructor dep of the same name. */
|
|
114
119
|
private readonly scalerAgentView?;
|
|
115
120
|
/**
|
|
116
|
-
* Single-flight guard for `retryPendingScaleRequests
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* the same tick.
|
|
121
|
+
* Single-flight guard for `retryPendingScaleRequests`: the capacity-freed hook
|
|
122
|
+
* and the leader-gated sweep can fire concurrently and must not double-offer
|
|
123
|
+
* the same pending jobs to the scaler in one tick.
|
|
120
124
|
*/
|
|
121
125
|
private redriveInFlight;
|
|
122
126
|
/**
|
|
123
|
-
* Single-flight guard for `redrivePendingToConnectedAgents
|
|
124
|
-
*
|
|
125
|
-
* re-entered by the next interval fire and double-scan the same pending rows.
|
|
127
|
+
* Single-flight guard for `redrivePendingToConnectedAgents`: the next interval
|
|
128
|
+
* fire must not re-enter a slow re-drive and double-scan the same pending rows.
|
|
126
129
|
*/
|
|
127
130
|
private pendingRedriveInFlight;
|
|
128
|
-
/**
|
|
129
|
-
* Tracks which jobs are dispatched to which agents.
|
|
130
|
-
* Used for marking jobs as failed on agent disconnect.
|
|
131
|
-
*/
|
|
131
|
+
/** agentId -> dispatched jobIds, for failing jobs on agent disconnect. */
|
|
132
132
|
private readonly agentJobs;
|
|
133
133
|
/** Reverse map: jobId -> agentId, for cancel-run lookups. */
|
|
134
134
|
private readonly jobToAgent;
|
|
135
135
|
/**
|
|
136
|
-
* jobId -> runId
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* state (`resolveOwnedJob`) rather than trusting an agent-asserted value.
|
|
136
|
+
* jobId -> runId, kept and cleared with `jobToAgent`/`agentJobs`, so the
|
|
137
|
+
* provenance token relay resolves a job's runId from dispatcher state
|
|
138
|
+
* (`resolveOwnedJob`) rather than trusting an agent-asserted value.
|
|
140
139
|
*/
|
|
141
140
|
private readonly jobRunIds;
|
|
142
141
|
/**
|
|
143
|
-
* Grace window for recently completed jobs.
|
|
144
|
-
*
|
|
145
|
-
*
|
|
142
|
+
* Grace window for recently completed jobs: late messages (log.chunk,
|
|
143
|
+
* step.status) are accepted briefly after completion, not flagged as
|
|
144
|
+
* ownership violations.
|
|
146
145
|
*/
|
|
147
146
|
private readonly completedJobs;
|
|
148
|
-
/**
|
|
147
|
+
/** Bounds completedJobs growth. */
|
|
149
148
|
private static readonly COMPLETED_JOBS_CAP;
|
|
150
|
-
/** Grace window duration in milliseconds (30 seconds). */
|
|
151
149
|
private static readonly GRACE_WINDOW_MS;
|
|
152
|
-
/** Interval for cleaning up expired grace window entries (10 seconds). */
|
|
153
150
|
private static readonly GRACE_CLEANUP_INTERVAL_MS;
|
|
154
|
-
/** Timer for periodic grace cleanup. */
|
|
155
151
|
private graceCleanupTimer;
|
|
156
|
-
/**
|
|
152
|
+
/** From agent config; derives the recovery grace period. */
|
|
157
153
|
private readonly maxReconnectDelayMs;
|
|
158
154
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* the execution-tracker job failed with the given reason.
|
|
155
|
+
* Fired on a permanent dispatch-side failure (recovery window expired,
|
|
156
|
+
* re-dispatch attempts exhausted, or a scaler-managed agent destroyed
|
|
157
|
+
* mid-execution); the receiver marks the execution-tracker job failed.
|
|
163
158
|
*/
|
|
164
159
|
private readonly onJobFailedPermanently?;
|
|
165
|
-
/** Callback when a job enters recovery (starts timer). */
|
|
166
160
|
private readonly onRecoveryStarted?;
|
|
167
161
|
/** Fallback ack deadline when no getAckTimeoutMs dep is wired (tests). */
|
|
168
162
|
private static readonly DEFAULT_ACK_TIMEOUT_MS;
|
|
169
163
|
/**
|
|
170
|
-
* Pending dispatch
|
|
171
|
-
*
|
|
172
|
-
*
|
|
164
|
+
* Pending dispatch acks: armed when a job.dispatch is sent, resolved by
|
|
165
|
+
* job.ack / job.reject / job.status running / disconnect triage. On expiry the
|
|
166
|
+
* dispatch is lost: requeue + disconnect.
|
|
173
167
|
*/
|
|
174
168
|
private readonly pendingAcks;
|
|
175
169
|
/**
|
|
176
|
-
*
|
|
177
|
-
* answered
|
|
178
|
-
*
|
|
179
|
-
* `armAckDeadline`, which then skips arming.
|
|
170
|
+
* jobId -> acking agent, for acks that beat their pending-ack entry (the agent
|
|
171
|
+
* answered before the timeout was resolved and the deadline stamped).
|
|
172
|
+
* `armAckDeadline` consumes it and skips arming.
|
|
180
173
|
*/
|
|
181
174
|
private readonly earlyAcks;
|
|
182
|
-
/**
|
|
175
|
+
/** Per-job ack deadline (per-org override / cluster default). */
|
|
183
176
|
private readonly getAckTimeoutMs;
|
|
184
177
|
/** Cancel + disconnect an agent whose dispatch ack deadline expired. */
|
|
185
178
|
private readonly onAckTimeout?;
|
|
186
179
|
/**
|
|
187
|
-
* Jobs
|
|
188
|
-
*
|
|
189
|
-
* re-dispatchable; started jobs on destroyed agents fail fast.
|
|
180
|
+
* Jobs whose `job.status: running` arrived. Disconnect triage re-dispatches
|
|
181
|
+
* never-started jobs; started jobs on destroyed agents fail fast.
|
|
190
182
|
*/
|
|
191
183
|
private readonly startedJobs;
|
|
192
184
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* If the agent reconnects before the timer fires, the timer is cancelled.
|
|
185
|
+
* Recovery timers for 'recovering' jobs: each in-flight job of a disconnected
|
|
186
|
+
* agent gets one, cancelled if the agent reconnects before it fires.
|
|
196
187
|
*/
|
|
197
188
|
private readonly recoveringJobs;
|
|
198
|
-
/** Grace period = 2x max reconnection delay. */
|
|
199
189
|
private get gracePeriodMs();
|
|
200
|
-
/**
|
|
190
|
+
/** For the reboot-pending gate; undefined ⇒ flow inert. */
|
|
201
191
|
private readonly rosterStore?;
|
|
202
|
-
/**
|
|
203
|
-
* dispatching. Defaults to never-draining. */
|
|
192
|
+
/** When true, new jobs queue Pending instead of dispatching. Defaults to never. */
|
|
204
193
|
private readonly isDraining;
|
|
205
|
-
/**
|
|
194
|
+
/** Defaults to none (a single node). */
|
|
206
195
|
private readonly hasPeerCoordinators;
|
|
207
196
|
constructor(deps: {
|
|
208
197
|
registry: AgentRegistry;
|
|
209
198
|
queue: JobQueue;
|
|
210
199
|
metrics: DispatchMetrics;
|
|
211
200
|
onDispatch: OnDispatch;
|
|
212
|
-
/**
|
|
213
|
-
*
|
|
214
|
-
* per-scaler / per-orchestrator / per-machine caps before spawning. */
|
|
201
|
+
/** Called when no agent matches; gets the per-job `resources` so the scaler
|
|
202
|
+
* applies per-scaler / per-orchestrator / per-machine caps before spawning. */
|
|
215
203
|
onNoMatchingAgent?: (labels: string[], jobId: string, runId: string, excludeLabels: string[], resources?: ResourceRequest, orgId?: string,
|
|
216
204
|
/**
|
|
217
|
-
* The job's own
|
|
218
|
-
*
|
|
219
|
-
*
|
|
205
|
+
* The job's own image plus registry credentials, resolved at dispatch.
|
|
206
|
+
* Present: the backend spawns THAT image with the KiCI runtime injected
|
|
207
|
+
* instead of the pool's fixed agent image.
|
|
220
208
|
*/
|
|
221
209
|
containerSpawn?: ResolvedContainerSpawn) => Promise<ScaleResult>;
|
|
222
210
|
/**
|
|
223
|
-
* What the scaler knows about an agent it started
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* is configured; the predicate then judges every agent on its own
|
|
228
|
-
* registration.
|
|
211
|
+
* What the scaler knows about an agent it started (`ScalerManager.agentView`),
|
|
212
|
+
* undefined for others. Feeds `canAgentRunJob`: the job the agent was started
|
|
213
|
+
* for, whether it runs in that job's image, a warm agent's fixed shape. Absent
|
|
214
|
+
* with no scaler; every agent is then judged on its own registration.
|
|
229
215
|
*/
|
|
230
216
|
scalerAgentView?: (agentId: string) => ScalerAgentView | undefined;
|
|
231
|
-
/**
|
|
217
|
+
/** From agent config (default 60s); derives the grace period. */
|
|
232
218
|
maxReconnectDelayMs?: number;
|
|
233
|
-
/**
|
|
219
|
+
/** Fired when a job is permanently failed before/outside agent execution. */
|
|
234
220
|
onJobFailedPermanently?: (agentId: string, jobId: string, runId: string, reason: string) => void;
|
|
235
|
-
/**
|
|
221
|
+
/** Fired when a job enters recovery (its timer starts). */
|
|
236
222
|
onRecoveryStarted?: (agentId: string, jobId: string) => void;
|
|
237
|
-
/**
|
|
223
|
+
/** Per-job dispatch-ack deadline (ms). Defaults to 10s. */
|
|
238
224
|
getAckTimeoutMs?: (job: QueuedJob) => Promise<number>;
|
|
239
225
|
/** Cancel + disconnect an agent whose dispatch ack deadline expired. */
|
|
240
226
|
onAckTimeout?: (agentId: string, jobId: string, runId: string) => void;
|
|
241
227
|
/**
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* success rather than starting the recovery-fail timer). Omitted ⇒ the
|
|
246
|
-
* reboot-pending behavior is inert (every host reads not-pending).
|
|
228
|
+
* For the host-restart flow: no pinned drain to a reboot-pending agent, and
|
|
229
|
+
* its disconnect is the expected reboot (in-flight job completes success, no
|
|
230
|
+
* recovery-fail timer). Omitted ⇒ inert (every host reads not-pending).
|
|
247
231
|
*/
|
|
248
232
|
rosterStore?: HostRosterRebootStore;
|
|
249
|
-
/**
|
|
250
|
-
*
|
|
251
|
-
* finish. Defaults to never-draining. */
|
|
233
|
+
/** When true, dispatch() enqueues new jobs Pending and onAgentAvailable()
|
|
234
|
+
* claims nothing; jobs already on agents finish. Defaults to never. */
|
|
252
235
|
isDraining?: () => boolean;
|
|
253
236
|
/**
|
|
254
237
|
* Whether another coordinator is live: connected, or disconnected for less
|
|
@@ -261,365 +244,272 @@ export declare class Dispatcher {
|
|
|
261
244
|
/** Runs with the ids of the jobs each disconnect triage failed; see {@link setDisconnectCleanup}. */
|
|
262
245
|
private disconnectCleanup?;
|
|
263
246
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* waiting for its socket (heartbeat timeout, ack timeout, token revocation)
|
|
269
|
-
* reaches it too.
|
|
247
|
+
* The agent WS handler installs the release of the failed jobs' in-memory
|
|
248
|
+
* waiters (pending builds, inits, dynamic evaluations, global eval rounds). It
|
|
249
|
+
* runs inside {@link onAgentDisconnect}, so paths that drop an agent without
|
|
250
|
+
* its socket closing (heartbeat timeout, ack timeout, token revocation) reach it.
|
|
270
251
|
*/
|
|
271
252
|
setDisconnectCleanup(cleanup: (failedJobIds: string[]) => void): void;
|
|
272
|
-
/**
|
|
273
|
-
* Dispatch a job to a matching agent, or queue it if none available.
|
|
274
|
-
*
|
|
275
|
-
* Flow:
|
|
276
|
-
* 1. Find available agents matching job's runsOnLabels.
|
|
277
|
-
* 2. If agent found: increment activeJobs, call onDispatch, return 'dispatched'.
|
|
278
|
-
* 3. If no agent: enqueue in queue, return 'queued'.
|
|
279
|
-
* 4. If queue full: return 'rejected'.
|
|
280
|
-
*/
|
|
253
|
+
/** Dispatch a job to a matching agent, or queue it; 'rejected' when the queue is full. */
|
|
281
254
|
dispatch(job: QueuedJobInput): Promise<DispatchResult>;
|
|
282
255
|
/**
|
|
283
|
-
* Re-drive the scaler for jobs still pending after
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
* accounting. A job that returns `at-capacity` again just stays pending for
|
|
291
|
-
* the next free/sweep tick — no retry state, no backoff bookkeeping.
|
|
256
|
+
* Re-drive the scaler for jobs still pending after `at-capacity`, from the
|
|
257
|
+
* capacity-freed hook (`ScalerManager.onCapacityFreed`) and the leader-gated
|
|
258
|
+
* `PendingScaleSweeper`. Oldest first (FIFO: the longest-waiting burst victim
|
|
259
|
+
* gets the freed slot), through the SAME `onNoMatchingAgent` → `requestScale`
|
|
260
|
+
* path as dispatch, so it inherits the spawn semaphore and cap accounting. A
|
|
261
|
+
* job that gets `at-capacity` again stays pending for the next tick — no retry
|
|
262
|
+
* state, no backoff.
|
|
292
263
|
*
|
|
293
|
-
* Single-flight
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* A job whose sealed secrets this coordinator cannot open is never scaled
|
|
298
|
-
* for: it is settled instead ({@link settleUnopenablePending}).
|
|
264
|
+
* Single-flight (an overlapping call returns 0, so hook+sweep never double-offer)
|
|
265
|
+
* and bounded by `maxJobs`. A job whose sealed secrets this coordinator cannot
|
|
266
|
+
* open is settled instead ({@link settleUnopenablePending}).
|
|
299
267
|
*
|
|
300
268
|
* @returns the number of jobs that entered `spawning`.
|
|
301
269
|
*/
|
|
302
270
|
retryPendingScaleRequests(maxJobs?: number, trigger?: ScalerRedispatchTrigger): Promise<number>;
|
|
303
271
|
/**
|
|
304
|
-
* Re-offer ONE pending job to the scaler
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
* sweep to pick it up. The worker's per-job attempt gate is what keeps this
|
|
309
|
-
* from starting a second spawn for the same job.
|
|
272
|
+
* Re-offer ONE pending job to the scaler when a worker's spawn-retry backoff
|
|
273
|
+
* ends. Outside the batch single-flight on purpose: a wake-up during a batch
|
|
274
|
+
* pass would be dropped, and a worker runs no pending-scale sweep. The worker's
|
|
275
|
+
* per-job attempt gate prevents a second spawn for the same job.
|
|
310
276
|
*
|
|
311
277
|
* @returns true when a spawn started.
|
|
312
278
|
*/
|
|
313
279
|
redrivePendingJob(jobId: string): Promise<boolean>;
|
|
314
280
|
/**
|
|
315
|
-
* Offer one pending job
|
|
316
|
-
*
|
|
317
|
-
* cannot be opened here.
|
|
281
|
+
* Offer one pending job via the dispatch scale path, or settle it when its
|
|
282
|
+
* sealed secrets cannot be opened here.
|
|
318
283
|
*/
|
|
319
284
|
private offerPendingToScaler;
|
|
320
285
|
/**
|
|
321
|
-
* Release the slot
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* under `queued` exactly as it would that one.
|
|
286
|
+
* Release the slot of a direct dispatch the queue refused because the run has
|
|
287
|
+
* stopped; nothing is sent. The queue already recorded the row `expired` and
|
|
288
|
+
* cancelled the job, so it reads as a queued job the cancel expired, and the
|
|
289
|
+
* caller tracks it under `queued` the same way.
|
|
326
290
|
*/
|
|
327
291
|
private refuseStoppedRunDispatch;
|
|
328
292
|
/**
|
|
329
|
-
* Dispatch a host-fanout pinned child
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
* agent frees up or (re)connects. A pinned job never falls through to a
|
|
334
|
-
* different agent.
|
|
293
|
+
* Dispatch a host-fanout pinned child to exactly `job.pinnedAgentId` when it is
|
|
294
|
+
* locally connected, passes the runsOn/exclude/mandatory gate and has capacity;
|
|
295
|
+
* otherwise queue it WITH the pin for the pin-aware drain when the agent frees
|
|
296
|
+
* up or (re)connects. Never falls through to a different agent.
|
|
335
297
|
*/
|
|
336
298
|
private dispatchPinned;
|
|
337
299
|
/**
|
|
338
|
-
* Eagerly dispatch
|
|
339
|
-
* scaler-managed agent
|
|
300
|
+
* Eagerly dispatch the job the scaler bound at spawn time to a freshly
|
|
301
|
+
* registered scaler-managed agent (the agent-handler calls it right after
|
|
302
|
+
* registration). Atomically claims it (still pending, labels still satisfied),
|
|
303
|
+
* marks it dispatched and sends it.
|
|
340
304
|
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* dispatched, and sends it to the agent.
|
|
346
|
-
*
|
|
347
|
-
* Returns true only when the job was sent to the agent. False when nothing
|
|
348
|
-
* was claimed (the bound job was already claimed elsewhere, expired, or the
|
|
349
|
-
* agent isn't registered, is full or the coordinator is draining), and also
|
|
350
|
-
* when the claimed job was not sent: its dispatch was refused and it failed,
|
|
351
|
-
* or this coordinator could not open its sealed secrets. The caller falls
|
|
352
|
-
* back to the generic onAgentAvailable() drain in every false case.
|
|
305
|
+
* True only when sent. False when nothing was claimed (claimed elsewhere,
|
|
306
|
+
* expired, agent unregistered or full, coordinator draining) or the claimed
|
|
307
|
+
* job was not sent (refused and failed, or sealed secrets this coordinator
|
|
308
|
+
* cannot open). On false the caller falls back to the onAgentAvailable() drain.
|
|
353
309
|
*/
|
|
354
310
|
dispatchBoundJob(agentId: string, jobId: string): Promise<boolean>;
|
|
355
311
|
/** {@link dispatchBoundJob}, reporting whether the job was claimed apart from whether it was sent. */
|
|
356
312
|
private claimBoundJob;
|
|
357
313
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
* Dequeues matching jobs from the queue while the agent has capacity,
|
|
362
|
-
* calling onDispatch for each.
|
|
363
|
-
*/
|
|
364
|
-
/**
|
|
365
|
-
* Drop agents whose reboot-pending flag is set from a candidate list. Used by
|
|
366
|
-
* the label-routed dispatch path so a post-restart job is never sent to a host
|
|
367
|
-
* that is about to reboot. No-op when no roster store is wired.
|
|
314
|
+
* Drop reboot-pending agents, so label-routed dispatch never sends a
|
|
315
|
+
* post-restart job to a host about to reboot. No-op with no roster store.
|
|
368
316
|
*/
|
|
369
317
|
private filterRebootPending;
|
|
370
318
|
/**
|
|
371
|
-
* Drop the agents that cannot run this job (`canAgentRunJob`)
|
|
372
|
-
* {@link filterRebootPending}
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* shape. Dropping the candidate here is what sends the job down the ordinary
|
|
378
|
-
* `onNoMatchingAgent` scale path.
|
|
379
|
-
*
|
|
380
|
-
* `jobId` is the job's queue id when it has one: it is how the agent started
|
|
381
|
-
* for the job recognizes it.
|
|
319
|
+
* Drop the agents that cannot run this job (`canAgentRunJob`): like
|
|
320
|
+
* {@link filterRebootPending}, a reason labels cannot express (started inside
|
|
321
|
+
* another job's image, no container runtime for a container job, a warm agent
|
|
322
|
+
* of another shape). Dropping them sends the job down the `onNoMatchingAgent`
|
|
323
|
+
* scale path. `jobId` (the queue id, when any) is how the agent started for
|
|
324
|
+
* the job recognizes it.
|
|
382
325
|
*/
|
|
383
326
|
private filterUnservableAgents;
|
|
384
327
|
/** The registration facts, and the scaler's record, `canAgentRunJob` judges an agent on. */
|
|
385
328
|
private fitAgentFor;
|
|
386
329
|
/**
|
|
387
|
-
* The fit question for one job:
|
|
388
|
-
*
|
|
330
|
+
* The fit question for one job: queue id, declared shape, and what its
|
|
331
|
+
* `container:` asks of the host.
|
|
389
332
|
*
|
|
390
|
-
* The shape
|
|
391
|
-
* mirror is
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
* declares nothing, which admits it onto a pre-spawned agent of some other
|
|
396
|
-
* size — the exact mismatch this gate exists to refuse.
|
|
333
|
+
* The shape falls back to `jobConfig.resources` because the typed `resources`
|
|
334
|
+
* mirror is optional and several paths never fill it: a job reaching {@link dispatch}
|
|
335
|
+
* off the webhook pipeline or a worker's reroute handler declares in
|
|
336
|
+
* `jobConfig` alone. Reading only the mirror admits it onto a pre-spawned agent
|
|
337
|
+
* of another size — the mismatch this gate exists to refuse.
|
|
397
338
|
*/
|
|
398
339
|
private agentFitFor;
|
|
399
340
|
/**
|
|
400
|
-
* The queue-drain half of {@link filterUnservableAgents}: a per-job
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
* Undefined is the common answer for an agent that runs any job: the
|
|
404
|
-
* predicate could only ever say yes, and returning one would cost the drain
|
|
405
|
-
* its single-statement fast path for nothing.
|
|
341
|
+
* The queue-drain half of {@link filterUnservableAgents}: a per-job predicate
|
|
342
|
+
* for one agent, or undefined for an agent that runs any job — a predicate
|
|
343
|
+
* that only says yes would cost the drain its single-statement fast path.
|
|
406
344
|
*/
|
|
407
345
|
private agentFitFilterFor;
|
|
408
346
|
/**
|
|
409
|
-
*
|
|
410
|
-
* the
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
* trigger (job completion / agent.status), which must keep the gate closed.
|
|
347
|
+
* Clear a reboot-pending host's flag on its real (down-then-up) reconnect, so
|
|
348
|
+
* the next `onAgentAvailable` drain dispatches the held post-restart job. Call
|
|
349
|
+
* ONLY from the (re-)register path, never from a still-connected drain trigger
|
|
350
|
+
* (job completion / agent.status), which must keep the gate closed.
|
|
414
351
|
*/
|
|
415
352
|
releaseRebootPending(agentId: string): Promise<void>;
|
|
416
|
-
onAgentAvailable(agentId: string): Promise<void>;
|
|
417
353
|
/**
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
354
|
+
* Try draining the queue for a specific agent. Called when an agent registers,
|
|
355
|
+
* completes a job or reports `agent.status`; claims at most one queued job per
|
|
356
|
+
* call ({@link drainForAgent}).
|
|
421
357
|
*/
|
|
358
|
+
onAgentAvailable(agentId: string): Promise<void>;
|
|
359
|
+
/** Claim at most one queued job for a freed agent; null when one was dispatched. */
|
|
422
360
|
private drainForAgent;
|
|
423
361
|
/** {@link deliver} inside the job's own request context, restored for a queue-drained job. */
|
|
424
362
|
private deliverInRequestContext;
|
|
425
363
|
/**
|
|
426
|
-
* Hand a tracked job to `onDispatch`.
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
* ({@link releaseUnopenableDispatch}).
|
|
364
|
+
* Hand a tracked job to `onDispatch`. False when not sent: the callback
|
|
365
|
+
* refused it (failed permanently — the refusal is a fact about the job, so
|
|
366
|
+
* another agent would refuse it too), or this coordinator cannot open its
|
|
367
|
+
* sealed secrets (put back for a key holder, or failed when none can:
|
|
368
|
+
* {@link releaseUnopenableDispatch}).
|
|
432
369
|
*/
|
|
433
370
|
private deliver;
|
|
434
371
|
/**
|
|
435
|
-
* Handle a claimed job
|
|
436
|
-
* was sealed with a master key this coordinator does not hold.
|
|
372
|
+
* Handle a claimed job sealed with a master key this coordinator does not hold.
|
|
437
373
|
*
|
|
438
|
-
* With
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
* spending one dispatch attempt and recording the reason as the job's
|
|
374
|
+
* With a peer live it is not permanent: mid rolling master-key rotation the
|
|
375
|
+
* peer may hold the new key and its drains can take the job. The row returns
|
|
376
|
+
* to pending, spending one dispatch attempt and recording the reason as the
|
|
442
377
|
* provisioning error (what an expiry reports), and this coordinator stops
|
|
443
|
-
* offering
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* {@link MAX_DISPATCH_ATTEMPTS} is reached. With no other coordinator live
|
|
447
|
-
* nobody can open it, so it fails at once.
|
|
378
|
+
* offering it for the sealed-secrets back-off. After that, drains and re-drives
|
|
379
|
+
* offer it again, so a job no coordinator opens fails with the reason at
|
|
380
|
+
* {@link MAX_DISPATCH_ATTEMPTS}. With no peer live it fails at once.
|
|
448
381
|
*
|
|
449
|
-
* `agentId` is
|
|
450
|
-
*
|
|
382
|
+
* `agentId` is undefined when a re-drive claimed it for no agent
|
|
383
|
+
* ({@link settleUnopenablePending}).
|
|
451
384
|
*/
|
|
452
385
|
private releaseUnopenableDispatch;
|
|
453
386
|
/**
|
|
454
|
-
* Settle a pending job
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
* back from. So the job is claimed by id for no agent and gets the decision a
|
|
463
|
-
* drain that claimed it would give it ({@link releaseUnopenableDispatch}). A
|
|
464
|
-
* claim lost to another coordinator, or refused inside the back-off, leaves
|
|
465
|
-
* the job alone.
|
|
387
|
+
* Settle a pending job with unopenable sealed secrets that a re-drive would
|
|
388
|
+
* otherwise scale for. Scaling is wrong twice: a private image's registry
|
|
389
|
+
* credentials are sealed with the other secrets, so its spawn pulls without
|
|
390
|
+
* them and fails before any agent registers (never claimed, no attempt spent,
|
|
391
|
+
* every re-drive spawns again); and any agent a spawn starts would get the job
|
|
392
|
+
* handed back. So it is claimed by id for no agent and decided as a drain
|
|
393
|
+
* would ({@link releaseUnopenableDispatch}). A claim lost to another
|
|
394
|
+
* coordinator, or refused inside the back-off, leaves the job alone.
|
|
466
395
|
*/
|
|
467
396
|
private settleUnopenablePending;
|
|
468
|
-
/**
|
|
469
|
-
* Undo the dispatch accounting of a refused job and fail it with the refusal
|
|
470
|
-
* reason. `agentId` is undefined for a job claimed for no agent.
|
|
471
|
-
*/
|
|
397
|
+
/** Undo a refused job's accounting and fail it; `agentId` undefined = claimed for no agent. */
|
|
472
398
|
private failRefusedDispatch;
|
|
473
399
|
/** Free the slot and tracking a claim took on its agent; a claim for no agent took none. */
|
|
474
400
|
private releaseClaimAccounting;
|
|
475
401
|
/**
|
|
476
|
-
* Release the slot and tracking `jobId` holds on `agentId
|
|
477
|
-
*
|
|
478
|
-
* put-back, a disconnect) already took it.
|
|
402
|
+
* Release the slot and tracking `jobId` holds on `agentId`; false when another
|
|
403
|
+
* path (a refusal, a put-back, a disconnect) already took it.
|
|
479
404
|
*/
|
|
480
405
|
private releaseTrackedClaim;
|
|
481
406
|
/**
|
|
482
|
-
* Hand a job
|
|
483
|
-
*
|
|
484
|
-
*
|
|
485
|
-
* agent is not left holding a slot for a job it never received.
|
|
407
|
+
* Hand a just-claimed job to `agentId`, whose slot the claim took. A query
|
|
408
|
+
* failing before the send returns the claim ({@link returnUndeliveredClaim})
|
|
409
|
+
* and rethrows, so the agent holds no slot for a job it never received.
|
|
486
410
|
*
|
|
487
411
|
* @returns whether the job was sent.
|
|
488
412
|
*/
|
|
489
413
|
private sendClaimedJob;
|
|
490
414
|
/**
|
|
491
|
-
* Put back a job a
|
|
492
|
-
*
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* the row stays dispatched with no ack deadline and the stale-dispatch scan
|
|
498
|
-
* reaps it.
|
|
415
|
+
* Put back a claimed job a query failure kept from being sent. The slot (and
|
|
416
|
+
* tracking, once taken) is released, and the row returns to pending without
|
|
417
|
+
* spending an attempt, since no agent saw it; the next drain or pending
|
|
418
|
+
* re-drive offers it again. A job a refusal or disconnect already took is left
|
|
419
|
+
* to that path. If the put-back fails too, the row stays dispatched with no ack
|
|
420
|
+
* deadline and the stale-dispatch scan reaps it.
|
|
499
421
|
*/
|
|
500
422
|
private returnUndeliveredClaim;
|
|
501
|
-
/** Record that a job began executing on its agent. */
|
|
502
423
|
markJobStarted(jobId: string): void;
|
|
503
424
|
/**
|
|
504
|
-
* The agent accepted `jobId` (
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
* {@link AgentRegistry.clearExpiredBusyHold}.
|
|
425
|
+
* The agent accepted `jobId` (`job.ack`, or `running` standing in for a lost
|
|
426
|
+
* one). An expired busy hold is dropped: the job was dispatched after it ran
|
|
427
|
+
* out, into a free slot, so the job count is not stuck and the next
|
|
428
|
+
* teardown-window rejection must not spend an attempt. A hold still in force
|
|
429
|
+
* is kept — see {@link AgentRegistry.clearExpiredBusyHold}.
|
|
510
430
|
*/
|
|
511
431
|
private noteJobAccepted;
|
|
512
432
|
/**
|
|
513
433
|
* Arm the ack deadline for a just-sent dispatch (timer + persisted row).
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
* a
|
|
517
|
-
* in-memory entry. `earlyAcks` records such an ack so this method skips
|
|
518
|
-
* arming entirely instead of starting a timer that has nothing to resolve
|
|
519
|
-
* it (which would expire a dispatch the agent actually accepted).
|
|
434
|
+
* Resolving the timeout and persisting both touch the DB, so a fast job.ack can
|
|
435
|
+
* beat the in-memory entry; `earlyAcks` records it and arming is skipped, since
|
|
436
|
+
* a timer with nothing to resolve it would expire an accepted dispatch.
|
|
520
437
|
*/
|
|
521
438
|
private armAckDeadline;
|
|
522
|
-
/**
|
|
523
|
-
* Consume a recorded early ack for `jobId` from `agentId`. Returns true if
|
|
524
|
-
* one was pending (and removes it).
|
|
525
|
-
*/
|
|
439
|
+
/** Consume a recorded early ack for `jobId` from `agentId`; true if one was pending. */
|
|
526
440
|
private consumeEarlyAck;
|
|
527
441
|
/** Clear a pending ack (answered or otherwise settled). Idempotent. */
|
|
528
442
|
private resolvePendingAck;
|
|
529
|
-
/** Handle
|
|
443
|
+
/** Handle a `job.ack` from an agent. */
|
|
530
444
|
onJobAcked(agentId: string, jobId: string): void;
|
|
531
445
|
/**
|
|
532
|
-
* The ack deadline expired: the dispatch is lost.
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* triage finds nothing to double-handle.
|
|
446
|
+
* The ack deadline expired: the dispatch is lost. The job is untracked and the
|
|
447
|
+
* agent removed from the registry BEFORE the requeue, so the redispatch cannot
|
|
448
|
+
* land it back on the agent being torn down, and the later WS-close triage
|
|
449
|
+
* finds nothing to double-handle.
|
|
537
450
|
*/
|
|
538
451
|
private handleAckExpiry;
|
|
539
452
|
/**
|
|
540
|
-
* Drop an agent that did not
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
* once, so a redispatch cannot re-select it while the triage awaits.
|
|
453
|
+
* Drop an agent that did not ack a dispatch. Its other in-flight jobs (a
|
|
454
|
+
* multi-slot agent) go through {@link onAgentDisconnect}, which reads the
|
|
455
|
+
* registration before its first await to tell scaler-managed from static, so
|
|
456
|
+
* the triage starts first; the unregister right after removes the agent from
|
|
457
|
+
* routing so a redispatch cannot re-select it while the triage awaits.
|
|
546
458
|
*/
|
|
547
459
|
private dropUnacknowledgingAgent;
|
|
548
|
-
/**
|
|
549
|
-
* Handle an explicit dispatch rejection (`job.reject`) from an agent.
|
|
550
|
-
* Undoes the dispatch accounting and requeues the job for another agent.
|
|
551
|
-
*/
|
|
460
|
+
/** Handle a `job.reject`: undo the dispatch accounting and requeue for another agent. */
|
|
552
461
|
onJobRejected(agentId: string, jobId: string, reason: string): Promise<void>;
|
|
553
|
-
/** Remove a job from all per-agent in-memory tracking. */
|
|
554
462
|
private untrackJob;
|
|
555
463
|
/**
|
|
556
|
-
* Requeue a dispatched job
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
* requeues without spending the budget (a busy rejection).
|
|
464
|
+
* Requeue a dispatched job, or fail it once its attempt budget is exhausted;
|
|
465
|
+
* the outcome lets disconnect triage surface failed job IDs. `countAttempt:
|
|
466
|
+
* false` spends no budget (a busy rejection).
|
|
560
467
|
*/
|
|
561
468
|
private requeueOrFail;
|
|
562
469
|
/**
|
|
563
|
-
* The half of {@link requeueOrFail}
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
* Split out so the ack-expiry paths can drive it from the attempt count their
|
|
567
|
-
* own guarded requeue (`requeueIfAwaitingAck`) returned, instead of flipping
|
|
568
|
-
* the row a second time.
|
|
470
|
+
* The post-flip half of {@link requeueOrFail}: fail on an exhausted budget,
|
|
471
|
+
* else re-dispatch. Split out so ack expiry drives it from its guarded
|
|
472
|
+
* requeue's (`requeueIfAwaitingAck`) attempt count without flipping the row twice.
|
|
569
473
|
*/
|
|
570
474
|
private finishRequeue;
|
|
571
475
|
/**
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
* fresh agent is spawned bound to this job.
|
|
476
|
+
* Deliver a requeued pending job: an idle matching agent (atomic claim via
|
|
477
|
+
* dispatchBoundJob), else the scaler spawns a fresh agent bound to it.
|
|
575
478
|
*/
|
|
576
479
|
private redispatch;
|
|
577
480
|
/**
|
|
578
|
-
* Safety-net re-drive: deliver
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* Runs per-coordinator and is NOT leader-gated: each coordinator drains the
|
|
583
|
-
* shared queue onto its OWN connected agents, and the atomic claim guarantees
|
|
584
|
-
* at most one agent (on any coordinator) wins each job, so concurrent ticks
|
|
585
|
-
* cannot double-dispatch.
|
|
481
|
+
* Safety-net re-drive: deliver each pending job a connected, idle, matching
|
|
482
|
+
* agent could take, through the drain's atomic claim (`dispatchBoundJob` →
|
|
483
|
+
* `dequeueById`).
|
|
586
484
|
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
* agent whose own drain trigger (registration / completion / status) already
|
|
591
|
-
* fired before the requeue has no further trigger, so if that one attempt
|
|
592
|
-
* transiently misses the agent — the agent is momentarily at capacity while an
|
|
593
|
-
* in-flight drain holds its eagerly-claimed slot, or the agent is connected to
|
|
594
|
-
* a different coordinator than the one that ran the expiry — the requeued
|
|
595
|
-
* pending job would otherwise sit undelivered until it expired. This tick
|
|
596
|
-
* re-attempts delivery onto connected agents so the miss recovers on the next
|
|
597
|
-
* sweep.
|
|
485
|
+
* Per-coordinator, NOT leader-gated: each coordinator drains the shared queue
|
|
486
|
+
* onto its OWN agents, and the atomic claim lets at most one agent (on any
|
|
487
|
+
* coordinator) win each job, so concurrent ticks cannot double-dispatch.
|
|
598
488
|
*
|
|
599
|
-
* It
|
|
600
|
-
*
|
|
489
|
+
* It closes the requeue gap: a job requeued by `handleAckExpiry` /
|
|
490
|
+
* `onJobRejected` / the leader ack sweep gets one delivery attempt
|
|
491
|
+
* (`redispatch`'s `findAvailable` + `dispatchBoundJob`), and an idle agent whose
|
|
492
|
+
* drain trigger fired before the requeue gets no other. If that attempt misses
|
|
493
|
+
* (the agent momentarily at capacity while a drain holds its eagerly claimed
|
|
494
|
+
* slot, or connected to another coordinator than the one that ran the expiry),
|
|
495
|
+
* the job would sit until it expired; this tick recovers it on the next sweep.
|
|
601
496
|
*
|
|
602
|
-
*
|
|
603
|
-
* dispatch refused, or its sealed secrets unopenable here) is not counted.
|
|
497
|
+
* Never consults the scaler (that is `retryPendingScaleRequests`) or spawns.
|
|
604
498
|
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
* releases the single-flight guard.
|
|
499
|
+
* Returns the jobs sent; a claimed job not sent (refused, or sealed secrets
|
|
500
|
+
* unopenable here) is not counted. Failures propagate: the per-coord interval
|
|
501
|
+
* wrapper is the single error-log site, like the sibling recovery/ack sweeps
|
|
502
|
+
* on its cadence. The `finally` only releases the single-flight guard.
|
|
609
503
|
*/
|
|
610
504
|
redrivePendingToConnectedAgents(maxJobs?: number): Promise<number>;
|
|
611
505
|
/**
|
|
612
|
-
* Pick a connected agent
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
* offered to `findAvailable`, which would mis-deliver it to any label match.
|
|
506
|
+
* Pick a connected agent for a pending job, or null. A pinned host-fanout child
|
|
507
|
+
* runs ONLY on its pinned agent and `dequeueById` ignores the pin, so it never
|
|
508
|
+
* goes to `findAvailable`, which would mis-deliver it to any label match.
|
|
616
509
|
*
|
|
617
|
-
* Reboot-pending gate:
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
* counterpart of the same gate in `dispatch()` / `dispatchPinned` /
|
|
621
|
-
* `drainForAgent`; without it this path re-drives the held job onto the
|
|
622
|
-
* reboot-pending host and defeats the hold.
|
|
510
|
+
* Reboot-pending gate: the safety-net counterpart of the gate in `dispatch()` /
|
|
511
|
+
* `dispatchPinned` / `drainForAgent`; without it this path re-drives the held
|
|
512
|
+
* post-restart job onto the about-to-reboot host and defeats the hold.
|
|
623
513
|
*/
|
|
624
514
|
private selectConnectedTargetForPending;
|
|
625
515
|
/**
|
|
@@ -627,160 +517,116 @@ export declare class Dispatcher {
|
|
|
627
517
|
* immediately failing jobs, giving the agent a grace period to reconnect.
|
|
628
518
|
* If no in-flight jobs, performs a clean disconnect.
|
|
629
519
|
*
|
|
630
|
-
* Returns
|
|
631
|
-
* asynchronously when recovery timers expire).
|
|
520
|
+
* Returns the started jobs a scaler-managed agent's disconnect failed outright;
|
|
521
|
+
* otherwise empty (failures happen asynchronously when recovery timers expire).
|
|
632
522
|
*/
|
|
633
523
|
onAgentDisconnect(agentId: string): Promise<string[]>;
|
|
634
524
|
/**
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
*
|
|
638
|
-
* a recovery timer. Untracks the jobs so the reconnect does not reconcile a
|
|
639
|
-
* phantom in-flight set.
|
|
525
|
+
* Complete a reboot-pending agent's in-flight started jobs as success (the
|
|
526
|
+
* restart job may already be terminal; `markCompleted` is guarded then). No
|
|
527
|
+
* recovery timer. Untracked so the reconnect reconciles no phantom in-flight set.
|
|
640
528
|
*/
|
|
641
529
|
private completeInFlightForReboot;
|
|
642
|
-
/** Drop grace-window entries owned by an agent. */
|
|
643
530
|
private cleanupGraceEntriesForAgent;
|
|
644
|
-
/**
|
|
645
|
-
* Scaler-managed agent disconnected: requeue never-started jobs, fail
|
|
646
|
-
* started ones. Returns the permanently failed job IDs.
|
|
647
|
-
*/
|
|
531
|
+
/** Scaler-managed disconnect: requeue never-started jobs, fail started ones (returned). */
|
|
648
532
|
private triageScalerManagedDisconnect;
|
|
649
533
|
/**
|
|
650
|
-
* Static
|
|
651
|
-
*
|
|
652
|
-
* asynchronously when recovery timers expire.
|
|
534
|
+
* Static disconnect: per-job recovery timers (the agent may reconnect and
|
|
535
|
+
* reclaim). Always returns []; failures happen when the timers expire.
|
|
653
536
|
*/
|
|
654
537
|
private startRecoveryForDisconnect;
|
|
655
538
|
/**
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
* (e.g. final log chunks) are still accepted.
|
|
539
|
+
* An agent finished a job (success or failure). The job moves to the grace
|
|
540
|
+
* window rather than being removed, so late messages (final log chunks) are
|
|
541
|
+
* still accepted.
|
|
660
542
|
*/
|
|
661
543
|
onJobComplete(agentId: string, jobId: string): void;
|
|
662
544
|
/**
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
* in recovery (agent disconnected but within grace period),
|
|
666
|
-
* or in the grace window (completed within the last 30 seconds).
|
|
545
|
+
* True if the job is dispatched to the agent, recovering (disconnected within
|
|
546
|
+
* the grace period), or in the grace window (completed in the last 30 seconds).
|
|
667
547
|
*/
|
|
668
548
|
isJobOwnedByAgent(agentId: string, jobId: string): boolean;
|
|
669
|
-
/**
|
|
670
|
-
* Resolve which agent a dispatched job was sent to.
|
|
671
|
-
* Used by the cancel-run API. Returns null if the job is not tracked (e.g. already completed).
|
|
672
|
-
*/
|
|
549
|
+
/** For the cancel-run API; null once the job is untracked (e.g. completed). */
|
|
673
550
|
getAgentIdForJob(jobId: string): string | null;
|
|
674
551
|
/** The jobs of `runId` this dispatcher currently tracks to an agent. */
|
|
675
552
|
getTrackedJobIdsForRun(runId: string): string[];
|
|
676
|
-
/**
|
|
677
|
-
* Start periodic cleanup of expired grace window entries.
|
|
678
|
-
* Should be called during server startup.
|
|
679
|
-
*/
|
|
553
|
+
/** Start periodic cleanup of expired grace window entries; call at server startup. */
|
|
680
554
|
startGraceCleanup(): void;
|
|
681
|
-
/**
|
|
682
|
-
* Stop periodic grace cleanup.
|
|
683
|
-
* Should be called during server shutdown.
|
|
684
|
-
*/
|
|
555
|
+
/** Call at server shutdown. */
|
|
685
556
|
stopGraceCleanup(): void;
|
|
686
557
|
/**
|
|
687
|
-
* Claim a recovering job back for a reconnected agent
|
|
688
|
-
*
|
|
689
|
-
* for this agent. Returns false if the job is not recovering or belongs
|
|
690
|
-
* to a different agent.
|
|
558
|
+
* Claim a recovering job back for a reconnected agent, cancelling its timer;
|
|
559
|
+
* false if it is not recovering or belongs to a different agent.
|
|
691
560
|
*/
|
|
692
561
|
claimRecovery(jobId: string, agentId: string): boolean;
|
|
693
562
|
/**
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
* and restores in-memory tracking. Returns true if reconciled.
|
|
563
|
+
* Reconcile a recovering job for a reconnected agent: claim the timer, move
|
|
564
|
+
* the DB row back to dispatched, restore in-memory tracking.
|
|
697
565
|
*/
|
|
698
566
|
reconcileRecovery(jobId: string, agentId: string): Promise<boolean>;
|
|
699
|
-
/**
|
|
700
|
-
* Get recovery info for a job (for structured logging).
|
|
701
|
-
*/
|
|
567
|
+
/** For structured logging. */
|
|
702
568
|
getRecoveryInfo(jobId: string): {
|
|
703
569
|
disconnectedAt: number;
|
|
704
570
|
agentId: string;
|
|
705
571
|
} | null;
|
|
706
|
-
/**
|
|
707
|
-
* Get all recovering job IDs for a specific agent.
|
|
708
|
-
* Used during reconnection reconciliation.
|
|
709
|
-
*/
|
|
572
|
+
/** For reconnection reconciliation. */
|
|
710
573
|
getRecoveringJobsForAgent(agentId: string): string[];
|
|
711
574
|
/**
|
|
712
|
-
* Restore a
|
|
713
|
-
*
|
|
714
|
-
* reconnecting agent reporting the job in-flight means it had started,
|
|
715
|
-
* so mark it started for disconnect triage.
|
|
575
|
+
* Restore a job a reconnected agent claimed from recovery. The agent reports
|
|
576
|
+
* it in-flight, so it had started: marked started for disconnect triage.
|
|
716
577
|
*/
|
|
717
578
|
restoreJobForAgent(agentId: string, jobId: string, runId?: string): void;
|
|
718
579
|
/**
|
|
719
|
-
* Start a recovery timer for a job found
|
|
720
|
-
*
|
|
721
|
-
* from a previous orchestrator instance.
|
|
580
|
+
* Start a recovery timer for a job found 'dispatched' at startup. Called by
|
|
581
|
+
* orchestrator-core.ts for jobs from a previous orchestrator instance.
|
|
722
582
|
*/
|
|
723
583
|
startRecoveryTimer(jobId: string, agentId: string, runId: string): Promise<void>;
|
|
724
584
|
/**
|
|
725
|
-
* Rebuild
|
|
726
|
-
*
|
|
727
|
-
*
|
|
728
|
-
*
|
|
729
|
-
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
* the leader-gated `sweepExpiredRecoveries()` will pick it up on
|
|
733
|
-
* its next tick (which avoids two coords racing to mark the same
|
|
734
|
-
* job failed during recovery).
|
|
735
|
-
* - rows with NULL deadline (pre-migration recovering jobs) are
|
|
736
|
-
* fast-failed by the sweep on its first run.
|
|
585
|
+
* Rebuild `recoveringJobs` from `dispatch_queue` after a coord boot / Raft
|
|
586
|
+
* leader switch. Per `status='recovering'` row:
|
|
587
|
+
* - future `recovery_deadline`: re-arm a timer for the remaining window.
|
|
588
|
+
* - past deadline: left to the leader-gated `sweepExpiredRecoveries()`, so
|
|
589
|
+
* two coords never race to mark the same job failed.
|
|
590
|
+
* - NULL deadline (pre-migration recovering jobs): the sweep fast-fails it
|
|
591
|
+
* on its first run.
|
|
737
592
|
*/
|
|
738
593
|
recoverState(): Promise<void>;
|
|
739
594
|
/**
|
|
740
|
-
* Leader-gated sweep: requeue
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
* so racing coords cannot double-requeue.
|
|
595
|
+
* Leader-gated sweep: requeue `dispatched` rows whose ack deadline passed
|
|
596
|
+
* unwatched (the owning coord crashed before its timer fired). The requeue is
|
|
597
|
+
* atomic (WHERE status='dispatched'), so racing coords cannot double-requeue.
|
|
744
598
|
*/
|
|
745
599
|
sweepExpiredAckDeadlines(): Promise<number>;
|
|
746
600
|
/**
|
|
747
|
-
* Leader-gated sweep:
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
* fixed interval
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
* Safe to call on non-leaders (idempotent due to the WHERE clause)
|
|
754
|
-
* but skipping the call on followers avoids redundant DB updates.
|
|
601
|
+
* Leader-gated sweep: fail `recovering` rows with `recovery_deadline < now`
|
|
602
|
+
* and fire `onJobFailedPermanently`, so jobs whose owning coord crashed
|
|
603
|
+
* mid-recovery still reach a terminal state. Runs on the Raft leader at a
|
|
604
|
+
* fixed interval; idempotent on followers (WHERE clause), skipped there to
|
|
605
|
+
* avoid redundant DB updates.
|
|
755
606
|
*/
|
|
756
607
|
sweepExpiredRecoveries(): Promise<number>;
|
|
757
|
-
/**
|
|
758
|
-
* Stop all recovery timers. Called during graceful shutdown.
|
|
759
|
-
*/
|
|
608
|
+
/** Called during graceful shutdown. */
|
|
760
609
|
stopRecoveryTimers(): void;
|
|
761
610
|
/**
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
611
|
+
* Recovery timer expiry for one job, shared by onAgentDisconnect and
|
|
612
|
+
* startRecoveryTimer; callers `.catch()` it to avoid unhandled rejections in
|
|
613
|
+
* setTimeout.
|
|
765
614
|
*/
|
|
766
615
|
private handleRecoveryExpiry;
|
|
767
|
-
/** Remove expired entries from the completedJobs grace window map. */
|
|
768
616
|
private cleanupExpiredGraceEntries;
|
|
769
617
|
private trackJobForAgent;
|
|
770
618
|
/**
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
* agent never asserts a runId.
|
|
775
|
-
* own the job (or the runId is no longer tracked).
|
|
619
|
+
* The runId of `jobId` from dispatcher tracking, if `agentId` currently owns
|
|
620
|
+
* it; else `undefined` (also when the runId is no longer tracked). The
|
|
621
|
+
* provenance token relay binds a minted token to a job the agent actually
|
|
622
|
+
* owns — the agent never asserts a runId.
|
|
776
623
|
*/
|
|
777
624
|
resolveOwnedJob(agentId: string, jobId: string): {
|
|
778
625
|
runId: string;
|
|
779
626
|
} | undefined;
|
|
780
627
|
/**
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
* accepts the rerouted job.
|
|
628
|
+
* Mark a queued job failed: the coordinator cleans up its local fallback
|
|
629
|
+
* entry once a peer accepts the rerouted job.
|
|
784
630
|
*/
|
|
785
631
|
cancelQueuedJob(jobId: string, reason: string): Promise<void>;
|
|
786
632
|
private updateQueueDepthMetric;
|