@kici-dev/orchestrator 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/agent/token-store.d.ts +4 -0
  2. package/dist/app.d.ts +27 -0
  3. package/dist/audit/access-log.d.ts +4 -0
  4. package/dist/cache/pending-inits.d.ts +3 -2
  5. package/dist/cancel/cancel-run.d.ts +2 -0
  6. package/dist/cli/api-client.d.ts +10 -0
  7. package/dist/cli/commands/attestations-list.d.ts +49 -0
  8. package/dist/cli/commands/attestations-retry.d.ts +28 -0
  9. package/dist/cli/commands/attestations-reverify.d.ts +18 -0
  10. package/dist/cli/commands/attestations.d.ts +4 -0
  11. package/dist/cli/commands/cluster.d.ts +3 -0
  12. package/dist/cli/commands/shared/versioned-upgrade.d.ts +52 -0
  13. package/dist/cli/local-github-ingress-url.d.ts +8 -0
  14. package/dist/cli.js +3308 -1011
  15. package/dist/cluster/cluster-identity.d.ts +11 -0
  16. package/dist/cluster/reconcile-identity.d.ts +50 -0
  17. package/dist/cold-store/load-access-log-range.d.ts +4 -0
  18. package/dist/config.d.ts +4 -0
  19. package/dist/dashboard/attestation-filters.d.ts +131 -0
  20. package/dist/dashboard/handler.d.ts +56 -4
  21. package/dist/db/migrations/054_local_working_tree.d.ts +15 -0
  22. package/dist/db/migrations/055_agent_token_mandatory_labels.d.ts +18 -0
  23. package/dist/db/migrations/056_execution_jobs_environments.d.ts +17 -0
  24. package/dist/db/migrations/057_step_concurrency.d.ts +4 -0
  25. package/dist/db/migrations/058_access_log_agent_label.d.ts +4 -0
  26. package/dist/db/migrations/059_attestation_verdict.d.ts +4 -0
  27. package/dist/db/migrations/060_run_trigger_actor.d.ts +4 -0
  28. package/dist/db/migrations/061_execution_runs_environment_id.d.ts +4 -0
  29. package/dist/db/migrations/062_execution_runs_agent_label.d.ts +4 -0
  30. package/dist/db/migrations/063_access_log_agent_label_index.d.ts +10 -0
  31. package/dist/db/migrations/064_execution_jobs_skipped_environments.d.ts +17 -0
  32. package/dist/db/migrations/065_pending_attestations.d.ts +22 -0
  33. package/dist/db/migrations/066_pending_attestations_rejected.d.ts +13 -0
  34. package/dist/db/types.d.ts +113 -0
  35. package/dist/environments/protection/aggregate.d.ts +43 -0
  36. package/dist/environments/protection/satisfiability.d.ts +69 -0
  37. package/dist/events/circuit-breaker.d.ts +8 -5
  38. package/dist/events/event-router.d.ts +12 -4
  39. package/dist/events/event-store.d.ts +21 -3
  40. package/dist/events/trust-store.d.ts +6 -1
  41. package/dist/events/types.d.ts +6 -1
  42. package/dist/helpers/rate-limiter.d.ts +17 -2
  43. package/dist/index.js +11 -1
  44. package/dist/metrics/prometheus.d.ts +6 -0
  45. package/dist/orchestrator-core.d.ts +8 -0
  46. package/dist/pipeline/dispatch-matched-workflow.d.ts +8 -0
  47. package/dist/pipeline/flatten-lock-steps.d.ts +11 -0
  48. package/dist/pipeline/inline-eval.d.ts +2 -1
  49. package/dist/pipeline/job-environments.d.ts +71 -0
  50. package/dist/pipeline/manual-schedule.d.ts +23 -1
  51. package/dist/pipeline/process-webhook.d.ts +14 -1
  52. package/dist/pipeline/rerun.d.ts +1 -1
  53. package/dist/pipeline/test-pipeline.d.ts +15 -0
  54. package/dist/provenance/attestation-retrier.d.ts +92 -0
  55. package/dist/provenance/backfill-run.d.ts +41 -0
  56. package/dist/provenance/pending-attestations-repo.d.ts +64 -0
  57. package/dist/provenance/trust-root.d.ts +24 -0
  58. package/dist/provenance/verify-at-ingest.d.ts +31 -0
  59. package/dist/reporting/agent-failure-category.d.ts +27 -0
  60. package/dist/reporting/agent-run-result-mapper.d.ts +13 -0
  61. package/dist/reporting/execution-tracker.d.ts +38 -6
  62. package/dist/reporting/run-aggregator.d.ts +165 -0
  63. package/dist/reporting/step-log-reader.d.ts +39 -0
  64. package/dist/routes/admin-access-log.d.ts +2 -1
  65. package/dist/routes/admin-registrations.d.ts +8 -0
  66. package/dist/routes/admin-runs.d.ts +7 -0
  67. package/dist/routes/admin.d.ts +14 -0
  68. package/dist/routes/github-webhook.d.ts +37 -0
  69. package/dist/routes/health.d.ts +9 -0
  70. package/dist/routes/webhooks.d.ts +2 -4
  71. package/dist/secrets/index.d.ts +1 -1
  72. package/dist/server.js +5326 -2100
  73. package/dist/sources/source-store.d.ts +6 -0
  74. package/dist/stale-detector/workflow-deadline-detector.d.ts +25 -0
  75. package/dist/standalone.js +19787 -17304
  76. package/dist/storage/loopback-guard.d.ts +49 -0
  77. package/dist/webhook/dedup.d.ts +14 -0
  78. package/dist/ws/agent-handler.d.ts +38 -1
  79. package/dist/ws/oidc-token-relay.d.ts +31 -21
  80. package/dist/ws/orch-rpc.d.ts +9 -0
  81. package/dist/ws/platform-client.d.ts +53 -1
  82. package/dist/ws/test-relay-handlers.d.ts +2 -0
  83. package/installer-image-digests.json +3 -3
  84. package/package.json +6 -8
  85. package/sbom.spdx.json +62 -57
  86. package/dist/secrets/crypto.d.ts +0 -49
