@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
@@ -0,0 +1,79 @@
1
+ import type { ContextBinding, ScopedSecret } from './types.js';
2
+ import { type HostFacts } from './host-match.js';
3
+ export type { HostFacts } from './host-match.js';
4
+ /**
5
+ * Check whether a scope string matches a pattern.
6
+ *
7
+ * Supports exact match and glob patterns (via picomatch).
8
+ * Scope paths use '/' as separator (e.g., 'aws/prod/db').
9
+ *
10
+ * For prefixed scopes (e.g., 'pg:aws/prod'), the pattern may be prefixed too
11
+ * (e.g., 'pg:**'). In this case, the backend prefix must match exactly and
12
+ * the path portion is matched separately against the glob. This is needed
13
+ * because picomatch's '**' requires '/' separators — 'pg:**' wouldn't match
14
+ * 'pg:aws/prod' without splitting on the colon.
15
+ */
16
+ export declare function matchScopePattern(scope: string, pattern: string): boolean;
17
+ /**
18
+ * Strip the backend prefix from a scope string.
19
+ * Prefixed scopes have the form "backendName:path" (e.g., "pg:aws/prod").
20
+ * Returns the path after the first colon, or the full scope if no prefix.
21
+ */
22
+ export declare function stripScopePrefix(scope: string): string;
23
+ /** The winning scoped secret for a key, with the precedence tuple that selected it. */
24
+ export interface ResolvedSecretCandidate {
25
+ secret: ScopedSecret;
26
+ scopeDepth: number;
27
+ hostSpec: number;
28
+ }
29
+ /**
30
+ * Resolve the winning secret per key by matching bindings against scoped secrets,
31
+ * applying the host gate and `(host specificity, scope depth)` precedence — WITHOUT
32
+ * decrypting, keeping this module crypto-free. This is the single source of truth for
33
+ * scope precedence; `resolveSecretsForContext` delegates to it and adds the decrypt step.
34
+ *
35
+ * Takes already-filtered bindings (for the target context). For each binding, finds
36
+ * secrets whose (substituted) scope matches the binding's scopePattern via picomatch.
37
+ * When multiple scopes provide the same key, precedence is the tuple
38
+ * `(host specificity, scope depth)` — a per-host binding (exact host) overrides a
39
+ * fleet-wide one, then longest scope path wins. Scope depth is computed AFTER stripping
40
+ * the backend prefix.
41
+ *
42
+ * When `hostFacts` is supplied (a fan-out child's identity), each binding is gated by
43
+ * its `host_pattern` and its `scope_pattern` is templated per-child
44
+ * (`${agentId}`/`${host}`/`${label:NAME}`). When omitted, only fleet-wide (`'**'`/NULL)
45
+ * non-templated bindings contribute — preserving the workflow-level (no-host) behaviour.
46
+ *
47
+ * @param bindings - Bindings already filtered for the target context
48
+ * @param allSecrets - All scoped secrets in the org
49
+ * @param hostFacts - Optional fan-out child identity for per-host resolution
50
+ * @returns Map of secret key → winning candidate (secret + precedence tuple)
51
+ */
52
+ export declare function resolveSecretsWithProvenance(bindings: ContextBinding[], allSecrets: ScopedSecret[], hostFacts?: HostFacts): Map<string, ResolvedSecretCandidate>;
53
+ /**
54
+ * Resolve secrets for a context by matching bindings against scoped secrets.
55
+ *
56
+ * Takes already-filtered bindings (for the target context). For each binding,
57
+ * finds secrets whose (substituted) scope matches the binding's scopePattern via
58
+ * picomatch. When multiple scopes provide the same key, precedence is the tuple
59
+ * `(host specificity, scope depth)` — a per-host binding (exact host) overrides a
60
+ * fleet-wide one, then longest scope path wins. Scope depth is computed AFTER
61
+ * stripping the backend prefix.
62
+ *
63
+ * When `hostFacts` is supplied (a fan-out child's identity), each binding is
64
+ * gated by its `host_pattern` and its `scope_pattern` is templated per-child
65
+ * (`${agentId}`/`${host}`/`${label:NAME}`). When omitted, only fleet-wide
66
+ * (`'**'`/NULL) non-templated bindings contribute — preserving the workflow-level
67
+ * (no-host) behaviour.
68
+ *
69
+ * Delegates precedence to `resolveSecretsWithProvenance` and applies `decryptFn`
70
+ * to each winning secret.
71
+ *
72
+ * @param bindings - Bindings already filtered for the target context
73
+ * @param allSecrets - All scoped secrets in the org
74
+ * @param decryptFn - Pure decryption function (keeps this module crypto-free)
75
+ * @param hostFacts - Optional fan-out child identity for per-host resolution
76
+ * @returns Flat record of decrypted secret key-value pairs
77
+ */
78
+ export declare function resolveSecretsForContext(bindings: ContextBinding[], allSecrets: ScopedSecret[], decryptFn: (s: ScopedSecret) => string, hostFacts?: HostFacts): Record<string, string>;
79
+ //# sourceMappingURL=scope-resolver.d.ts.map
@@ -2,7 +2,7 @@ import "../rolldown-runtime-ClRpJifh.js";
2
2
  import { hostSpecificity, matchHostPattern } from "./host-match.js";
