@kici-dev/engine 0.1.27 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/approval/types.d.ts +8 -1
  2. package/dist/approval/types.js +8 -1
  3. package/dist/artifacts/name.d.ts +60 -0
  4. package/dist/artifacts/name.js +71 -0
  5. package/dist/audit/access-log-policy.d.ts +1 -1
  6. package/dist/audit/access-log-policy.js +8 -0
  7. package/dist/audit/activity.d.ts +12 -12
  8. package/dist/audit/retention-policy.js +16 -0
  9. package/dist/billing/plan-type.d.ts +53 -0
  10. package/dist/billing/plan-type.js +70 -0
  11. package/dist/bundler/rolldown-config.d.ts +3 -3
  12. package/dist/check-mode.d.ts +1 -1
  13. package/dist/context/concurrency-strategy.d.ts +34 -0
  14. package/dist/context/concurrency-strategy.js +35 -0
  15. package/dist/context/held-run-job-id.d.ts +45 -0
  16. package/dist/context/held-run-job-id.js +56 -0
  17. package/dist/context/held-run-status.d.ts +33 -0
  18. package/dist/context/held-run-status.js +37 -0
  19. package/dist/context/hold-expiry.d.ts +20 -0
  20. package/dist/context/hold-expiry.js +25 -0
  21. package/dist/context/hold-reason.d.ts +33 -0
  22. package/dist/context/hold-reason.js +23 -0
  23. package/dist/context/hold-type.d.ts +40 -0
  24. package/dist/context/hold-type.js +61 -0
  25. package/dist/context/index.d.ts +9 -1
  26. package/dist/context/index.js +9 -2
  27. package/dist/context/multi-context.d.ts +3 -3
  28. package/dist/context/scope-name.d.ts +29 -0
  29. package/dist/context/scope-name.js +49 -0
  30. package/dist/context/scope-resolver.d.ts +33 -0
  31. package/dist/context/scope-resolver.js +45 -15
  32. package/dist/context/types.d.ts +8 -5
  33. package/dist/dev-ops/operations.d.ts +8 -0
  34. package/dist/dev-ops/operations.js +36 -19
  35. package/dist/diagnostics/infra-alert.d.ts +71 -0
  36. package/dist/diagnostics/infra-alert.js +60 -0
  37. package/dist/env/environment-allowlist.d.ts +4 -4
  38. package/dist/fanout/materialize.d.ts +16 -0
  39. package/dist/fanout/materialize.js +32 -3
  40. package/dist/index.d.ts +15 -6
  41. package/dist/index.js +34 -19
  42. package/dist/inputs/descriptor.d.ts +9 -9
  43. package/dist/inventory.d.ts +4 -4
  44. package/dist/labels.d.ts +82 -2
  45. package/dist/labels.js +119 -1
  46. package/dist/matrix/expand.d.ts +49 -2
  47. package/dist/matrix/expand.js +102 -13
  48. package/dist/matrix/format.d.ts +6 -1
  49. package/dist/matrix/format.js +6 -1
  50. package/dist/mcp/held-run-resolve.d.ts +7 -10
  51. package/dist/mcp/held-run-resolve.js +33 -7
  52. package/dist/metrics/catalog-policy.js +4 -4
  53. package/dist/metrics/metric-catalog.generated.d.ts +959 -739
  54. package/dist/metrics/metric-catalog.generated.js +284 -20
  55. package/dist/metrics/metric-kind-compat.d.ts +26 -0
  56. package/dist/metrics/metric-kind-compat.js +33 -0
  57. package/dist/protocol/analytics-events.d.ts +6 -6
  58. package/dist/protocol/dashboard-api-errors.d.ts +1 -0
  59. package/dist/protocol/dashboard-api-errors.js +5 -1
  60. package/dist/protocol/dashboard-write-operations.d.ts +143 -86
  61. package/dist/protocol/dashboard-write-operations.js +91 -17
  62. package/dist/protocol/messages/access-log.d.ts +437 -392
  63. package/dist/protocol/messages/access-log.js +11 -2
  64. package/dist/protocol/messages/actor.d.ts +2 -2
  65. package/dist/protocol/messages/agent-dev-ops.d.ts +4 -2
  66. package/dist/protocol/messages/agent-dev-ops.js +2 -5
  67. package/dist/protocol/messages/agent-run-result.d.ts +72 -62
  68. package/dist/protocol/messages/auth.d.ts +35 -23
  69. package/dist/protocol/messages/browser.d.ts +81 -5
  70. package/dist/protocol/messages/browser.js +53 -2
  71. package/dist/protocol/messages/capabilities.d.ts +106 -31
  72. package/dist/protocol/messages/capabilities.js +94 -10
  73. package/dist/protocol/messages/common.d.ts +45 -2
  74. package/dist/protocol/messages/common.js +64 -3
  75. package/dist/protocol/messages/dashboard-sealed-write.d.ts +52 -0
  76. package/dist/protocol/messages/dashboard-sealed-write.js +57 -0
  77. package/dist/protocol/messages/dashboard.d.ts +1026 -498
  78. package/dist/protocol/messages/dashboard.js +208 -31
  79. package/dist/protocol/messages/deployment-identity.d.ts +37 -10
  80. package/dist/protocol/messages/deployment-identity.js +30 -3
  81. package/dist/protocol/messages/event-log.d.ts +5 -5
  82. package/dist/protocol/messages/execution-status.d.ts +189 -53
  83. package/dist/protocol/messages/execution-status.js +108 -40
  84. package/dist/protocol/messages/heartbeat-health.d.ts +83 -0
  85. package/dist/protocol/messages/heartbeat-health.js +87 -0
  86. package/dist/protocol/messages/log-stream.d.ts +18 -0
  87. package/dist/protocol/messages/log-stream.js +19 -0
  88. package/dist/protocol/messages/oidc-mint.d.ts +7 -0
  89. package/dist/protocol/messages/oidc-mint.js +7 -0
  90. package/dist/protocol/messages/orchestrator-agent.d.ts +264 -67
  91. package/dist/protocol/messages/orchestrator-agent.js +170 -5
  92. package/dist/protocol/messages/pat-kind.d.ts +1 -1
  93. package/dist/protocol/messages/peer.d.ts +122 -58
  94. package/dist/protocol/messages/peer.js +37 -2
  95. package/dist/protocol/messages/platform-orchestrator.d.ts +561 -217
  96. package/dist/protocol/messages/platform-orchestrator.js +131 -21
  97. package/dist/protocol/messages/run-events.d.ts +5 -5
  98. package/dist/protocol/messages/scaler-event.d.ts +3 -3
  99. package/dist/protocol/messages/source-registration.d.ts +56 -13
  100. package/dist/protocol/messages/source-registration.js +49 -6
  101. package/dist/protocol/source-origin.d.ts +1 -1
  102. package/dist/provenance/attestation-origin.d.ts +1 -1
  103. package/dist/provenance/schema.d.ts +11 -11
  104. package/dist/provenance/verify.js +2 -1
  105. package/dist/provider/changed-files-fetcher.d.ts +21 -2
  106. package/dist/provider/check-run-conclusion.d.ts +2 -2
  107. package/dist/provider/check-status-poster.d.ts +23 -0
  108. package/dist/provider/index.d.ts +2 -2
  109. package/dist/registration/registerable-trigger-type.d.ts +14 -13
  110. package/dist/registration/registerable-trigger-type.js +1 -0
  111. package/dist/sandbox/capabilities.d.ts +6 -0
  112. package/dist/sandbox/capabilities.js +57 -0
  113. package/dist/scaler/scaler-backend-type.d.ts +1 -1
  114. package/dist/status/presentation.d.ts +89 -0
  115. package/dist/status/presentation.js +163 -0
  116. package/dist/trigger/compiled-matchers.d.ts +13 -0
  117. package/dist/trigger/compiled-matchers.js +44 -0
  118. package/dist/trigger/event-buckets.d.ts +44 -0
  119. package/dist/trigger/event-buckets.js +93 -0
  120. package/dist/trigger/matcher.d.ts +7 -3
  121. package/dist/trigger/matcher.js +53 -15
  122. package/dist/trigger/schedule-key.d.ts +14 -0
  123. package/dist/trigger/schedule-key.js +21 -0
  124. package/dist/trigger/trigger-event-type.d.ts +1 -1
  125. package/dist/trigger/trigger-event-type.js +2 -0
  126. package/dist/trigger/types.d.ts +173 -43
  127. package/dist/trigger/types.js +82 -25
  128. package/dist/webhook/event-types.d.ts +56 -0
  129. package/dist/webhook/event-types.js +59 -0
  130. package/dist/ws/ws-like.d.ts +13 -0
  131. package/package.json +12 -4
  132. package/sbom.spdx.json +10 -10
  133. package/dist/environment/host-match.d.ts +0 -25
  134. package/dist/environment/index.d.ts +0 -6
  135. package/dist/environment/multi-env.d.ts +0 -30
  136. package/dist/environment/scope-resolver.d.ts +0 -46
  137. package/dist/environment/scope-template.d.ts +0 -18
  138. package/dist/environment/types.d.ts +0 -119
  139. package/dist/package-manager.d.ts +0 -20
  140. package/dist/protocol/messages/observe.d.ts +0 -76
  141. package/dist/protocol/messages/saas-orchestrator.d.ts +0 -2179
  142. package/dist/protocol/messages/test-run.d.ts +0 -59
  143. package/dist/state-machine/index.d.ts +0 -2
  144. package/dist/state-machine/index.js +0 -3
  145. package/dist/state-machine/machine.d.ts +0 -34
  146. package/dist/state-machine/machine.js +0 -103
  147. package/dist/state-machine/types.d.ts +0 -34
  148. package/dist/state-machine/types.js +0 -15
