@kici-dev/engine 0.1.21 → 0.1.22

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.
@@ -314,6 +314,8 @@ export declare const orchCapabilitiesUpdateSchema: z.ZodObject<{
314
314
  "backends.sync": "backends.sync";
315
315
  "backends.sync_one": "backends.sync_one";
316
316
  "backends.test": "backends.test";
317
+ "fleet.host.declare": "fleet.host.declare";
318
+ "fleet.host.remove": "fleet.host.remove";
317
319
  }> & z.core.$partial, z.ZodBoolean>>;
318
320
  }, z.core.$loose>;
319
321
  }, z.core.$strip>;
@@ -1294,6 +1296,7 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1294
1296
  component: z.ZodString;
1295
1297
  }, z.core.$strip>], "type">;
1296
1298
  heldRunId: z.ZodString;
1299
+ autoApprove: z.ZodOptional<z.ZodBoolean>;
1297
1300
  }, z.core.$strip>, z.ZodObject<{
1298
1301
  type: z.ZodLiteral<"dashboard.held-runs.reject">;
1299
1302
  requestId: z.ZodString;
@@ -1413,6 +1416,123 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1413
1416
  component: z.ZodString;
1414
1417
  }, z.core.$strip>], "type">;
1415
1418
  includeAgents: z.ZodOptional<z.ZodBoolean>;