3
3
  import { substituteScopePattern } from "./scope-template.js";
4
4
  import picomatch from "picomatch";
5
- //#region src/environment/scope-resolver.ts
5
+ //#region src/context/scope-resolver.ts
6
6
  /**
7
7
  * Check whether a scope string matches a pattern.
8
8
  *
@@ -70,28 +70,29 @@ function candidateWins(c, existing) {
70
70
  return c.scopeDepth > existing.scopeDepth;
71
71
  }
72
72
  /**
73
- * Resolve secrets for an environment by matching bindings against scoped secrets.
73
+ * Resolve the winning secret per key by matching bindings against scoped secrets,
74
+ * applying the host gate and `(host specificity, scope depth)` precedence — WITHOUT
75
+ * decrypting, keeping this module crypto-free. This is the single source of truth for
76
+ * scope precedence; `resolveSecretsForContext` delegates to it and adds the decrypt step.
74
77
  *
75
- * Takes already-filtered bindings (for the target environment). For each binding,
76
- * finds secrets whose (substituted) scope matches the binding's scopePattern via
77
- * picomatch. When multiple scopes provide the same key, precedence is the tuple
78
+ * Takes already-filtered bindings (for the target context). For each binding, finds
79
+ * secrets whose (substituted) scope matches the binding's scopePattern via picomatch.
80
+ * When multiple scopes provide the same key, precedence is the tuple
78
81
  * `(host specificity, scope depth)` — a per-host binding (exact host) overrides a
79
- * fleet-wide one, then longest scope path wins. Scope depth is computed AFTER
80
- * stripping the backend prefix.
82
+ * fleet-wide one, then longest scope path wins. Scope depth is computed AFTER stripping
83
+ * the backend prefix.
81
84
  *
82
- * When `hostFacts` is supplied (a fan-out child's identity), each binding is
83
- * gated by its `host_pattern` and its `scope_pattern` is templated per-child
84
- * (`${agentId}`/`${host}`/`${label:NAME}`). When omitted, only fleet-wide
85
- * (`'**'`/NULL) non-templated bindings contribute — preserving the workflow-level
86
- * (no-host) behaviour.
85
+ * When `hostFacts` is supplied (a fan-out child's identity), each binding is gated by
86
+ * its `host_pattern` and its `scope_pattern` is templated per-child
87
+ * (`${agentId}`/`${host}`/`${label:NAME}`). When omitted, only fleet-wide (`'**'`/NULL)
88
+ * non-templated bindings contribute — preserving the workflow-level (no-host) behaviour.
87
89
  *
88
- * @param bindings - Bindings already filtered for the target environment
90
+ * @param bindings - Bindings already filtered for the target context
89
91
  * @param allSecrets - All scoped secrets in the org
90
- * @param decryptFn - Pure decryption function (keeps this module crypto-free)
91
92
  * @param hostFacts - Optional fan-out child identity for per-host resolution
92
- * @returns Flat record of decrypted secret key-value pairs
93
+ * @returns Map of secret key → winning candidate (secret + precedence tuple)
93
94
  */
