@kici-dev/orchestrator 0.5.0 → 0.6.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/dist/__test-helpers__/fake-scaler-state-store.d.ts +24 -0
- package/dist/__test-helpers__/mock-db-query.d.ts +130 -0
- package/dist/__test-helpers__/mock-db.d.ts +23 -0
- package/dist/agent/dispatcher.d.ts +81 -13
- package/dist/agent/host-roster.d.ts +37 -5
- package/dist/agent/registry.d.ts +2 -0
- package/dist/app.d.ts +33 -6
- package/dist/approvals/apply-decision.d.ts +67 -19
- package/dist/approvals/held-run-release-wiring.d.ts +45 -0
- package/dist/approvals/independent-wiring.d.ts +55 -0
- package/dist/approvals/resume-router.d.ts +9 -0
- package/dist/approvals/triggerer-subject.d.ts +37 -0
- package/dist/cache/dep-cache.d.ts +54 -10
- package/dist/cache/global-eval-round-cache.d.ts +7 -0
- package/dist/cli/api-client.d.ts +18 -0
- package/dist/cli/commands/cluster-settings.d.ts +11 -0
- package/dist/cli/commands/diagnose.d.ts +6 -0
- package/dist/cli/commands/held-run.d.ts +58 -0
- package/dist/cli/commands/trust-policy.d.ts +117 -12
- package/dist/cli/kici-admin.d.ts +10 -0
- package/dist/cli.js +2272 -1025
- package/dist/cluster/cluster-identity.d.ts +3 -3
- package/dist/cluster/cluster-settings-reader.d.ts +7 -1
- package/dist/cluster/coordinator.d.ts +44 -0
- package/dist/cluster/index.d.ts +4 -0
- package/dist/cluster/peer-handler.d.ts +19 -0
- package/dist/cluster/peer-registry.d.ts +17 -0
- package/dist/cluster/plan-headroom-store.d.ts +26 -0
- package/dist/cluster/worker-eviction.d.ts +69 -0
- package/dist/cold-store/load-event-log-range.d.ts +10 -3
- package/dist/cold-store/load-secret-audit-log-range.d.ts +4 -3
- package/dist/cold-store/tables/secret-audit-log.d.ts +4 -3
- package/dist/config.d.ts +21 -21
- package/dist/contexts/held-runs.d.ts +123 -16
- package/dist/contexts/protection/aggregate.d.ts +3 -2
- package/dist/contexts/protection/branch-gate.d.ts +15 -0
- package/dist/contexts/protection/concurrency-gate.d.ts +8 -2
- package/dist/contexts/protection/pipeline.d.ts +18 -0
- package/dist/contexts/release-queued-holds.d.ts +35 -0
- package/dist/dashboard/attestation-filters.d.ts +8 -0
- package/dist/dashboard/handler.d.ts +6 -24
- package/dist/db/migrations/116_org_plan_headroom.d.ts +4 -0
- package/dist/db/migrations/117_invoke_gate_proxy_jobs.d.ts +4 -0
- package/dist/db/migrations/118_invoke_gate_scheduling.d.ts +4 -0
- package/dist/db/migrations/119_scaler_ha_ownership.d.ts +4 -0
- package/dist/db/migrations/120_cluster_settings_scaler_reaper.d.ts +4 -0
- package/dist/db/migrations/121_org_settings_allow_untrusted_dockerfile_builds.d.ts +19 -0
- package/dist/db/migrations/122_host_roster_scaler_managed.d.ts +25 -0
- package/dist/db/migrations/123_workflow_registrations_default_branch.d.ts +24 -0
- package/dist/db/migrations/124_cluster_settings_provision_backoff.d.ts +4 -0
- package/dist/db/migrations/125_org_trust_directory.d.ts +30 -0
- package/dist/db/migrations/126_held_runs_posted_pending_check.d.ts +28 -0
- package/dist/db/migrations/127_org_trust_policy_approval_expiry_seconds.d.ts +26 -0
- package/dist/db/migrations/128_execution_runs_global_eval_round.d.ts +23 -0
- package/dist/db/migrations/129_execution_runs_dispatch_routing_key.d.ts +24 -0
- package/dist/db/migrations/130_scaler_provision_outcomes.d.ts +32 -0
- package/dist/db/types.d.ts +368 -10
- package/dist/entry-helpers.d.ts +28 -0
- package/dist/events/event-emitter.d.ts +22 -0
- package/dist/events/event-router.d.ts +87 -1
- package/dist/events/types.d.ts +2 -23
- package/dist/git/credential-broker.d.ts +94 -0
- package/dist/git/inherited-secret.d.ts +24 -0
- package/dist/git/installation-token.d.ts +38 -0
- package/dist/git/job-context.d.ts +13 -0
- package/dist/index.js +324 -84
- package/dist/metrics/agent-metrics-aggregator.d.ts +2 -2
- package/dist/metrics/prometheus.d.ts +111 -3
- package/dist/oidc/oidc-mint-registration.d.ts +7 -3
- package/dist/orchestrator-core.d.ts +79 -23
- package/dist/pipeline/direct-ingress-deps.d.ts +100 -0
- package/dist/pipeline/dispatch-matched-workflow.d.ts +302 -31
- package/dist/pipeline/global-eval-round.d.ts +14 -0
- package/dist/pipeline/internal-event-pipeline.d.ts +140 -0
- package/dist/pipeline/invoke-gate.d.ts +164 -0
- package/dist/pipeline/needs-scheduler.d.ts +13 -0
- package/dist/pipeline/process-webhook.d.ts +119 -31
- package/dist/pipeline/processor.d.ts +226 -21
- package/dist/pipeline/rerun.d.ts +21 -0
- package/dist/pipeline/resume-workflow.d.ts +40 -7
- package/dist/pipeline/route-or-dispatch-jobs.d.ts +9 -0
- package/dist/pipeline/security-hold-check.d.ts +217 -0
- package/dist/pipeline/undispatched-hold-checks.d.ts +23 -0
- package/dist/policy/dashboard-write-policy-listener.d.ts +62 -0
- package/dist/policy/dashboard-write-policy.d.ts +14 -0
- package/dist/provider-registry.d.ts +10 -2
- package/dist/providers/github/check-status-poster.d.ts +11 -0
- package/dist/providers/github/index.d.ts +0 -2
- package/dist/providers/github/normalizer.d.ts +3 -2
- package/dist/providers/local/normalizer.d.ts +3 -5
- package/dist/providers/universal-git/index.d.ts +11 -2
- package/dist/queue/job-queue.d.ts +43 -1
- package/dist/registration/extractor.d.ts +3 -3
- package/dist/registration/registration-index.d.ts +7 -0
- package/dist/registration/registration-store.d.ts +22 -0
- package/dist/reporting/check-run-reporter.d.ts +94 -1
- package/dist/reporting/check-run-summary.d.ts +25 -1
- package/dist/reporting/execution-tracker.d.ts +207 -2
- package/dist/reporting/run-aggregator.d.ts +4 -14
- package/dist/reporting/step-display-order.d.ts +43 -0
- package/dist/routes/admin-held-runs.d.ts +142 -0
- package/dist/routes/admin-trust-policy.d.ts +34 -6
- package/dist/routes/admin.d.ts +9 -0
- package/dist/scaler/backend-factory.d.ts +55 -0
- package/dist/scaler/bare-metal-backend.d.ts +43 -5
- package/dist/scaler/claim-store.d.ts +119 -0
- package/dist/scaler/config.d.ts +4 -0
- package/dist/scaler/container-backend.d.ts +18 -4
- package/dist/scaler/container-routing.d.ts +23 -0
- package/dist/scaler/container-spawn.d.ts +28 -0
- package/dist/scaler/event-backend.d.ts +124 -0
- package/dist/scaler/event-provision-reaper.d.ts +350 -0
- package/dist/scaler/failure-tracker.d.ts +1 -1
- package/dist/scaler/firecracker-backend.d.ts +33 -6
- package/dist/scaler/index.d.ts +11 -1
- package/dist/scaler/label-matcher.d.ts +4 -3
- package/dist/scaler/manager.d.ts +899 -72
- package/dist/scaler/resolve-container-auth.d.ts +45 -0
- package/dist/scaler/scaler-events.d.ts +11 -0
- package/dist/scaler/scaler-state-store.d.ts +294 -10
- package/dist/scaler/types.d.ts +131 -13
- package/dist/scaler/warm-pool.d.ts +132 -29
- package/dist/security/comment-handler.d.ts +50 -11
- package/dist/security/identity-link.d.ts +60 -0
- package/dist/security/lock-source.d.ts +11 -13
- package/dist/security/reduced-privilege-note.d.ts +59 -0
- package/dist/security/trust-directory-store.d.ts +233 -0
- package/dist/security/trust-policy-gate.d.ts +94 -59
- package/dist/security/trust-policy-store.d.ts +3 -0
- package/dist/security/trust-resolver.d.ts +14 -98
- package/dist/server.d.ts +11 -1
- package/dist/server.js +17684 -7351
- package/dist/stale-detector/gate-deadline-detector.d.ts +52 -0
- package/dist/stale-detector/stale-run-detector.d.ts +61 -3
- package/dist/standalone.js +24238 -13822
- package/dist/worker/in-memory-job-queue.d.ts +1 -1
- package/dist/ws/agent-handler.d.ts +28 -4
- package/dist/ws/dashboard-context-handler.d.ts +28 -4
- package/dist/ws/dashboard-global-workflows-handler.d.ts +6 -0
- package/dist/ws/failure-messages.d.ts +2 -0
- package/dist/ws/git-credential-relay.d.ts +39 -0
- package/dist/ws/oidc-token-relay.d.ts +6 -11
- package/dist/ws/platform-client.d.ts +54 -9
- package/installer-image-digests.json +3 -3
- package/package.json +24 -19
- package/sbom.spdx.json +864 -822
- package/dist/approvals/team-membership-lookup.d.ts +0 -13
- package/dist/providers/github/contributor-resolver.d.ts +0 -30
- package/dist/security/contributor-cache.d.ts +0 -83
|
@@ -35,7 +35,7 @@ export declare class InMemoryJobQueue {
|
|
|
35
35
|
* label in the gate set. Empty (default) is a no-op for static / non-scaler
|
|
36
36
|
* agents — the gate trivially passes.
|
|
37
37
|
*/
|
|
38
|
-
dequeueForLabels(agentLabels: string[], agentMandatoryLabels?: string[]): Promise<QueuedJob | null>;
|
|
38
|
+
dequeueForLabels(agentLabels: string[], agentMandatoryLabels?: string[], _agentId?: string, canServe?: (job: QueuedJob) => boolean): Promise<QueuedJob | null>;
|
|
39
39
|
/**
|
|
40
40
|
* Dequeue a specific pending job by id, validating that the agent's labels
|
|
41
41
|
* still satisfy the job's runsOn / excludeLabels and the agent's
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
* 2. pendingRegistration (10s): After auth.success, agent must send agent.register.
|
|
14
14
|
* 3. registered: Agent is fully connected and can exchange messages.
|
|
15
15
|
*
|
|
16
|
-
* When agentAuthMode === 'none', the auth phase is skipped
|
|
16
|
+
* When agentAuthMode === 'none', the auth phase is skipped and the connection
|
|
17
|
+
* starts in pendingRegistration. An agent that happens to carry a token still
|
|
18
|
+
* opens with auth.request — nothing on the wire tells it the mode — so that
|
|
19
|
+
* frame is accepted there and answered with auth.success without reading the
|
|
20
|
+
* token, and the agent then registers as normal.
|
|
17
21
|
*/
|
|
18
22
|
import type { WSEvents } from 'hono/ws';
|
|
19
23
|
import { LogStream } from '@kici-dev/engine';
|
|
@@ -124,12 +128,16 @@ export interface AgentWsHandlerDeps {
|
|
|
124
128
|
* AgentRegistry so subsequent label matches (queue drain + eager
|
|
125
129
|
* dispatch) apply the same gate the scaler-side selector applied.
|
|
126
130
|
*
|
|
127
|
-
*
|
|
131
|
+
* Resolves to `null` for static agents not managed by any scaler.
|
|
132
|
+
*
|
|
133
|
+
* Asynchronous because the agent may reach an instance that did not spawn
|
|
134
|
+
* it: that instance adopts the agent from the shared spawn record, which is
|
|
135
|
+
* a database round trip.
|
|
128
136
|
*/
|
|
129
|
-
onScalerAgentRegistered?: (agentId: string, labels: string[]) => {
|
|
137
|
+
onScalerAgentRegistered?: (agentId: string, labels: string[]) => Promise<{
|
|
130
138
|
boundJobId?: string;
|
|
131
139
|
mandatoryLabels: string[];
|
|
132
|
-
} | null
|
|
140
|
+
} | null>;
|
|
133
141
|
/** Optional callback when an agent disconnects (for scaler lifecycle). */
|
|
134
142
|
onScalerAgentDisconnected?: (agentId: string) => void;
|
|
135
143
|
/** Optional callback when an agent completes a job (for scaler lifecycle). */
|
|
@@ -170,6 +178,22 @@ export interface AgentWsHandlerDeps {
|
|
|
170
178
|
deliveryId?: string;
|
|
171
179
|
error?: string;
|
|
172
180
|
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Optional callback: a provisioning workflow's agent exchanges a single-use
|
|
183
|
+
* claim code (from a `kici.scaler.scale-up` event) for freshly minted
|
|
184
|
+
* ephemeral agent credentials. Delegates to the event scaler backend's claim
|
|
185
|
+
* store. Returns the credentials or an author-actionable error; the token is
|
|
186
|
+
* carried only in the response, never logged.
|
|
187
|
+
*/
|
|
188
|
+
onClaimCredentials?: (agentId: string, claimCode: string) => Promise<{
|
|
189
|
+
credentials?: {
|
|
190
|
+
agentToken: string;
|
|
191
|
+
agentId: string;
|
|
192
|
+
orchestratorUrl: string;
|
|
193
|
+
labels: string[];
|
|
194
|
+
};
|
|
195
|
+
error?: string;
|
|
196
|
+
}>;
|
|
173
197
|
/** Optional callback when agent sends a run.event for infrastructure lifecycle tracking. */
|
|
174
198
|
onRunEvent?: (agentId: string, msg: {
|
|
175
199
|
runId: string;
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
import { type Kysely } from 'kysely';
|
|
14
14
|
import type { HeldRunStore, ReleaseSignal } from '../contexts/held-runs.js';
|
|
15
15
|
import type { TeamMembershipLookup } from '../approvals/approval-resolver.js';
|
|
16
|
+
import { type ApplyDecisionDeps } from '../approvals/apply-decision.js';
|
|
16
17
|
import type { DashboardPlatformToOrchMessage } from '@kici-dev/engine';
|
|
17
18
|
import type { ContextStore } from '../contexts/context-store.js';
|
|
18
19
|
import type { VariableStore } from '../contexts/variable-store.js';
|
|
19
20
|
import type { BindingStore } from '../contexts/binding-store.js';
|
|
20
|
-
import type { Database } from '../db/types.js';
|
|
21
|
+
import type { Database, HeldRun } from '../db/types.js';
|
|
21
22
|
import type { AccessLogWriter } from '../audit/access-log.js';
|
|
22
23
|
import { type ScopedSecretStore } from '../secrets/scope-routing.js';
|
|
23
24
|
import type { ResolvedDashboardEncryptionKey } from '../secrets/dashboard-encryption-key.js';
|
|
@@ -74,10 +75,22 @@ export interface ApprovalHandlerDeps {
|
|
|
74
75
|
resumeStep?: (signal: ReleaseSignal) => Promise<void>;
|
|
75
76
|
/** Notify a waiting agent that a step hold was rejected (step scope). */
|
|
76
77
|
rejectStep?: (heldRunId: string, reason?: string) => Promise<void> | void;
|
|
77
|
-
/** Resume a released workflow
|
|
78
|
+
/** Resume a released workflow-scoped hold (install gate or trust policy). */
|
|
78
79
|
resumeWorkflow?: (signal: ReleaseSignal) => Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Cancel a rejected workflow-scoped hold (install gate, trust policy, or an
|
|
82
|
+
* SDK workflow-level `requireApproval`), recording the rejecter's own reason
|
|
83
|
+
* as the run's cancellation reason. The hold row tells those apart, and the
|
|
84
|
+
* resolved boolean says whether a terminal `KiCI Security` check was written
|
|
85
|
+
* — see `onWorkflowReject` on `ApplyDecisionDeps`.
|
|
86
|
+
*/
|
|
87
|
+
rejectWorkflow?: (hold: HeldRun, reason?: string) => Promise<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* Terminalize the `KiCI Security` check of any hold this handler ends that
|
|
90
|
+
* `rejectWorkflow` did not report on — see `settleSecurityCheck` on
|
|
91
|
+
* `ApplyDecisionDeps`.
|
|
92
|
+
*/
|
|
93
|
+
settleSecurityCheck?: ApplyDecisionDeps['settleSecurityCheck'];
|
|
81
94
|
}
|
|
82
95
|
/**
|
|
83
96
|
* Handler for all dashboard context and held run WS messages.
|
|
@@ -162,6 +175,12 @@ export declare class DashboardContextHandler {
|
|
|
162
175
|
/**
|
|
163
176
|
* Resolve the actor's Keycloak sub for approval attribution. Only `user` and
|
|
164
177
|
* `platform_operator` actors carry a `sub`; others fall back to a stable id.
|
|
178
|
+
*
|
|
179
|
+
* The `service:` namespace comes from {@link adminActorSub} rather than a
|
|
180
|
+
* literal here: `applyDecision`'s self-approval gate compares this value
|
|
181
|
+
* against {@link triggererSubjectFor}'s output, so the two renderings of one
|
|
182
|
+
* principal have to be produced by the same code or the gate compares strings
|
|
183
|
+
* that can never be equal.
|
|
165
184
|
*/
|
|
166
185
|
private actorSub;
|
|
167
186
|
/** Read org_settings.allow_self_approval (default true). */
|
|
@@ -170,6 +189,11 @@ export declare class DashboardContextHandler {
|
|
|
170
189
|
* Route an approve/reject through the shared `applyDecision` applier:
|
|
171
190
|
* eligibility check, real attribution, multi-clause accumulation, and the
|
|
172
191
|
* resume-after-approval re-dispatch. Sends the matching response message.
|
|
192
|
+
*
|
|
193
|
+
* The response goes out as soon as the decision is durable, not when its
|
|
194
|
+
* consequence finishes — see `ApplyDecisionResult.consequence`. The audit
|
|
195
|
+
* entry is attached to that consequence instead, so there is still exactly one
|
|
196
|
+
* per decision and it still carries the real outcome.
|
|
173
197
|
*/
|
|
174
198
|
private applyApprovalDecision;
|
|
175
199
|
private handleHeldRunApprove;
|
|
@@ -75,6 +75,12 @@ export declare class DashboardGlobalWorkflowsHandler {
|
|
|
75
75
|
*/
|
|
76
76
|
private effectiveEnabled;
|
|
77
77
|
private upsertRow;
|
|
78
|
+
/**
|
|
79
|
+
* Same envelope as `sendError`, for a request the client got wrong. Logged at
|
|
80
|
+
* warn level: bad input is not a server fault, and error-level rows here would
|
|
81
|
+
* pollute the error dashboards an operator watches.
|
|
82
|
+
*/
|
|
83
|
+
private sendClientError;
|
|
78
84
|
private sendError;
|
|
79
85
|
}
|
|
80
86
|
interface NormalizedPatch {
|
|
@@ -25,5 +25,7 @@ export declare const AgentWsInternalFailure: Readonly<{
|
|
|
25
25
|
readonly eventEmitFailed: 'the orchestrator hit an internal error while emitting this event';
|
|
26
26
|
/** An agent private-API handler threw for a reason other than its two deliberate rejections. */
|
|
27
27
|
readonly agentApiFailed: 'the orchestrator hit an internal error while handling this API request';
|
|
28
|
+
/** The event-scaler claim store threw while minting ephemeral credentials. */
|
|
29
|
+
readonly scalerClaimFailed: 'the orchestrator hit an internal error while claiming scaler credentials';
|
|
28
30
|
}>;
|
|
29
31
|
//# sourceMappingURL=failure-messages.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent.api` handler for GIT_CREDENTIAL_REQUEST_METHOD.
|
|
3
|
+
*
|
|
4
|
+
* The agent's credential helper calls this on every git network operation, so
|
|
5
|
+
* this path is hot and must stay cheap: validate, authorize, delegate.
|
|
6
|
+
*
|
|
7
|
+
* Authorization has two layers. Job ownership comes first — an agent may only
|
|
8
|
+
* request credentials for a job it was dispatched, resolved from server truth
|
|
9
|
+
* via the dispatcher, never from the params. Then the repository fence, which
|
|
10
|
+
* applies to WRITE only: a read with the source credential may reach any
|
|
11
|
+
* repository inside the App installation's own selection (GitHub enforces that
|
|
12
|
+
* selection when the mint names the repository), so cloning a sibling repo
|
|
13
|
+
* needs no credential in workflow code. A write must additionally stay inside
|
|
14
|
+
* the organisation that owns the job's source repository.
|
|
15
|
+
*
|
|
16
|
+
* A workflow-supplied credential needs no fence of its own: it names secrets
|
|
17
|
+
* the job can already read with `ctx.secrets.get()`, so brokering it grants no
|
|
18
|
+
* capability the workflow did not already have — the secret ACL is the
|
|
19
|
+
* authorization.
|
|
20
|
+
*/
|
|
21
|
+
import type { GitCredentialBroker } from '../git/credential-broker.js';
|
|
22
|
+
/** Per-job facts the handler needs. Resolved from server truth, never from params. */
|
|
23
|
+
export interface JobCredentialContext {
|
|
24
|
+
orgId: string;
|
|
25
|
+
/** The repository this job was dispatched for. */
|
|
26
|
+
sourceRepo: string;
|
|
27
|
+
}
|
|
28
|
+
export interface GitCredentialHandlerDeps {
|
|
29
|
+
broker: GitCredentialBroker;
|
|
30
|
+
/** The dispatcher's job-ownership resolver — the same one the OIDC relay uses. */
|
|
31
|
+
dispatcher: {
|
|
32
|
+
resolveOwnedJob(agentId: string, jobId: string): {
|
|
33
|
+
runId: string;
|
|
34
|
+
} | undefined;
|
|
35
|
+
};
|
|
36
|
+
jobContext: (runId: string, jobId: string) => Promise<JobCredentialContext | null>;
|
|
37
|
+
}
|
|
38
|
+
export declare function buildGitCredentialHandler(deps: GitCredentialHandlerDeps): (agentId: string, rawParams: Record<string, unknown>) => Promise<unknown>;
|
|
39
|
+
//# sourceMappingURL=git-credential-relay.d.ts.map
|
|
@@ -60,19 +60,14 @@ export interface OidcTokenHandlerDeps {
|
|
|
60
60
|
};
|
|
61
61
|
platformClient: MintPlatformClient;
|
|
62
62
|
orchestratorId: string;
|
|
63
|
-
/** Test-only fault-injection master switch (config.testMode). */
|
|
64
|
-
testMode: boolean;
|
|
65
63
|
/**
|
|
66
|
-
* Test-only
|
|
67
|
-
*
|
|
64
|
+
* Test-only fault-injection predicate over the requested OIDC `audience`,
|
|
65
|
+
* supplied only by the build-time test double. Returning `true` short-circuits
|
|
66
|
+
* the *initial* mint to a transient defer BEFORE the real Platform relay is
|
|
67
|
+
* contacted — it can only defer/reject, never forge or weaken a signature.
|
|
68
|
+
* Undefined (the shipped default) means no fault injection.
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Test-only: force the *initial* agent mint to defer for this OIDC audience
|
|
72
|
-
* (config.testMintRejectAudience) so a pending row is created, which the
|
|
73
|
-
* retrier then terminally rejects. Ignored unless `testMode`.
|
|
74
|
-
*/
|
|
75
|
-
testMintRejectAudience?: string;
|
|
70
|
+
initialMintFault?: (audience: string) => boolean;
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
78
73
|
* Build the agent.api handler for `OIDC_TOKEN_REQUEST_METHOD`. Validates the
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type StateReplayRun, type OrchestratorToPlatformMessage, type WebhookRelay, type WebhookRelayResult, type TrustPolicyUpdate, type StaleCheckrunCleanup, type DashboardRunDetailRequest, type DashboardRunStructuredRequest, type DashboardRunStateRequest, type DashboardRunsListRequest, type DashboardRunsFiltersRequest, type DashboardSourcesListRequest, type DashboardStepLogsRequest, type DashboardAttestationsListRequest, type DashboardAttestationsListAllRequest, type DashboardAttestationGetRequest, type DashboardAttestationRetryRequest, type DashboardArtifactsListRequest, type DashboardOrchLogsRequest, type RunRerunRequest, type ManualScheduleRequest, type RunCancelRequest, type DashboardPayloadRequest, type DashboardPlatformToOrchMessage, type TestRelayRequest, type DashboardDiagnosticsRequest, type DashboardScalerCapacityRequest, type DashboardScalerAgentsRequest, type DashboardFleetHostsRequest, type DashboardFleetHostRequest, type DashboardFleetPreviewRequest, type DashboardFleetWorkflowsForHostRequest, type JoinRequest, type JoinResponse, type DeploymentIdentity, type OrchCapabilities, type OrchRole } from '@kici-dev/engine';
|
|
2
|
+
import type { PlanHeadroomStore } from '../cluster/plan-headroom-store.js';
|
|
2
3
|
import { RelayBufferRegistry, type RelayStartMeta } from '../webhook/relay-buffer.js';
|
|
3
4
|
import type { AdmitResult } from '../webhook/ingest-admission.js';
|
|
4
5
|
/**
|
|
@@ -114,6 +115,27 @@ export interface PlatformClientOptions {
|
|
|
114
115
|
}) => void;
|
|
115
116
|
/** Optional callback invoked after successful authentication and source registration. */
|
|
116
117
|
onAuthenticated?: () => void;
|
|
118
|
+
/**
|
|
119
|
+
* Returns this coordinator's currently-connected worker peers for the
|
|
120
|
+
* `cluster.membership` snapshot. Undefined on a non-coordinator (or when
|
|
121
|
+
* clustering is off) → no membership is reported.
|
|
122
|
+
*/
|
|
123
|
+
getWorkerPeers?: () => Array<{
|
|
124
|
+
instanceId: string;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Persisted cache of the Platform-pushed worker ceiling. Written on every
|
|
128
|
+
* `plan.headroom`, read by `getWorkerCeiling`. Undefined → the coordinator
|
|
129
|
+
* receives no ceiling and admits worker joins freely.
|
|
130
|
+
*/
|
|
131
|
+
planHeadroomStore?: PlanHeadroomStore;
|
|
132
|
+
/**
|
|
133
|
+
* Reconcile this coordinator's workers against a pushed ceiling. Invoked on
|
|
134
|
+
* EVERY `plan.headroom` frame with the frame's `evictExcess` flag, so a raised
|
|
135
|
+
* ceiling (or a cleared `evictExcess`) can cancel an in-flight drain, not only
|
|
136
|
+
* start one. Undefined → no eviction reconciliation.
|
|
137
|
+
*/
|
|
138
|
+
onPlanCeiling?: (ceiling: number, evictExcess: boolean) => void;
|
|
117
139
|
/**
|
|
118
140
|
* Optional callback invoked when the Platform surfaces the orchestrator's
|
|
119
141
|
* canonical org id on `auth.success`. Used to auto-provision the
|
|
@@ -195,16 +217,12 @@ export interface PlatformClientOptions {
|
|
|
195
217
|
/** Custom orchestrator capabilities to merge with ORCH_CAPABILITIES in auth.request. */
|
|
196
218
|
orchCapabilities?: Partial<OrchCapabilities>;
|
|
197
219
|
/**
|
|
198
|
-
* Test-only
|
|
199
|
-
*
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Test-only. Comma-separated `dashboard.*` request types to drop from the
|
|
204
|
-
* advertised capability manifest (config `KICI_TEST_OMIT_DASHBOARD_REQUEST_TYPES`).
|
|
205
|
-
* Only honored when `testMode` is true; production leaves both unset.
|
|
220
|
+
* Test-only fault-injection transform over the advertised capability manifest,
|
|
221
|
+
* supplied only by the build-time test double to reproduce an older /
|
|
222
|
+
* sourceless orchestrator that predates a given dashboard capability. Undefined
|
|
223
|
+
* (the shipped default) means identity — the full capability set is advertised.
|
|
206
224
|
*/
|
|
207
|
-
|
|
225
|
+
capabilitiesTransform?: (c: OrchCapabilities) => OrchCapabilities;
|
|
208
226
|
/**
|
|
209
227
|
* Verify a reassembled inbound webhook from the chunked relay path.
|
|
210
228
|
*
|
|
@@ -269,6 +287,7 @@ export declare class PlatformClient {
|
|
|
269
287
|
private _state;
|
|
270
288
|
private readonly eventBuffer;
|
|
271
289
|
private heartbeatTimer;
|
|
290
|
+
private membershipTimer;
|
|
272
291
|
private reconnectTimer;
|
|
273
292
|
private reconnectAttempts;
|
|
274
293
|
/** Armed on auth; resets the backoff only if the connection survives it. */
|
|
@@ -321,6 +340,9 @@ export declare class PlatformClient {
|
|
|
321
340
|
private readonly onLogPullRequest?;
|
|
322
341
|
private readonly onPeerDiscover?;
|
|
323
342
|
private readonly onAuthenticated?;
|
|
343
|
+
private readonly getWorkerPeers?;
|
|
344
|
+
private readonly planHeadroomStore?;
|
|
345
|
+
private readonly onPlanCeiling?;
|
|
324
346
|
private readonly onOrgIdentified?;
|
|
325
347
|
private readonly onProvenanceIssuer?;
|
|
326
348
|
private readonly onDashboardRunDetail?;
|
|
@@ -532,6 +554,29 @@ export declare class PlatformClient {
|
|
|
532
554
|
private flushBuffer;
|
|
533
555
|
private startHeartbeat;
|
|
534
556
|
private stopHeartbeat;
|
|
557
|
+
/** How often a coordinator re-sends its membership snapshot. */
|
|
558
|
+
private static readonly CLUSTER_MEMBERSHIP_INTERVAL_MS;
|
|
559
|
+
/**
|
|
560
|
+
* Send the current worker-peer snapshot to the Platform.
|
|
561
|
+
*
|
|
562
|
+
* A snapshot, not a delta: a dropped frame self-heals on the next send. A
|
|
563
|
+
* no-op when the client is not authenticated or has no worker-peer source.
|
|
564
|
+
*/
|
|
565
|
+
sendClusterMembership(): void;
|
|
566
|
+
private startClusterMembership;
|
|
567
|
+
private stopClusterMembership;
|
|
568
|
+
/**
|
|
569
|
+
* Store the Platform's worker ceiling and act on an eviction directive.
|
|
570
|
+
*
|
|
571
|
+
* The stored value survives a Platform disconnect and a coordinator restart,
|
|
572
|
+
* which is what makes the fail-open stance bounded rather than unlimited.
|
|
573
|
+
*/
|
|
574
|
+
private onPlanHeadroom;
|
|
575
|
+
/**
|
|
576
|
+
* The ceiling this coordinator enforces, or `null` when none was ever
|
|
577
|
+
* received — in which case worker joins are admitted freely.
|
|
578
|
+
*/
|
|
579
|
+
getWorkerCeiling(): Promise<number | null>;
|
|
535
580
|
private scheduleReconnect;
|
|
536
581
|
private clearStabilityTimer;
|
|
537
582
|
private cancelReconnect;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.6.1",
|
|
3
3
|
"images": {
|
|
4
|
-
"kici-agent": "sha256:
|
|
5
|
-
"kici-orchestrator": "sha256:
|
|
4
|
+
"kici-agent": "sha256:bc64f67d749520b7424de6fc1bd614791064eadde3cb2d007074605aa30496c2",
|
|
5
|
+
"kici-orchestrator": "sha256:80079e870c3755f9467164fa7189c2a7dc6ddc44028e9c0932778839d56e0778"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kici-dev/orchestrator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Customer-deployable orchestrator for the KiCI CI/CD stack. Receives webhook events (direct or via Platform relay), matches triggers against the lock file, and dispatches jobs to connected agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
"files": [
|
|
31
31
|
"dist",
|
|
32
32
|
"!dist/**/*.map",
|
|
33
|
+
"!dist/server-test.d.ts",
|
|
34
|
+
"!dist/testing",
|
|
33
35
|
"sbom.spdx.json",
|
|
34
36
|
"installer-image-digests.json"
|
|
35
37
|
],
|
|
@@ -54,38 +56,41 @@
|
|
|
54
56
|
"standalone.js": "src/standalone.ts",
|
|
55
57
|
"cli.js": "src/cli/kici-admin.ts",
|
|
56
58
|
"index.js": "src/index.ts"
|
|
59
|
+
},
|
|
60
|
+
"devEntries": {
|
|
61
|
+
"server-test.js": "src/server-test.ts"
|
|
57
62
|
}
|
|
58
63
|
},
|
|
59
64
|
"dependencies": {
|
|
60
|
-
"@aws-sdk/client-kms": "^3.
|
|
61
|
-
"@aws-sdk/client-s3": "^3.
|
|
62
|
-
"@aws-sdk/lib-storage": "^3.
|
|
63
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
64
|
-
"@hono/node-server": "^2.
|
|
65
|
-
"@inquirer/prompts": "^8.
|
|
66
|
-
"@octokit/auth-app": "^8.
|
|
65
|
+
"@aws-sdk/client-kms": "^3.1121.0",
|
|
66
|
+
"@aws-sdk/client-s3": "^3.1121.0",
|
|
67
|
+
"@aws-sdk/lib-storage": "^3.1121.0",
|
|
68
|
+
"@aws-sdk/s3-request-presigner": "^3.1121.0",
|
|
69
|
+
"@hono/node-server": "^2.1.1",
|
|
70
|
+
"@inquirer/prompts": "^8.7.0",
|
|
71
|
+
"@octokit/auth-app": "^8.3.0",
|
|
67
72
|
"@octokit/rest": "^22.0.1",
|
|
68
73
|
"archiver": "^8.0.0",
|
|
69
74
|
"commander": "^15.0.0",
|
|
70
75
|
"croner": "^10.0.1",
|
|
71
76
|
"dockerode": "^5.0.1",
|
|
72
|
-
"hashi-vault-js": "^0.5.
|
|
73
|
-
"hono": "^4.
|
|
74
|
-
"jose": "^6.
|
|
77
|
+
"hashi-vault-js": "^0.5.3",
|
|
78
|
+
"hono": "^4.13.2",
|
|
79
|
+
"jose": "^6.2.10",
|
|
75
80
|
"jsonpath-plus": "^10.4.0",
|
|
76
81
|
"jszip": "^3.10.1",
|
|
77
82
|
"kysely": "^0.29.4",
|
|
78
83
|
"lru-cache": "^11.5.2",
|
|
79
|
-
"nanoid": "^6.0.
|
|
80
|
-
"pg": "^8.
|
|
81
|
-
"picomatch": "^4.0.
|
|
84
|
+
"nanoid": "^6.0.1",
|
|
85
|
+
"pg": "^8.23.0",
|
|
86
|
+
"picomatch": "^4.0.7",
|
|
82
87
|
"strip-ansi": "^7.2.0",
|
|
83
|
-
"tar": "^7.5.
|
|
84
|
-
"ws": "^8.21.
|
|
88
|
+
"tar": "^7.5.22",
|
|
89
|
+
"ws": "^8.21.3",
|
|
85
90
|
"yaml": "^2.9.0",
|
|
86
91
|
"zod": "^4.4.3",
|
|
87
|
-
"@kici-dev/
|
|
88
|
-
"@kici-dev/
|
|
92
|
+
"@kici-dev/shared": "0.6.1",
|
|
93
|
+
"@kici-dev/engine": "0.6.1"
|
|
89
94
|
},
|
|
90
95
|
"kici": {
|
|
91
96
|
"metrics": {
|
|
@@ -100,7 +105,7 @@
|
|
|
100
105
|
"@types/dockerode": "^4.0.1",
|
|
101
106
|
"@types/ws": "^8.18.1",
|
|
102
107
|
"kysely-ctl": "^0.21.0",
|
|
103
|
-
"@kici-dev/agent": "0.
|
|
108
|
+
"@kici-dev/agent": "0.6.1"
|
|
104
109
|
},
|
|
105
110
|
"scripts": {
|
|
106
111
|
"build": "node ../../scripts/build-service.mjs && tsgo --emitDeclarationOnly",
|