@kici-dev/orchestrator 0.0.0 → 0.1.2
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/LICENSE +661 -0
- package/README.md +1 -6
- package/dist/__test-helpers__/mock-db.d.ts +103 -0
- package/dist/__test-helpers__/mock-ws.d.ts +13 -0
- package/dist/agent/dispatcher.d.ts +231 -0
- package/dist/agent/ownership-tracker.d.ts +46 -0
- package/dist/agent/registry.d.ts +255 -0
- package/dist/agent/token-store.d.ts +96 -0
- package/dist/app.d.ts +234 -0
- package/dist/audit/access-log.d.ts +92 -0
- package/dist/audit/sampling-rate-limiter.d.ts +41 -0
- package/dist/cache/build-coordinator.d.ts +42 -0
- package/dist/cache/dep-cache.d.ts +51 -0
- package/dist/cache/index.d.ts +16 -0
- package/dist/cache/pending-builds.d.ts +14 -0
- package/dist/cache/pending-dynamics.d.ts +15 -0
- package/dist/cache/pending-inits.d.ts +19 -0
- package/dist/cache/pending-tracker.d.ts +65 -0
- package/dist/cache/source-cache.d.ts +30 -0
- package/dist/cli/api-client.d.ts +411 -0
- package/dist/cli/commands/access-log.d.ts +30 -0
- package/dist/cli/commands/agent-service/index.d.ts +15 -0
- package/dist/cli/commands/agent-service/install.d.ts +9 -0
- package/dist/cli/commands/agent-service/logs.d.ts +9 -0
- package/dist/cli/commands/agent-service/restart.d.ts +8 -0
- package/dist/cli/commands/agent-service/start.d.ts +8 -0
- package/dist/cli/commands/agent-service/status.d.ts +10 -0
- package/dist/cli/commands/agent-service/stop.d.ts +8 -0
- package/dist/cli/commands/agent-service/uninstall.d.ts +9 -0
- package/dist/cli/commands/agent-service/upgrade.d.ts +11 -0
- package/dist/cli/commands/agent.d.ts +10 -0
- package/dist/cli/commands/api-key.d.ts +12 -0
- package/dist/cli/commands/audit.d.ts +9 -0
- package/dist/cli/commands/backend.d.ts +17 -0
- package/dist/cli/commands/cold-store-impl.d.ts +101 -0
- package/dist/cli/commands/cold-store.d.ts +30 -0
- package/dist/cli/commands/config.d.ts +16 -0
- package/dist/cli/commands/db.d.ts +19 -0
- package/dist/cli/commands/debug-bundle.d.ts +16 -0
- package/dist/cli/commands/diagnose.d.ts +15 -0
- package/dist/cli/commands/environment.d.ts +24 -0
- package/dist/cli/commands/event-dlq.d.ts +19 -0
- package/dist/cli/commands/event-log.d.ts +27 -0
- package/dist/cli/commands/event.d.ts +4 -0
- package/dist/cli/commands/execution.d.ts +17 -0
- package/dist/cli/commands/inspect-bundle.d.ts +16 -0
- package/dist/cli/commands/maintenance.d.ts +4 -0
- package/dist/cli/commands/orchestrator-service/index.d.ts +12 -0
- package/dist/cli/commands/orchestrator-service/install.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/logs.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/restart.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/start.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/status.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/stop.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/uninstall.d.ts +9 -0
- package/dist/cli/commands/orchestrator-service/upgrade.d.ts +12 -0
- package/dist/cli/commands/org-settings.d.ts +17 -0
- package/dist/cli/commands/peer.d.ts +13 -0
- package/dist/cli/commands/queue.d.ts +16 -0
- package/dist/cli/commands/registration.d.ts +18 -0
- package/dist/cli/commands/rotate.d.ts +9 -0
- package/dist/cli/commands/runs.d.ts +34 -0
- package/dist/cli/commands/secret.d.ts +12 -0
- package/dist/cli/commands/shared/db.d.ts +16 -0
- package/dist/cli/commands/shared/versioned-upgrade.d.ts +38 -0
- package/dist/cli/commands/source.d.ts +24 -0
- package/dist/cli/commands/token.d.ts +10 -0
- package/dist/cli/commands/workflow.d.ts +31 -0
- package/dist/cli/join.d.ts +14 -0
- package/dist/cli/kici-admin.d.ts +13 -0
- package/dist/cli/lazy-deps/cache.d.ts +17 -0
- package/dist/cli/lazy-deps/downloader.d.ts +33 -0
- package/dist/cli/lazy-deps/registry.d.ts +43 -0
- package/dist/cli/service/compose.d.ts +25 -0
- package/dist/cli/service/index.d.ts +24 -0
- package/dist/cli/service/launchd.d.ts +34 -0
- package/dist/cli/service/platform-detect.d.ts +59 -0
- package/dist/cli/service/systemd.d.ts +41 -0
- package/dist/cli/service/types.d.ts +91 -0
- package/dist/cli/service/windows.d.ts +20 -0
- package/dist/cli/wizard/agent-wizard.d.ts +24 -0
- package/dist/cli/wizard/orchestrator-wizard.d.ts +38 -0
- package/dist/cli/wizard/prompts.d.ts +23 -0
- package/dist/cli.js +11435 -0
- package/dist/cluster/cluster-identity.d.ts +59 -0
- package/dist/cluster/coordinator.d.ts +204 -0
- package/dist/cluster/health-api.d.ts +30 -0
- package/dist/cluster/index.d.ts +24 -0
- package/dist/cluster/join-client.d.ts +75 -0
- package/dist/cluster/join-handler.d.ts +58 -0
- package/dist/cluster/join-token.d.ts +94 -0
- package/dist/cluster/orphan-recovery.d.ts +67 -0
- package/dist/cluster/peer-client.d.ts +190 -0
- package/dist/cluster/peer-credentials.d.ts +108 -0
- package/dist/cluster/peer-crypto.d.ts +57 -0
- package/dist/cluster/peer-handler.d.ts +97 -0
- package/dist/cluster/peer-registry.d.ts +186 -0
- package/dist/cluster/raft-state.d.ts +36 -0
- package/dist/cluster/raft.d.ts +140 -0
- package/dist/cold-store/load-access-log-range.d.ts +73 -0
- package/dist/cold-store/load-event-log-range.d.ts +62 -0
- package/dist/cold-store/load-secret-audit-log-range.d.ts +38 -0
- package/dist/cold-store/orchestrator-cold-store.d.ts +58 -0
- package/dist/cold-store/tables/access-log.d.ts +80 -0
- package/dist/cold-store/tables/event-log.d.ts +70 -0
- package/dist/cold-store/tables/execution-jobs.d.ts +63 -0
- package/dist/cold-store/tables/execution-runs.d.ts +81 -0
- package/dist/cold-store/tables/execution-steps.d.ts +65 -0
- package/dist/cold-store/tables/secret-audit-log.d.ts +77 -0
- package/dist/concurrency/dispatch-next-queued.d.ts +63 -0
- package/dist/concurrency/group-tracker.d.ts +51 -0
- package/dist/concurrency/index.d.ts +3 -0
- package/dist/concurrency/queue-manager.d.ts +68 -0
- package/dist/concurrency/waiters.d.ts +58 -0
- package/dist/config/encryption.d.ts +82 -0
- package/dist/config/env-overlay.d.ts +45 -0
- package/dist/config/index.d.ts +16 -0
- package/dist/config/loader.d.ts +26 -0
- package/dist/config/reload.d.ts +113 -0
- package/dist/config/resolver.d.ts +47 -0
- package/dist/config/schema.d.ts +210 -0
- package/dist/config/shared-store.d.ts +142 -0
- package/dist/config/types.d.ts +218 -0
- package/dist/config.d.ts +249 -0
- package/dist/cron/cron-scheduler.d.ts +78 -0
- package/dist/cron/cron-store.d.ts +38 -0
- package/dist/dashboard/handler.d.ts +243 -0
- package/dist/db/client.d.ts +13 -0
- package/dist/db/migration-provider.d.ts +9 -0
- package/dist/db/migrations/001_initial.d.ts +8 -0
- package/dist/db/migrations/002_config_versions_key_version.d.ts +16 -0
- package/dist/db/migrations/003_access_log.d.ts +26 -0
- package/dist/db/migrations/004_rename_bundle_to_source.d.ts +19 -0
- package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +19 -0
- package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +38 -0
- package/dist/db/migrations/007_audit_logs_archived_at.d.ts +42 -0
- package/dist/db/migrations/008_event_log_archived_at.d.ts +40 -0
- package/dist/db/migrations/009_access_log_trigram.d.ts +15 -0
- package/dist/db/migrations/010_cold_store_chunks.d.ts +34 -0
- package/dist/db/migrations/011_drop_source_secrets_notify.d.ts +21 -0
- package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +28 -0
- package/dist/db/migrations/013_execution_log_bytes.d.ts +21 -0
- package/dist/db/migrations/014_kici_events_lease_retry.d.ts +36 -0
- package/dist/db/migrations/015_org_settings_customer_scoped.d.ts +30 -0
- package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +15 -0
- package/dist/db/migrations/017_org_id_widen.d.ts +4 -0
- package/dist/db/migrations/018_org_id_prefix_backfill.d.ts +4 -0
- package/dist/db/migrator.d.ts +32 -0
- package/dist/db/types.d.ts +1266 -0
- package/dist/diagnostics/bundle-reader.d.ts +48 -0
- package/dist/diagnostics/bundle-writer.d.ts +57 -0
- package/dist/diagnostics/checks/agents.d.ts +10 -0
- package/dist/diagnostics/checks/certs.d.ts +9 -0
- package/dist/diagnostics/checks/config.d.ts +10 -0
- package/dist/diagnostics/checks/db.d.ts +9 -0
- package/dist/diagnostics/checks/disk.d.ts +9 -0
- package/dist/diagnostics/checks/index.d.ts +17 -0
- package/dist/diagnostics/checks/ws.d.ts +9 -0
- package/dist/diagnostics/index.d.ts +13 -0
- package/dist/diagnostics/runner.d.ts +23 -0
- package/dist/diagnostics/types.d.ts +38 -0
- package/dist/entry-helpers.d.ts +93 -0
- package/dist/environments/binding-store.d.ts +27 -0
- package/dist/environments/environment-store.d.ts +74 -0
- package/dist/environments/held-runs.d.ts +64 -0
- package/dist/environments/index.d.ts +10 -0
- package/dist/environments/protection/branch-gate.d.ts +5 -0
- package/dist/environments/protection/concurrency-gate.d.ts +7 -0
- package/dist/environments/protection/pipeline.d.ts +18 -0
- package/dist/environments/protection/reviewer-gate.d.ts +7 -0
- package/dist/environments/protection/trust-gate.d.ts +7 -0
- package/dist/environments/protection/wait-timer-gate.d.ts +7 -0
- package/dist/environments/variable-store.d.ts +39 -0
- package/dist/events/circuit-breaker.d.ts +33 -0
- package/dist/events/event-emitter.d.ts +55 -0
- package/dist/events/event-retry-scanner.d.ts +52 -0
- package/dist/events/event-router.d.ts +183 -0
- package/dist/events/event-store.d.ts +157 -0
- package/dist/events/trust-store.d.ts +54 -0
- package/dist/events/types.d.ts +61 -0
- package/dist/helpers/ip-extraction.d.ts +29 -0
- package/dist/helpers/rate-limiter.d.ts +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +772 -0
- package/dist/lockfile-cache.d.ts +39 -0
- package/dist/metrics/agent-metrics-aggregator.d.ts +116 -0
- package/dist/metrics/metrics-reporter.d.ts +40 -0
- package/dist/metrics/prometheus.d.ts +261 -0
- package/dist/metrics/scheduled-jobs.d.ts +20 -0
- package/dist/orchestrator-core.d.ts +193 -0
- package/dist/pipeline/dispatch-matched-workflow.d.ts +102 -0
- package/dist/pipeline/inline-eval.d.ts +28 -0
- package/dist/pipeline/install-secrets-resolver.d.ts +73 -0
- package/dist/pipeline/manual-schedule.d.ts +21 -0
- package/dist/pipeline/needs-scheduler.d.ts +85 -0
- package/dist/pipeline/process-webhook.d.ts +38 -0
- package/dist/pipeline/processor.d.ts +326 -0
- package/dist/pipeline/rerun.d.ts +79 -0
- package/dist/pipeline/test-pipeline.d.ts +110 -0
- package/dist/provider-registry.d.ts +122 -0
- package/dist/providers/generic/index.d.ts +23 -0
- package/dist/providers/generic/normalizer.d.ts +112 -0
- package/dist/providers/generic/verification.d.ts +47 -0
- package/dist/providers/github/auth.d.ts +60 -0
- package/dist/providers/github/changed-files.d.ts +51 -0
- package/dist/providers/github/check-status-poster.d.ts +35 -0
- package/dist/providers/github/contributor-resolver.d.ts +30 -0
- package/dist/providers/github/index.d.ts +20 -0
- package/dist/providers/github/lock-file.d.ts +32 -0
- package/dist/providers/github/normalizer.d.ts +103 -0
- package/dist/providers/github/repo-url.d.ts +35 -0
- package/dist/providers/internal/index.d.ts +32 -0
- package/dist/providers/internal/lock-file-fetcher.d.ts +34 -0
- package/dist/providers/internal/normalizer.d.ts +89 -0
- package/dist/providers/internal/repo-url-builder.d.ts +42 -0
- package/dist/providers/universal-git/changed-files.d.ts +42 -0
- package/dist/providers/universal-git/clone-token.d.ts +83 -0
- package/dist/providers/universal-git/config.d.ts +192 -0
- package/dist/providers/universal-git/index.d.ts +55 -0
- package/dist/providers/universal-git/lock-file.d.ts +71 -0
- package/dist/providers/universal-git/normalizer.d.ts +90 -0
- package/dist/providers/universal-git/repo-url.d.ts +50 -0
- package/dist/providers/universal-git/ssh-auth.d.ts +94 -0
- package/dist/queue/bootstrap.d.ts +50 -0
- package/dist/queue/cleanup.d.ts +41 -0
- package/dist/queue/depth-refresher.d.ts +65 -0
- package/dist/queue/job-queue.d.ts +343 -0
- package/dist/queue/scheduled-job.d.ts +91 -0
- package/dist/registration/extractor.d.ts +44 -0
- package/dist/registration/registration-index.d.ts +162 -0
- package/dist/registration/registration-store.d.ts +111 -0
- package/dist/reporting/check-run-summary.d.ts +102 -0
- package/dist/reporting/commit-status.d.ts +382 -0
- package/dist/reporting/execution-tracker.d.ts +538 -0
- package/dist/reporting/fs-log-storage.d.ts +41 -0
- package/dist/reporting/log-pull-handler.d.ts +35 -0
- package/dist/reporting/log-storage.d.ts +70 -0
- package/dist/reporting/log-writer.d.ts +45 -0
- package/dist/reporting/s3-log-storage.d.ts +42 -0
- package/dist/reporting/step-log-buffer.d.ts +57 -0
- package/dist/routes/admin-access-log.d.ts +34 -0
- package/dist/routes/admin-backends.d.ts +28 -0
- package/dist/routes/admin-config.d.ts +57 -0
- package/dist/routes/admin-db.d.ts +20 -0
- package/dist/routes/admin-environments.d.ts +42 -0
- package/dist/routes/admin-errors.d.ts +4 -0
- package/dist/routes/admin-event-dlq.d.ts +39 -0
- package/dist/routes/admin-event-log.d.ts +42 -0
- package/dist/routes/admin-events.d.ts +46 -0
- package/dist/routes/admin-maintenance.d.ts +22 -0
- package/dist/routes/admin-org-settings.d.ts +29 -0
- package/dist/routes/admin-queue-execution.d.ts +27 -0
- package/dist/routes/admin-registrations.d.ts +37 -0
- package/dist/routes/admin-runs.d.ts +57 -0
- package/dist/routes/admin-scheduled-jobs.d.ts +36 -0
- package/dist/routes/admin-sources.d.ts +18 -0
- package/dist/routes/admin.d.ts +103 -0
- package/dist/routes/capabilities.d.ts +24 -0
- package/dist/routes/diagnostics.d.ts +16 -0
- package/dist/routes/health.d.ts +20 -0
- package/dist/routes/test-trigger.d.ts +41 -0
- package/dist/routes/uploads.d.ts +38 -0
- package/dist/routes/webhooks.d.ts +36 -0
- package/dist/scaler/bare-metal-backend.d.ts +107 -0
- package/dist/scaler/config.d.ts +303 -0
- package/dist/scaler/container-backend.d.ts +125 -0
- package/dist/scaler/file-tail.d.ts +23 -0
- package/dist/scaler/firecracker-api.d.ts +100 -0
- package/dist/scaler/firecracker-backend.d.ts +263 -0
- package/dist/scaler/index.d.ts +24 -0
- package/dist/scaler/ip-allocator.d.ts +177 -0
- package/dist/scaler/label-matcher.d.ts +73 -0
- package/dist/scaler/log-forwarder.d.ts +54 -0
- package/dist/scaler/machine-ledger.d.ts +160 -0
- package/dist/scaler/manager.d.ts +338 -0
- package/dist/scaler/nftables.d.ts +85 -0
- package/dist/scaler/types.d.ts +388 -0
- package/dist/scaler/warm-pool.d.ts +81 -0
- package/dist/secrets/audit-logger.d.ts +65 -0
- package/dist/secrets/backend-health.d.ts +60 -0
- package/dist/secrets/backend-registry.d.ts +68 -0
- package/dist/secrets/backend-sync.d.ts +40 -0
- package/dist/secrets/cleanup.d.ts +40 -0
- package/dist/secrets/config.d.ts +51 -0
- package/dist/secrets/crypto.d.ts +49 -0
- package/dist/secrets/ephemeral-keys.d.ts +49 -0
- package/dist/secrets/index.d.ts +17 -0
- package/dist/secrets/pg-secret-store.d.ts +105 -0
- package/dist/secrets/rbac.d.ts +47 -0
- package/dist/secrets/secret-output-store.d.ts +46 -0
- package/dist/secrets/secret-resolver.d.ts +137 -0
- package/dist/secrets/source-credentials.d.ts +61 -0
- package/dist/secrets/token-manager.d.ts +63 -0
- package/dist/secrets/vault-secret-store.d.ts +85 -0
- package/dist/security/comment-handler.d.ts +67 -0
- package/dist/security/contributor-cache.d.ts +75 -0
- package/dist/security/global-workflow-policy.d.ts +72 -0
- package/dist/security/lock-source.d.ts +34 -0
- package/dist/security/trust-resolver.d.ts +108 -0
- package/dist/security/workflow-diff.d.ts +26 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.js +48055 -0
- package/dist/sources/index.d.ts +10 -0
- package/dist/sources/source-manager.d.ts +63 -0
- package/dist/sources/source-store.d.ts +79 -0
- package/dist/sources/source-validator.d.ts +16 -0
- package/dist/stale-detector/stale-run-detector.d.ts +109 -0
- package/dist/standalone.d.ts +20 -0
- package/dist/standalone.js +41546 -0
- package/dist/storage/blob-routes.d.ts +20 -0
- package/dist/storage/filesystem.d.ts +60 -0
- package/dist/storage/index.d.ts +20 -0
- package/dist/storage/s3.d.ts +68 -0
- package/dist/storage/sign-url.d.ts +45 -0
- package/dist/storage/types.d.ts +98 -0
- package/dist/webhook/dedup.d.ts +44 -0
- package/dist/webhook/event-log.d.ts +83 -0
- package/dist/webhook/generic-sources.d.ts +169 -0
- package/dist/webhook/handler.d.ts +23 -0
- package/dist/webhook/relay-buffer.d.ts +96 -0
- package/dist/webhook/verify-inbound.d.ts +78 -0
- package/dist/worker/in-memory-execution-tracker.d.ts +94 -0
- package/dist/worker/in-memory-job-queue.d.ts +74 -0
- package/dist/worker/static-agent-token-store.d.ts +58 -0
- package/dist/worker/worker-status.d.ts +36 -0
- package/dist/worker-core.d.ts +74 -0
- package/dist/ws/agent-api-registry.d.ts +49 -0
- package/dist/ws/agent-handler.d.ts +176 -0
- package/dist/ws/agent-heartbeat.d.ts +45 -0
- package/dist/ws/dashboard-backends-handler.d.ts +51 -0
- package/dist/ws/dashboard-diagnostics-handler.d.ts +56 -0
- package/dist/ws/dashboard-env-handler.d.ts +107 -0
- package/dist/ws/dashboard-global-workflows-handler.d.ts +72 -0
- package/dist/ws/dashboard-registrations-handler.d.ts +84 -0
- package/dist/ws/event-buffer.d.ts +16 -0
- package/dist/ws/observer-handler.d.ts +42 -0
- package/dist/ws/observer-registry.d.ts +88 -0
- package/dist/ws/platform-client.d.ts +270 -0
- package/dist/ws/server-options.d.ts +15 -0
- package/package.json +87 -7
- package/sbom.spdx.json +14370 -0
- package/index.js +0 -3
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-workflow dispatch pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Handles everything that happens AFTER a workflow has been matched against an
|
|
5
|
+
* incoming webhook: payload storage, cache + build coordination, secret
|
|
6
|
+
* resolution, per-job environment evaluation, static job dispatch (cluster +
|
|
7
|
+
* single-orch paths), execution-tracker registration, deferred init dispatch
|
|
8
|
+
* for jobs with dynamic fields, and deferred dynamic-job-fn dispatch for
|
|
9
|
+
* `_type:'dynamic'` lock entries.
|
|
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.
|
|
15
|
+
*/
|
|
16
|
+
import type { LockWorkflow, SimulatedEvent, WorkflowDecision } from '@kici-dev/engine';
|
|
17
|
+
import type { WebhookInfo } from '../webhook/handler.js';
|
|
18
|
+
import type { ProviderBundle } from '../provider-registry.js';
|
|
19
|
+
import type { TrustResolution } from '../security/trust-resolver.js';
|
|
20
|
+
import { type ProcessingDeps } from './processor.js';
|
|
21
|
+
/**
|
|
22
|
+
* Context for dispatching a single matched workflow.
|
|
23
|
+
*
|
|
24
|
+
* Captures every per-workflow closure dependency so the dispatch body is
|
|
25
|
+
* callable from BOTH the same-source path AND the cross-source delegation
|
|
26
|
+
* shell. `crossSource` is the discriminator the helper uses to override the
|
|
27
|
+
* dispatch `deliveryId` so fan-out targets land on their composite dedup
|
|
28
|
+
* slot (`${inbound.deliveryId}:${reg.id}`) instead of the inbound delivery
|
|
29
|
+
* id.
|
|
30
|
+
*/
|
|
31
|
+
export interface WorkflowDispatchContext {
|
|
32
|
+
info: WebhookInfo;
|
|
33
|
+
deps: ProcessingDeps;
|
|
34
|
+
bundle: ProviderBundle;
|
|
35
|
+
payload: unknown;
|
|
36
|
+
repoIdentifier: string;
|
|
37
|
+
credentials: Record<string, unknown>;
|
|
38
|
+
event: SimulatedEvent;
|
|
39
|
+
eventWithFiles: SimulatedEvent;
|
|
40
|
+
ref: string;
|
|
41
|
+
fullLockFile: {
|
|
42
|
+
workflows: readonly LockWorkflow[];
|
|
43
|
+
lockfileHash?: string;
|
|
44
|
+
source: {
|
|
45
|
+
file: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
resolvedOrgId: string;
|
|
49
|
+
workflow: LockWorkflow;
|
|
50
|
+
decision: WorkflowDecision;
|
|
51
|
+
runId: string;
|
|
52
|
+
trustResolution: TrustResolution | undefined;
|
|
53
|
+
lockFileSource: string | undefined;
|
|
54
|
+
/** True only when invoked from the cross-source dispatch shell. */
|
|
55
|
+
crossSource: boolean;
|
|
56
|
+
/** Composite dedup key `${info.deliveryId}:${reg.id}` (cross-source only). */
|
|
57
|
+
crossSourceDeliveryId?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Routing key to use for dispatched QueuedJobInput + log / tracker rows.
|
|
60
|
+
* Same-source: equal to `info.routingKey`. Cross-source: equal to
|
|
61
|
+
* `reg.routingKey` (the registration's owning source, NOT the inbound
|
|
62
|
+
* generic routing key).
|
|
63
|
+
*/
|
|
64
|
+
effectiveRoutingKey?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Provider identifier to use for dispatched QueuedJobInput + tracker rows.
|
|
67
|
+
* Same-source: equal to `info.provider`. Cross-source: equal to
|
|
68
|
+
* `regBundle.normalizer.provider` (the registration's provider type,
|
|
69
|
+
* e.g. 'github').
|
|
70
|
+
*/
|
|
71
|
+
effectiveProvider?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Extra jobConfig fields merged into every dispatched QueuedJobInput by
|
|
74
|
+
* this helper. Cross-source callers use this to inject provenance fields
|
|
75
|
+
* (`crossSource: true`, `inboundRoutingKey`, `inboundEventName`,
|
|
76
|
+
* `workflowRepoUrl`, `workflowRef`, `workflowSha`,
|
|
77
|
+
* `workflowRepoIdentifier`) that downstream agents / dashboards need for
|
|
78
|
+
* correct clone + logging.
|
|
79
|
+
*/
|
|
80
|
+
extraJobConfig?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
export interface DispatchMatchedWorkflowResult {
|
|
83
|
+
/** Number of jobs successfully dispatched (non-rejected). */
|
|
84
|
+
dispatchedJobCount: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Dispatch a single matched workflow.
|
|
88
|
+
*
|
|
89
|
+
* Narrative orchestrator: each phase is a typed helper that returns a typed
|
|
90
|
+
* result the next phase consumes. The function reads top-to-bottom as the
|
|
91
|
+
* pipeline:
|
|
92
|
+
* A. setup → wrapped dispatcher + overlaid info
|
|
93
|
+
* B. cache + build → buildPrep with cache URLs and build-job state
|
|
94
|
+
* C. workflow secrets + ephemeral key → secret bundle
|
|
95
|
+
* D. per-job env evaluation → job env data + deferred-init queue
|
|
96
|
+
* E+F+G. static job dispatch → dispatchedJobs / rejectedJobs
|
|
97
|
+
* H. execution-tracker registration + edges + rejected-mark
|
|
98
|
+
* I. deferred init dispatch (fire-and-forget per job)
|
|
99
|
+
* J. deferred dynamic dispatch (fire-and-forget per dynamic entry)
|
|
100
|
+
*/
|
|
101
|
+
export declare function dispatchMatchedWorkflow(ctx: WorkflowDispatchContext): Promise<DispatchMatchedWorkflowResult>;
|
|
102
|
+
//# sourceMappingURL=dispatch-matched-workflow.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline expression evaluator for pure dynamic functions.
|
|
3
|
+
*
|
|
4
|
+
* Evaluates serialized arrow functions from the lockfile (LockInlineValue)
|
|
5
|
+
* in a sandboxed VM context at dispatch time, eliminating the init-job
|
|
6
|
+
* round-trip for pure functions.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Evaluate an inline expression that returns a string.
|
|
10
|
+
*
|
|
11
|
+
* @param expression - Serialized arrow function, e.g. '(event) => event.ref.split("/").pop()'
|
|
12
|
+
* @param event - Normalized webhook event payload
|
|
13
|
+
* @returns The string result
|
|
14
|
+
* @throws TypeError if result is not a string
|
|
15
|
+
* @throws Error on timeout or sandbox violation
|
|
16
|
+
*/
|
|
17
|
+
export declare function evaluateInlineString(expression: string, event: object): string;
|
|
18
|
+
/**
|
|
19
|
+
* Evaluate an inline expression that returns a Record<string, string>.
|
|
20
|
+
*
|
|
21
|
+
* @param expression - Serialized arrow function, e.g. '(event) => ({ NODE_ENV: event.env })'
|
|
22
|
+
* @param event - Normalized webhook event payload
|
|
23
|
+
* @returns The record result
|
|
24
|
+
* @throws TypeError if result is not a plain object
|
|
25
|
+
* @throws Error on timeout or sandbox violation
|
|
26
|
+
*/
|
|
27
|
+
export declare function evaluateInlineRecord(expression: string, event: object): Record<string, string>;
|
|
28
|
+
//# sourceMappingURL=inline-eval.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve workflow-level `registries:` and `installEnv:` declarations into the
|
|
3
|
+
* per-dispatch fields the agent needs to authenticate `npm install` against
|
|
4
|
+
* private registries.
|
|
5
|
+
*
|
|
6
|
+
* Each `tokenSecret` / `installEnv[]` entry uses the qualified
|
|
7
|
+
* `<environment>:<secret-name>` syntax. The resolver:
|
|
8
|
+
*
|
|
9
|
+
* 1. Parses every qualified ref and groups by environment name.
|
|
10
|
+
* 2. Fires the per-environment protection-rule pipeline once per unique env
|
|
11
|
+
* (branch / trust / concurrency / reviewer / wait-timer). Any non-pass
|
|
12
|
+
* result rejects the whole workflow dispatch — v1 does not yet support
|
|
13
|
+
* workflow-scoped held-runs, so a `hold` from the reviewer-gate is
|
|
14
|
+
* surfaced as a reject with a clear reason.
|
|
15
|
+
* 3. Resolves secrets per environment via `secretResolver.resolveForJob`
|
|
16
|
+
* (which writes its own audit log lines).
|
|
17
|
+
* 4. Validates each registry URL scheme: HTTPS always allowed; `http://`
|
|
18
|
+
* allowed only for loopback / `*.local` hosts OR when the org operator
|
|
19
|
+
* has flipped `org_settings.allow_http_npm_registries=true`.
|
|
20
|
+
* 5. Strips the resolved auth entirely when the contributor-trust tier is
|
|
21
|
+
* not `trusted` (defense in depth: even if a misconfigured environment
|
|
22
|
+
* lets an unknown contributor through the protection-pipeline trust
|
|
23
|
+
* gate, this strip ensures fork PRs never see registry tokens — the
|
|
24
|
+
* install fails naturally because the deps are unreachable).
|
|
25
|
+
*
|
|
26
|
+
* Pure helper: no imports of the dispatch giant. Tested in isolation in
|
|
27
|
+
* `install-secrets-resolver.test.ts`.
|
|
28
|
+
*/
|
|
29
|
+
import type { LockRegistry } from '@kici-dev/engine';
|
|
30
|
+
import type { TrustResolution } from '../security/trust-resolver.js';
|
|
31
|
+
import type { SecretResolver } from '../secrets/secret-resolver.js';
|
|
32
|
+
import type { EnvironmentStore } from '../environments/environment-store.js';
|
|
33
|
+
import { type JobDispatchContext } from '../environments/protection/pipeline.js';
|
|
34
|
+
/** Registry spec carried on the dispatch message (token already resolved). */
|
|
35
|
+
export interface NpmRegistrySpec {
|
|
36
|
+
url: string;
|
|
37
|
+
scope?: string;
|
|
38
|
+
alwaysAuth: boolean;
|
|
39
|
+
token: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ResolveInstallSecretsArgs {
|
|
42
|
+
registries: readonly LockRegistry[] | undefined;
|
|
43
|
+
installEnv: readonly string[] | undefined;
|
|
44
|
+
allowHttpNpmRegistries: boolean;
|
|
45
|
+
resolvedOrgId: string;
|
|
46
|
+
trustResolution: TrustResolution | undefined;
|
|
47
|
+
environmentStore: EnvironmentStore | undefined;
|
|
48
|
+
secretResolver: SecretResolver | undefined;
|
|
49
|
+
protectionContext: JobDispatchContext;
|
|
50
|
+
}
|
|
51
|
+
export type ResolveInstallSecretsResult = {
|
|
52
|
+
decision: 'pass';
|
|
53
|
+
npmRegistries: NpmRegistrySpec[] | undefined;
|
|
54
|
+
installEnvSecrets: Record<string, string> | undefined;
|
|
55
|
+
contributorStripped: boolean;
|
|
56
|
+
} | {
|
|
57
|
+
decision: 'reject';
|
|
58
|
+
reason: string;
|
|
59
|
+
};
|
|
60
|
+
/** Parse `<environment>:<secret-name>`. Returns null on malformed input. */
|
|
61
|
+
export declare function parseQualifiedSecretRef(ref: string): {
|
|
62
|
+
envName: string;
|
|
63
|
+
secretName: string;
|
|
64
|
+
} | null;
|
|
65
|
+
/** Validate a registry URL's scheme against the org's http allow-toggle. */
|
|
66
|
+
export declare function validateRegistryUrlScheme(url: string, allowHttp: boolean): {
|
|
67
|
+
ok: true;
|
|
68
|
+
} | {
|
|
69
|
+
ok: false;
|
|
70
|
+
reason: string;
|
|
71
|
+
};
|
|
72
|
+
export declare function resolveInstallSecrets(args: ResolveInstallSecretsArgs): Promise<ResolveInstallSecretsResult>;
|
|
73
|
+
//# sourceMappingURL=install-secrets-resolver.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manual schedule handler for the orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Dispatches a new run for a cron-scheduled workflow triggered manually
|
|
5
|
+
* from the dashboard UI. Uses direct dispatch (not eventRouter.emit) so
|
|
6
|
+
* the newRunId can be returned synchronously in the WS response.
|
|
7
|
+
*
|
|
8
|
+
* This is intentionally separate from the automatic cron path which uses
|
|
9
|
+
* eventRouter fire-and-forget. The manual path needs request/response
|
|
10
|
+
* correlation to return the newRunId to the dashboard.
|
|
11
|
+
*/
|
|
12
|
+
import type { RerunDeps } from './rerun.js';
|
|
13
|
+
import type { RegistrationIndex } from '../registration/registration-index.js';
|
|
14
|
+
interface ManualScheduleDeps extends RerunDeps {
|
|
15
|
+
registrationIndex: RegistrationIndex;
|
|
16
|
+
}
|
|
17
|
+
export declare function handleManualSchedule(registrationId: string, triggeredBy: string | null, deps: ManualScheduleDeps): Promise<{
|
|
18
|
+
newRunId: string;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=manual-schedule.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DB-backed needs-aware dispatch scheduler ( through).
|
|
3
|
+
*
|
|
4
|
+
* This module is the core of 's behavioral change: it replaces the
|
|
5
|
+
* "concurrent dispatch" model with event-driven scheduling that gates ALL
|
|
6
|
+
* needs edges (static-to-static, static-to-dyn-group, dyn-to-static, dyn-to-dyn).
|
|
7
|
+
*
|
|
8
|
+
* The scheduler is pure DB — no in-memory state. Every scheduling decision is
|
|
9
|
+
* a fresh DB query against execution_jobs + execution_job_needs. This means
|
|
10
|
+
* zero recovery code on orchestrator restart.
|
|
11
|
+
*
|
|
12
|
+
* Entry points:
|
|
13
|
+
* - insertEdgesForRun: called at run start for static-to-static edges
|
|
14
|
+
* - resolveGroupEdges: called on dynamic-eval completion
|
|
15
|
+
* - evaluateDownstreams: called from onJobStatus(terminal)
|
|
16
|
+
* - recomputeNeedsSatisfied: batch recompute after group resolution
|
|
17
|
+
* - checkSchedulerInvariant: Layer 3 defensive check
|
|
18
|
+
* - getFailurePropagationTargets: cascade for transitive skip
|
|
19
|
+
*/
|
|
20
|
+
import type { Kysely } from 'kysely';
|
|
21
|
+
import type { Database } from '../db/types.js';
|
|
22
|
+
import type { NeedsEntry, NeedsGroupEntry } from '@kici-dev/engine';
|
|
23
|
+
/** Result of evaluating downstream jobs after an upstream completes. */
|
|
24
|
+
export interface SchedulerResult {
|
|
25
|
+
jobName: string;
|
|
26
|
+
action: 'dispatch' | 'skip';
|
|
27
|
+
reason?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Minimal lock job shape needed by insertEdgesForRun. */
|
|
30
|
+
interface LockJobLike {
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly needs: readonly (string | NeedsEntry | NeedsGroupEntry)[];
|
|
33
|
+
readonly dependsOnGroups?: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Insert dependency edges at run start for static-to-static needs.
|
|
37
|
+
* NeedsGroupEntry items are skipped (resolved later via resolveGroupEdges).
|
|
38
|
+
* Root jobs (no needs, no dependsOnGroups) are marked needs_satisfied=true.
|
|
39
|
+
*/
|
|
40
|
+
export declare function insertEdgesForRun(db: Kysely<Database>, runId: string, lockJobs: readonly LockJobLike[]): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve dynamic group edges after eval completion.
|
|
43
|
+
*
|
|
44
|
+
* For each dependent static job and each member job name, inserts a concrete
|
|
45
|
+
* edge row. Empty groups (0 members) trigger immediate needs_satisfied=true
|
|
46
|
+
* for dependents.
|
|
47
|
+
*
|
|
48
|
+
* CRITICAL: dependentStaticJobs carries per-job ifFailed policy from the
|
|
49
|
+
* NeedsGroupEntry in the lock file. Without this, all group edges would
|
|
50
|
+
* silently default to 'skip'.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveGroupEdges(db: Kysely<Database>, runId: string, groupName: string, memberJobNames: string[], dependentStaticJobs: Array<{
|
|
53
|
+
jobName: string;
|
|
54
|
+
ifFailed: 'skip' | 'run';
|
|
55
|
+
}>): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Evaluate downstream jobs after an upstream reaches terminal state.
|
|
58
|
+
*
|
|
59
|
+
* This is the core scheduler hook. For each downstream of the completed job:
|
|
60
|
+
* 1. If upstream failed and edge has if_failed='skip', mark downstream as 'skip'
|
|
61
|
+
* 2. Otherwise, check if ALL upstreams are terminal
|
|
62
|
+
* 3. If all satisfied, mark needs_satisfied=true and return for dispatch
|
|
63
|
+
*/
|
|
64
|
+
export declare function evaluateDownstreams(db: Kysely<Database>, runId: string, completedJobName: string, completedStatus: string): Promise<SchedulerResult[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Batch recompute needs_satisfied for specified jobs.
|
|
67
|
+
* Used after group resolution and on orchestrator restart recovery.
|
|
68
|
+
* Returns scheduler results for any jobs that became ready.
|
|
69
|
+
*/
|
|
70
|
+
export declare function recomputeNeedsSatisfied(db: Kysely<Database>, runId: string, jobNames: string[]): Promise<SchedulerResult[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Layer 3: defensive scheduler invariant check.
|
|
73
|
+
*
|
|
74
|
+
* Finds jobs that are stuck: needs_satisfied=false, status='pending',
|
|
75
|
+
* all upstreams are terminal, and no pending group resolution.
|
|
76
|
+
* Returns the names of stuck jobs (empty array = no violation).
|
|
77
|
+
*/
|
|
78
|
+
export declare function checkSchedulerInvariant(db: Kysely<Database>, runId: string): Promise<string[]>;
|
|
79
|
+
/**
|
|
80
|
+
* cascade: find all transitive downstreams that should be skipped
|
|
81
|
+
* due to failure propagation. Only follows edges where if_failed='skip'.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getFailurePropagationTargets(db: Kysely<Database>, runId: string, failedJobName: string): Promise<string[]>;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=needs-scheduler.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook processing pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Splits the historic 1339-line `processWebhook` into typed phase helpers so
|
|
5
|
+
* each piece can be reasoned about independently. The main exported function
|
|
6
|
+
* is a narrative orchestrator that threads the typed results through the
|
|
7
|
+
* pipeline:
|
|
8
|
+
*
|
|
9
|
+
* dedup -> provider -> normalize -> (cross-source dispatch | per-repo path)
|
|
10
|
+
* per-repo path: extract repo + creds -> trust resolution -> lock file fetch
|
|
11
|
+
* -> (no lock file: global dispatch & return)
|
|
12
|
+
* -> security hold + workflow modifications -> default-branch registration
|
|
13
|
+
* -> match triggers -> dispatch matched same-source -> dispatch globals
|
|
14
|
+
* -> forward traces & event log
|
|
15
|
+
*
|
|
16
|
+
* Internal helpers are pure phase functions returning typed results; the only
|
|
17
|
+
* top-level export is `processWebhook`, callable from server.ts / app.ts.
|
|
18
|
+
*/
|
|
19
|
+
import type { WebhookInfo } from '../webhook/handler.js';
|
|
20
|
+
import { type ProcessingDeps } from './processor.js';
|
|
21
|
+
/**
|
|
22
|
+
* Process a webhook through the complete pipeline.
|
|
23
|
+
*
|
|
24
|
+
* Flow:
|
|
25
|
+
* 1. Dedup + provider lookup -> contributor cache invalidation -> normalize
|
|
26
|
+
* 2. Cross-source dispatch (generic webhook fan-out, optional)
|
|
27
|
+
* 3. Extract repo + credentials, handle /kici approval comments
|
|
28
|
+
* 4. Trust resolution for PR events
|
|
29
|
+
* 5. Lock file fetch (with multi-provider fallback)
|
|
30
|
+
* - No lock file: dispatch global workflows for this event (same org) and return
|
|
31
|
+
* 6. Workflow modification detection + security hold check status
|
|
32
|
+
* 7. Default-branch registration
|
|
33
|
+
* 8. Match triggers + dispatch matched same-source workflows
|
|
34
|
+
* 9. Match + dispatch global workflows for OTHER repos
|
|
35
|
+
* 10. Forward Platform trace + record event log
|
|
36
|
+
*/
|
|
37
|
+
export declare function processWebhook(info: WebhookInfo, deps: ProcessingDeps): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=process-webhook.d.ts.map
|