94
- function resolveSecretsForEnvironment(bindings, allSecrets, decryptFn, hostFacts) {
95
+ function resolveSecretsWithProvenance(bindings, allSecrets, hostFacts) {
95
96
  const resolved = /* @__PURE__ */ new Map();
96
97
  for (const binding of bindings) {
97
98
  const scopePattern = bindingScopeForHost(binding, hostFacts);
@@ -107,11 +108,40 @@ function resolveSecretsForEnvironment(bindings, allSecrets, decryptFn, hostFacts
107
108
  if (candidateWins(candidate, resolved.get(secret.key))) resolved.set(secret.key, candidate);
108
109
  }
109
110
  }
111
+ return resolved;
112
+ }
113
+ /**
114
+ * Resolve secrets for a context by matching bindings against scoped secrets.
115
+ *
116
+ * Takes already-filtered bindings (for the target context). For each binding,
117
+ * finds secrets whose (substituted) scope matches the binding's scopePattern via
118
+ * picomatch. When multiple scopes provide the same key, precedence is the tuple
119
+ * `(host specificity, scope depth)` — a per-host binding (exact host) overrides a
120
+ * fleet-wide one, then longest scope path wins. Scope depth is computed AFTER
121
+ * stripping the backend prefix.
122
+ *
123
+ * When `hostFacts` is supplied (a fan-out child's identity), each binding is
124
+ * gated by its `host_pattern` and its `scope_pattern` is templated per-child
125
+ * (`${agentId}`/`${host}`/`${label:NAME}`). When omitted, only fleet-wide
126
+ * (`'**'`/NULL) non-templated bindings contribute — preserving the workflow-level
127
+ * (no-host) behaviour.
128
+ *
129
+ * Delegates precedence to `resolveSecretsWithProvenance` and applies `decryptFn`
130
+ * to each winning secret.
131
+ *
132
+ * @param bindings - Bindings already filtered for the target context
133
+ * @param allSecrets - All scoped secrets in the org
134
+ * @param decryptFn - Pure decryption function (keeps this module crypto-free)
135
+ * @param hostFacts - Optional fan-out child identity for per-host resolution
136
+ * @returns Flat record of decrypted secret key-value pairs
137
+ */
138
+ function resolveSecretsForContext(bindings, allSecrets, decryptFn, hostFacts) {
139
+ const resolved = resolveSecretsWithProvenance(bindings, allSecrets, hostFacts);
110
140
  const result = {};
111
141
  for (const [key, { secret }] of resolved) result[key] = decryptFn(secret);
112
142
  return result;
113
143
  }
114
144
  //#endregion
115
- export { matchScopePattern, resolveSecretsForEnvironment, stripScopePrefix };
145
+ export { matchScopePattern, resolveSecretsForContext, resolveSecretsWithProvenance, stripScopePrefix };
116
146
 
117
147
  //# sourceMappingURL=scope-resolver.js.map
@@ -1,5 +1,5 @@
1
1
  import "../rolldown-runtime-ClRpJifh.js";
2
- //#region src/environment/scope-template.ts
2
+ //#region src/context/scope-template.ts
3
3
  /** A substituted value must be a single literal path segment — no `/` or glob. */
4
4
  const SAFE_SEGMENT = /^[A-Za-z0-9._-]+$/;
5
5
  const PLACEHOLDER = /\$\{(agentId|host|label:[^}]+)\}/g;
@@ -1,13 +1,16 @@
1
1
  /**
2
- * Environment types for KiCI's deployment environment model.
2
+ * Context types for KiCI's named-context model.
3
3
  *
4
- * Environments are org-level entities that group secrets, variables,
4
+ * Contexts are org-level entities that group secrets, variables,
5
5
  * and protection rules for deployment targets (dev, staging, production).
6
6
  */
7
7
  import { z } from 'zod';
8
8
  import type { ApproverClause } from '../approval/types.js';
