@xplane/core 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +53 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -198,6 +198,8 @@ interface WriteProxyOptions {
|
|
|
198
198
|
collector: EdgeCollector;
|
|
199
199
|
/** Base path prefix (e.g., "spec" when wrapping the spec subtree). */
|
|
200
200
|
basePath?: string;
|
|
201
|
+
/** Optional observed state at the same path for fallback reads. */
|
|
202
|
+
observed?: Record<string, unknown>;
|
|
201
203
|
}
|
|
202
204
|
/**
|
|
203
205
|
* Creates a WriteProxy that wraps a desired document.
|
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;;EAEX,iBAAA,EAAmB,uBAAA;EAAA;EAEnB,QAAA,EAAU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AAa,UAAA,EAAY,WAAA;EFNlC;EEaxB,eAAA,CAAgB,UAAA,WAAqB,WAAA;EAAA,IAIjC,WAAA,CAAA,GAAe,aAAA;EAAA,IAIf,KAAA,CAAA,GAAS,aAAA,CAAc,cAAA;EFzB3B;;;;EEiCA,eAAA,CAAA;IAAqB,KAAA;EAAA;IAAsB,KAAA;IAAa,KAAA;EAAA;AAAA;;;;;;iBCtC1C,WAAA,CAAY,KAAA,YAAiB,KAAK;;;;iBAWlC,gBAAA,CAAiB,KAAA,YAAiB,aAAa;;;;;;;;;iBAa/C,eAAA,kBAAA,CACd,MAAA,EAAQ,CAAA,EACR,KAAA,EAAO,WAAA,EACP,QAAA,WACC,CAAA;;;;;;iBAqEa,wBAAA,CACd,KAAA,6BACA,KAAA,EAAO,WAAW,EAClB,IAAA;;;;;;AHnGF;
|
|
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;;EAEX,iBAAA,EAAmB,uBAAA;EAAA;EAEnB,QAAA,EAAU,MAAA;EAEG;EAAb,WAAA,EAAa,U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dN7D;;;iBeIgB,IAAA,CAAK,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AfJzD;;;iBgBLgB,OAAA,CAAQ,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AhBK5D;;;;;iBiBFgB,OAAA,CAAQ,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AjBE5D;;;;;;iBkBDgB,QAAA,CAAS,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;UCW5C,aAAA;EnBFG;EmBIlB,WAAA,EAAa,WAAA;EnBJW;EmBMxB,gBAAA,EAAkB,WAAA,SAAoB,MAAA;EnBZlC;EmBcJ,gBAAA,EAAkB,WAAA,SAAoB,MAAA;AAAA;;;;;;iBAQxB,WAAA,CAAY,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;AnBxBhE;;;;;;;;;;;;iBoBagB,cAAA,yCAAA,CACd,gBAAA,YAA4B,WAAA,CAAY,KAAA,EAAO,OAAA,EAAS,QAAA,GACxD,KAAA,EAAO,gBAAA,GACN,iBAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -370,7 +370,7 @@ var EdgeCollector = class {
|
|
|
370
370
|
* - Reads return the stored value (desired-first).
|
|
371
371
|
*/
|
|
372
372
|
function createWriteProxy(target, opts) {
|
|
373
|
-
const { owner, collector, basePath = "" } = opts;
|
|
373
|
+
const { owner, collector, basePath = "", observed } = opts;
|
|
374
374
|
return new Proxy(target, {
|
|
375
375
|
get(obj, prop, receiver) {
|
|
376
376
|
if (typeof prop === "symbol") return Reflect.get(obj, prop, receiver);
|
|
@@ -379,8 +379,19 @@ function createWriteProxy(target, opts) {
|
|
|
379
379
|
if (typeof value === "object" && value !== null && !Pending.is(value)) return createWriteProxy(value, {
|
|
380
380
|
owner,
|
|
381
381
|
collector,
|
|
382
|
-
basePath: basePath ? `${basePath}.${String(prop)}` : String(prop)
|
|
382
|
+
basePath: basePath ? `${basePath}.${String(prop)}` : String(prop),
|
|
383
|
+
observed: observed && String(prop) in observed && typeof observed[String(prop)] === "object" ? observed[String(prop)] : void 0
|
|
383
384
|
});
|
|
385
|
+
if (value === void 0 && observed && String(prop) in observed) {
|
|
386
|
+
const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);
|
|
387
|
+
const obsValue = observed[String(prop)];
|
|
388
|
+
if (typeof obsValue === "object" && obsValue !== null) return createReadProxy(obsValue, owner, childPath);
|
|
389
|
+
if (obsValue !== void 0 && obsValue !== null) return createPrimitiveReadProxy(obsValue, owner, childPath);
|
|
390
|
+
}
|
|
391
|
+
if (value === void 0 && observed !== void 0) {
|
|
392
|
+
const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);
|
|
393
|
+
return createReadProxy(Object.create(null), owner, childPath);
|
|
394
|
+
}
|
|
384
395
|
return value;
|
|
385
396
|
},
|
|
386
397
|
set(obj, prop, value) {
|
|
@@ -506,7 +517,9 @@ var Resource = class Resource extends Construct$1 {
|
|
|
506
517
|
collector
|
|
507
518
|
};
|
|
508
519
|
internals.set(this, internal);
|
|
509
|
-
|
|
520
|
+
const proxy = createResourceProxy(this, internal);
|
|
521
|
+
scope.node._children[this.node.id] = proxy;
|
|
522
|
+
return proxy;
|
|
510
523
|
}
|
|
511
524
|
/**
|
|
512
525
|
* Look up an existing cluster resource by name.
|
|
@@ -668,13 +681,20 @@ function createResourceProxy(resource, internal) {
|
|
|
668
681
|
if (prop === "resource") return Reflect.get(target, prop, receiver);
|
|
669
682
|
if (typeof prop === "symbol") return Reflect.get(target, prop, receiver);
|
|
670
683
|
if (prop === "constructor") return Reflect.get(target, prop, receiver);
|
|
684
|
+
const protoValue = Reflect.get(target, prop, receiver);
|
|
685
|
+
if (typeof protoValue === "function") return protoValue.bind(proxy);
|
|
671
686
|
if (prop in desired) {
|
|
672
687
|
const value = desired[String(prop)];
|
|
673
|
-
if (typeof value === "object" && value !== null && !Pending.is(value))
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
688
|
+
if (typeof value === "object" && value !== null && !Pending.is(value)) {
|
|
689
|
+
const observed = internal.observed;
|
|
690
|
+
const observedAtPath = String(prop) in observed && typeof observed[String(prop)] === "object" ? observed[String(prop)] : {};
|
|
691
|
+
return createWriteProxy(value, {
|
|
692
|
+
owner: ref,
|
|
693
|
+
collector,
|
|
694
|
+
basePath: String(prop),
|
|
695
|
+
observed: observedAtPath
|
|
696
|
+
});
|
|
697
|
+
}
|
|
678
698
|
return value;
|
|
679
699
|
}
|
|
680
700
|
const observed = internal.observed;
|
|
@@ -683,7 +703,7 @@ function createResourceProxy(resource, internal) {
|
|
|
683
703
|
if (typeof value === "object" && value !== null) return createReadProxy(value, ref, String(prop));
|
|
684
704
|
return createPrimitiveReadProxyFromResource(value, ref, String(prop));
|
|
685
705
|
}
|
|
686
|
-
return
|
|
706
|
+
return createLazyInitProxy(desired, ref, collector, String(prop));
|
|
687
707
|
},
|
|
688
708
|
set(target, prop, value) {
|
|
689
709
|
if (typeof prop === "symbol") return Reflect.set(target, prop, value);
|
|
@@ -709,6 +729,30 @@ function createPrimitiveReadProxyFromResource(value, owner, path) {
|
|
|
709
729
|
if (value === null || value === void 0) return value;
|
|
710
730
|
return createPrimitiveReadProxy(value, owner, path);
|
|
711
731
|
}
|
|
732
|
+
/**
|
|
733
|
+
* Creates a proxy for a path that exists in neither desired nor observed.
|
|
734
|
+
* - Reading nested properties returns ReadProxy leaves (for dependency tracking).
|
|
735
|
+
* - Writing a nested property auto-initializes the path in desired and stores the value.
|
|
736
|
+
*/
|
|
737
|
+
function createLazyInitProxy(desired, owner, collector, basePath) {
|
|
738
|
+
const readProxy = createReadProxy({}, owner, basePath);
|
|
739
|
+
return new Proxy(readProxy, {
|
|
740
|
+
get(target, prop, receiver) {
|
|
741
|
+
if (typeof prop === "symbol") return Reflect.get(target, prop, receiver);
|
|
742
|
+
return Reflect.get(target, prop, receiver);
|
|
743
|
+
},
|
|
744
|
+
set(_target, prop, value) {
|
|
745
|
+
if (typeof prop === "symbol") return false;
|
|
746
|
+
let container = desired[basePath];
|
|
747
|
+
if (!container || typeof container !== "object") {
|
|
748
|
+
container = {};
|
|
749
|
+
desired[basePath] = container;
|
|
750
|
+
}
|
|
751
|
+
container[String(prop)] = processValue(value, owner, `${basePath}.${String(prop)}`, collector);
|
|
752
|
+
return true;
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
}
|
|
712
756
|
//#endregion
|
|
713
757
|
//#region src/logging/context.ts
|
|
714
758
|
const noopLogger = {
|
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 { getReadProxyMeta, isReadProxy } 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}\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 = '' } = 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 return createWriteProxy(value as object, { owner, collector, basePath: 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 // biome-ignore lint/correctness/noConstructorReturn: Proxy wrapping is intentional\n return createResourceProxy(this, internal);\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 (constructor, etc.)\n if (prop === 'constructor') return Reflect.get(target, prop, receiver);\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 return createWriteProxy(value as object, {\n owner: ref,\n collector,\n basePath: String(prop),\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 ReadProxy leaf (for chaining like .status.foo.bar)\n return createReadProxy({} as object, ref, 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","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 xrStat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ClB;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/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,OAA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