1419
+ }, z.core.$strip>, z.ZodObject<{
1420
+ type: z.ZodLiteral<"dashboard.fleet.hosts">;
1421
+ requestId: z.ZodString;
1422
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1423
+ type: z.ZodLiteral<"user">;
1424
+ sub: z.ZodString;
1425
+ }, z.core.$strip>, z.ZodObject<{
1426
+ type: z.ZodLiteral<"api_key">;
1427
+ keyId: z.ZodString;
1428
+ ownerSub: z.ZodString;
1429
+ }, z.core.$strip>, z.ZodObject<{
1430
+ type: z.ZodLiteral<"service_account">;
1431
+ id: z.ZodString;
1432
+ }, z.core.$strip>, z.ZodObject<{
1433
+ type: z.ZodLiteral<"platform_operator">;
1434
+ sub: z.ZodString;
1435
+ reason: z.ZodString;
1436
+ sessionId: z.ZodOptional<z.ZodString>;
1437
+ }, z.core.$strip>, z.ZodObject<{
1438
+ type: z.ZodLiteral<"system">;
1439
+ component: z.ZodString;
1440
+ }, z.core.$strip>], "type">;
1441
+ }, z.core.$strip>, z.ZodObject<{
1442
+ type: z.ZodLiteral<"dashboard.fleet.host">;
1443
+ requestId: z.ZodString;
1444
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1445
+ type: z.ZodLiteral<"user">;
1446
+ sub: z.ZodString;
1447
+ }, z.core.$strip>, z.ZodObject<{
1448
+ type: z.ZodLiteral<"api_key">;
1449
+ keyId: z.ZodString;
1450
+ ownerSub: z.ZodString;
1451
+ }, z.core.$strip>, z.ZodObject<{
1452
+ type: z.ZodLiteral<"service_account">;
1453
+ id: z.ZodString;
1454
+ }, z.core.$strip>, z.ZodObject<{
1455
+ type: z.ZodLiteral<"platform_operator">;
1456
+ sub: z.ZodString;
1457
+ reason: z.ZodString;
1458
+ sessionId: z.ZodOptional<z.ZodString>;
1459
+ }, z.core.$strip>, z.ZodObject<{
1460
+ type: z.ZodLiteral<"system">;
1461
+ component: z.ZodString;
1462
+ }, z.core.$strip>], "type">;
1463
+ agentId: z.ZodString;
1464
+ }, z.core.$strip>, z.ZodObject<{
1465
+ type: z.ZodLiteral<"dashboard.fleet.preview">;
1466
+ requestId: z.ZodString;
1467
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1468
+ type: z.ZodLiteral<"user">;
1469
+ sub: z.ZodString;
1470
+ }, z.core.$strip>, z.ZodObject<{
1471
+ type: z.ZodLiteral<"api_key">;
1472
+ keyId: z.ZodString;
1473
+ ownerSub: z.ZodString;
1474
+ }, z.core.$strip>, z.ZodObject<{
1475
+ type: z.ZodLiteral<"service_account">;
1476
+ id: z.ZodString;
1477
+ }, z.core.$strip>, z.ZodObject<{
1478
+ type: z.ZodLiteral<"platform_operator">;
1479
+ sub: z.ZodString;
1480
+ reason: z.ZodString;
1481
+ sessionId: z.ZodOptional<z.ZodString>;
1482
+ }, z.core.$strip>, z.ZodObject<{
1483
+ type: z.ZodLiteral<"system">;
1484
+ component: z.ZodString;
1485
+ }, z.core.$strip>], "type">;
1486
+ workflowName: z.ZodString;
1487
+ }, z.core.$strip>, z.ZodObject<{
1488
+ type: z.ZodLiteral<"dashboard.fleet.host.declare">;
1489
+ requestId: z.ZodString;
1490
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1491
+ type: z.ZodLiteral<"user">;
1492
+ sub: z.ZodString;
1493
+ }, z.core.$strip>, z.ZodObject<{
1494
+ type: z.ZodLiteral<"api_key">;
1495
+ keyId: z.ZodString;
1496
+ ownerSub: z.ZodString;
1497
+ }, z.core.$strip>, z.ZodObject<{
1498
+ type: z.ZodLiteral<"service_account">;
1499
+ id: z.ZodString;
1500
+ }, z.core.$strip>, z.ZodObject<{
1501
+ type: z.ZodLiteral<"platform_operator">;
1502
+ sub: z.ZodString;
1503
+ reason: z.ZodString;
1504
+ sessionId: z.ZodOptional<z.ZodString>;
1505
+ }, z.core.$strip>, z.ZodObject<{
1506
+ type: z.ZodLiteral<"system">;
1507
+ component: z.ZodString;
1508
+ }, z.core.$strip>], "type">;
1509
+ agentId: z.ZodString;
1510
+ labels: z.ZodArray<z.ZodString>;
1511
+ hostname: z.ZodOptional<z.ZodString>;
1512
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
1513
+ }, z.core.$strip>, z.ZodObject<{
1514
+ type: z.ZodLiteral<"dashboard.fleet.host.remove">;
1515
+ requestId: z.ZodString;
1516
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1517
+ type: z.ZodLiteral<"user">;
1518
+ sub: z.ZodString;
1519
+ }, z.core.$strip>, z.ZodObject<{
1520
+ type: z.ZodLiteral<"api_key">;
1521
+ keyId: z.ZodString;
1522
+ ownerSub: z.ZodString;
1523
+ }, z.core.$strip>, z.ZodObject<{
1524
+ type: z.ZodLiteral<"service_account">;
1525
+ id: z.ZodString;
1526
+ }, z.core.$strip>, z.ZodObject<{
1527
+ type: z.ZodLiteral<"platform_operator">;
1528
+ sub: z.ZodString;
1529
+ reason: z.ZodString;
1530
+ sessionId: z.ZodOptional<z.ZodString>;
1531
+ }, z.core.$strip>, z.ZodObject<{
1532
+ type: z.ZodLiteral<"system">;
1533
+ component: z.ZodString;
1534
+ }, z.core.$strip>], "type">;
1535
+ agentId: z.ZodString;
1416
1536
  }, z.core.$strip>, z.ZodObject<{
1417
1537
  type: z.ZodLiteral<"dashboard.scaler.capacity">;
1418
1538
  requestId: z.ZodString;
@@ -1849,6 +1969,8 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1849
1969
  "registration.disable": "registration.disable";
1850
1970
  "registration.delete": "registration.delete";
1851
1971
  "global_workflows.update": "global_workflows.update";
1972
+ "fleet.host.declare": "fleet.host.declare";
1973
+ "fleet.host.remove": "fleet.host.remove";
1852
1974
  "run.detail.read": "run.detail.read";
1853
1975
  "runs.list.read": "runs.list.read";
1854
1976
  "runs.filters.read": "runs.filters.read";
@@ -1888,6 +2010,7 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1888
2010
  "environment.history.read": "environment.history.read";
1889
2011
  "held_run.list.read": "held_run.list.read";
1890
2012
  "held_run.approve": "held_run.approve";
2013
+ "held_run.auto_approve": "held_run.auto_approve";
1891
2014
  "held_run.reject": "held_run.reject";
1892
2015
  "held_run.request": "held_run.request";
1893
2016
  "held_run.expire": "held_run.expire";
@@ -1895,6 +2018,7 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1895
2018
  "diagnostics.read": "diagnostics.read";
1896
2019
  "scaler.capacity.read": "scaler.capacity.read";
1897
2020
  "scaler.agents.read": "scaler.agents.read";
2021
+ "fleet.read": "fleet.read";
1898
2022
  "backend.list.read": "backend.list.read";
1899
2023
  "backend.get.read": "backend.get.read";
1900
2024
  "backend.sync": "backend.sync";
@@ -1931,6 +2055,7 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1931
2055
  backend: "backend";
1932
2056
  diagnostics: "diagnostics";
1933
2057
  scaler: "scaler";
2058
+ fleet: "fleet";
1934
2059
  held_run: "held_run";
1935
2060
  access_log: "access_log";
1936
2061
  event_dlq: "event_dlq";
@@ -2011,6 +2136,27 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
2011
2136
  check: "check";
2012
2137
  "check-fail-on-drift": "check-fail-on-drift";
2013
2138
  }>>;
