@kici-dev/engine 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.
Files changed (68) hide show
  1. package/dist/audit/access-log-policy.js +1 -0
  2. package/dist/audit/retention-policy.js +2 -0
  3. package/dist/context/held-run-job-id.d.ts +26 -10
  4. package/dist/context/held-run-job-id.js +30 -11
  5. package/dist/context/index.d.ts +1 -1
  6. package/dist/context/index.js +3 -3
  7. package/dist/context/types.d.ts +10 -1
  8. package/dist/context/types.js +10 -1
  9. package/dist/index.d.ts +4 -2
  10. package/dist/index.js +14 -11
  11. package/dist/labels.d.ts +66 -12
  12. package/dist/labels.js +74 -17
  13. package/dist/mcp/held-run-resolve.d.ts +40 -0
  14. package/dist/mcp/held-run-resolve.js +68 -15
  15. package/dist/mcp/tool-schemas.d.ts +4 -0
  16. package/dist/mcp/tool-schemas.js +13 -1
  17. package/dist/metrics/catalog-policy.d.ts +6 -3
  18. package/dist/metrics/catalog-policy.js +31 -10
  19. package/dist/metrics/metric-catalog.generated.d.ts +110 -0
  20. package/dist/metrics/metric-catalog.generated.js +132 -0
  21. package/dist/protocol/dashboard-global-workflows.js +2 -2
  22. package/dist/protocol/event-log-payload.js +1 -1
  23. package/dist/protocol/messages/access-log.d.ts +5 -0
  24. package/dist/protocol/messages/access-log.js +1 -0
  25. package/dist/protocol/messages/actor.d.ts +13 -2
  26. package/dist/protocol/messages/actor.js +16 -5
  27. package/dist/protocol/messages/common.js +1 -1
  28. package/dist/protocol/messages/dashboard-global-workflows.d.ts +21 -0
  29. package/dist/protocol/messages/dashboard-global-workflows.js +28 -1
  30. package/dist/protocol/messages/dashboard.d.ts +46 -5
  31. package/dist/protocol/messages/dashboard.js +67 -7
  32. package/dist/protocol/messages/execution-status.d.ts +41 -0
  33. package/dist/protocol/messages/execution-status.js +53 -2
  34. package/dist/protocol/messages/git-credential-relay.d.ts +78 -0
  35. package/dist/protocol/messages/git-credential-relay.js +86 -0
  36. package/dist/protocol/messages/orchestrator-agent.d.ts +89 -0
  37. package/dist/protocol/messages/orchestrator-agent.js +98 -3
  38. package/dist/protocol/messages/peer.d.ts +7 -0
  39. package/dist/protocol/messages/peer.js +18 -1
  40. package/dist/protocol/messages/platform-orchestrator.d.ts +150 -0
  41. package/dist/protocol/messages/platform-orchestrator.js +164 -19
  42. package/dist/protocol/version.d.ts +19 -2
  43. package/dist/protocol/version.js +20 -3
  44. package/dist/provenance/verify.js +11 -10
  45. package/dist/provider/check-status-poster.d.ts +24 -3
  46. package/dist/provider/contributor-resolver.d.ts +11 -3
  47. package/dist/provider/git-credential.d.ts +77 -0
  48. package/dist/provider/git-credential.js +10 -0
  49. package/dist/provider/index.d.ts +2 -0
  50. package/dist/provider/index.js +2 -1
  51. package/dist/provider/webhook-normalizer.d.ts +12 -12
  52. package/dist/repo/pattern-negation.d.ts +73 -0
  53. package/dist/repo/pattern-negation.js +86 -0
  54. package/dist/scaler/registry-auth.d.ts +18 -0
  55. package/dist/scaler/registry-auth.js +28 -0
  56. package/dist/scaler/scaler-backend-type.d.ts +35 -0
  57. package/dist/scaler/scaler-backend-type.js +39 -2
  58. package/dist/scaler/scaler-events.d.ts +79 -0
  59. package/dist/scaler/scaler-events.js +87 -0
  60. package/dist/trigger/content-requirements.js +1 -1
  61. package/dist/trigger/decision-trace.d.ts +79 -0
  62. package/dist/trigger/decision-trace.js +116 -8
  63. package/dist/trigger/matcher.js +4 -2
  64. package/dist/trigger/types.d.ts +87 -7
  65. package/dist/trigger/types.js +6 -1
  66. package/dist/ws/rate-limiter.js +3 -3
  67. package/package.json +11 -3
  68. package/sbom.spdx.json +15 -15
@@ -25,7 +25,17 @@ export type CacheRefScope = z.infer<typeof CacheRefScope>;
25
25
  * - `groups` maps a dynamic group name to its ordered member job names.
26
26
  * - `statuses` maps an upstream job name to its terminal status, so the
27
27
  * generator's `ctx.needs.<job>.status` reflects the frozen upstream outcome.
28
+ * - `invokeResults` maps an invoke-gate job name to its ordered per-run results,
29
+ * so the generator's `ctx.needs.<gate>.result` reflects each summoned run.
28
30
  */
31
+ export declare const invokeResultSchema: z.ZodObject<{
32
+ repo: z.ZodString;
33
+ workflow: z.ZodString;
34
+ runId: z.ZodString;
35
+ status: z.ZodString;
36
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
37
+ }, z.core.$strip>;
38
+ export type InvokeResult = z.infer<typeof invokeResultSchema>;
29
39
  export declare const upstreamSnapshotSchema: z.ZodObject<{
30
40
  jobs: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
31
41
  groups: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
@@ -43,6 +53,13 @@ export declare const upstreamSnapshotSchema: z.ZodObject<{
43
53
  timed_out_stale: "timed_out_stale";
44
54
  unroutable: "unroutable";
45
55
  }>>>;
56
+ invokeResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
57
+ repo: z.ZodString;
58
+ workflow: z.ZodString;
59
+ runId: z.ZodString;
60
+ status: z.ZodString;
61
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
62
+ }, z.core.$strip>>>>;
46
63
  }, z.core.$strip>;