@@ -19,11 +19,15 @@ export declare class AgentTokenStore {
19
19
  * Static tokens have no expiry and are intended for manually-registered agents.
20
20
  *
21
21
  * @param opts.labels - Optional agent labels this token is authorized for.
22
+ * @param opts.mandatoryLabels - Optional taint labels (a Kubernetes-taint-style
23
+ * gate): a static agent registering with this token only accepts a job when
24
+ * every label here appears in the job's required labels. Undefined = no taint.
22
25
  * @param opts.createdBy - Optional creator identifier (e.g. "cli:admin").
23
26
  * @returns The plaintext token (shown once) and the DB row ID.
24
27
  */
25
28
  createStatic(opts: {
26
29
  labels?: string[];
30
+ mandatoryLabels?: string[];
27
31
  createdBy?: string;
28
32
  }): Promise<{
29
33
  token: string;
package/dist/app.d.ts CHANGED
@@ -37,6 +37,7 @@ import type { PendingBuildTracker } from './cache/index.js';
37
37
  import type { PendingInitTracker } from './cache/index.js';
38
38
  import type { PendingDynamicTracker } from './cache/index.js';
39
39
  import type { CacheStorage } from './storage/types.js';
40
+ import type { ProvenanceTrustRoot } from './provenance/trust-root.js';
40
41
  import { type CheckRunReporter } from './reporting/check-run-reporter.js';
41
42
  import type { ExecutionTracker } from './reporting/execution-tracker.js';
42
43
  import type { LogWriter } from './reporting/log-writer.js';
@@ -53,6 +54,8 @@ import type { FleetAgentCollector } from './ws/fleet-agent-collector.js';
53
54
  import type { FleetTopology } from './diagnostics/fleet-topology.js';
54
55
  import type { TokenManager } from './secrets/token-manager.js';
55
56
  import type { SecretResolver } from './secrets/secret-resolver.js';
57
+ import type { VerifyInboundDeps } from './webhook/verify-inbound.js';
58
+ import type { SourceStore } from './sources/source-store.js';
56
59
  import { type AdminRouteDeps } from './routes/admin.js';
57
60
  import type { RegistrationStore } from './registration/registration-store.js';
58
61
  import type { RegistrationIndex } from './registration/registration-index.js';
@@ -82,6 +85,12 @@ export interface AppDependencies {
82
85
  db: Kysely<Database>;
83
86
  pool: pg.Pool;
84
87
  registry: AgentRegistry;
88
+ /**
89
+ * Warmth latch surfaced on `GET /ready`. Returns `true` only once the
90
+ * orchestrator boot sequence has finished. When provided, `/ready` returns
91
+ * `503` until boot completes. Absent → warm defaults to `true`.
92
+ */
93
+ isWarm?: () => boolean;
85
94
  /** Host roster store for runsOnAll fan-out resolution. */
86
95
  hostRosterStore?: HostRosterStore;
87
96
  dispatcher: Dispatcher;
@@ -90,6 +99,19 @@ export interface AppDependencies {
90
99
  lockFileCache: LockFileCache;
91
100
  providerRegistry: ProviderRegistry;
92
101
  platformClient?: PlatformClient;
102
+ /**
103
+ * Fulfil deferred attestations on demand (mints in this process, which owns
104
+ * the Platform WS). Backs `POST /api/v1/admin/attestations/retry`. Wired only
105
+ * in coordinator mode where the retrier exists.
106
+ */
107
+ retryAttestations?: (opts: {
108
+ runId?: string;
109
+ includeRejected?: boolean;
110
+ }) => Promise<{
111
+ minted: number;
112
+ stillPending: number;
113
+ rejected: number;
114
+ }>;
93
115
  scalerManager?: ScalerManager;
94
116
  /** Bundle cache for compiled workflow bundles. Optional — requires S3 storage. */
95
117
  sourceCache?: SourceCache;
@@ -108,6 +130,8 @@ export interface AppDependencies {
108
130
  dispatchCacheRefs?: DispatchCacheRefTracker;
109
131
  /** Cache storage backend (S3) for metadata operations on upload completion. */
110
132
  cacheStorage?: CacheStorage;
133
+ /** Provenance trust root used to verify build-provenance bundles at ingest. */
134
+ provenanceTrustRoot?: ProvenanceTrustRoot;
111
135
  /**
112
136
  * Filesystem cache backend handle. Only set when KICI_STORAGE_TYPE is
113
137
  * `filesystem`. Drives the /api/v1/cache/blob/* HTTP route that serves and
@@ -166,6 +190,9 @@ export interface AppDependencies {
166
190
  eventEmitter?: EventEmitter;
167
191
  /** Generic webhook source manager. Optional -- if not set, generic webhooks are disabled. */
168
192
  genericSourceManager?: GenericSourceManager;
193
+ /** GitHub direct-ingress route deps (hybrid/independent only). Optional -- if not set, the direct GitHub ingress route is not mounted. */
194
+ githubSourceStore?: SourceStore;
195
+ githubVerifyDeps?: VerifyInboundDeps;
169
196
  /** Trust store for cross-repo event trust. Optional -- if not set, trust management admin routes are unavailable. */
170
197
  trustStore?: TrustStore;
171
198
  /** Observer registry for broadcasting status/log updates to CLI observers. Optional -- if not set, observer features are inactive. */
@@ -36,6 +36,10 @@ export interface AccessLogQueryFilter {
36
36
  toTimestamp?: Date | string;
37
37
  /** Full-text search over error_message (trigram-indexed). */
38
38
  q?: string;
39
+ /** Exact-match filter on the agent provenance label (`agent_label` column). */
40
+ agentLabel?: string;
41
+ /** When true, return only agent-attributed rows (`agent_label IS NOT NULL`). */
42
+ agentOnly?: boolean;
39
43
  limit?: number;
40
44
  cursor?: string;
41
45
  }
@@ -3,13 +3,14 @@
3
3
  *
4
4
  * The orchestrator dispatches an init job for dynamic environment resolution
5
5
  * and waits for the agent to return the resolved field values
6
- * (environmentName, env, concurrencyGroup). The underlying tracker logic lives
6
+ * (environmentNames, env, concurrencyGroup). The underlying tracker logic lives
7
7
  * in `PendingTracker<InitResult>`; this subclass wires the init-specific
8
8
  * logger prefix and disconnect error.
9
9
  */
10
10
  import { PendingTracker } from './pending-tracker.js';
11
11
  export interface InitResult {
12
- environmentName?: string;
12
+ /** Resolved bound-environment names, in merge order (one per `environments` element). */
13
+ environmentNames?: string[];
13
14
  env?: Record<string, string>;
14
15
  concurrencyGroup?: string;
15
16
  /**
@@ -33,6 +33,8 @@ export interface CancelRunOptions {
33
33
  force?: boolean;
34
34
  /** Attribution stamped into execution_runs.cancelled_by. */
35
35
  cancelledBy?: string;
36
+ /** Agent provenance label stamped into execution_runs.cancelled_by_agent_label. */
37
+ cancelledByAgentLabel?: string | null;
36
38
  }
37
39
  export interface CancelRunResult {
38
40
  /** Number of `job.cancel` messages dispatched to agents (running jobs). */
@@ -206,6 +206,7 @@ export declare class AdminApiClient {
206
206
  revokeToken(id: string): Promise<void>;
207
207
  createAgentToken(opts: {
208
208
  labels?: string[];
209
+ mandatoryLabels?: string[];
209
210
  }): Promise<{
210
211
  id: string;
211
212
  token: string;
@@ -373,6 +374,13 @@ export declare class AdminApiClient {
373
374
  }): Promise<{
374
375
  jobs: Array<Record<string, unknown>>;
375
376
  }>;
377
+ /**
378
+ * Fetch the machine-first, provenance-tagged structured run result: typed
379
+ * job DAG, per-step exit codes / durations / statuses, derived failure
380
+ * category. Untrusted fields are envelope-tagged; secret values are never
381
+ * returned (only secret-output key names).
382
+ */
383
+ getRunStructured(runId: string): Promise<Record<string, unknown>>;
376
384
  /**
377
385
  * Fetch the scrub status of the run's ephemeral key. Never returns the
378
386
  * key material itself — only `{ exists, createdAt }`.
@@ -436,6 +444,8 @@ export declare class AdminApiClient {
436
444
  from?: string;
437
445
  to?: string;
438
446
  q?: string;
447
+ agentLabel?: string;
448
+ agentOnly?: boolean;
439
449
  limit?: number;
440
450
  cursor?: string;
441
451
  }): Promise<{
@@ -0,0 +1,49 @@
1
+ /**
2
+ * `kici-admin attestations list` runner — a read-only projection of the
3
+ * orchestrator `attestations` table into a JSON envelope mirroring
4
+ * `runs list --json`'s shape. The DB read is injected so the row→envelope
5
+ * mapping is unit-testable without a Postgres connection (mirrors
6
+ * attestations-retry.ts's injected-transport pattern).
7
+ */
8
+ import type { Kysely } from 'kysely';
9
+ import type { Database } from '../../db/types.js';
10
+ /** One attestation row as read from the orchestrator DB (snake_case columns). */
11
+ export interface AttestationListDbRow {
12
+ id: string;
13
+ run_id: string;
14
+ job_id: string;
15
+ subject_name: string;
16
+ verify_status: string;
17
+ created_at: Date;
18
+ }
19
+ /** One attestation as rendered in the CLI JSON envelope (camelCase). */
20
+ export interface AttestationListItem {
21
+ id: string;
22
+ runId: string;
23
+ jobId: string;
24
+ subjectName: string;
25
+ verifyStatus: string;
26
+ createdAt: string;
27
+ }
28
+ /** Scope + bound for a list read. Filters are applied by the read fn. */
29
+ export interface AttestationListOptions {
30
+ limit: number;
31
+ runId?: string;
32
+ jobId?: string;
33
+ }
34
+ /** The `--json` envelope (mirrors `runs list --json`'s `{ runs: [...] }`). */
35
+ export interface AttestationListResult {
36
+ attestations: AttestationListItem[];
37
+ }
38
+ /**
39
+ * Map the injected DB read into the CLI envelope. `limit` / `runId` / `jobId`
40
+ * are honored by the injected `read` fn (the real one is a Kysely query); this
41
+ * runner owns only the row→envelope projection, so it stays pure and testable.
42
+ */
43
+ export declare function runAttestationList(read: (opts: AttestationListOptions) => Promise<AttestationListDbRow[]>, opts: AttestationListOptions): Promise<AttestationListResult>;
44
+ /**
45
+ * Build the real DB read: a Kysely query over `attestations`, newest first,
46
+ * with optional run/job filters and a row cap.
47
+ */
48
+ export declare function readAttestations(db: Kysely<Database>): (opts: AttestationListOptions) => Promise<AttestationListDbRow[]>;
49
+ //# sourceMappingURL=attestations-list.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `kici-admin attestations retry` runner. Triggers an immediate drain of the
3
+ * deferred-attestation outbox on the running orchestrator via the admin API —
4
+ * minting happens in the orchestrator process, which owns the authenticated
5
+ * Platform WebSocket. `--run-id` scopes to one run; otherwise the whole outbox
6
+ * drains (the `--all-pending` flag is the explicit form of the default).
7
+ */
8
+ export interface AttestationRetryOptions {
9
+ runId?: string;
10
+ allPending?: boolean;
11
+ includeRejected?: boolean;
12
+ }
13
+ export interface AttestationRetryResult {
14
+ minted: number;
15
+ stillPending: number;
16
+ rejected: number;
17
+ }
18
+ /**
19
+ * Post the retry request through the injected transport (the admin API POST)
20
+ * and return the counts. Validates that the scope is unambiguous. When
21
+ * `includeRejected` is set, previously terminally-rejected rows are re-armed
22
+ * and re-attempted in the same drain.
23
+ */
24
+ export declare function runAttestationRetry(post: (body: {
25
+ runId?: string;
26
+ includeRejected?: boolean;
27
+ }) => Promise<AttestationRetryResult>, opts: AttestationRetryOptions): Promise<AttestationRetryResult>;
28
+ //# sourceMappingURL=attestations-retry.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { Kysely } from 'kysely';
2
+ import type { Database } from '../../db/types.js';
3
+ import type { CacheStorage } from '../../storage/types.js';
4
+ import type { ProvenanceTrustRoot } from '../../provenance/trust-root.js';
5
+ /**
6
+ * Backfill / refresh attestation verdicts. By default it re-evaluates only rows
7
+ * that have no usable verdict yet (`pending` / `unverifiable`) — the rollout
8
+ * path for rows recorded before verify-at-ingest, or before an org configured
9
+ * provenance. With `--all` it re-evaluates every row. Idempotent: re-running
10
+ * over already-verified rows (when `--all`) recomputes the same verdict.
11
+ */
12
+ export declare function reverifyAttestations(db: Kysely<Database>, trustRoot: ProvenanceTrustRoot, storage: CacheStorage | undefined, opts: {
13
+ all: boolean;
14
+ }): Promise<{
15
+ updated: number;
16
+ scanned: number;
17
+ }>;
18
+ //# sourceMappingURL=attestations-reverify.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { AdminApiClient } from '../api-client.js';
3
+ export declare function registerAttestationsCommands(program: Command, getClient: () => AdminApiClient): void;
4
+ //# sourceMappingURL=attestations.d.ts.map
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function registerClusterCommands(program: Command): void;
3
+ //# sourceMappingURL=cluster.d.ts.map
@@ -27,6 +27,7 @@ interface VersionedUpgradeOptions {
27
27
  yes?: boolean;
28
28
  cleanup?: boolean;
29
29
  rollback?: boolean;
30
+ pick?: boolean;
30
31
  force?: boolean;
31
32
  }
32
33
  /**
@@ -74,6 +75,40 @@ export declare function resolveUpgradeTarget(args: {
74
75
  * - windows: C:\Program Files\KiCI\<name>\
75
76
  */
76
77
  export declare function getInstallBase(platform: ServicePlatform, name: string): string;
78
+ /** A choice row for the `--pick` interactive select. */
79
+ export interface PickChoice {
80
+ value: string;
81
+ name: string;
82
+ /** `false` when selectable; a reason string when disabled (inquirer renders it). */
83
+ disabled: boolean | string;
84
+ }
85
+ /**
86
+ * Build the interactive `--pick` choices, newest-first (lexicographic, matching
87
+ * the rest of the versioned-directory handling). The currently-active version is
88
+ * labeled `(current)` and disabled so it cannot be selected — picking it would be
89
+ * a no-op restart.
90
+ */
91
+ export declare function buildPickChoices(versions: string[], current: string | null): PickChoice[];
92
+ /**
93
+ * The versions a `--pick` switch may target: every installed version except the
94
+ * currently-active one. Empty when only the current version (or nothing) is
95
+ * installed — the caller turns that into a "nothing to pick" error.
96
+ */
97
+ export declare function selectablePickTargets(versions: string[], current: string | null): string[];
98
+ /**
99
+ * Validate that `--pick` is not combined with a source/mode flag it conflicts
100
+ * with. `--pick` activates an already-installed version, so it never downloads
101
+ * (`--from`/`--url`), never takes an explicit `--version`, and is its own mode
102
+ * (not `--rollback`/`--cleanup`). Returns an error message, or null when OK.
103
+ */
104
+ export declare function checkPickFlagConflicts(opts: {
105
+ pick?: boolean;
106
+ from?: string;
107
+ url?: string;
108
+ version?: string;
109
+ rollback?: boolean;
110
+ cleanup?: boolean;
111
+ }): string | null;
77
112
  /**
78
113
  * Perform a versioned directory upgrade for a KiCI component.
79
114
  *
@@ -123,5 +158,22 @@ export declare function verifyNpmSourceLaunch(opts: {
123
158
  force: boolean;
124
159
  }): NpmSourceLaunchVerdict;
125
160
  export declare function performVersionedUpgrade(component: UpgradeComponent, opts: VersionedUpgradeOptions): Promise<void>;
161
+ /**
162
+ * Stop the service, switch the active version pointer to an already-installed
163
+ * versioned directory (atomic symlink on Unix; uninstall→install + version file
164
+ * on Windows), restart, and persist the new `kiciVersion` into the manifest.
165
+ *
166
+ * Shared by `--rollback` (switch to the previous version) and `--pick` (switch
167
+ * to any chosen installed version).
168
+ */
169
+ export declare function switchToInstalledVersion(args: {
170
+ component: UpgradeComponent;
171
+ platform: ServicePlatform;
172
+ installBase: string;
173
+ config: ServiceConfig;
174
+ manager: ServiceManager;
175
+ resolvedInstance: ResolvedInstance;
176
+ targetVersion: string;
177
+ }): Promise<void>;
126
178
  export {};
127
179
  //# sourceMappingURL=versioned-upgrade.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Build the orchestrator's OWN direct GitHub ingress URL for a source, from
3
+ * the configured public base (`KICI_WEBHOOK_PUBLIC_URL`). Returns null when no
4
+ * public base is configured (the CLI then prints an honest "set
5
+ * KICI_WEBHOOK_PUBLIC_URL" note instead of a fabricated URL).
6
+ */
7
+ export declare function buildLocalGithubIngressUrl(webhookPublicUrl: string | undefined, orgId: string, sourceId: string): string | null;
8
+ //# sourceMappingURL=local-github-ingress-url.d.ts.map