@elementumai/edk 0.9.19 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +159 -7
  2. package/dist-sdk/src/catalog/factories.d.ts +33 -2
  3. package/dist-sdk/src/catalog/factories.js +40 -1
  4. package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
  5. package/dist-sdk/src/catalog/from-authoring.js +34 -9
  6. package/dist-sdk/src/catalog/index.d.ts +2 -2
  7. package/dist-sdk/src/catalog/index.js +2 -2
  8. package/dist-sdk/src/catalog/render.js +6 -6
  9. package/dist-sdk/src/catalog/token.js +11 -0
  10. package/dist-sdk/src/catalog/types.d.ts +40 -1
  11. package/dist-sdk/src/catalog/types.js +12 -0
  12. package/dist-sdk/src/core/triggers/on-demand.d.ts +40 -4
  13. package/dist-sdk/src/core/triggers/on-demand.js +17 -2
  14. package/dist-sdk/src/core/types/app.d.ts +2 -2
  15. package/dist-sdk/src/engine/build/context.d.ts +1 -1
  16. package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
  17. package/dist-sdk/src/engine/coverage-gaps.js +156 -0
  18. package/dist-sdk/src/engine/ei/run.d.ts +169 -0
  19. package/dist-sdk/src/engine/ei/run.js +1219 -0
  20. package/dist-sdk/src/engine/logging.d.ts +17 -0
  21. package/dist-sdk/src/engine/logging.js +18 -0
  22. package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
  23. package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
  24. package/dist-sdk/src/engine/pull/context.d.ts +68 -6
  25. package/dist-sdk/src/engine/pull/context.js +40 -1
  26. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
  27. package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
  28. package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
  29. package/dist-sdk/src/engine/pull/ref-only.js +10 -7
  30. package/dist-sdk/src/engine/pull/result-output.d.ts +6 -0
  31. package/dist-sdk/src/engine/pull/result-output.js +113 -3
  32. package/dist-sdk/src/engine/tf/expr.js +1 -1
  33. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  34. package/dist-sdk/src/engine/tf/index.js +1 -1
  35. package/dist-sdk/src/engine/tf/labels.d.ts +28 -5
  36. package/dist-sdk/src/engine/tf/labels.js +54 -3
  37. package/dist-sdk/src/engine/tf/model.d.ts +22 -1
  38. package/dist-sdk/src/engine/tf/parse.js +93 -4
  39. package/dist-sdk/src/engine/tf/render.d.ts +4 -2
  40. package/dist-sdk/src/engine/tf/render.js +41 -7
  41. package/dist-sdk/src/engine/validation.d.ts +44 -0
  42. package/dist-sdk/src/engine/validation.js +95 -0
  43. package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
  44. package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
  45. package/dist-sdk/src/entities/access-policy/to-tf.js +5 -2
  46. package/dist-sdk/src/entities/agent/build.d.ts +4 -16
  47. package/dist-sdk/src/entities/agent/build.js +40 -5
  48. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
  49. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +46 -21
  50. package/dist-sdk/src/entities/agent/from-tf.js +11 -3
  51. package/dist-sdk/src/entities/agent/module.js +2 -0
  52. package/dist-sdk/src/entities/agent/to-tf.js +20 -6
  53. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +10 -1
  54. package/dist-sdk/src/entities/agent-tool/from-tf.js +18 -6
  55. package/dist-sdk/src/entities/agent-tool/module.js +3 -0
  56. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  57. package/dist-sdk/src/entities/agent-tool/to-tf.js +27 -5
  58. package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
  59. package/dist-sdk/src/entities/app/auto-share.js +49 -0
  60. package/dist-sdk/src/entities/app/build.d.ts +105 -22
  61. package/dist-sdk/src/entities/app/build.js +107 -10
  62. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +22 -1
  63. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
  64. package/dist-sdk/src/entities/app/from-tf.js +11 -2
  65. package/dist-sdk/src/entities/app/index.d.ts +7 -6
  66. package/dist-sdk/src/entities/app/index.js +2 -8
  67. package/dist-sdk/src/entities/app/module.js +5 -2
  68. package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
  69. package/dist-sdk/src/entities/app/to-tf.js +40 -13
  70. package/dist-sdk/src/entities/automation/build.d.ts +56 -6
  71. package/dist-sdk/src/entities/automation/build.js +230 -26
  72. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
  73. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +41 -5
  74. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +470 -58
  75. package/dist-sdk/src/entities/automation/from-tf.d.ts +37 -8
  76. package/dist-sdk/src/entities/automation/from-tf.js +791 -131
  77. package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
  78. package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
  79. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  80. package/dist-sdk/src/entities/automation/index.js +1 -1
  81. package/dist-sdk/src/entities/automation/module.d.ts +3 -0
  82. package/dist-sdk/src/entities/automation/module.js +107 -15
  83. package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
  84. package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
  85. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
  86. package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
  87. package/dist-sdk/src/entities/automation/script-code.d.ts +20 -0
  88. package/dist-sdk/src/entities/automation/script-code.js +109 -5
  89. package/dist-sdk/src/entities/automation/system-ref-name.js +4 -0
  90. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +39 -0
  91. package/dist-sdk/src/entities/automation/task-output-labels.js +85 -0
  92. package/dist-sdk/src/entities/automation/tasks.d.ts +116 -22
  93. package/dist-sdk/src/entities/automation/tasks.js +86 -24
  94. package/dist-sdk/src/entities/automation/to-tf.d.ts +24 -3
  95. package/dist-sdk/src/entities/automation/to-tf.js +1082 -132
  96. package/dist-sdk/src/entities/automation/triggers.d.ts +12 -6
  97. package/dist-sdk/src/entities/automation/triggers.js +4 -0
  98. package/dist-sdk/src/entities/automation/types.d.ts +9 -0
  99. package/dist-sdk/src/entities/automation/types.js +19 -0
  100. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
  101. package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
  102. package/dist-sdk/src/entities/chart/from-tf.js +9 -1
  103. package/dist-sdk/src/entities/chart/to-tf.js +10 -3
  104. package/dist-sdk/src/entities/data-lookup/module.js +2 -0
  105. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +24 -31
  106. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  107. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
  108. package/dist-sdk/src/entities/element/build.d.ts +28 -13
  109. package/dist-sdk/src/entities/element/build.js +5 -1
  110. package/dist-sdk/src/entities/element/from-tf.d.ts +11 -0
  111. package/dist-sdk/src/entities/element/from-tf.js +62 -1
  112. package/dist-sdk/src/entities/element/index.d.ts +5 -3
  113. package/dist-sdk/src/entities/element/index.js +1 -0
  114. package/dist-sdk/src/entities/element/module.js +9 -3
  115. package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
  116. package/dist-sdk/src/entities/element/to-tf.js +16 -16
  117. package/dist-sdk/src/entities/field/build.d.ts +17 -3
  118. package/dist-sdk/src/entities/field/build.js +3 -0
  119. package/dist-sdk/src/entities/field/calc.d.ts +7 -7
  120. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -4
  121. package/dist-sdk/src/entities/field/from-tf.js +244 -49
  122. package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
  123. package/dist-sdk/src/entities/field/media-types.js +30 -0
  124. package/dist-sdk/src/entities/field/module.js +2 -0
  125. package/dist-sdk/src/entities/field/options.js +6 -1
  126. package/dist-sdk/src/entities/field/to-tf.d.ts +26 -5
  127. package/dist-sdk/src/entities/field/to-tf.js +137 -15
  128. package/dist-sdk/src/entities/field/types.d.ts +2 -0
  129. package/dist-sdk/src/entities/field/types.js +27 -0
  130. package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
  131. package/dist-sdk/src/entities/file-reader/module.js +1 -0
  132. package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
  133. package/dist-sdk/src/entities/file-reader/types.js +1 -1
  134. package/dist-sdk/src/entities/portal/build.d.ts +26 -0
  135. package/dist-sdk/src/entities/portal/build.js +37 -0
  136. package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
  137. package/dist-sdk/src/entities/portal/from-tf.js +75 -0
  138. package/dist-sdk/src/entities/portal/index.d.ts +1 -0
  139. package/dist-sdk/src/entities/portal/index.js +1 -0
  140. package/dist-sdk/src/entities/portal/module.d.ts +3 -0
  141. package/dist-sdk/src/entities/portal/module.js +28 -0
  142. package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
  143. package/dist-sdk/src/entities/portal/to-tf.js +73 -0
  144. package/dist-sdk/src/entities/portal/types.d.ts +1 -0
  145. package/dist-sdk/src/entities/portal/types.js +1 -0
  146. package/dist-sdk/src/entities/relationship/module.js +2 -0
  147. package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
  148. package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
  149. package/dist-sdk/src/entities/relationship/to-tf.d.ts +2 -0
  150. package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
  151. package/dist-sdk/src/entities/role/from-tf.js +3 -3
  152. package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
  153. package/dist-sdk/src/entities/role/to-tf.js +12 -4
  154. package/dist-sdk/src/entities/search-table/module.js +1 -0
  155. package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
  156. package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
  157. package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
  158. package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
  159. package/dist-sdk/src/entities/service-account/from-tf.js +20 -8
  160. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
  161. package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
  162. package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
  163. package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
  164. package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
  165. package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
  166. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
  167. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
  168. package/dist-sdk/src/entities/shared/filters/ast.d.ts +23 -1
  169. package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
  170. package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
  171. package/dist-sdk/src/entities/shared/filters/index.js +19 -4
  172. package/dist-sdk/src/entities/shared/filters/print.js +24 -3
  173. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -0
  174. package/dist-sdk/src/entities/shared/filters/tf-codec.js +46 -7
  175. package/dist-sdk/src/entities/shared/filters/types.d.ts +15 -2
  176. package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
  177. package/dist-sdk/src/entities/shared/ref.js +5 -7
  178. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
  179. package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
  180. package/dist-sdk/src/entities/shared/types/field-types.d.ts +20 -5
  181. package/dist-sdk/src/entities/shared/types/field-types.js +8 -0
  182. package/dist-sdk/src/entities/skill/access-policy.js +3 -3
  183. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
  184. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +14 -6
  185. package/dist-sdk/src/entities/skill/from-tf.js +70 -15
  186. package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
  187. package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
  188. package/dist-sdk/src/entities/skill/module.js +2 -0
  189. package/dist-sdk/src/entities/skill/to-tf.js +14 -4
  190. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  191. package/dist-sdk/src/entities/skill-tool/from-tf.js +49 -10
  192. package/dist-sdk/src/entities/skill-tool/module.js +3 -0
  193. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -8
  194. package/dist-sdk/src/entities/skill-tool/to-tf.js +49 -14
  195. package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
  196. package/dist-sdk/src/entities/table/catalog.js +66 -0
  197. package/dist-sdk/src/entities/table/module.js +2 -1
  198. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  199. package/dist-sdk/src/entities/task/build.d.ts +8 -0
  200. package/dist-sdk/src/entities/task/build.js +10 -1
  201. package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
  202. package/dist-sdk/src/entities/task/from-tf.js +7 -2
  203. package/dist-sdk/src/entities/task/module.js +2 -2
  204. package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
  205. package/dist-sdk/src/entities/task/to-tf.js +28 -1
  206. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -9
  207. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +71 -18
  208. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +19 -4
  209. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +82 -10
  210. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +53 -23
  211. package/dist-sdk/src/entities/view/agent-view-layout.js +1 -1
  212. package/dist-sdk/src/entities/view/from-tf.d.ts +3 -2
  213. package/dist-sdk/src/entities/view/from-tf.js +133 -13
  214. package/dist-sdk/src/entities/view/module.js +30 -3
  215. package/dist-sdk/src/entities/view/to-tf.d.ts +20 -8
  216. package/dist-sdk/src/entities/view/to-tf.js +86 -18
  217. package/dist-sdk/src/entities/view/types.d.ts +4 -15
  218. package/dist-sdk/src/entities/view/types.js +15 -15
  219. package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
  220. package/dist-sdk/src/entities/visual-flow/build.js +9 -0
  221. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
  222. package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
  223. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  224. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  225. package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
  226. package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
  227. package/dist-sdk/src/entities/widget/build.d.ts +16 -1
  228. package/dist-sdk/src/entities/widget/build.js +11 -1
  229. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  230. package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
  231. package/dist-sdk/src/entities/widget/to-tf.js +41 -14
  232. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +148 -13
  233. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  234. package/dist-sdk/src/graph/index.d.ts +12 -0
  235. package/dist-sdk/src/graph/index.js +21 -0
  236. package/dist-sdk/src/graph/modules.js +2 -0
  237. package/dist-sdk/src/graph/types.d.ts +83 -4
  238. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  239. package/dist-sdk/src/internal/sdk-package.js +1 -0
  240. package/package.json +16 -3