@@ -24,28 +24,37 @@ export declare const CONTEXTS_MAX = 30;
24
24
  * transitions to `cancelled`.
25
25
  */
26
26
  export declare const ExecutionRunStatus: z.ZodEnum<{
27
- success: "success";
28
- pending: "pending";
29
- running: "running";
30
- failed: "failed";
31
27
  cancelled: "cancelled";
32
28
  cancelling: "cancelling";
29
+ failed: "failed";
33
30
  held: "held";
31
+ pending: "pending";
32
+ running: "running";
33
+ success: "success";
34
34
  }>;
35
35
  export type ExecutionRunStatus = z.infer<typeof ExecutionRunStatus>;
36
- /** Status values for execution jobs (execution_jobs table + job.status protocol messages). */
36
+ /**
37
+ * Status values for execution jobs (execution_jobs table + job.status protocol messages).
38
+ *
39
+ * `unroutable` = the job's `runsOn` matched no agent for the whole queue
40
+ * window, so it never ran. Distinct from `failed` (a failed job ran and has
41
+ * logs to read; an unroutable one has a fleet/label problem to fix), from
42
+ * `skipped` (a condition deliberately excluded it) and from `timed_out_stale`
43
+ * (capacity existed but never freed up).
44
+ */
37
45
  export declare const ExecutionJobStatus: z.ZodEnum<{
38
- skipped: "skipped";
39
- success: "success";
40
- pending: "pending";
41
- running: "running";
42
- failed: "failed";
43
46
  cancelled: "cancelled";
44
47
  cancelling: "cancelling";
48
+ drift_dropped: "drift_dropped";
49
+ failed: "failed";
50
+ pending: "pending";
45
51
  queued: "queued";
46
52
  recovering: "recovering";
53
+ running: "running";
54
+ skipped: "skipped";
55
+ success: "success";
47
56
  timed_out_stale: "timed_out_stale";
48
- drift_dropped: "drift_dropped";
57
+ unroutable: "unroutable";
49
58
  }>;