9
- /** Environment entity org-level deployment target with protection rules. */
10
- export interface Environment {
9
+ import type { HoldType } from './hold-type.js';
10
+ import type { HeldRunStatus } from './held-run-status.js';
11
+ import type { ConcurrencyStrategy } from './concurrency-strategy.js';
12
+ /** Context entity — org-level deployment target with protection rules. */
13
+ export interface Context {
11
14
  id: string;
12
15
  orgId: string;
13
16
  name: string;
@@ -17,14 +20,14 @@ export interface Environment {
17
20
  triggerTypeFilters: string[];
18
21
  repoPatterns: string[];
19
22
  concurrencyLimit: number | null;
20
- concurrencyStrategy: 'queue' | 'cancel-pending';
23
+ concurrencyStrategy: ConcurrencyStrategy;
21
24
  concurrencyTimeoutMs: number;
22
25
  requiredReviewers: string[] | null;
23
26
  waitTimerSeconds: number | null;
24
27
  holdExpirySeconds: number;
25
- /** Minimum trust tier required for CI execution in this environment. */
28
+ /** Minimum trust tier required for CI execution in this context. */
26
29
  minimumTrust?: 'known' | 'trusted';
27
- /** Whether this environment allows local (no-remote) executions. Default false. */
30
+ /** Whether this context allows local (no-remote) executions. Default false. */
28
31
  allowLocalExecution?: boolean;
29
32
  enabled: boolean;
30
33
  createdAt: string;
@@ -43,11 +46,11 @@ export interface ScopedSecret {
43
46
  createdAt: string;
44
47
  updatedAt: string;
45
48
  }
46
- /** Binding that maps a scope pattern to an environment. */
47
- export interface EnvironmentBinding {
49
+ /** Binding that maps a scope pattern to a context. */
50
+ export interface ContextBinding {
48
51
  id: string;
49
52
  orgId: string;
50
- environmentId: string;
53
+ contextId: string;
51
54
  scopePattern: string;
52
55
  /**
53
56
  * Host selector this binding applies to (exact / glob / regex, matched
@@ -58,22 +61,22 @@ export interface EnvironmentBinding {
58
61
  hostPattern: string;
59
62
  createdAt: string;
60
63
  }
61
- /** Non-secret key-value config per environment, with optional lock. */
62
- export interface EnvironmentVariable {
64
+ /** Non-secret key-value config per context, with optional lock. */
65
+ export interface ContextVariable {
63
66
  id: string;
64
67
  orgId: string;
65
- environmentId: string;
68
+ contextId: string;
66
69
  key: string;
67
70
  value: string;
68
71
  locked: boolean;
69
72
  createdAt: string;
70
73
  updatedAt: string;
71
74
  }
72
- /** Per-source override for an environment variable. */
73
- export interface EnvironmentSourceOverride {
75
+ /** Per-source override for a context variable. */
76
+ export interface ContextSourceOverride {
74
77
  id: string;
75
78
  orgId: string;
76
- environmentId: string;
79
+ contextId: string;
77
80
  routingKey: string;
78
81
  key: string;
79
82
  value: string;
@@ -82,9 +85,9 @@ export interface EnvironmentSourceOverride {
82
85
  }
83
86
  /** Trust tier for contributor-based CI execution gating (single source of truth). */
84
87
  export declare const TrustTierSchema: z.ZodEnum<{
85
- unknown: "unknown";
86
88
  known: "known";
87
89
  trusted: "trusted";
90
+ unknown: "unknown";
88
91
  }>;
89
92
  export type TrustTier = z.infer<typeof TrustTierSchema>;
90
93
  /** Held run record for protection gate enforcement. */
@@ -93,9 +96,9 @@ export interface HeldRun {
93
96
  orgId: string;
94
97
  runId: string;
95
98
  jobId: string;
96
- environmentId: string;
97
- holdType: 'reviewer' | 'timer' | 'concurrency' | 'security';
98
- status: 'pending' | 'approved' | 'rejected' | 'expired';
99
+ contextId: string;
100
+ holdType: HoldType;
101
+ status: HeldRunStatus;
99
102
  reason: string | null;
100
103
  approvedBy: string | null;
101
104
  createdAt: string;
@@ -107,9 +110,9 @@ export interface ProtectionGateResult {
107
110
  action: 'pass' | 'reject' | 'hold' | 'queue' | 'wait';
108
111
  reason?: string;
109
112
  holdUntil?: string;
110
- holdType?: 'reviewer' | 'timer' | 'concurrency' | 'security';
113
+ holdType?: HoldType;
111
114
  /**
112
- * Approver clauses for a reviewer hold, mapped from the environment's
115
+ * Approver clauses for a reviewer hold, mapped from the context's
113
116
  * `requiredReviewers`. Each reviewer string maps to a `{ user }` clause
114
117
  * (team-named reviewers are a documented follow-up). Empty/undefined means
115
118
  * "any approval-capable member".
@@ -1,10 +1,10 @@
1
1
  import "../rolldown-runtime-ClRpJifh.js";
2
2
  import { z } from "zod";
3
- //#region src/environment/types.ts
3
+ //#region src/context/types.ts
4
4
  /**
5
- * Environment types for KiCI's deployment environment model.
5
+ * Context types for KiCI's named-context model.
6
6
  *
7
- * Environments are org-level entities that group secrets, variables,
7
+ * Contexts are org-level entities that group secrets, variables,
8
8
  * and protection rules for deployment targets (dev, staging, production).
9
9
  */
10
10
  /** Trust tier for contributor-based CI execution gating (single source of truth). */
@@ -21,7 +21,7 @@
21
21
  * Browser-safe: data + TypeScript types only, no Node imports, so it lives in
22
22
  * the engine barrel importable by the web UI, the CLI, and the Platform.
23
23
  */
24
- export type DeveloperOpDomain = 'runs' | 'workflows' | 'environments' | 'secrets' | 'held-runs' | 'diagnostics' | 'orchestrators' | 'sources' | 'dlq' | 'attestations' | 'activity' | 'orgs';
24
+ export type DeveloperOpDomain = 'runs' | 'workflows' | 'contexts' | 'secrets' | 'held-runs' | 'diagnostics' | 'orchestrators' | 'sources' | 'dlq' | 'attestations' | 'activity' | 'orgs';
25
25
  export type DeveloperOpKind = 'read' | 'write';
26
26
  /** Which of the three entrypoints a developer op is (or should be) exposed on. */
27
27
  export interface DeveloperOpEntrypoints {
@@ -45,6 +45,14 @@ export interface DeveloperOperation {
45
45
  mcpAppropriate: boolean;
46
46
  /** MCP tool name when `entrypoints.mcp` is true; null otherwise. */
47
47
  mcpTool: string | null;
48
+ /**
49
+ * True when the op acts on a specific repository's resource and must honour
50
+ * the caller's repo glob patterns on EVERY entrypoint. Required on every row
51
+ * so a new op cannot compile without an explicit decision, and NOT derivable
52
+ * from `domain` — `workflows.list` is repo-scoped while `secrets.list`, whose
53
+ * rows are context-keyed with no repository to scope against, is not.
54
+ */
55
+ repoScoped: boolean;
48
56
  }
49
57
  /**
50
58
  * The workflow-developer core. Developer plane only — org-membership-scoped,
@@ -1,7 +1,7 @@
1
1
  import "../rolldown-runtime-ClRpJifh.js";
2
2
  //#region src/dev-ops/operations.ts
3
3
  /** Build a row, defaulting every unspecified entrypoint to false. */
4
- function op(id, domain, kind, ep, mcpAppropriate, mcpTool) {
4
+ function op(id, domain, kind, ep, mcpAppropriate, mcpTool, repoScoped) {
5
5
  return {
6
6
  id,
7
7
  domain,
@@ -14,7 +14,8 @@ function op(id, domain, kind, ep, mcpAppropriate, mcpTool) {
14
14
  ...ep
15
15
  },
16
16
  mcpAppropriate,
17
- mcpTool
17
+ mcpTool,
18
+ repoScoped
18
19
  };
19
20
  }
20
21
  /**
@@ -27,103 +28,119 @@ const DEVELOPER_OPERATIONS = [
27
28
  cli: true,
28
29
  mcp: true,
29
30
  ui: true
30
- }, true, "list_runs"),
31
+ }, true, "list_runs", true),
31
32
  op("runs.get", "runs", "read", {
32
33
  http: true,
33
34
  cli: true,
34
35
  mcp: true,
35
36
  ui: true
36
- }, true, "get_run"),
37
+ }, true, "get_run", true),
37
38
  op("runs.stepLogs", "runs", "read", {
38
39
  http: true,
39
40
  cli: true,
40
41
  mcp: true,
41
42
  ui: true
42
- }, true, "get_step_logs"),
43
+ }, true, "get_step_logs", true),
43
44
  op("runs.cancel", "runs", "write", {
44
45
  http: true,
45
46
  cli: true,
46
47
  mcp: true,
47
48
  ui: true
48
- }, true, "cancel_run"),
49
+ }, true, "cancel_run", true),
49
50
  op("runs.cancelByBranch", "runs", "write", {
50
51
  http: true,
51
52
  cli: true,
52
53
  mcp: true,
53
54
  ui: false
54
- }, true, "cancel_runs_by_branch"),
55
+ }, true, "cancel_runs_by_branch", true),
55
56
  op("runs.rerun", "runs", "write", {
56
57
  http: true,
57
58
  cli: true,
58
59
  mcp: true,
59
60
  ui: true
60
- }, true, "rerun_run"),
61
+ }, true, "rerun_run", true),
61
62
  op("workflows.list", "workflows", "read", {
62
63
  http: true,
63
64
  cli: true,
64
65
  mcp: true,
65
66
  ui: true
66
- }, true, "list_workflows"),
67
+ }, true, "list_workflows", true),
67
68
  op("workflows.trigger", "workflows", "write", {
68
69
  http: true,
69
70
  cli: false,
70
71
  mcp: true,
71
72
  ui: true
72
- }, true, "trigger_run"),
73
+ }, true, "trigger_run", true),
74
+ op("workflows.disable", "workflows", "write", {
75
+ http: true,
76
+ cli: false,
77
+ mcp: false,
78
+ ui: true
79
+ }, false, null, true),
80
+ op("workflows.delete", "workflows", "write", {
81
+ http: true,
82
+ cli: false,
83
+ mcp: false,
84
+ ui: true
85
+ }, false, null, true),
73
86
  op("secrets.list", "secrets", "read", {
74
87
  http: true,
75
88
  cli: true,
76
89
  mcp: true,
77
90
  ui: true
78
- }, true, "list_secrets"),
91
+ }, true, "list_secrets", false),
79
92
  op("secrets.set", "secrets", "write", {
80
93
  http: true,
81
94
  cli: false,
82
95
  mcp: false,
83
96
  ui: true
84
- }, false, null),
97
+ }, false, null, false),
85
98
  op("secrets.delete", "secrets", "write", {
86
99
  http: true,
87
100
  cli: false,
88
101
  mcp: false,
89
102
  ui: true
90
- }, false, null),
91
- op("environments.delete", "environments", "write", {
103
+ }, false, null, false),
104
+ op("contexts.delete", "contexts", "write", {
92
105
  http: true,
93
106
  cli: false,
94
107
  mcp: false,
95
108
  ui: true
96
- }, false, null),
109
+ }, false, null, false),
110
+ op("held-runs.list", "held-runs", "read", {
111
+ http: true,
112
+ ui: true
113
+ }, false, null, true),
97
114
  op("held-runs.approve", "held-runs", "write", {
98
115
  http: true,
99
116
  cli: true,
100
117
  mcp: true,
101
118
  ui: true
102
- }, true, "approve_run"),
119
+ }, true, "approve_run", true),
103
120
  op("held-runs.reject", "held-runs", "write", {
104
121
  http: true,
105
122
  cli: true,
106
123
  mcp: true,
107
124
  ui: true
108
- }, true, "reject_run"),
125
+ }, true, "reject_run", true),
109
126
  op("diagnostics.get", "diagnostics", "read", {
110
127
  http: true,
111
128
  cli: true,
112
129
  mcp: true,
113
130
  ui: true
114
- }, true, "get_diagnostics"),
131
+ }, true, "get_diagnostics", false),
115
132
  op("orchestrators.list", "orchestrators", "read", {
116
133
  http: true,
117
134
  cli: true,
118
135
  mcp: true,
119
136
  ui: true
120
- }, true, "list_orchestrators"),
137
+ }, true, "list_orchestrators", false),
121
138
  op("orgs.list", "orgs", "read", {
122
139
  http: true,
123
140
  cli: true,
124
141
  mcp: true,
125
142
  ui: true
126
- }, true, "list_orgs")
143
+ }, true, "list_orgs", false)
127
144
  ];
128
145
  /** All ops a given entrypoint should expose. */
129
146
  function developerOpsForEntrypoint(ep) {
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Infrastructure alert vocabulary — the single definition of what a diagnostics
3
+ * infrastructure alert's `type` and `severity` can be.
4
+ *
5
+ * Lives beside the other shared vocabularies (`billing/plan-type.ts`,
6
+ * `context/held-run-status.ts`) rather than in the protocol module, so the
7
+ * Platform producer, the dashboard, and the `kici` CLI all name one enum
8
+ * instead of each carrying a copy. Pure Zod with no Node built-ins, so it is
9
+ * safe on the browser-facing engine barrel.
10
+ *
11
+ * This is the *known* vocabulary — the set the Platform mints alerts from and
12
+ * the set the read-side consumers colour their badges by. It is deliberately
13
+ * NOT the wire type of the response fields. The hosted Platform always runs the
14
+ * newest build, while a customer's `kici` CLI is pinned to whatever version
15
+ * they installed and hard-parses this response
16
+ * (`packages/compiler/src/remote/dashboard-client.ts`). A strict enum on the
17
+ * wire would not degrade one alert row — it would fail the whole
18
+ * `/diagnostics/infrastructure` parse and take `kici diagnostics` down with it
19
+ * the day a fifth alert type ships. So the response carries `z.string()` and
20
+ * the producer carries the enum: strict on write, permissive on read.
21
+ */
22
+ import { z } from 'zod';
23
+ /**
24
+ * Known infrastructure alert types, matching what the Platform mints from the
25
+ * state it computes about connected orchestrators.
26
+ */
27
+ export declare const InfraAlertType: z.ZodEnum<{
28
+ capacity: "capacity";
29
+ "label-gaps": "label-gaps";
30
+ "no-raft-leader": "no-raft-leader";
31
+ "zero-agents": "zero-agents";
32
+ }>;
33
+ export type InfraAlertType = z.infer<typeof InfraAlertType>;
34
+ /** Every known alert type, in declaration order. */
35
+ export declare const INFRA_ALERT_TYPES: readonly InfraAlertType[];
36
+ /** Known alert severities, in ascending urgency. */
37
+ export declare const InfraAlertSeverity: z.ZodEnum<{
38
+ critical: "critical";
39
+ warning: "warning";
40
+ }>;
41
+ export type InfraAlertSeverity = z.infer<typeof InfraAlertSeverity>;
42
+ /**
43
+ * An alert as the Platform mints it, with both fields narrowed to the known
44
+ * vocabulary.
45
+ *
46
+ * The producer annotates its accumulator with this type, which is what turns a
47
+ * misspelled or unranked alert type into a `pnpm typecheck` failure at the mint
48
+ * site rather than a string that validates on the wire and renders as an
49
+ * unrecognised row.
50
+ */
51
+ export interface MintedInfraAlert {
52
+ type: InfraAlertType;
53
+ message: string;
54
+ severity: InfraAlertSeverity;
55
+ }
56
+ /**
57
+ * Resolve an arbitrary severity string read off the wire to a known severity.
58
+ *
59
+ * An unrecognised value resolves to `critical`. A client older than the
60
+ * Platform cannot know whether a severity it has never seen is quieter or
61
+ * louder than `critical`, and on an operator surface the safe reading of "I
62
+ * don't know" is the conspicuous one. A plain `severity === 'critical'`
63
+ * comparison instead reads every unrecognised value as a yellow warning, so a
64
+ * `critcal` typo silently downgrades a critical alert.
65
+ *
66
+ * `safeParse` is a set membership test, so an attacker-supplied
67
+ * `constructor` / `toString` cannot walk the prototype chain the way a bare
68
+ * object index would.
69
+ */
70
+ export declare function normalizeInfraAlertSeverity(severity: string): InfraAlertSeverity;
71
+ //# sourceMappingURL=infra-alert.d.ts.map
@@ -0,0 +1,60 @@
1
+ import "../rolldown-runtime-ClRpJifh.js";
2
+ import { z } from "zod";
3
+ //#region src/diagnostics/infra-alert.ts
4
+ /**
5
+ * Infrastructure alert vocabulary — the single definition of what a diagnostics
6
+ * infrastructure alert's `type` and `severity` can be.
7
+ *
8
+ * Lives beside the other shared vocabularies (`billing/plan-type.ts`,
9
+ * `context/held-run-status.ts`) rather than in the protocol module, so the
10
+ * Platform producer, the dashboard, and the `kici` CLI all name one enum
11
+ * instead of each carrying a copy. Pure Zod with no Node built-ins, so it is
12
+ * safe on the browser-facing engine barrel.
13
+ *
14
+ * This is the *known* vocabulary — the set the Platform mints alerts from and
15
+ * the set the read-side consumers colour their badges by. It is deliberately
16
+ * NOT the wire type of the response fields. The hosted Platform always runs the
17
+ * newest build, while a customer's `kici` CLI is pinned to whatever version
18
+ * they installed and hard-parses this response
19
+ * (`packages/compiler/src/remote/dashboard-client.ts`). A strict enum on the
20
+ * wire would not degrade one alert row — it would fail the whole
21
+ * `/diagnostics/infrastructure` parse and take `kici diagnostics` down with it
22
+ * the day a fifth alert type ships. So the response carries `z.string()` and
23
+ * the producer carries the enum: strict on write, permissive on read.
24
+ */
25
+ /**
26
+ * Known infrastructure alert types, matching what the Platform mints from the
27
+ * state it computes about connected orchestrators.
28
+ */
29
+ const InfraAlertType = z.enum([
30
+ "zero-agents",
31
+ "capacity",
32
+ "label-gaps",
33
+ "no-raft-leader"
34
+ ]);
35
+ /** Every known alert type, in declaration order. */
36
+ const INFRA_ALERT_TYPES = InfraAlertType.options;
37
+ /** Known alert severities, in ascending urgency. */
38
+ const InfraAlertSeverity = z.enum(["warning", "critical"]);
39
+ /**
40
+ * Resolve an arbitrary severity string read off the wire to a known severity.
41
+ *
42
+ * An unrecognised value resolves to `critical`. A client older than the
43
+ * Platform cannot know whether a severity it has never seen is quieter or
44
+ * louder than `critical`, and on an operator surface the safe reading of "I
45
+ * don't know" is the conspicuous one. A plain `severity === 'critical'`
46
+ * comparison instead reads every unrecognised value as a yellow warning, so a
47
+ * `critcal` typo silently downgrades a critical alert.
48
+ *
49
+ * `safeParse` is a set membership test, so an attacker-supplied
50
+ * `constructor` / `toString` cannot walk the prototype chain the way a bare
51
+ * object index would.
52
+ */
53
+ function normalizeInfraAlertSeverity(severity) {
54
+ const parsed = InfraAlertSeverity.safeParse(severity);
55
+ return parsed.success ? parsed.data : InfraAlertSeverity.enum.critical;
56
+ }
57
+ //#endregion
58
+ export { INFRA_ALERT_TYPES, InfraAlertSeverity, InfraAlertType, normalizeInfraAlertSeverity };
59
+
60
+ //# sourceMappingURL=infra-alert.js.map