2139
+ target: z.ZodOptional<z.ZodObject<{
2140
+ values: z.ZodArray<z.ZodObject<{
2141
+ include: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2142
+ kind: z.ZodLiteral<"exact">;
2143
+ value: z.ZodString;
2144
+ }, z.core.$strip>, z.ZodObject<{
2145
+ kind: z.ZodLiteral<"regex">;
2146
+ source: z.ZodString;
2147
+ flags: z.ZodString;
2148
+ }, z.core.$strip>], "kind">>;
2149
+ exclude: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
2150
+ kind: z.ZodLiteral<"exact">;
2151
+ value: z.ZodString;
2152
+ }, z.core.$strip>, z.ZodObject<{
2153
+ kind: z.ZodLiteral<"regex">;
2154
+ source: z.ZodString;
2155
+ flags: z.ZodString;
2156
+ }, z.core.$strip>], "kind">>;
2157
+ }, z.core.$strip>>;
2158
+ allowEmpty: z.ZodBoolean;
2159
+ }, z.core.$strip>>;
2014
2160
  secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2015
2161
  encryptedSecrets: z.ZodOptional<z.ZodString>;
2016
2162
  encryptedSecretsKey: z.ZodOptional<z.ZodString>;
@@ -2309,6 +2455,8 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
2309
2455
  "backends.sync": "backends.sync";
2310
2456
  "backends.sync_one": "backends.sync_one";
2311
2457
  "backends.test": "backends.test";
2458
+ "fleet.host.declare": "fleet.host.declare";
2459
+ "fleet.host.remove": "fleet.host.remove";
2312
2460
  }> & z.core.$partial, z.ZodBoolean>>;
2313
2461
  }, z.core.$loose>;
2314
2462
  }, z.core.$strip>, z.ZodObject<{
@@ -2329,6 +2477,7 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
2329
2477
  universal_git: "universal_git";
2330
2478
  local: "local";
2331
2479
  }>;
2480
+ slug: z.ZodOptional<z.ZodString>;
2332
2481
  }, z.core.$strip>>;
2333
2482
  instanceId: z.ZodOptional<z.ZodString>;
2334
2483
  clusterName: z.ZodOptional<z.ZodString>;
@@ -2341,6 +2490,20 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
2341
2490
  independent: "independent";
2342
2491
  }>>;
2343
2492
  scalerBackends: z.ZodOptional<z.ZodArray<z.ZodString>>;
2493
+ deployment: z.ZodOptional<z.ZodObject<{
2494
+ mode: z.ZodEnum<{
2495
+ unknown: "unknown";
2496
+ systemd: "systemd";
2497
+ launchd: "launchd";
2498
+ windows: "windows";
2499
+ compose: "compose";
2500
+ }>;
2501
+ containerName: z.ZodOptional<z.ZodString>;
2502
+ containerRuntime: z.ZodOptional<z.ZodEnum<{
2503
+ podman: "podman";
2504
+ docker: "docker";
2505
+ }>>;
2506
+ }, z.core.$strip>>;
2344
2507
  s3LogAccess: z.ZodOptional<z.ZodBoolean>;
2345
2508
  queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
2346
2509
  }, z.core.$strip>, z.ZodObject<{
@@ -2388,6 +2551,8 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
2388
2551
  "backends.sync": "backends.sync";
2389
2552
  "backends.sync_one": "backends.sync_one";
2390
2553
  "backends.test": "backends.test";
2554
+ "fleet.host.declare": "fleet.host.declare";
2555
+ "fleet.host.remove": "fleet.host.remove";
2391
2556
  }> & z.core.$partial, z.ZodBoolean>>;