@@ -140,6 +140,16 @@ export function isUuid(value) {
140
140
  export function appResourceLabelPrefix(appTfLabel) {
141
141
  return `apps_${appTfLabel}_`;
142
142
  }
143
+ /** Prefix for standalone-task-owned children (custom fields, edk#1464). */
144
+ export function taskResourceLabelPrefix(taskTfLabel) {
145
+ return `tasks_${taskTfLabel}_`;
146
+ }
147
+ /** Prefix for a child label in the given owner scope. */
148
+ export function scopedResourceLabelPrefix(ownerTfLabel, scope) {
149
+ return scope === "app" ? appResourceLabelPrefix(ownerTfLabel)
150
+ : scope === "task" ? taskResourceLabelPrefix(ownerTfLabel)
151
+ : elementResourceLabelPrefix(ownerTfLabel);
152
+ }
143
153
  /** Prefix for element-owned children in a shared `.tf/out/` workspace. */
144
154
  export function elementResourceLabelPrefix(elementTfLabel) {
145
155
  return `elements_${elementTfLabel}_`;
@@ -171,18 +181,19 @@ export function appScopedResourceLabel(appTfLabel, childPart) {
171
181
  * address ei already uses — see `__tests__/tf/labels.test.ts`'s "element-prefixed child labels
172
182
  * round-trip" block. Re-pull an existing element (`elementum pull element <ns>`) before your
173
183
  * next build/plan if it predates this fix; adoption's rename guard (board item 225,
174
- * `docs/design/rename-label-identity.md`) safely `state mv`s any address that does shift.
184
+ * `docs/design/rename-label-identity.md`) moves any address that does shift with a `moved` block.
175
185
  */
176
186
  export function elementScopedResourceLabel(elementTfLabel, childPart) {
177
187
  return `${elementResourceLabelPrefix(elementTfLabel)}${elementTfLabel}_${childPart}`;
178
188
  }
179
189
  /** Emit a scoped child label for the owning stream root kind. */
180
190
  export function scopedResourceLabel(ownerTfLabel, childPart, scope) {
181
- return scope === "app" ? appScopedResourceLabel(ownerTfLabel, childPart) : elementScopedResourceLabel(ownerTfLabel, childPart);
191
+ // Same unconditional `<prefix><ns>_<ns>_<child>` doubling for every scope (issue #115).
192
+ return `${scopedResourceLabelPrefix(ownerTfLabel, scope)}${ownerTfLabel}_${childPart}`;
182
193
  }
183
194
  /** Strip a scoped child label back to its bare form (no-op when unprefixed). */
184
195
  export function bareChildResourceLabel(ownerTfLabel, scopedLabel, scope = "app") {
185
- const prefix = scope === "app" ? appResourceLabelPrefix(ownerTfLabel) : elementResourceLabelPrefix(ownerTfLabel);
196
+ const prefix = scopedResourceLabelPrefix(ownerTfLabel, scope);
186
197
  return scopedLabel.startsWith(prefix) ? scopedLabel.slice(prefix.length) : scopedLabel;
187
198
  }
188
199
  /**
@@ -198,6 +209,46 @@ export function childPartFromScopedLabel(ownerTfLabel, scopedLabel, scope) {
198
209
  const nsPrefix = `${ownerTfLabel}_`;
199
210
  return bare.startsWith(nsPrefix) ? bare.slice(nsPrefix.length) : bare;
200
211
  }
212
+ /**
213
+ * Owner encoded in `apps_<ns>_<ns>_<child>` / `elements_<ns>_<ns>_<child>` /
214
+ * `tasks_<ns>_<ns>_<child>`. The namespace may itself contain underscores, so
215
+ * the owner is the longest prefix that is immediately repeated. The shortest
216
+ * match treats a repeated token inside the namespace as the owner
217
+ * (`apps_foo_foo_foo_foo_status`).
218
+ */
219
+ export function ownerFromScopedChildLabel(scopedLabel) {
220
+ const scope = scopedLabel.startsWith("elements_")
221
+ ? "element"
222
+ : scopedLabel.startsWith("tasks_")
223
+ ? "task"
224
+ : scopedLabel.startsWith("apps_")
225
+ ? "app"
226
+ : undefined;
227
+ if (scope === undefined)
228
+ return undefined;
229
+ const prefixLen = scope === "element" ? "elements_".length
230
+ : scope === "task" ? "tasks_".length
231
+ : "apps_".length;
232
+ const rest = scopedLabel.slice(prefixLen);
233
+ let match;
234
+ for (let i = 1; i < rest.length; i++) {
235
+ if (rest[i] !== "_")
236
+ continue;
237
+ const owner = rest.slice(0, i);
238
+ if (rest.startsWith(`${owner}_${owner}_`))
239
+ match = { scope, ownerTfLabel: owner };
240
+ }
241
+ return match;
242
+ }
243
+ /**
244
+ * First 8 alphanumeric characters of `id`, lowercased. ei export's
245
+ * `stableIDSuffix` (cmd/elementum/export/search_table_refs.go) must stay
246
+ * identical so an id-keyed data source address matches on both sides.
247
+ */
248
+ export function stableIdSuffix(id) {
249
+ const normalized = id.toLowerCase().replace(/[^a-z0-9]/g, "");
250
+ return normalized.slice(0, 8);
251
+ }
201
252
  /** Scoped terraform label → authoring bag key / ref key. */
202
253
  export function scopedLabelToBagKey(ownerTfLabel, scopedLabel, scope = "app") {
203
254
  return tfLabelToTsLabel(childPartFromScopedLabel(ownerTfLabel, scopedLabel, scope));
@@ -67,13 +67,34 @@ export type TfValue = string | number | boolean | null | TfValue[] | {
67
67
  [k: string]: TfValue;
68
68
  } | TfExpr;
69
69
  export type TfBlockKind = "resource" | "data" | "locals" | "import" | "provider" | "terraform" | "variable";
70
+ /**
71
+ * A resource's nested `lifecycle { ignore_changes = ... }` block — `"all"` or
72
+ * named top-level attributes. Never part of the ei dialect: only smart apply
73
+ * emits it, to stop a limited plan changing items that aren't the caller's.
74
+ */
75
+ export interface TfLifecycle {
76
+ ignoreChanges: "all" | readonly string[];
77
+ }
78
+ /**
79
+ * A variable's nested `validation` block. The condition is raw HCL, not a
80
+ * closed-grammar expression: `var.name != ""` is outside that grammar, and
81
+ * pull must still accept the block. Only required write-only secrets emit it.
82
+ */
83
+ export interface TfVariableValidation {
84
+ readonly condition: string;
85
+ readonly errorMessage: string;
86
+ }
70
87
  export interface TfBlock {
71
88
  kind: TfBlockKind;
72
89
  /** resource/data only: the terraform type, e.g. "elementum_app" */
73
90
  type?: string;
74
- /** resource/data: the label; provider: the provider name */
91
+ /** resource/data: the label; provider: the provider name; variable: the variable name */
75
92
  label?: string;
76
93
  attrs: Record<string, TfValue>;
94
+ /** resource only: rendered as a nested `lifecycle` block after the attributes. */
95
+ lifecycle?: TfLifecycle;
96
+ /** variable only: rendered as a nested `validation` block. */
97
+ variableValidation?: TfVariableValidation;
77
98
  }
78
99
  export interface TfDocument {
79
100
  blocks: TfBlock[];
@@ -328,7 +328,14 @@ function documentFromHcl2Json(raw) {
328
328
  for (const [type, byLabel] of Object.entries(byType)) {
329
329
  for (const [label, bodies] of Object.entries(byLabel)) {
330
330
  for (const body of bodies) {
331
- blocks.push({ kind, type, label, attrs: convertBody(body, `${kind}.${type}.${label}`) });
331
+ const ctx = `${kind}.${type}.${label}`;
332
+ if (kind === "resource" && isRecord(body) && "lifecycle" in body) {
333
+ const { lifecycle, ...rest } = body;
334
+ blocks.push({ kind, type, label, attrs: convertBody(rest, ctx), lifecycle: convertLifecycle(lifecycle, ctx) });
335
+ }
336
+ else {
337
+ blocks.push({ kind, type, label, attrs: convertBody(body, ctx) });
338
+ }
332
339
  }
333
340
  }
334
341
  }
@@ -354,8 +361,20 @@ function documentFromHcl2Json(raw) {
354
361
  const variables = raw["variable"];
355
362
  if (variables) {
356
363
  for (const [name, bodies] of Object.entries(variables)) {
357
- for (const body of bodies)
358
- blocks.push({ kind: "variable", label: name, attrs: convertBody(body, `variable.${name}`) });
364
+ for (const body of bodies) {
365
+ if (isRecord(body) && "validation" in body) {
366
+ const { validation, ...rest } = body;
367
+ blocks.push({
368
+ kind: "variable",
369
+ label: name,
370
+ attrs: convertBody(rest, `variable.${name}`),
371
+ variableValidation: convertVariableValidation(validation, `variable.${name}`),
372
+ });
373
+ }
374
+ else {
375
+ blocks.push({ kind: "variable", label: name, attrs: convertBody(body, `variable.${name}`) });
376
+ }
377
+ }
359
378
  }
360
379
  }
361
380
  const terraformBodies = raw["terraform"];
@@ -366,6 +385,39 @@ function documentFromHcl2Json(raw) {
366
385
  }
367
386
  return { blocks };
368
387
  }
388
+ function isRecord(value) {
389
+ return typeof value === "object" && value !== null && !Array.isArray(value);
390
+ }
391
+ const BARE_REFERENCE_RE = /^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;
392
+ /**
393
+ * hcl2json reads `lifecycle { ignore_changes = all }` as
394
+ * `[{ "ignore_changes": "${all}" }]` and a name list as `["${name}", ...]`.
395
+ * Only that one shape is accepted — any other lifecycle setting stays loud.
396
+ */
397
+ function convertLifecycle(value, ctx) {
398
+ const at = `${ctx}.lifecycle`;
399
+ if (!Array.isArray(value) || value.length !== 1 || !isRecord(value[0])) {
400
+ throw new TfParseError(`unexpected lifecycle block shape at ${at}`);
401
+ }
402
+ const keys = Object.keys(value[0]);
403
+ if (keys.length !== 1 || keys[0] !== "ignore_changes") {
404
+ throw new TfParseError(`at ${at}: only ignore_changes is supported, got ${keys.join(", ") || "nothing"}`);
405
+ }
406
+ const ignore = value[0]["ignore_changes"];
407
+ if (ignore === "${all}")
408
+ return { ignoreChanges: "all" };
409
+ if (Array.isArray(ignore)) {
410
+ return {
411
+ ignoreChanges: ignore.map((entry) => {
412
+ const match = typeof entry === "string" ? BARE_REFERENCE_RE.exec(entry) : null;
413
+ if (match === null)
414
+ throw new TfParseError(`at ${at}.ignore_changes: expected attribute names, got ${JSON.stringify(entry)}`);
415
+ return match[1];
416
+ }),
417
+ };
418
+ }
419
+ throw new TfParseError(`at ${at}.ignore_changes: expected all or a list of attribute names`);
420
+ }
369
421
  function convertBody(body, ctx) {
370
422
  if (typeof body !== "object" || body === null || Array.isArray(body)) {
371
423
  throw new TfParseError(`unexpected block body shape at ${ctx}`);
@@ -383,7 +435,7 @@ function convertValue(value, ctx) {
383
435
  return value;
384
436
  if (typeof value === "string") {
385
437
  try {
386
- return parseStringValue(value, { allowVariables: isCredentialVariableContext(ctx) });
438
+ return parseStringValue(value, { allowVariables: allowsVariableReference(ctx) });
387
439
  }
388
440
  catch (e) {
389
441
  if (e instanceof TfExprError) {
@@ -409,10 +461,47 @@ function convertValue(value, ctx) {
409
461
  }
410
462
  throw new TfParseError(`unsupported value type "${typeof value}" at ${ctx}`);
411
463
  }
464
+ function allowsVariableReference(ctx) {
465
+ return isCredentialVariableContext(ctx) || isWriteOnlyApiSecretContext(ctx);
466
+ }
412
467
  function isCredentialVariableContext(ctx) {
468
+ // Resource types stay inside regex literals. src/engine must not contain
469
+ // quoted elementum_* resource-type strings.
413
470
  return /^resource\.elementum_cloudlink\.[^.]+\.credentials(?:\.|$)/.test(ctx) ||
414
471
  /^resource\.elementum_phone_provider\.[^.]+\.twilio(?:\.|$)/.test(ctx);
415
472
  }
473
+ function isWriteOnlyApiSecretContext(ctx) {
474
+ // value_wo/username_wo are the provider's write-only forms (edk#1400).
475
+ return /^resource\.elementum_api_task\.[^.]+\.headers\[\d+\]\.value(?:_wo)?$/.test(ctx) ||
476
+ /^resource\.elementum_api_task\.[^.]+\.basic_auth\.username(?:_wo)?$/.test(ctx);
477
+ }
478
+ /**
479
+ * hcl2json reads `validation { condition = var.x != "" }` as
480
+ * `[{ condition: "${var.x != \"\"}", error_message: "..." }]`. The condition
481
+ * is not a closed-grammar expression, so it is preserved as raw text.
482
+ */
483
+ function convertVariableValidation(value, ctx) {
484
+ const at = `${ctx}.validation`;
485
+ if (!Array.isArray(value) || value.length !== 1 || !isRecord(value[0])) {
486
+ throw new TfParseError(`unexpected validation block shape at ${at}`);
487
+ }
488
+ const condition = unwrapHclExpr(value[0]["condition"]);
489
+ const errorMessage = value[0]["error_message"];
490
+ if (condition === undefined || condition === "") {
491
+ throw new TfParseError(`at ${at}: validation condition must be an expression`);
492
+ }
493
+ if (typeof errorMessage !== "string") {
494
+ throw new TfParseError(`at ${at}: validation error_message must be a string`);
495
+ }
496
+ return { condition, errorMessage };
497
+ }
498
+ function unwrapHclExpr(value) {
499
+ if (typeof value !== "string")
500
+ return undefined;
501
+ if (value.startsWith("${") && value.endsWith("}") && value.length >= 3)
502
+ return value.slice(2, -1);
503
+ return value;
504
+ }
416
505
  /**
417
506
  * Refuse to parse text whose integer literals exceed Number.MAX_SAFE_INTEGER —
418
507
  * hcl2json would round them silently (verified: 2^53+1 → 2^53).
@@ -5,8 +5,10 @@
5
5
  * Formatting is OURS (deterministic, 2-space indent, attrs sorted
6
6
  * alphabetically) — ei's incidental formatting is not replicated; the
7
7
  * round-trip check is structural, both sides parsed by the same parser.
8
- * The ei dialect is attributes-only (verified across real exports), so no
9
- * nested-block syntax is emitted.
8
+ * The ei resource dialect is attributes-only (verified across real exports).
9
+ * Two nested blocks are emitted outside that dialect: a resource's
10
+ * `lifecycle`, which only smart apply sets, and a variable's `validation`,
11
+ * which only a required write-only secret sets.
10
12
  */
11
13
  import type { TfBlock, TfDocument } from "./model.js";
12
14
  export declare function renderDocument(doc: TfDocument): string;
@@ -5,8 +5,10 @@
5
5
  * Formatting is OURS (deterministic, 2-space indent, attrs sorted
6
6
  * alphabetically) — ei's incidental formatting is not replicated; the
7
7
  * round-trip check is structural, both sides parsed by the same parser.
8
- * The ei dialect is attributes-only (verified across real exports), so no
9
- * nested-block syntax is emitted.
8
+ * The ei resource dialect is attributes-only (verified across real exports).
9
+ * Two nested blocks are emitted outside that dialect: a resource's
10
+ * `lifecycle`, which only smart apply sets, and a variable's `validation`,
11
+ * which only a required write-only secret sets.
10
12
  */
11
13
  import { quoteHclString } from "./escape.js";
12
14
  import { isTfExpr } from "./model.js";
@@ -15,11 +17,40 @@ export function renderDocument(doc) {
15
17
  }
16
18
  export function renderBlock(block) {
17
19
  const header = blockHeader(block);
18
- const body = Object.entries(block.attrs)
20
+ const lines = Object.entries(block.attrs)
19
21
  .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
20
- .map(([key, value]) => ` ${key} = ${renderValue(value, 1)}`)
21
- .join("\n");
22
- return `${header} {\n${body}\n}\n`;
22
+ .map(([key, value]) => ` ${key} = ${renderValue(value, 1)}`);
23
+ if (block.lifecycle !== undefined) {
24
+ if (block.kind !== "resource")
25
+ throw new Error(`a lifecycle block is only valid on a resource, not ${block.kind}`);
26
+ lines.push(renderLifecycle(block.lifecycle));
27
+ }
28
+ if (block.variableValidation !== undefined) {
29
+ if (block.kind !== "variable")
30
+ throw new Error(`a validation block is only valid on a variable, not ${block.kind}`);
31
+ lines.push(renderVariableValidation(block.label, block.variableValidation));
32
+ }
33
+ return `${header} {\n${lines.join("\n")}\n}\n`;
34
+ }
35
+ const ATTRIBUTE_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
36
+ function renderLifecycle(lifecycle) {
37
+ if (lifecycle.ignoreChanges === "all")
38
+ return " lifecycle {\n ignore_changes = all\n }";
39
+ const names = lifecycle.ignoreChanges.map((name) => {
40
+ if (!ATTRIBUTE_NAME_RE.test(name))
41
+ throw new Error(`ignore_changes names a top-level attribute, got "${name}"`);
42
+ return name;
43
+ });
44
+ return ` lifecycle {\n ignore_changes = [${names.join(", ")}]\n }`;
45
+ }
46
+ const REQUIRED_SECRET_CONDITION = /^var\.[A-Za-z_][A-Za-z0-9_]* != ""$/;
47
+ function renderVariableValidation(label, validation) {
48
+ if (!label || !ATTRIBUTE_NAME_RE.test(label))
49
+ throw new Error(`variable validation needs an identifier name, got "${label ?? ""}"`);
50
+ if (!REQUIRED_SECRET_CONDITION.test(validation.condition)) {
51
+ throw new Error(`variable ${label} validation condition must refuse an empty value`);
52
+ }
53
+ return ` validation {\n condition = ${validation.condition}\n error_message = ${quoteHclString(validation.errorMessage)}\n }`;
23
54
  }
24
55
  function blockHeader(block) {
25
56
  switch (block.kind) {
@@ -67,8 +98,11 @@ function renderValue(value, depth) {
67
98
  return `{\n${body}\n${close}}`;
68
99
  }
69
100
  const BARE_KEY_RE = /^[A-Za-z_][A-Za-z0-9_-]*$/;
101
+ // `for` starts a for-expression, so `{ for = 1 }` is not an object. `null`,
102
+ // `true`, and `false` are literals; quote them too. `if` is a valid bare key.
103
+ const RESERVED_OBJECT_KEYS = new Set(["false", "for", "null", "true"]);
70
104
  function objectKey(k) {
71
- return BARE_KEY_RE.test(k) ? k : quoteHclString(k);
105
+ return BARE_KEY_RE.test(k) && !RESERVED_OBJECT_KEYS.has(k) ? k : quoteHclString(k);
72
106
  }
73
107
  function renderExpr(e, depth) {
74
108
  switch (e.$expr) {
@@ -0,0 +1,44 @@
1
+ export type ValidationSeverity = "fatal" | "warning";
2
+ export type ValidationMode = "pull" | "build";
3
+ export interface ValidationFailure {
4
+ readonly severity: ValidationSeverity;
5
+ /** Terraform resource address, `type.label`. */
6
+ readonly address: string;
7
+ /** Automation or agent display name. */
8
+ readonly name: string;
9
+ readonly ownerKind: string;
10
+ readonly message: string;
11
+ /**
12
+ * A reference the live config no longer satisfies (for example a run-automation
13
+ * tool that does not map a newly required trigger parameter). Pull downgrades
14
+ * these to warnings; build/plan/apply keep them fatal.
15
+ */
16
+ readonly staleReference?: boolean;
17
+ }
18
+ export declare function formatValidationFailure(failure: ValidationFailure): string;
19
+ export declare class ValidationFailureError extends Error {
20
+ readonly failures: readonly ValidationFailure[];
21
+ constructor(failures: readonly ValidationFailure[]);
22
+ }
23
+ /** True for this module's class and for the same-shaped error from a loader copy. */
24
+ export declare function isValidationFailureError(error: unknown): error is ValidationFailureError;
25
+ export declare function withValidationSession<T>(mode: ValidationMode, run: () => T): T;
26
+ export declare function withValidationSessionAsync<T>(mode: ValidationMode, run: () => Promise<T>): Promise<T>;
27
+ /**
28
+ * A fresh session even inside another one, for a side computation whose
29
+ * findings must not reach the enclosing command's verdict.
30
+ */
31
+ export declare function withIsolatedValidationSessionAsync<T>(mode: ValidationMode, run: () => Promise<T>): Promise<T>;
32
+ export declare function currentValidationMode(): ValidationMode | undefined;
33
+ export declare function currentValidationScope(): {
34
+ readonly appTfLabel?: string;
35
+ readonly parentScope?: "app" | "element" | "table";
36
+ };
37
+ export declare function setValidationScope(scope: {
38
+ appTfLabel?: string;
39
+ parentScope?: "app" | "element" | "table";
40
+ }): void;
41
+ export declare function sessionValidationFailures(): readonly ValidationFailure[];
42
+ /** Record failures into the active session. No-op when nothing is collecting. */
43
+ export declare function recordValidations(incoming: readonly ValidationFailure[]): void;
44
+ export declare function hasFatalValidation(failures: readonly ValidationFailure[]): boolean;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Collects validation failures across a pull or build instead of stopping at
3
+ * the first one. A stale reference is fatal while authoring (build/plan/apply)
4
+ * and a warning on pull, which is a read of live configuration.
5
+ */
6
+ import { AsyncLocalStorage } from "node:async_hooks";
7
+ export function formatValidationFailure(failure) {
8
+ return `${failure.address}: ${failure.ownerKind} "${failure.name}": ${failure.message}`;
9
+ }
10
+ export class ValidationFailureError extends Error {
11
+ failures;
12
+ constructor(failures) {
13
+ super(failures.map(formatValidationFailure).join("\n"));
14
+ this.name = "ValidationFailureError";
15
+ this.failures = failures;
16
+ }
17
+ }
18
+ /**
19
+ * The workspace loader evaluates authored files through a second module
20
+ * graph (native import with a generation query, or jiti with
21
+ * `moduleCache: false`). A storage local to this module would be invisible
22
+ * to `def()` in that copy, and `instanceof` against this class would miss.
23
+ * One process-wide store keeps the async context shared.
24
+ */
25
+ const STORAGE_KEY = Symbol.for("edk.validationStorage");
26
+ function storage() {
27
+ const host = globalThis;
28
+ host[STORAGE_KEY] ??= new AsyncLocalStorage();
29
+ return host[STORAGE_KEY];
30
+ }
31
+ /** True for this module's class and for the same-shaped error from a loader copy. */
32
+ export function isValidationFailureError(error) {
33
+ if (error instanceof ValidationFailureError)
34
+ return true;
35
+ if (!(error instanceof Error) || error.name !== "ValidationFailureError")
36
+ return false;
37
+ return Array.isArray(error.failures);
38
+ }
39
+ function newSession(mode) {
40
+ return { mode, failures: [], seen: new Set() };
41
+ }
42
+ export function withValidationSession(mode, run) {
43
+ if (storage().getStore() !== undefined)
44
+ return run();
45
+ return storage().run(newSession(mode), run);
46
+ }
47
+ export function withValidationSessionAsync(mode, run) {
48
+ if (storage().getStore() !== undefined)
49
+ return run();
50
+ return withIsolatedValidationSessionAsync(mode, run);
51
+ }
52
+ /**
53
+ * A fresh session even inside another one, for a side computation whose
54
+ * findings must not reach the enclosing command's verdict.
55
+ */
56
+ export function withIsolatedValidationSessionAsync(mode, run) {
57
+ return storage().run(newSession(mode), run);
58
+ }
59
+ export function currentValidationMode() {
60
+ return storage().getStore()?.mode;
61
+ }
62
+ export function currentValidationScope() {
63
+ const session = storage().getStore();
64
+ return { appTfLabel: session?.appTfLabel, parentScope: session?.parentScope };
65
+ }
66
+ export function setValidationScope(scope) {
67
+ const session = storage().getStore();
68
+ if (session === undefined)
69
+ return;
70
+ if (scope.appTfLabel !== undefined)
71
+ session.appTfLabel = scope.appTfLabel;
72
+ if (scope.parentScope !== undefined)
73
+ session.parentScope = scope.parentScope;
74
+ }
75
+ export function sessionValidationFailures() {
76
+ return storage().getStore()?.failures ?? [];
77
+ }
78
+ /** Record failures into the active session. No-op when nothing is collecting. */
79
+ export function recordValidations(incoming) {
80
+ const session = storage().getStore();
81
+ if (session === undefined)
82
+ return;
83
+ for (const failure of incoming) {
84
+ const severity = failure.staleReference === true && session.mode === "pull" ? "warning" : failure.severity;
85
+ const recorded = severity === failure.severity ? failure : { ...failure, severity };
86
+ const key = `${recorded.severity}\0${recorded.address}\0${recorded.message}`;
87
+ if (session.seen.has(key))
88
+ continue;
89
+ session.seen.add(key);
90
+ session.failures.push(recorded);
91
+ }
92
+ }
93
+ export function hasFatalValidation(failures) {
94
+ return failures.some((failure) => failure.severity === "fatal");
95
+ }
@@ -11,7 +11,7 @@
11
11
  * dropped with a diagnostic rather than silently misattributed.
12
12
  */
13
13
  import { EntityTfError } from "../../engine/entity.js";
14
- import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
14
+ import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
15
15
  import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedLabelToBagKey, scopedResourceLabel, tfLabelToTsLabel, } from "../../engine/tf/index.js";
16
16
  import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
17
17
  import { groupId, userId, } from "./principal.js";
@@ -143,8 +143,45 @@ function principalListItem(item, dataType, where, ctx, owner) {
143
143
  }
144
144
  return { __kind: "serviceAccount", appRefName, name: value };
145
145
  }
146
+ if (dataType === "elementum_group" && ctx.groupKeysByName?.has(value)) {
147
+ return { __kind: "orgPrincipalRef", dataType, label, value, catalogKey: groupCatalogKey(ctx, label, value) };
148
+ }
146
149
  return { __kind: "orgPrincipalRef", dataType, label, value };
147
150
  }
151
+ // Same-app service accounts export as resource-attr (not data-attr). Match
152
+ // skill/agent/role pull: recover name from the managed SA block.
153
+ if (dataType === "elementum_service_account") {
154
+ const resourceLabel = resourceRefLabel(item, "elementum_service_account");
155
+ if (resourceLabel !== undefined) {
156
+ const account = ctx.resourceByAddress?.(`elementum_service_account.${resourceLabel}`);
157
+ const explicitName = account?.attrs["name"];
158
+ const firstName = account?.attrs["first_name"];
159
+ const lastName = account?.attrs["last_name"];
160
+ const name = typeof explicitName === "string" && explicitName !== ""
161
+ ? explicitName
162
+ : typeof firstName === "string" && typeof lastName === "string" ? `${firstName} ${lastName}` : undefined;
163
+ if (name === undefined) {
164
+ ctx.diagnostics.push(`${where}: elementum_service_account.${resourceLabel} has no recoverable display name; dropped`);
165
+ return undefined;
166
+ }
167
+ const appId = account?.attrs["app_id"];
168
+ const appDataLabel = dataRefLabel(appId, "elementum_app");
169
+ const appResourceLabel = resourceRefLabel(appId, "elementum_app");
170
+ const appName = appDataLabel === undefined ? undefined : ctx.dataName("elementum_app", appDataLabel);
171
+ const appRefName = appName !== undefined
172
+ ? ctx.foreignAppRefNames?.get(appName)
173
+ : appResourceLabel !== undefined && owner?.scope === "app" && owner.label === appResourceLabel
174
+ ? owner.ownerRefName
175
+ : appResourceLabel === undefined
176
+ ? undefined
177
+ : ctx.foreignAppRefNamespaces?.get(appResourceLabel);
178
+ if (appRefName === undefined) {
179
+ ctx.diagnostics.push(`${where}: elementum_service_account.${resourceLabel} has no resolvable app_id owner; dropped`);
180
+ return undefined;
181
+ }
182
+ return { __kind: "serviceAccount", appRefName, name };
183
+ }
184
+ }
148
185
  if (typeof item === "string") {
149
186
  if (dataType === "elementum_user")
150
187
  return userId(item);
@@ -24,6 +24,8 @@ export interface AccessPolicyPrincipalRef<DataType extends PrincipalDataType = P
24
24
  readonly label: string;
25
25
  /** The data block's lookup value: email for a user, name for a group or service account. */
26
26
  readonly value: string;
27
+ /** For a group: the `org.groups` key org.ts assigned it, when known (edk#1412). */
28
+ readonly catalogKey?: string;
27
29
  }
28
30
  export type AccessPolicyUserRef = UserId | RoleUserRef | AccessPolicyPrincipalRef<"elementum_user">;
29
31
  export type AccessPolicyGroupRef = GroupId | GroupRef | AccessPolicyPrincipalRef<"elementum_group">;
@@ -45,9 +45,12 @@ function fieldValueToTf(token, where, ctx) {
45
45
  function picklistLiteralToTf(literal, field, ctx) {
46
46
  if (field?.options === undefined || !field.options.includes(literal))
47
47
  return undefined;
48
- const localName = field.tags?.includes("STATUS")
48
+ // Hand-built refs to an app's system status/stage carry no tags; match them
49
+ // by key, as field resolution does. Elements have no status/stage system fields.
50
+ const systemKey = ctx.scope === "element" ? undefined : field.refName;
51
+ const localName = ctx.scope === "app" && (field.tags?.includes("STATUS") || systemKey === "status")
49
52
  ? `${ctx.ownerTfLabel}_status_options_by_label`
50
- : field.tags?.includes("STAGE")
53
+ : ctx.scope === "app" && (field.tags?.includes("STAGE") || systemKey === "stage")
51
54
  ? `${ctx.ownerTfLabel}_stage_options_by_label`
52
55
  : undefined;
53
56
  // Non-status/stage picklists: the field's own options-by-label local, keyed
@@ -126,22 +126,10 @@ export interface AgentV2Options extends EntityDeployOptions {
126
126
  readonly a2aSkills?: readonly A2ASkill[];
127
127
  readonly tools?: readonly AgentTool[];
128
128
  }
129
- /**
130
- * def()-time validation of run-automation (executeWorkflow) tools against
131
- * the embedded automation token's trigger/outputs bags — the runtime
132
- * backstop behind `agentRunAutomation`'s typed inputs (the app
133
- * handle/namespace pattern: throw with the full story, at def() time).
134
- *
135
- * MUST run before `slimTokens` — slimming strips the automation token's
136
- * `trigger`/`outputs` bags. Bags that are absent OR EMPTY are skipped:
137
- * absent = a hand-written/foreign token (the printer's foreign-token
138
- * policy — platform stays the backstop); empty `{}` = the catalog regen's
139
- * STUB pass, which builds the defs bag (and therefore calls def()) against
140
- * stub tokens whose bags are empty objects. A real catalog token is either
141
- * bag-less (paramless automation → undefined) or non-empty, so skipping
142
- * empty costs no real coverage.
143
- */
144
- export declare function validateAgentTools(agentName: string, tools: readonly AgentTool[]): void;
129
+ export declare function validateAgentTools(agentName: string, tools: readonly AgentTool[], identity?: {
130
+ readonly appTfLabel: string;
131
+ readonly agentRefName: string;
132
+ }): void;
145
133
  /**
146
134
  * The configured result of `agent` — its reference surface (`ref()`)
147
135
  * and its deployable entity (`def()`). Both take `refName` as a **call-time