47
64
  export type UpstreamSnapshot = z.infer<typeof upstreamSnapshotSchema>;
48
65
  /**
@@ -111,6 +128,13 @@ export declare const jobDispatchSchema: z.ZodObject<{
111
128
  timed_out_stale: "timed_out_stale";
112
129
  unroutable: "unroutable";
113
130
  }>>>;
131
+ upstreamInvokeResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
132
+ repo: z.ZodString;
133
+ workflow: z.ZodString;
134
+ runId: z.ZodString;
135
+ status: z.ZodString;
136
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
137
+ }, z.core.$strip>>>>;
114
138
  sourceAuth: z.ZodOptional<z.ZodObject<{
115
139
  kind: z.ZodEnum<{
116
140
  basic: "basic";
@@ -143,6 +167,11 @@ export declare const jobDispatchSchema: z.ZodObject<{
143
167
  alwaysAuth: z.ZodBoolean;
144
168
  token: z.ZodString;
145
169
  }, z.core.$strip>>>;
170
+ containerRegistryAuth: z.ZodOptional<z.ZodObject<{
171
+ username: z.ZodString;
172
+ password: z.ZodString;
173
+ serveraddress: z.ZodString;
174
+ }, z.core.$strip>>;
146
175
  installEnvSecrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
147
176
  orgId: z.ZodOptional<z.ZodString>;
148
177
  repoId: z.ZodOptional<z.ZodString>;
@@ -167,6 +196,7 @@ export declare const registerAckSchema: z.ZodObject<{
167
196
  labels: z.ZodArray<z.ZodString>;
168
197
  scalerManaged: z.ZodDefault<z.ZodBoolean>;
169
198
  pendingDispatch: z.ZodOptional<z.ZodBoolean>;
199
+ warmPool: z.ZodOptional<z.ZodBoolean>;
170
200
  capabilities: z.ZodOptional<z.ZodObject<{
171
201
  artifactCompleteAck: z.ZodOptional<z.ZodBoolean>;
172
202
  }, z.core.$loose>>;
@@ -646,6 +676,35 @@ export declare const eventEmitResponseSchema: z.ZodObject<{
646
676
  deliveryId: z.ZodOptional<z.ZodString>;
647
677
  error: z.ZodOptional<z.ZodString>;
648
678
  }, z.core.$strip>;
679
+ /**
680
+ * Agent -> Orchestrator: exchanges a single-use claim code (delivered on a
681
+ * `kici.scaler.scale-up` event) for freshly minted ephemeral agent credentials.
682
+ * A provisioned agent normally sends this itself to self-bootstrap — the claim
683
+ * code is the authorization, so it may send it before it authenticates or
684
+ * registers. A provisioning workflow can also send it to obtain the token
685
+ * directly. Additive/negotiated by presence — older peers that never emit it
686
+ * are unaffected, so it needs no `PROTOCOL_VERSION` bump of its own.
687
+ */
688
+ export declare const scalerClaimCredentialsSchema: z.ZodObject<{
689
+ type: z.ZodLiteral<"scaler.claim-credentials">;
690
+ requestId: z.ZodString;
691
+ claimCode: z.ZodString;
692
+ }, z.core.$strip>;
693
+ /**
694
+ * Orchestrator -> Agent: minted ephemeral credentials for a claimed provision,
695
+ * or an error. The token appears only here — never in the persisted event log.
696
+ */
697
+ export declare const scalerClaimCredentialsResponseSchema: z.ZodObject<{
698
+ type: z.ZodLiteral<"scaler.claim-credentials.response">;
699
+ requestId: z.ZodString;
700
+ credentials: z.ZodOptional<z.ZodObject<{
701
+ agentToken: z.ZodString;
702
+ agentId: z.ZodString;
703
+ orchestratorUrl: z.ZodString;
704
+ labels: z.ZodArray<z.ZodString>;
705
+ }, z.core.$strip>>;
706
+ error: z.ZodOptional<z.ZodString>;
707
+ }, z.core.$strip>;
649
708
  /** Periodic metrics push from agent to orchestrator. */
650
709
  export declare const agentMetricsSchema: z.ZodObject<{
651
710
  type: z.ZodLiteral<"agent.metrics">;
@@ -830,6 +889,13 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
830
889
  timed_out_stale: "timed_out_stale";
831
890
  unroutable: "unroutable";
832
891
  }>>>;