2392
2557
  }, z.core.$loose>>;
2393
2558
  }, z.core.$strip>, z.ZodObject<{
@@ -56,6 +56,7 @@ export declare const sourceRegistrationSchema: z.ZodObject<{
56
56
  universal_git: "universal_git";
57
57
  local: "local";
58
58
  }>;
59
+ slug: z.ZodOptional<z.ZodString>;
59
60
  }, z.core.$strip>>;
60
61
  instanceId: z.ZodOptional<z.ZodString>;
61
62
  clusterName: z.ZodOptional<z.ZodString>;
@@ -68,6 +69,20 @@ export declare const sourceRegistrationSchema: z.ZodObject<{
68
69
  independent: "independent";
69
70
  }>>;
70
71
  scalerBackends: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
+ deployment: z.ZodOptional<z.ZodObject<{
73
+ mode: z.ZodEnum<{
74
+ unknown: "unknown";
75
+ systemd: "systemd";
76
+ launchd: "launchd";
77
+ windows: "windows";
78
+ compose: "compose";
79
+ }>;
80
+ containerName: z.ZodOptional<z.ZodString>;
81
+ containerRuntime: z.ZodOptional<z.ZodEnum<{
82
+ podman: "podman";
83
+ docker: "docker";
84
+ }>>;
85
+ }, z.core.$strip>>;
71
86
  s3LogAccess: z.ZodOptional<z.ZodBoolean>;
72
87
  queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
73
88
  }, z.core.$strip>;
@@ -1,4 +1,5 @@
1
1
  import "../../chunk-BTugEXQM.js";
2
+ import { DeploymentIdentitySchema } from "./deployment-identity.js";
2
3
  import { z } from "zod";
3
4
  //#region src/protocol/messages/source-registration.ts
4
5
  /**
@@ -54,7 +55,15 @@ const sourceRegistrationSchema = z.object({
54
55
  * Fine-grained source subtype. See {@link SourceSubtype} for the full
55
56
  * mapping. Required — pre-release, no backward-compat shims.
56
57
  */
57
- subtype: SourceSubtype
58
+ subtype: SourceSubtype,
59
+ /**
60
+ * GitHub App slug (the URL-safe identifier GitHub assigns, e.g.
61
+ * `my-kici-app`). Only set for GitHub-App sources, where GitHub is the
62
+ * source of truth for both the display `name` and the `slug`. Optional —
63
+ * generic / universal-git / local sources have no slug, and a GitHub
64
+ * source whose identity fetch hasn't run yet leaves it unset.
65
+ */
66
+ slug: z.string().min(1).optional()
58
67
  })),
59
68
  /** Orchestrator cluster instance ID for peer correlation. */
60
69
  instanceId: z.string().optional(),
@@ -91,6 +100,13 @@ const sourceRegistrationSchema = z.object({
91
100
  ]).optional(),
92
101
  /** Scaler backends configured on this orchestrator (e.g. ["container", "firecracker"]). */
93
102
  scalerBackends: z.array(z.string()).optional(),
103
+ /**
104
+ * How the orchestrator process itself was deployed (systemd/launchd/windows/
105
+ * compose/unknown), used by the dashboard to build the correct kici-admin
106
+ * invocation. Optional: older orchestrators that haven't been redeployed don't
107
+ * publish it, in which case the dashboard treats the shape as `unknown`.
108
+ */
109
+ deployment: DeploymentIdentitySchema.optional(),
94
110
  /** Whether this orchestrator has S3 log storage configured. Used for multi-orch pool validation. */
95
111
  s3LogAccess: z.boolean().optional(),
96
112
  /** Queue timeout in ms. Platform uses this (with margin) for safety-net GC of stale queued jobs. */
@@ -20,11 +20,12 @@ import { z } from 'zod';
20
20
  import type { ProviderType } from '../provider/types.js';
21
21
  import type { ApproverClause } from '../approval/types.js';
22
22
  import { LabelMatcher } from '../labels-match.js';
23
+ import { ExecutionJobStatus } from '../protocol/messages/execution-status.js';
23
24
  /** Schema version - increment on breaking changes */
