@kici-dev/engine 0.1.26 → 0.2.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 (157) hide show
  1. package/dist/approval/types.d.ts +11 -4
  2. package/dist/approval/types.js +11 -4
  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 +20 -11
  7. package/dist/audit/activity.d.ts +12 -12
  8. package/dist/audit/retention-policy.js +40 -22
  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/{environment → context}/host-match.js +1 -1
  26. package/dist/context/index.d.ts +14 -0
  27. package/dist/context/index.js +12 -0
  28. package/dist/context/multi-context.d.ts +30 -0
  29. package/dist/context/multi-context.js +38 -0
  30. package/dist/context/scope-name.d.ts +29 -0
  31. package/dist/context/scope-name.js +49 -0
  32. package/dist/context/scope-resolver.d.ts +79 -0
  33. package/dist/{environment → context}/scope-resolver.js +47 -17
  34. package/dist/{environment → context}/scope-template.js +1 -1
  35. package/dist/{environment → context}/types.d.ts +25 -22
  36. package/dist/{environment → context}/types.js +3 -3
  37. package/dist/dev-ops/operations.d.ts +9 -1
  38. package/dist/dev-ops/operations.js +37 -20
  39. package/dist/diagnostics/infra-alert.d.ts +71 -0
  40. package/dist/diagnostics/infra-alert.js +60 -0
  41. package/dist/env/environment-allowlist.d.ts +26 -3
  42. package/dist/env/environment-allowlist.js +35 -1
  43. package/dist/fanout/materialize.d.ts +16 -0
  44. package/dist/fanout/materialize.js +34 -5
  45. package/dist/index.d.ts +16 -7
  46. package/dist/index.js +38 -23
  47. package/dist/inputs/descriptor.d.ts +9 -9
  48. package/dist/inventory.d.ts +4 -4
  49. package/dist/labels.d.ts +82 -2
  50. package/dist/labels.js +119 -1
  51. package/dist/matrix/expand.d.ts +49 -2
  52. package/dist/matrix/expand.js +102 -13
  53. package/dist/matrix/format.d.ts +6 -1
  54. package/dist/matrix/format.js +6 -1
  55. package/dist/mcp/held-run-resolve.d.ts +7 -10
  56. package/dist/mcp/held-run-resolve.js +33 -7
  57. package/dist/metrics/catalog-policy.js +4 -4
  58. package/dist/metrics/metric-catalog.generated.d.ts +954 -734
  59. package/dist/metrics/metric-catalog.generated.js +296 -32
  60. package/dist/metrics/metric-kind-compat.d.ts +26 -0
  61. package/dist/metrics/metric-kind-compat.js +33 -0
  62. package/dist/protocol/analytics-events.d.ts +6 -6
  63. package/dist/protocol/dashboard-api-errors.d.ts +13 -0
  64. package/dist/protocol/dashboard-api-errors.js +17 -0
  65. package/dist/protocol/dashboard-write-operations.d.ts +143 -86
  66. package/dist/protocol/dashboard-write-operations.js +143 -69
  67. package/dist/protocol/messages/access-log.d.ts +438 -388
  68. package/dist/protocol/messages/access-log.js +24 -14
  69. package/dist/protocol/messages/actor.d.ts +2 -2
  70. package/dist/protocol/messages/agent-dev-ops.d.ts +4 -2
  71. package/dist/protocol/messages/agent-dev-ops.js +2 -5
  72. package/dist/protocol/messages/agent-run-result.d.ts +74 -64
  73. package/dist/protocol/messages/agent-run-result.js +1 -1
  74. package/dist/protocol/messages/auth.d.ts +35 -23
  75. package/dist/protocol/messages/browser.d.ts +81 -5
  76. package/dist/protocol/messages/browser.js +53 -2
  77. package/dist/protocol/messages/capabilities.d.ts +106 -31
  78. package/dist/protocol/messages/capabilities.js +94 -10
  79. package/dist/protocol/messages/common.d.ts +45 -2
  80. package/dist/protocol/messages/common.js +64 -3
  81. package/dist/protocol/messages/dashboard-sealed-write.d.ts +52 -0
  82. package/dist/protocol/messages/dashboard-sealed-write.js +57 -0
  83. package/dist/protocol/messages/dashboard.d.ts +1232 -706
  84. package/dist/protocol/messages/dashboard.js +387 -220
  85. package/dist/protocol/messages/deployment-identity.d.ts +37 -10
  86. package/dist/protocol/messages/deployment-identity.js +30 -3
  87. package/dist/protocol/messages/event-log.d.ts +5 -5
  88. package/dist/protocol/messages/execution-status.d.ts +198 -62
  89. package/dist/protocol/messages/execution-status.js +114 -46
  90. package/dist/protocol/messages/heartbeat-health.d.ts +83 -0
  91. package/dist/protocol/messages/heartbeat-health.js +87 -0
  92. package/dist/protocol/messages/log-stream.d.ts +18 -0
  93. package/dist/protocol/messages/log-stream.js +19 -0
  94. package/dist/protocol/messages/oidc-mint.d.ts +7 -0
  95. package/dist/protocol/messages/oidc-mint.js +7 -0
  96. package/dist/protocol/messages/orchestrator-agent.d.ts +264 -67
  97. package/dist/protocol/messages/orchestrator-agent.js +170 -5
  98. package/dist/protocol/messages/pat-kind.d.ts +1 -1
  99. package/dist/protocol/messages/peer.d.ts +122 -58
  100. package/dist/protocol/messages/peer.js +37 -2
  101. package/dist/protocol/messages/platform-orchestrator.d.ts +603 -258
  102. package/dist/protocol/messages/platform-orchestrator.js +131 -21
  103. package/dist/protocol/messages/run-events.d.ts +5 -5
  104. package/dist/protocol/messages/scaler-event.d.ts +3 -3
  105. package/dist/protocol/messages/source-registration.d.ts +56 -13
  106. package/dist/protocol/messages/source-registration.js +49 -6
  107. package/dist/protocol/session-policy.d.ts +20 -0
  108. package/dist/protocol/session-policy.js +25 -0
  109. package/dist/protocol/source-origin.d.ts +1 -1
  110. package/dist/provenance/attestation-origin.d.ts +1 -1
  111. package/dist/provenance/schema.d.ts +11 -11
  112. package/dist/provenance/verify.js +2 -1
  113. package/dist/provider/changed-files-fetcher.d.ts +21 -2
  114. package/dist/provider/check-run-conclusion.d.ts +2 -2
  115. package/dist/provider/check-status-poster.d.ts +23 -0
  116. package/dist/provider/index.d.ts +2 -2
  117. package/dist/registration/registerable-trigger-type.d.ts +14 -13
  118. package/dist/registration/registerable-trigger-type.js +1 -0
  119. package/dist/sandbox/capabilities.d.ts +6 -0
  120. package/dist/sandbox/capabilities.js +57 -0
  121. package/dist/scaler/scaler-backend-type.d.ts +1 -1
  122. package/dist/status/presentation.d.ts +89 -0
  123. package/dist/status/presentation.js +163 -0
  124. package/dist/trigger/compiled-matchers.d.ts +13 -0
  125. package/dist/trigger/compiled-matchers.js +44 -0
  126. package/dist/trigger/event-buckets.d.ts +44 -0
  127. package/dist/trigger/event-buckets.js +93 -0
  128. package/dist/trigger/matcher.d.ts +7 -3
  129. package/dist/trigger/matcher.js +53 -15
  130. package/dist/trigger/schedule-key.d.ts +14 -0
  131. package/dist/trigger/schedule-key.js +21 -0
  132. package/dist/trigger/trigger-event-type.d.ts +1 -1
  133. package/dist/trigger/trigger-event-type.js +2 -0
  134. package/dist/trigger/types.d.ts +178 -47
  135. package/dist/trigger/types.js +82 -24
  136. package/dist/webhook/event-types.d.ts +56 -0
  137. package/dist/webhook/event-types.js +59 -0
  138. package/dist/ws/ws-like.d.ts +13 -0
  139. package/package.json +26 -10
  140. package/sbom.spdx.json +10 -10
  141. package/dist/environment/index.d.ts +0 -6
  142. package/dist/environment/index.js +0 -5
  143. package/dist/environment/multi-env.d.ts +0 -30
  144. package/dist/environment/multi-env.js +0 -38
  145. package/dist/environment/scope-resolver.d.ts +0 -46
  146. package/dist/package-manager.d.ts +0 -20
  147. package/dist/protocol/messages/observe.d.ts +0 -76
  148. package/dist/protocol/messages/saas-orchestrator.d.ts +0 -2179
  149. package/dist/protocol/messages/test-run.d.ts +0 -59
  150. package/dist/state-machine/index.d.ts +0 -2
  151. package/dist/state-machine/index.js +0 -3
  152. package/dist/state-machine/machine.d.ts +0 -34
  153. package/dist/state-machine/machine.js +0 -103
  154. package/dist/state-machine/types.d.ts +0 -34
  155. package/dist/state-machine/types.js +0 -15
  156. /package/dist/{environment → context}/host-match.d.ts +0 -0
  157. /package/dist/{environment → context}/scope-template.d.ts +0 -0
