@xplane/core 1.0.1 → 1.1.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.
- package/dist/index.d.mts +60 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +203 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -31,6 +31,12 @@ interface CompositionInput {
|
|
|
31
31
|
interface CompositionResult {
|
|
32
32
|
/** Resources to emit to Crossplane as desired composed resources. */
|
|
33
33
|
resources: DesiredResource[];
|
|
34
|
+
/**
|
|
35
|
+
* Names of resources that are blocked (pending resolution). The handler
|
|
36
|
+
* uses these to preserve any previously-observed documents in desired state
|
|
37
|
+
* (preventing accidental deletion) and to prevent premature XR readiness.
|
|
38
|
+
*/
|
|
39
|
+
blockedResources: string[];
|
|
34
40
|
/** External resources that need to be fetched via requireResource. */
|
|
35
41
|
externalResources: ExternalResourceRequest[];
|
|
36
42
|
/** Desired XR status patches (from this.xr.status assignments). */
|
|
@@ -126,6 +132,37 @@ interface ReadProxyMeta {
|
|
|
126
132
|
readonly owner: ResourceRef;
|
|
127
133
|
readonly path: string;
|
|
128
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* A Pending-like marker for strings produced by template literals that
|
|
137
|
+
* interpolate one or more unresolved ReadProxy values.
|
|
138
|
+
*
|
|
139
|
+
* Holds the template structure so the resolve phase can reconstruct the
|
|
140
|
+
* final string once all dependency slots are available.
|
|
141
|
+
*
|
|
142
|
+
* Invariant: parts.length === slots.length + 1
|
|
143
|
+
* result = parts[0] + resolved[0] + parts[1] + … + resolved[n-1] + parts[n]
|
|
144
|
+
*/
|
|
145
|
+
declare const PENDING_TEMPLATE_TAG: unique symbol;
|
|
146
|
+
declare class PendingTemplate {
|
|
147
|
+
/** Literal text segments between (and around) pending slots. */
|
|
148
|
+
readonly parts: readonly string[];
|
|
149
|
+
/** The pending slots — each maps to an entry in a resource's observed state. */
|
|
150
|
+
readonly slots: ReadonlyArray<{
|
|
151
|
+
source: ResourceRef;
|
|
152
|
+
path: string;
|
|
153
|
+
}>;
|
|
154
|
+
static readonly TAG: symbol;
|
|
155
|
+
readonly [PENDING_TEMPLATE_TAG] = true;
|
|
156
|
+
constructor(/** Literal text segments between (and around) pending slots. */
|
|
157
|
+
|
|
158
|
+
parts: readonly string[], /** The pending slots — each maps to an entry in a resource's observed state. */
|
|
159
|
+
|
|
160
|
+
slots: ReadonlyArray<{
|
|
161
|
+
source: ResourceRef;
|
|
162
|
+
path: string;
|
|
163
|
+
}>);
|
|
164
|
+
static is(value: unknown): value is PendingTemplate;
|
|
165
|
+
}
|
|
129
166
|
//#endregion
|
|
130
167
|
//#region src/tracking/dependency-graph.d.ts
|
|
131
168
|
/**
|
|
@@ -181,6 +218,19 @@ declare function createReadProxy<T extends object>(target: T, owner: ResourceRef
|
|
|
181
218
|
*/
|
|
182
219
|
declare function createPrimitiveReadProxy(value: string | number | boolean, owner: ResourceRef, path: string): object;
|
|
183
220
|
//#endregion
|
|
221
|
+
//#region src/tracking/token-registry.d.ts
|
|
222
|
+
interface TokenRegistry {
|
|
223
|
+
readonly byToken: Map<string, ReadProxyMeta>;
|
|
224
|
+
readonly byKey: Map<string, string>;
|
|
225
|
+
counter: number;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Per-run AsyncLocalStorage for the template-literal token registry.
|
|
229
|
+
* Kept separate from compositionStorage (core/) to avoid circular deps.
|
|
230
|
+
*/
|
|
231
|
+
declare const tokenRegistryStorage: AsyncLocalStorage<TokenRegistry>;
|
|
232
|
+
declare function createTokenRegistry(): TokenRegistry;
|
|
233
|
+
//#endregion
|
|
184
234
|
//#region src/tracking/write-proxy.d.ts
|
|
185
235
|
/**
|
|
186
236
|
* Collector that accumulates dependency edges discovered during
|
|
@@ -434,6 +484,15 @@ declare class Resource extends Construct$1 {
|
|
|
434
484
|
allowedPattern?: RegExp;
|
|
435
485
|
extra?: string;
|
|
436
486
|
}): string;
|
|
487
|
+
/**
|
|
488
|
+
* Like {@link uniqueName} but produces names compliant with RFC 1123 DNS labels:
|
|
489
|
+
* lowercase alphanumeric characters and hyphens only, starting and ending with
|
|
490
|
+
* an alphanumeric character. Suitable for use as Kubernetes resource names.
|
|
491
|
+
*/
|
|
492
|
+
static uniqueNameRfc1123(scope: Construct$1, options?: {
|
|
493
|
+
maxLength?: number;
|
|
494
|
+
extra?: string;
|
|
495
|
+
}): string;
|
|
437
496
|
}
|
|
438
497
|
declare function getResourceInternals(resource: Resource): ResourceInternals;
|
|
439
498
|
declare function getResourceRef(resource: Resource): ResourceRef;
|
|
@@ -604,5 +663,5 @@ declare function runPipeline(input: PipelineInput): PipelineState;
|
|
|
604
663
|
*/
|
|
605
664
|
declare function runComposition<TSpec, TStatus, TContext extends object>(CompositionClass: new () => Composition<TSpec, TStatus, TContext>, input: CompositionInput): CompositionResult;
|
|
606
665
|
//#endregion
|
|
607
|
-
export { Composition, type CompositionContext, type CompositionInput, type CompositionModule, type CompositionResult, Construct, DEFAULT_CHECKS, type DependencyEdge, DependencyGraph, type DesiredResource, type Diagnostic, type DiagnosticReport, EdgeCollector, type EmittedResource, type ExternalResourceRef, type ExternalResourceRequest, type KubernetesResource, Pending, type PipelineContextAccessor, type PipelineInput, type PipelineState, type ReadProxyMeta, type ReadyCheck, type ReadyCheckFn, Resource, type ResourceClassification, type ResourceConfig, type ResourceProps, type ResourceRef, type XplaneLogger, type XrProxy, compositionStorage, createPrimitiveReadProxy, createReadProxy, createWriteProxy, diagnose, emit, evaluateReadiness, getCompositionContext, getDesiredDocument, getExternalRef, getLogger, getObservedDocument, getReadProxyMeta, getReadyChecks, getResourceInternals, getResourceRef, getXrDesiredStatus, hydrate, hydrateObserved, isExternal, isReadProxy, resolve, runComposition, runPipeline, sequence, withLogger };
|
|
666
|
+
export { Composition, type CompositionContext, type CompositionInput, type CompositionModule, type CompositionResult, Construct, DEFAULT_CHECKS, type DependencyEdge, DependencyGraph, type DesiredResource, type Diagnostic, type DiagnosticReport, EdgeCollector, type EmittedResource, type ExternalResourceRef, type ExternalResourceRequest, type KubernetesResource, Pending, PendingTemplate, type PipelineContextAccessor, type PipelineInput, type PipelineState, type ReadProxyMeta, type ReadyCheck, type ReadyCheckFn, Resource, type ResourceClassification, type ResourceConfig, type ResourceProps, type ResourceRef, type XplaneLogger, type XrProxy, compositionStorage, createPrimitiveReadProxy, createReadProxy, createTokenRegistry, createWriteProxy, diagnose, emit, evaluateReadiness, getCompositionContext, getDesiredDocument, getExternalRef, getLogger, getObservedDocument, getReadProxyMeta, getReadyChecks, getResourceInternals, getResourceRef, getXrDesiredStatus, hydrate, hydrateObserved, isExternal, isReadProxy, resolve, runComposition, runPipeline, sequence, tokenRegistryStorage, withLogger };
|
|
608
667
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/contract.ts","../src/tracking/types.ts","../src/tracking/dependency-graph.ts","../src/tracking/read-proxy.ts","../src/tracking/write-proxy.ts","../src/core/composition.ts","../src/core/context.ts","../src/readiness/types.ts","../src/readiness/defaults.ts","../src/readiness/evaluate.ts","../src/core/resource.ts","../src/logging/types.ts","../src/logging/context.ts","../src/pipeline/types.ts","../src/pipeline/diagnose.ts","../src/pipeline/emit.ts","../src/pipeline/hydrate.ts","../src/pipeline/resolve.ts","../src/pipeline/sequence.ts","../src/pipeline/index.ts","../src/run.ts"],"mappings":";;;;;;;;AAeA;;;;;;;;UAAiB,gBAAA;EAQS;EANxB,EAAA,EAAI,MAAA;EAAJ;EAEA,eAAA,EAAiB,MAAA;EAAjB;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;EAAjC;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;AAAA;;;;;UASlB,iBAAA;EAAA;EAEf,SAAA,EAAW,eAAA
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/contract.ts","../src/tracking/types.ts","../src/tracking/dependency-graph.ts","../src/tracking/read-proxy.ts","../src/tracking/token-registry.ts","../src/tracking/write-proxy.ts","../src/core/composition.ts","../src/core/context.ts","../src/readiness/types.ts","../src/readiness/defaults.ts","../src/readiness/evaluate.ts","../src/core/resource.ts","../src/logging/types.ts","../src/logging/context.ts","../src/pipeline/types.ts","../src/pipeline/diagnose.ts","../src/pipeline/emit.ts","../src/pipeline/hydrate.ts","../src/pipeline/resolve.ts","../src/pipeline/sequence.ts","../src/pipeline/index.ts","../src/run.ts"],"mappings":";;;;;;;;AAeA;;;;;;;;UAAiB,gBAAA;EAQS;EANxB,EAAA,EAAI,MAAA;EAAJ;EAEA,eAAA,EAAiB,MAAA;EAAjB;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;EAAjC;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;AAAA;;;;;UASlB,iBAAA;EAAA;EAEf,SAAA,EAAW,eAAA;;;;;;EAMX,gBAAA;EAMuB;EAJvB,iBAAA,EAAmB,uBAAA;EARR;EAUX,QAAA,EAAU,MAAA;EAFV;EAIA,WAAA,EAAa,UAAA;AAAA;;UAIE,eAAA;EAJF;EAMb,IAAA;EANuB;EAQvB,QAAA,EAAU,MAAM;EAJc;EAM9B,KAAA;AAAA;;UAIe,uBAAA;EANL;EAQV,MAAA;EACA,UAAA;EACA,IAAA;EAJe;EAMf,IAAA;;EAEA,SAAA;AAAA;;UAIe,UAAA;EANf;EAQA,QAAA;EANS;EAQT,MAAA;EAJe;EAMf,YAAA,GAAe,KAAK;IAClB,IAAA;IACA,SAAA;MAAa,QAAA;MAAkB,IAAA;IAAA;EAAA;EAD/B;EAIF,KAAA;EAHe;EAKf,MAAA;AAAA;;;AAAM;AASR;UAAiB,iBAAA;EACf,GAAA,CAAI,KAAA,EAAO,gBAAA,GAAmB,iBAAiB;AAAA;;;;UC9FhC,WAAA;EAAA,SACN,EAAE;AAAA;ADab;AAAA,UCTiB,cAAA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;;AdlCzB;;;;;;;iBeMgB,QAAA,CAAS,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AfN7D;;;iBgBKgB,IAAA,CAAK,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AhBLzD;;;iBiBLgB,OAAA,CAAQ,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AjBK5D;;;;;iBkBFgB,OAAA,CAAQ,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AlBE5D;;;;;;iBmBDgB,QAAA,CAAS,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;UCW5C,aAAA;EpBFG;EoBIlB,WAAA,EAAa,WAAA;EpBJW;EoBMxB,gBAAA,EAAkB,WAAA,SAAoB,MAAA;EpBZlC;EoBcJ,gBAAA,EAAkB,WAAA,SAAoB,MAAA;AAAA;;;;;;iBAQxB,WAAA,CAAY,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;ApBxBhE;;;;;;;;;;;;iBqBcgB,cAAA,yCAAA,CACd,gBAAA,YAA4B,WAAA,CAAY,KAAA,EAAO,OAAA,EAAS,QAAA,GACxD,KAAA,EAAO,gBAAA,GACN,iBAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -219,6 +219,114 @@ var DependencyGraph = class {
|
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
221
|
//#endregion
|
|
222
|
+
//#region src/tracking/types.ts
|
|
223
|
+
/**
|
|
224
|
+
* A Pending marker stored in a desired document when a ReadProxy value
|
|
225
|
+
* is assigned. Carries full source info so the resolve phase knows
|
|
226
|
+
* where to look for the concrete value.
|
|
227
|
+
*/
|
|
228
|
+
const PENDING_TAG = Symbol.for("xplane.pending");
|
|
229
|
+
var Pending = class {
|
|
230
|
+
source;
|
|
231
|
+
path;
|
|
232
|
+
static TAG = PENDING_TAG;
|
|
233
|
+
[PENDING_TAG] = true;
|
|
234
|
+
constructor(source, path) {
|
|
235
|
+
this.source = source;
|
|
236
|
+
this.path = path;
|
|
237
|
+
}
|
|
238
|
+
static is(value) {
|
|
239
|
+
return typeof value === "object" && value !== null && value[PENDING_TAG] === true;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* A Pending-like marker for strings produced by template literals that
|
|
244
|
+
* interpolate one or more unresolved ReadProxy values.
|
|
245
|
+
*
|
|
246
|
+
* Holds the template structure so the resolve phase can reconstruct the
|
|
247
|
+
* final string once all dependency slots are available.
|
|
248
|
+
*
|
|
249
|
+
* Invariant: parts.length === slots.length + 1
|
|
250
|
+
* result = parts[0] + resolved[0] + parts[1] + … + resolved[n-1] + parts[n]
|
|
251
|
+
*/
|
|
252
|
+
const PENDING_TEMPLATE_TAG = Symbol.for("xplane.pendingTemplate");
|
|
253
|
+
var PendingTemplate = class {
|
|
254
|
+
parts;
|
|
255
|
+
slots;
|
|
256
|
+
static TAG = PENDING_TEMPLATE_TAG;
|
|
257
|
+
[PENDING_TEMPLATE_TAG] = true;
|
|
258
|
+
constructor(parts, slots) {
|
|
259
|
+
this.parts = parts;
|
|
260
|
+
this.slots = slots;
|
|
261
|
+
}
|
|
262
|
+
static is(value) {
|
|
263
|
+
return typeof value === "object" && value !== null && value[PENDING_TEMPLATE_TAG] === true;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/tracking/token-registry.ts
|
|
268
|
+
/**
|
|
269
|
+
* Per-run AsyncLocalStorage for the template-literal token registry.
|
|
270
|
+
* Kept separate from compositionStorage (core/) to avoid circular deps.
|
|
271
|
+
*/
|
|
272
|
+
const tokenRegistryStorage = new AsyncLocalStorage();
|
|
273
|
+
function createTokenRegistry() {
|
|
274
|
+
return {
|
|
275
|
+
byToken: /* @__PURE__ */ new Map(),
|
|
276
|
+
byKey: /* @__PURE__ */ new Map(),
|
|
277
|
+
counter: 0
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Get or create a stable token for a given (owner, path) pair.
|
|
282
|
+
* Returns null when no registry is active (outside of a composition run).
|
|
283
|
+
*/
|
|
284
|
+
function getOrCreateToken(owner, path) {
|
|
285
|
+
const registry = tokenRegistryStorage.getStore();
|
|
286
|
+
if (!registry) return null;
|
|
287
|
+
const key = `${owner.id}\0${path}`;
|
|
288
|
+
const existing = registry.byKey.get(key);
|
|
289
|
+
if (existing !== void 0) return existing;
|
|
290
|
+
const token = `__pending__tpl_${registry.counter++}__`;
|
|
291
|
+
registry.byToken.set(token, {
|
|
292
|
+
owner,
|
|
293
|
+
path
|
|
294
|
+
});
|
|
295
|
+
registry.byKey.set(key, token);
|
|
296
|
+
return token;
|
|
297
|
+
}
|
|
298
|
+
function lookupToken(token) {
|
|
299
|
+
return tokenRegistryStorage.getStore()?.byToken.get(token);
|
|
300
|
+
}
|
|
301
|
+
const TEMPLATE_TOKEN_RE = /__pending__tpl_\d+__/g;
|
|
302
|
+
/**
|
|
303
|
+
* Scan a string for pending template tokens. If any are found, calls
|
|
304
|
+
* `onSlot` for each registered token and returns a PendingTemplate.
|
|
305
|
+
* Returns the original string if no tokens are found or none are registered.
|
|
306
|
+
*/
|
|
307
|
+
function processStringValue(value, onSlot) {
|
|
308
|
+
const parts = [];
|
|
309
|
+
const slots = [];
|
|
310
|
+
let lastIndex = 0;
|
|
311
|
+
let hasSlots = false;
|
|
312
|
+
TEMPLATE_TOKEN_RE.lastIndex = 0;
|
|
313
|
+
for (const match of value.matchAll(TEMPLATE_TOKEN_RE)) {
|
|
314
|
+
const meta = lookupToken(match[0]);
|
|
315
|
+
if (!meta) continue;
|
|
316
|
+
hasSlots = true;
|
|
317
|
+
parts.push(value.slice(lastIndex, match.index));
|
|
318
|
+
slots.push({
|
|
319
|
+
source: meta.owner,
|
|
320
|
+
path: meta.path
|
|
321
|
+
});
|
|
322
|
+
onSlot(meta);
|
|
323
|
+
lastIndex = match.index + match[0].length;
|
|
324
|
+
}
|
|
325
|
+
if (!hasSlots) return value;
|
|
326
|
+
parts.push(value.slice(lastIndex));
|
|
327
|
+
return new PendingTemplate(parts, slots);
|
|
328
|
+
}
|
|
329
|
+
//#endregion
|
|
222
330
|
//#region src/tracking/read-proxy.ts
|
|
223
331
|
/**
|
|
224
332
|
* WeakMap storing metadata for ReadProxy instances.
|
|
@@ -277,13 +385,15 @@ function createReadProxy(target, owner, basePath) {
|
|
|
277
385
|
* coerced to a primitive.
|
|
278
386
|
*/
|
|
279
387
|
function createLeafReadProxy(owner, path) {
|
|
280
|
-
const
|
|
388
|
+
const target = Object.create(null);
|
|
389
|
+
const getToken = () => getOrCreateToken(owner, path) ?? `__pending__${owner.id}__${path}`;
|
|
390
|
+
const proxy = new Proxy(target, {
|
|
281
391
|
get(_obj, prop) {
|
|
282
392
|
if (prop === READ_PROXY_TAG) return true;
|
|
283
|
-
if (prop === Symbol.toPrimitive) return () =>
|
|
393
|
+
if (prop === Symbol.toPrimitive) return () => getToken();
|
|
284
394
|
if (typeof prop === "symbol") return void 0;
|
|
285
395
|
if (prop === "toJSON") return () => void 0;
|
|
286
|
-
if (prop === "toString") return () =>
|
|
396
|
+
if (prop === "toString") return () => getToken();
|
|
287
397
|
if (prop === "valueOf") return () => proxy;
|
|
288
398
|
return createLeafReadProxy(owner, `${path}.${String(prop)}`);
|
|
289
399
|
},
|
|
@@ -326,27 +436,6 @@ function createPrimitiveReadProxy(value, owner, path) {
|
|
|
326
436
|
return proxy;
|
|
327
437
|
}
|
|
328
438
|
//#endregion
|
|
329
|
-
//#region src/tracking/types.ts
|
|
330
|
-
/**
|
|
331
|
-
* A Pending marker stored in a desired document when a ReadProxy value
|
|
332
|
-
* is assigned. Carries full source info so the resolve phase knows
|
|
333
|
-
* where to look for the concrete value.
|
|
334
|
-
*/
|
|
335
|
-
const PENDING_TAG = Symbol.for("xplane.pending");
|
|
336
|
-
var Pending = class {
|
|
337
|
-
source;
|
|
338
|
-
path;
|
|
339
|
-
static TAG = PENDING_TAG;
|
|
340
|
-
[PENDING_TAG] = true;
|
|
341
|
-
constructor(source, path) {
|
|
342
|
-
this.source = source;
|
|
343
|
-
this.path = path;
|
|
344
|
-
}
|
|
345
|
-
static is(value) {
|
|
346
|
-
return typeof value === "object" && value !== null && value[PENDING_TAG] === true;
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
//#endregion
|
|
350
439
|
//#region src/tracking/write-proxy.ts
|
|
351
440
|
/**
|
|
352
441
|
* Collector that accumulates dependency edges discovered during
|
|
@@ -422,6 +511,17 @@ function createWriteProxy(target, opts) {
|
|
|
422
511
|
return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));
|
|
423
512
|
}
|
|
424
513
|
}
|
|
514
|
+
if (typeof value === "string") {
|
|
515
|
+
const processed = processStringValue(value, (meta) => {
|
|
516
|
+
collector.add({
|
|
517
|
+
from: meta.owner,
|
|
518
|
+
fromPath: meta.path,
|
|
519
|
+
to: owner,
|
|
520
|
+
toPath: targetPath
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
return Reflect.set(obj, prop, processed);
|
|
524
|
+
}
|
|
425
525
|
if (typeof value === "object" && value !== null && !Pending.is(value)) {
|
|
426
526
|
const processed = deepProcessValue(value, owner, targetPath, collector);
|
|
427
527
|
return Reflect.set(obj, prop, processed);
|
|
@@ -453,6 +553,14 @@ function tryExtractPrimitive$2(proxy) {
|
|
|
453
553
|
*/
|
|
454
554
|
function deepProcessValue(value, owner, basePath, collector) {
|
|
455
555
|
if (value === null || value === void 0) return value;
|
|
556
|
+
if (typeof value === "string") return processStringValue(value, (meta) => {
|
|
557
|
+
collector.add({
|
|
558
|
+
from: meta.owner,
|
|
559
|
+
fromPath: meta.path,
|
|
560
|
+
to: owner,
|
|
561
|
+
toPath: basePath
|
|
562
|
+
});
|
|
563
|
+
});
|
|
456
564
|
if (typeof value !== "object") return value;
|
|
457
565
|
if (isReadProxy(value)) {
|
|
458
566
|
const meta = getReadProxyMeta(value);
|
|
@@ -581,6 +689,33 @@ var Resource = class Resource extends Construct$1 {
|
|
|
581
689
|
if (withHash.length <= maxLength) return withHash;
|
|
582
690
|
return `${full.slice(0, maxLength - hash.length - separator.length)}${separator}${hash}`;
|
|
583
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* Like {@link uniqueName} but produces names compliant with RFC 1123 DNS labels:
|
|
694
|
+
* lowercase alphanumeric characters and hyphens only, starting and ending with
|
|
695
|
+
* an alphanumeric character. Suitable for use as Kubernetes resource names.
|
|
696
|
+
*/
|
|
697
|
+
static uniqueNameRfc1123(scope, options = {}) {
|
|
698
|
+
const maxLength = options.maxLength ?? 63;
|
|
699
|
+
const clean = (s) => s.toLowerCase().replace(/\s+/g, "").replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
700
|
+
const xrMeta = scope.node.tryGetContext("xplane:xr-meta");
|
|
701
|
+
const parts = [];
|
|
702
|
+
if (xrMeta?.namespace) parts.push(clean(xrMeta.namespace));
|
|
703
|
+
if (xrMeta?.name) parts.push(clean(xrMeta.name));
|
|
704
|
+
for (const s of scope.node.scopes.slice(1)) {
|
|
705
|
+
const c = clean(s.node.id);
|
|
706
|
+
if (c) parts.push(c);
|
|
707
|
+
}
|
|
708
|
+
if (options.extra) {
|
|
709
|
+
const c = clean(options.extra);
|
|
710
|
+
if (c) parts.push(c);
|
|
711
|
+
}
|
|
712
|
+
const full = parts.join("-");
|
|
713
|
+
const hash = shortHash(full);
|
|
714
|
+
const withHash = `${full}-${hash}`;
|
|
715
|
+
if (withHash.length <= maxLength) return withHash;
|
|
716
|
+
const trimmedPrefix = full.slice(0, maxLength - hash.length - 1).replace(/-+$/, "");
|
|
717
|
+
return trimmedPrefix ? `${trimmedPrefix}-${hash}` : hash;
|
|
718
|
+
}
|
|
584
719
|
};
|
|
585
720
|
function getResourceInternals(resource) {
|
|
586
721
|
const internal = internals.get(resource);
|
|
@@ -642,6 +777,14 @@ function processDesiredProps(props, owner, collector) {
|
|
|
642
777
|
}
|
|
643
778
|
function processValue(value, owner, path, collector) {
|
|
644
779
|
if (value === null || value === void 0) return value;
|
|
780
|
+
if (typeof value === "string") return processStringValue(value, (meta) => {
|
|
781
|
+
collector.add({
|
|
782
|
+
from: meta.owner,
|
|
783
|
+
fromPath: meta.path,
|
|
784
|
+
to: owner,
|
|
785
|
+
toPath: path
|
|
786
|
+
});
|
|
787
|
+
});
|
|
645
788
|
if (typeof value !== "object") return value;
|
|
646
789
|
if (isReadProxy(value)) {
|
|
647
790
|
const meta = getReadProxyMeta(value);
|
|
@@ -911,6 +1054,7 @@ function deepClean(obj) {
|
|
|
911
1054
|
function cleanValue(value) {
|
|
912
1055
|
if (value === null || value === void 0) return value;
|
|
913
1056
|
if (typeof value !== "object") return value;
|
|
1057
|
+
if (PendingTemplate.is(value)) throw new Error(`PendingTemplate reached emit phase — resource should have been classified as blocked. Parts: ${JSON.stringify(value.parts)}`);
|
|
914
1058
|
if (Array.isArray(value)) return value.map(cleanValue);
|
|
915
1059
|
const result = {};
|
|
916
1060
|
for (const [key, val] of Object.entries(value)) result[key] = cleanValue(val);
|
|
@@ -1017,6 +1161,9 @@ function resolvePending(obj, resourceById) {
|
|
|
1017
1161
|
const resolved = getNestedValue(getObservedDocument(sourceResource), value.path);
|
|
1018
1162
|
if (resolved !== void 0) obj[key] = resolved;
|
|
1019
1163
|
}
|
|
1164
|
+
} else if (PendingTemplate.is(value)) {
|
|
1165
|
+
const resolved = resolvePendingTemplate(value, resourceById);
|
|
1166
|
+
if (resolved !== void 0) obj[key] = resolved;
|
|
1020
1167
|
} else if (Array.isArray(value)) resolveArray(value, resourceById);
|
|
1021
1168
|
else if (value !== null && typeof value === "object") resolvePending(value, resourceById);
|
|
1022
1169
|
}
|
|
@@ -1029,6 +1176,9 @@ function resolveArray(arr, resourceById) {
|
|
|
1029
1176
|
const resolved = getNestedValue(getObservedDocument(sourceResource), value.path);
|
|
1030
1177
|
if (resolved !== void 0) arr[i] = resolved;
|
|
1031
1178
|
}
|
|
1179
|
+
} else if (PendingTemplate.is(value)) {
|
|
1180
|
+
const resolved = resolvePendingTemplate(value, resourceById);
|
|
1181
|
+
if (resolved !== void 0) arr[i] = resolved;
|
|
1032
1182
|
} else if (Array.isArray(value)) resolveArray(value, resourceById);
|
|
1033
1183
|
else if (value !== null && typeof value === "object") resolvePending(value, resourceById);
|
|
1034
1184
|
}
|
|
@@ -1046,6 +1196,23 @@ function getNestedValue(obj, path) {
|
|
|
1046
1196
|
}
|
|
1047
1197
|
return current;
|
|
1048
1198
|
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Attempt to resolve all slots of a PendingTemplate.
|
|
1201
|
+
* Returns the reconstructed string if all slots resolve, undefined otherwise.
|
|
1202
|
+
*/
|
|
1203
|
+
function resolvePendingTemplate(template, resourceById) {
|
|
1204
|
+
const values = [];
|
|
1205
|
+
for (const slot of template.slots) {
|
|
1206
|
+
const sourceResource = resourceById.get(slot.source.id);
|
|
1207
|
+
if (!sourceResource) return void 0;
|
|
1208
|
+
const resolved = getNestedValue(getObservedDocument(sourceResource), slot.path);
|
|
1209
|
+
if (resolved === void 0 || resolved === null) return void 0;
|
|
1210
|
+
values.push(String(resolved));
|
|
1211
|
+
}
|
|
1212
|
+
let result = template.parts[0];
|
|
1213
|
+
for (let i = 0; i < values.length; i++) result += values[i] + template.parts[i + 1];
|
|
1214
|
+
return result;
|
|
1215
|
+
}
|
|
1049
1216
|
//#endregion
|
|
1050
1217
|
//#region src/pipeline/sequence.ts
|
|
1051
1218
|
/**
|
|
@@ -1083,6 +1250,7 @@ function sequence(state) {
|
|
|
1083
1250
|
function containsPending(obj) {
|
|
1084
1251
|
if (obj === null || obj === void 0) return false;
|
|
1085
1252
|
if (Pending.is(obj)) return true;
|
|
1253
|
+
if (PendingTemplate.is(obj)) return true;
|
|
1086
1254
|
if (typeof obj !== "object") return false;
|
|
1087
1255
|
if (Array.isArray(obj)) return obj.some(containsPending);
|
|
1088
1256
|
for (const value of Object.values(obj)) if (containsPending(value)) return true;
|
|
@@ -1271,7 +1439,7 @@ function runComposition(CompositionClass, input) {
|
|
|
1271
1439
|
collector
|
|
1272
1440
|
};
|
|
1273
1441
|
const state = runPipeline({
|
|
1274
|
-
composition: compositionStorage.run(ctx, () => new CompositionClass()),
|
|
1442
|
+
composition: compositionStorage.run(ctx, () => tokenRegistryStorage.run(createTokenRegistry(), () => new CompositionClass())),
|
|
1275
1443
|
observedComposed,
|
|
1276
1444
|
observedRequired
|
|
1277
1445
|
});
|
|
@@ -1299,14 +1467,23 @@ function runComposition(CompositionClass, input) {
|
|
|
1299
1467
|
...ref.namespace ? { namespace: ref.namespace } : {}
|
|
1300
1468
|
});
|
|
1301
1469
|
}
|
|
1470
|
+
const blockedResources = [];
|
|
1471
|
+
for (const resource of state.resources) {
|
|
1472
|
+
if (isExternal(resource)) continue;
|
|
1473
|
+
const ref = getResourceRef(resource);
|
|
1474
|
+
if (state.classification.get(ref.id) !== "blocked") continue;
|
|
1475
|
+
const name = ref.id.startsWith("Composition/") ? ref.id.slice(12) : ref.id;
|
|
1476
|
+
blockedResources.push(name);
|
|
1477
|
+
}
|
|
1302
1478
|
return {
|
|
1303
1479
|
resources,
|
|
1480
|
+
blockedResources,
|
|
1304
1481
|
externalResources,
|
|
1305
1482
|
xrStatus: state.xrStatusPatches,
|
|
1306
1483
|
diagnostics: state.diagnostics
|
|
1307
1484
|
};
|
|
1308
1485
|
}
|
|
1309
1486
|
//#endregion
|
|
1310
|
-
export { Composition, Construct, DEFAULT_CHECKS, DependencyGraph, EdgeCollector, Pending, Resource, compositionStorage, createPrimitiveReadProxy, createReadProxy, createWriteProxy, diagnose, emit, evaluateReadiness, getCompositionContext, getDesiredDocument, getExternalRef, getLogger, getObservedDocument, getReadProxyMeta, getReadyChecks, getResourceInternals, getResourceRef, getXrDesiredStatus, hydrate, hydrateObserved, isExternal, isReadProxy, resolve, runComposition, runPipeline, sequence, withLogger };
|
|
1487
|
+
export { Composition, Construct, DEFAULT_CHECKS, DependencyGraph, EdgeCollector, Pending, PendingTemplate, Resource, compositionStorage, createPrimitiveReadProxy, createReadProxy, createTokenRegistry, createWriteProxy, diagnose, emit, evaluateReadiness, getCompositionContext, getDesiredDocument, getExternalRef, getLogger, getObservedDocument, getReadProxyMeta, getReadyChecks, getResourceInternals, getResourceRef, getXrDesiredStatus, hydrate, hydrateObserved, isExternal, isReadProxy, resolve, runComposition, runPipeline, sequence, tokenRegistryStorage, withLogger };
|
|
1311
1488
|
|
|
1312
1489
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["Construct","tryExtractPrimitive","Construct","tryExtractPrimitive","getNestedValue"],"sources":["../src/core/context.ts","../src/core/composition.ts","../src/tracking/dependency-graph.ts","../src/tracking/read-proxy.ts","../src/tracking/types.ts","../src/tracking/write-proxy.ts","../src/core/resource.ts","../src/logging/context.ts","../src/pipeline/diagnose.ts","../src/pipeline/emit.ts","../src/pipeline/hydrate.ts","../src/pipeline/resolve.ts","../src/pipeline/sequence.ts","../src/pipeline/index.ts","../src/readiness/defaults.ts","../src/readiness/evaluate.ts","../src/run.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { DependencyGraph, EdgeCollector } from '../tracking/index.js';\n\n/**\n * Runtime context passed into a Composition during construction\n * via AsyncLocalStorage. Holds everything the Composition needs\n * without relying on static state or globalThis.\n */\nexport interface CompositionContext {\n /** Observed XR data. */\n xr: Record<string, unknown>;\n /** Full Crossplane function pipeline context (all keys). */\n pipelineContext: ReadonlyMap<string, unknown>;\n /** Pre-populated data for existing resources (from prior iterations). */\n requiredResources: ReadonlyMap<string, Record<string, unknown>>;\n /** The dependency graph for this composition run. */\n graph: DependencyGraph;\n /** The edge collector for this composition run. */\n collector: EdgeCollector;\n}\n\n/**\n * AsyncLocalStorage instance that carries the CompositionContext.\n * The handler sets it before constructing the user's Composition,\n * and the Composition constructor reads from it.\n */\nexport const compositionStorage = new AsyncLocalStorage<CompositionContext>();\n\n/**\n * Get the current composition context from AsyncLocalStorage.\n * Throws if called outside of a composition construction scope.\n */\nexport function getCompositionContext(): CompositionContext {\n const ctx = compositionStorage.getStore();\n if (ctx) return ctx;\n\n throw new Error(\n 'No composition context found. Ensure the Composition is constructed within compositionStorage.run().',\n );\n}\n","import { Construct } from 'constructs';\n\nimport type { DependencyGraph, EdgeCollector } from '../tracking/index.js';\nimport { getCompositionContext } from './context.js';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Base generics for a Composition.\n * - TSpec: shape of the XR's spec\n * - TStatus: shape of the XR's status (writable)\n * - TContext: shape of the pipeline context map keys→values\n */\nexport type CompositionProps<\n TSpec = Record<string, unknown>,\n TStatus = Record<string, unknown>,\n TContext extends object = Record<string, unknown>,\n> = {\n spec?: TSpec;\n status?: TStatus;\n context?: TContext;\n};\n\n/** The shape of the XR proxy exposed via `this.xr`. */\nexport interface XrProxy<TSpec = Record<string, unknown>, TStatus = Record<string, unknown>> {\n spec: TSpec;\n status: TStatus;\n metadata: {\n name: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n// ─── Composition class ────────────────────────────────────────────────────────\n\n/**\n * Base class for user-authored Crossplane compositions.\n *\n * Users extend this class and define resources in the constructor:\n *\n * ```ts\n * class MyComposition extends Composition<MySpec, MyStatus> {\n * constructor() {\n * super();\n * const vpc = new Vpc(this, 'vpc', { spec: { ... } });\n * this.xr.status.vpcId = vpc.status.atProvider.vpcId;\n * }\n * }\n * ```\n *\n * `this.xr` is a \"desired-first, fallback-to-observed\" proxy over the XR.\n * `this.pipelineContext` provides typed read-only access to Crossplane function context.\n */\nexport class Composition<\n TSpec = Record<string, unknown>,\n TStatus = Record<string, unknown>,\n TContext extends object = Record<string, unknown>,\n> extends Construct {\n /**\n * The XR proxy — reads from desired first (status writes), falls through to observed.\n * Writing to `this.xr.status.*` sets the composite status output.\n */\n readonly xr: XrProxy<TSpec, TStatus>;\n\n /** The dependency graph tracking resource relationships. */\n readonly graph: DependencyGraph;\n\n /** The edge collector accumulating dependency edges. */\n readonly collector: EdgeCollector;\n\n constructor() {\n // Use 'Composition' as the root construct ID\n super(undefined as unknown as Construct, 'Composition');\n\n const ctx = getCompositionContext();\n\n this.graph = ctx.graph;\n this.collector = ctx.collector;\n\n // Set context values on the construct tree so Resources can find them\n this.node.setContext('xplane:graph', ctx.graph);\n this.node.setContext('xplane:collector', ctx.collector);\n\n // Set XR metadata on tree for Resource.uniqueName()\n const xrMeta = ctx.xr.metadata as { name?: string; namespace?: string } | undefined;\n if (xrMeta) {\n this.node.setContext('xplane:xr-meta', xrMeta);\n }\n\n // Build the XR proxy\n this.xr = createXrProxy<TSpec, TStatus>(ctx);\n }\n\n /**\n * Read-only accessor for Crossplane function pipeline context.\n * Keys are the context keys set by Crossplane or prior functions in the pipeline.\n */\n get pipelineContext(): PipelineContextAccessor<TContext> {\n const ctx = getCompositionContext();\n return {\n get<K extends keyof TContext>(key: K): TContext[K] | undefined {\n return ctx.pipelineContext.get(key as string) as TContext[K] | undefined;\n },\n has(key: keyof TContext): boolean {\n return ctx.pipelineContext.has(key as string);\n },\n keys(): IterableIterator<keyof TContext> {\n return ctx.pipelineContext.keys() as IterableIterator<keyof TContext>;\n },\n };\n }\n}\n\n/** Typed read-only interface for pipeline context. */\nexport interface PipelineContextAccessor<TContext extends object = Record<string, unknown>> {\n get<K extends keyof TContext>(key: K): TContext[K] | undefined;\n has(key: keyof TContext): boolean;\n keys(): IterableIterator<keyof TContext>;\n}\n\n// ─── XR Proxy ─────────────────────────────────────────────────────────────────\n\n/**\n * Creates the \"desired-first, fallback-to-observed\" proxy for the XR.\n *\n * - Reading `xr.spec.*` reads from observed XR spec (creates ReadProxy for tracking)\n * - Writing `xr.status.*` writes to a desired-status store (emitted as composite status)\n * - Other reads fall through to observed\n */\nfunction createXrProxy<TSpec, TStatus>(ctx: {\n xr: Record<string, unknown>;\n graph: DependencyGraph;\n collector: EdgeCollector;\n}): XrProxy<TSpec, TStatus> {\n const xrObserved = ctx.xr;\n const xrDesiredStatus: Record<string, unknown> = {};\n\n // The XR ref for dependency tracking\n const xrRef = { id: '__xr__' };\n ctx.graph.addResource(xrRef);\n\n const statusProxy = new Proxy(xrDesiredStatus, {\n get(_target, prop) {\n if (typeof prop === 'symbol') return undefined;\n const key = String(prop);\n // Desired-first\n if (key in xrDesiredStatus) return xrDesiredStatus[key];\n // Fallback to observed status\n const observedStatus = xrObserved.status as Record<string, unknown> | undefined;\n if (observedStatus && key in observedStatus) {\n return observedStatus[key];\n }\n return undefined;\n },\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n xrDesiredStatus[String(prop)] = value;\n return true;\n },\n has(_target, prop) {\n if (typeof prop === 'symbol') return false;\n const key = String(prop);\n if (key in xrDesiredStatus) return true;\n const observedStatus = xrObserved.status as Record<string, unknown> | undefined;\n return observedStatus ? key in observedStatus : false;\n },\n });\n\n const proxy = new Proxy({} as XrProxy<TSpec, TStatus>, {\n get(_target, prop) {\n if (typeof prop === 'symbol') return undefined;\n const key = String(prop);\n if (key === 'status') return statusProxy;\n // Everything else reads from observed XR\n if (key in xrObserved) return xrObserved[key];\n return undefined;\n },\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n const key = String(prop);\n if (key === 'status') {\n // Allow replacing entire status\n Object.assign(xrDesiredStatus, value as object);\n return true;\n }\n // Writes to other top-level XR fields are unusual but allowed\n (xrObserved as Record<string, unknown>)[key] = value;\n return true;\n },\n has(_target, prop) {\n if (typeof prop === 'symbol') return false;\n return String(prop) in xrObserved || String(prop) === 'status';\n },\n });\n\n return proxy;\n}\n\n/**\n * Extract the desired XR status from a Composition instance.\n * Used by the emit pipeline phase to produce composite status output.\n */\nexport function getXrDesiredStatus(composition: Composition): Record<string, unknown> {\n // Access the internal status proxy target\n const statusProxy = composition.xr.status;\n // Collect all keys from the status proxy.\n // We intentionally return raw values (including ReadProxy references) so\n // that the emit phase can resolve them from observed resource data.\n const result: Record<string, unknown> = {};\n if (statusProxy && typeof statusProxy === 'object') {\n for (const key of Object.keys(statusProxy)) {\n const value = (statusProxy as Record<string, unknown>)[key];\n if (value != null) {\n result[key] = value;\n }\n }\n }\n return result;\n}\n","import type { DependencyEdge, ResourceRef } from './types.js';\n\n/**\n * Tracks dependency relationships between resources as a directed acyclic graph.\n * Edges are added as resources reference each other's observed state.\n */\nexport class DependencyGraph {\n private readonly _adjacency = new Map<string, Set<string>>();\n private readonly _resources = new Map<string, ResourceRef>();\n private readonly _edges: DependencyEdge[] = [];\n\n addResource(ref: ResourceRef): void {\n this._resources.set(ref.id, ref);\n if (!this._adjacency.has(ref.id)) {\n this._adjacency.set(ref.id, new Set());\n }\n }\n\n addEdge(edge: DependencyEdge): void {\n this.addResource(edge.from);\n this.addResource(edge.to);\n this._adjacency.get(edge.to.id)!.add(edge.from.id);\n this._edges.push(edge);\n }\n\n addEdges(edges: ReadonlyArray<DependencyEdge>): void {\n for (const edge of edges) this.addEdge(edge);\n }\n\n addExplicitDependency(dependent: ResourceRef, dependency: ResourceRef): void {\n this.addResource(dependent);\n this.addResource(dependency);\n this._adjacency.get(dependent.id)!.add(dependency.id);\n }\n\n /** Get the set of resource IDs that `resourceId` depends on. */\n getDependencies(resourceId: string): ReadonlySet<string> {\n return this._adjacency.get(resourceId) ?? new Set();\n }\n\n get resourceIds(): ReadonlyArray<string> {\n return [...this._resources.keys()];\n }\n\n get edges(): ReadonlyArray<DependencyEdge> {\n return this._edges;\n }\n\n /**\n * Returns a topological ordering of resources.\n * If a cycle is detected, returns { order: null, cycle: string[] }.\n */\n topologicalSort(): { order: string[] } | { order: null; cycle: string[] } {\n const visited = new Set<string>();\n const visiting = new Set<string>();\n const sorted: string[] = [];\n\n const visit = (id: string): string[] | null => {\n if (visited.has(id)) return null;\n if (visiting.has(id)) {\n // Build cycle path\n return [...visiting, id];\n }\n visiting.add(id);\n const deps = this._adjacency.get(id);\n if (deps) {\n for (const depId of deps) {\n const cycle = visit(depId);\n if (cycle) return cycle;\n }\n }\n visiting.delete(id);\n visited.add(id);\n sorted.push(id);\n return null;\n };\n\n for (const id of this._resources.keys()) {\n const cycle = visit(id);\n if (cycle) {\n // Trim cycle to start from the repeated node\n const start = cycle[cycle.length - 1]!;\n const startIdx = cycle.indexOf(start);\n return { order: null, cycle: cycle.slice(startIdx) };\n }\n }\n return { order: sorted };\n }\n}\n","import type { ReadProxyMeta, ResourceRef } from './types.js';\n\n/**\n * WeakMap storing metadata for ReadProxy instances.\n * This avoids polluting proxy objects with symbols.\n */\nconst proxyMeta = new WeakMap<object, ReadProxyMeta>();\n\n/** Sentinel symbol to identify ReadProxy instances. */\nconst READ_PROXY_TAG = Symbol.for('xplane.readProxy');\n\n/**\n * Check if a value is a ReadProxy.\n */\nexport function isReadProxy(value: unknown): value is object {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[READ_PROXY_TAG] === true\n );\n}\n\n/**\n * Get the metadata for a ReadProxy value.\n */\nexport function getReadProxyMeta(value: unknown): ReadProxyMeta | undefined {\n if (!isReadProxy(value)) return undefined;\n return proxyMeta.get(value as object);\n}\n\n/**\n * Creates a ReadProxy that wraps observed data.\n *\n * - Property access navigates into the data, building up the path.\n * - Missing paths return `undefined` (no placeholder proxies).\n * - The proxy carries owner + path metadata so that when it's assigned\n * to a WriteProxy, the dependency edge can be recorded.\n */\nexport function createReadProxy<T extends object>(\n target: T,\n owner: ResourceRef,\n basePath: string,\n): T {\n const proxy = new Proxy(target, {\n get(obj, prop, receiver) {\n // Identity checks\n if (prop === READ_PROXY_TAG) return true;\n if (typeof prop === 'symbol') return Reflect.get(obj, prop, receiver);\n if (prop === 'toJSON') return () => obj;\n\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const value = Reflect.get(obj, prop, receiver);\n\n if (value === undefined || value === null) {\n // Return a \"leaf\" proxy with undefined target — carries metadata\n // for dependency edge creation but resolves to undefined\n return createLeafReadProxy(owner, childPath);\n }\n\n if (typeof value === 'object') {\n // Wrap nested objects so path accumulates\n return createReadProxy(value as object, owner, childPath);\n }\n\n // Primitive — wrap in a tagged object so it can carry metadata\n // when assigned to a WriteProxy\n return createPrimitiveReadProxy(value as string | number | boolean, owner, childPath);\n },\n\n has(obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return Reflect.has(obj, prop);\n },\n });\n\n proxyMeta.set(proxy, { owner, path: basePath });\n return proxy as T;\n}\n\n/**\n * A \"leaf\" ReadProxy for paths that don't exist in observed data yet.\n * Carries metadata for edge creation. Resolves to `undefined` when\n * coerced to a primitive.\n */\nfunction createLeafReadProxy(owner: ResourceRef, path: string): object {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n const proxy = new Proxy(target, {\n get(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n if (prop === Symbol.toPrimitive) return () => `__pending__${owner.id}__${path}`;\n if (typeof prop === 'symbol') return undefined;\n if (prop === 'toJSON') return () => undefined;\n if (prop === 'toString') return () => `__pending__${owner.id}__${path}`;\n if (prop === 'valueOf') return () => proxy;\n // Nested access on a leaf — still a leaf with extended path\n return createLeafReadProxy(owner, `${path}.${String(prop)}`);\n },\n has(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return false;\n },\n });\n proxyMeta.set(proxy, { owner, path });\n return proxy;\n}\n\n/**\n * Wraps a concrete primitive value so it carries ReadProxy metadata.\n * This allows the WriteProxy to detect it during assignment and\n * record the dependency edge, while the value itself resolves correctly.\n */\nexport function createPrimitiveReadProxy(\n value: string | number | boolean,\n owner: ResourceRef,\n path: string,\n): object {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n const proxy = new Proxy(target, {\n get(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n if (prop === Symbol.toPrimitive) return () => value;\n if (prop === 'valueOf') return () => value;\n if (prop === 'toString') return () => String(value);\n if (prop === 'toJSON') return () => value;\n if (typeof prop === 'symbol') return undefined;\n // Navigating into a primitive — leaf\n return createLeafReadProxy(owner, `${path}.${String(prop)}`);\n },\n has(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return false;\n },\n });\n proxyMeta.set(proxy, { owner, path });\n return proxy;\n}\n","/** Identifies a resource in the dependency graph. */\nexport interface ResourceRef {\n readonly id: string;\n}\n\n/** A dependency edge between two resources at specific field paths. */\nexport interface DependencyEdge {\n /** Resource being read from (observed state). */\n readonly from: ResourceRef;\n /** Path in the source resource's observed data. */\n readonly fromPath: string;\n /** Resource being written to (desired state). */\n readonly to: ResourceRef;\n /** Path in the target resource's desired data. */\n readonly toPath: string;\n}\n\n/**\n * A Pending marker stored in a desired document when a ReadProxy value\n * is assigned. Carries full source info so the resolve phase knows\n * where to look for the concrete value.\n */\nconst PENDING_TAG: unique symbol = Symbol.for('xplane.pending') as unknown as typeof PENDING_TAG;\n\nexport class Pending {\n static readonly TAG = PENDING_TAG;\n readonly [PENDING_TAG] = true;\n\n constructor(\n /** The resource that owns the observed data. */\n readonly source: ResourceRef,\n /** The path within that resource's observed data. */\n readonly path: string,\n ) {}\n\n static is(value: unknown): value is Pending {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_TAG] === true\n );\n }\n}\n\n/** Metadata associated with a ReadProxy instance. */\nexport interface ReadProxyMeta {\n readonly owner: ResourceRef;\n readonly path: string;\n}\n","import {\n createPrimitiveReadProxy,\n createReadProxy,\n getReadProxyMeta,\n isReadProxy,\n} from './read-proxy.js';\nimport { type DependencyEdge, Pending, type ResourceRef } from './types.js';\n\n/**\n * Collector that accumulates dependency edges discovered during\n * WriteProxy assignments.\n */\nexport class EdgeCollector {\n private readonly _edges: DependencyEdge[] = [];\n\n add(edge: DependencyEdge): void {\n // Deduplicate\n const exists = this._edges.some(\n (e) =>\n e.from.id === edge.from.id &&\n e.fromPath === edge.fromPath &&\n e.to.id === edge.to.id &&\n e.toPath === edge.toPath,\n );\n if (!exists) this._edges.push(edge);\n }\n\n get edges(): ReadonlyArray<DependencyEdge> {\n return this._edges;\n }\n}\n\nexport interface WriteProxyOptions {\n /** The resource that owns this desired document. */\n owner: ResourceRef;\n /** The collector to record edges into. */\n collector: EdgeCollector;\n /** Base path prefix (e.g., \"spec\" when wrapping the spec subtree). */\n basePath?: string;\n /** Optional observed state at the same path for fallback reads. */\n observed?: Record<string, unknown>;\n}\n\n/**\n * Creates a WriteProxy that wraps a desired document.\n *\n * - Writes store values in the target.\n * - When a ReadProxy value is assigned, it records a dependency edge\n * and stores a Pending marker if the value is not yet concrete.\n * - Reads return the stored value (desired-first).\n */\nexport function createWriteProxy<T extends object>(target: T, opts: WriteProxyOptions): T {\n const { owner, collector, basePath = '', observed } = opts;\n\n return new Proxy(target, {\n get(obj, prop, receiver) {\n if (typeof prop === 'symbol') return Reflect.get(obj, prop, receiver);\n if (prop === 'toJSON') return () => obj;\n\n const value = Reflect.get(obj, prop, receiver);\n\n // If the value is a nested object (not a Pending), wrap it recursively\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const childObserved =\n observed && String(prop) in observed && typeof observed[String(prop)] === 'object'\n ? (observed[String(prop)] as Record<string, unknown>)\n : undefined;\n return createWriteProxy(value as object, {\n owner,\n collector,\n basePath: childPath,\n observed: childObserved,\n });\n }\n\n // If value is undefined and observed has data at this path, fall through to ReadProxy\n if (value === undefined && observed && String(prop) in observed) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const obsValue = observed[String(prop)];\n if (typeof obsValue === 'object' && obsValue !== null) {\n return createReadProxy(obsValue as object, owner, childPath);\n }\n if (obsValue !== undefined && obsValue !== null) {\n return createPrimitiveReadProxy(obsValue as string | number | boolean, owner, childPath);\n }\n }\n\n // If value is undefined and observed doesn't have it either, return a leaf ReadProxy\n // so that cross-resource references create proper dependency edges and Pending markers\n if (value === undefined && observed !== undefined) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n return createReadProxy(Object.create(null) as object, owner, childPath);\n }\n\n return value;\n },\n\n set(obj, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(obj, prop, value);\n\n const targetPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n\n // Check if the value being assigned is a ReadProxy\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value);\n if (meta && meta.owner.id !== owner.id) {\n // Record dependency edge\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: targetPath,\n });\n\n // Try to extract a concrete value via Symbol.toPrimitive\n const primitive = tryExtractPrimitive(value);\n if (primitive !== undefined) {\n // The value is already concrete (primitive from observed data)\n return Reflect.set(obj, prop, primitive);\n }\n\n // Not concrete — store a Pending marker\n return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));\n }\n\n // Self-reference or XR — try to extract value\n const primitive = tryExtractPrimitive(value);\n if (primitive !== undefined) {\n return Reflect.set(obj, prop, primitive);\n }\n\n // XR leaf with no value — store Pending\n if (meta) {\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: targetPath,\n });\n return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));\n }\n }\n\n // Plain object — deep-process to catch nested ReadProxy values\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n const processed = deepProcessValue(value, owner, targetPath, collector);\n return Reflect.set(obj, prop, processed);\n }\n\n return Reflect.set(obj, prop, value);\n },\n\n deleteProperty(obj, prop) {\n return Reflect.deleteProperty(obj, prop);\n },\n }) as T;\n}\n\n/**\n * Try to extract a primitive value from a ReadProxy via Symbol.toPrimitive.\n * Returns `undefined` if the proxy represents a non-existent (leaf) value.\n */\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\n/**\n * Deep-process a plain object/array being assigned to a WriteProxy.\n * Replaces any nested ReadProxy values with Pending markers or concrete values.\n */\nfunction deepProcessValue(\n value: unknown,\n owner: ResourceRef,\n basePath: string,\n collector: EdgeCollector,\n): unknown {\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value)!;\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: basePath,\n });\n const primitive = tryExtractPrimitive(value as object);\n if (primitive !== undefined) return primitive;\n return new Pending(meta.owner, meta.path);\n }\n\n if (Array.isArray(value as object)) {\n return (value as unknown[]).map((item, i) =>\n deepProcessValue(item, owner, `${basePath}[${i}]`, collector),\n );\n }\n\n // Plain object — recurse\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = deepProcessValue(val, owner, `${basePath}.${key}`, collector);\n }\n return result;\n}\n","import { Construct } from 'constructs';\n\nimport type { ReadyCheck, ReadyCheckFn } from '../readiness/index.js';\nimport {\n createPrimitiveReadProxy,\n createReadProxy,\n createWriteProxy,\n type DependencyGraph,\n type EdgeCollector,\n getReadProxyMeta,\n isReadProxy,\n Pending,\n type ResourceRef,\n} from '../tracking/index.js';\nimport { compositionStorage } from './context.js';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/** Minimal shape for a Kubernetes resource — only apiVersion + kind required. */\nexport interface KubernetesResource {\n apiVersion: string;\n kind: string;\n metadata?: {\n name?: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n/** Props passed to the Resource constructor — becomes the desired document. */\nexport interface ResourceProps {\n apiVersion: string;\n kind: string;\n [key: string]: unknown;\n}\n\n/** Framework configuration accessible via `resource.resource`. */\nexport interface ResourceConfig {\n autoReady: boolean;\n addReadyCheck(fn: ReadyCheckFn, priority?: number): void;\n}\n\n/** Internal metadata stored per Resource (not exposed on the proxy). */\ninterface ResourceInternals {\n /** Unique reference for the dependency graph. */\n ref: ResourceRef;\n /** The desired document (what the user wrote). */\n desired: Record<string, unknown>;\n /** The observed document (populated by the hydrate phase). */\n observed: Record<string, unknown>;\n /** Whether this is an external (existing) resource. */\n external: boolean;\n /** For external resources: the lookup key. */\n externalRef?: ExternalResourceRef;\n /** Framework config. */\n config: ResourceConfig;\n /** Custom readiness checks registered by the composition author. */\n readyChecks: ReadyCheck[];\n /** The dependency graph. */\n graph: DependencyGraph;\n /** The edge collector. */\n collector: EdgeCollector;\n}\n\nexport interface ExternalResourceRef {\n apiVersion: string;\n kind: string;\n name: unknown;\n namespace?: string;\n refKey: string;\n}\n\n// ─── WeakMap stores for internal data ─────────────────────────────────────────\n\nconst internals = new WeakMap<Resource, ResourceInternals>();\n\n// ─── Resource class ───────────────────────────────────────────────────────────\n\n/**\n * A Kubernetes resource within a Composition.\n *\n * The Resource instance acts as a \"desired-first, fallback-to-observed\" proxy:\n * - Reading a path that exists in the desired document returns the desired value.\n * - Reading a path that does NOT exist in desired falls through to a tracked\n * ReadProxy over observed state (creates dependency edges).\n * - Writing always goes to the desired document.\n *\n * The only reserved properties are `node` (from Construct) and `resource`\n * (framework config namespace).\n */\nexport class Resource extends Construct {\n readonly resource: ResourceConfig;\n declare metadata: {\n name?: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n\n constructor(scope: Construct, id: string, props: ResourceProps) {\n super(scope, id);\n\n const graph = scope.node.tryGetContext('xplane:graph') as DependencyGraph;\n const collector = scope.node.tryGetContext('xplane:collector') as EdgeCollector;\n\n if (!graph || !collector) {\n throw new Error('Resource must be created within a Composition tree.');\n }\n\n const ref: ResourceRef = { id: this.node.path };\n graph.addResource(ref);\n\n const readyChecks: ReadyCheck[] = [];\n const config: ResourceConfig = {\n autoReady: true,\n addReadyCheck(fn: ReadyCheckFn, priority = 50) {\n readyChecks.push({ fn, priority });\n },\n };\n this.resource = config;\n\n // Process props — deep scan for ReadProxy values in the desired doc\n const desired = processDesiredProps(props, ref, collector);\n\n const internal: ResourceInternals = {\n ref,\n desired,\n observed: {},\n external: false,\n config,\n readyChecks,\n graph,\n collector,\n };\n internals.set(this, internal);\n\n // Return a proxy over `this` that implements the desired-first/observed-fallback\n const proxy = createResourceProxy(this, internal);\n\n // Patch the construct tree so node.children / findAll() yield the proxy\n // instead of the raw instance (which was registered during super()).\n // biome-ignore lint/suspicious/noExplicitAny: accessing private _children is intentional\n (scope.node as any)._children[this.node.id] = proxy;\n\n // biome-ignore lint/correctness/noConstructorReturn: Proxy wrapping is intentional\n return proxy;\n }\n\n /**\n * Look up an existing cluster resource by name.\n * Returns a Resource that only has observed state (no desired output).\n *\n * The `name` parameter accepts either a plain string or a PrimitiveReadProxy\n * (returned when reading a tracked property like `ns.metadata.labels['x']`).\n * Proxies are coerced to their underlying string via `Symbol.toPrimitive`.\n */\n static fromExistingByName(\n scope: Construct,\n apiVersion: string,\n kind: string,\n name: unknown,\n namespace?: string,\n ): Resource {\n const resolvedName = coerceToString(name);\n const refKey = computeRefKey(apiVersion, kind, resolvedName, namespace);\n const id = `__existing__${refKey.replace(/\\//g, '_')}`;\n\n const instance = new Resource(scope, id, { apiVersion, kind });\n const internal = internals.get(instance)!;\n internal.external = true;\n internal.externalRef = { apiVersion, kind, name: resolvedName ?? name, namespace, refKey };\n\n // Pre-hydrate from context if observed data is already available (from a prior iteration)\n const ctx = compositionStorage.getStore();\n if (ctx) {\n const observed = ctx.requiredResources.get(refKey);\n if (observed) {\n Object.assign(internal.observed, observed);\n }\n }\n\n return instance;\n }\n\n /**\n * Generate a deterministic unique name based on the XR identity and construct path.\n * Useful for resource fields that need unique names (e.g., AWS resource names).\n */\n static uniqueName(\n scope: Construct,\n options: {\n maxLength?: number;\n separator?: string;\n allowedPattern?: RegExp;\n extra?: string;\n } = {},\n ): string {\n const maxLength = options.maxLength ?? 63;\n const separator = options.separator ?? '-';\n const allowedPattern = options.allowedPattern ?? /[^a-zA-Z0-9]/g;\n const escapedSep = separator.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const collapseRe = new RegExp(`${escapedSep}+`, 'g');\n\n const clean = (s: string) =>\n s\n .replace(/\\s+/g, '')\n .replace(allowedPattern, separator)\n .replace(collapseRe, separator)\n .replace(new RegExp(`^${escapedSep}|${escapedSep}$`, 'g'), '');\n\n const xrMeta = scope.node.tryGetContext('xplane:xr-meta') as\n | { name?: string; namespace?: string }\n | undefined;\n\n const parts: string[] = [];\n if (xrMeta?.namespace) parts.push(clean(xrMeta.namespace));\n if (xrMeta?.name) parts.push(clean(xrMeta.name));\n for (const s of scope.node.scopes.slice(1)) {\n const c = clean(s.node.id);\n if (c) parts.push(c);\n }\n if (options.extra) {\n const c = clean(options.extra);\n if (c) parts.push(c);\n }\n\n const full = parts.join(separator);\n const hash = shortHash(full);\n const withHash = `${full}${separator}${hash}`;\n\n if (withHash.length <= maxLength) return withHash;\n const prefix = full.slice(0, maxLength - hash.length - separator.length);\n return `${prefix}${separator}${hash}`;\n }\n}\n\n// ─── Internal accessors (used by pipeline phases) ─────────────────────────────\n\nexport function getResourceInternals(resource: Resource): ResourceInternals {\n const internal = internals.get(resource);\n if (!internal) throw new Error('Resource internals not found');\n return internal;\n}\n\nexport function getResourceRef(resource: Resource): ResourceRef {\n return getResourceInternals(resource).ref;\n}\n\nexport function getDesiredDocument(resource: Resource): Record<string, unknown> {\n return getResourceInternals(resource).desired;\n}\n\nexport function getObservedDocument(resource: Resource): Record<string, unknown> {\n return getResourceInternals(resource).observed;\n}\n\nexport function hydrateObserved(resource: Resource, data: Record<string, unknown>): void {\n const internal = getResourceInternals(resource);\n Object.assign(internal.observed, data);\n}\n\nexport function isExternal(resource: Resource): boolean {\n return getResourceInternals(resource).external;\n}\n\nexport function getExternalRef(resource: Resource): ExternalResourceRef | undefined {\n return getResourceInternals(resource).externalRef;\n}\n\nexport function getReadyChecks(resource: Resource): ReadyCheck[] {\n return getResourceInternals(resource).readyChecks;\n}\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\n/**\n * Coerce a value to a string, handling PrimitiveReadProxy objects that wrap\n * primitive values behind a `Symbol.toPrimitive` method.\n * Returns `undefined` if the value cannot be resolved to a string.\n */\nfunction coerceToString(value: unknown): string | undefined {\n if (typeof value === 'string') return value;\n if (\n value != null &&\n typeof (value as { [Symbol.toPrimitive]?: unknown })[Symbol.toPrimitive] === 'function'\n ) {\n return String(value);\n }\n return undefined;\n}\n\nexport function computeRefKey(\n apiVersion: string,\n kind: string,\n name: string | undefined,\n namespace?: string,\n): string {\n const namePart = name ?? '__unresolved__';\n if (namespace) return `${apiVersion}/${kind}/${namespace}/${namePart}`;\n return `${apiVersion}/${kind}/${namePart}`;\n}\n\nfunction shortHash(s: string): string {\n let h = 5381;\n for (let i = 0; i < s.length; i++) {\n h = ((h << 5) + h) ^ s.charCodeAt(i);\n h = h >>> 0;\n }\n return h.toString(16).padStart(8, '0');\n}\n\n/**\n * Process the desired props — deep-scan for ReadProxy values and replace them\n * with Pending markers (recording edges in the collector).\n */\nfunction processDesiredProps(\n props: ResourceProps,\n owner: ResourceRef,\n collector: EdgeCollector,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n result[key] = processValue(value, owner, key, collector);\n }\n return result;\n}\n\nfunction processValue(\n value: unknown,\n owner: ResourceRef,\n path: string,\n collector: EdgeCollector,\n): unknown {\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value)!;\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: path,\n });\n // Try to get concrete value\n const prim = tryExtractPrimitive(value);\n if (prim !== undefined) return prim;\n return new Pending(meta.owner, meta.path);\n }\n\n if (Array.isArray(value as object)) {\n return (value as unknown[]).map((item, i) =>\n processValue(item, owner, `${path}[${i}]`, collector),\n );\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = processValue(val, owner, `${path}.${key}`, collector);\n }\n return result;\n}\n\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\n/**\n * Creates the \"desired-first, fallback-to-observed\" proxy around a Resource.\n */\nfunction createResourceProxy(resource: Resource, internal: ResourceInternals): Resource {\n const { ref, desired, collector } = internal;\n\n const proxy = new Proxy(resource, {\n get(target, prop, receiver) {\n // Framework reserved properties\n if (prop === 'node') return Reflect.get(target, prop, receiver);\n if (prop === 'resource') return Reflect.get(target, prop, receiver);\n if (typeof prop === 'symbol') return Reflect.get(target, prop, receiver);\n\n // Prototype methods and inherited Construct methods (e.g. .with(), .toString())\n if (prop === 'constructor') return Reflect.get(target, prop, receiver);\n const protoValue = Reflect.get(target, prop, receiver);\n if (typeof protoValue === 'function') return protoValue.bind(proxy);\n\n // Check desired first\n if (prop in desired) {\n const value = desired[String(prop)];\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n // Return a WriteProxy so nested writes go to desired\n // Pass observed at the same path for fallback reads\n const observed = internal.observed;\n const observedAtPath =\n String(prop) in observed && typeof observed[String(prop)] === 'object'\n ? (observed[String(prop)] as Record<string, unknown>)\n : {};\n return createWriteProxy(value as object, {\n owner: ref,\n collector,\n basePath: String(prop),\n observed: observedAtPath,\n });\n }\n return value;\n }\n\n // Fallback to observed via ReadProxy\n const observed = internal.observed;\n if (String(prop) in observed) {\n const value = observed[String(prop)];\n if (typeof value === 'object' && value !== null) {\n return createReadProxy(value as object, ref, String(prop));\n }\n // Primitive observed value — wrap in ReadProxy for tracking\n return createPrimitiveReadProxyFromResource(value, ref, String(prop));\n }\n\n // Path exists in neither — return a lazy-init proxy that behaves as a\n // ReadProxy for reads but auto-initializes the path in desired on write.\n return createLazyInitProxy(desired, ref, collector, String(prop));\n },\n\n set(target, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(target, prop, value);\n if (prop === 'resource') return Reflect.set(target, prop, value);\n\n // All writes go to desired, processing ReadProxy values\n const path = String(prop);\n desired[path] = processValue(value, ref, path, collector);\n return true;\n },\n\n has(target, prop) {\n if (typeof prop === 'symbol') return Reflect.has(target, prop);\n if (prop === 'node' || prop === 'resource') return true;\n return prop in desired || prop in internal.observed;\n },\n }) as Resource;\n\n // Store internal mapping for the proxy too, so internals.get(proxy) works\n internals.set(proxy, internal);\n return proxy;\n}\n\n/**\n * Wrap a primitive observed value so it carries ReadProxy metadata\n * for dependency tracking when assigned elsewhere.\n */\nfunction createPrimitiveReadProxyFromResource(\n value: unknown,\n owner: ResourceRef,\n path: string,\n): unknown {\n if (value === null || value === undefined) return value;\n return createPrimitiveReadProxy(value as string | number | boolean, owner, path);\n}\n\n/**\n * Creates a proxy for a path that exists in neither desired nor observed.\n * - Reading nested properties returns ReadProxy leaves (for dependency tracking).\n * - Writing a nested property auto-initializes the path in desired and stores the value.\n */\nfunction createLazyInitProxy(\n desired: Record<string, unknown>,\n owner: ResourceRef,\n collector: EdgeCollector,\n basePath: string,\n): object {\n const readProxy = createReadProxy({} as object, owner, basePath);\n\n return new Proxy(readProxy as object, {\n get(target, prop, receiver) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop, receiver);\n // Delegate reads to the ReadProxy (for tracking)\n return Reflect.get(target, prop, receiver);\n },\n\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n // Auto-initialize the parent object in desired\n let container = desired[basePath] as Record<string, unknown> | undefined;\n if (!container || typeof container !== 'object') {\n container = {};\n desired[basePath] = container;\n }\n container[String(prop)] = processValue(\n value,\n owner,\n `${basePath}.${String(prop)}`,\n collector,\n );\n return true;\n },\n });\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { XplaneLogger } from './types.js';\n\nconst noopLogger: XplaneLogger = {\n debug() {},\n info() {},\n warn() {},\n};\n\nconst loggerStorage = new AsyncLocalStorage<XplaneLogger>();\n\n/**\n * Get the current logger from async context.\n * Returns a no-op logger if none has been set (silent by default).\n */\nexport function getLogger(): XplaneLogger {\n return loggerStorage.getStore() ?? noopLogger;\n}\n\n/**\n * Run a function with a logger available in async context.\n * All code within `fn` (and any nested async calls) can access\n * the logger via `getLogger()`.\n */\nexport function withLogger<T>(logger: XplaneLogger, fn: () => T): T {\n return loggerStorage.run(logger, fn);\n}\n","import {\n getDesiredDocument,\n getExternalRef,\n getObservedDocument,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { Pending } from '../tracking/index.js';\n\nimport type { DiagnosticReport, PipelineState } from './types.js';\n\n/**\n * DIAGNOSE phase: produce structured diagnostics for blocked resources.\n *\n * For each resource classified as 'blocked':\n * - Find all Pending markers in the desired document\n * - Report what they're waiting on (source resource + path)\n *\n * For circular dependencies (detected in sequence phase):\n * - Produce a 'cycle' diagnostic with the full cycle path\n */\nexport function diagnose(state: PipelineState): PipelineState {\n const diagnostics: DiagnosticReport[] = [];\n\n // Check for cycles from the graph\n const sortResult = state.graph.topologicalSort();\n if (sortResult.order === null && sortResult.cycle) {\n const firstCycleMember = sortResult.cycle[0];\n if (firstCycleMember) {\n diagnostics.push({\n resource: firstCycleMember,\n reason: 'cycle',\n cycle: sortResult.cycle,\n });\n }\n }\n\n // Report external resources that were required but not found\n for (const resource of state.resources) {\n if (!isExternal(resource)) continue;\n const ref = getExternalRef(resource);\n if (!ref) continue;\n const observed = getObservedDocument(resource);\n if (Object.keys(observed).length > 0) continue; // hydrated, no problem\n const nameDisplay =\n typeof ref.name === 'string' ? ref.name : ref.name == null ? '(unresolved)' : '(unresolved)';\n const nsDisplay = ref.namespace ? ` in namespace '${ref.namespace}'` : '';\n diagnostics.push({\n resource: getResourceRef(resource).id,\n reason: 'not-found',\n detail: `External resource ${ref.apiVersion}/${ref.kind} '${nameDisplay}'${nsDisplay} was required but not found by Crossplane`,\n });\n }\n\n // For each blocked resource, find pending paths\n const pendingDiagnostics: DiagnosticReport[] = [];\n for (const resource of state.resources) {\n if (isExternal(resource)) continue;\n\n const ref = getResourceRef(resource);\n const classification = state.classification.get(ref.id);\n if (classification !== 'blocked') continue;\n\n // Skip if already reported as cycle member\n if (sortResult.order === null && sortResult.cycle?.includes(ref.id)) continue;\n\n const desired = getDesiredDocument(resource);\n const pendingPaths = findPendingPaths(desired, '');\n\n if (pendingPaths.length > 0) {\n pendingDiagnostics.push({\n resource: ref.id,\n reason: 'pending',\n pendingPaths,\n });\n }\n }\n\n // Filter out cascading diagnostics: only keep pending diagnostics that have\n // at least one dependency that is NOT itself blocked or not-found.\n // This surfaces only root causes rather than the full dependency cascade.\n const notFoundIds = new Set(\n diagnostics.filter((d) => d.reason === 'not-found').map((d) => d.resource),\n );\n const blockedIds = new Set(pendingDiagnostics.map((d) => d.resource));\n\n for (const diag of pendingDiagnostics) {\n const isRootCause = diag.pendingPaths?.some((p) => {\n const dep = p.waitingOn.resource;\n // If waiting on something that isn't blocked or not-found, this IS a root cause\n return !blockedIds.has(dep) && !notFoundIds.has(dep);\n });\n if (isRootCause) {\n diagnostics.push(diag);\n }\n }\n\n return { ...state, diagnostics };\n}\n\n/**\n * Recursively find all Pending markers in a document and report their source.\n */\nfunction findPendingPaths(\n obj: unknown,\n basePath: string,\n): Array<{ path: string; waitingOn: { resource: string; path: string } }> {\n const results: Array<{ path: string; waitingOn: { resource: string; path: string } }> = [];\n\n if (obj === null || obj === undefined) return results;\n if (Pending.is(obj)) {\n results.push({\n path: basePath,\n waitingOn: { resource: obj.source.id, path: obj.path },\n });\n return results;\n }\n if (typeof obj !== 'object') return results;\n\n if (Array.isArray(obj)) {\n for (let i = 0; i < obj.length; i++) {\n const childPath = basePath ? `${basePath}[${i}]` : `[${i}]`;\n results.push(...findPendingPaths(obj[i], childPath));\n }\n return results;\n }\n\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n const childPath = basePath ? `${basePath}.${key}` : key;\n results.push(...findPendingPaths(value, childPath));\n }\n return results;\n}\n","import { getXrDesiredStatus } from '../core/composition.js';\nimport {\n getDesiredDocument,\n getObservedDocument,\n getReadyChecks,\n getResourceInternals,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { getReadProxyMeta, isReadProxy } from '../tracking/index.js';\n\nimport type { EmittedResource, PipelineState } from './types.js';\n\n/**\n * EMIT phase: serialize each resource classified as 'emit' into a plain\n * Kubernetes resource document ready for Crossplane.\n *\n * Also extracts the XR desired status from this.xr.status assignments.\n */\nexport function emit(state: PipelineState): PipelineState {\n const emitted: EmittedResource[] = [];\n\n for (const resource of state.resources) {\n if (isExternal(resource)) continue;\n\n const ref = getResourceRef(resource);\n const classification = state.classification.get(ref.id);\n if (classification !== 'emit') continue;\n\n const internal = getResourceInternals(resource);\n const desired = getDesiredDocument(resource);\n\n // Strip the construct path prefix to get the resource name\n // The name is the full construct path minus the root \"Composition/\" prefix\n const name = ref.id.startsWith('Composition/') ? ref.id.slice('Composition/'.length) : ref.id;\n\n emitted.push({\n name,\n document: deepClean(desired),\n autoReady: internal.config.autoReady,\n readyChecks: getReadyChecks(resource),\n });\n }\n\n // Extract XR status and resolve any ReadProxy values using observed data\n const resourceById = new Map(state.resources.map((r) => [getResourceRef(r).id, r]));\n const rawStatus = getXrDesiredStatus(state.composition);\n const xrStatusPatches = resolveXrStatus(rawStatus, resourceById);\n\n return { ...state, emitted, xrStatusPatches };\n}\n\n/**\n * Deep-clone an object, stripping any remaining framework internals.\n * This produces a clean JSON-serializable Kubernetes document.\n */\nfunction deepClean(obj: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n result[key] = cleanValue(value);\n }\n\n return result;\n}\n\nfunction cleanValue(value: unknown): unknown {\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n if (Array.isArray(value)) {\n return value.map(cleanValue);\n }\n\n // Plain objects — recurse\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = cleanValue(val);\n }\n return result;\n}\n\n/**\n * Resolve ReadProxy values in XR status using observed resource data.\n * This is needed because XR status is written at construction time (before hydration),\n * so read proxy references need to be resolved post-hydration.\n */\nfunction resolveXrStatus(\n status: Record<string, unknown>,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(status)) {\n const resolved = resolveStatusValue(value, resourceById);\n if (resolved !== undefined) {\n result[key] = resolved;\n }\n }\n return result;\n}\n\nfunction resolveStatusValue(\n value: unknown,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): unknown {\n if (value === null || value === undefined) return undefined;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value);\n if (!meta) return undefined;\n\n // Try to extract a concrete primitive (already resolved read proxy)\n const prim = tryExtractPrimitive(value as object);\n if (prim !== undefined) return prim;\n\n // Leaf proxy — try to resolve from observed data\n const resource = resourceById.get(meta.owner.id);\n if (!resource) return undefined;\n const observed = getObservedDocument(resource);\n return getNestedValue(observed, meta.path);\n }\n\n if (Array.isArray(value)) {\n return value.map((v) => resolveStatusValue(v, resourceById)).filter((v) => v != null);\n }\n\n if (typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const resolved = resolveStatusValue(v, resourceById);\n if (resolved !== undefined) {\n out[k] = resolved;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n }\n\n return value;\n}\n\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values — skip them\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split('.');\n let current: unknown = obj;\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n","import { getExternalRef, hydrateObserved, isExternal } from '../core/resource.js';\n\nimport type { PipelineState } from './types.js';\n\n/**\n * HYDRATE phase: feed observed state from Crossplane into each resource.\n *\n * - Composed resources are matched by their construct path (resource name).\n * - External resources are matched by their refKey.\n */\nexport function hydrate(state: PipelineState): PipelineState {\n for (const resource of state.resources) {\n if (isExternal(resource)) {\n const ref = getExternalRef(resource);\n if (ref) {\n const observed = state.observedRequired.get(ref.refKey);\n if (observed) {\n hydrateObserved(resource, observed);\n }\n }\n } else {\n // Match by construct path\n const name = resource.node.path;\n const observed = state.observedComposed.get(name);\n if (observed) {\n hydrateObserved(resource, observed);\n }\n }\n }\n\n return state;\n}\n","import { getDesiredDocument, getObservedDocument, getResourceRef } from '../core/resource.js';\nimport { Pending } from '../tracking/index.js';\n\nimport type { PipelineState } from './types.js';\n\n/**\n * RESOLVE phase: walk dependency edges and replace Pending markers\n * with concrete values from observed state where available.\n *\n * For each resource's desired document, recursively find Pending values.\n * Look up the source resource's observed state at the source path.\n * If concrete → replace. If not available → leave Pending in place.\n */\nexport function resolve(state: PipelineState): PipelineState {\n // Build a lookup: resource id → Resource instance\n const resourceById = new Map(state.resources.map((r) => [getResourceRef(r).id, r]));\n\n for (const resource of state.resources) {\n const desired = getDesiredDocument(resource);\n resolvePending(desired, resourceById);\n }\n\n return state;\n}\n\n/**\n * Recursively walk an object and resolve any Pending markers.\n */\nfunction resolvePending(\n obj: Record<string, unknown>,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): void {\n for (const [key, value] of Object.entries(obj)) {\n if (Pending.is(value)) {\n const sourceResource = resourceById.get(value.source.id);\n if (sourceResource) {\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, value.path);\n if (resolved !== undefined) {\n obj[key] = resolved;\n }\n // else: leave Pending in place — still unresolved\n }\n } else if (Array.isArray(value)) {\n resolveArray(value, resourceById);\n } else if (value !== null && typeof value === 'object') {\n resolvePending(value as Record<string, unknown>, resourceById);\n }\n }\n}\n\nfunction resolveArray(\n arr: unknown[],\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): void {\n for (let i = 0; i < arr.length; i++) {\n const value = arr[i];\n if (Pending.is(value)) {\n const sourceResource = resourceById.get(value.source.id);\n if (sourceResource) {\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, value.path);\n if (resolved !== undefined) {\n arr[i] = resolved;\n }\n }\n } else if (Array.isArray(value)) {\n resolveArray(value, resourceById);\n } else if (value !== null && typeof value === 'object') {\n resolvePending(value as Record<string, unknown>, resourceById);\n }\n }\n}\n\n/**\n * Get a nested value from an object by dot-separated path.\n */\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const segments = path.split('.');\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (current === null || current === undefined) return undefined;\n if (typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n\n return current;\n}\n","import { getDesiredDocument, getResourceRef, isExternal } from '../core/resource.js';\nimport { Pending } from '../tracking/index.js';\n\nimport type { PipelineState, ResourceClassification } from './types.js';\n\n/**\n * SEQUENCE phase: topological sort and classification.\n *\n * - Runs topological sort on the dependency graph.\n * - Classifies each resource as 'emit', 'blocked', or 'external'.\n * - A resource is 'blocked' if it still has Pending markers in its desired document.\n * - External resources are classified as 'external' (never emitted).\n * - Circular dependencies are detected via the graph's topological sort.\n */\nexport function sequence(state: PipelineState): PipelineState {\n const classification = new Map<string, ResourceClassification>();\n\n // Run topological sort for cycle detection\n const sortResult = state.graph.topologicalSort();\n\n // Classify each resource\n for (const resource of state.resources) {\n const ref = getResourceRef(resource);\n\n if (isExternal(resource)) {\n classification.set(ref.id, 'external');\n continue;\n }\n\n // Check if this resource has any remaining Pending markers\n const desired = getDesiredDocument(resource);\n const hasPending = containsPending(desired);\n\n if (hasPending) {\n classification.set(ref.id, 'blocked');\n } else {\n classification.set(ref.id, 'emit');\n }\n }\n\n // If there's a cycle, mark all cycle members as blocked\n if (sortResult.order === null && sortResult.cycle) {\n for (const id of sortResult.cycle) {\n if (classification.get(id) !== 'external') {\n classification.set(id, 'blocked');\n }\n }\n }\n\n return { ...state, classification };\n}\n\n/**\n * Recursively check if an object contains any Pending markers.\n */\nfunction containsPending(obj: unknown): boolean {\n if (obj === null || obj === undefined) return false;\n if (Pending.is(obj)) return true;\n if (typeof obj !== 'object') return false;\n\n if (Array.isArray(obj)) {\n return obj.some(containsPending);\n }\n\n for (const value of Object.values(obj as Record<string, unknown>)) {\n if (containsPending(value)) return true;\n }\n return false;\n}\n","import type { Composition } from '../core/composition.js';\nimport type { Resource } from '../core/resource.js';\n\nimport { diagnose } from './diagnose.js';\nimport { emit } from './emit.js';\nimport { hydrate } from './hydrate.js';\nimport { resolve } from './resolve.js';\nimport { sequence } from './sequence.js';\nimport type { PipelineState } from './types.js';\n\nexport { diagnose } from './diagnose.js';\nexport { emit } from './emit.js';\nexport { hydrate } from './hydrate.js';\nexport { resolve } from './resolve.js';\nexport { sequence } from './sequence.js';\nexport type {\n DiagnosticReport,\n EmittedResource,\n PipelineState,\n ResourceClassification,\n} from './types.js';\n\n/**\n * Input to the pipeline — provided by the handler or simulator.\n */\nexport interface PipelineInput {\n /** The constructed Composition instance. */\n composition: Composition;\n /** Observed composed resources from Crossplane (keyed by resource name). */\n observedComposed: ReadonlyMap<string, Record<string, unknown>>;\n /** Observed existing/required resources (keyed by refKey). */\n observedRequired: ReadonlyMap<string, Record<string, unknown>>;\n}\n\n/**\n * Run the full rendering pipeline.\n *\n * Phases: hydrate → resolve → sequence → diagnose → emit\n */\nexport function runPipeline(input: PipelineInput): PipelineState {\n const resources = collectResources(input.composition);\n\n const initialState: PipelineState = {\n composition: input.composition,\n resources,\n graph: input.composition.graph,\n observedComposed: input.observedComposed,\n observedRequired: input.observedRequired,\n classification: new Map(),\n diagnostics: [],\n emitted: [],\n xrStatusPatches: {},\n };\n\n // Run phases sequentially — each transforms the state\n let state = initialState;\n state = hydrate(state);\n state = resolve(state);\n state = sequence(state);\n state = diagnose(state);\n state = emit(state);\n\n return state;\n}\n\n/**\n * Collect all Resource instances from the composition's construct tree.\n */\nfunction collectResources(composition: Composition): Resource[] {\n const resources: Resource[] = [];\n collectFromNode(composition, resources);\n return resources;\n}\n\nfunction collectFromNode(construct: import('constructs').Construct, resources: Resource[]): void {\n for (const child of construct.node.children) {\n // Check if it's a Resource (has our internals)\n if (isResourceInstance(child)) {\n resources.push(child as Resource);\n }\n // Recurse into children\n collectFromNode(child, resources);\n }\n}\n\nfunction isResourceInstance(obj: unknown): obj is Resource {\n if (obj === null || typeof obj !== 'object') return false;\n const r = obj as Record<string, unknown>;\n if (!('resource' in r) || r.resource === null || typeof r.resource !== 'object') return false;\n return 'autoReady' in (r.resource as object);\n}\n","import type { ReadyCheck } from './types.js';\n\n/**\n * Checks if the resource has a `Ready` condition with status `True`.\n */\nexport function conditionReady(observed: Record<string, unknown>): boolean | undefined {\n const status = observed.status as Record<string, unknown> | undefined;\n const conditions = status?.conditions as Array<Record<string, unknown>> | undefined;\n if (!conditions || !Array.isArray(conditions)) return undefined;\n\n const ready = conditions.find((c) => c.type === 'Ready');\n if (!ready) return undefined;\n\n return ready.status === 'True';\n}\n\n/**\n * Checks if the resource has `status.ready === true`.\n */\nexport function statusReady(observed: Record<string, unknown>): boolean | undefined {\n const status = observed.status as Record<string, unknown> | undefined;\n if (status === undefined) return undefined;\n if (!('ready' in status)) return undefined;\n\n return status.ready === true;\n}\n\n/**\n * Fallback: resource exists in observed state → ready.\n * Always returns `true` (only called when observed is defined).\n */\nexport function exists(_observed: Record<string, unknown>): boolean {\n return true;\n}\n\n/**\n * Built-in default readiness checks, appended at low priority.\n */\nexport const DEFAULT_CHECKS: ReadyCheck[] = [\n { fn: conditionReady, priority: 100, name: 'conditionReady' },\n { fn: statusReady, priority: 200, name: 'statusReady' },\n { fn: exists, priority: 1000, name: 'exists' },\n];\n","import { getLogger } from '../logging/index.js';\n\nimport type { ReadyCheck } from './types.js';\n\n/**\n * Evaluate readiness for a resource by running checks grouped by priority.\n *\n * - If `observed` is undefined, the resource doesn't exist yet → not ready.\n * - Checks are grouped by priority (ascending). Within a group, all checks\n * are AND-ed: if any returns `false`, the resource is not ready. If at least\n * one returns `true` and none return `false`, the resource is ready.\n * If all return `undefined`, cascade to the next priority group.\n * - Final fallback (no group had a definitive answer): not ready.\n */\nexport function evaluateReadiness(\n checks: ReadyCheck[],\n observed: Record<string, unknown> | undefined,\n): boolean {\n const log = getLogger();\n\n if (!observed) {\n log.debug('readiness: resource not observed, not ready');\n return false;\n }\n\n // Group checks by priority\n const groups = new Map<number, ReadyCheck[]>();\n for (const check of checks) {\n const group = groups.get(check.priority);\n if (group) {\n group.push(check);\n } else {\n groups.set(check.priority, [check]);\n }\n }\n\n // Process groups in ascending priority order\n const priorities = [...groups.keys()].sort((a, b) => a - b);\n\n for (const priority of priorities) {\n const group = groups.get(priority)!;\n let hasTrue = false;\n let hasFalse = false;\n const results: Array<{ name: string; result: boolean | undefined }> = [];\n\n for (const check of group) {\n const result = check.fn(observed);\n results.push({ name: check.name ?? 'anonymous', result });\n\n if (result === false) {\n hasFalse = true;\n break; // Short-circuit: one false in the group → not ready\n }\n if (result === true) {\n hasTrue = true;\n }\n }\n\n log.debug('readiness: evaluated group', { priority, results });\n\n if (hasFalse) {\n log.debug('readiness: group returned false, not ready', { priority });\n return false;\n }\n if (hasTrue) {\n log.debug('readiness: group returned true, ready', { priority });\n return true;\n }\n // All undefined → cascade to next group\n }\n\n log.debug('readiness: no group had definitive answer, not ready');\n return false;\n}\n","import type {\n CompositionInput,\n CompositionResult,\n DesiredResource,\n ExternalResourceRequest,\n} from './contract.js';\nimport type { Composition } from './core/composition.js';\nimport type { CompositionContext } from './core/context.js';\nimport { compositionStorage } from './core/context.js';\nimport { getExternalRef, isExternal } from './core/resource.js';\nimport { runPipeline } from './pipeline/index.js';\nimport { DEFAULT_CHECKS, evaluateReadiness } from './readiness/index.js';\nimport { DependencyGraph, EdgeCollector } from './tracking/index.js';\n\n/**\n * Run a composition class with the given input and return a plain-data result.\n *\n * This is the single entry point that bridges the composition author's class\n * with the runtime. It handles:\n * 1. Setting up internal context (DependencyGraph, EdgeCollector, ALS)\n * 2. Instantiating the Composition class\n * 3. Running the full pipeline (hydrate → resolve → sequence → diagnose → emit)\n * 4. Evaluating readiness per resource\n * 5. Returning a fully serializable CompositionResult\n *\n * The runtime never needs to access framework internals — everything it needs\n * is in the returned plain-data structure.\n */\nexport function runComposition<TSpec, TStatus, TContext extends object>(\n CompositionClass: new () => Composition<TSpec, TStatus, TContext>,\n input: CompositionInput,\n): CompositionResult {\n // Convert plain Records to Maps for the internal pipeline\n const observedComposed = new Map(Object.entries(input.observedComposed));\n const observedRequired = new Map(Object.entries(input.observedRequired));\n\n // Set up internal context\n const graph = new DependencyGraph();\n const collector = new EdgeCollector();\n const pipelineContext = new Map(Object.entries(input.pipelineContext));\n\n const ctx: CompositionContext = {\n xr: input.xr,\n pipelineContext,\n requiredResources: observedRequired,\n graph,\n collector,\n };\n\n // Instantiate composition within ALS context\n const composition = compositionStorage.run(ctx, () => new CompositionClass()) as Composition;\n\n // Run the pipeline\n const state = runPipeline({ composition, observedComposed, observedRequired });\n\n // Build the result — plain data only\n const resources: DesiredResource[] = state.emitted.map((emitted) => {\n const allChecks = [...emitted.readyChecks, ...DEFAULT_CHECKS];\n // Look up observed using the full construct path (Composition/{name})\n const observed = observedComposed.get(`Composition/${emitted.name}`);\n const ready = emitted.autoReady ? evaluateReadiness(allChecks, observed) : true;\n\n return {\n name: emitted.name,\n document: emitted.document,\n ready,\n };\n });\n\n const externalResources: ExternalResourceRequest[] = [];\n for (const resource of state.resources) {\n if (!isExternal(resource)) continue;\n const ref = getExternalRef(resource);\n if (!ref || typeof ref.name !== 'string') continue;\n if (ref.name.startsWith('__pending__')) continue;\n\n externalResources.push({\n refKey: ref.refKey,\n apiVersion: ref.apiVersion,\n kind: ref.kind,\n name: ref.name,\n ...(ref.namespace ? { namespace: ref.namespace } : {}),\n });\n }\n\n return {\n resources,\n externalResources,\n xrStatus: state.xrStatusPatches,\n diagnostics: state.diagnostics,\n };\n}\n"],"mappings":";;;;;;;;AA2BA,MAAa,qBAAqB,IAAI,kBAAsC;;;;;AAM5E,SAAgB,wBAA4C;CAC1D,MAAM,MAAM,mBAAmB,SAAS;CACxC,IAAI,KAAK,OAAO;CAEhB,MAAM,IAAI,MACR,sGACF;AACF;;;;;;;;;;;;;;;;;;;;;ACiBA,IAAa,cAAb,cAIUA,YAAU;;;;;CAKlB;;CAGA;;CAGA;CAEA,cAAc;EAEZ,MAAM,KAAA,GAAmC,aAAa;EAEtD,MAAM,MAAM,sBAAsB;EAElC,KAAK,QAAQ,IAAI;EACjB,KAAK,YAAY,IAAI;EAGrB,KAAK,KAAK,WAAW,gBAAgB,IAAI,KAAK;EAC9C,KAAK,KAAK,WAAW,oBAAoB,IAAI,SAAS;EAGtD,MAAM,SAAS,IAAI,GAAG;EACtB,IAAI,QACF,KAAK,KAAK,WAAW,kBAAkB,MAAM;EAI/C,KAAK,KAAK,cAA8B,GAAG;CAC7C;;;;;CAMA,IAAI,kBAAqD;EACvD,MAAM,MAAM,sBAAsB;EAClC,OAAO;GACL,IAA8B,KAAiC;IAC7D,OAAO,IAAI,gBAAgB,IAAI,GAAa;GAC9C;GACA,IAAI,KAA8B;IAChC,OAAO,IAAI,gBAAgB,IAAI,GAAa;GAC9C;GACA,OAAyC;IACvC,OAAO,IAAI,gBAAgB,KAAK;GAClC;EACF;CACF;AACF;;;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AAM,mBAAmB,IAAI,IAAI,OAAO,QAAQ,MAAM,gBAAgB,CAAC;CAGvE,MAAM,QAAQ,IAAI,gBAAgB;CAClC,MAAM,YAAY,IAAI,cAAc;CACpC,MAAM,kBAAkB,IAAI,IAAI,OAAO,QAAQ,MAAM,eAAe,CAAC;CAErE,MAAM,MAA0B;EAC9B,IAAI,MAAM;EACV;EACA,mBAAmB;EACnB;EACA;CACF;CAMA,MAAM,QAAQ,YAAY;EAAE,aAHR,mBAAmB,IAAI,WAAW,IAAI,iBAAiB,CAGrC;EAAG;EAAkB;CAAiB,CAAC;CAG7E,MAAM,YAA+B,MAAM,QAAQ,KAAK,YAAY;EAClE,MAAM,YAAY,CAAC,GAAG,QAAQ,aAAa,GAAG,cAAc;EAE5D,MAAM,WAAW,iBAAiB,IAAI,eAAe,QAAQ,MAAM;EACnE,MAAM,QAAQ,QAAQ,YAAY,kBAAkB,WAAW,QAAQ,IAAI;EAE3E,OAAO;GACL,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB;EACF;CACF,CAAC;CAED,MAAM,oBAA+C,CAAC;CACtD,KAAK,MAAM,YAAY,MAAM,WAAW;EACtC,IAAI,CAAC,WAAW,QAAQ,GAAG;EAC3B,MAAM,MAAM,eAAe,QAAQ;EACnC,IAAI,CAAC,OAAO,OAAO,IAAI,SAAS,UAAU;EAC1C,IAAI,IAAI,KAAK,WAAW,aAAa,GAAG;EAExC,kBAAkB,KAAK;GACrB,QAAQ,IAAI;GACZ,YAAY,IAAI;GAChB,MAAM,IAAI;GACV,MAAM,IAAI;GACV,GAAI,IAAI,YAAY,EAAE,WAAW,IAAI,UAAU,IAAI,CAAC;EACtD,CAAC;CACH;CAEA,OAAO;EACL;EACA;EACA,UAAU,MAAM;EAChB,aAAa,MAAM;CACrB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Construct","tryExtractPrimitive","Construct","tryExtractPrimitive","getNestedValue"],"sources":["../src/core/context.ts","../src/core/composition.ts","../src/tracking/dependency-graph.ts","../src/tracking/types.ts","../src/tracking/token-registry.ts","../src/tracking/read-proxy.ts","../src/tracking/write-proxy.ts","../src/core/resource.ts","../src/logging/context.ts","../src/pipeline/diagnose.ts","../src/pipeline/emit.ts","../src/pipeline/hydrate.ts","../src/pipeline/resolve.ts","../src/pipeline/sequence.ts","../src/pipeline/index.ts","../src/readiness/defaults.ts","../src/readiness/evaluate.ts","../src/run.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { DependencyGraph, EdgeCollector } from '../tracking/index.js';\n\n/**\n * Runtime context passed into a Composition during construction\n * via AsyncLocalStorage. Holds everything the Composition needs\n * without relying on static state or globalThis.\n */\nexport interface CompositionContext {\n /** Observed XR data. */\n xr: Record<string, unknown>;\n /** Full Crossplane function pipeline context (all keys). */\n pipelineContext: ReadonlyMap<string, unknown>;\n /** Pre-populated data for existing resources (from prior iterations). */\n requiredResources: ReadonlyMap<string, Record<string, unknown>>;\n /** The dependency graph for this composition run. */\n graph: DependencyGraph;\n /** The edge collector for this composition run. */\n collector: EdgeCollector;\n}\n\n/**\n * AsyncLocalStorage instance that carries the CompositionContext.\n * The handler sets it before constructing the user's Composition,\n * and the Composition constructor reads from it.\n */\nexport const compositionStorage = new AsyncLocalStorage<CompositionContext>();\n\n/**\n * Get the current composition context from AsyncLocalStorage.\n * Throws if called outside of a composition construction scope.\n */\nexport function getCompositionContext(): CompositionContext {\n const ctx = compositionStorage.getStore();\n if (ctx) return ctx;\n\n throw new Error(\n 'No composition context found. Ensure the Composition is constructed within compositionStorage.run().',\n );\n}\n","import { Construct } from 'constructs';\n\nimport type { DependencyGraph, EdgeCollector } from '../tracking/index.js';\nimport { getCompositionContext } from './context.js';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Base generics for a Composition.\n * - TSpec: shape of the XR's spec\n * - TStatus: shape of the XR's status (writable)\n * - TContext: shape of the pipeline context map keys→values\n */\nexport type CompositionProps<\n TSpec = Record<string, unknown>,\n TStatus = Record<string, unknown>,\n TContext extends object = Record<string, unknown>,\n> = {\n spec?: TSpec;\n status?: TStatus;\n context?: TContext;\n};\n\n/** The shape of the XR proxy exposed via `this.xr`. */\nexport interface XrProxy<TSpec = Record<string, unknown>, TStatus = Record<string, unknown>> {\n spec: TSpec;\n status: TStatus;\n metadata: {\n name: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n// ─── Composition class ────────────────────────────────────────────────────────\n\n/**\n * Base class for user-authored Crossplane compositions.\n *\n * Users extend this class and define resources in the constructor:\n *\n * ```ts\n * class MyComposition extends Composition<MySpec, MyStatus> {\n * constructor() {\n * super();\n * const vpc = new Vpc(this, 'vpc', { spec: { ... } });\n * this.xr.status.vpcId = vpc.status.atProvider.vpcId;\n * }\n * }\n * ```\n *\n * `this.xr` is a \"desired-first, fallback-to-observed\" proxy over the XR.\n * `this.pipelineContext` provides typed read-only access to Crossplane function context.\n */\nexport class Composition<\n TSpec = Record<string, unknown>,\n TStatus = Record<string, unknown>,\n TContext extends object = Record<string, unknown>,\n> extends Construct {\n /**\n * The XR proxy — reads from desired first (status writes), falls through to observed.\n * Writing to `this.xr.status.*` sets the composite status output.\n */\n readonly xr: XrProxy<TSpec, TStatus>;\n\n /** The dependency graph tracking resource relationships. */\n readonly graph: DependencyGraph;\n\n /** The edge collector accumulating dependency edges. */\n readonly collector: EdgeCollector;\n\n constructor() {\n // Use 'Composition' as the root construct ID\n super(undefined as unknown as Construct, 'Composition');\n\n const ctx = getCompositionContext();\n\n this.graph = ctx.graph;\n this.collector = ctx.collector;\n\n // Set context values on the construct tree so Resources can find them\n this.node.setContext('xplane:graph', ctx.graph);\n this.node.setContext('xplane:collector', ctx.collector);\n\n // Set XR metadata on tree for Resource.uniqueName()\n const xrMeta = ctx.xr.metadata as { name?: string; namespace?: string } | undefined;\n if (xrMeta) {\n this.node.setContext('xplane:xr-meta', xrMeta);\n }\n\n // Build the XR proxy\n this.xr = createXrProxy<TSpec, TStatus>(ctx);\n }\n\n /**\n * Read-only accessor for Crossplane function pipeline context.\n * Keys are the context keys set by Crossplane or prior functions in the pipeline.\n */\n get pipelineContext(): PipelineContextAccessor<TContext> {\n const ctx = getCompositionContext();\n return {\n get<K extends keyof TContext>(key: K): TContext[K] | undefined {\n return ctx.pipelineContext.get(key as string) as TContext[K] | undefined;\n },\n has(key: keyof TContext): boolean {\n return ctx.pipelineContext.has(key as string);\n },\n keys(): IterableIterator<keyof TContext> {\n return ctx.pipelineContext.keys() as IterableIterator<keyof TContext>;\n },\n };\n }\n}\n\n/** Typed read-only interface for pipeline context. */\nexport interface PipelineContextAccessor<TContext extends object = Record<string, unknown>> {\n get<K extends keyof TContext>(key: K): TContext[K] | undefined;\n has(key: keyof TContext): boolean;\n keys(): IterableIterator<keyof TContext>;\n}\n\n// ─── XR Proxy ─────────────────────────────────────────────────────────────────\n\n/**\n * Creates the \"desired-first, fallback-to-observed\" proxy for the XR.\n *\n * - Reading `xr.spec.*` reads from observed XR spec (creates ReadProxy for tracking)\n * - Writing `xr.status.*` writes to a desired-status store (emitted as composite status)\n * - Other reads fall through to observed\n */\nfunction createXrProxy<TSpec, TStatus>(ctx: {\n xr: Record<string, unknown>;\n graph: DependencyGraph;\n collector: EdgeCollector;\n}): XrProxy<TSpec, TStatus> {\n const xrObserved = ctx.xr;\n const xrDesiredStatus: Record<string, unknown> = {};\n\n // The XR ref for dependency tracking\n const xrRef = { id: '__xr__' };\n ctx.graph.addResource(xrRef);\n\n const statusProxy = new Proxy(xrDesiredStatus, {\n get(_target, prop) {\n if (typeof prop === 'symbol') return undefined;\n const key = String(prop);\n // Desired-first\n if (key in xrDesiredStatus) return xrDesiredStatus[key];\n // Fallback to observed status\n const observedStatus = xrObserved.status as Record<string, unknown> | undefined;\n if (observedStatus && key in observedStatus) {\n return observedStatus[key];\n }\n return undefined;\n },\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n xrDesiredStatus[String(prop)] = value;\n return true;\n },\n has(_target, prop) {\n if (typeof prop === 'symbol') return false;\n const key = String(prop);\n if (key in xrDesiredStatus) return true;\n const observedStatus = xrObserved.status as Record<string, unknown> | undefined;\n return observedStatus ? key in observedStatus : false;\n },\n });\n\n const proxy = new Proxy({} as XrProxy<TSpec, TStatus>, {\n get(_target, prop) {\n if (typeof prop === 'symbol') return undefined;\n const key = String(prop);\n if (key === 'status') return statusProxy;\n // Everything else reads from observed XR\n if (key in xrObserved) return xrObserved[key];\n return undefined;\n },\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n const key = String(prop);\n if (key === 'status') {\n // Allow replacing entire status\n Object.assign(xrDesiredStatus, value as object);\n return true;\n }\n // Writes to other top-level XR fields are unusual but allowed\n (xrObserved as Record<string, unknown>)[key] = value;\n return true;\n },\n has(_target, prop) {\n if (typeof prop === 'symbol') return false;\n return String(prop) in xrObserved || String(prop) === 'status';\n },\n });\n\n return proxy;\n}\n\n/**\n * Extract the desired XR status from a Composition instance.\n * Used by the emit pipeline phase to produce composite status output.\n */\nexport function getXrDesiredStatus(composition: Composition): Record<string, unknown> {\n // Access the internal status proxy target\n const statusProxy = composition.xr.status;\n // Collect all keys from the status proxy.\n // We intentionally return raw values (including ReadProxy references) so\n // that the emit phase can resolve them from observed resource data.\n const result: Record<string, unknown> = {};\n if (statusProxy && typeof statusProxy === 'object') {\n for (const key of Object.keys(statusProxy)) {\n const value = (statusProxy as Record<string, unknown>)[key];\n if (value != null) {\n result[key] = value;\n }\n }\n }\n return result;\n}\n","import type { DependencyEdge, ResourceRef } from './types.js';\n\n/**\n * Tracks dependency relationships between resources as a directed acyclic graph.\n * Edges are added as resources reference each other's observed state.\n */\nexport class DependencyGraph {\n private readonly _adjacency = new Map<string, Set<string>>();\n private readonly _resources = new Map<string, ResourceRef>();\n private readonly _edges: DependencyEdge[] = [];\n\n addResource(ref: ResourceRef): void {\n this._resources.set(ref.id, ref);\n if (!this._adjacency.has(ref.id)) {\n this._adjacency.set(ref.id, new Set());\n }\n }\n\n addEdge(edge: DependencyEdge): void {\n this.addResource(edge.from);\n this.addResource(edge.to);\n this._adjacency.get(edge.to.id)!.add(edge.from.id);\n this._edges.push(edge);\n }\n\n addEdges(edges: ReadonlyArray<DependencyEdge>): void {\n for (const edge of edges) this.addEdge(edge);\n }\n\n addExplicitDependency(dependent: ResourceRef, dependency: ResourceRef): void {\n this.addResource(dependent);\n this.addResource(dependency);\n this._adjacency.get(dependent.id)!.add(dependency.id);\n }\n\n /** Get the set of resource IDs that `resourceId` depends on. */\n getDependencies(resourceId: string): ReadonlySet<string> {\n return this._adjacency.get(resourceId) ?? new Set();\n }\n\n get resourceIds(): ReadonlyArray<string> {\n return [...this._resources.keys()];\n }\n\n get edges(): ReadonlyArray<DependencyEdge> {\n return this._edges;\n }\n\n /**\n * Returns a topological ordering of resources.\n * If a cycle is detected, returns { order: null, cycle: string[] }.\n */\n topologicalSort(): { order: string[] } | { order: null; cycle: string[] } {\n const visited = new Set<string>();\n const visiting = new Set<string>();\n const sorted: string[] = [];\n\n const visit = (id: string): string[] | null => {\n if (visited.has(id)) return null;\n if (visiting.has(id)) {\n // Build cycle path\n return [...visiting, id];\n }\n visiting.add(id);\n const deps = this._adjacency.get(id);\n if (deps) {\n for (const depId of deps) {\n const cycle = visit(depId);\n if (cycle) return cycle;\n }\n }\n visiting.delete(id);\n visited.add(id);\n sorted.push(id);\n return null;\n };\n\n for (const id of this._resources.keys()) {\n const cycle = visit(id);\n if (cycle) {\n // Trim cycle to start from the repeated node\n const start = cycle[cycle.length - 1]!;\n const startIdx = cycle.indexOf(start);\n return { order: null, cycle: cycle.slice(startIdx) };\n }\n }\n return { order: sorted };\n }\n}\n","/** Identifies a resource in the dependency graph. */\nexport interface ResourceRef {\n readonly id: string;\n}\n\n/** A dependency edge between two resources at specific field paths. */\nexport interface DependencyEdge {\n /** Resource being read from (observed state). */\n readonly from: ResourceRef;\n /** Path in the source resource's observed data. */\n readonly fromPath: string;\n /** Resource being written to (desired state). */\n readonly to: ResourceRef;\n /** Path in the target resource's desired data. */\n readonly toPath: string;\n}\n\n/**\n * A Pending marker stored in a desired document when a ReadProxy value\n * is assigned. Carries full source info so the resolve phase knows\n * where to look for the concrete value.\n */\nconst PENDING_TAG: unique symbol = Symbol.for('xplane.pending') as unknown as typeof PENDING_TAG;\n\nexport class Pending {\n static readonly TAG = PENDING_TAG;\n readonly [PENDING_TAG] = true;\n\n constructor(\n /** The resource that owns the observed data. */\n readonly source: ResourceRef,\n /** The path within that resource's observed data. */\n readonly path: string,\n ) {}\n\n static is(value: unknown): value is Pending {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_TAG] === true\n );\n }\n}\n\n/** Metadata associated with a ReadProxy instance. */\nexport interface ReadProxyMeta {\n readonly owner: ResourceRef;\n readonly path: string;\n}\n\n// ─── PendingTemplate ─────────────────────────────────────────────────────────\n\n/**\n * A Pending-like marker for strings produced by template literals that\n * interpolate one or more unresolved ReadProxy values.\n *\n * Holds the template structure so the resolve phase can reconstruct the\n * final string once all dependency slots are available.\n *\n * Invariant: parts.length === slots.length + 1\n * result = parts[0] + resolved[0] + parts[1] + … + resolved[n-1] + parts[n]\n */\nconst PENDING_TEMPLATE_TAG: unique symbol = Symbol.for(\n 'xplane.pendingTemplate',\n) as unknown as typeof PENDING_TEMPLATE_TAG;\n\nexport class PendingTemplate {\n static readonly TAG = PENDING_TEMPLATE_TAG;\n readonly [PENDING_TEMPLATE_TAG] = true;\n\n constructor(\n /** Literal text segments between (and around) pending slots. */\n readonly parts: readonly string[],\n /** The pending slots — each maps to an entry in a resource's observed state. */\n readonly slots: ReadonlyArray<{ source: ResourceRef; path: string }>,\n ) {}\n\n static is(value: unknown): value is PendingTemplate {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_TEMPLATE_TAG] === true\n );\n }\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\nimport type { ReadProxyMeta, ResourceRef } from './types.js';\nimport { PendingTemplate } from './types.js';\n\n// ─── Token Registry ───────────────────────────────────────────────────────────\n\nexport interface TokenRegistry {\n readonly byToken: Map<string, ReadProxyMeta>;\n readonly byKey: Map<string, string>;\n counter: number;\n}\n\n/**\n * Per-run AsyncLocalStorage for the template-literal token registry.\n * Kept separate from compositionStorage (core/) to avoid circular deps.\n */\nexport const tokenRegistryStorage = new AsyncLocalStorage<TokenRegistry>();\n\nexport function createTokenRegistry(): TokenRegistry {\n return { byToken: new Map(), byKey: new Map(), counter: 0 };\n}\n\n/**\n * Get or create a stable token for a given (owner, path) pair.\n * Returns null when no registry is active (outside of a composition run).\n */\nexport function getOrCreateToken(owner: ResourceRef, path: string): string | null {\n const registry = tokenRegistryStorage.getStore();\n if (!registry) return null;\n\n const key = `${owner.id}\\0${path}`;\n const existing = registry.byKey.get(key);\n if (existing !== undefined) return existing;\n\n const token = `__pending__tpl_${registry.counter++}__`;\n registry.byToken.set(token, { owner, path });\n registry.byKey.set(key, token);\n return token;\n}\n\nexport function lookupToken(token: string): ReadProxyMeta | undefined {\n return tokenRegistryStorage.getStore()?.byToken.get(token);\n}\n\n// ─── String Processing ────────────────────────────────────────────────────────\n\nconst TEMPLATE_TOKEN_RE = /__pending__tpl_\\d+__/g;\n\n/**\n * Scan a string for pending template tokens. If any are found, calls\n * `onSlot` for each registered token and returns a PendingTemplate.\n * Returns the original string if no tokens are found or none are registered.\n */\nexport function processStringValue(\n value: string,\n onSlot: (meta: ReadProxyMeta) => void,\n): PendingTemplate | string {\n const parts: string[] = [];\n const slots: Array<{ source: ResourceRef; path: string }> = [];\n let lastIndex = 0;\n let hasSlots = false;\n\n // Reset lastIndex before iterating (regex is stateful)\n TEMPLATE_TOKEN_RE.lastIndex = 0;\n\n for (const match of value.matchAll(TEMPLATE_TOKEN_RE)) {\n const meta = lookupToken(match[0]!);\n if (!meta) continue; // token not in registry — treat as literal\n\n hasSlots = true;\n parts.push(value.slice(lastIndex, match.index!));\n slots.push({ source: meta.owner, path: meta.path });\n onSlot(meta);\n lastIndex = match.index! + match[0]!.length;\n }\n\n if (!hasSlots) return value;\n\n parts.push(value.slice(lastIndex));\n return new PendingTemplate(parts, slots);\n}\n","import { getOrCreateToken } from './token-registry.js';\nimport type { ReadProxyMeta, ResourceRef } from './types.js';\n\n/**\n * WeakMap storing metadata for ReadProxy instances.\n * This avoids polluting proxy objects with symbols.\n */\nconst proxyMeta = new WeakMap<object, ReadProxyMeta>();\n\n/** Sentinel symbol to identify ReadProxy instances. */\nconst READ_PROXY_TAG = Symbol.for('xplane.readProxy');\n\n/**\n * Check if a value is a ReadProxy.\n */\nexport function isReadProxy(value: unknown): value is object {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[READ_PROXY_TAG] === true\n );\n}\n\n/**\n * Get the metadata for a ReadProxy value.\n */\nexport function getReadProxyMeta(value: unknown): ReadProxyMeta | undefined {\n if (!isReadProxy(value)) return undefined;\n return proxyMeta.get(value as object);\n}\n\n/**\n * Creates a ReadProxy that wraps observed data.\n *\n * - Property access navigates into the data, building up the path.\n * - Missing paths return `undefined` (no placeholder proxies).\n * - The proxy carries owner + path metadata so that when it's assigned\n * to a WriteProxy, the dependency edge can be recorded.\n */\nexport function createReadProxy<T extends object>(\n target: T,\n owner: ResourceRef,\n basePath: string,\n): T {\n const proxy = new Proxy(target, {\n get(obj, prop, receiver) {\n // Identity checks\n if (prop === READ_PROXY_TAG) return true;\n if (typeof prop === 'symbol') return Reflect.get(obj, prop, receiver);\n if (prop === 'toJSON') return () => obj;\n\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const value = Reflect.get(obj, prop, receiver);\n\n if (value === undefined || value === null) {\n // Return a \"leaf\" proxy with undefined target — carries metadata\n // for dependency edge creation but resolves to undefined\n return createLeafReadProxy(owner, childPath);\n }\n\n if (typeof value === 'object') {\n // Wrap nested objects so path accumulates\n return createReadProxy(value as object, owner, childPath);\n }\n\n // Primitive — wrap in a tagged object so it can carry metadata\n // when assigned to a WriteProxy\n return createPrimitiveReadProxy(value as string | number | boolean, owner, childPath);\n },\n\n has(obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return Reflect.has(obj, prop);\n },\n });\n\n proxyMeta.set(proxy, { owner, path: basePath });\n return proxy as T;\n}\n\n/**\n * A \"leaf\" ReadProxy for paths that don't exist in observed data yet.\n * Carries metadata for edge creation. Resolves to `undefined` when\n * coerced to a primitive.\n */\nfunction createLeafReadProxy(owner: ResourceRef, path: string): object {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n const getToken = () => getOrCreateToken(owner, path) ?? `__pending__${owner.id}__${path}`;\n const proxy = new Proxy(target, {\n get(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n if (prop === Symbol.toPrimitive) return () => getToken();\n if (typeof prop === 'symbol') return undefined;\n if (prop === 'toJSON') return () => undefined;\n if (prop === 'toString') return () => getToken();\n if (prop === 'valueOf') return () => proxy;\n // Nested access on a leaf — still a leaf with extended path\n return createLeafReadProxy(owner, `${path}.${String(prop)}`);\n },\n has(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return false;\n },\n });\n proxyMeta.set(proxy, { owner, path });\n return proxy;\n}\n\n/**\n * Wraps a concrete primitive value so it carries ReadProxy metadata.\n * This allows the WriteProxy to detect it during assignment and\n * record the dependency edge, while the value itself resolves correctly.\n */\nexport function createPrimitiveReadProxy(\n value: string | number | boolean,\n owner: ResourceRef,\n path: string,\n): object {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n const proxy = new Proxy(target, {\n get(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n if (prop === Symbol.toPrimitive) return () => value;\n if (prop === 'valueOf') return () => value;\n if (prop === 'toString') return () => String(value);\n if (prop === 'toJSON') return () => value;\n if (typeof prop === 'symbol') return undefined;\n // Navigating into a primitive — leaf\n return createLeafReadProxy(owner, `${path}.${String(prop)}`);\n },\n has(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return false;\n },\n });\n proxyMeta.set(proxy, { owner, path });\n return proxy;\n}\n","import {\n createPrimitiveReadProxy,\n createReadProxy,\n getReadProxyMeta,\n isReadProxy,\n} from './read-proxy.js';\nimport { processStringValue } from './token-registry.js';\nimport { type DependencyEdge, Pending, type ResourceRef } from './types.js';\n\n/**\n * Collector that accumulates dependency edges discovered during\n * WriteProxy assignments.\n */\nexport class EdgeCollector {\n private readonly _edges: DependencyEdge[] = [];\n\n add(edge: DependencyEdge): void {\n // Deduplicate\n const exists = this._edges.some(\n (e) =>\n e.from.id === edge.from.id &&\n e.fromPath === edge.fromPath &&\n e.to.id === edge.to.id &&\n e.toPath === edge.toPath,\n );\n if (!exists) this._edges.push(edge);\n }\n\n get edges(): ReadonlyArray<DependencyEdge> {\n return this._edges;\n }\n}\n\nexport interface WriteProxyOptions {\n /** The resource that owns this desired document. */\n owner: ResourceRef;\n /** The collector to record edges into. */\n collector: EdgeCollector;\n /** Base path prefix (e.g., \"spec\" when wrapping the spec subtree). */\n basePath?: string;\n /** Optional observed state at the same path for fallback reads. */\n observed?: Record<string, unknown>;\n}\n\n/**\n * Creates a WriteProxy that wraps a desired document.\n *\n * - Writes store values in the target.\n * - When a ReadProxy value is assigned, it records a dependency edge\n * and stores a Pending marker if the value is not yet concrete.\n * - Reads return the stored value (desired-first).\n */\nexport function createWriteProxy<T extends object>(target: T, opts: WriteProxyOptions): T {\n const { owner, collector, basePath = '', observed } = opts;\n\n return new Proxy(target, {\n get(obj, prop, receiver) {\n if (typeof prop === 'symbol') return Reflect.get(obj, prop, receiver);\n if (prop === 'toJSON') return () => obj;\n\n const value = Reflect.get(obj, prop, receiver);\n\n // If the value is a nested object (not a Pending), wrap it recursively\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const childObserved =\n observed && String(prop) in observed && typeof observed[String(prop)] === 'object'\n ? (observed[String(prop)] as Record<string, unknown>)\n : undefined;\n return createWriteProxy(value as object, {\n owner,\n collector,\n basePath: childPath,\n observed: childObserved,\n });\n }\n\n // If value is undefined and observed has data at this path, fall through to ReadProxy\n if (value === undefined && observed && String(prop) in observed) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const obsValue = observed[String(prop)];\n if (typeof obsValue === 'object' && obsValue !== null) {\n return createReadProxy(obsValue as object, owner, childPath);\n }\n if (obsValue !== undefined && obsValue !== null) {\n return createPrimitiveReadProxy(obsValue as string | number | boolean, owner, childPath);\n }\n }\n\n // If value is undefined and observed doesn't have it either, return a leaf ReadProxy\n // so that cross-resource references create proper dependency edges and Pending markers\n if (value === undefined && observed !== undefined) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n return createReadProxy(Object.create(null) as object, owner, childPath);\n }\n\n return value;\n },\n\n set(obj, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(obj, prop, value);\n\n const targetPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n\n // Check if the value being assigned is a ReadProxy\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value);\n if (meta && meta.owner.id !== owner.id) {\n // Record dependency edge\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: targetPath,\n });\n\n // Try to extract a concrete value via Symbol.toPrimitive\n const primitive = tryExtractPrimitive(value);\n if (primitive !== undefined) {\n // The value is already concrete (primitive from observed data)\n return Reflect.set(obj, prop, primitive);\n }\n\n // Not concrete — store a Pending marker\n return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));\n }\n\n // Self-reference or XR — try to extract value\n const primitive = tryExtractPrimitive(value);\n if (primitive !== undefined) {\n return Reflect.set(obj, prop, primitive);\n }\n\n // XR leaf with no value — store Pending\n if (meta) {\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: targetPath,\n });\n return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));\n }\n }\n\n // String with pending template tokens\n if (typeof value === 'string') {\n const processed = processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: targetPath });\n });\n return Reflect.set(obj, prop, processed);\n }\n\n // Plain object — deep-process to catch nested ReadProxy values\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n const processed = deepProcessValue(value, owner, targetPath, collector);\n return Reflect.set(obj, prop, processed);\n }\n\n return Reflect.set(obj, prop, value);\n },\n\n deleteProperty(obj, prop) {\n return Reflect.deleteProperty(obj, prop);\n },\n }) as T;\n}\n\n/**\n * Try to extract a primitive value from a ReadProxy via Symbol.toPrimitive.\n * Returns `undefined` if the proxy represents a non-existent (leaf) value.\n */\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\n/**\n * Deep-process a plain object/array being assigned to a WriteProxy.\n * Replaces any nested ReadProxy values with Pending markers or concrete values.\n */\nfunction deepProcessValue(\n value: unknown,\n owner: ResourceRef,\n basePath: string,\n collector: EdgeCollector,\n): unknown {\n if (value === null || value === undefined) return value;\n\n if (typeof value === 'string') {\n return processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: basePath });\n });\n }\n\n if (typeof value !== 'object') return value;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value)!;\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: basePath,\n });\n const primitive = tryExtractPrimitive(value as object);\n if (primitive !== undefined) return primitive;\n return new Pending(meta.owner, meta.path);\n }\n\n if (Array.isArray(value as object)) {\n return (value as unknown[]).map((item, i) =>\n deepProcessValue(item, owner, `${basePath}[${i}]`, collector),\n );\n }\n\n // Plain object — recurse\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = deepProcessValue(val, owner, `${basePath}.${key}`, collector);\n }\n return result;\n}\n","import { Construct } from 'constructs';\n\nimport type { ReadyCheck, ReadyCheckFn } from '../readiness/index.js';\nimport {\n createPrimitiveReadProxy,\n createReadProxy,\n createWriteProxy,\n type DependencyGraph,\n type EdgeCollector,\n getReadProxyMeta,\n isReadProxy,\n Pending,\n type ResourceRef,\n} from '../tracking/index.js';\nimport { processStringValue } from '../tracking/token-registry.js';\nimport { compositionStorage } from './context.js';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/** Minimal shape for a Kubernetes resource — only apiVersion + kind required. */\nexport interface KubernetesResource {\n apiVersion: string;\n kind: string;\n metadata?: {\n name?: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n/** Props passed to the Resource constructor — becomes the desired document. */\nexport interface ResourceProps {\n apiVersion: string;\n kind: string;\n [key: string]: unknown;\n}\n\n/** Framework configuration accessible via `resource.resource`. */\nexport interface ResourceConfig {\n autoReady: boolean;\n addReadyCheck(fn: ReadyCheckFn, priority?: number): void;\n}\n\n/** Internal metadata stored per Resource (not exposed on the proxy). */\ninterface ResourceInternals {\n /** Unique reference for the dependency graph. */\n ref: ResourceRef;\n /** The desired document (what the user wrote). */\n desired: Record<string, unknown>;\n /** The observed document (populated by the hydrate phase). */\n observed: Record<string, unknown>;\n /** Whether this is an external (existing) resource. */\n external: boolean;\n /** For external resources: the lookup key. */\n externalRef?: ExternalResourceRef;\n /** Framework config. */\n config: ResourceConfig;\n /** Custom readiness checks registered by the composition author. */\n readyChecks: ReadyCheck[];\n /** The dependency graph. */\n graph: DependencyGraph;\n /** The edge collector. */\n collector: EdgeCollector;\n}\n\nexport interface ExternalResourceRef {\n apiVersion: string;\n kind: string;\n name: unknown;\n namespace?: string;\n refKey: string;\n}\n\n// ─── WeakMap stores for internal data ─────────────────────────────────────────\n\nconst internals = new WeakMap<Resource, ResourceInternals>();\n\n// ─── Resource class ───────────────────────────────────────────────────────────\n\n/**\n * A Kubernetes resource within a Composition.\n *\n * The Resource instance acts as a \"desired-first, fallback-to-observed\" proxy:\n * - Reading a path that exists in the desired document returns the desired value.\n * - Reading a path that does NOT exist in desired falls through to a tracked\n * ReadProxy over observed state (creates dependency edges).\n * - Writing always goes to the desired document.\n *\n * The only reserved properties are `node` (from Construct) and `resource`\n * (framework config namespace).\n */\nexport class Resource extends Construct {\n readonly resource: ResourceConfig;\n declare metadata: {\n name?: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n\n constructor(scope: Construct, id: string, props: ResourceProps) {\n super(scope, id);\n\n const graph = scope.node.tryGetContext('xplane:graph') as DependencyGraph;\n const collector = scope.node.tryGetContext('xplane:collector') as EdgeCollector;\n\n if (!graph || !collector) {\n throw new Error('Resource must be created within a Composition tree.');\n }\n\n const ref: ResourceRef = { id: this.node.path };\n graph.addResource(ref);\n\n const readyChecks: ReadyCheck[] = [];\n const config: ResourceConfig = {\n autoReady: true,\n addReadyCheck(fn: ReadyCheckFn, priority = 50) {\n readyChecks.push({ fn, priority });\n },\n };\n this.resource = config;\n\n // Process props — deep scan for ReadProxy values in the desired doc\n const desired = processDesiredProps(props, ref, collector);\n\n const internal: ResourceInternals = {\n ref,\n desired,\n observed: {},\n external: false,\n config,\n readyChecks,\n graph,\n collector,\n };\n internals.set(this, internal);\n\n // Return a proxy over `this` that implements the desired-first/observed-fallback\n const proxy = createResourceProxy(this, internal);\n\n // Patch the construct tree so node.children / findAll() yield the proxy\n // instead of the raw instance (which was registered during super()).\n // biome-ignore lint/suspicious/noExplicitAny: accessing private _children is intentional\n (scope.node as any)._children[this.node.id] = proxy;\n\n // biome-ignore lint/correctness/noConstructorReturn: Proxy wrapping is intentional\n return proxy;\n }\n\n /**\n * Look up an existing cluster resource by name.\n * Returns a Resource that only has observed state (no desired output).\n *\n * The `name` parameter accepts either a plain string or a PrimitiveReadProxy\n * (returned when reading a tracked property like `ns.metadata.labels['x']`).\n * Proxies are coerced to their underlying string via `Symbol.toPrimitive`.\n */\n static fromExistingByName(\n scope: Construct,\n apiVersion: string,\n kind: string,\n name: unknown,\n namespace?: string,\n ): Resource {\n const resolvedName = coerceToString(name);\n const refKey = computeRefKey(apiVersion, kind, resolvedName, namespace);\n const id = `__existing__${refKey.replace(/\\//g, '_')}`;\n\n const instance = new Resource(scope, id, { apiVersion, kind });\n const internal = internals.get(instance)!;\n internal.external = true;\n internal.externalRef = { apiVersion, kind, name: resolvedName ?? name, namespace, refKey };\n\n // Pre-hydrate from context if observed data is already available (from a prior iteration)\n const ctx = compositionStorage.getStore();\n if (ctx) {\n const observed = ctx.requiredResources.get(refKey);\n if (observed) {\n Object.assign(internal.observed, observed);\n }\n }\n\n return instance;\n }\n\n /**\n * Generate a deterministic unique name based on the XR identity and construct path.\n * Useful for resource fields that need unique names (e.g., AWS resource names).\n */\n static uniqueName(\n scope: Construct,\n options: {\n maxLength?: number;\n separator?: string;\n allowedPattern?: RegExp;\n extra?: string;\n } = {},\n ): string {\n const maxLength = options.maxLength ?? 63;\n const separator = options.separator ?? '-';\n const allowedPattern = options.allowedPattern ?? /[^a-zA-Z0-9]/g;\n const escapedSep = separator.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const collapseRe = new RegExp(`${escapedSep}+`, 'g');\n\n const clean = (s: string) =>\n s\n .replace(/\\s+/g, '')\n .replace(allowedPattern, separator)\n .replace(collapseRe, separator)\n .replace(new RegExp(`^${escapedSep}|${escapedSep}$`, 'g'), '');\n\n const xrMeta = scope.node.tryGetContext('xplane:xr-meta') as\n | { name?: string; namespace?: string }\n | undefined;\n\n const parts: string[] = [];\n if (xrMeta?.namespace) parts.push(clean(xrMeta.namespace));\n if (xrMeta?.name) parts.push(clean(xrMeta.name));\n for (const s of scope.node.scopes.slice(1)) {\n const c = clean(s.node.id);\n if (c) parts.push(c);\n }\n if (options.extra) {\n const c = clean(options.extra);\n if (c) parts.push(c);\n }\n\n const full = parts.join(separator);\n const hash = shortHash(full);\n const withHash = `${full}${separator}${hash}`;\n\n if (withHash.length <= maxLength) return withHash;\n const prefix = full.slice(0, maxLength - hash.length - separator.length);\n return `${prefix}${separator}${hash}`;\n }\n\n /**\n * Like {@link uniqueName} but produces names compliant with RFC 1123 DNS labels:\n * lowercase alphanumeric characters and hyphens only, starting and ending with\n * an alphanumeric character. Suitable for use as Kubernetes resource names.\n */\n static uniqueNameRfc1123(\n scope: Construct,\n options: {\n maxLength?: number;\n extra?: string;\n } = {},\n ): string {\n const maxLength = options.maxLength ?? 63;\n\n const clean = (s: string) =>\n s\n .toLowerCase()\n .replace(/\\s+/g, '')\n .replace(/[^a-z0-9-]/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n\n const xrMeta = scope.node.tryGetContext('xplane:xr-meta') as\n | { name?: string; namespace?: string }\n | undefined;\n\n const parts: string[] = [];\n if (xrMeta?.namespace) parts.push(clean(xrMeta.namespace));\n if (xrMeta?.name) parts.push(clean(xrMeta.name));\n for (const s of scope.node.scopes.slice(1)) {\n const c = clean(s.node.id);\n if (c) parts.push(c);\n }\n if (options.extra) {\n const c = clean(options.extra);\n if (c) parts.push(c);\n }\n\n const full = parts.join('-');\n const hash = shortHash(full);\n const withHash = `${full}-${hash}`;\n\n if (withHash.length <= maxLength) return withHash;\n const prefix = full.slice(0, maxLength - hash.length - 1);\n const trimmedPrefix = prefix.replace(/-+$/, '');\n return trimmedPrefix ? `${trimmedPrefix}-${hash}` : hash;\n }\n}\n\n// ─── Internal accessors (used by pipeline phases) ─────────────────────────────\n\nexport function getResourceInternals(resource: Resource): ResourceInternals {\n const internal = internals.get(resource);\n if (!internal) throw new Error('Resource internals not found');\n return internal;\n}\n\nexport function getResourceRef(resource: Resource): ResourceRef {\n return getResourceInternals(resource).ref;\n}\n\nexport function getDesiredDocument(resource: Resource): Record<string, unknown> {\n return getResourceInternals(resource).desired;\n}\n\nexport function getObservedDocument(resource: Resource): Record<string, unknown> {\n return getResourceInternals(resource).observed;\n}\n\nexport function hydrateObserved(resource: Resource, data: Record<string, unknown>): void {\n const internal = getResourceInternals(resource);\n Object.assign(internal.observed, data);\n}\n\nexport function isExternal(resource: Resource): boolean {\n return getResourceInternals(resource).external;\n}\n\nexport function getExternalRef(resource: Resource): ExternalResourceRef | undefined {\n return getResourceInternals(resource).externalRef;\n}\n\nexport function getReadyChecks(resource: Resource): ReadyCheck[] {\n return getResourceInternals(resource).readyChecks;\n}\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\n/**\n * Coerce a value to a string, handling PrimitiveReadProxy objects that wrap\n * primitive values behind a `Symbol.toPrimitive` method.\n * Returns `undefined` if the value cannot be resolved to a string.\n */\nfunction coerceToString(value: unknown): string | undefined {\n if (typeof value === 'string') return value;\n if (\n value != null &&\n typeof (value as { [Symbol.toPrimitive]?: unknown })[Symbol.toPrimitive] === 'function'\n ) {\n return String(value);\n }\n return undefined;\n}\n\nexport function computeRefKey(\n apiVersion: string,\n kind: string,\n name: string | undefined,\n namespace?: string,\n): string {\n const namePart = name ?? '__unresolved__';\n if (namespace) return `${apiVersion}/${kind}/${namespace}/${namePart}`;\n return `${apiVersion}/${kind}/${namePart}`;\n}\n\nfunction shortHash(s: string): string {\n let h = 5381;\n for (let i = 0; i < s.length; i++) {\n h = ((h << 5) + h) ^ s.charCodeAt(i);\n h = h >>> 0;\n }\n return h.toString(16).padStart(8, '0');\n}\n\n/**\n * Process the desired props — deep-scan for ReadProxy values and replace them\n * with Pending markers (recording edges in the collector).\n */\nfunction processDesiredProps(\n props: ResourceProps,\n owner: ResourceRef,\n collector: EdgeCollector,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n result[key] = processValue(value, owner, key, collector);\n }\n return result;\n}\n\nfunction processValue(\n value: unknown,\n owner: ResourceRef,\n path: string,\n collector: EdgeCollector,\n): unknown {\n if (value === null || value === undefined) return value;\n\n if (typeof value === 'string') {\n return processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: path });\n });\n }\n\n if (typeof value !== 'object') return value;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value)!;\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: path,\n });\n // Try to get concrete value\n const prim = tryExtractPrimitive(value);\n if (prim !== undefined) return prim;\n return new Pending(meta.owner, meta.path);\n }\n\n if (Array.isArray(value as object)) {\n return (value as unknown[]).map((item, i) =>\n processValue(item, owner, `${path}[${i}]`, collector),\n );\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = processValue(val, owner, `${path}.${key}`, collector);\n }\n return result;\n}\n\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\n/**\n * Creates the \"desired-first, fallback-to-observed\" proxy around a Resource.\n */\nfunction createResourceProxy(resource: Resource, internal: ResourceInternals): Resource {\n const { ref, desired, collector } = internal;\n\n const proxy = new Proxy(resource, {\n get(target, prop, receiver) {\n // Framework reserved properties\n if (prop === 'node') return Reflect.get(target, prop, receiver);\n if (prop === 'resource') return Reflect.get(target, prop, receiver);\n if (typeof prop === 'symbol') return Reflect.get(target, prop, receiver);\n\n // Prototype methods and inherited Construct methods (e.g. .with(), .toString())\n if (prop === 'constructor') return Reflect.get(target, prop, receiver);\n const protoValue = Reflect.get(target, prop, receiver);\n if (typeof protoValue === 'function') return protoValue.bind(proxy);\n\n // Check desired first\n if (prop in desired) {\n const value = desired[String(prop)];\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n // Return a WriteProxy so nested writes go to desired\n // Pass observed at the same path for fallback reads\n const observed = internal.observed;\n const observedAtPath =\n String(prop) in observed && typeof observed[String(prop)] === 'object'\n ? (observed[String(prop)] as Record<string, unknown>)\n : {};\n return createWriteProxy(value as object, {\n owner: ref,\n collector,\n basePath: String(prop),\n observed: observedAtPath,\n });\n }\n return value;\n }\n\n // Fallback to observed via ReadProxy\n const observed = internal.observed;\n if (String(prop) in observed) {\n const value = observed[String(prop)];\n if (typeof value === 'object' && value !== null) {\n return createReadProxy(value as object, ref, String(prop));\n }\n // Primitive observed value — wrap in ReadProxy for tracking\n return createPrimitiveReadProxyFromResource(value, ref, String(prop));\n }\n\n // Path exists in neither — return a lazy-init proxy that behaves as a\n // ReadProxy for reads but auto-initializes the path in desired on write.\n return createLazyInitProxy(desired, ref, collector, String(prop));\n },\n\n set(target, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(target, prop, value);\n if (prop === 'resource') return Reflect.set(target, prop, value);\n\n // All writes go to desired, processing ReadProxy values\n const path = String(prop);\n desired[path] = processValue(value, ref, path, collector);\n return true;\n },\n\n has(target, prop) {\n if (typeof prop === 'symbol') return Reflect.has(target, prop);\n if (prop === 'node' || prop === 'resource') return true;\n return prop in desired || prop in internal.observed;\n },\n }) as Resource;\n\n // Store internal mapping for the proxy too, so internals.get(proxy) works\n internals.set(proxy, internal);\n return proxy;\n}\n\n/**\n * Wrap a primitive observed value so it carries ReadProxy metadata\n * for dependency tracking when assigned elsewhere.\n */\nfunction createPrimitiveReadProxyFromResource(\n value: unknown,\n owner: ResourceRef,\n path: string,\n): unknown {\n if (value === null || value === undefined) return value;\n return createPrimitiveReadProxy(value as string | number | boolean, owner, path);\n}\n\n/**\n * Creates a proxy for a path that exists in neither desired nor observed.\n * - Reading nested properties returns ReadProxy leaves (for dependency tracking).\n * - Writing a nested property auto-initializes the path in desired and stores the value.\n */\nfunction createLazyInitProxy(\n desired: Record<string, unknown>,\n owner: ResourceRef,\n collector: EdgeCollector,\n basePath: string,\n): object {\n const readProxy = createReadProxy({} as object, owner, basePath);\n\n return new Proxy(readProxy as object, {\n get(target, prop, receiver) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop, receiver);\n // Delegate reads to the ReadProxy (for tracking)\n return Reflect.get(target, prop, receiver);\n },\n\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n // Auto-initialize the parent object in desired\n let container = desired[basePath] as Record<string, unknown> | undefined;\n if (!container || typeof container !== 'object') {\n container = {};\n desired[basePath] = container;\n }\n container[String(prop)] = processValue(\n value,\n owner,\n `${basePath}.${String(prop)}`,\n collector,\n );\n return true;\n },\n });\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { XplaneLogger } from './types.js';\n\nconst noopLogger: XplaneLogger = {\n debug() {},\n info() {},\n warn() {},\n};\n\nconst loggerStorage = new AsyncLocalStorage<XplaneLogger>();\n\n/**\n * Get the current logger from async context.\n * Returns a no-op logger if none has been set (silent by default).\n */\nexport function getLogger(): XplaneLogger {\n return loggerStorage.getStore() ?? noopLogger;\n}\n\n/**\n * Run a function with a logger available in async context.\n * All code within `fn` (and any nested async calls) can access\n * the logger via `getLogger()`.\n */\nexport function withLogger<T>(logger: XplaneLogger, fn: () => T): T {\n return loggerStorage.run(logger, fn);\n}\n","import {\n getDesiredDocument,\n getExternalRef,\n getObservedDocument,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { Pending } from '../tracking/index.js';\n\nimport type { DiagnosticReport, PipelineState } from './types.js';\n\n/**\n * DIAGNOSE phase: produce structured diagnostics for blocked resources.\n *\n * For each resource classified as 'blocked':\n * - Find all Pending markers in the desired document\n * - Report what they're waiting on (source resource + path)\n *\n * For circular dependencies (detected in sequence phase):\n * - Produce a 'cycle' diagnostic with the full cycle path\n */\nexport function diagnose(state: PipelineState): PipelineState {\n const diagnostics: DiagnosticReport[] = [];\n\n // Check for cycles from the graph\n const sortResult = state.graph.topologicalSort();\n if (sortResult.order === null && sortResult.cycle) {\n const firstCycleMember = sortResult.cycle[0];\n if (firstCycleMember) {\n diagnostics.push({\n resource: firstCycleMember,\n reason: 'cycle',\n cycle: sortResult.cycle,\n });\n }\n }\n\n // Report external resources that were required but not found\n for (const resource of state.resources) {\n if (!isExternal(resource)) continue;\n const ref = getExternalRef(resource);\n if (!ref) continue;\n const observed = getObservedDocument(resource);\n if (Object.keys(observed).length > 0) continue; // hydrated, no problem\n const nameDisplay =\n typeof ref.name === 'string' ? ref.name : ref.name == null ? '(unresolved)' : '(unresolved)';\n const nsDisplay = ref.namespace ? ` in namespace '${ref.namespace}'` : '';\n diagnostics.push({\n resource: getResourceRef(resource).id,\n reason: 'not-found',\n detail: `External resource ${ref.apiVersion}/${ref.kind} '${nameDisplay}'${nsDisplay} was required but not found by Crossplane`,\n });\n }\n\n // For each blocked resource, find pending paths\n const pendingDiagnostics: DiagnosticReport[] = [];\n for (const resource of state.resources) {\n if (isExternal(resource)) continue;\n\n const ref = getResourceRef(resource);\n const classification = state.classification.get(ref.id);\n if (classification !== 'blocked') continue;\n\n // Skip if already reported as cycle member\n if (sortResult.order === null && sortResult.cycle?.includes(ref.id)) continue;\n\n const desired = getDesiredDocument(resource);\n const pendingPaths = findPendingPaths(desired, '');\n\n if (pendingPaths.length > 0) {\n pendingDiagnostics.push({\n resource: ref.id,\n reason: 'pending',\n pendingPaths,\n });\n }\n }\n\n // Filter out cascading diagnostics: only keep pending diagnostics that have\n // at least one dependency that is NOT itself blocked or not-found.\n // This surfaces only root causes rather than the full dependency cascade.\n const notFoundIds = new Set(\n diagnostics.filter((d) => d.reason === 'not-found').map((d) => d.resource),\n );\n const blockedIds = new Set(pendingDiagnostics.map((d) => d.resource));\n\n for (const diag of pendingDiagnostics) {\n const isRootCause = diag.pendingPaths?.some((p) => {\n const dep = p.waitingOn.resource;\n // If waiting on something that isn't blocked or not-found, this IS a root cause\n return !blockedIds.has(dep) && !notFoundIds.has(dep);\n });\n if (isRootCause) {\n diagnostics.push(diag);\n }\n }\n\n return { ...state, diagnostics };\n}\n\n/**\n * Recursively find all Pending markers in a document and report their source.\n */\nfunction findPendingPaths(\n obj: unknown,\n basePath: string,\n): Array<{ path: string; waitingOn: { resource: string; path: string } }> {\n const results: Array<{ path: string; waitingOn: { resource: string; path: string } }> = [];\n\n if (obj === null || obj === undefined) return results;\n if (Pending.is(obj)) {\n results.push({\n path: basePath,\n waitingOn: { resource: obj.source.id, path: obj.path },\n });\n return results;\n }\n if (typeof obj !== 'object') return results;\n\n if (Array.isArray(obj)) {\n for (let i = 0; i < obj.length; i++) {\n const childPath = basePath ? `${basePath}[${i}]` : `[${i}]`;\n results.push(...findPendingPaths(obj[i], childPath));\n }\n return results;\n }\n\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n const childPath = basePath ? `${basePath}.${key}` : key;\n results.push(...findPendingPaths(value, childPath));\n }\n return results;\n}\n","import { getXrDesiredStatus } from '../core/composition.js';\nimport {\n getDesiredDocument,\n getObservedDocument,\n getReadyChecks,\n getResourceInternals,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { getReadProxyMeta, isReadProxy } from '../tracking/index.js';\nimport { PendingTemplate } from '../tracking/types.js';\n\nimport type { EmittedResource, PipelineState } from './types.js';\n\n/**\n * EMIT phase: serialize each resource classified as 'emit' into a plain\n * Kubernetes resource document ready for Crossplane.\n *\n * Also extracts the XR desired status from this.xr.status assignments.\n */\nexport function emit(state: PipelineState): PipelineState {\n const emitted: EmittedResource[] = [];\n\n for (const resource of state.resources) {\n if (isExternal(resource)) continue;\n\n const ref = getResourceRef(resource);\n const classification = state.classification.get(ref.id);\n if (classification !== 'emit') continue;\n\n const internal = getResourceInternals(resource);\n const desired = getDesiredDocument(resource);\n\n // Strip the construct path prefix to get the resource name\n // The name is the full construct path minus the root \"Composition/\" prefix\n const name = ref.id.startsWith('Composition/') ? ref.id.slice('Composition/'.length) : ref.id;\n\n emitted.push({\n name,\n document: deepClean(desired),\n autoReady: internal.config.autoReady,\n readyChecks: getReadyChecks(resource),\n });\n }\n\n // Extract XR status and resolve any ReadProxy values using observed data\n const resourceById = new Map(state.resources.map((r) => [getResourceRef(r).id, r]));\n const rawStatus = getXrDesiredStatus(state.composition);\n const xrStatusPatches = resolveXrStatus(rawStatus, resourceById);\n\n return { ...state, emitted, xrStatusPatches };\n}\n\n/**\n * Deep-clone an object, stripping any remaining framework internals.\n * This produces a clean JSON-serializable Kubernetes document.\n */\nfunction deepClean(obj: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n result[key] = cleanValue(value);\n }\n\n return result;\n}\n\nfunction cleanValue(value: unknown): unknown {\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n if (PendingTemplate.is(value)) {\n // Should never reach emit — indicates a bug in the pipeline\n throw new Error(\n `PendingTemplate reached emit phase — resource should have been classified as blocked. Parts: ${JSON.stringify(value.parts)}`,\n );\n }\n\n if (Array.isArray(value)) {\n return value.map(cleanValue);\n }\n\n // Plain objects — recurse\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = cleanValue(val);\n }\n return result;\n}\n\n/**\n * Resolve ReadProxy values in XR status using observed resource data.\n * This is needed because XR status is written at construction time (before hydration),\n * so read proxy references need to be resolved post-hydration.\n */\nfunction resolveXrStatus(\n status: Record<string, unknown>,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(status)) {\n const resolved = resolveStatusValue(value, resourceById);\n if (resolved !== undefined) {\n result[key] = resolved;\n }\n }\n return result;\n}\n\nfunction resolveStatusValue(\n value: unknown,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): unknown {\n if (value === null || value === undefined) return undefined;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value);\n if (!meta) return undefined;\n\n // Try to extract a concrete primitive (already resolved read proxy)\n const prim = tryExtractPrimitive(value as object);\n if (prim !== undefined) return prim;\n\n // Leaf proxy — try to resolve from observed data\n const resource = resourceById.get(meta.owner.id);\n if (!resource) return undefined;\n const observed = getObservedDocument(resource);\n return getNestedValue(observed, meta.path);\n }\n\n if (Array.isArray(value)) {\n return value.map((v) => resolveStatusValue(v, resourceById)).filter((v) => v != null);\n }\n\n if (typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const resolved = resolveStatusValue(v, resourceById);\n if (resolved !== undefined) {\n out[k] = resolved;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n }\n\n return value;\n}\n\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values — skip them\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split('.');\n let current: unknown = obj;\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n","import { getExternalRef, hydrateObserved, isExternal } from '../core/resource.js';\n\nimport type { PipelineState } from './types.js';\n\n/**\n * HYDRATE phase: feed observed state from Crossplane into each resource.\n *\n * - Composed resources are matched by their construct path (resource name).\n * - External resources are matched by their refKey.\n */\nexport function hydrate(state: PipelineState): PipelineState {\n for (const resource of state.resources) {\n if (isExternal(resource)) {\n const ref = getExternalRef(resource);\n if (ref) {\n const observed = state.observedRequired.get(ref.refKey);\n if (observed) {\n hydrateObserved(resource, observed);\n }\n }\n } else {\n // Match by construct path\n const name = resource.node.path;\n const observed = state.observedComposed.get(name);\n if (observed) {\n hydrateObserved(resource, observed);\n }\n }\n }\n\n return state;\n}\n","import { getDesiredDocument, getObservedDocument, getResourceRef } from '../core/resource.js';\nimport { Pending, PendingTemplate } from '../tracking/index.js';\n\nimport type { PipelineState } from './types.js';\n\n/**\n * RESOLVE phase: walk dependency edges and replace Pending markers\n * with concrete values from observed state where available.\n *\n * For each resource's desired document, recursively find Pending values.\n * Look up the source resource's observed state at the source path.\n * If concrete → replace. If not available → leave Pending in place.\n */\nexport function resolve(state: PipelineState): PipelineState {\n // Build a lookup: resource id → Resource instance\n const resourceById = new Map(state.resources.map((r) => [getResourceRef(r).id, r]));\n\n for (const resource of state.resources) {\n const desired = getDesiredDocument(resource);\n resolvePending(desired, resourceById);\n }\n\n return state;\n}\n\n/**\n * Recursively walk an object and resolve any Pending markers.\n */\nfunction resolvePending(\n obj: Record<string, unknown>,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): void {\n for (const [key, value] of Object.entries(obj)) {\n if (Pending.is(value)) {\n const sourceResource = resourceById.get(value.source.id);\n if (sourceResource) {\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, value.path);\n if (resolved !== undefined) {\n obj[key] = resolved;\n }\n // else: leave Pending in place — still unresolved\n }\n } else if (PendingTemplate.is(value)) {\n const resolved = resolvePendingTemplate(value, resourceById);\n if (resolved !== undefined) obj[key] = resolved;\n } else if (Array.isArray(value)) {\n resolveArray(value, resourceById);\n } else if (value !== null && typeof value === 'object') {\n resolvePending(value as Record<string, unknown>, resourceById);\n }\n }\n}\n\nfunction resolveArray(\n arr: unknown[],\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): void {\n for (let i = 0; i < arr.length; i++) {\n const value = arr[i];\n if (Pending.is(value)) {\n const sourceResource = resourceById.get(value.source.id);\n if (sourceResource) {\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, value.path);\n if (resolved !== undefined) {\n arr[i] = resolved;\n }\n }\n } else if (PendingTemplate.is(value)) {\n const resolved = resolvePendingTemplate(value, resourceById);\n if (resolved !== undefined) arr[i] = resolved;\n } else if (Array.isArray(value)) {\n resolveArray(value, resourceById);\n } else if (value !== null && typeof value === 'object') {\n resolvePending(value as Record<string, unknown>, resourceById);\n }\n }\n}\n\n/**\n * Get a nested value from an object by dot-separated path.\n */\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const segments = path.split('.');\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (current === null || current === undefined) return undefined;\n if (typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n\n return current;\n}\n\n/**\n * Attempt to resolve all slots of a PendingTemplate.\n * Returns the reconstructed string if all slots resolve, undefined otherwise.\n */\nfunction resolvePendingTemplate(\n template: PendingTemplate,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): string | undefined {\n const values: string[] = [];\n for (const slot of template.slots) {\n const sourceResource = resourceById.get(slot.source.id);\n if (!sourceResource) return undefined;\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, slot.path);\n if (resolved === undefined || resolved === null) return undefined;\n values.push(String(resolved));\n }\n let result = template.parts[0]!;\n for (let i = 0; i < values.length; i++) {\n result += values[i] + template.parts[i + 1]!;\n }\n return result;\n}\n","import { getDesiredDocument, getResourceRef, isExternal } from '../core/resource.js';\nimport { Pending, PendingTemplate } from '../tracking/index.js';\n\nimport type { PipelineState, ResourceClassification } from './types.js';\n\n/**\n * SEQUENCE phase: topological sort and classification.\n *\n * - Runs topological sort on the dependency graph.\n * - Classifies each resource as 'emit', 'blocked', or 'external'.\n * - A resource is 'blocked' if it still has Pending markers in its desired document.\n * - External resources are classified as 'external' (never emitted).\n * - Circular dependencies are detected via the graph's topological sort.\n */\nexport function sequence(state: PipelineState): PipelineState {\n const classification = new Map<string, ResourceClassification>();\n\n // Run topological sort for cycle detection\n const sortResult = state.graph.topologicalSort();\n\n // Classify each resource\n for (const resource of state.resources) {\n const ref = getResourceRef(resource);\n\n if (isExternal(resource)) {\n classification.set(ref.id, 'external');\n continue;\n }\n\n // Check if this resource has any remaining Pending markers\n const desired = getDesiredDocument(resource);\n const hasPending = containsPending(desired);\n\n if (hasPending) {\n classification.set(ref.id, 'blocked');\n } else {\n classification.set(ref.id, 'emit');\n }\n }\n\n // If there's a cycle, mark all cycle members as blocked\n if (sortResult.order === null && sortResult.cycle) {\n for (const id of sortResult.cycle) {\n if (classification.get(id) !== 'external') {\n classification.set(id, 'blocked');\n }\n }\n }\n\n return { ...state, classification };\n}\n\n/**\n * Recursively check if an object contains any Pending markers.\n */\nfunction containsPending(obj: unknown): boolean {\n if (obj === null || obj === undefined) return false;\n if (Pending.is(obj)) return true;\n if (PendingTemplate.is(obj)) return true;\n if (typeof obj !== 'object') return false;\n\n if (Array.isArray(obj)) {\n return obj.some(containsPending);\n }\n\n for (const value of Object.values(obj as Record<string, unknown>)) {\n if (containsPending(value)) return true;\n }\n return false;\n}\n","import type { Composition } from '../core/composition.js';\nimport type { Resource } from '../core/resource.js';\n\nimport { diagnose } from './diagnose.js';\nimport { emit } from './emit.js';\nimport { hydrate } from './hydrate.js';\nimport { resolve } from './resolve.js';\nimport { sequence } from './sequence.js';\nimport type { PipelineState } from './types.js';\n\nexport { diagnose } from './diagnose.js';\nexport { emit } from './emit.js';\nexport { hydrate } from './hydrate.js';\nexport { resolve } from './resolve.js';\nexport { sequence } from './sequence.js';\nexport type {\n DiagnosticReport,\n EmittedResource,\n PipelineState,\n ResourceClassification,\n} from './types.js';\n\n/**\n * Input to the pipeline — provided by the handler or simulator.\n */\nexport interface PipelineInput {\n /** The constructed Composition instance. */\n composition: Composition;\n /** Observed composed resources from Crossplane (keyed by resource name). */\n observedComposed: ReadonlyMap<string, Record<string, unknown>>;\n /** Observed existing/required resources (keyed by refKey). */\n observedRequired: ReadonlyMap<string, Record<string, unknown>>;\n}\n\n/**\n * Run the full rendering pipeline.\n *\n * Phases: hydrate → resolve → sequence → diagnose → emit\n */\nexport function runPipeline(input: PipelineInput): PipelineState {\n const resources = collectResources(input.composition);\n\n const initialState: PipelineState = {\n composition: input.composition,\n resources,\n graph: input.composition.graph,\n observedComposed: input.observedComposed,\n observedRequired: input.observedRequired,\n classification: new Map(),\n diagnostics: [],\n emitted: [],\n xrStatusPatches: {},\n };\n\n // Run phases sequentially — each transforms the state\n let state = initialState;\n state = hydrate(state);\n state = resolve(state);\n state = sequence(state);\n state = diagnose(state);\n state = emit(state);\n\n return state;\n}\n\n/**\n * Collect all Resource instances from the composition's construct tree.\n */\nfunction collectResources(composition: Composition): Resource[] {\n const resources: Resource[] = [];\n collectFromNode(composition, resources);\n return resources;\n}\n\nfunction collectFromNode(construct: import('constructs').Construct, resources: Resource[]): void {\n for (const child of construct.node.children) {\n // Check if it's a Resource (has our internals)\n if (isResourceInstance(child)) {\n resources.push(child as Resource);\n }\n // Recurse into children\n collectFromNode(child, resources);\n }\n}\n\nfunction isResourceInstance(obj: unknown): obj is Resource {\n if (obj === null || typeof obj !== 'object') return false;\n const r = obj as Record<string, unknown>;\n if (!('resource' in r) || r.resource === null || typeof r.resource !== 'object') return false;\n return 'autoReady' in (r.resource as object);\n}\n","import type { ReadyCheck } from './types.js';\n\n/**\n * Checks if the resource has a `Ready` condition with status `True`.\n */\nexport function conditionReady(observed: Record<string, unknown>): boolean | undefined {\n const status = observed.status as Record<string, unknown> | undefined;\n const conditions = status?.conditions as Array<Record<string, unknown>> | undefined;\n if (!conditions || !Array.isArray(conditions)) return undefined;\n\n const ready = conditions.find((c) => c.type === 'Ready');\n if (!ready) return undefined;\n\n return ready.status === 'True';\n}\n\n/**\n * Checks if the resource has `status.ready === true`.\n */\nexport function statusReady(observed: Record<string, unknown>): boolean | undefined {\n const status = observed.status as Record<string, unknown> | undefined;\n if (status === undefined) return undefined;\n if (!('ready' in status)) return undefined;\n\n return status.ready === true;\n}\n\n/**\n * Fallback: resource exists in observed state → ready.\n * Always returns `true` (only called when observed is defined).\n */\nexport function exists(_observed: Record<string, unknown>): boolean {\n return true;\n}\n\n/**\n * Built-in default readiness checks, appended at low priority.\n */\nexport const DEFAULT_CHECKS: ReadyCheck[] = [\n { fn: conditionReady, priority: 100, name: 'conditionReady' },\n { fn: statusReady, priority: 200, name: 'statusReady' },\n { fn: exists, priority: 1000, name: 'exists' },\n];\n","import { getLogger } from '../logging/index.js';\n\nimport type { ReadyCheck } from './types.js';\n\n/**\n * Evaluate readiness for a resource by running checks grouped by priority.\n *\n * - If `observed` is undefined, the resource doesn't exist yet → not ready.\n * - Checks are grouped by priority (ascending). Within a group, all checks\n * are AND-ed: if any returns `false`, the resource is not ready. If at least\n * one returns `true` and none return `false`, the resource is ready.\n * If all return `undefined`, cascade to the next priority group.\n * - Final fallback (no group had a definitive answer): not ready.\n */\nexport function evaluateReadiness(\n checks: ReadyCheck[],\n observed: Record<string, unknown> | undefined,\n): boolean {\n const log = getLogger();\n\n if (!observed) {\n log.debug('readiness: resource not observed, not ready');\n return false;\n }\n\n // Group checks by priority\n const groups = new Map<number, ReadyCheck[]>();\n for (const check of checks) {\n const group = groups.get(check.priority);\n if (group) {\n group.push(check);\n } else {\n groups.set(check.priority, [check]);\n }\n }\n\n // Process groups in ascending priority order\n const priorities = [...groups.keys()].sort((a, b) => a - b);\n\n for (const priority of priorities) {\n const group = groups.get(priority)!;\n let hasTrue = false;\n let hasFalse = false;\n const results: Array<{ name: string; result: boolean | undefined }> = [];\n\n for (const check of group) {\n const result = check.fn(observed);\n results.push({ name: check.name ?? 'anonymous', result });\n\n if (result === false) {\n hasFalse = true;\n break; // Short-circuit: one false in the group → not ready\n }\n if (result === true) {\n hasTrue = true;\n }\n }\n\n log.debug('readiness: evaluated group', { priority, results });\n\n if (hasFalse) {\n log.debug('readiness: group returned false, not ready', { priority });\n return false;\n }\n if (hasTrue) {\n log.debug('readiness: group returned true, ready', { priority });\n return true;\n }\n // All undefined → cascade to next group\n }\n\n log.debug('readiness: no group had definitive answer, not ready');\n return false;\n}\n","import type {\n CompositionInput,\n CompositionResult,\n DesiredResource,\n ExternalResourceRequest,\n} from './contract.js';\nimport type { Composition } from './core/composition.js';\nimport type { CompositionContext } from './core/context.js';\nimport { compositionStorage } from './core/context.js';\nimport { getExternalRef, getResourceRef, isExternal } from './core/resource.js';\nimport { runPipeline } from './pipeline/index.js';\nimport { DEFAULT_CHECKS, evaluateReadiness } from './readiness/index.js';\nimport { DependencyGraph, EdgeCollector } from './tracking/index.js';\nimport { createTokenRegistry, tokenRegistryStorage } from './tracking/token-registry.js';\n\n/**\n * Run a composition class with the given input and return a plain-data result.\n *\n * This is the single entry point that bridges the composition author's class\n * with the runtime. It handles:\n * 1. Setting up internal context (DependencyGraph, EdgeCollector, ALS)\n * 2. Instantiating the Composition class\n * 3. Running the full pipeline (hydrate → resolve → sequence → diagnose → emit)\n * 4. Evaluating readiness per resource\n * 5. Returning a fully serializable CompositionResult\n *\n * The runtime never needs to access framework internals — everything it needs\n * is in the returned plain-data structure.\n */\nexport function runComposition<TSpec, TStatus, TContext extends object>(\n CompositionClass: new () => Composition<TSpec, TStatus, TContext>,\n input: CompositionInput,\n): CompositionResult {\n // Convert plain Records to Maps for the internal pipeline\n const observedComposed = new Map(Object.entries(input.observedComposed));\n const observedRequired = new Map(Object.entries(input.observedRequired));\n\n // Set up internal context\n const graph = new DependencyGraph();\n const collector = new EdgeCollector();\n const pipelineContext = new Map(Object.entries(input.pipelineContext));\n\n const ctx: CompositionContext = {\n xr: input.xr,\n pipelineContext,\n requiredResources: observedRequired,\n graph,\n collector,\n };\n\n // Instantiate composition within ALS context\n const composition = compositionStorage.run(ctx, () =>\n tokenRegistryStorage.run(createTokenRegistry(), () => new CompositionClass()),\n ) as Composition;\n\n // Run the pipeline\n const state = runPipeline({ composition, observedComposed, observedRequired });\n\n // Build the result — plain data only\n const resources: DesiredResource[] = state.emitted.map((emitted) => {\n const allChecks = [...emitted.readyChecks, ...DEFAULT_CHECKS];\n // Look up observed using the full construct path (Composition/{name})\n const observed = observedComposed.get(`Composition/${emitted.name}`);\n const ready = emitted.autoReady ? evaluateReadiness(allChecks, observed) : true;\n\n return {\n name: emitted.name,\n document: emitted.document,\n ready,\n };\n });\n\n const externalResources: ExternalResourceRequest[] = [];\n for (const resource of state.resources) {\n if (!isExternal(resource)) continue;\n const ref = getExternalRef(resource);\n if (!ref || typeof ref.name !== 'string') continue;\n if (ref.name.startsWith('__pending__')) continue;\n\n externalResources.push({\n refKey: ref.refKey,\n apiVersion: ref.apiVersion,\n kind: ref.kind,\n name: ref.name,\n ...(ref.namespace ? { namespace: ref.namespace } : {}),\n });\n }\n\n // Collect blocked resource names so the handler can preserve observed state\n // in desired (preventing accidental deletion) and prevent premature XR readiness.\n const blockedResources: string[] = [];\n for (const resource of state.resources) {\n if (isExternal(resource)) continue;\n const ref = getResourceRef(resource);\n if (state.classification.get(ref.id) !== 'blocked') continue;\n const name = ref.id.startsWith('Composition/') ? ref.id.slice('Composition/'.length) : ref.id;\n blockedResources.push(name);\n }\n\n return {\n resources,\n blockedResources,\n externalResources,\n xrStatus: state.xrStatusPatches,\n diagnostics: state.diagnostics,\n };\n}\n"],"mappings":";;;;;;;;AA2BA,MAAa,qBAAqB,IAAI,kBAAsC;;;;;AAM5E,SAAgB,wBAA4C;CAC1D,MAAM,MAAM,mBAAmB,SAAS;CACxC,IAAI,KAAK,OAAO;CAEhB,MAAM,IAAI,MACR,sGACF;AACF;;;;;;;;;;;;;;;;;;;;;ACiBA,IAAa,cAAb,cAIUA,YAAU;;;;;CAKlB;;CAGA;;CAGA;CAEA,cAAc;EAEZ,MAAM,KAAA,GAAmC,aAAa;EAEtD,MAAM,MAAM,sBAAsB;EAElC,KAAK,QAAQ,IAAI;EACjB,KAAK,YAAY,IAAI;EAGrB,KAAK,KAAK,WAAW,gBAAgB,IAAI,KAAK;EAC9C,KAAK,KAAK,WAAW,oBAAoB,IAAI,SAAS;EAGtD,MAAM,SAAS,IAAI,GAAG;EACtB,IAAI,QACF,KAAK,KAAK,WAAW,kBAAkB,MAAM;EA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