892
+ upstreamInvokeResults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodObject<{
893
+ repo: z.ZodString;
894
+ workflow: z.ZodString;
895
+ runId: z.ZodString;
896
+ status: z.ZodString;
897
+ outputs: z.ZodRecord<z.ZodString, z.ZodUnknown>;
898
+ }, z.core.$strip>>>>;
833
899
  sourceAuth: z.ZodOptional<z.ZodObject<{
834
900
  kind: z.ZodEnum<{
835
901
  basic: "basic";
@@ -862,6 +928,11 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
862
928
  alwaysAuth: z.ZodBoolean;
863
929
  token: z.ZodString;
864
930
  }, z.core.$strip>>>;
931
+ containerRegistryAuth: z.ZodOptional<z.ZodObject<{
932
+ username: z.ZodString;
933
+ password: z.ZodString;
934
+ serveraddress: z.ZodString;
935
+ }, z.core.$strip>>;
865
936
  installEnvSecrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
866
937
  orgId: z.ZodOptional<z.ZodString>;
867
938
  repoId: z.ZodOptional<z.ZodString>;
@@ -882,6 +953,7 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
882
953
  labels: z.ZodArray<z.ZodString>;
883
954
  scalerManaged: z.ZodDefault<z.ZodBoolean>;
884
955
  pendingDispatch: z.ZodOptional<z.ZodBoolean>;
956
+ warmPool: z.ZodOptional<z.ZodBoolean>;
885
957
  capabilities: z.ZodOptional<z.ZodObject<{
886
958
  artifactCompleteAck: z.ZodOptional<z.ZodBoolean>;
887
959
  }, z.core.$loose>>;
@@ -956,6 +1028,16 @@ export declare const orchestratorToAgentMessageSchema: z.ZodDiscriminatedUnion<[
956
1028
  requestId: z.ZodString;
957
1029
  deliveryId: z.ZodOptional<z.ZodString>;
958
1030
  error: z.ZodOptional<z.ZodString>;
1031
+ }, z.core.$strip>, z.ZodObject<{
1032
+ type: z.ZodLiteral<"scaler.claim-credentials.response">;
1033
+ requestId: z.ZodString;
1034
+ credentials: z.ZodOptional<z.ZodObject<{
1035
+ agentToken: z.ZodString;
1036
+ agentId: z.ZodString;
1037
+ orchestratorUrl: z.ZodString;
1038
+ labels: z.ZodArray<z.ZodString>;
1039
+ }, z.core.$strip>>;
1040
+ error: z.ZodOptional<z.ZodString>;
959
1041
  }, z.core.$strip>, z.ZodObject<{
960
1042
  type: z.ZodLiteral<"agent.api.response">;
961
1043
  requestId: z.ZodString;
@@ -1137,6 +1219,7 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
1137
1219
  lockfileHash: z.ZodOptional<z.ZodString>;
1138
1220
  platform: z.ZodString;
1139
1221
  arch: z.ZodString;
1222
+ depsHash: z.ZodOptional<z.ZodString>;
1140
1223
  }, z.core.$strip>, z.ZodObject<{
1141
1224
  type: z.ZodLiteral<"cache.upload.complete">;
1142
1225
  messageId: z.ZodString;
@@ -1226,6 +1309,10 @@ export declare const agentToOrchestratorMessageSchema: z.ZodDiscriminatedUnion<[
1226
1309
  target: z.ZodOptional<z.ZodObject<{
1227
1310
  repos: z.ZodOptional<z.ZodArray<z.ZodString>>;
1228
1311
  }, z.core.$strip>>;
1312
+ }, z.core.$strip>, z.ZodObject<{
1313
+ type: z.ZodLiteral<"scaler.claim-credentials">;
1314
+ requestId: z.ZodString;
1315
+ claimCode: z.ZodString;
1229
1316
  }, z.core.$strip>, z.ZodObject<{
1230
1317
  type: z.ZodLiteral<"agent.api.request">;
1231
1318
  requestId: z.ZodString;
@@ -1312,6 +1399,8 @@ export type ArtifactsDownloadResponse = z.infer<typeof artifactsDownloadResponse
1312
1399
  export type FleetLogsRequest = z.infer<typeof fleetLogsRequestSchema>;
1313
1400
  export type FleetBundleChunk = z.infer<typeof fleetBundleChunkSchema>;
1314
1401
  export type FleetBundleError = z.infer<typeof fleetBundleErrorSchema>;
1402
+ export type ScalerClaimCredentials = z.infer<typeof scalerClaimCredentialsSchema>;
1403
+ export type ScalerClaimCredentialsResponse = z.infer<typeof scalerClaimCredentialsResponseSchema>;
1315
1404
  export type OrchestratorToAgentMessage = z.infer<typeof orchestratorToAgentMessageSchema>;
1316
1405
  export type AgentToOrchestratorMessage = z.infer<typeof agentToOrchestratorMessageSchema>;
1317
1406
  //# sourceMappingURL=orchestrator-agent.d.ts.map
@@ -27,11 +27,21 @@ const CacheRefScope = z.enum(["shared", "isolated"]);
27
27
  * - `groups` maps a dynamic group name to its ordered member job names.
28
28
  * - `statuses` maps an upstream job name to its terminal status, so the
29
29
  * generator's `ctx.needs.<job>.status` reflects the frozen upstream outcome.
30
+ * - `invokeResults` maps an invoke-gate job name to its ordered per-run results,
31
+ * so the generator's `ctx.needs.<gate>.result` reflects each summoned run.
30
32
  */
33
+ const invokeResultSchema = z.object({
34
+ repo: z.string(),
35
+ workflow: z.string(),
36
+ runId: z.string(),
37
+ status: z.string(),
38
+ outputs: z.record(z.string(), z.unknown())
39
+ });
31
40
  const upstreamSnapshotSchema = z.object({
32
41
  jobs: z.record(z.string(), z.record(z.string(), z.unknown())),
33
42
  groups: z.record(z.string(), z.array(z.string())),
34
- statuses: z.record(z.string(), ExecutionJobStatus).optional()
43
+ statuses: z.record(z.string(), ExecutionJobStatus).optional(),
44
+ invokeResults: z.record(z.string(), z.array(invokeResultSchema)).optional()
35
45
  });
36
46
  /**
37
47
  * Structured git-clone auth material. Carries everything the agent needs to
@@ -108,6 +118,15 @@ const jobDispatchSchema = z.object({
108
118
  /** Terminal status of each upstream job (keyed by job name; per-child for fan-out). Powers `ctx.needs.<job>.status`. */
109
119
  upstreamJobStatuses: z.record(z.string(), ExecutionJobStatus).optional(),
110
120
  /**
121
+ * Per-invoke-gate results for any upstream gate this job `needs`, keyed by
122
+ * gate job name. One {@link invokeResultSchema} entry per run the gate
123
+ * triggered, carrying the invoked run's non-secret declared outputs. Powers
124
+ * a standard downstream job's `ctx.needs['<gate>'].result`. Additive and
125
+ * optional — older orchestrators omit it and the agent resolves the gate
126
+ * need through the fan-out group shape instead.
127
+ */
128
+ upstreamInvokeResults: z.record(z.string(), z.array(invokeResultSchema)).optional(),
129
+ /**
111
130
  * Structured clone auth for the source repo. Preferred over `token` (which
112
131
  * remains as a backward-compat field for same-provider GitHub App flows
113
132
  * during the transition to universal-git / cross-provider global workflows).
@@ -143,6 +162,20 @@ const jobDispatchSchema = z.object({
143
162
  token: z.string().min(1)
144
163
  })).optional(),
145
164
  /**
165
+ * Registry credentials for pulling this job's container image, already
166
+ * resolved by the orchestrator (the lock carries secret NAMES; the agent
167
+ * never resolves them itself).
168
+ *
169
+ * Optional for backward compatibility with older orchestrators, which do
170
+ * not send it — an agent that receives no auth pulls anonymously, exactly
171
+ * as it did before.
172
+ */
173
+ containerRegistryAuth: z.object({
174
+ username: z.string().min(1),
175
+ password: z.string().min(1),
176
+ serveraddress: z.string().min(1)
177
+ }).optional(),
178
+ /**
146
179
  * Extra resolved secrets to project as env vars on the install
147
180
  * subprocess. Keyed by the bare secret name (the qualified env: prefix
148
181
  * is stripped at resolution time). For use with a customer-committed
@@ -204,6 +237,23 @@ const registerAckSchema = z.object({
204
237
  */
205
238
  pendingDispatch: z.boolean().optional(),
206
239
  /**
240
+ * Set when this agent was pre-spawned to wait for work (a warm pool) rather
241
+ * than for a specific queued job. Such an agent MUST NOT arm any
242
+ * idle-shutdown timer on register: it is meant to sit ready until the
243
+ * orchestrator either dispatches a job to it or destroys it.
244
+ *
245
+ * The orchestrator's warm-pool reaper is the sole authority on its lifetime.
246
+ * An agent that also ran its own idle timer would self-terminate behind the
247
+ * reaper's back, re-creating the spawn/reap churn that reaping only surplus
248
+ * agents exists to prevent.
249
+ *
250
+ * Absent on orchestrators that predate warm pools. An agent that does not
251
+ * understand this field arms the short KICI_SCALER_IDLE_TIMEOUT timer exactly
252
+ * as before — so warm pools do not work against it, which is today's
253
+ * behaviour rather than a regression.
254
+ */
255
+ warmPool: z.boolean().optional(),
256
+ /**
207
257
  * Optional agent-facing capabilities this orchestrator supports (absent on
208
258
  * pre-capability orchestrators). The agent reads it to decide whether to
209
259
  * await optional acks like `artifacts.upload.complete.ack`.
@@ -486,7 +536,16 @@ const cacheUploadRequestSchema = z.object({
486
536
  contentHash: z.string().optional(),
487
537
  lockfileHash: z.string().optional(),
488
538
  platform: z.string(),
489
- arch: z.string()
539
+ arch: z.string(),
540
+ /**
541
+ * SHA-256 of the dependency tarball about to be uploaded. Deps uploads only.
542
+ *
543
+ * The dep tarball is stored under its own content hash, so the orchestrator
544
+ * needs it to sign the upload URL — the agent has already built the tarball
545
+ * and hashed it by the time it asks. Optional so an older agent that omits it
546
+ * still gets a usable (lockfile-keyed) URL during a mixed-version rollout.
547
+ */
548
+ depsHash: z.string().optional()
490
549
  });
491
550
  /** Orchestrator -> Agent: return the pre-signed upload URL. */
492
551
  const cacheUploadResponseSchema = z.object({
@@ -775,6 +834,40 @@ const eventEmitResponseSchema = z.object({
775
834
  /** Error description (present on failure). */
776
835
  error: z.string().optional()
777
836
  });
837
+ /**
838
+ * Agent -> Orchestrator: exchanges a single-use claim code (delivered on a
839
+ * `kici.scaler.scale-up` event) for freshly minted ephemeral agent credentials.
840
+ * A provisioned agent normally sends this itself to self-bootstrap — the claim
841
+ * code is the authorization, so it may send it before it authenticates or
842
+ * registers. A provisioning workflow can also send it to obtain the token
843
+ * directly. Additive/negotiated by presence — older peers that never emit it
844
+ * are unaffected, so it needs no `PROTOCOL_VERSION` bump of its own.
845
+ */
846
+ const scalerClaimCredentialsSchema = z.object({
847
+ type: z.literal("scaler.claim-credentials"),
848
+ /** Correlates to the response for this claim. */
849
+ requestId: z.string(),
850
+ /** Single-use code from the scale-up event's payload. */
851
+ claimCode: z.string()
852
+ });
853
+ /**
854
+ * Orchestrator -> Agent: minted ephemeral credentials for a claimed provision,
855
+ * or an error. The token appears only here — never in the persisted event log.
856
+ */
857
+ const scalerClaimCredentialsResponseSchema = z.object({
858
+ type: z.literal("scaler.claim-credentials.response"),
859
+ /** Correlates to the original scaler.claim-credentials requestId. */
860
+ requestId: z.string(),
861
+ /** Minted credentials (present on success). */
862
+ credentials: z.object({
863
+ agentToken: z.string(),
864
+ agentId: z.string(),
865
+ orchestratorUrl: z.string(),
866
+ labels: z.array(z.string())
867
+ }).optional(),
868
+ /** Error description (present on failure). */
869
+ error: z.string().optional()
870
+ });
778
871
  /** Periodic metrics push from agent to orchestrator. */
779
872
  const agentMetricsSchema = z.object({
780
873
  type: z.literal("agent.metrics"),
@@ -939,6 +1032,7 @@ const orchestratorToAgentMessageSchema = z.discriminatedUnion("type", [
939
1032
  artifactsUploadCompleteAckSchema,
940
1033
  artifactsDownloadResponseSchema,
941
1034
  eventEmitResponseSchema,
1035
+ scalerClaimCredentialsResponseSchema,
942
1036
  agentApiResponseSchema,
943
1037
  agentAuthSuccessSchema,
944
1038
  agentAuthFailureSchema,
@@ -970,6 +1064,7 @@ const agentToOrchestratorMessageSchema = z.discriminatedUnion("type", [
970
1064
  artifactsUploadCompleteSchema,
971
1065
  artifactsDownloadRequestSchema,
972
1066
  eventEmitSchema,
1067
+ scalerClaimCredentialsSchema,
973
1068
  agentApiRequestSchema,
974
1069
  agentMetricsSchema,
975
1070
  agentAuthRequestSchema,
@@ -978,6 +1073,6 @@ const agentToOrchestratorMessageSchema = z.discriminatedUnion("type", [
978
1073
  stepApprovalRequestSchema
979
1074
  ]);
980
1075
  //#endregion
981
- export { ArtifactCompleteAckOutcome, ArtifactDownloadOutcome, ArtifactRejectReason, ArtifactUploadOutcome, CacheRefScope, JobRejectReason, StepApprovalOutcome, agentApiRequestSchema, agentApiResponseSchema, agentAuthFailureSchema, agentAuthRequestSchema, agentAuthSuccessSchema, agentLogChunkSchema, agentMetricsSchema, agentRegisterSchema, agentStatusSchema, agentStepStatusSchema, agentToOrchestratorMessageSchema, artifactsDownloadRequestSchema, artifactsDownloadResponseSchema, artifactsUploadCompleteAckSchema, artifactsUploadCompleteSchema, artifactsUploadRequestSchema, artifactsUploadResponseSchema, cacheUserRestoreRequestSchema, cacheUserRestoreResponseSchema, cacheUserSaveCompleteSchema, cacheUserSaveRequestSchema, cacheUserSaveResponseSchema, configAckSchema, eventEmitResponseSchema, eventEmitSchema, fleetBundleChunkSchema, fleetBundleErrorSchema, fleetLogsRequestSchema, gitAuthSchema, globalEvalCandidateResultSchema, globalEvalRoundResultSchema, jobAckSchema, jobCancelSchema, jobConcurrencyAckSchema, jobConcurrencyReportSchema, jobDispatchSchema, jobRejectSchema, jobStatusSchema, orchestratorToAgentMessageSchema, provenanceUploadCompleteSchema, provenanceUploadDeferSchema, provenanceUploadRequestSchema, provenanceUploadResponseSchema, registerAckSchema, stepApprovalPayloadSchema, stepApprovalRequestSchema, stepApprovalResolvedSchema, upstreamSnapshotSchema };
1076
+ export { ArtifactCompleteAckOutcome, ArtifactDownloadOutcome, ArtifactRejectReason, ArtifactUploadOutcome, CacheRefScope, JobRejectReason, StepApprovalOutcome, agentApiRequestSchema, agentApiResponseSchema, agentAuthFailureSchema, agentAuthRequestSchema, agentAuthSuccessSchema, agentLogChunkSchema, agentMetricsSchema, agentRegisterSchema, agentStatusSchema, agentStepStatusSchema, agentToOrchestratorMessageSchema, artifactsDownloadRequestSchema, artifactsDownloadResponseSchema, artifactsUploadCompleteAckSchema, artifactsUploadCompleteSchema, artifactsUploadRequestSchema, artifactsUploadResponseSchema, cacheUserRestoreRequestSchema, cacheUserRestoreResponseSchema, cacheUserSaveCompleteSchema, cacheUserSaveRequestSchema, cacheUserSaveResponseSchema, configAckSchema, eventEmitResponseSchema, eventEmitSchema, fleetBundleChunkSchema, fleetBundleErrorSchema, fleetLogsRequestSchema, gitAuthSchema, globalEvalCandidateResultSchema, globalEvalRoundResultSchema, invokeResultSchema, jobAckSchema, jobCancelSchema, jobConcurrencyAckSchema, jobConcurrencyReportSchema, jobDispatchSchema, jobRejectSchema, jobStatusSchema, orchestratorToAgentMessageSchema, provenanceUploadCompleteSchema, provenanceUploadDeferSchema, provenanceUploadRequestSchema, provenanceUploadResponseSchema, registerAckSchema, scalerClaimCredentialsResponseSchema, scalerClaimCredentialsSchema, stepApprovalPayloadSchema, stepApprovalRequestSchema, stepApprovalResolvedSchema, upstreamSnapshotSchema };
982
1077
 
983
1078
  //# sourceMappingURL=orchestrator-agent.js.map
@@ -16,6 +16,7 @@ declare const scalerCapacitySummarySchema: z.ZodObject<{
16
16
  activeCount: z.ZodNumber;
17
17
  spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
18
18
  mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
19
+ labelSetMandatoryLabels: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
19
20
  }, z.core.$strip>;
20
21
  /** Peer hello: initiator sends ephemeral X25519 public key and nonce. */
21
22
  export declare const peerHelloSchema: z.ZodObject<{
@@ -68,6 +69,7 @@ export declare const peerAuthResponseSchema: z.ZodObject<{
68
69
  activeCount: z.ZodNumber;
69
70
  spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
70
71
  mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
72
+ labelSetMandatoryLabels: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
71
73
  }, z.core.$strip>>>;
72
74
  capabilities: z.ZodOptional<z.ZodObject<{
73
75
  s3LogAccess: z.ZodBoolean;
@@ -109,6 +111,7 @@ export declare const peerHeartbeatSchema: z.ZodObject<{
109
111
  activeCount: z.ZodNumber;
110
112
  spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
111
113
  mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
114
+ labelSetMandatoryLabels: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
112
115
  }, z.core.$strip>>>;
113
116
  configVersion: z.ZodOptional<z.ZodNumber>;
114
117
  registryVersion: z.ZodOptional<z.ZodNumber>;
@@ -495,6 +498,7 @@ export declare const peerToPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObje
495
498
  activeCount: z.ZodNumber;
496
499
  spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
497
500
  mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
501
+ labelSetMandatoryLabels: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
498
502
  }, z.core.$strip>>>;
499
503
  capabilities: z.ZodOptional<z.ZodObject<{
500
504
  s3LogAccess: z.ZodBoolean;
@@ -534,6 +538,7 @@ export declare const peerToPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObje
534
538
  activeCount: z.ZodNumber;
535
539
  spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
536
540
  mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
541
+ labelSetMandatoryLabels: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
537
542
  }, z.core.$strip>>>;
538
543
  configVersion: z.ZodOptional<z.ZodNumber>;
539
544
  registryVersion: z.ZodOptional<z.ZodNumber>;
@@ -809,6 +814,7 @@ export declare const peerFromPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
809
814
  activeCount: z.ZodNumber;
810
815
  spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
811
816
  mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
817
+ labelSetMandatoryLabels: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
812
818
  }, z.core.$strip>>>;
813
819
  capabilities: z.ZodOptional<z.ZodObject<{
814
820
  s3LogAccess: z.ZodBoolean;
@@ -848,6 +854,7 @@ export declare const peerFromPeerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodOb
848
854
  activeCount: z.ZodNumber;
849
855
  spawnsOnLocalHost: z.ZodOptional<z.ZodBoolean>;
850
856
  mandatoryLabels: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
857
+ labelSetMandatoryLabels: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
851
858
  }, z.core.$strip>>>;
852
859
  configVersion: z.ZodOptional<z.ZodNumber>;
853
860
  registryVersion: z.ZodOptional<z.ZodNumber>;
@@ -62,8 +62,25 @@ const scalerCapacitySummarySchema = z.object({
62
62
  * empty the backend has no gate. Cross-peer routing applies the same
63
63
  * rule as the local label matcher: a scaler-capacity entry only
64
64
  * matches when every mandatory label appears in the required label set.
65
+ *
66
+ * @deprecated Use {@link labelSetMandatoryLabels}, which carries one gate
67
+ * per label set. This field is the union across every label set, so a
68
+ * scaler mixing `[linux, gpu]` with `[macos, xcode]` advertises a gate that
69
+ * makes its linux set unroutable. It stays populated for peers that predate
70
+ * the per-label-set field and is removed in v1.0.0.
71
+ */
72
+ mandatoryLabels: z.array(z.string()).optional().default([]),
73
+ /**
74
+ * Per-label-set taint gate, index-aligned with `labelSets`: entry `i` is the
75
+ * gate a job must satisfy to route to `labelSets[i]`.
76
+ *
77
+ * Deliberately `.optional()` with no default. `undefined` is the only value
78
+ * that can mean "this peer predates the field — fall back to the scaler-wide
79
+ * `mandatoryLabels`"; an empty array would read as "every label set is
80
+ * ungated". A consumer also falls back when the length does not equal
81
+ * `labelSets.length`, so a malformed advertisement is never indexed into.
65
82
  */
66
- mandatoryLabels: z.array(z.string()).optional().default([])
83
+ labelSetMandatoryLabels: z.array(z.array(z.string())).optional()
67
84
  });
68
85
  /** Peer hello: initiator sends ephemeral X25519 public key and nonce. */
69
86
  const peerHelloSchema = z.object({
@@ -13,10 +13,91 @@ import { z } from 'zod';
13
13
  * number cannot drift between the two packages that enforce it.
14
14
  */
15
15
  export declare const DEFAULT_APPROVAL_EXPIRY_HOURS = 72;
16
+ /** Seconds in an hour — the one conversion between the two expiry spellings. */
17
+ export declare const SECONDS_PER_HOUR = 3600;
18
+ /**
19
+ * The same documented default as {@link DEFAULT_APPROVAL_EXPIRY_HOURS}, in the
20
+ * granularity the policy actually stores.
21
+ */
22
+ export declare const DEFAULT_APPROVAL_EXPIRY_SECONDS: number;
23
+ /**
24
+ * The shortest expressible security-hold window.
25
+ *
26
+ * One second, not a rounder-looking number: the floor exists to stop a zero or
27
+ * negative value minting an already-expired hold, and any strictly positive
28
+ * integer discharges that. A larger floor would be an invented usability
29
+ * opinion that also puts the window back out of reach of a test.
30
+ */
31
+ export declare const MIN_APPROVAL_EXPIRY_SECONDS = 1;
32
+ /** The longest window the Platform accepts: one year, the bound already applied to hours. */
33
+ export declare const MAX_APPROVAL_EXPIRY_HOURS = 8760;
34
+ /** {@link MAX_APPROVAL_EXPIRY_HOURS} in seconds, so neither spelling outranges the other. */
35
+ export declare const MAX_APPROVAL_EXPIRY_SECONDS: number;
36
+ /**
37
+ * The window a policy actually means, in seconds.
38
+ *
39
+ * `approvalExpirySeconds` is the authority and `approvalExpiryHours` its coarse
40
+ * spelling, so the more specific field wins whenever both are present — the
41
+ * only rule that never discards what an operator asked for. A policy carrying
42
+ * neither (an older peer that sent no window at all) falls back to the
43
+ * documented default.
44
+ */
45
+ export declare function approvalExpirySecondsOf(policy: {
46
+ approvalExpiryHours?: number | null;
47
+ approvalExpirySeconds?: number | null;
48
+ }): number;
49
+ /**
50
+ * The coarse `approvalExpiryHours` view of a window stored in seconds.
51
+ *
52
+ * Rounds UP, and never below one hour. A sub-hour window has no exact hours
53
+ * spelling, and the peer reading this field is one that cannot express the real
54
+ * value anyway — so the choice is which way to be wrong. Rounding up yields a
55
+ * longer hold than asked for, which stays approvable; rounding down yields zero,
56
+ * which is the already-expired hold `MIN_APPROVAL_EXPIRY_SECONDS` exists to
57
+ * prevent.
58
+ */
59
+ export declare function approvalExpiryHoursOf(seconds: number): number;
60
+ /**
61
+ * The org-level fork switch: the setting an org's trust policy carries for how
62
+ * fork pull requests are treated. Each value names what the operator is
63
+ * choosing; which values the orchestrator's trust-policy gate honours, and the
64
+ * mechanism it uses, are owned there rather than here.
65
+ *
66
+ * - `ignore` — the operator declines fork pull requests.
67
+ * - `hold` — the operator requires approval first; the policy's approval expiry
68
+ * bounds how long that approval stays open.
69
+ * - `allow` — the operator permits fork pull requests to run with reduced
70
+ * privilege.
71
+ * - `reject` — deprecated in favour of `ignore`; removed at v1.0.0.
72
+ */
73
+ export declare const ForkPolicy: z.ZodEnum<{
74
+ allow: "allow";
75
+ hold: "hold";
76
+ ignore: "ignore";
77
+ reject: "reject";
78
+ }>;
79
+ export type ForkPolicy = z.infer<typeof ForkPolicy>;
80
+ /**
81
+ * How much CI authority one org member holds.
82
+ *
83
+ * The level the `/kici approve` comment path reads once it has resolved a
84
+ * commenter to a KiCI user id: `write` or `admin` may release a security hold,
85
+ * `read` and `none` may not. Named here rather than spelled inline so the wire
86
+ * schema, the orchestrator's admin route, and `kici-admin` all offer exactly
87
+ * the same four values.
88
+ */
89
+ export declare const CiTrustLevel: z.ZodEnum<{
90
+ admin: "admin";
91
+ none: "none";
92
+ read: "read";
93
+ write: "write";
94
+ }>;
95
+ export type CiTrustLevel = z.infer<typeof CiTrustLevel>;
16
96
  export declare const trustPolicySchema: z.ZodObject<{
17
97
  forkPolicy: z.ZodEnum<{
18
98
  allow: "allow";
19
99
  hold: "hold";
100
+ ignore: "ignore";
20
101
  reject: "reject";
21
102
  }>;
22
103
  unknownContributorPolicy: z.ZodEnum<{
@@ -29,6 +110,7 @@ export declare const trustPolicySchema: z.ZodObject<{
29
110
  reject: "reject";
30
111
  }>;
31
112
  approvalExpiryHours: z.ZodNumber;
113
+ approvalExpirySeconds: z.ZodOptional<z.ZodNumber>;
32
114
  }, z.core.$strip>;
33
115
  export type TrustPolicy = z.infer<typeof trustPolicySchema>;
34
116
  /** Trust policy update pushed from Platform to orchestrator when policy or identity links change. */
@@ -39,6 +121,7 @@ export declare const trustPolicyUpdateSchema: z.ZodObject<{
39
121
  forkPolicy: z.ZodEnum<{
40
122
  allow: "allow";
41
123
  hold: "hold";
124
+ ignore: "ignore";
42
125
  reject: "reject";
43
126
  }>;
44
127
  unknownContributorPolicy: z.ZodEnum<{
@@ -51,6 +134,7 @@ export declare const trustPolicyUpdateSchema: z.ZodObject<{
51
134
  reject: "reject";
52
135
  }>;
53
136
  approvalExpiryHours: z.ZodNumber;
137
+ approvalExpirySeconds: z.ZodOptional<z.ZodNumber>;
54
138
  }, z.core.$strip>;
55
139
  identityLinks: z.ZodArray<z.ZodObject<{
56
140
  userId: z.ZodString;
@@ -275,6 +359,50 @@ export declare const orchMetricsSchema: z.ZodObject<{
275
359
  timestamp: z.ZodNumber;
276
360
  }, z.core.$strip>;
277
361
  export type OrchMetrics = z.infer<typeof orchMetricsSchema>;
362
+ /** Largest worker-peer snapshot accepted on one frame. */
363
+ export declare const CLUSTER_MEMBERSHIP_MAX_WORKERS = 512;
364
+ /**
365
+ * Worker-peer membership snapshot, sent by a coordinator to the Platform.
366
+ *
367
+ * A snapshot rather than a delta: a dropped or reordered frame self-heals on
368
+ * the next send instead of corrupting a running tally. The Platform stores the
369
+ * reported size on `platform_connections` and aggregates it into the org's
370
+ * combined orchestrator count.
371
+ *
372
+ * The array bound is the first line of defence, for the same reason
373
+ * `orchMetricsSchema` bounds its own arrays: a malformed or hostile push must
374
+ * fail Zod parse at the WS edge and never reach the aggregate.
375
+ */
376
+ export declare const clusterMembershipSchema: z.ZodObject<{
377
+ type: z.ZodLiteral<"cluster.membership">;
378
+ workers: z.ZodArray<z.ZodObject<{
379
+ instanceId: z.ZodString;
380
+ }, z.core.$strip>>;
381
+ timestamp: z.ZodNumber;
382
+ }, z.core.$strip>;
383
+ export type ClusterMembership = z.infer<typeof clusterMembershipSchema>;
384
+ /**
385
+ * Per-coordinator orchestrator ceiling, pushed by the Platform.
386
+ *
387
+ * `maxWorkerPeers` is an ABSOLUTE ceiling on this coordinator's connected
388
+ * worker peers, not a remaining allowance. The Platform computes it by
389
+ * excluding this connection's own workers from the org total, so it does not
390
+ * move when a local worker joins or leaves — the coordinator can enforce
391
+ * against its live peer count with no round trip and no staleness window.
392
+ *
393
+ * `orgLimit` and `orgTotal` are informational: they let the coordinator's
394
+ * rejection reason say why, rather than closing opaquely. `evictExcess` is set
395
+ * once the org has been over its limit for longer than the grace window, and
396
+ * asks the coordinator to drain its newest workers down to the ceiling.
397
+ */
398
+ export declare const planHeadroomSchema: z.ZodObject<{
399
+ type: z.ZodLiteral<"plan.headroom">;
400
+ maxWorkerPeers: z.ZodNumber;
401
+ orgLimit: z.ZodNumber;
402
+ orgTotal: z.ZodNumber;
403
+ evictExcess: z.ZodBoolean;
404
+ }, z.core.$strip>;
405
+ export type PlanHeadroom = z.infer<typeof planHeadroomSchema>;
278
406
  /**
279
407
  * Acknowledgment that a webhook was received and processing started.
280
408
  *
@@ -475,6 +603,7 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
475
603
  forkPolicy: z.ZodEnum<{
476
604
  allow: "allow";
477
605
  hold: "hold";
606
+ ignore: "ignore";
478
607
  reject: "reject";
479
608
  }>;
480
609
  unknownContributorPolicy: z.ZodEnum<{
@@ -487,6 +616,7 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
487
616
  reject: "reject";
488
617
  }>;
489
618
  approvalExpiryHours: z.ZodNumber;
619
+ approvalExpirySeconds: z.ZodOptional<z.ZodNumber>;
490
620
  }, z.core.$strip>;
491
621
  identityLinks: z.ZodArray<z.ZodObject<{
492
622
  userId: z.ZodString;
@@ -588,6 +718,12 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
588
718
  orchMetrics: z.ZodOptional<z.ZodBoolean>;
589
719
  oidcMint: z.ZodOptional<z.ZodBoolean>;
590
720
  }, z.core.$loose>;
721
+ }, z.core.$strip>, z.ZodObject<{
722
+ type: z.ZodLiteral<"plan.headroom">;
723
+ maxWorkerPeers: z.ZodNumber;
724
+ orgLimit: z.ZodNumber;
725
+ orgTotal: z.ZodNumber;
726
+ evictExcess: z.ZodBoolean;
591
727
  }, z.core.$strip>, z.ZodObject<{
592
728
  type: z.ZodLiteral<"nack">;
593
729
  messageId: z.ZodOptional<z.ZodString>;
@@ -2893,6 +3029,7 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
2893
3029
  "source_override.set": "source_override.set";
2894
3030
  "sources.list.read": "sources.list.read";
2895
3031
  "step.logs.read": "step.logs.read";
3032
+ "trust_directory.updated": "trust_directory.updated";
2896
3033
  "trust_policy.updated": "trust_policy.updated";
2897
3034
  }>>;
2898
3035
  source: z.ZodOptional<z.ZodEnum<{
@@ -3209,6 +3346,7 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
3209
3346
  routingKey: z.ZodOptional<z.ZodString>;
3210
3347
  repoIdentifier: z.ZodOptional<z.ZodString>;
3211
3348
  workflowRepoIdentifier: z.ZodOptional<z.ZodString>;
3349
+ isGlobalEvalRound: z.ZodOptional<z.ZodBoolean>;
3212
3350
  repoProvider: z.ZodOptional<z.ZodString>;
3213
3351
  localWorkingTree: z.ZodOptional<z.ZodBoolean>;
3214
3352
  sha: z.ZodOptional<z.ZodString>;
@@ -3334,6 +3472,12 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
3334
3472
  message: z.ZodString;
3335
3473
  jobName: z.ZodOptional<z.ZodString>;
3336
3474
  }, z.core.$strip>>;
3475
+ jobKind: z.ZodOptional<z.ZodEnum<{
3476
+ gate: "gate";
3477
+ proxy: "proxy";
3478
+ standard: "standard";
3479
+ }>>;
3480
+ summonedRunId: z.ZodOptional<z.ZodString>;
3337
3481
  }, z.core.$strip>, z.ZodObject<{
3338
3482
  type: z.ZodLiteral<"state.replay">;
3339
3483
  messageId: z.ZodString;
@@ -3636,6 +3780,12 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
3636
3780
  deferred: "deferred";
3637
3781
  "offline-backfill": "offline-backfill";
3638
3782
  }>>;
3783
+ }, z.core.$strip>, z.ZodObject<{
3784
+ type: z.ZodLiteral<"cluster.membership">;
3785
+ workers: z.ZodArray<z.ZodObject<{
3786
+ instanceId: z.ZodString;
3787
+ }, z.core.$strip>>;
3788
+ timestamp: z.ZodNumber;
3639
3789
  }, z.core.$strip>, z.ZodObject<{
3640
3790
  type: z.ZodLiteral<"nack">;
3641
3791
  messageId: z.ZodOptional<z.ZodString>;