@kici-dev/orchestrator 0.0.0 → 0.1.1
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 -6
- package/sbom.spdx.json +14370 -0
- package/index.js +0 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-agnostic LRU cache for lock files.
|
|
3
|
+
*
|
|
4
|
+
* Wraps any LockFileFetcher with an in-memory LRU cache.
|
|
5
|
+
* Cache key: `{repoIdentifier}:{ref}` -- the fetcher handles
|
|
6
|
+
* content-addressable keying internally if the provider supports it.
|
|
7
|
+
*
|
|
8
|
+
* Replaces the old GitHub-specific LockFileCache in github/lockfile.ts.
|
|
9
|
+
*/
|
|
10
|
+
import type { LockFileFetcher, LockFile } from '@kici-dev/engine';
|
|
11
|
+
export declare class LockFileCache {
|
|
12
|
+
private readonly cache;
|
|
13
|
+
private hits;
|
|
14
|
+
private misses;
|
|
15
|
+
constructor(options: {
|
|
16
|
+
max: number;
|
|
17
|
+
ttl: number;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Fetch the lock file for a repository at a specific ref,
|
|
21
|
+
* using the provided fetcher and LRU caching.
|
|
22
|
+
*
|
|
23
|
+
* @param fetcher - Provider-specific lock file fetcher
|
|
24
|
+
* @param repoIdentifier - Provider-specific repo identifier (e.g., "owner/repo")
|
|
25
|
+
* @param ref - Git ref (branch, tag, or commit SHA)
|
|
26
|
+
* @param credentials - Provider-specific credentials
|
|
27
|
+
* @returns Parsed lock file, or null if not found
|
|
28
|
+
*/
|
|
29
|
+
get(fetcher: LockFileFetcher, repoIdentifier: string, ref: string, credentials: unknown): Promise<LockFile | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Get cache statistics for metrics/monitoring.
|
|
32
|
+
*/
|
|
33
|
+
getStats(): {
|
|
34
|
+
hits: number;
|
|
35
|
+
misses: number;
|
|
36
|
+
size: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=lockfile-cache.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory aggregator for agent-pushed metrics.
|
|
3
|
+
*
|
|
4
|
+
* Agents push their OTel metrics snapshots via the WS `agent.metrics` message.
|
|
5
|
+
* This aggregator stores the latest snapshot per agent and produces a
|
|
6
|
+
* cardinality-bounded view by **collapsing all agents within the same
|
|
7
|
+
* scaler pool into one series per (metric, labels, scaler)**. The
|
|
8
|
+
* `agent_id` label is intentionally NOT emitted — including it would
|
|
9
|
+
* make Mimir cardinality grow with the number of agents that have ever
|
|
10
|
+
* existed (every ephemeral firecracker microVM minted a fresh ID), which
|
|
11
|
+
* is unbounded. The caller-side dashboard filters by `scaler` instead,
|
|
12
|
+
* which has a fixed enum of values (`stateful` / `container` /
|
|
13
|
+
* `firecracker` / `bare-metal`).
|
|
14
|
+
*
|
|
15
|
+
* Aggregation rules per metric kind:
|
|
16
|
+
* - counter / upDownCounter / gauge → SUM across agents in the pool
|
|
17
|
+
* - histogram → bucket-by-bucket SUM, plus summed `_count` / `_sum`
|
|
18
|
+
*
|
|
19
|
+
* Trade-off: counter rates are approximate during agent churn. If
|
|
20
|
+
* agent A reports `100` at t1 and disconnects, then agent B starts
|
|
21
|
+
* fresh at `0` for t2, the combined series steps 100 → 0 — which
|
|
22
|
+
* Prometheus interprets as a reset and `rate()` handles correctly.
|
|
23
|
+
* Over a longer window though (e.g. a day with many ephemeral agents
|
|
24
|
+
* appearing + disappearing), the integrated count can under-count.
|
|
25
|
+
* The orchestrator-side counters (`kici_orch_*`) are the canonical
|
|
26
|
+
* source for absolute totals; the agent counters here are for live
|
|
27
|
+
* "what's happening right now" panels.
|
|
28
|
+
*
|
|
29
|
+
* Cleanup: after an agent disconnects, its snapshot is retained for one
|
|
30
|
+
* configurable retention period (default 30s, ~2x scrape interval) so
|
|
31
|
+
* Prometheus can scrape it at least once before it disappears.
|
|
32
|
+
*/
|
|
33
|
+
/** Shape of a single metric data point pushed by the agent. */
|
|
34
|
+
export interface MetricSnapshot {
|
|
35
|
+
name: string;
|
|
36
|
+
type: 'counter' | 'histogram' | 'gauge' | 'upDownCounter';
|
|
37
|
+
value?: number;
|
|
38
|
+
labels?: Record<string, string>;
|
|
39
|
+
buckets?: Array<{
|
|
40
|
+
le: number;
|
|
41
|
+
count: number;
|
|
42
|
+
}>;
|
|
43
|
+
count?: number;
|
|
44
|
+
sum?: number;
|
|
45
|
+
}
|
|
46
|
+
export declare class AgentMetricsAggregator {
|
|
47
|
+
private store;
|
|
48
|
+
private defaultRetentionMs;
|
|
49
|
+
/**
|
|
50
|
+
* Optional lookup: agentId → scaler backend name (e.g. `container`,
|
|
51
|
+
* `firecracker`, `bare-metal`). Returning null marks the agent as
|
|
52
|
+
* static / stateful — we then stamp the `scaler` label as `'stateful'`.
|
|
53
|
+
* Wired from ScalerManager.getBackendName in production. Tests can
|
|
54
|
+
* leave it undefined; in that case the `scaler` label is omitted.
|
|
55
|
+
*/
|
|
56
|
+
private readonly getScalerForAgent?;
|
|
57
|
+
constructor(opts?: {
|
|
58
|
+
retentionMs?: number;
|
|
59
|
+
getScalerForAgent?: (agentId: string) => string | null;
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the `scaler` label for one agentId. Centralized so both the
|
|
63
|
+
* structured snapshot (Mimir push) and the Prometheus text
|
|
64
|
+
* exporter (HTTP /metrics) stamp identical values.
|
|
65
|
+
*/
|
|
66
|
+
private resolveScalerLabel;
|
|
67
|
+
/** Store or replace metrics for an agent. */
|
|
68
|
+
update(agentId: string, metrics: MetricSnapshot[]): void;
|
|
69
|
+
/** Mark an agent as disconnected (start the retention countdown). */
|
|
70
|
+
markDisconnected(agentId: string): void;
|
|
71
|
+
/** Remove entries where disconnectedAt + retentionMs < now. */
|
|
72
|
+
cleanup(retentionMs?: number): void;
|
|
73
|
+
/**
|
|
74
|
+
* Build a stable string key for grouping metrics across agents. The
|
|
75
|
+
* key encodes the metric name plus every label except `agent_id`
|
|
76
|
+
* (which is dropped) and including the resolved `scaler`. Sorted so
|
|
77
|
+
* insertion order can't sneak into the key.
|
|
78
|
+
*/
|
|
79
|
+
private groupKey;
|
|
80
|
+
/**
|
|
81
|
+
* Walk every stored snapshot and bucket points into per-(metric, labels)
|
|
82
|
+
* groups, summing counter / gauge values and merging histogram buckets
|
|
83
|
+
* across all agents in each bucket. The bucketing key includes the
|
|
84
|
+
* `scaler` label and excludes `agent_id`, so the output is one series
|
|
85
|
+
* per (metric, labels-except-agent_id, scaler) combination.
|
|
86
|
+
*
|
|
87
|
+
* Returns one MetricSnapshot per group so both `getStructuredSnapshot`
|
|
88
|
+
* and `getPrometheusText` can iterate the same shape.
|
|
89
|
+
*/
|
|
90
|
+
private aggregateAcrossAgents;
|
|
91
|
+
/**
|
|
92
|
+
* Produce a structured snapshot of all stored agent metrics in the
|
|
93
|
+
* `OrchMetrics['metrics']` wire shape — same format the orchestrator's
|
|
94
|
+
* own `MetricsReporter` produces from its OTel exporter. Used by the
|
|
95
|
+
* Platform-bound Mimir push pipeline so agent metrics land in Mimir
|
|
96
|
+
* per-org alongside `kici_orch_*` .
|
|
97
|
+
*
|
|
98
|
+
* Output is **already aggregated across agents per scaler** — see the
|
|
99
|
+
* class docstring for the cardinality rationale and counter trade-off.
|
|
100
|
+
*
|
|
101
|
+
* Runs `cleanup()` first so disconnected agents past their retention
|
|
102
|
+
* window stop being emitted.
|
|
103
|
+
*/
|
|
104
|
+
getStructuredSnapshot(): MetricSnapshot[];
|
|
105
|
+
/**
|
|
106
|
+
* Produce Prometheus exposition text for all stored agent metrics,
|
|
107
|
+
* aggregated across agents per scaler. See `getStructuredSnapshot` for
|
|
108
|
+
* the aggregation rules. Runs auto-cleanup before generating output.
|
|
109
|
+
*
|
|
110
|
+
* Groups metrics by name and emits `# TYPE` directives so Prometheus
|
|
111
|
+
* correctly interprets histograms, counters, and gauges.
|
|
112
|
+
*/
|
|
113
|
+
getPrometheusText(): string;
|
|
114
|
+
private formatHistogram;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=agent-metrics-aggregator.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Periodic metrics reporter that collects OTel metrics and pushes them
|
|
3
|
+
* to the Platform via WebSocket as `orch.metrics` messages.
|
|
4
|
+
*
|
|
5
|
+
* The Platform aggregates these metrics from all orchestrators and exposes
|
|
6
|
+
* them on its `/metrics` endpoint for Prometheus scraping.
|
|
7
|
+
*/
|
|
8
|
+
import type { OrchMetrics } from '@kici-dev/engine';
|
|
9
|
+
import type { AgentMetricsAggregator } from './agent-metrics-aggregator.js';
|
|
10
|
+
export declare class MetricsReporter {
|
|
11
|
+
private timer?;
|
|
12
|
+
private readonly send;
|
|
13
|
+
private readonly intervalMs;
|
|
14
|
+
private readonly agentMetricsAggregator?;
|
|
15
|
+
constructor(opts: {
|
|
16
|
+
send: (msg: OrchMetrics) => void;
|
|
17
|
+
intervalMs?: number;
|
|
18
|
+
/**
|
|
19
|
+
* If provided, the reporter concatenates the aggregator's structured
|
|
20
|
+
* snapshot onto its own snapshot before sending — so agent metrics
|
|
21
|
+
* (`kici_agent_*`) land in Mimir per-org alongside `kici_orch_*`.
|
|
22
|
+
* Each agent metric carries an `agent_id` label injected by the
|
|
23
|
+
* aggregator. See the metrics enforcement plan.
|
|
24
|
+
*/
|
|
25
|
+
agentMetricsAggregator?: AgentMetricsAggregator;
|
|
26
|
+
});
|
|
27
|
+
/** Start periodic metric collection and push. */
|
|
28
|
+
start(): void;
|
|
29
|
+
/** Stop the periodic reporter. */
|
|
30
|
+
stop(): void;
|
|
31
|
+
/** Collect current metrics and send as orch.metrics message. */
|
|
32
|
+
collectAndSend(): Promise<void>;
|
|
33
|
+
/** Collect a snapshot of all current OTel metrics. */
|
|
34
|
+
collectSnapshot(): Promise<OrchMetrics['metrics']>;
|
|
35
|
+
/** Map OTel DataPointType to wire format type string. */
|
|
36
|
+
private mapDataPointType;
|
|
37
|
+
/** Extract string labels from OTel Attributes. */
|
|
38
|
+
private extractLabels;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=metrics-reporter.d.ts.map
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/** Set the current number of active agents. */
|
|
2
|
+
export declare function setAgentsActive(value: number): void;
|
|
3
|
+
/** Set the current config version number. */
|
|
4
|
+
export declare function setConfigVersion(value: number): void;
|
|
5
|
+
/** Set the current number of stale runs detected. */
|
|
6
|
+
export declare function setStaleRunsCurrent(value: number): void;
|
|
7
|
+
interface ScalerUsageRow {
|
|
8
|
+
scaler: string;
|
|
9
|
+
machinePool?: string;
|
|
10
|
+
cpus: number;
|
|
11
|
+
memBytes: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Replace the current scaler-usage breakdown.
|
|
15
|
+
*
|
|
16
|
+
* Called by ScalerManager whenever a reservation lands or releases. Caller is
|
|
17
|
+
* responsible for including a `scaler="__global__"` row for the orchestrator-wide
|
|
18
|
+
* total and one row per active machine pool (with `machinePool` set) reflecting
|
|
19
|
+
* the on-disk ledger snapshot. Per-scaler rows omit `machinePool`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setScalerUsageBreakdown(rows: ScalerUsageRow[]): void;
|
|
22
|
+
/** Increment the spawn-refusal counter (called by ScalerManager when a request fails the cap check). */
|
|
23
|
+
export declare function incScalerSpawnRefusals(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Update the dispatch-queue depth breakdown used by the Prometheus gauges.
|
|
26
|
+
*
|
|
27
|
+
* Called by the orchestrator's periodic depth refresher after polling the
|
|
28
|
+
* JobQueue. Normalizes the input so the gauge callback can emit explicit
|
|
29
|
+
* zero series for known statuses even when the queue is empty.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setDispatchQueueDepthBreakdown(snapshot: {
|
|
32
|
+
byStatus: Partial<Record<'pending' | 'dispatched', number>>;
|
|
33
|
+
byLabel: Record<string, number>;
|
|
34
|
+
}): void;
|
|
35
|
+
/**
|
|
36
|
+
* Total webhooks received by the orchestrator.
|
|
37
|
+
* Labels:
|
|
38
|
+
* - source: relay (from Platform) | direct (webhook endpoint)
|
|
39
|
+
* - event: GitHub event type (push, pull_request, etc.)
|
|
40
|
+
*/
|
|
41
|
+
export declare const webhooksReceivedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
42
|
+
/**
|
|
43
|
+
* Total webhooks processed with outcome.
|
|
44
|
+
* Labels:
|
|
45
|
+
* - result: matched (triggered workflow) | skipped (no match) | error (processing failure)
|
|
46
|
+
*/
|
|
47
|
+
export declare const webhooksProcessedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
48
|
+
/**
|
|
49
|
+
* Duration of trigger matching operations (lock file evaluation).
|
|
50
|
+
* Buckets: 1ms to 5s covering fast rejects through complex evaluations.
|
|
51
|
+
*/
|
|
52
|
+
export declare const triggerMatchDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
53
|
+
/**
|
|
54
|
+
* Total deduplication cache hits (duplicate webhooks rejected).
|
|
55
|
+
*/
|
|
56
|
+
export declare const dedupHitsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
57
|
+
/**
|
|
58
|
+
* Total source cache hits (`.kici/` source tarball found for content hash).
|
|
59
|
+
*/
|
|
60
|
+
export declare const sourceCacheHitsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
61
|
+
/**
|
|
62
|
+
* Total source cache misses (no source tarball cached for content hash).
|
|
63
|
+
*/
|
|
64
|
+
export declare const sourceCacheMissesTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
65
|
+
/**
|
|
66
|
+
* Total dep cache hits (dependency tarball found for lockfile hash).
|
|
67
|
+
*/
|
|
68
|
+
export declare const depCacheHitsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
69
|
+
/**
|
|
70
|
+
* Total dep cache misses (no dependency tarball for lockfile hash).
|
|
71
|
+
*/
|
|
72
|
+
export declare const depCacheMissesTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
73
|
+
/**
|
|
74
|
+
* Duration of build agent operations in seconds.
|
|
75
|
+
* Tracks how long it takes to compile a workflow bundle via a build agent.
|
|
76
|
+
* Buckets: 1s to 10min covering fast to slow compilations.
|
|
77
|
+
*/
|
|
78
|
+
export declare const buildDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
79
|
+
/**
|
|
80
|
+
* Total execution runs tracked.
|
|
81
|
+
* Labels:
|
|
82
|
+
* - status: running | success | failed | cancelled
|
|
83
|
+
*/
|
|
84
|
+
export declare const executionsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
85
|
+
/**
|
|
86
|
+
* Duration of execution runs in seconds.
|
|
87
|
+
* Buckets: 1s to 30min covering fast to long pipelines.
|
|
88
|
+
*/
|
|
89
|
+
export declare const executionDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
90
|
+
/**
|
|
91
|
+
* Total steps executed.
|
|
92
|
+
* Labels:
|
|
93
|
+
* - status: running | success | failed | skipped
|
|
94
|
+
*/
|
|
95
|
+
export declare const stepsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
96
|
+
/**
|
|
97
|
+
* Total GitHub check run API calls (create + update + stale_cleanup).
|
|
98
|
+
* Labels:
|
|
99
|
+
* - operation: create | update | stale_cleanup
|
|
100
|
+
*/
|
|
101
|
+
export declare const githubCheckRunTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
102
|
+
/**
|
|
103
|
+
* Total log chunks received from agents.
|
|
104
|
+
*/
|
|
105
|
+
export declare const logChunksReceivedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
106
|
+
/**
|
|
107
|
+
* Total log bytes written to storage backend.
|
|
108
|
+
*/
|
|
109
|
+
export declare const logBytesStoredTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
110
|
+
/**
|
|
111
|
+
* Total number of scaler config reload operations.
|
|
112
|
+
* Labels:
|
|
113
|
+
* - result: attempted | success | failed
|
|
114
|
+
*/
|
|
115
|
+
export declare const scalerConfigReloadsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
116
|
+
/**
|
|
117
|
+
* Total number of config reload operations.
|
|
118
|
+
* Labels:
|
|
119
|
+
* - result: success | failed | attempted
|
|
120
|
+
* - source: sighup | http | cluster | cli
|
|
121
|
+
*/
|
|
122
|
+
export declare const configReloadTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
123
|
+
/**
|
|
124
|
+
* Total number of stale runs detected and marked as failed.
|
|
125
|
+
*/
|
|
126
|
+
export declare const staleRunsDetectedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
127
|
+
/**
|
|
128
|
+
* Time between job becoming stale and detection (seconds).
|
|
129
|
+
* Buckets: 10s to 10min covering typical scan intervals.
|
|
130
|
+
*/
|
|
131
|
+
export declare const staleDetectionDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
132
|
+
/**
|
|
133
|
+
* Number of webhook-trigger registrations matched when an inbound generic
|
|
134
|
+
* webhook fans out across sources in the same org.
|
|
135
|
+
*
|
|
136
|
+
* Recorded once per inbound webhook on the cross-source dispatch path
|
|
137
|
+
* (including zero-match cases). Label `event` is the inbound event name
|
|
138
|
+
* (NOT the literal 'generic_webhook' — see Pitfall 1 in 28.4 RESEARCH).
|
|
139
|
+
*
|
|
140
|
+
* Buckets cover small fan-outs (1-2 typical) through large org-wide fan-outs.
|
|
141
|
+
*
|
|
142
|
+
* NOTE: dashboard panel for `kici_cross_source_fanout_size` not yet added —
|
|
143
|
+
* follow-up per .claude/rules/monitoring.md (out of scope for plan 28.4-02).
|
|
144
|
+
*/
|
|
145
|
+
export declare const crossSourceFanoutSize: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
146
|
+
/**
|
|
147
|
+
* Errors encountered during cross-source webhook dispatch.
|
|
148
|
+
*
|
|
149
|
+
* Labels:
|
|
150
|
+
* - reason: 'clone_token' (issuance failed) | 'bundle_missing' (registration's
|
|
151
|
+
* provider bundle not found in registry)
|
|
152
|
+
*
|
|
153
|
+
* NOTE: dashboard panel for `kici_cross_source_errors_total` not yet added —
|
|
154
|
+
* follow-up per .claude/rules/monitoring.md (out of scope for plan 28.4-02).
|
|
155
|
+
*/
|
|
156
|
+
export declare const crossSourceErrorsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
157
|
+
/**
|
|
158
|
+
* Counter for universal-git source registration errors at orchestrator
|
|
159
|
+
* startup or config reload. A non-zero rate indicates at least one
|
|
160
|
+
* `generic_webhook_sources` row with a non-null `git_config` could not be
|
|
161
|
+
* promoted to a provider bundle — the row stays in the DB but its routing
|
|
162
|
+
* key has no bundle, so webhooks for it will fall through to the generic
|
|
163
|
+
* bundle's payload-only path.
|
|
164
|
+
*
|
|
165
|
+
* Labels:
|
|
166
|
+
* - reason: 'invalid_config' (Zod parse failed) | 'bundle_build' (factory
|
|
167
|
+
* threw) | 'registration' (providerRegistry.registerByRoutingKey threw)
|
|
168
|
+
*/
|
|
169
|
+
export declare const universalGitRegistrationErrorsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
170
|
+
/**
|
|
171
|
+
* Counter for trust-resolution paths that were refused because the
|
|
172
|
+
* numeric provider id was absent (on either side) or did not match an
|
|
173
|
+
* identity link. Under the strict policy these refusals resolve the
|
|
174
|
+
* contributor to `unknown` regardless of username overlap.
|
|
175
|
+
*
|
|
176
|
+
* Labels:
|
|
177
|
+
* - reason: 'event_missing' (webhook payload had no sender.id) |
|
|
178
|
+
* 'link_missing' (a username-matched link has provider_user_id NULL) |
|
|
179
|
+
* 'id_mismatch' (a username-matched link has a different provider_user_id)
|
|
180
|
+
*/
|
|
181
|
+
export declare const trustMatchRefusedNoIdTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
182
|
+
export declare const eventDispatchSuccessTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
183
|
+
export declare const eventRetryTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
184
|
+
export declare const eventDlqTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
185
|
+
export declare const eventLeaseExpirationsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
186
|
+
export declare const eventAttemptsHistogram: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
187
|
+
/** Set the current DLQ depth gauge. Refreshed by the leader-only retry scanner each tick. */
|
|
188
|
+
export declare function setEventDlqDepth(value: number): void;
|
|
189
|
+
/**
|
|
190
|
+
* Reason values for the `kici_orch_install_secrets_decisions_total` counter.
|
|
191
|
+
* The single source of truth — the resolver and tests both reference these
|
|
192
|
+
* constants, so adding a new reject path requires extending the union here.
|
|
193
|
+
*/
|
|
194
|
+
export declare const InstallSecretsDecisionReason: {
|
|
195
|
+
readonly Ok: "ok";
|
|
196
|
+
readonly MalformedRef: "malformed_ref";
|
|
197
|
+
readonly InvalidUrlScheme: "invalid_url_scheme";
|
|
198
|
+
readonly MissingEnvStore: "missing_env_store";
|
|
199
|
+
readonly MissingSecretResolver: "missing_secret_resolver";
|
|
200
|
+
readonly EnvNotFound: "env_not_found";
|
|
201
|
+
readonly ProtectionRuleBlock: "protection_rule_block";
|
|
202
|
+
readonly MissingToken: "missing_token";
|
|
203
|
+
readonly MissingInstallEnv: "missing_install_env";
|
|
204
|
+
};
|
|
205
|
+
export type InstallSecretsDecisionReason = (typeof InstallSecretsDecisionReason)[keyof typeof InstallSecretsDecisionReason];
|
|
206
|
+
/**
|
|
207
|
+
* Channel label for `kici_orch_install_secrets_npm_registry_used_total`.
|
|
208
|
+
* - `registries` is Option A (workflow-level `registries:` block).
|
|
209
|
+
* - `install_env` is Option C (committed `.kici/.npmrc` + `installEnv:`).
|
|
210
|
+
*/
|
|
211
|
+
export declare const InstallSecretsChannel: {
|
|
212
|
+
readonly Registries: "registries";
|
|
213
|
+
readonly InstallEnv: "install_env";
|
|
214
|
+
};
|
|
215
|
+
export type InstallSecretsChannel = (typeof InstallSecretsChannel)[keyof typeof InstallSecretsChannel];
|
|
216
|
+
/**
|
|
217
|
+
* Total install-secrets resolution decisions.
|
|
218
|
+
*
|
|
219
|
+
* Labels:
|
|
220
|
+
* - decision: pass | reject
|
|
221
|
+
* - reason: ok (only with `pass`), or one of the reject reasons enumerated in `InstallSecretsDecisionReason`
|
|
222
|
+
*
|
|
223
|
+
* Pass series are emitted exactly once per resolver call that does any work
|
|
224
|
+
* (workflows declaring neither `registries:` nor `installEnv:` are NOT
|
|
225
|
+
* counted — that's the trivial early-return path and dashboard rates would
|
|
226
|
+
* be dominated by it).
|
|
227
|
+
*/
|
|
228
|
+
export declare const installSecretsDecisionsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
229
|
+
/**
|
|
230
|
+
* Total registry / installEnv entries that successfully resolved on a
|
|
231
|
+
* passing dispatch. Each entry contributes one increment, so a workflow
|
|
232
|
+
* with two `registries:` rows and one `installEnv:` entry adds three.
|
|
233
|
+
*
|
|
234
|
+
* Labels:
|
|
235
|
+
* - channel: registries (Option A workflow block) | install_env (Option C committed .npmrc + installEnv:)
|
|
236
|
+
* - provider: static today (long-lived `tokenSecret`); reserved for the typed RegistryProvider (aws-codeartifact, gcp-artifact-registry, …) when that lands
|
|
237
|
+
* - scope: the npm scope string like `@my-org`, the literal `default` for a no-scope default registry, or `-` for install_env entries (no scope concept on Option C)
|
|
238
|
+
*/
|
|
239
|
+
export declare const installSecretsRegistryUsedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
240
|
+
/**
|
|
241
|
+
* Total dispatches where the orchestrator stripped registry tokens because
|
|
242
|
+
* the resolved contributor trust tier was not `trusted` (fork PRs from
|
|
243
|
+
* unknown contributors). Defense-in-depth: even if a misconfigured
|
|
244
|
+
* environment lacks a `minimum_trust` rule, this strip prevents tokens
|
|
245
|
+
* from leaving the orchestrator for those dispatches.
|
|
246
|
+
*
|
|
247
|
+
* Labels:
|
|
248
|
+
* - trust_tier: unknown | known (the `trusted` tier does not strip and therefore never fires this counter)
|
|
249
|
+
*/
|
|
250
|
+
export declare const installSecretsContributorStrippedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
251
|
+
/**
|
|
252
|
+
* Per-environment latency of `secretResolver.resolveForJob` calls in the
|
|
253
|
+
* install-secrets path. Buckets mirror `triggerMatchDurationSeconds`:
|
|
254
|
+
* 1ms → 5s covers fast Postgres reads through pathological Vault timeouts.
|
|
255
|
+
*
|
|
256
|
+
* Labels:
|
|
257
|
+
* - environment: the environment name referenced in the qualified `<environment>:<secret>` ref (per-org count is typically <10)
|
|
258
|
+
*/
|
|
259
|
+
export declare const installSecretsTokenResolutionDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
260
|
+
export {};
|
|
261
|
+
//# sourceMappingURL=prometheus.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Success/failure counter for each tick of each scheduled job. */
|
|
2
|
+
export declare const jobRunsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
|
|
3
|
+
/** Histogram of per-tick duration, seconds. */
|
|
4
|
+
export declare const jobDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
|
|
5
|
+
/** Unix timestamp (seconds) of the most recent successful tick. */
|
|
6
|
+
export declare const jobLastSuccessTimestamp: {
|
|
7
|
+
set(labels: Record<string, string>, value: number): void;
|
|
8
|
+
reset(): void;
|
|
9
|
+
};
|
|
10
|
+
/** Unix timestamp (seconds) of the most recent failed tick. */
|
|
11
|
+
export declare const jobLastFailureTimestamp: {
|
|
12
|
+
set(labels: Record<string, string>, value: number): void;
|
|
13
|
+
reset(): void;
|
|
14
|
+
};
|
|
15
|
+
/** Count of consecutive failures since last success. Resets to 0 on success. */
|
|
16
|
+
export declare const jobConsecutiveFailures: {
|
|
17
|
+
set(labels: Record<string, string>, value: number): void;
|
|
18
|
+
reset(): void;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=scheduled-jobs.d.ts.map
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared orchestrator bootstrap logic.
|
|
3
|
+
*
|
|
4
|
+
* Both server.ts (platform/hybrid) and standalone.ts (independent) delegate to
|
|
5
|
+
* bootstrapOrchestrator() for all startup/shutdown work that is identical
|
|
6
|
+
* between the two modes. Mode-specific behavior is injected via the
|
|
7
|
+
* OrchestratorHooks interface.
|
|
8
|
+
*
|
|
9
|
+
* This eliminates ~1300 lines of duplication that previously existed across
|
|
10
|
+
* the two entry points.
|
|
11
|
+
*/
|
|
12
|
+
import { type ColdStore } from '@kici-dev/shared';
|
|
13
|
+
import type { AppConfig } from './config.js';
|
|
14
|
+
import { ConfigReloader } from './config/reload.js';
|
|
15
|
+
import { AgentRegistry } from './agent/registry.js';
|
|
16
|
+
import { JobQueue } from './queue/job-queue.js';
|
|
17
|
+
import { EventLogWriter } from './webhook/event-log.js';
|
|
18
|
+
import { AccessLogWriter } from './audit/access-log.js';
|
|
19
|
+
import { Dispatcher } from './agent/dispatcher.js';
|
|
20
|
+
import { LockFileCache } from './lockfile-cache.js';
|
|
21
|
+
import { DedupCache } from './webhook/dedup.js';
|
|
22
|
+
import { ObserverRegistry } from './ws/observer-registry.js';
|
|
23
|
+
import { AgentMetricsAggregator } from './metrics/agent-metrics-aggregator.js';
|
|
24
|
+
import { SourceLocationStore } from './app.js';
|
|
25
|
+
import { type PeerHeartbeat } from '@kici-dev/engine';
|
|
26
|
+
import { ScalerManager } from './scaler/index.js';
|
|
27
|
+
import type { ScalerConfig } from './scaler/index.js';
|
|
28
|
+
import type { CacheStorage } from './storage/index.js';
|
|
29
|
+
import { SourceCache, BuildCoordinator, DepCache, PendingBuildTracker, PendingInitTracker, PendingDynamicTracker } from './cache/index.js';
|
|
30
|
+
import { CommitStatusReporter } from './reporting/commit-status.js';
|
|
31
|
+
import { StepLogBuffer } from './reporting/step-log-buffer.js';
|
|
32
|
+
import { type LogStorage } from './reporting/log-storage.js';
|
|
33
|
+
import { ExecutionTracker, type ExecutionTrackerDeps } from './reporting/execution-tracker.js';
|
|
34
|
+
import { LogWriter } from './reporting/log-writer.js';
|
|
35
|
+
import { PeerRegistry, PeerClient, createPeerHandler, RaftNode, OrphanRecovery, RunCoordinator } from './cluster/index.js';
|
|
36
|
+
import { SourceStore, SourceManager } from './sources/index.js';
|
|
37
|
+
import { PgSecretStore, AuditLogger, SecretResolver } from './secrets/index.js';
|
|
38
|
+
import type { SecretStore } from '@kici-dev/engine';
|
|
39
|
+
import type { AdminRouteDeps } from './routes/admin.js';
|
|
40
|
+
import { AgentTokenStore } from './agent/token-store.js';
|
|
41
|
+
import { OwnershipTracker } from './agent/ownership-tracker.js';
|
|
42
|
+
import { EventRouter } from './events/event-router.js';
|
|
43
|
+
import { EventEmitter } from './events/event-emitter.js';
|
|
44
|
+
import { TrustStore } from './events/trust-store.js';
|
|
45
|
+
import { GenericSourceManager } from './webhook/generic-sources.js';
|
|
46
|
+
import { RegistrationStore } from './registration/registration-store.js';
|
|
47
|
+
import { RegistrationIndex } from './registration/registration-index.js';
|
|
48
|
+
import { CronScheduler } from './cron/cron-scheduler.js';
|
|
49
|
+
import { ProviderRegistry } from './provider-registry.js';
|
|
50
|
+
import { JoinHandler } from './cluster/join-handler.js';
|
|
51
|
+
import type { Kysely } from 'kysely';
|
|
52
|
+
import type { Database } from './db/types.js';
|
|
53
|
+
import type pg from 'pg';
|
|
54
|
+
/**
|
|
55
|
+
* All subsystems that are created during bootstrap.
|
|
56
|
+
* Passed to hooks so mode-specific code can wire callbacks.
|
|
57
|
+
*/
|
|
58
|
+
export interface OrchestratorSubsystems {
|
|
59
|
+
config: AppConfig;
|
|
60
|
+
db: Kysely<Database>;
|
|
61
|
+
pool: pg.Pool;
|
|
62
|
+
providerRegistry: ProviderRegistry;
|
|
63
|
+
agentRegistry: AgentRegistry;
|
|
64
|
+
dispatcher: Dispatcher;
|
|
65
|
+
queue: JobQueue;
|
|
66
|
+
scalerManager: ScalerManager | null;
|
|
67
|
+
scalerConfig: ScalerConfig | null;
|
|
68
|
+
cacheStorage: CacheStorage | undefined;
|
|
69
|
+
sourceCache: SourceCache | undefined;
|
|
70
|
+
depCache: DepCache | undefined;
|
|
71
|
+
buildCoordinator: BuildCoordinator | undefined;
|
|
72
|
+
pendingBuilds: PendingBuildTracker | undefined;
|
|
73
|
+
pendingInits: PendingInitTracker;
|
|
74
|
+
pendingDynamics: PendingDynamicTracker;
|
|
75
|
+
commitStatusReporter: CommitStatusReporter;
|
|
76
|
+
stepLogBuffer: StepLogBuffer;
|
|
77
|
+
sourceLocationStore: SourceLocationStore;
|
|
78
|
+
logStorage: LogStorage;
|
|
79
|
+
logWriter: LogWriter;
|
|
80
|
+
observerRegistry: ObserverRegistry;
|
|
81
|
+
executionTracker: ExecutionTracker;
|
|
82
|
+
secretResolver: SecretResolver | null;
|
|
83
|
+
adminDeps: AdminRouteDeps | undefined;
|
|
84
|
+
pgSecretStore: PgSecretStore | undefined;
|
|
85
|
+
tokenStore: AgentTokenStore;
|
|
86
|
+
ownershipTracker: OwnershipTracker;
|
|
87
|
+
lockFileCache: LockFileCache;
|
|
88
|
+
dedup: DedupCache;
|
|
89
|
+
eventRouter: EventRouter;
|
|
90
|
+
eventEmitter: EventEmitter;
|
|
91
|
+
genericSourceManager: GenericSourceManager;
|
|
92
|
+
trustStore: TrustStore;
|
|
93
|
+
registrationStore: RegistrationStore;
|
|
94
|
+
registrationIndex: RegistrationIndex;
|
|
95
|
+
cronScheduler: CronScheduler;
|
|
96
|
+
peerRegistry: PeerRegistry;
|
|
97
|
+
raft: RaftNode;
|
|
98
|
+
coordinator: RunCoordinator;
|
|
99
|
+
orphanRecovery: OrphanRecovery;
|
|
100
|
+
peerHandler: ReturnType<typeof createPeerHandler>;
|
|
101
|
+
peerClients: Map<string, PeerClient>;
|
|
102
|
+
getLocalInventory: () => Omit<PeerHeartbeat, 'type'>;
|
|
103
|
+
broadcastHeartbeatToAllPeers: () => void;
|
|
104
|
+
broadcastAgentTokenRevoke: (tokenId: string) => void;
|
|
105
|
+
joinHandler: JoinHandler;
|
|
106
|
+
configReloader: ConfigReloader;
|
|
107
|
+
localConfigVersion: number;
|
|
108
|
+
sourceStore: SourceStore;
|
|
109
|
+
sourceManager: SourceManager;
|
|
110
|
+
/** Inbound webhook delivery log writer (event_log table + object-storage payloads). */
|
|
111
|
+
eventLogWriter: EventLogWriter;
|
|
112
|
+
/** Access log writer (read + mutation attribution for dashboard + admin). */
|
|
113
|
+
accessLogWriter: AccessLogWriter;
|
|
114
|
+
/**
|
|
115
|
+
* Long-lived cold-store handle. Read paths (dashboard, CLI) use this
|
|
116
|
+
* for transparent fallback to S3 when a row has aged out of PG. The
|
|
117
|
+
* scheduled archive cycle constructs its own ephemeral instance per
|
|
118
|
+
* tick (so SIGHUP-driven config reload picks up new bucket / prefix
|
|
119
|
+
* values without a restart) — these two instances are independent.
|
|
120
|
+
* `null` when cold-store is not enabled in the env.
|
|
121
|
+
*/
|
|
122
|
+
coldStore: ColdStore | null;
|
|
123
|
+
/**
|
|
124
|
+
* In-memory aggregator for agent-pushed metrics. Constructed once at
|
|
125
|
+
* subsystem-build time so both the HTTP `/metrics` exposition path
|
|
126
|
+
* (orchestrator-side) and the Platform-bound MetricsReporter (which
|
|
127
|
+
* concatenates the agent snapshot before WS push so agent metrics
|
|
128
|
+
* land in Mimir per-org alongside `kici_orch_*`) reference the same
|
|
129
|
+
* store. the metrics enforcement plan.
|
|
130
|
+
*/
|
|
131
|
+
agentMetricsAggregator: AgentMetricsAggregator;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Mode-specific hooks injected by each entry point.
|
|
135
|
+
*/
|
|
136
|
+
export interface OrchestratorHooks {
|
|
137
|
+
/** Logger prefix for mode-specific messages */
|
|
138
|
+
logPrefix: string;
|
|
139
|
+
/**
|
|
140
|
+
* Extra ExecutionTracker callbacks (e.g., Platform-mode forwards execution
|
|
141
|
+
* status and step status to the relay).
|
|
142
|
+
*/
|
|
143
|
+
executionTrackerExtras?: (subsystems: OrchestratorSubsystems) => {
|
|
144
|
+
onExecutionStatusChange?: ExecutionTrackerDeps['onExecutionStatusChange'];
|
|
145
|
+
onStepStatusForward?: ExecutionTrackerDeps['onStepStatusForward'];
|
|
146
|
+
onJobStatusChange?: ExecutionTrackerDeps['onJobStatusChange'];
|
|
147
|
+
onRunEventEmit?: ExecutionTrackerDeps['onRunEventEmit'];
|
|
148
|
+
orgId?: string;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Called after the secrets subsystem is initialized.
|
|
152
|
+
* Server.ts uses this to create SecretResolver; standalone doesn't.
|
|
153
|
+
*/
|
|
154
|
+
onSecretsInitialized?: (ctx: {
|
|
155
|
+
pgSecretStore: PgSecretStore;
|
|
156
|
+
backendStores: Map<string, SecretStore>;
|
|
157
|
+
db: Kysely<Database>;
|
|
158
|
+
auditLogger: AuditLogger;
|
|
159
|
+
}) => SecretResolver | null;
|
|
160
|
+
/**
|
|
161
|
+
* Called after all subsystems are built, before HTTP server starts.
|
|
162
|
+
* Mode-specific wiring (PlatformClient creation, peer client setup, etc.)
|
|
163
|
+
*
|
|
164
|
+
* Returns mode-specific dependencies to pass to createApp() and
|
|
165
|
+
* additional shutdown steps.
|
|
166
|
+
*/
|
|
167
|
+
onSubsystemsReady: (subsystems: OrchestratorSubsystems) => Promise<{
|
|
168
|
+
/** Extra dependencies to merge into createApp() */
|
|
169
|
+
appDepsExtras?: Record<string, unknown>;
|
|
170
|
+
/** Extra ConfigReloader deps beyond shared ones */
|
|
171
|
+
configReloaderExtras?: {
|
|
172
|
+
onProviderChange?: (newConfig: AppConfig, oldConfig: AppConfig, subsystems: OrchestratorSubsystems) => Promise<void>;
|
|
173
|
+
onPlatformReconnect?: (newConfig: AppConfig) => Promise<void>;
|
|
174
|
+
};
|
|
175
|
+
/** Extra shutdown steps in order (run before shared shutdown) */
|
|
176
|
+
shutdownExtras?: Array<{
|
|
177
|
+
label: string;
|
|
178
|
+
fn: () => Promise<void> | void;
|
|
179
|
+
}>;
|
|
180
|
+
/** Called after HTTP server starts (e.g., PlatformClient.connect) */
|
|
181
|
+
onServerStarted?: () => Promise<void>;
|
|
182
|
+
}>;
|
|
183
|
+
/**
|
|
184
|
+
* Mode startup log message.
|
|
185
|
+
*/
|
|
186
|
+
startupLogMessage: (port: number) => string;
|
|
187
|
+
}
|
|
188
|
+
export declare function bootstrapOrchestrator(config: AppConfig, hooks: OrchestratorHooks, options?: {
|
|
189
|
+
otelSdk?: {
|
|
190
|
+
shutdown(): Promise<void>;
|
|
191
|
+
};
|
|
192
|
+
}): Promise<void>;
|
|
193
|
+
//# sourceMappingURL=orchestrator-core.d.ts.map
|