@kici-dev/orchestrator 0.1.27 → 0.2.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/__test-helpers__/mock-db.d.ts +2 -0
- package/dist/agent/dispatcher.d.ts +52 -2
- package/dist/agent/host-roster-reaper.d.ts +1 -2
- package/dist/agent/host-roster.d.ts +34 -0
- package/dist/agent/ownership-refusal.d.ts +12 -0
- package/dist/agent/ownership-tracker.d.ts +64 -16
- package/dist/agent/token-store.d.ts +13 -0
- package/dist/agent-packaging/availability.d.ts +27 -0
- package/dist/agent-packaging/build-package.d.ts +16 -0
- package/dist/agent-packaging/download.d.ts +30 -0
- package/dist/agent-packaging/index.d.ts +9 -0
- package/dist/agent-packaging/install-closure.d.ts +30 -0
- package/dist/agent-packaging/node-binary.d.ts +26 -0
- package/dist/agent-packaging/refresh.d.ts +50 -0
- package/dist/agent-packaging/store.d.ts +15 -0
- package/dist/agent-packaging/upload.d.ts +24 -0
- package/dist/app-on-error.d.ts +29 -0
- package/dist/app.d.ts +56 -4
- package/dist/artifacts/artifact-store.d.ts +233 -0
- package/dist/artifacts/failure-messages.d.ts +46 -0
- package/dist/audit/access-log.d.ts +18 -1
- package/dist/cache/dep-cache.d.ts +15 -0
- package/dist/cache/user-cache.d.ts +37 -0
- package/dist/cancel/cancel-run.d.ts +10 -3
- package/dist/cancel/dashboard-cancel-handler.d.ts +19 -0
- package/dist/cli/api-client.d.ts +22 -1
- package/dist/cli/commands/agent-package.d.ts +34 -0
- package/dist/cli/commands/check-run.d.ts +26 -0
- package/dist/cli/commands/cluster-settings.d.ts +55 -0
- package/dist/cli/commands/dashboard-encryption-key.d.ts +3 -0
- package/dist/cli/commands/db-backup.d.ts +71 -0
- package/dist/cli/commands/orchestrator-service/drain.d.ts +31 -0
- package/dist/cli/commands/orchestrator-service/index.d.ts +7 -4
- package/dist/cli/commands/orchestrator-service/install-env.d.ts +58 -0
- package/dist/cli/commands/secret.d.ts +45 -1
- package/dist/cli/commands/shared/admin-cli-access-log.d.ts +46 -0
- package/dist/cli/commands/shared/versioned-upgrade.d.ts +65 -2
- package/dist/cli/commands/signing-key.d.ts +3 -0
- package/dist/cli/commands/source.d.ts +12 -0
- package/dist/cli/commands/token.d.ts +9 -0
- package/dist/cli/commands/trust-policy.d.ts +48 -0
- package/dist/cli/join.d.ts +1 -1
- package/dist/cli/service/index.d.ts +2 -2
- package/dist/cli/service/instance/manifest.d.ts +17 -0
- package/dist/cli/service/instance/resolve.d.ts +11 -0
- package/dist/cli/wizard/orchestrator-wizard.d.ts +39 -11
- package/dist/cli.js +9818 -3408
- package/dist/cluster/cluster-settings-reader.d.ts +78 -0
- package/dist/cluster/coordinator.d.ts +81 -9
- package/dist/cluster/join-client.d.ts +1 -1
- package/dist/cluster/leader-gated-scheduler.d.ts +50 -0
- package/dist/cluster/orphan-recovery.d.ts +14 -0
- package/dist/cluster/peer-client.d.ts +12 -2
- package/dist/cluster/peer-handler.d.ts +15 -4
- package/dist/cluster/peer-registry.d.ts +12 -0
- package/dist/cluster/verified-issuer-poller.d.ts +11 -0
- package/dist/cluster/verified-issuer.d.ts +63 -0
- package/dist/cold-store/tables/access-log.d.ts +1 -1
- package/dist/cold-store/tables/event-log.d.ts +1 -1
- package/dist/cold-store/tables/execution-jobs.d.ts +1 -1
- package/dist/cold-store/tables/execution-runs.d.ts +1 -1
- package/dist/cold-store/tables/execution-steps.d.ts +1 -1
- package/dist/cold-store/tables/secret-audit-log.d.ts +1 -1
- package/dist/config/loader.d.ts +1 -1
- package/dist/config/resolver.d.ts +2 -1
- package/dist/config/schema.d.ts +8 -6
- package/dist/config/types.d.ts +3 -2
- package/dist/config.d.ts +363 -53
- package/dist/contexts/context-store.d.ts +21 -8
- package/dist/contexts/glob-specificity.d.ts +30 -0
- package/dist/contexts/held-runs.d.ts +51 -19
- package/dist/contexts/protection/aggregate.d.ts +2 -2
- package/dist/contexts/protection/concurrency-gate.d.ts +0 -3
- package/dist/contexts/protection/reviewer-gate.d.ts +0 -3
- package/dist/contexts/protection/satisfiability.d.ts +1 -1
- package/dist/contexts/protection/trust-gate.d.ts +0 -3
- package/dist/contexts/protection/wait-timer-gate.d.ts +0 -3
- package/dist/cron/cron-scheduler.d.ts +24 -4
- package/dist/cron/cron-store.d.ts +21 -7
- package/dist/dashboard/attestation-filters.d.ts +92 -74
- package/dist/dashboard/handler.d.ts +35 -1
- package/dist/db/migration-test-harness.d.ts +41 -0
- package/dist/db/migrations/069_reroute_tunables.d.ts +21 -0
- package/dist/db/migrations/070_execution_runs_failure_class.d.ts +4 -0
- package/dist/db/migrations/071_batch_accumulation.d.ts +26 -0
- package/dist/db/migrations/072_dispatch_queue_run_id_index.d.ts +15 -0
- package/dist/db/migrations/073_org_settings_ingest_concurrency.d.ts +13 -0
- package/dist/db/migrations/074_normalize_zero_concurrency_limit.d.ts +13 -0
- package/dist/db/migrations/075_ingest_overflow_buffer.d.ts +16 -0
- package/dist/db/migrations/076_artifacts.d.ts +19 -0
- package/dist/db/migrations/077_backup_runs.d.ts +13 -0
- package/dist/db/migrations/078_org_settings_backup_staleness.d.ts +12 -0
- package/dist/db/migrations/079_org_settings_scaler_spawn_timeout.d.ts +14 -0
- package/dist/db/migrations/080_cluster_settings.d.ts +17 -0
- package/dist/db/migrations/081_org_settings_queue_timeout.d.ts +19 -0
- package/dist/db/migrations/082_host_s3_reachable.d.ts +16 -0
- package/dist/db/migrations/083_org_settings_artifact_caps.d.ts +18 -0
- package/dist/db/migrations/084_orchestrator_signing_keys.d.ts +20 -0
- package/dist/db/migrations/085_cluster_settings_reroute_flap_grace_ms.d.ts +12 -0
- package/dist/db/migrations/086_cluster_settings_max_fanout_hosts.d.ts +12 -0
- package/dist/db/migrations/087_cluster_settings_event_router_rate_limit.d.ts +12 -0
- package/dist/db/migrations/088_cluster_settings_cache_max_tarball_bytes.d.ts +12 -0
- package/dist/db/migrations/089_cluster_settings_cache_ttl_days.d.ts +12 -0
- package/dist/db/migrations/090_cluster_settings_concurrency_wait_timeout_ms.d.ts +12 -0
- package/dist/db/migrations/091_cluster_settings_agent_token_ttl_ms.d.ts +12 -0
- package/dist/db/migrations/092_cluster_settings_version.d.ts +16 -0
- package/dist/db/migrations/093_org_settings_sandbox_allowlist.d.ts +4 -0
- package/dist/db/migrations/094_dashboard_encryption_keys.d.ts +21 -0
- package/dist/db/migrations/095_dashboard_write_policy_tristate.d.ts +20 -0
- package/dist/db/migrations/096_multi_schedule_cron_last_fired.d.ts +4 -0
- package/dist/db/migrations/097_execution_runs_pr_number.d.ts +4 -0
- package/dist/db/migrations/098_execution_runs_customer_id.d.ts +4 -0
- package/dist/db/migrations/099_cluster_settings_dashboard_verified_issuer.d.ts +21 -0
- package/dist/db/migrations/100_held_runs_hold_type_vocabulary.d.ts +31 -0
- package/dist/db/migrations/101_contexts_hold_expiry_drop_default.d.ts +31 -0
- package/dist/db/migrations/102_dispatch_queue_agent_id.d.ts +20 -0
- package/dist/db/migrations/103_cluster_settings_ownership_db_check_timeout_ms.d.ts +20 -0
- package/dist/db/migrations/104_check_run_terminal_sent.d.ts +22 -0
- package/dist/db/migrations/105_org_trust_policy.d.ts +19 -0
- package/dist/db/migrations/106_cluster_settings_check_run_tracking_ttl_days.d.ts +18 -0
- package/dist/db/migrations/107_check_run_tracking_updated_at_index.d.ts +23 -0
- package/dist/db/repos/dashboard-encryption-keys-repo.d.ts +48 -0
- package/dist/db/repos/signing-keys-repo.d.ts +34 -0
- package/dist/db/types.d.ts +421 -7
- package/dist/deployment/deployment-identity.d.ts +87 -2
- package/dist/diagnostics/checks/backup.d.ts +18 -0
- package/dist/diagnostics/checks/index.d.ts +2 -1
- package/dist/diagnostics/fleet-collector.d.ts +1 -1
- package/dist/drain/drain-controller.d.ts +52 -0
- package/dist/events/batch-accumulator.d.ts +63 -0
- package/dist/events/circuit-breaker.d.ts +9 -3
- package/dist/events/event-emitter.d.ts +31 -0
- package/dist/events/event-retry-scanner.d.ts +12 -2
- package/dist/events/event-router.d.ts +29 -0
- package/dist/firecracker/host-network.d.ts +2 -0
- package/dist/firecracker/net-interfaces.d.ts +14 -0
- package/dist/github-app-name-refresher/github-app-name-refresher.d.ts +18 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +604 -16
- package/dist/lockfile-cache.d.ts +4 -0
- package/dist/lockfile-validate.d.ts +16 -9
- package/dist/metrics/prometheus.d.ts +112 -15
- package/dist/oidc/aws-kms-signer.d.ts +37 -0
- package/dist/oidc/command-signer.d.ts +23 -0
- package/dist/oidc/db-signer.d.ts +48 -0
- package/dist/oidc/id-token-claims.d.ts +22 -9
- package/dist/oidc/jwt.d.ts +5 -2
- package/dist/oidc/local-dev-signer.d.ts +1 -1
- package/dist/oidc/oidc-mint-registration.d.ts +27 -11
- package/dist/oidc/orchestrator-mint.d.ts +97 -0
- package/dist/oidc/orchestrator-signer-factory.d.ts +33 -0
- package/dist/oidc/reconcile-signing-key.d.ts +21 -0
- package/dist/oidc/signer.d.ts +25 -0
- package/dist/oidc/signing-key-status.d.ts +23 -0
- package/dist/orchestrator-core.d.ts +42 -2
- package/dist/pipeline/decorating-secret-resolver.d.ts +3 -2
- package/dist/pipeline/dispatch-matched-workflow.d.ts +41 -0
- package/dist/pipeline/install-secrets-resolver.d.ts +12 -1
- package/dist/pipeline/manual-schedule.d.ts +20 -13
- package/dist/pipeline/pending-workflow-context.d.ts +1 -1
- package/dist/pipeline/process-webhook.d.ts +57 -2
- package/dist/pipeline/processor.d.ts +44 -8
- package/dist/pipeline/rerun.d.ts +12 -13
- package/dist/pipeline/resolve-sandbox-grant.d.ts +28 -0
- package/dist/pipeline/route-or-dispatch-jobs.d.ts +71 -0
- package/dist/pipeline/sandbox-allowlist-reader.d.ts +33 -0
- package/dist/policy/dashboard-write-policy.d.ts +9 -4
- package/dist/provenance/backfill-run.d.ts +1 -0
- package/dist/provenance/trust-root.d.ts +13 -0
- package/dist/providers/generic/normalizer.d.ts +1 -1
- package/dist/providers/github/auth.d.ts +1 -1
- package/dist/providers/github/changed-files.d.ts +14 -6
- package/dist/providers/github/check-status-poster.d.ts +19 -3
- package/dist/providers/github/contributor-resolver.d.ts +1 -1
- package/dist/providers/github/lock-file.d.ts +1 -1
- package/dist/providers/github/normalizer.d.ts +1 -1
- package/dist/providers/github/repo-url.d.ts +1 -1
- package/dist/providers/local/lock-file-fetcher.d.ts +1 -1
- package/dist/providers/local/normalizer.d.ts +1 -1
- package/dist/providers/local/repo-url-builder.d.ts +1 -1
- package/dist/providers/universal-git/changed-files.d.ts +8 -7
- package/dist/providers/universal-git/clone-token.d.ts +1 -1
- package/dist/providers/universal-git/config.d.ts +4 -4
- package/dist/providers/universal-git/index.d.ts +5 -1
- package/dist/providers/universal-git/lock-file.d.ts +6 -1
- package/dist/providers/universal-git/normalizer.d.ts +1 -1
- package/dist/providers/universal-git/repo-url.d.ts +1 -1
- package/dist/queue/cleanup.d.ts +69 -8
- package/dist/queue/job-queue.d.ts +94 -14
- package/dist/queue/scheduled-job.d.ts +2 -2
- package/dist/registration/registration-index.d.ts +1 -1
- package/dist/reporting/agent-failure-category.d.ts +4 -1
- package/dist/reporting/check-run-reporter.d.ts +34 -14
- package/dist/reporting/check-run-tracking-store.d.ts +70 -8
- package/dist/reporting/execution-tracker.d.ts +156 -10
- package/dist/reporting/fs-log-storage.d.ts +31 -2
- package/dist/reporting/job-check-run-completion.d.ts +50 -0
- package/dist/reporting/log-chunk-sink.d.ts +47 -0
- package/dist/reporting/log-retention.d.ts +16 -0
- package/dist/reporting/log-storage.d.ts +64 -4
- package/dist/reporting/log-writer.d.ts +22 -7
- package/dist/reporting/peer-log-normalize.d.ts +14 -0
- package/dist/reporting/run-aggregator.d.ts +32 -32
- package/dist/reporting/s3-log-storage.d.ts +102 -8
- package/dist/routes/admin-auth.d.ts +90 -0
- package/dist/routes/admin-cluster-settings.d.ts +31 -0
- package/dist/routes/admin-events.d.ts +3 -0
- package/dist/routes/admin-orchestrator-drain.d.ts +35 -0
- package/dist/routes/admin-runs.d.ts +9 -0
- package/dist/routes/admin-sources.d.ts +7 -0
- package/dist/routes/admin-trust-policy.d.ts +49 -0
- package/dist/routes/admin.d.ts +15 -1
- package/dist/routes/github-webhook.d.ts +9 -3
- package/dist/routes/provenance-oidc.d.ts +38 -0
- package/dist/routes/verify-attestation.d.ts +21 -0
- package/dist/scaler/bare-metal-backend.d.ts +9 -2
- package/dist/scaler/config.d.ts +25 -4
- package/dist/scaler/container-backend.d.ts +9 -1
- package/dist/scaler/firecracker-backend.d.ts +29 -2
- package/dist/scaler/index.d.ts +1 -1
- package/dist/scaler/manager.d.ts +166 -8
- package/dist/scaler/pending-scale-sweeper.d.ts +35 -0
- package/dist/scaler/types.d.ts +75 -6
- package/dist/secrets/backend-registry.d.ts +32 -1
- package/dist/secrets/dashboard-encryption-key.d.ts +48 -0
- package/dist/secrets/ephemeral-keys.d.ts +16 -0
- package/dist/secrets/pg-secret-store.d.ts +10 -0
- package/dist/secrets/rbac.d.ts +5 -1
- package/dist/secrets/routing-key-scope.d.ts +6 -0
- package/dist/secrets/scope-routing.d.ts +126 -0
- package/dist/secrets/secret-resolver.d.ts +1 -14
- package/dist/secrets/token-manager.d.ts +5 -1
- package/dist/security/contributor-cache.d.ts +9 -1
- package/dist/security/trust-policy-gate.d.ts +117 -0
- package/dist/security/trust-policy-store.d.ts +78 -0
- package/dist/server.js +35769 -25052
- package/dist/sources/source-manager.d.ts +24 -0
- package/dist/stale-detector/stale-run-detector.d.ts +7 -0
- package/dist/standalone.js +34831 -25317
- package/dist/storage/filesystem.d.ts +17 -0
- package/dist/storage/key-discriminator.d.ts +20 -0
- package/dist/storage/s3.d.ts +2 -0
- package/dist/storage/types.d.ts +16 -0
- package/dist/webhook/dedup.d.ts +9 -1
- package/dist/webhook/event-log.d.ts +13 -2
- package/dist/webhook/generic-sources-listener.d.ts +4 -0
- package/dist/webhook/ingest-admission.d.ts +140 -0
- package/dist/webhook/ingest-overflow-buffer.d.ts +27 -0
- package/dist/webhook/ingest-overflow-replayer.d.ts +49 -0
- package/dist/webhook/ingest-overflow-types.d.ts +73 -0
- package/dist/webhook/loop-lag-source.d.ts +40 -0
- package/dist/webhook/observed-relay-guard.d.ts +40 -0
- package/dist/webhook/org-ingest-cap-reader.d.ts +24 -0
- package/dist/webhook/register-source-bundle.d.ts +3 -0
- package/dist/webhook/relay-reinject.d.ts +43 -0
- package/dist/worker/in-memory-job-queue.d.ts +8 -3
- package/dist/worker-core.d.ts +10 -0
- package/dist/ws/agent-api-registry.d.ts +20 -0
- package/dist/ws/agent-handler.d.ts +63 -7
- package/dist/ws/bringup-api.d.ts +99 -0
- package/dist/ws/dashboard-context-handler.d.ts +28 -10
- package/dist/ws/dashboard-run-state-handler.d.ts +31 -0
- package/dist/ws/failure-messages.d.ts +29 -0
- package/dist/ws/oidc-token-relay.d.ts +9 -0
- package/dist/ws/ownership-gate.d.ts +22 -0
- package/dist/ws/platform-client.d.ts +96 -1
- package/dist/ws/replay-chunker.d.ts +37 -0
- package/installer-image-digests.json +3 -3
- package/package.json +22 -21
- package/sbom.spdx.json +1240 -1788
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backup-freshness diagnostic check.
|
|
3
|
+
*
|
|
4
|
+
* Reads the newest `backup_runs.created_at` and reports whether the
|
|
5
|
+
* orchestrator DB has a recent `kici-admin db backup`. FAIL when none was ever
|
|
6
|
+
* recorded, WARN when the newest is older than the effective staleness
|
|
7
|
+
* threshold, else PASS.
|
|
8
|
+
*
|
|
9
|
+
* The threshold is cluster-configurable: the strictest (minimum) non-null
|
|
10
|
+
* `org_settings.backup_staleness_warn_hours` across all orgs, falling back to
|
|
11
|
+
* `config.backupStalenessWarnHours` when no org sets an override. A stale
|
|
12
|
+
* whole-DB backup affects every org, so the tightest org requirement wins.
|
|
13
|
+
*/
|
|
14
|
+
import type { DiagnosticDeps, DiagnosticResult } from '../types.js';
|
|
15
|
+
export declare const DEFAULT_BACKUP_STALENESS_WARN_HOURS = 24;
|
|
16
|
+
export declare function resolveStalenessThresholdHours(deps: DiagnosticDeps): Promise<number>;
|
|
17
|
+
export declare function checkBackupFreshness(deps: DiagnosticDeps): Promise<DiagnosticResult>;
|
|
18
|
+
//# sourceMappingURL=backup.d.ts.map
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { DiagnosticCheck } from '../types.js';
|
|
8
8
|
import { checkDbConnectivity } from './db.js';
|
|
9
|
+
import { checkBackupFreshness } from './backup.js';
|
|
9
10
|
import { checkWsToPlatform } from './ws.js';
|
|
10
11
|
import { checkAgentConnectivity } from './agents.js';
|
|
11
12
|
import { checkDiskSpace } from './disk.js';
|
|
@@ -15,5 +16,5 @@ import { checkScalerProvisioning } from './scaler.js';
|
|
|
15
16
|
import { checkFirecrackerNetwork } from './firecracker-network.js';
|
|
16
17
|
/** All diagnostic checks in display order. */
|
|
17
18
|
export declare const defaultChecks: DiagnosticCheck[];
|
|
18
|
-
export { checkDbConnectivity, checkWsToPlatform, checkAgentConnectivity, checkDiskSpace, checkConfigValidity, checkCertificateExpiry, checkScalerProvisioning, checkFirecrackerNetwork, };
|
|
19
|
+
export { checkDbConnectivity, checkBackupFreshness, checkWsToPlatform, checkAgentConnectivity, checkDiskSpace, checkConfigValidity, checkCertificateExpiry, checkScalerProvisioning, checkFirecrackerNetwork, };
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -12,9 +12,9 @@ import { z } from 'zod';
|
|
|
12
12
|
/** Per-node collection outcome recorded in the fleet manifest. */
|
|
13
13
|
export declare const FleetNodeStatus: z.ZodEnum<{
|
|
14
14
|
error: "error";
|
|
15
|
-
unreachable: "unreachable";
|
|
16
15
|
ok: "ok";
|
|
17
16
|
timeout: "timeout";
|
|
17
|
+
unreachable: "unreachable";
|
|
18
18
|
}>;
|
|
19
19
|
export type FleetNodeStatus = z.infer<typeof FleetNodeStatus>;
|
|
20
20
|
export interface FleetCollectorDeps {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owns the coordinator's ephemeral "draining" state for pre-upgrade quiescing.
|
|
3
|
+
*
|
|
4
|
+
* While draining, the Dispatcher routes every new job to the Pending queue
|
|
5
|
+
* (Model A / job-level drain), the peer heartbeat advertises `draining: true`
|
|
6
|
+
* (siblings stop rerouting here), and the scaler stops spawning fresh agents.
|
|
7
|
+
* Jobs already executing on agents finish; `jobsRunning()` drops monotonically
|
|
8
|
+
* to zero, at which point the coordinator is quiesced and safe to restart.
|
|
9
|
+
*
|
|
10
|
+
* State is in-memory only: an upgrade restart comes back accepting and the
|
|
11
|
+
* existing startup recovery re-dispatches the Pending backlog.
|
|
12
|
+
*/
|
|
13
|
+
export interface DrainControllerDeps {
|
|
14
|
+
/** Sum of activeJobs across all connected agents (agentRegistry). */
|
|
15
|
+
activeJobsTotal: () => number;
|
|
16
|
+
/**
|
|
17
|
+
* Count of dispatch_queue rows in Dispatched status. In the single-coordinator
|
|
18
|
+
* drain-before-upgrade scenario this equals this instance's in-flight jobs; a
|
|
19
|
+
* per-instance ownership column does not exist on dispatch_queue, so a
|
|
20
|
+
* multi-coordinator cluster may over-count here (belt-and-suspenders only —
|
|
21
|
+
* `activeJobsTotal` is the primary signal, and both shrink monotonically once
|
|
22
|
+
* the dispatcher gate stops new claims).
|
|
23
|
+
*/
|
|
24
|
+
dispatchedJobsOwned: () => Promise<number>;
|
|
25
|
+
/**
|
|
26
|
+
* Optional hook fired whenever the draining flag changes, used to drive the
|
|
27
|
+
* `kici_orchestrator_draining` metric. Not fired on a no-op (idempotent) call.
|
|
28
|
+
*/
|
|
29
|
+
onChange?: (draining: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare class DrainController {
|
|
32
|
+
private readonly deps;
|
|
33
|
+
private draining;
|
|
34
|
+
constructor(deps: DrainControllerDeps);
|
|
35
|
+
isDraining(): boolean;
|
|
36
|
+
startDrain(): void;
|
|
37
|
+
stopDrain(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Live quiesce signal: jobs currently executing on agents versus any row this
|
|
40
|
+
* instance already claimed (Dispatched) but whose activeJobs increment has not
|
|
41
|
+
* yet landed. Since draining stops new claims, this set only shrinks, so a
|
|
42
|
+
* poll on it is guaranteed to converge to zero. Uses `Math.max` (not sum) — the
|
|
43
|
+
* Dispatched rows are the durable view of the same jobs the in-memory
|
|
44
|
+
* activeJobs counts, so summing would double-count the common case.
|
|
45
|
+
*/
|
|
46
|
+
jobsRunning(): Promise<number>;
|
|
47
|
+
snapshot(): Promise<{
|
|
48
|
+
draining: boolean;
|
|
49
|
+
jobsRunning: number;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=drain-controller.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Kysely } from 'kysely';
|
|
2
|
+
import type { Database } from '../db/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Durable accumulator backing the `workflowsFailedBatch` trigger.
|
|
5
|
+
*
|
|
6
|
+
* A failed `workflow_complete` event that matches a `workflowsFailedBatch`
|
|
7
|
+
* registration is buffered into a per-(registration, window) row instead of
|
|
8
|
+
* dispatching now. The first failure opens the window; the Raft-leader-only
|
|
9
|
+
* scanner sweeps windows past `expires_at`, emits one `__workflows_failed_batch`
|
|
10
|
+
* event, and deletes the window (cascading its items). The state lives in
|
|
11
|
+
* Postgres (not an in-memory Map) so a node restart mid-window loses nothing.
|
|
12
|
+
*/
|
|
13
|
+
/** A failed run buffered into a batch window. */
|
|
14
|
+
export interface BatchAccumulatorRun {
|
|
15
|
+
runId: string;
|
|
16
|
+
repoIdentifier: string;
|
|
17
|
+
workflowName: string;
|
|
18
|
+
failureClass?: string | null;
|
|
19
|
+
senderUsername?: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** A window swept past its deadline, with the runs it accumulated. */
|
|
22
|
+
export interface SweptBatchWindow {
|
|
23
|
+
windowId: string;
|
|
24
|
+
customerId: string;
|
|
25
|
+
registrationId: string;
|
|
26
|
+
routingKey: string;
|
|
27
|
+
repoIdentifier: string;
|
|
28
|
+
runs: BatchAccumulatorRun[];
|
|
29
|
+
}
|
|
30
|
+
export interface OpenBatchWindowInput {
|
|
31
|
+
registrationId: string;
|
|
32
|
+
customerId: string;
|
|
33
|
+
routingKey: string;
|
|
34
|
+
repoIdentifier: string;
|
|
35
|
+
accumulateForMs: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Open the accumulation window for a registration, or return the existing open
|
|
39
|
+
* one. `opened` is true only for the caller that created the window (the first
|
|
40
|
+
* failure of the burst) so exactly one caller schedules nothing beyond the DB
|
|
41
|
+
* row — the leader scanner owns the flush.
|
|
42
|
+
*
|
|
43
|
+
* Uses `INSERT ... ON CONFLICT (registration_id) DO NOTHING RETURNING id` for an
|
|
44
|
+
* atomic open-once: concurrent failures append to the same window rather than
|
|
45
|
+
* racing to open N windows.
|
|
46
|
+
*/
|
|
47
|
+
export declare function openOrGetBatchWindow(db: Kysely<Database>, input: OpenBatchWindowInput): Promise<{
|
|
48
|
+
windowId: string;
|
|
49
|
+
opened: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
/** Append one failed run to an open window. */
|
|
52
|
+
export declare function appendBatchItem(db: Kysely<Database>, input: {
|
|
53
|
+
windowId: string;
|
|
54
|
+
run: BatchAccumulatorRun;
|
|
55
|
+
}): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Sweep every window whose `expires_at <= now`. For each, in a transaction, load
|
|
58
|
+
* its items, delete the window (cascading the items), and return the runs. Only
|
|
59
|
+
* the Raft leader calls this. Windows with no items (a run that was excluded
|
|
60
|
+
* after opening) still emit — the caller decides whether to skip an empty batch.
|
|
61
|
+
*/
|
|
62
|
+
export declare function sweepExpiredBatchWindows(db: Kysely<Database>, now: Date): Promise<SweptBatchWindow[]>;
|
|
63
|
+
//# sourceMappingURL=batch-accumulator.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EventRouterConfig } from './types.js';
|
|
2
|
+
import type { ClusterSettingsReader } from '../cluster/cluster-settings-reader.js';
|
|
2
3
|
/**
|
|
3
4
|
* Circuit breaker for event loop detection and user-event rate limiting.
|
|
4
5
|
*
|
|
@@ -9,8 +10,9 @@ import type { EventRouterConfig } from './types.js';
|
|
|
9
10
|
*/
|
|
10
11
|
export declare class EventCircuitBreaker {
|
|
11
12
|
private readonly config;
|
|
13
|
+
private readonly clusterSettings?;
|
|
12
14
|
private rateLimiter;
|
|
13
|
-
constructor(config: EventRouterConfig);
|
|
15
|
+
constructor(config: EventRouterConfig, clusterSettings?: ClusterSettingsReader | undefined);
|
|
14
16
|
/**
|
|
15
17
|
* Check if the current chain depth is within limits.
|
|
16
18
|
*/
|
|
@@ -23,11 +25,15 @@ export declare class EventCircuitBreaker {
|
|
|
23
25
|
* sliding 60-second window. Callers key user events by
|
|
24
26
|
* `<sourceRoutingKey>:<eventName>`; system events (`__`-prefixed) are exempt
|
|
25
27
|
* upstream and never reach here.
|
|
28
|
+
*
|
|
29
|
+
* The per-(source routing key + event) limit is the fleet-wide cluster
|
|
30
|
+
* tunable `event_router_rate_limit_per_workflow_per_minute` (live override
|
|
31
|
+
* wins), falling back to the configured default.
|
|
26
32
|
*/
|
|
27
|
-
checkRateLimit(rateKey: string): {
|
|
33
|
+
checkRateLimit(rateKey: string): Promise<{
|
|
28
34
|
allowed: boolean;
|
|
29
35
|
retryAfterMs?: number;
|
|
30
|
-
}
|
|
36
|
+
}>;
|
|
31
37
|
/**
|
|
32
38
|
* Clear all rate limit state (for testing).
|
|
33
39
|
*/
|
|
@@ -14,6 +14,29 @@ export interface WorkflowCompleteData {
|
|
|
14
14
|
name: string;
|
|
15
15
|
status: string;
|
|
16
16
|
}>;
|
|
17
|
+
/** Why the run failed (`RunFailureClass`); carried on the event so Plane B can route on it. */
|
|
18
|
+
failureClass?: string;
|
|
19
|
+
}
|
|
20
|
+
/** One failed run carried in a workflows_failed_batch event. */
|
|
21
|
+
export interface WorkflowsFailedBatchRun {
|
|
22
|
+
runId: string;
|
|
23
|
+
repo: string;
|
|
24
|
+
workflowName: string;
|
|
25
|
+
failureClass?: string;
|
|
26
|
+
senderUsername?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Input data for emitting a __workflows_failed_batch system event.
|
|
30
|
+
* One event per swept accumulation window; `registrationId` targets the single
|
|
31
|
+
* subscribing workflow so the batch dispatches once.
|
|
32
|
+
*/
|
|
33
|
+
export interface WorkflowsFailedBatchData {
|
|
34
|
+
routingKey: string;
|
|
35
|
+
repo: string;
|
|
36
|
+
registrationId: string;
|
|
37
|
+
/** Total failed runs in the window (may exceed `runs.length` when capped). */
|
|
38
|
+
total: number;
|
|
39
|
+
runs: WorkflowsFailedBatchRun[];
|
|
17
40
|
}
|
|
18
41
|
/**
|
|
19
42
|
* Input data for emitting a job_complete system event.
|
|
@@ -46,6 +69,14 @@ export declare class EventEmitter {
|
|
|
46
69
|
* Returns the event ID as delivery receipt.
|
|
47
70
|
*/
|
|
48
71
|
emitWorkflowComplete(data: WorkflowCompleteData): Promise<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Emit a __workflows_failed_batch system event: one synthetic event per swept
|
|
74
|
+
* accumulation window carrying the batched failed runs. Targeted at the single
|
|
75
|
+
* subscribing registration via `payload.registrationId` so the batch workflow
|
|
76
|
+
* dispatches exactly once, no matter how many failures landed in the window.
|
|
77
|
+
* Returns the event ID as delivery receipt.
|
|
78
|
+
*/
|
|
79
|
+
emitWorkflowsFailedBatch(data: WorkflowsFailedBatchData): Promise<string>;
|
|
49
80
|
/**
|
|
50
81
|
* Emit a __job_complete system event with rich metadata.
|
|
51
82
|
* Returns the event ID as delivery receipt.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type Kysely } from 'kysely';
|
|
2
2
|
import type { Database } from '../db/types.js';
|
|
3
3
|
import type { EventStore } from './event-store.js';
|
|
4
|
+
import type { EventEmitter } from './event-emitter.js';
|
|
4
5
|
import type { EventRouterConfig } from './types.js';
|
|
5
6
|
interface EventRetryScannerOptions {
|
|
6
7
|
db: Kysely<Database>;
|
|
7
8
|
eventStore: EventStore;
|
|
9
|
+
eventEmitter: EventEmitter;
|
|
8
10
|
config: EventRouterConfig;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
@@ -32,9 +34,9 @@ interface EventRetryScannerOptions {
|
|
|
32
34
|
export declare class EventRetryScanner {
|
|
33
35
|
private readonly db;
|
|
34
36
|
private readonly eventStore;
|
|
37
|
+
private readonly eventEmitter;
|
|
35
38
|
private readonly config;
|
|
36
|
-
private
|
|
37
|
-
private isLeader;
|
|
39
|
+
private readonly scheduler;
|
|
38
40
|
constructor(options: EventRetryScannerOptions);
|
|
39
41
|
onBecomeLeader(): void;
|
|
40
42
|
onLoseLeadership(): void;
|
|
@@ -43,6 +45,14 @@ export declare class EventRetryScanner {
|
|
|
43
45
|
* One scanner tick. Public for tests; not on the hot path otherwise.
|
|
44
46
|
*/
|
|
45
47
|
tick(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Sweep expired workflows_failed_batch accumulation windows and emit one
|
|
50
|
+
* `__workflows_failed_batch` event per window that accumulated at least one
|
|
51
|
+
* run. The emitted event flows back through the router and dispatches the
|
|
52
|
+
* subscribing workflow exactly once. The run list is capped at
|
|
53
|
+
* `BATCH_MAX_RUNS`; `total` carries the true count.
|
|
54
|
+
*/
|
|
55
|
+
private processBatchWindows;
|
|
46
56
|
private processExpiredLeases;
|
|
47
57
|
private processDueRetries;
|
|
48
58
|
private refreshDlqDepth;
|
|
@@ -7,6 +7,7 @@ import type { EventCircuitBreaker } from './circuit-breaker.js';
|
|
|
7
7
|
import type { TrustStore } from './trust-store.js';
|
|
8
8
|
import type { RegistrationIndex } from '../registration/registration-index.js';
|
|
9
9
|
import type { EventRouterConfig, StoredEvent } from './types.js';
|
|
10
|
+
import type { ClusterSettingsReader } from '../cluster/cluster-settings-reader.js';
|
|
10
11
|
/**
|
|
11
12
|
* Input for emitting an internal event.
|
|
12
13
|
*/
|
|
@@ -41,6 +42,12 @@ export interface EventRouterOptions {
|
|
|
41
42
|
circuitBreaker: EventCircuitBreaker;
|
|
42
43
|
trustStore: TrustStore;
|
|
43
44
|
config: EventRouterConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Fleet-wide settings reader. When present, the per-event insert TTL and the
|
|
47
|
+
* max-dispatch-attempts cap are read live from cluster_settings, falling back
|
|
48
|
+
* to `config.eventTtlSeconds` / `config.maxDispatchAttempts`.
|
|
49
|
+
*/
|
|
50
|
+
clusterSettings?: ClusterSettingsReader;
|
|
44
51
|
onEventMatched: (event: StoredEvent, lockFile: LockFile, matchedWorkflows: WorkflowDecision[], context?: EventMatchContext) => Promise<void>;
|
|
45
52
|
/** Registration index for DB-backed subscription matching. Events match against persistent registrations. */
|
|
46
53
|
registrationIndex: RegistrationIndex;
|
|
@@ -66,6 +73,7 @@ export declare class EventRouter {
|
|
|
66
73
|
private readonly circuitBreaker;
|
|
67
74
|
private readonly trustStore;
|
|
68
75
|
private readonly config;
|
|
76
|
+
private readonly clusterSettings?;
|
|
69
77
|
private readonly onEventMatched;
|
|
70
78
|
private readonly registrationIndex;
|
|
71
79
|
private readonly nodeId;
|
|
@@ -139,6 +147,27 @@ export declare class EventRouter {
|
|
|
139
147
|
* lease pattern fixes.
|
|
140
148
|
*/
|
|
141
149
|
private processSubscriptions;
|
|
150
|
+
/**
|
|
151
|
+
* Partition matched decisions into "dispatch now" and "buffer into a batch
|
|
152
|
+
* window". A decision whose matched trigger is `workflows_failed_batch` and
|
|
153
|
+
* whose event is a failed `__workflow_complete` is buffered (and excluded from
|
|
154
|
+
* the returned dispatch set) so the whole burst notifies once per window.
|
|
155
|
+
*
|
|
156
|
+
* Self-exclusion: a failed `__workflow_complete` whose originating run was
|
|
157
|
+
* itself dispatched by a failure-lifecycle trigger is neither buffered nor
|
|
158
|
+
* dispatched — a broken notifier must not re-trigger the batch on its own
|
|
159
|
+
* failure. The chain-depth breaker remains the backstop for anything missed.
|
|
160
|
+
*/
|
|
161
|
+
private bufferBatchDecisions;
|
|
162
|
+
/** Open (or reuse) the registration's batch window and append the failed run. */
|
|
163
|
+
private bufferBatchFailure;
|
|
164
|
+
/**
|
|
165
|
+
* True when the given run was dispatched by a failure-lifecycle trigger
|
|
166
|
+
* (`workflows_failed_batch` or a `workflow_complete` failed-status trigger),
|
|
167
|
+
* recorded in `execution_runs.trigger_decision.dispatchedByFailureLifecycle`
|
|
168
|
+
* at dispatch time. Used for batch self-exclusion.
|
|
169
|
+
*/
|
|
170
|
+
private isFailureLifecycleRun;
|
|
142
171
|
/**
|
|
143
172
|
* Map a stored event to a trigger type string for RegistrationIndex lookup.
|
|
144
173
|
*
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* nft table name but have separate lifecycles; this module never touches the
|
|
13
13
|
* per-VM rules.
|
|
14
14
|
*/
|
|
15
|
+
import { FIRECRACKER_NET_INTERFACES } from './net-interfaces.js';
|
|
16
|
+
export { FIRECRACKER_NET_INTERFACES };
|
|
15
17
|
/** A single subprocess invocation (no shell). */
|
|
16
18
|
export interface CommandSpec {
|
|
17
19
|
bin: string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface patterns the Firecracker host setup marks unmanaged in
|
|
3
|
+
* NetworkManager.
|
|
4
|
+
*
|
|
5
|
+
* A leaf module on purpose: it imports nothing, so an out-of-package consumer
|
|
6
|
+
* can read the constant without pulling the orchestrator runtime graph in with
|
|
7
|
+
* it. The NetworkManager drift watchdog (`hack/lib/nm-watchdog.ts`) derives its
|
|
8
|
+
* expected-pattern set from here rather than re-typing the patterns — a second
|
|
9
|
+
* copy desyncs silently the moment a pattern is added. `host-network.ts`
|
|
10
|
+
* re-exports it and renders `NM_CONF_CONTENT` from it, so the drop-in and the
|
|
11
|
+
* watchdog can never disagree.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FIRECRACKER_NET_INTERFACES: readonly ['kici-*'];
|
|
14
|
+
//# sourceMappingURL=net-interfaces.d.ts.map
|
|
@@ -15,14 +15,16 @@
|
|
|
15
15
|
* then a `setInterval`; `stop()` clears it. Per-source errors are logged and
|
|
16
16
|
* never abort the loop.
|
|
17
17
|
*/
|
|
18
|
+
/** A source row as returned by listSources() — the slice this module needs. */
|
|
19
|
+
export type SourceIdentityRow = {
|
|
20
|
+
routing_key: string;
|
|
21
|
+
provider: string;
|
|
22
|
+
name: string;
|
|
23
|
+
slug: string | null;
|
|
24
|
+
};
|
|
18
25
|
/** The slice of {@link SourceStore} this module needs. */
|
|
19
26
|
export interface RefreshableSourceStore {
|
|
20
|
-
listSources(): Promise<
|
|
21
|
-
routing_key: string;
|
|
22
|
-
provider: string;
|
|
23
|
-
name: string;
|
|
24
|
-
slug: string | null;
|
|
25
|
-
}>>;
|
|
27
|
+
listSources(): Promise<SourceIdentityRow[]>;
|
|
26
28
|
getSourceWithSecrets(routingKey: string): Promise<{
|
|
27
29
|
provider: string;
|
|
28
30
|
config: string | Record<string, unknown>;
|
|
@@ -50,10 +52,18 @@ export interface RefreshResult {
|
|
|
50
52
|
oldSlug: string | null;
|
|
51
53
|
newSlug: string;
|
|
52
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Refresh one already-resolved GitHub source's identity from GitHub and persist
|
|
57
|
+
* it when the name or slug drifted. The caller supplies the row it already holds,
|
|
58
|
+
* so this never lists the sources table. Throws for a non-GitHub row or missing
|
|
59
|
+
* credentials.
|
|
60
|
+
*/
|
|
61
|
+
export declare function refreshResolvedGithubSource(sourceStore: Pick<RefreshableSourceStore, 'getSourceWithSecrets' | 'updateSource'>, row: SourceIdentityRow, fetchIdentity: FetchGithubAppIdentity): Promise<RefreshResult>;
|
|
53
62
|
/**
|
|
54
63
|
* Re-fetch one GitHub source's identity from GitHub and persist it when the
|
|
55
|
-
* name or slug drifted.
|
|
56
|
-
* refresh`. Throws for a missing or
|
|
64
|
+
* name or slug drifted. Resolves the row by routing key (one sources read) then
|
|
65
|
+
* delegates. Shared by `kici-admin source refresh`. Throws for a missing or
|
|
66
|
+
* non-GitHub routing key.
|
|
57
67
|
*/
|
|
58
68
|
export declare function refreshGithubSourceIdentity(sourceStore: RefreshableSourceStore, routingKey: string, fetchIdentity: FetchGithubAppIdentity): Promise<RefreshResult>;
|
|
59
69
|
export interface GithubAppNameRefresherDeps {
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export { UserCache, DEFAULT_USER_CACHE_QUOTA_BYTES, DEFAULT_USER_CACHE_TTL_MS, t
|
|
|
7
7
|
export { PeerCredentialStore, createPeerCredentialStoreFromUrl, type PeerCredential, type CredentialFileData, } from './cluster/peer-credentials.js';
|
|
8
8
|
export { PeerAuthCoordinator, type AuthDecision, type RejectionAction, } from './cluster/peer-auth-coordinator.js';
|
|
9
9
|
export { JoinTokenManager, createJoinTokenManagerFromUrl } from './cluster/join-token.js';
|
|
10
|
+
export { HeldRunStore, createHeldRunStoreFromUrl, SecurityHoldReason, } from './contexts/held-runs.js';
|
|
11
|
+
export { TrustPolicyStore, createTrustPolicyStoreFromUrl, TrustPolicySource, DEFAULT_TRUST_POLICY, type StoredTrustPolicy, } from './security/trust-policy-store.js';
|
|
10
12
|
export { AdminApiClient } from './cli/api-client.js';
|
|
11
13
|
export { runGithubManifestSetup, type ManifestSetupOptions, type ManifestSetupDeps, } from './cli/commands/source-manifest.js';
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|