@@ -13,8 +13,8 @@ const STATE_REPLAY_MAX_RUNS = 500;
13
13
  const MAX_JOBS_PER_RUN = 1e3;
14
14
  /** Max number of `runsOn` / `secretsAccessed` label entries on a job/step. */
15
15
  const RUNS_ON_LABELS_MAX = 30;
16
- /** Max number of bound deployment-environment names on a job. */
17
- const ENVIRONMENTS_MAX = 30;
16
+ /** Max number of bound context names on a job. */
17
+ const CONTEXTS_MAX = 30;
18
18
  /**
19
19
  * Status values for execution runs (execution_runs table).
20
20
  *
@@ -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,19 +120,42 @@ 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
- * (environment_rules, dynamic_eval, no_agent, matrix_expansion).
125
+ * (context_rules, dynamic_eval, no_agent, matrix_expansion).
117
126
  */
118
127
  const InitFailureCategory = z.enum([
119
128
  "secret_resolution",
120
129
  "install_secrets",
121
130
  "lock_resolution",
122
131
  "build_coordination",
123
- "environment_rules",
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({
@@ -274,8 +331,8 @@ const jobStatusForwardSchema = z.object({
274
331
  orchestratorId: z.string().max(128).nullable().optional(),
275
332
  /** Labels used for agent routing. */
276
333
  runsOnLabels: z.array(z.string().max(128)).max(30).optional(),
277
- /** Ordered bound deployment-environment names for this job (multi-env jobs). */
278
- environments: z.array(z.string().max(128)).max(30).optional(),
334
+ /** Ordered bound context names for this job (multi-context jobs). */
335
+ contexts: z.array(z.string().max(128)).max(30).optional(),
279
336
  /**
280
337
  * Total raw log bytes accumulated across all steps of this job, summed by
281
338
  * the orchestrator from per-step `logBytesStreamed` values reported by the
@@ -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
- environments: 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 { CacheOutcome, CacheRunEventType, CacheStepType, ENVIRONMENTS_MAX, 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
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Heartbeat-freshness policy for Platform connection and agent health.
3
+ *
4
+ * Two distinct policies live here, and their numbers differ on purpose.
5
+ *
6
+ * **Rendering policy** — badge freshness, computed from `last_heartbeat_at` on
7
+ * a DB row, by any instance. Advisory: nothing routes on a badge, so it can
8
+ * afford a tight bound. Two independent heartbeat domains consult it — Platform
9
+ * connection health (platform_connections) and agent liveness in the
10
+ * dashboard's infrastructure tree — so the two badges cannot drift apart.
11
+ * Browser-safe so the dashboard renders against the same numbers the server
12
+ * computes with.
13
+ *
14
+ * **Teardown policy** — applied by the owning instance to its own live sockets.
15
+ * Wider than the rendering bounds because the `platform_connections.status`
16
+ * write it drives gates every `status = 'connected'` reader — among them the
17
+ * plan-limit connection count, the cross-instance relay lookup, the dashboard
18
+ * proxy's owning-instance lookup, and the stale-orchestrator detector. Marking
19
+ * a live socket unhealthy too eagerly removes it from routing while it is still
20
+ * serving.
21
+ *
22
+ * The two policies also cover different lifetimes. An instance that closes a
23
+ * socket at HEARTBEAT_CLOSE_MS deletes its row in the same step, so the `stale`
24
+ * (HEARTBEAT_DEGRADED_MS) and `orphaned` (HEARTBEAT_STALE_THRESHOLD_SECONDS)
25
+ * levels describe rows that delete never ran for — the ones the orphan sweeper
26
+ * reaps. That is why the sweeper cutoff sits at twice HEARTBEAT_CLOSE_MS: a
27
+ * clean close always beats the sweep to the row.
28
+ *
29
+ * Neither policy has an unclassified case, which is what makes them safe to
30
+ * keep separate: the rendering policy maps a missing `last_heartbeat_at` to
31
+ * `orphaned` (worst-case, no heartbeat evidence at all), and the teardown
32
+ * policy never encounters one because the registry stamps `lastHeartbeatAt` at
33
+ * registration. Any future attempt to collapse the two must preserve that — an
34
+ * unknown treated as healthy hides a dead peer, and one treated as unhealthy
35
+ * sheds a live one.
36
+ *
37
+ * Consumers:
38
+ * - platform ws/connection-health.ts — the four-level status computation
39
+ * - platform ws/heartbeat.ts — the teardown policy
40
+ * - platform queue/jobs/orphan-sweeper.ts — periodic DELETE of orphan rows
41
+ * - platform ws/registry.ts — plan-limit count excludes stale rows
42
+ * - platform dashboard/routes/admin.ts — GET /admin/connections filter enum
43
+ * - platform dev-ops/developer-ops.ts — the diagnostics badge + orphan count
44
+ * - dashboard utils/diagnostics-helpers.ts — agent heartbeat badge colour
45
+ */
46
+ import { z } from 'zod';
47
+ /** A heartbeat younger than this is fully healthy. */
48
+ export declare const HEARTBEAT_FRESH_MS = 60000;
49
+ /** Between fresh and this, the peer is degraded but not yet presumed gone. */
50
+ export declare const HEARTBEAT_DEGRADED_MS = 300000;
51
+ /**
52
+ * A row is considered stale (the owning orchestrator process is no longer
53
+ * publishing heartbeats) when `last_heartbeat_at` is older than this. Past it,
54
+ * the connection is orphaned and the sweeper is entitled to delete the row.
55
+ *
56
+ * The Platform's same-instance DB eviction on reconnect
57
+ * (`ws/handler.ts#handleSourceRegistration`) shares this rationale: the DELETE
58
+ * itself is unconditional on staleness, but the reason it is needed at all is
59
+ * this same staleness window.
60
+ */
61
+ export declare const HEARTBEAT_STALE_THRESHOLD_SECONDS = 360;
62
+ /**
63
+ * Silence after which the owning instance writes
64
+ * `platform_connections.status = 'unhealthy'`. Wider than HEARTBEAT_FRESH_MS
65
+ * because that write gates relay routing, not rendering.
66
+ */
67
+ export declare const HEARTBEAT_UNHEALTHY_MARK_MS = 90000;
68
+ /**
69
+ * Silence after which the owning instance closes the socket with
70
+ * WS_CLOSE_HEARTBEAT_TIMEOUT (4004) and drops it from the registry — which
71
+ * deletes the platform_connections row too. A row outlives its socket only when
72
+ * that delete never ran; the orphan sweeper reaps those.
73
+ */
74
+ export declare const HEARTBEAT_CLOSE_MS = 180000;
75
+ /** The four-level connection health vocabulary, worst-last. */
76
+ export declare const connectionHealthStatusSchema: z.ZodEnum<{
77
+ connected: "connected";
78
+ orphaned: "orphaned";
79
+ stale: "stale";
80
+ unhealthy: "unhealthy";
81
+ }>;
82
+ export type ConnectionHealthStatus = z.infer<typeof connectionHealthStatusSchema>;
83
+ //# sourceMappingURL=heartbeat-health.d.ts.map
@@ -0,0 +1,87 @@
1
+ import "../../rolldown-runtime-ClRpJifh.js";
2
+ import { z } from "zod";
3
+ //#region src/protocol/messages/heartbeat-health.ts
4
+ /**
5
+ * Heartbeat-freshness policy for Platform connection and agent health.
6
+ *
7
+ * Two distinct policies live here, and their numbers differ on purpose.
8
+ *
9
+ * **Rendering policy** — badge freshness, computed from `last_heartbeat_at` on
10
+ * a DB row, by any instance. Advisory: nothing routes on a badge, so it can
11
+ * afford a tight bound. Two independent heartbeat domains consult it — Platform
12
+ * connection health (platform_connections) and agent liveness in the
13
+ * dashboard's infrastructure tree — so the two badges cannot drift apart.
14
+ * Browser-safe so the dashboard renders against the same numbers the server
15
+ * computes with.
16
+ *
17
+ * **Teardown policy** — applied by the owning instance to its own live sockets.
18
+ * Wider than the rendering bounds because the `platform_connections.status`
19
+ * write it drives gates every `status = 'connected'` reader — among them the
20
+ * plan-limit connection count, the cross-instance relay lookup, the dashboard
21
+ * proxy's owning-instance lookup, and the stale-orchestrator detector. Marking
22
+ * a live socket unhealthy too eagerly removes it from routing while it is still
23
+ * serving.
24
+ *
25
+ * The two policies also cover different lifetimes. An instance that closes a
26
+ * socket at HEARTBEAT_CLOSE_MS deletes its row in the same step, so the `stale`
27
+ * (HEARTBEAT_DEGRADED_MS) and `orphaned` (HEARTBEAT_STALE_THRESHOLD_SECONDS)
28
+ * levels describe rows that delete never ran for — the ones the orphan sweeper
29
+ * reaps. That is why the sweeper cutoff sits at twice HEARTBEAT_CLOSE_MS: a
30
+ * clean close always beats the sweep to the row.
31
+ *
32
+ * Neither policy has an unclassified case, which is what makes them safe to
33
+ * keep separate: the rendering policy maps a missing `last_heartbeat_at` to
34
+ * `orphaned` (worst-case, no heartbeat evidence at all), and the teardown
35
+ * policy never encounters one because the registry stamps `lastHeartbeatAt` at
36
+ * registration. Any future attempt to collapse the two must preserve that — an
37
+ * unknown treated as healthy hides a dead peer, and one treated as unhealthy
38
+ * sheds a live one.
39
+ *
40
+ * Consumers:
41
+ * - platform ws/connection-health.ts — the four-level status computation
42
+ * - platform ws/heartbeat.ts — the teardown policy
43
+ * - platform queue/jobs/orphan-sweeper.ts — periodic DELETE of orphan rows
44
+ * - platform ws/registry.ts — plan-limit count excludes stale rows
45
+ * - platform dashboard/routes/admin.ts — GET /admin/connections filter enum
46
+ * - platform dev-ops/developer-ops.ts — the diagnostics badge + orphan count
47
+ * - dashboard utils/diagnostics-helpers.ts — agent heartbeat badge colour
48
+ */
49
+ /** A heartbeat younger than this is fully healthy. */
50
+ const HEARTBEAT_FRESH_MS = 6e4;
51
+ /** Between fresh and this, the peer is degraded but not yet presumed gone. */
52
+ const HEARTBEAT_DEGRADED_MS = 3e5;
53
+ /**
54
+ * A row is considered stale (the owning orchestrator process is no longer
55
+ * publishing heartbeats) when `last_heartbeat_at` is older than this. Past it,
56
+ * the connection is orphaned and the sweeper is entitled to delete the row.
57
+ *
58
+ * The Platform's same-instance DB eviction on reconnect
59
+ * (`ws/handler.ts#handleSourceRegistration`) shares this rationale: the DELETE
60
+ * itself is unconditional on staleness, but the reason it is needed at all is
61
+ * this same staleness window.
62
+ */
63
+ const HEARTBEAT_STALE_THRESHOLD_SECONDS = 360;
64
+ /**
65
+ * Silence after which the owning instance writes
66
+ * `platform_connections.status = 'unhealthy'`. Wider than HEARTBEAT_FRESH_MS
67
+ * because that write gates relay routing, not rendering.
68
+ */
69
+ const HEARTBEAT_UNHEALTHY_MARK_MS = 9e4;
70
+ /**
71
+ * Silence after which the owning instance closes the socket with
72
+ * WS_CLOSE_HEARTBEAT_TIMEOUT (4004) and drops it from the registry — which
73
+ * deletes the platform_connections row too. A row outlives its socket only when
74
+ * that delete never ran; the orphan sweeper reaps those.
75
+ */
76
+ const HEARTBEAT_CLOSE_MS = 18e4;
77
+ /** The four-level connection health vocabulary, worst-last. */
78
+ const connectionHealthStatusSchema = z.enum([
79
+ "connected",
80
+ "unhealthy",
81
+ "stale",
82
+ "orphaned"
83
+ ]);
84
+ //#endregion
85
+ export { HEARTBEAT_CLOSE_MS, HEARTBEAT_DEGRADED_MS, HEARTBEAT_FRESH_MS, HEARTBEAT_STALE_THRESHOLD_SECONDS, HEARTBEAT_UNHEALTHY_MARK_MS, connectionHealthStatusSchema };
86
+
87
+ //# sourceMappingURL=heartbeat-health.js.map
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Which of a subprocess's two output streams a run-log line came from.
4
+ *
5
+ * Carried per log chunk rather than per line: chunks are delivered in order and
6
+ * the agent closes the pending chunk whenever the kind flips, so stdout/stderr
7
+ * interleaving is preserved without a per-line field.
8
+ *
9
+ * Lives in its own module because three protocol planes reference it — the
10
+ * agent→orchestrator chunk, the orchestrator→Platform relay, and the
11
+ * Platform→browser fan-out — and a shared leaf keeps those files acyclic.
12
+ */
13
+ export declare const LogStream: z.ZodEnum<{
14
+ stderr: "stderr";
15
+ stdout: "stdout";
16
+ }>;
17
+ export type LogStream = z.infer<typeof LogStream>;
18
+ //# sourceMappingURL=log-stream.d.ts.map
@@ -0,0 +1,19 @@
1
+ import "../../rolldown-runtime-ClRpJifh.js";
2
+ import { z } from "zod";
3
+ //#region src/protocol/messages/log-stream.ts
4
+ /**
5
+ * Which of a subprocess's two output streams a run-log line came from.
6
+ *
7
+ * Carried per log chunk rather than per line: chunks are delivered in order and
8
+ * the agent closes the pending chunk whenever the kind flips, so stdout/stderr
9
+ * interleaving is preserved without a per-line field.
10
+ *
11
+ * Lives in its own module because three protocol planes reference it — the
12
+ * agent→orchestrator chunk, the orchestrator→Platform relay, and the
13
+ * Platform→browser fan-out — and a shared leaf keeps those files acyclic.
14
+ */
15
+ const LogStream = z.enum(["stdout", "stderr"]);
16
+ //#endregion
17
+ export { LogStream };
18
+
19
+ //# sourceMappingURL=log-stream.js.map
@@ -1,4 +1,11 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * @deprecated The `oidc.mint.*` RPC pair (Platform-rooted identity mint) is
4
+ * hard-deprecated in favor of orchestrator-owned signing. It is kept
5
+ * wire-compatible for the mixed-version rollout window and removed at v1.0; a
6
+ * fresh orchestrator with its own signer never sends it. See
7
+ * docs/user/deprecations.md.
8
+ */
2
9
  /**
3
10
  * Error discriminator for a failed provenance mint, carried on
4
11
  * `oidc.mint.response.error.code`. Mirrors the three orchestrator-side error
@@ -3,6 +3,13 @@ import { AttestationOrigin } from "../../provenance/attestation-origin.js";
3
3
  import { z } from "zod";
4
4
  //#region src/protocol/messages/oidc-mint.ts
5
5
  /**
6
+ * @deprecated The `oidc.mint.*` RPC pair (Platform-rooted identity mint) is
7
+ * hard-deprecated in favor of orchestrator-owned signing. It is kept
8
+ * wire-compatible for the mixed-version rollout window and removed at v1.0; a
9
+ * fresh orchestrator with its own signer never sends it. See
10
+ * docs/user/deprecations.md.
11
+ */
12
+ /**
6
13
  * Error discriminator for a failed provenance mint, carried on
7
14
  * `oidc.mint.response.error.code`. Mirrors the three orchestrator-side error
8
15
  * classes that consume it: