typekro 0.26.0 → 0.27.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 (41) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/alchemy/kro-delete.d.ts +8 -0
  3. package/dist/alchemy/kro-delete.d.ts.map +1 -1
  4. package/dist/alchemy/kro-delete.js +34 -35
  5. package/dist/alchemy/kro-delete.js.map +1 -1
  6. package/dist/alchemy/resource-registration.d.ts +60 -0
  7. package/dist/alchemy/resource-registration.d.ts.map +1 -1
  8. package/dist/alchemy/resource-registration.js +290 -11
  9. package/dist/alchemy/resource-registration.js.map +1 -1
  10. package/dist/alchemy/types.d.ts +44 -0
  11. package/dist/alchemy/types.d.ts.map +1 -1
  12. package/dist/core/deployment/k8s-helpers.d.ts +12 -0
  13. package/dist/core/deployment/k8s-helpers.d.ts.map +1 -1
  14. package/dist/core/deployment/k8s-helpers.js +26 -1
  15. package/dist/core/deployment/k8s-helpers.js.map +1 -1
  16. package/dist/core/deployment/kro-factory.d.ts +248 -1
  17. package/dist/core/deployment/kro-factory.d.ts.map +1 -1
  18. package/dist/core/deployment/kro-factory.js +1060 -180
  19. package/dist/core/deployment/kro-factory.js.map +1 -1
  20. package/dist/core/deployment/kro-instance-safety.d.ts +209 -0
  21. package/dist/core/deployment/kro-instance-safety.d.ts.map +1 -1
  22. package/dist/core/deployment/kro-instance-safety.js +506 -24
  23. package/dist/core/deployment/kro-instance-safety.js.map +1 -1
  24. package/dist/core/deployment/kro-namespace-teardown.d.ts +248 -0
  25. package/dist/core/deployment/kro-namespace-teardown.d.ts.map +1 -0
  26. package/dist/core/deployment/kro-namespace-teardown.js +459 -0
  27. package/dist/core/deployment/kro-namespace-teardown.js.map +1 -0
  28. package/dist/core/deployment/rollback-manager.d.ts +32 -0
  29. package/dist/core/deployment/rollback-manager.d.ts.map +1 -1
  30. package/dist/core/deployment/rollback-manager.js +69 -21
  31. package/dist/core/deployment/rollback-manager.js.map +1 -1
  32. package/dist/core/serialization/core.d.ts.map +1 -1
  33. package/dist/core/serialization/core.js +82 -8
  34. package/dist/core/serialization/core.js.map +1 -1
  35. package/dist/core/types/deployment.d.ts +20 -0
  36. package/dist/core/types/deployment.d.ts.map +1 -1
  37. package/dist/utils/string.d.ts +14 -0
  38. package/dist/utils/string.d.ts.map +1 -1
  39. package/dist/utils/string.js +22 -0
  40. package/dist/utils/string.js.map +1 -1
  41. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
+ import { CEL_EXPRESSION_BRAND } from '../../shared/brands.js';
1
2
  import { isCelExpression, isKubernetesRef } from '../../utils/type-guards.js';
2
3
  import { createCompositionContext, runWithCompositionContext } from '../composition/context.js';
3
4
  import { KUBERNETES_REF_SCHEMA_MARKER_SOURCE } from '../constants/brands.js';
4
5
  import { TypeKroError } from '../errors.js';
5
- import { getIncludeWhen } from '../metadata/index.js';
6
+ import { copyResourceMetadata, getIncludeWhen } from '../metadata/index.js';
6
7
  import { evaluateSchemaCelExpression } from './schema-cel-evaluator.js';
7
8
  function resourceEntries(resources) {
8
9
  if (!resources)
@@ -21,7 +22,7 @@ function resolveSpecPath(spec, fieldPath) {
21
22
  }
22
23
  return current;
23
24
  }
24
- function resolveNamespaceName(value, spec) {
25
+ export function resolveNamespaceName(value, spec) {
25
26
  if (isKubernetesRef(value)) {
26
27
  if (value.resourceId !== '__schema__')
27
28
  return undefined;
@@ -57,6 +58,64 @@ function resolveNamespaceName(value, spec) {
57
58
  });
58
59
  return unresolved ? undefined : resolved;
59
60
  }
61
+ /**
62
+ * Resolve a Namespace METADATA value (a label or annotation VALUE) to its concrete
63
+ * string form (finding #5).
64
+ *
65
+ * Unlike {@link resolveNamespaceName} — which resolves a namespace NAME and is
66
+ * correctly restricted to DNS-label shape — metadata values are UNRESTRICTED strings:
67
+ * `Team_A`, free text with spaces, arbitrary annotation content. The old path routed
68
+ * these through `resolveNamespaceName`, whose DNS-label short-circuit only accepts a
69
+ * CEL body matching a DNS label and then hands anything else to the CEL evaluator,
70
+ * which throws / returns undefined for a plain literal like `Team_A` or `some text` —
71
+ * silently DROPPING valid metadata.
72
+ *
73
+ * A concrete re-execution collapses a schema-derived value into a CEL whose BODY is
74
+ * the resolved literal. So for a CEL value we:
75
+ * - first try evaluating it (handles genuine expressions — `has()`, `orValue()`,
76
+ * concatenations); if that yields a primitive, use it;
77
+ * - otherwise the body is a concrete literal that is not a valid standalone CEL
78
+ * program (e.g. `Team_A`, `some text`) — return it VERBATIM as the concrete value,
79
+ * with NO DNS-label restriction.
80
+ * Numbers / booleans are stringified; refs resolve against the spec; plain strings and
81
+ * marker-embedded strings defer to {@link resolveNamespaceName} (which returns them
82
+ * verbatim / resolves the marker). Returns `undefined` only for a genuinely
83
+ * unresolvable value (an unresolved schema ref), so the caller drops just those.
84
+ */
85
+ export function resolveConcreteMetadataValue(value, spec) {
86
+ if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
87
+ return String(value);
88
+ }
89
+ if (isCelExpression(value)) {
90
+ const body = value.expression.trim().replace(/^\$\{\s*|\s*\}$/g, '');
91
+ // A concrete re-execution collapses a schema-derived value into a CEL whose BODY is
92
+ // the resolved LITERAL — that literal must be returned VERBATIM, NEVER fed to the
93
+ // CEL evaluator, which mis-parses many literals (e.g. `data-platform` → `data -
94
+ // platform` → NaN, `Team_A`/free text → identifier/parse errors). Only a body that
95
+ // STILL references the schema (`spec.*` / `schema.spec.*`) or uses a schema CEL
96
+ // helper (`has()` / `.orValue()`) genuinely needs evaluation against the spec.
97
+ const referencesSchema = /(?<![\w$])(?:schema\.)?spec\.[A-Za-z_$]/.test(body) ||
98
+ /\bhas\(/.test(body) ||
99
+ /\.orValue\(/.test(body);
100
+ if (referencesSchema) {
101
+ try {
102
+ const evaluated = evaluateSchemaCelExpression(value, spec);
103
+ if (typeof evaluated === 'string')
104
+ return evaluated;
105
+ if (typeof evaluated === 'number' ||
106
+ typeof evaluated === 'boolean' ||
107
+ typeof evaluated === 'bigint') {
108
+ return String(evaluated);
109
+ }
110
+ }
111
+ catch {
112
+ // Unevaluable despite looking schema-shaped — fall through to the verbatim body.
113
+ }
114
+ }
115
+ return body.length > 0 ? body : undefined;
116
+ }
117
+ return resolveNamespaceName(value, spec);
118
+ }
60
119
  function concreteResources(input) {
61
120
  if (!input.compositionFn)
62
121
  return resourceEntries(input.resources);
@@ -99,7 +158,7 @@ function concreteBoolean(value, spec) {
99
158
  const resolved = resolveSpecPath(spec, schemaPath);
100
159
  return typeof resolved === 'boolean' ? resolved : undefined;
101
160
  }
102
- function isActiveOwnedResource(resource, spec) {
161
+ export function isActiveOwnedResource(resource, spec) {
103
162
  if (Reflect.get(resource, '__externalRef') === true)
104
163
  return false;
105
164
  const metadataConditions = getIncludeWhen(resource);
@@ -108,14 +167,19 @@ function isActiveOwnedResource(resource, spec) {
108
167
  return !conditions?.some((condition) => concreteBoolean(condition, spec) === false);
109
168
  }
110
169
  /**
111
- * Reject a KRO instance that would own the Namespace containing its own CR.
170
+ * Per-resource detection: for each actively-owned Namespace, its resource id
171
+ * mapped to its resolved concrete name. `unresolved` holds the ids of owned
172
+ * Namespaces whose name cannot be evaluated from the spec.
112
173
  *
113
- * KRO deletes graph children before clearing the owner CR's finalizer. If a
114
- * child Namespace contains that CR, namespace termination can strand the
115
- * finalizer permanently. Re-executing with the concrete instance spec makes
116
- * this check survive nested compositions and schema-driven namespace names.
174
+ * The resource ids are stable across the re-execution used here (dedup + explicit
175
+ * `id`s), so a factory can match them back to its own `resources` to HOIST the
176
+ * owned namespace out of the RGD graph. Re-execution is also what resolves the
177
+ * schema-driven names to concrete values (the built `resources` carry `${...}`
178
+ * KRO templates that can't be evaluated directly).
117
179
  */
118
- export function assertKroInstanceNamespaceOwnershipSafe(input) {
180
+ export function detectOwnedNamespaceResources(input) {
181
+ const ownedById = new Map();
182
+ const unresolved = [];
119
183
  for (const [resourceId, resource] of concreteResources(input)) {
120
184
  if (resource.kind !== 'Namespace')
121
185
  continue;
@@ -123,24 +187,442 @@ export function assertKroInstanceNamespaceOwnershipSafe(input) {
123
187
  continue;
124
188
  const ownedNamespace = resolveNamespaceName(resource.metadata?.name, input.spec);
125
189
  if (ownedNamespace === undefined) {
126
- throw new TypeKroError(`Cannot prove KRO instance namespace '${input.instanceNamespace}' is safe because active owned Namespace '${resourceId}' in composition '${input.compositionName}' has a name that cannot be evaluated from the concrete spec. ` +
127
- 'Use a concrete or schema-only CEL Namespace name, or move the KRO instance to a control-plane namespace whose safety can be established.', 'UNRESOLVED_KRO_NAMESPACE_OWNERSHIP', {
128
- composition: input.compositionName,
129
- instanceNamespace: input.instanceNamespace,
130
- resourceId,
131
- mode: 'kro',
132
- });
190
+ unresolved.push(resourceId);
133
191
  }
134
- if (ownedNamespace === input.instanceNamespace) {
135
- throw new TypeKroError(`KRO instance namespace '${input.instanceNamespace}' cannot also be an owned Namespace in composition '${input.compositionName}'. ` +
136
- 'Place the KRO instance in a separate control-plane namespace so deleting it cannot terminate the namespace containing its own finalizer.', 'UNSAFE_KRO_NAMESPACE_OWNERSHIP', {
137
- composition: input.compositionName,
138
- instanceNamespace: input.instanceNamespace,
139
- ownedNamespace,
140
- resourceId,
141
- mode: 'kro',
192
+ else {
193
+ ownedById.set(resourceId, ownedNamespace);
194
+ }
195
+ }
196
+ return { ownedById, unresolved };
197
+ }
198
+ export function detectOwnedNamespaces(input) {
199
+ const { ownedById, unresolved } = detectOwnedNamespaceResources(input);
200
+ return { owned: new Set(ownedById.values()), unresolved };
201
+ }
202
+ /**
203
+ * The CONCRETE (re-executed against the spec) resource objects for each
204
+ * actively-owned Namespace, keyed by resource id. Unlike
205
+ * {@link detectOwnedNamespaceResources} (which returns only the resolved names),
206
+ * this returns the full concrete metadata — labels (incl. Pod Security),
207
+ * annotations, name — so the KRO factory can PRESERVE the original Namespace
208
+ * configuration when it hoists the Namespace out of the graph and re-emits it as
209
+ * a sibling resource (finding #5), rather than synthesizing a bare Namespace.
210
+ */
211
+ export function concreteOwnedNamespaceResources(input) {
212
+ const byId = new Map();
213
+ for (const [resourceId, resource] of concreteResources(input)) {
214
+ if (resource.kind !== 'Namespace')
215
+ continue;
216
+ if (!isActiveOwnedResource(resource, input.spec))
217
+ continue;
218
+ byId.set(resourceId, resource);
219
+ }
220
+ return byId;
221
+ }
222
+ /**
223
+ * Select EVERY Namespace to HOIST out of the RGD graph — the new, UNCONDITIONAL
224
+ * model: typekro NEVER emits a Namespace into RGD YAML. Selection is trivially
225
+ * `kind === 'Namespace'` (excluding `__externalRef` observed namespaces, which are
226
+ * not owned graph children), NOT the old structural "name tracks spec.namespace"
227
+ * detection. Every owned Namespace becomes a sibling resource applied before the
228
+ * RGD and torn down after it, so KRO never owns a namespace.
229
+ *
230
+ * Returns a map from each hoisted Namespace's resource id to its RAW
231
+ * `metadata.name` VALUE (a schema `KubernetesRef`, a `CelExpression`, or a plain
232
+ * string). The name value is what {@link rewriteHoistedNamespaceReferences} /
233
+ * {@link rewriteHoistedNamespaceRefsInValue} rewrite dangling references TO — a
234
+ * reference to a hoisted Namespace's `metadata.name` becomes that Namespace's own
235
+ * concrete name expression. The map is a STABLE STRUCTURAL property of the graph
236
+ * (spec-independent), so the shared RGD's shape is identical for every instance.
237
+ *
238
+ * Deliberately does NOT filter on `includeWhen`: a namespace's ACTIVITY is
239
+ * spec-dependent, but whether a resource is a Namespace is not. A namespace that is
240
+ * inactive for a given spec is simply not created as a sibling; removing it from the
241
+ * RGD is harmless (it was not going to be created there either).
242
+ */
243
+ export function selectHoistedNamespaces(resources) {
244
+ const byId = new Map();
245
+ for (const [resourceId, resource] of resourceEntries(resources)) {
246
+ if (resource.kind !== 'Namespace')
247
+ continue;
248
+ if (Reflect.get(resource, '__externalRef') === true)
249
+ continue;
250
+ byId.set(resourceId, resource.metadata?.name);
251
+ }
252
+ return byId;
253
+ }
254
+ /** A branded CEL expression object built from a bare expression body. */
255
+ function makeCelExpression(expression) {
256
+ return { [CEL_EXPRESSION_BRAND]: true, expression };
257
+ }
258
+ function hoistedNamespaceNameForms(nameValue) {
259
+ if (isKubernetesRef(nameValue)) {
260
+ // Only a schema-driven name is representable as an RGD-portable expression.
261
+ if (nameValue.resourceId !== '__schema__')
262
+ return undefined;
263
+ const fieldPath = nameValue.fieldPath === 'namespace' ? 'spec.namespace' : nameValue.fieldPath;
264
+ const celBody = `schema.${fieldPath}`;
265
+ return {
266
+ celBody,
267
+ marker: `__KUBERNETES_REF___schema___${fieldPath}__`,
268
+ ref: makeCelExpression(celBody),
269
+ };
270
+ }
271
+ if (isCelExpression(nameValue)) {
272
+ const celBody = nameValue.expression.trim().replace(/^\$\{\s*|\s*\}$/g, '');
273
+ // If the CEL body is itself a bare schema field, it has a clean marker form too.
274
+ const schemaField = /^schema\.(spec\.[A-Za-z_$][\w$.]*)$/.exec(celBody)?.[1];
275
+ return {
276
+ celBody,
277
+ marker: schemaField ? `__KUBERNETES_REF___schema___${schemaField}__` : undefined,
278
+ ref: nameValue,
279
+ };
280
+ }
281
+ if (typeof nameValue === 'string') {
282
+ // A serialized schema marker (whole string) → schema field.
283
+ const markerMatch = /^__KUBERNETES_REF___schema___(spec\.[A-Za-z0-9_.$]+?)__$/.exec(nameValue.trim());
284
+ if (markerMatch?.[1]) {
285
+ const fieldPath = markerMatch[1];
286
+ return {
287
+ celBody: `schema.${fieldPath}`,
288
+ marker: nameValue.trim(),
289
+ ref: makeCelExpression(`schema.${fieldPath}`),
290
+ };
291
+ }
292
+ // A template string carrying embedded markers is a concatenation with no simple
293
+ // single-token substitution — fail closed.
294
+ if (/__KUBERNETES_REF_/.test(nameValue))
295
+ return undefined;
296
+ // A plain string literal (a concrete DNS namespace name).
297
+ return { celBody: JSON.stringify(nameValue), marker: nameValue, ref: nameValue };
298
+ }
299
+ return undefined;
300
+ }
301
+ function escapeRegExp(value) {
302
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
303
+ }
304
+ /**
305
+ * Rewrite every reference to a HOISTED Namespace's `metadata.name` — ANYWHERE it
306
+ * appears in a value — to that Namespace's CONCRETE name expression (findings
307
+ * #3 + #6).
308
+ *
309
+ * `hoisted` maps each hoisted Namespace's resource id to its RAW `metadata.name`
310
+ * value (see {@link selectHoistedNamespaces}). When a Namespace is hoisted OUT of
311
+ * the RGD graph, any other value that still refers to it would leave a live
312
+ * reference to a resource KRO no longer knows about, and KRO rejects the whole
313
+ * graph. Each reference is rewritten to the referenced Namespace's own name
314
+ * expression — for a Namespace named `${schema.spec.namespace}` that is
315
+ * `schema.spec.namespace` (as before); for a literally-named Namespace `"foo"`
316
+ * that is the constant `foo` — which is exactly the value the removed resource
317
+ * would have produced.
318
+ *
319
+ * The rewrite is STRUCTURAL, not exact-string (finding #6): it replaces the
320
+ * reference TOKEN `<id>.metadata.name` wherever it occurs, so embedded /
321
+ * concatenated (`ns-${string(id.metadata.name)}`), function-wrapped
322
+ * (`string(id.metadata.name)`), and ternary (`... ? id.metadata.name : "x"`)
323
+ * forms are all handled — in plain strings, CEL expressions, and raw
324
+ * `__KUBERNETES_REF_*` markers alike. It applies to arbitrary values (resource
325
+ * bodies AND status mappings). A reference whose target Namespace name has no
326
+ * representable form is left as-is and caught by
327
+ * {@link findDanglingHoistedReference}.
328
+ */
329
+ export function rewriteHoistedNamespaceRefsInValue(value, hoisted) {
330
+ if (hoisted.size === 0)
331
+ return value;
332
+ // Per-id substitution forms; ids whose name is not representable are skipped
333
+ // (the reference is left dangling for the post-serialization assertion).
334
+ const forms = new Map();
335
+ for (const [id, nameValue] of hoisted) {
336
+ const f = hoistedNamespaceNameForms(nameValue);
337
+ if (f)
338
+ forms.set(id, f);
339
+ }
340
+ if (forms.size === 0)
341
+ return value;
342
+ // TOKEN-level (not whole-`${...}`) patterns for a reference to
343
+ // `<id>.metadata.name`, so wrappers/concatenation/ternaries are handled. A
344
+ // negative lookbehind avoids matching an id that is only a SUFFIX of a longer
345
+ // identifier (e.g. `myOwnedNamespace` when the hoisted id is `ownedNamespace`).
346
+ const celTokenReplacers = [...forms].map(([id, f]) => ({
347
+ pattern: new RegExp(`(?<![A-Za-z0-9_$])${escapeRegExp(id)}\\.metadata\\.name\\b`, 'g'),
348
+ replacement: f.celBody,
349
+ }));
350
+ const markerTokenReplacers = [...forms]
351
+ .filter(([, f]) => f.marker !== undefined)
352
+ .map(([id, f]) => ({
353
+ pattern: new RegExp(`__KUBERNETES_REF_${escapeRegExp(id)}_metadata\\.name__`, 'g'),
354
+ // biome-ignore lint/style/noNonNullAssertion: filtered on marker !== undefined
355
+ replacement: f.marker,
356
+ }));
357
+ const rewriteString = (input) => {
358
+ let out = input;
359
+ // Use a function replacer so `$` in a replacement is never treated as a
360
+ // special replacement pattern.
361
+ for (const { pattern, replacement } of celTokenReplacers)
362
+ out = out.replace(pattern, () => replacement);
363
+ for (const { pattern, replacement } of markerTokenReplacers)
364
+ out = out.replace(pattern, () => replacement);
365
+ return out;
366
+ };
367
+ const rewriteValue = (val) => {
368
+ if (isKubernetesRef(val)) {
369
+ // Rewrite ONLY an exact `metadata.name` reference to a hoisted Namespace
370
+ // (finding #7); requiring EXACT field equality lets any unsupported reference
371
+ // fall through to the dangling-reference validation instead.
372
+ const f = forms.get(val.resourceId);
373
+ return f && val.fieldPath === 'metadata.name' ? f.ref : val;
374
+ }
375
+ if (isCelExpression(val)) {
376
+ const rewritten = rewriteString(val.expression);
377
+ return rewritten === val.expression ? val : makeCelExpression(rewritten);
378
+ }
379
+ if (typeof val === 'string') {
380
+ return rewriteString(val);
381
+ }
382
+ if (Array.isArray(val)) {
383
+ let changed = false;
384
+ const next = val.map((item) => {
385
+ const rewritten = rewriteValue(item);
386
+ if (rewritten !== item)
387
+ changed = true;
388
+ return rewritten;
142
389
  });
390
+ return changed ? next : val;
391
+ }
392
+ if (val !== null && typeof val === 'object') {
393
+ let changed = false;
394
+ const next = {};
395
+ for (const [key, item] of Object.entries(val)) {
396
+ const rewritten = rewriteValue(item);
397
+ if (rewritten !== item)
398
+ changed = true;
399
+ next[key] = rewritten;
400
+ }
401
+ return changed ? next : val;
402
+ }
403
+ return val;
404
+ };
405
+ return rewriteValue(value);
406
+ }
407
+ /**
408
+ * The top-level STATUS field names whose value, once the owned Namespace is HOISTED
409
+ * out of the RGD, can no longer be represented in the KRO status schema (finding #6).
410
+ *
411
+ * When a Namespace is hoisted OUT of the RGD, a status field that referenced its
412
+ * `metadata.name` is rewritten to the Namespace's own name expression. KRO requires
413
+ * every instance status field to reference at least one RESOURCE (KRO builder.go:
414
+ * `instance status field must refer to a resource`), and its status CEL environment
415
+ * has no `schema` identifier. So a rewritten value that references NO managed resource
416
+ * is unrepresentable in the KRO status — in BOTH shapes:
417
+ * - schema-only (`schema.spec.namespace`, for a schema-named Namespace) — KRO
418
+ * status CEL cannot evaluate `schema`; and
419
+ * - a plain CONSTANT (for a literally-named Namespace) — a literal has zero resource
420
+ * dependencies, so KRO rejects it, AND typekro's own schema generation classifies
421
+ * a literal-only status as static and DROPS it from the emitted KRO status.
422
+ * BOTH were previously handled inconsistently (schema-only rejected, literal silently
423
+ * dropped). We now REJECT both consistently (see {@link assertNoHoistWeakenedStatusFields})
424
+ * — the one behavior. A field that ALSO references a real managed resource stays
425
+ * representable (KRO accepts it; a literal inside it is fine) and is NOT flagged.
426
+ *
427
+ * Returns only TOP-LEVEL status keys (the KRO status schema is a flat map of field →
428
+ * CEL); a field is included iff rewriting its value CHANGED it (it referenced the
429
+ * hoisted Namespace) AND the rewritten value references no managed resource (i.e. it
430
+ * references `schema`, or is a pure constant).
431
+ */
432
+ export function hoistWeakenedStatusFields(statusMappings, hoisted) {
433
+ if (!statusMappings || hoisted.size === 0)
434
+ return [];
435
+ const weakened = [];
436
+ for (const [key, value] of Object.entries(statusMappings)) {
437
+ if (key.startsWith('__'))
438
+ continue; // internal composition metadata, not a status field
439
+ const rewritten = rewriteHoistedNamespaceRefsInValue(value, hoisted);
440
+ if (rewritten === value)
441
+ continue; // did not reference a hoisted Namespace
442
+ // Unrepresentable in KRO status when the rewritten value references `schema`
443
+ // (KRO can't eval it) OR references NO managed resource (a pure constant — KRO
444
+ // requires a resource dependency, and typekro would drop it as static).
445
+ if (rewrittenReferencesSchema(rewritten) || !rewrittenReferencesManagedResource(rewritten)) {
446
+ weakened.push(key);
447
+ }
448
+ }
449
+ return weakened;
450
+ }
451
+ /**
452
+ * Whether a rewritten status value still references the `schema` identifier — a
453
+ * schema-only expression KRO status CEL cannot evaluate.
454
+ */
455
+ function rewrittenReferencesSchema(value) {
456
+ const hasSchema = (s) => /(?<![A-Za-z0-9_$])schema\./.test(s) || /__KUBERNETES_REF___schema__/.test(s);
457
+ if (typeof value === 'string')
458
+ return hasSchema(value);
459
+ if (isCelExpression(value))
460
+ return hasSchema(value.expression);
461
+ if (isKubernetesRef(value))
462
+ return value.resourceId === '__schema__';
463
+ if (Array.isArray(value))
464
+ return value.some(rewrittenReferencesSchema);
465
+ if (value !== null && typeof value === 'object') {
466
+ return Object.values(value).some(rewrittenReferencesSchema);
467
+ }
468
+ return false;
469
+ }
470
+ /**
471
+ * Whether a rewritten status value references at least one MANAGED RESOURCE — a
472
+ * non-`schema` KubernetesRef, or a `<id>.status|spec|metadata` / `__KUBERNETES_REF_<id>_`
473
+ * token whose id is not `schema`. KRO requires every status field to reference a
474
+ * resource; a value that references none (a pure constant, or schema-only) is
475
+ * unrepresentable. Used together with {@link rewrittenReferencesSchema} so the
476
+ * literal-only case (finding #6) is rejected consistently with the schema-only case.
477
+ */
478
+ function rewrittenReferencesManagedResource(value) {
479
+ const hasResourceToken = (s) => {
480
+ const dotRef = /(?<![A-Za-z0-9_$])([A-Za-z_$][\w$]*)\.(?:status|spec|metadata)\b/g;
481
+ for (const match of s.matchAll(dotRef)) {
482
+ if (match[1] !== 'schema')
483
+ return true;
484
+ }
485
+ const markerRef = /__KUBERNETES_REF_([A-Za-z0-9_$]+?)_/g;
486
+ for (const match of s.matchAll(markerRef)) {
487
+ if (match[1] !== '__schema__' && match[1] !== 'schema')
488
+ return true;
489
+ }
490
+ return false;
491
+ };
492
+ if (typeof value === 'string')
493
+ return hasResourceToken(value);
494
+ if (isCelExpression(value))
495
+ return hasResourceToken(value.expression);
496
+ if (isKubernetesRef(value))
497
+ return value.resourceId !== '__schema__';
498
+ if (Array.isArray(value))
499
+ return value.some(rewrittenReferencesManagedResource);
500
+ if (value !== null && typeof value === 'object') {
501
+ return Object.values(value).some(rewrittenReferencesManagedResource);
502
+ }
503
+ return false;
504
+ }
505
+ /**
506
+ * HONEST, CONSISTENT behavior for finding #6: REJECT (throw) a composition whose
507
+ * status field(s) resolve ONLY to a hoisted owned Namespace's `metadata.name` — i.e.
508
+ * once the Namespace leaves the RGD the field references no managed resource.
509
+ *
510
+ * KRO requires every instance status field to reference a resource and cannot
511
+ * evaluate `schema` in status CEL, so such a field is unrepresentable in the emitted
512
+ * KRO status whether the Namespace is schema-named (rewrites to `schema.spec.namespace`)
513
+ * or literally-named (rewrites to a constant). Previously the schema case threw while
514
+ * the literal case was silently dropped (schema generation classifies literal-only
515
+ * status as static and excludes it) — the two code paths disagreed. Both are now
516
+ * REJECTED the same way: FAIL LOUDLY at serialization, naming the field(s), so the
517
+ * author restructures the status (derive the value from a managed resource, or drop
518
+ * the field) instead of shipping a silently-weakened status API.
519
+ */
520
+ export function assertNoHoistWeakenedStatusFields(statusMappings, hoisted, compositionName) {
521
+ const weakened = hoistWeakenedStatusFields(statusMappings, hoisted);
522
+ if (weakened.length === 0)
523
+ return;
524
+ throw new TypeKroError(`Composition "${compositionName}" cannot be serialized for KRO: status field(s) ` +
525
+ `[${weakened.join(', ')}] resolve ONLY to a hoisted owned Namespace's metadata.name. ` +
526
+ `Once that Namespace is hoisted out of the RGD the reference no longer targets any managed ` +
527
+ `resource (it becomes a schema-only expression \`schema.spec.namespace\` for a schema-named ` +
528
+ `Namespace, or a bare constant for a literally-named one). KRO requires every status field ` +
529
+ `to reference a resource and cannot evaluate \`schema\` in status CEL, so the field cannot be ` +
530
+ `represented in the KRO status schema either way. Remove the field or derive its value from a ` +
531
+ `managed resource instead of the owned Namespace's name. See docs/advanced/migration.md.`, 'HOIST_WEAKENED_STATUS_FIELD', { compositionName, fields: weakened });
532
+ }
533
+ /**
534
+ * Resource-map form of {@link rewriteHoistedNamespaceRefsInValue}: rewrite every
535
+ * dangling reference to a hoisted Namespace across a resource collection.
536
+ *
537
+ * Only resources that actually contain such a reference are reconstructed; every
538
+ * other resource is passed through by identity, so the common case (no reference
539
+ * to the hoisted Namespace) is untouched. When a resource IS reconstructed, its
540
+ * TypeKro metadata (WeakMap-stored `includeWhen` / `readinessEvaluator` /
541
+ * `__resourceId` / readiness+iteration markers) is copied onto the new object via
542
+ * {@link copyResourceMetadata} so the rewrite never silently drops it (finding #7).
543
+ */
544
+ export function rewriteHoistedNamespaceReferences(resources, hoisted) {
545
+ if (hoisted.size === 0)
546
+ return resources;
547
+ const result = {};
548
+ for (const [id, resource] of Object.entries(resources)) {
549
+ const rewritten = rewriteHoistedNamespaceRefsInValue(resource, hoisted);
550
+ if (rewritten !== resource) {
551
+ // Reconstructed a NEW resource object — carry its non-enumerable / WeakMap
552
+ // TypeKro metadata across so readiness/iteration/includeWhen survive.
553
+ copyResourceMetadata(resource, rewritten);
143
554
  }
555
+ result[id] = rewritten;
556
+ }
557
+ return result;
558
+ }
559
+ /**
560
+ * Scan an emitted RGD YAML for any leftover reference to a hoisted (removed)
561
+ * resource id — either a CEL interpolation `${<id>.…}` or a raw
562
+ * `__KUBERNETES_REF_<id>_…` marker. Returns the FIRST offending id, or
563
+ * `undefined` when the RGD is clean.
564
+ *
565
+ * This is the shared post-serialization dangling-reference check applied to BOTH
566
+ * the factory serialization path ({@link KroResourceFactoryImpl.buildRgdYaml})
567
+ * and the graph/composition serialization path (`core.ts`). After hoisting an
568
+ * owned Namespace out of the RGD, NO reference to it may remain anywhere in the
569
+ * emitted RGD (resource templates, status CEL, nested CEL, overrides); otherwise
570
+ * KRO rejects the graph at runtime with a dangling `${...}` reference. A negative
571
+ * lookbehind avoids matching an id that is only a suffix of a longer identifier.
572
+ */
573
+ export function findDanglingHoistedReference(rgdYaml, hoistedIds) {
574
+ for (const id of hoistedIds) {
575
+ const escaped = escapeRegExp(id);
576
+ const celRef = new RegExp(`\\$\\{[^}]*?(?<![A-Za-z0-9_$])${escaped}\\.`);
577
+ const markerRef = new RegExp(`__KUBERNETES_REF_${escaped}_`);
578
+ if (celRef.test(rgdYaml) || markerRef.test(rgdYaml))
579
+ return id;
580
+ }
581
+ return undefined;
582
+ }
583
+ /**
584
+ * Reject a KRO instance that would own the Namespace containing its own CR.
585
+ *
586
+ * KRO deletes graph children before clearing the owner CR's finalizer. If a
587
+ * child Namespace contains that CR, namespace termination can strand the
588
+ * finalizer permanently. Re-executing with the concrete instance spec makes
589
+ * this check survive nested compositions and schema-driven namespace names.
590
+ *
591
+ * The KRO factory now HOISTS every owned Namespace OUT of the RGD graph (emitting
592
+ * it as a SIBLING resource created deps-first and torn down after the RGD) before
593
+ * calling this guard, and passes the hoisted names in `hoistedNamespaces`. Because
594
+ * a hoisted namespace is no longer a graph child, deleting the instance can't GC
595
+ * it, so the common create-namespace-and-put-the-instance-in-it pattern is safe —
596
+ * this guard skips it. The guard remains the defense-in-depth net for HAND-AUTHORED
597
+ * graphs that hoisting does not cover: an owned Namespace whose name can't be proven
598
+ * safe (fails closed), and a caller who places `instanceNamespace` on a namespace
599
+ * the composition owns WITHOUT hoisting it (opts into the unsafe pattern).
600
+ */
601
+ export function assertKroInstanceNamespaceOwnershipSafe(input) {
602
+ const { owned, unresolved } = detectOwnedNamespaces(input);
603
+ const unresolvedId = unresolved[0];
604
+ if (unresolvedId !== undefined) {
605
+ throw new TypeKroError(`Cannot prove KRO instance namespace '${input.instanceNamespace}' is safe because active owned Namespace '${unresolvedId}' in composition '${input.compositionName}' has a name that cannot be evaluated from the concrete spec. ` +
606
+ 'Use a concrete or schema-only CEL Namespace name, or move the KRO instance to a control-plane namespace whose safety can be established.', 'UNRESOLVED_KRO_NAMESPACE_OWNERSHIP', {
607
+ composition: input.compositionName,
608
+ instanceNamespace: input.instanceNamespace,
609
+ resourceId: unresolvedId,
610
+ mode: 'kro',
611
+ });
612
+ }
613
+ // An owned namespace the factory has HOISTED out of the graph is safe: it is no
614
+ // longer a graph child, so deleting the instance can never garbage-collect it.
615
+ if (owned.has(input.instanceNamespace) && input.hoistedNamespaces?.has(input.instanceNamespace)) {
616
+ return;
617
+ }
618
+ if (owned.has(input.instanceNamespace)) {
619
+ throw new TypeKroError(`KRO instance namespace '${input.instanceNamespace}' cannot also be an owned Namespace in composition '${input.compositionName}'. ` +
620
+ 'Place the KRO instance in a separate control-plane namespace so deleting it cannot terminate the namespace containing its own finalizer.', 'UNSAFE_KRO_NAMESPACE_OWNERSHIP', {
621
+ composition: input.compositionName,
622
+ instanceNamespace: input.instanceNamespace,
623
+ ownedNamespace: input.instanceNamespace,
624
+ mode: 'kro',
625
+ });
144
626
  }
145
627
  }
146
628
  /** Validate the fixed registry namespace used by a shared singleton owner. */
@@ -1 +1 @@
1
- {"version":3,"file":"kro-instance-safety.js","sourceRoot":"","sources":["../../../src/core/deployment/kro-instance-safety.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAkBxE,SAAS,eAAe,CACtB,SAAyC;IAEzC,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAC;IAC1B,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAC7B,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,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