50
59
  export type ExecutionJobStatus = z.infer<typeof ExecutionJobStatus>;
51
60
  /**
@@ -65,12 +74,12 @@ export declare function statusOptionsForLevel(level: 'run' | 'job'): readonly st
65
74
  * - `cancelled` — a parallel-group sibling aborted by fail-fast (NOT a failure).
66
75
  */
67
76
  export declare const ExecutionStepStatus: z.ZodEnum<{
68
- skipped: "skipped";
69
- success: "success";
77
+ cancelled: "cancelled";
78
+ failed: "failed";
70
79
  pending: "pending";
71
80
  running: "running";
72
- failed: "failed";
73
- cancelled: "cancelled";
81
+ skipped: "skipped";
82
+ success: "success";
74
83
  }>;
75
84
  export type ExecutionStepStatus = z.infer<typeof ExecutionStepStatus>;
76
85
  /**
@@ -83,9 +92,9 @@ export type ExecutionStepStatus = z.infer<typeof ExecutionStepStatus>;
83
92
  * only for the dashboard band aggregate, not persisted per step.
84
93
  */
85
94
  export declare const StepConcurrencyKind: z.ZodEnum<{
86
- sequential: "sequential";
87
95
  "parallel-child": "parallel-child";
88
96
  "parallel-group": "parallel-group";
97
+ sequential: "sequential";
89
98
  }>;
90
99
  export type StepConcurrencyKind = z.infer<typeof StepConcurrencyKind>;
91
100
  /**
@@ -115,21 +124,45 @@ export type TimeoutReason = z.infer<typeof TimeoutReason>;
115
124
  * Scope is carried separately on `initFailureSchema.scope`:
116
125
  * - `run`-scoped categories fail the whole run before any job runs
117
126
  * (secret_resolution, install_secrets, lock_resolution,
118
- * build_coordination).
127
+ * build_coordination, approval_misconfig, sandbox_denied, trust_policy).
119
128
  * - `job`-scoped categories fail one job and leave siblings alone
120
129
  * (context_rules, dynamic_eval, no_agent, matrix_expansion).
121
130
  */
122
131
  export declare const InitFailureCategory: z.ZodEnum<{
123
- secret_resolution: "secret_resolution";
124
- install_secrets: "install_secrets";
125
- lock_resolution: "lock_resolution";
132
+ approval_misconfig: "approval_misconfig";
126
133
  build_coordination: "build_coordination";
127
134
  context_rules: "context_rules";
128
135
  dynamic_eval: "dynamic_eval";
129
- no_agent: "no_agent";
136
+ install_secrets: "install_secrets";
137
+ lock_resolution: "lock_resolution";
130
138
  matrix_expansion: "matrix_expansion";
139
+ no_agent: "no_agent";
140
+ sandbox_denied: "sandbox_denied";
141
+ secret_resolution: "secret_resolution";
142
+ trust_policy: "trust_policy";
131
143
  }>;
132
144
  export type InitFailureCategory = z.infer<typeof InitFailureCategory>;
145
+ /**
146
+ * Why a terminal run failed (only meaningful for failed/cancelled runs):
147
+ * - never_started — init failure (no_agent/secret/lock/build); no step ran.
148
+ * - timed_out — a job timed out (never dispatched, or agent went silent).
149
+ * - dead_orchestrator — the Platform failed the run because its orchestrator died.
150
+ * - step_failure — a job actually ran and failed.
151
+ * - cancelled — the run was cancelled.
152
+ *
153
+ * Derived at run completion from the terminal job statuses, because
154
+ * `timed_out`/`step_failure` both collapse to run-status `failed` — the status
155
+ * alone can't carry it. `never_started` is stamped by the init-failure paths and
156
+ * `dead_orchestrator` is stamped Platform-side by the dead-orchestrator detector.
157
+ */
158
+ export declare const RunFailureClass: z.ZodEnum<{
159
+ cancelled: "cancelled";
160
+ dead_orchestrator: "dead_orchestrator";
161
+ never_started: "never_started";
162
+ step_failure: "step_failure";
163
+ timed_out: "timed_out";
164
+ }>;
165
+ export type RunFailureClass = z.infer<typeof RunFailureClass>;
133
166
  /**
134
167
  * `step_type` values for the user-facing cache pseudo-steps that appear in the
135
168
  * run timeline. Mirrors the `hook:*` pseudo-step `step_type` convention: each
@@ -158,13 +191,21 @@ export type CacheRunEventType = z.infer<typeof CacheRunEventType>;
158
191
  * - `error` — the restore/save failed (pack/extract/transport error).
159
192
  */