24
- export declare const SCHEMA_VERSION: 21;
25
+ export declare const SCHEMA_VERSION: 22;
25
26
  /**
26
27
  * Normalized approval config carried in the lock file. Produced by the compiler
27
- * from an SDK `requireApproval` at any of the three levels; consumed by the
28
+ * from an SDK `approval` at any of the three levels; consumed by the
28
29
  * orchestrator dispatch gate (and the agent step round-trip for step scope).
29
30
  */
30
31
  export interface LockApproval {
@@ -34,6 +35,11 @@ export interface LockApproval {
34
35
  readonly reason?: string;
35
36
  /** Per-gate expiry override (seconds); falls back to the org default. */
36
37
  readonly timeoutSeconds?: number;
38
+ /**
39
+ * When the gate fires. `always` (default) gates before the element; `drift`
40
+ * gates between a step's check and run on detected drift (step scope only).
41
+ */
42
+ readonly when: 'always' | 'drift';
37
43
  }
38
44
  /**
39
45
  * Source file reference with meaningful path.
@@ -352,38 +358,84 @@ export interface LockInlineValue {
352
358
  /** Type guard for inline expression values */
353
359
  export declare function isLockInlineValue(value: unknown): value is LockInlineValue;
354
360
  /**
355
- * Per-edge failure policy for a `needs` dependency: `skip` propagates an
356
- * upstream failure to the downstream job (default), `run` runs the downstream
357
- * job regardless of the upstream outcome. Single source of truth for this
358
- * value across lock-file schemas and protocol messages.
361
+ * Author-facing keyword sugar for a `needs` edge's run condition. Each keyword
362
+ * resolves (at compile time) to a set of upstream terminal statuses; the
363
+ * downstream edge is dispatch-satisfied when the upstream's terminal status is
364
+ * a member of that set.
359
365
  */
360
- export declare const IfFailedPolicy: z.ZodEnum<{
361
- run: "run";
362
- skip: "skip";
366
+ export declare const NeedsWhen: z.ZodEnum<{
367
+ always: "always";
368
+ "on-success": "on-success";
369
+ "on-skip": "on-skip";
370
+ "on-failure": "on-failure";
363
371
  }>;
364
- export type IfFailedPolicy = z.infer<typeof IfFailedPolicy>;
365
- /**
366
- * Needs entry with per-edge failure policy.
367
- * Used in lock file needs arrays for explicit ifFailed override.
372
+ export type NeedsWhen = z.infer<typeof NeedsWhen>;
373
+ /**
374
+ * Normalized, DB-evaluable run condition for a `needs` edge: the non-empty set
375
+ * of upstream terminal statuses that satisfy the edge. The lock file and the
376
+ * orchestrator scheduler only ever see this resolved set (never a keyword), so
377
+ * gating stays a pure status-set membership test.
378
+ */
379
+ export declare const NeedsRunOn: z.ZodArray<z.ZodEnum<{
380
+ skipped: "skipped";
381
+ success: "success";
382
+ pending: "pending";
383
+ running: "running";
384
+ failed: "failed";
385
+ cancelled: "cancelled";
386
+ cancelling: "cancelling";
387
+ queued: "queued";
388
+ recovering: "recovering";
389
+ timed_out_stale: "timed_out_stale";
390
+ drift_dropped: "drift_dropped";
391
+ }>>;
392
+ export type NeedsRunOn = z.infer<typeof NeedsRunOn>;
393
+ /**
394
+ * Resolve the author-facing `when` (keyword sugar | raw status-set | unset) to
395
+ * the normalized status-set. An unset `when` defaults to success-only — the
396
+ * downstream runs only when the upstream succeeded.
397
+ */
398
+ export declare function resolveWhenToRunOn(when: NeedsWhen | ExecutionJobStatus[] | undefined): ExecutionJobStatus[];
399
+ /**
400
+ * Needs entry carrying the normalized run-on status-set.
401
+ * Used in lock file needs arrays for an explicit per-edge run condition.
368
402
  */
369
403
  export declare const NeedsEntrySchema: z.ZodObject<{
370
404
  name: z.ZodString;
371
- ifFailed: z.ZodDefault<z.ZodEnum<{
372
- run: "run";
373
- skip: "skip";
374
- }>>;
405
+ runOn: z.ZodDefault<z.ZodArray<z.ZodEnum<{
406
+ skipped: "skipped";
407
+ success: "success";
408
+ pending: "pending";
409
+ running: "running";
410
+ failed: "failed";
411
+ cancelled: "cancelled";
412
+ cancelling: "cancelling";
413
+ queued: "queued";
414
+ recovering: "recovering";
415
+ timed_out_stale: "timed_out_stale";
416
+ drift_dropped: "drift_dropped";
417
+ }>>>;
375
418
  }, z.core.$strip>;
376
419
  export type NeedsEntry = z.infer<typeof NeedsEntrySchema>;
377
420
  /**
378
- * Needs group entry with per-edge failure policy.
421
+ * Needs group entry carrying the normalized run-on status-set.
379
422
  * Used in lock file needs arrays for dynamic group dependencies.
380
423
  */
381
424
  export declare const NeedsGroupEntrySchema: z.ZodObject<{
382
425
  group: z.ZodString;
383
- ifFailed: z.ZodDefault<z.ZodEnum<{
384
- run: "run";
385
- skip: "skip";
386
- }>>;
426
+ runOn: z.ZodDefault<z.ZodArray<z.ZodEnum<{
427
+ skipped: "skipped";
428
+ success: "success";
429
+ pending: "pending";
430
+ running: "running";
431
+ failed: "failed";
432
+ cancelled: "cancelled";
433
+ cancelling: "cancelling";
434
+ queued: "queued";
435
+ recovering: "recovering";
436
+ timed_out_stale: "timed_out_stale";
437
+ drift_dropped: "drift_dropped";
438
+ }>>>;
387
439
  }, z.core.$strip>;
388
440
  export type NeedsGroupEntry = z.infer<typeof NeedsGroupEntrySchema>;
389
441
  /**
@@ -1,4 +1,5 @@
1
1
  import "../chunk-BTugEXQM.js";
2
+ import { ExecutionJobStatus, TERMINAL_JOB_STATES } from "../protocol/messages/execution-status.js";
2
3
  import { z } from "zod";
3
4
  //#region src/trigger/types.ts
4
5
  /**
@@ -20,33 +21,61 @@ import { z } from "zod";
20
21
  * Schema version 20: runsOn/runsOnAll/excludeLabels carry LabelMatcher (exact|regex) for glob+regex selectors.
21
22
  */
22
23
  /** Schema version - increment on breaking changes */
23
- const SCHEMA_VERSION = 21;
24
+ const SCHEMA_VERSION = 22;
24
25
  /** Type guard for inline expression values */
25
26
  function isLockInlineValue(value) {
26
27
  return typeof value === "object" && value !== null && value._type === "inline";
27
28
  }
28
29
  /**
29
- * Per-edge failure policy for a `needs` dependency: `skip` propagates an
30
- * upstream failure to the downstream job (default), `run` runs the downstream
31
- * job regardless of the upstream outcome. Single source of truth for this
32
- * value across lock-file schemas and protocol messages.
30
+ * Author-facing keyword sugar for a `needs` edge's run condition. Each keyword
31
+ * resolves (at compile time) to a set of upstream terminal statuses; the
32
+ * downstream edge is dispatch-satisfied when the upstream's terminal status is
33
+ * a member of that set.
33
34
  */
34
- const IfFailedPolicy = z.enum(["skip", "run"]);
35
+ const NeedsWhen = z.enum([
36
+ "on-success",
37
+ "always",
38
+ "on-skip",
39
+ "on-failure"
40
+ ]);
41
+ /**
42
+ * Normalized, DB-evaluable run condition for a `needs` edge: the non-empty set
43
+ * of upstream terminal statuses that satisfy the edge. The lock file and the
44
+ * orchestrator scheduler only ever see this resolved set (never a keyword), so
45
+ * gating stays a pure status-set membership test.
46
+ */
47
+ const NeedsRunOn = z.array(ExecutionJobStatus).nonempty();
48
+ const WHEN_TO_RUN_ON = {
49
+ "on-success": [ExecutionJobStatus.enum.success],
50
+ always: [...TERMINAL_JOB_STATES],
51
+ "on-skip": [ExecutionJobStatus.enum.success, ExecutionJobStatus.enum.skipped],
52
+ "on-failure": [ExecutionJobStatus.enum.failed, ExecutionJobStatus.enum.timed_out_stale]
53
+ };
54
+ /**
55
+ * Resolve the author-facing `when` (keyword sugar | raw status-set | unset) to
56
+ * the normalized status-set. An unset `when` defaults to success-only — the
57
+ * downstream runs only when the upstream succeeded.
58
+ */
59
+ function resolveWhenToRunOn(when) {
60
+ if (when === void 0) return [ExecutionJobStatus.enum.success];
61
+ if (Array.isArray(when)) return when;
62
+ return WHEN_TO_RUN_ON[when];
63
+ }
35
64
  /**
36
- * Needs entry with per-edge failure policy.
37
- * Used in lock file needs arrays for explicit ifFailed override.
65
+ * Needs entry carrying the normalized run-on status-set.
66
+ * Used in lock file needs arrays for an explicit per-edge run condition.
38
67
  */
39
68
  const NeedsEntrySchema = z.object({
40
69
  name: z.string(),
41
- ifFailed: IfFailedPolicy.default(IfFailedPolicy.enum.skip)
70
+ runOn: NeedsRunOn.default([ExecutionJobStatus.enum.success])
42
71
  });
43
72
  /**
44
- * Needs group entry with per-edge failure policy.
73
+ * Needs group entry carrying the normalized run-on status-set.
45
74
  * Used in lock file needs arrays for dynamic group dependencies.
46
75
  */
47
76
  const NeedsGroupEntrySchema = z.object({
48
77
  group: z.string(),
49
- ifFailed: IfFailedPolicy.default(IfFailedPolicy.enum.skip)
78
+ runOn: NeedsRunOn.default([ExecutionJobStatus.enum.success])
50
79
  });
51
80
  /**
52
81
  * Failure policy for a host fan-out (`runsOnAll`) when an expected durable host
@@ -74,6 +103,6 @@ function isLockDynamicJobFn(job) {
74
103
  return job._type === "dynamic";
75
104
  }
76
105
  //#endregion
77
- export { IfFailedPolicy, NeedsEntrySchema, NeedsGroupEntrySchema, OnUnreachableMode, SCHEMA_VERSION, isLockDynamicJobFn, isLockInlineValue, isLockStaticJob };
106
+ export { NeedsEntrySchema, NeedsGroupEntrySchema, NeedsRunOn, NeedsWhen, OnUnreachableMode, SCHEMA_VERSION, isLockDynamicJobFn, isLockInlineValue, isLockStaticJob, resolveWhenToRunOn };
78
107
 
79
108
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kici-dev/engine",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Shared business logic for the KiCI CI/CD stack: protocol, triggers, state machine, and provider interfaces used by the Platform relay, orchestrator, and compiler.",
5
5
  "keywords": [
6
6
  "ci",
package/sbom.spdx.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "spdxVersion": "SPDX-2.3",
3
3
  "dataLicense": "CC0-1.0",
4
4
  "SPDXID": "SPDXRef-DOCUMENT",
5
- "name": "@kici-dev/engine@0.1.21",
6
- "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fengine/0.1.21/e80a4720-81f4-4549-ae95-80ee7a5c127e",
5
+ "name": "@kici-dev/engine@0.1.22",
6
+ "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fengine/0.1.22/5dc6919d-c8a2-40b2-aba3-44650ecac92f",
7
7
  "creationInfo": {
8
- "created": "2026-06-23T05:10:06Z",
8
+ "created": "2026-06-24T06:02:58Z",
9
9
  "creators": [
10
10
  "Tool: kici-sbom-generator"
11
11
  ]
@@ -54,7 +54,7 @@
54
54
  {
55
55
  "SPDXID": "SPDXRef-RootPackage",
56
56
  "name": "@kici-dev/engine",
57
- "versionInfo": "0.1.21",
57
+ "versionInfo": "0.1.22",
58
58
  "downloadLocation": "NOASSERTION",
59
59
  "filesAnalyzed": false,
60
60
  "licenseConcluded": "NOASSERTION",
@@ -65,7 +65,7 @@
65
65
  {
66
66
  "referenceCategory": "PACKAGE-MANAGER",
67
67
  "referenceType": "purl",
68
- "referenceLocator": "pkg:npm/%40kici-dev/engine@0.1.21"
68
+ "referenceLocator": "pkg:npm/%40kici-dev/engine@0.1.22"
69
69
  }
70
70
  ],
71
71
  "description": "Shared business logic for the KiCI CI/CD stack: protocol, triggers, state machine, and provider interfaces used by the Platform relay, orchestrator, and compiler.",