160
193
  export declare const CacheOutcome: z.ZodEnum<{
161
- skipped: "skipped";
162
194
  error: "error";
163
195
  hit: "hit";
164
196
  miss: "miss";
165
197
  saved: "saved";
198
+ skipped: "skipped";
166
199
  }>;
167
200
  export type CacheOutcome = z.infer<typeof CacheOutcome>;
201
+ /**
202
+ * Failure reason the Platform records on a run it fails because that run's
203
+ * orchestrator disconnected and did not reconnect within the stale threshold.
204
+ * Written by the Platform stale-detector into `execution_runs.failure_reason`
205
+ * and matched by the dashboard to render the "stale / offline" run badge. A
206
+ * shared constant so the writer (Platform) and reader (dashboard) never drift.
207
+ */
208
+ export declare const DEAD_ORCH_FAILURE_REASON = "Orchestrator disconnected and did not recover";
168
209
  /** Structured init-failure signal. Presence on a run/job means "never started". */
169
210
  export declare const initFailureSchema: z.ZodObject<{
170
211
  scope: z.ZodEnum<{
@@ -172,14 +213,17 @@ export declare const initFailureSchema: z.ZodObject<{
172
213
  run: "run";
173
214
  }>;
174
215
  category: z.ZodEnum<{
175
- secret_resolution: "secret_resolution";
176
- install_secrets: "install_secrets";
177
- lock_resolution: "lock_resolution";
216
+ approval_misconfig: "approval_misconfig";
178
217
  build_coordination: "build_coordination";
179
218
  context_rules: "context_rules";
180
219
  dynamic_eval: "dynamic_eval";
181
- no_agent: "no_agent";
220
+ install_secrets: "install_secrets";
221
+ lock_resolution: "lock_resolution";
182
222
  matrix_expansion: "matrix_expansion";
223
+ no_agent: "no_agent";
224
+ sandbox_denied: "sandbox_denied";
225
+ secret_resolution: "secret_resolution";
226
+ trust_policy: "trust_policy";
183
227
  }>;
184
228
  message: z.ZodString;
185
229
  jobName: z.ZodOptional<z.ZodString>;
@@ -189,6 +233,20 @@ export type InitFailure = z.infer<typeof initFailureSchema>;
189
233
  export declare const TERMINAL_RUN_STATES: ReadonlySet<string>;
190
234
  /** Terminal job states that indicate the job is no longer running. */
191
235
  export declare const TERMINAL_JOB_STATES: ReadonlySet<string>;
236
+ /**
237
+ * The type-level counterpart of `TERMINAL_JOB_STATES`.
238
+ *
239
+ * Written as `Exclude<>` of the non-terminal statuses, never `Extract<>` of the
240
+ * terminal ones. That direction is load-bearing: `Extract<ExecutionJobStatus,
241
+ * 'success' | …>` does not widen when a value is added to the enum, so an
242
+ * exhaustive switch over it keeps compiling and its `never` default arm is
243
+ * inert. `Exclude<>` does widen, so a new status becomes a compile error at
244
+ * every switch that claims to be total over the terminal set — which is the
245
+ * only reason to write such a switch.
246
+ */
247
+ export type TerminalJobStatus = Exclude<ExecutionJobStatus, 'pending' | 'queued' | 'running' | 'recovering' | 'cancelling'>;
248
+ /** Terminal step states that indicate the step is no longer running. */
249
+ export declare const TERMINAL_STEP_STATES: ReadonlySet<string>;
192
250
  /** Structured execution status update for Platform metadata tracking. */
193
251
  export declare const executionStatusSchema: z.ZodObject<{
194
252
  type: z.ZodLiteral<"execution.status">;
@@ -196,14 +254,15 @@ export declare const executionStatusSchema: z.ZodObject<{
196
254
  runId: z.ZodString;
197
255
  workflowName: z.ZodString;
198
256
  status: z.ZodEnum<{
199
- success: "success";
200
- pending: "pending";
201
- running: "running";
202
- failed: "failed";
203
257
  cancelled: "cancelled";
204
258
  cancelling: "cancelling";
259
+ failed: "failed";
205
260
  held: "held";
261
+ pending: "pending";
262
+ running: "running";
263
+ success: "success";
206
264
  }>;
265
+ routingKey: z.ZodOptional<z.ZodString>;
207
266
  repoIdentifier: z.ZodOptional<z.ZodString>;
208
267
  repoProvider: z.ZodOptional<z.ZodString>;
209
268
  localWorkingTree: z.ZodOptional<z.ZodBoolean>;
@@ -231,18 +290,28 @@ export declare const executionStatusSchema: z.ZodObject<{
231
290
  run: "run";
232
291
  }>;
233
292
  category: z.ZodEnum<{
234
- secret_resolution: "secret_resolution";
235
- install_secrets: "install_secrets";
236
- lock_resolution: "lock_resolution";
293
+ approval_misconfig: "approval_misconfig";
237
294
  build_coordination: "build_coordination";
238
295
  context_rules: "context_rules";
239
296
  dynamic_eval: "dynamic_eval";
240
- no_agent: "no_agent";
297
+ install_secrets: "install_secrets";
298
+ lock_resolution: "lock_resolution";
241
299
  matrix_expansion: "matrix_expansion";
300
+ no_agent: "no_agent";
301
+ sandbox_denied: "sandbox_denied";
302
+ secret_resolution: "secret_resolution";
303
+ trust_policy: "trust_policy";
242
304
  }>;
243
305
  message: z.ZodString;
244
306
  jobName: z.ZodOptional<z.ZodString>;
245
307
  }, z.core.$strip>>;
308
+ failureClass: z.ZodOptional<z.ZodEnum<{
309
+ cancelled: "cancelled";
310
+ dead_orchestrator: "dead_orchestrator";
311
+ never_started: "never_started";
312
+ step_failure: "step_failure";
313
+ timed_out: "timed_out";
314
+ }>>;
246
315
  }, z.core.$strip>;
247
316
  /** Per-step status forwarded from agent to Platform (real-time). */
248
317
  export declare const stepStatusForwardSchema: z.ZodObject<{
@@ -254,20 +323,20 @@ export declare const stepStatusForwardSchema: z.ZodObject<{
254
323
  stepIndex: z.ZodNumber;
255
324
  stepName: z.ZodString;
256
325
  state: z.ZodEnum<{
257
- skipped: "skipped";
258
- success: "success";
326
+ cancelled: "cancelled";
327
+ failed: "failed";
259
328
  pending: "pending";
260
329
  running: "running";
261
- failed: "failed";
262
- cancelled: "cancelled";
330
+ skipped: "skipped";
331
+ success: "success";
263
332
  }>;
264
333
  timestamp: z.ZodNumber;
265
334
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
266
335
  secretsAccessed: z.ZodOptional<z.ZodArray<z.ZodString>>;
267
336
  concurrencyKind: z.ZodOptional<z.ZodEnum<{
268
- sequential: "sequential";
269
337
  "parallel-child": "parallel-child";
270
338
  "parallel-group": "parallel-group";
339
+ sequential: "sequential";
271
340
  }>>;
272
341
  groupId: z.ZodOptional<z.ZodString>;
273
342
  }, z.core.$strip>;
@@ -279,17 +348,18 @@ export declare const jobStatusForwardSchema: z.ZodObject<{
279
348
  jobId: z.ZodString;
280
349
  jobName: z.ZodString;
281
350
  status: z.ZodEnum<{
282
- skipped: "skipped";
283
- success: "success";
284
- pending: "pending";
285
- running: "running";
286
- failed: "failed";
287
351
  cancelled: "cancelled";
288
352
  cancelling: "cancelling";
353
+ drift_dropped: "drift_dropped";
354
+ failed: "failed";
355
+ pending: "pending";
289
356
  queued: "queued";
290
357
  recovering: "recovering";
358
+ running: "running";
359
+ skipped: "skipped";
360
+ success: "success";
291
361
  timed_out_stale: "timed_out_stale";
292
- drift_dropped: "drift_dropped";
362
+ unroutable: "unroutable";
293
363
  }>;
294
364
  matrixValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
295
365
  startedAt: z.ZodOptional<z.ZodNumber>;
@@ -308,20 +378,79 @@ export declare const jobStatusForwardSchema: z.ZodObject<{
308
378
  run: "run";
309
379
  }>;
310
380
  category: z.ZodEnum<{
311
- secret_resolution: "secret_resolution";
312
- install_secrets: "install_secrets";
313
- lock_resolution: "lock_resolution";
381
+ approval_misconfig: "approval_misconfig";
314
382
  build_coordination: "build_coordination";
315
383
  context_rules: "context_rules";
316
384
  dynamic_eval: "dynamic_eval";
317
- no_agent: "no_agent";
385
+ install_secrets: "install_secrets";
386
+ lock_resolution: "lock_resolution";
318
387
  matrix_expansion: "matrix_expansion";
388
+ no_agent: "no_agent";
389
+ sandbox_denied: "sandbox_denied";
390
+ secret_resolution: "secret_resolution";
391
+ trust_policy: "trust_policy";
319
392
  }>;
320
393
  message: z.ZodString;
321
394
  jobName: z.ZodOptional<z.ZodString>;
322
395
  }, z.core.$strip>>;
323
396
  }, z.core.$strip>;
324
397
  /** State replay sent on orchestrator reconnection -- full snapshot of active runs and jobs. */
398
+ /**
399
+ * A single run's full mirror-projection shape, as carried in `state.replay`.
400
+ *
401
+ * Carried by the orchestrator-reconnect `state.replay` push and consumed by the
402
+ * Platform's shared `upsertRunMirror` mirror-projection helper. Extracting it as
403
+ * a named schema keeps a single source of truth for any future reconciliation
404
+ * path that projects the same per-run shape.
405
+ */
406
+ export declare const stateReplayRunSchema: z.ZodObject<{
407
+ runId: z.ZodString;
408
+ workflowName: z.ZodString;
409
+ status: z.ZodEnum<{
410
+ cancelled: "cancelled";
411
+ cancelling: "cancelling";
412
+ failed: "failed";
413
+ held: "held";
414
+ pending: "pending";
415
+ running: "running";
416
+ success: "success";
417
+ }>;
418
+ routingKey: z.ZodOptional<z.ZodString>;
419
+ repoIdentifier: z.ZodOptional<z.ZodString>;
420
+ sha: z.ZodOptional<z.ZodString>;
421
+ ref: z.ZodOptional<z.ZodString>;
422
+ triggerEvent: z.ZodOptional<z.ZodString>;
423
+ commitMessage: z.ZodOptional<z.ZodString>;
424
+ jobCount: z.ZodNumber;
425
+ startedAt: z.ZodNumber;
426
+ completedAt: z.ZodOptional<z.ZodNumber>;
427
+ durationMs: z.ZodOptional<z.ZodNumber>;
428
+ parentRunId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
429
+ originalRunId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
430
+ triggeredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
431
+ triggeredByAgentLabel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
432
+ failureReason: z.ZodOptional<z.ZodString>;
433
+ failureClass: z.ZodOptional<z.ZodEnum<{
434
+ cancelled: "cancelled";
435
+ dead_orchestrator: "dead_orchestrator";
436
+ never_started: "never_started";
437
+ step_failure: "step_failure";
438
+ timed_out: "timed_out";
439
+ }>>;
440
+ jobs: z.ZodArray<z.ZodObject<{
441
+ jobId: z.ZodString;
442
+ jobName: z.ZodString;
443
+ status: z.ZodString;
444
+ startedAt: z.ZodOptional<z.ZodNumber>;
445
+ completedAt: z.ZodOptional<z.ZodNumber>;
446
+ durationMs: z.ZodOptional<z.ZodNumber>;
447
+ errorMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
448
+ agentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
449
+ runsOnLabels: z.ZodOptional<z.ZodArray<z.ZodString>>;
450
+ contexts: z.ZodOptional<z.ZodArray<z.ZodString>>;
451
+ }, z.core.$strip>>;
452
+ }, z.core.$strip>;
453
+ export type StateReplayRun = z.infer<typeof stateReplayRunSchema>;
325
454
  export declare const stateReplaySchema: z.ZodObject<{
326
455
  type: z.ZodLiteral<"state.replay">;
327
456
  messageId: z.ZodString;
@@ -329,13 +458,13 @@ export declare const stateReplaySchema: z.ZodObject<{
329
458
  runId: z.ZodString;
330
459
  workflowName: z.ZodString;
331
460
  status: z.ZodEnum<{
332
- success: "success";
333
- pending: "pending";
334
- running: "running";
335
- failed: "failed";
336
461
  cancelled: "cancelled";
337
462
  cancelling: "cancelling";
463
+ failed: "failed";
338
464
  held: "held";
465
+ pending: "pending";
466
+ running: "running";
467
+ success: "success";
339
468
  }>;
340
469
  routingKey: z.ZodOptional<z.ZodString>;
341
470
  repoIdentifier: z.ZodOptional<z.ZodString>;
@@ -352,6 +481,13 @@ export declare const stateReplaySchema: z.ZodObject<{
352
481
  triggeredBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
353
482
  triggeredByAgentLabel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
354
483
  failureReason: z.ZodOptional<z.ZodString>;
484
+ failureClass: z.ZodOptional<z.ZodEnum<{
485
+ cancelled: "cancelled";
486
+ dead_orchestrator: "dead_orchestrator";
487
+ never_started: "never_started";
488
+ step_failure: "step_failure";
489
+ timed_out: "timed_out";
490
+ }>>;
355
491
  jobs: z.ZodArray<z.ZodObject<{
356
492
  jobId: z.ZodString;
357
493
  jobName: z.ZodString;
@@ -34,7 +34,15 @@ const ExecutionRunStatus = z.enum([
34
34
  "cancelling",
35
35
  "held"
36
36
  ]);
37
- /** Status values for execution jobs (execution_jobs table + job.status protocol messages). */
37
+ /**
38
+ * Status values for execution jobs (execution_jobs table + job.status protocol messages).
39
+ *
40
+ * `unroutable` = the job's `runsOn` matched no agent for the whole queue
41
+ * window, so it never ran. Distinct from `failed` (a failed job ran and has
42
+ * logs to read; an unroutable one has a fleet/label problem to fix), from
43
+ * `skipped` (a condition deliberately excluded it) and from `timed_out_stale`
44
+ * (capacity existed but never freed up).
45
+ */
38
46
  const ExecutionJobStatus = z.enum([
39
47
  "pending",
40
48
  "queued",
@@ -46,7 +54,8 @@ const ExecutionJobStatus = z.enum([
46
54
  "cancelled",
47
55
  "skipped",
48
56
  "timed_out_stale",
49
- "drift_dropped"
57
+ "drift_dropped",
58
+ "unroutable"
50
59
  ]);
51
60
  /**
52
61
  * The status values a notification subscription may target at the given level.
@@ -111,7 +120,7 @@ const TimeoutReason = z.enum(["job_timeout", "workflow_timeout"]);
111
120
  * Scope is carried separately on `initFailureSchema.scope`:
112
121
  * - `run`-scoped categories fail the whole run before any job runs
113
122
  * (secret_resolution, install_secrets, lock_resolution,
114
- * build_coordination).
123
+ * build_coordination, approval_misconfig, sandbox_denied, trust_policy).
115
124
  * - `job`-scoped categories fail one job and leave siblings alone
116
125
  * (context_rules, dynamic_eval, no_agent, matrix_expansion).
117
126
  */
@@ -123,7 +132,30 @@ const InitFailureCategory = z.enum([
123
132
  "context_rules",
124
133
  "dynamic_eval",
125
134
  "no_agent",
126
- "matrix_expansion"
135
+ "matrix_expansion",
136
+ "approval_misconfig",
137
+ "sandbox_denied",
138
+ "trust_policy"
139
+ ]);
140
+ /**
141
+ * Why a terminal run failed (only meaningful for failed/cancelled runs):
142
+ * - never_started — init failure (no_agent/secret/lock/build); no step ran.
143
+ * - timed_out — a job timed out (never dispatched, or agent went silent).
144
+ * - dead_orchestrator — the Platform failed the run because its orchestrator died.
145
+ * - step_failure — a job actually ran and failed.
146
+ * - cancelled — the run was cancelled.
147
+ *
148
+ * Derived at run completion from the terminal job statuses, because
149
+ * `timed_out`/`step_failure` both collapse to run-status `failed` — the status
150
+ * alone can't carry it. `never_started` is stamped by the init-failure paths and
151
+ * `dead_orchestrator` is stamped Platform-side by the dead-orchestrator detector.
152
+ */
153
+ const RunFailureClass = z.enum([
154
+ "never_started",
155
+ "timed_out",
156
+ "dead_orchestrator",
157
+ "step_failure",
158
+ "cancelled"
127
159
  ]);
128
160
  /**
129
161
  * `step_type` values for the user-facing cache pseudo-steps that appear in the
@@ -151,6 +183,14 @@ const CacheOutcome = z.enum([
151
183
  "skipped",
152
184
  "error"
153
185
  ]);
186
+ /**
187
+ * Failure reason the Platform records on a run it fails because that run's
188
+ * orchestrator disconnected and did not reconnect within the stale threshold.
189
+ * Written by the Platform stale-detector into `execution_runs.failure_reason`
190
+ * and matched by the dashboard to render the "stale / offline" run badge. A
191
+ * shared constant so the writer (Platform) and reader (dashboard) never drift.
192
+ */
193
+ const DEAD_ORCH_FAILURE_REASON = "Orchestrator disconnected and did not recover";
154
194
  /** Structured init-failure signal. Presence on a run/job means "never started". */
155
195
  const initFailureSchema = z.object({
156
196
  scope: z.enum(["run", "job"]),
@@ -173,7 +213,15 @@ const TERMINAL_JOB_STATES = /* @__PURE__ */ new Set([
173
213
  ExecutionJobStatus.enum.cancelled,
174
214
  ExecutionJobStatus.enum.skipped,
175
215
  ExecutionJobStatus.enum.timed_out_stale,
176
- ExecutionJobStatus.enum.drift_dropped
216
+ ExecutionJobStatus.enum.drift_dropped,
217
+ ExecutionJobStatus.enum.unroutable
218
+ ]);
219
+ /** Terminal step states that indicate the step is no longer running. */
220
+ const TERMINAL_STEP_STATES = /* @__PURE__ */ new Set([
221
+ ExecutionStepStatus.enum.success,
222
+ ExecutionStepStatus.enum.failed,
223
+ ExecutionStepStatus.enum.skipped,
224
+ ExecutionStepStatus.enum.cancelled
177
225
  ]);
178
226
  /** Structured execution status update for Platform metadata tracking. */
179
227
  const executionStatusSchema = z.object({
@@ -182,6 +230,13 @@ const executionStatusSchema = z.object({
182
230
  runId: z.string().max(128),
183
231
  workflowName: z.string().max(128),
184
232
  status: ExecutionRunStatus,
233
+ /**
234
+ * Routing key of the run's own source. Optional for backward compatibility
235
+ * with older orchestrators (absent → the Platform falls back to the WS
236
+ * connection's first routing key). Lets the Platform mirror attribute each
237
+ * run to its real source even when one orchestrator serves multiple sources.
238
+ */
239
+ routingKey: z.string().max(128).optional(),
185
240
  repoIdentifier: z.string().max(256).optional(),
186
241
  /**
187
242
  * Run-level repo provider (origin host: `github` / `gitlab` / `bitbucket` /
@@ -236,7 +291,9 @@ const executionStatusSchema = z.object({
236
291
  * never executed a single step. Persisted in execution_runs.init_failure
237
292
  * on both orchestrator and Platform sides. Only present when status === 'failed'.
238
293
  */
239
- initFailure: initFailureSchema.optional()
294
+ initFailure: initFailureSchema.optional(),
295
+ /** Why a terminal run failed (only present for failed/cancelled runs). */
296
+ failureClass: RunFailureClass.optional()
240
297
  });
241
298
  /** Per-step status forwarded from agent to Platform (real-time). */
242
299
  const stepStatusForwardSchema = z.object({
@@ -288,45 +345,56 @@ const jobStatusForwardSchema = z.object({
288
345
  initFailure: initFailureSchema.optional()
289
346
  });
290
347
  /** State replay sent on orchestrator reconnection -- full snapshot of active runs and jobs. */
348
+ /**
349
+ * A single run's full mirror-projection shape, as carried in `state.replay`.
350
+ *
351
+ * Carried by the orchestrator-reconnect `state.replay` push and consumed by the
352
+ * Platform's shared `upsertRunMirror` mirror-projection helper. Extracting it as
353
+ * a named schema keeps a single source of truth for any future reconciliation
354
+ * path that projects the same per-run shape.
355
+ */
356
+ const stateReplayRunSchema = z.object({
357
+ runId: z.string().max(128),
358
+ workflowName: z.string().max(128),
359
+ status: ExecutionRunStatus,
360
+ routingKey: z.string().max(128).optional(),
361
+ repoIdentifier: z.string().max(256).optional(),
362
+ sha: z.string().max(128).optional(),
363
+ ref: z.string().max(128).optional(),
364
+ triggerEvent: z.string().max(128).optional(),
365
+ commitMessage: z.string().max(STATUS_FREE_TEXT_MAX).optional(),
366
+ jobCount: z.number(),
367
+ startedAt: z.number(),
368
+ completedAt: z.number().optional(),
369
+ durationMs: z.number().optional(),
370
+ parentRunId: z.string().max(128).nullable().optional(),
371
+ originalRunId: z.string().max(128).nullable().optional(),
372
+ triggeredBy: z.string().max(128).nullable().optional(),
373
+ triggeredByAgentLabel: z.string().max(128).nullable().optional(),
374
+ /** Human-readable reason why the run failed (only present for failed runs). */
375
+ failureReason: z.string().max(STATUS_FREE_TEXT_MAX).optional(),
376
+ /** Why the run failed (`RunFailureClass`); only present for failed/cancelled runs. */
377
+ failureClass: RunFailureClass.optional(),
378
+ jobs: z.array(z.object({
379
+ jobId: z.string().max(128),
380
+ jobName: z.string().max(128),
381
+ status: z.string().max(128),
382
+ startedAt: z.number().optional(),
383
+ completedAt: z.number().optional(),
384
+ durationMs: z.number().optional(),
385
+ errorMessage: z.string().max(STATUS_FREE_TEXT_MAX).nullable().optional(),
386
+ agentId: z.string().max(128).nullable().optional(),
387
+ runsOnLabels: z.array(z.string().max(128)).max(30).optional(),
388
+ contexts: z.array(z.string().max(128)).max(30).optional()
389
+ })).max(MAX_JOBS_PER_RUN)
390
+ });
291
391
  const stateReplaySchema = z.object({
292
392
  type: z.literal("state.replay"),
293
393
  messageId: z.string().max(128),
294
- runs: z.array(z.object({
295
- runId: z.string().max(128),
296
- workflowName: z.string().max(128),
297
- status: ExecutionRunStatus,
298
- routingKey: z.string().max(128).optional(),
299
- repoIdentifier: z.string().max(256).optional(),
300
- sha: z.string().max(128).optional(),
301
- ref: z.string().max(128).optional(),
302
- triggerEvent: z.string().max(128).optional(),
303
- commitMessage: z.string().max(STATUS_FREE_TEXT_MAX).optional(),
304
- jobCount: z.number(),
305
- startedAt: z.number(),
306
- completedAt: z.number().optional(),
307
- durationMs: z.number().optional(),
308
- parentRunId: z.string().max(128).nullable().optional(),
309
- originalRunId: z.string().max(128).nullable().optional(),
310
- triggeredBy: z.string().max(128).nullable().optional(),
311
- triggeredByAgentLabel: z.string().max(128).nullable().optional(),
312
- /** Human-readable reason why the run failed (only present for failed runs). */
313
- failureReason: z.string().max(STATUS_FREE_TEXT_MAX).optional(),
314
- jobs: z.array(z.object({
315
- jobId: z.string().max(128),
316
- jobName: z.string().max(128),
317
- status: z.string().max(128),
318
- startedAt: z.number().optional(),
319
- completedAt: z.number().optional(),
320
- durationMs: z.number().optional(),
321
- errorMessage: z.string().max(STATUS_FREE_TEXT_MAX).nullable().optional(),
322
- agentId: z.string().max(128).nullable().optional(),
323
- runsOnLabels: z.array(z.string().max(128)).max(30).optional(),
324
- contexts: z.array(z.string().max(128)).max(30).optional()
325
- })).max(MAX_JOBS_PER_RUN)
326
- })).max(500),
394
+ runs: z.array(stateReplayRunSchema).max(500),
327
395
  timestamp: z.number()
328
396
  });
329
397
  //#endregion
330
- export { CONTEXTS_MAX, CacheOutcome, CacheRunEventType, CacheStepType, ExecutionJobStatus, ExecutionRunStatus, ExecutionStepStatus, InitFailureCategory, MAX_JOBS_PER_RUN, REPO_IDENTIFIER_MAX, RUNS_ON_LABELS_MAX, STATE_REPLAY_MAX_RUNS, STATUS_FREE_TEXT_MAX, STATUS_ID_MAX, StepConcurrencyKind, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, TimeoutReason, executionStatusSchema, initFailureSchema, jobStatusForwardSchema, stateReplaySchema, statusOptionsForLevel, stepStatusForwardSchema };
398
+ export { CONTEXTS_MAX, CacheOutcome, CacheRunEventType, CacheStepType, DEAD_ORCH_FAILURE_REASON, ExecutionJobStatus, ExecutionRunStatus, ExecutionStepStatus, InitFailureCategory, MAX_JOBS_PER_RUN, REPO_IDENTIFIER_MAX, RUNS_ON_LABELS_MAX, RunFailureClass, STATE_REPLAY_MAX_RUNS, STATUS_FREE_TEXT_MAX, STATUS_ID_MAX, StepConcurrencyKind, TERMINAL_JOB_STATES, TERMINAL_RUN_STATES, TERMINAL_STEP_STATES, TimeoutReason, executionStatusSchema, initFailureSchema, jobStatusForwardSchema, stateReplayRunSchema, stateReplaySchema, statusOptionsForLevel, stepStatusForwardSchema };
331
399
 
332
400
  //# sourceMappingURL=execution-status.js.map