@xplane/core 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -52,8 +52,19 @@ interface CompositionResult {
52
52
  }
53
53
  /** A desired composed resource ready for emission. */
54
54
  interface DesiredResource {
55
- /** The resource name (construct path without "Composition/" prefix). */
56
- name: string;
55
+ /**
56
+ * The construct path (without the `Composition/` prefix). This doubles as the
57
+ * Crossplane composed-resource key in the function-pipeline desired map and
58
+ * uniquely identifies the resource within the composition.
59
+ */
60
+ nodePath: string;
61
+ /**
62
+ * The actual Kubernetes `metadata.name` of the resolved document, when known.
63
+ * May be undefined if the name is provider-generated or not yet resolved.
64
+ */
65
+ name?: string;
66
+ /** The Kubernetes `metadata.namespace` of the document, when present. */
67
+ namespace?: string;
57
68
  /** The fully-resolved desired Kubernetes resource document. */
58
69
  document: Record<string, unknown>;
59
70
  /** Whether this resource is ready (readiness already evaluated). */
@@ -81,14 +92,16 @@ interface ExternalResourceRequest {
81
92
  * `status.xplane.blockedResources` for visibility.
82
93
  */
83
94
  interface BlockedResource {
84
- /** Construct path name (also used as the Crossplane composed resource name). */
85
- name: string;
95
+ /** Construct path (also used as the Crossplane composed resource key). */
96
+ nodePath: string;
97
+ /** The actual Kubernetes `metadata.name` of the resolved document, when known. */
98
+ name?: string;
99
+ /** The Kubernetes `metadata.namespace` of the document, when present. */
100
+ namespace?: string;
86
101
  /** The desired resource's apiVersion. */
87
102
  apiVersion: string;
88
103
  /** The desired resource's kind. */
89
104
  kind: string;
90
- /** The desired resource's metadata.name (if resolved). */
91
- resourceName?: string;
92
105
  /** Human-readable list of things this resource is waiting for. */
93
106
  waitingFor?: string[];
94
107
  }
@@ -97,7 +110,7 @@ interface Diagnostic {
97
110
  /** The resource name (construct path). */
98
111
  resource: string;
99
112
  /** Why the resource is blocked. */
100
- reason: 'pending' | 'cycle' | 'not-found';
113
+ reason: 'pending' | 'cycle' | 'not-found' | 'dependency';
101
114
  /** For 'pending': what paths are waiting on what. */
102
115
  pendingPaths?: Array<{
103
116
  path: string;
@@ -108,6 +121,8 @@ interface Diagnostic {
108
121
  }>;
109
122
  /** For 'cycle': the cycle path. */
110
123
  cycle?: string[];
124
+ /** For 'dependency': the dependency target ids being awaited. */
125
+ waitingOn?: string[];
111
126
  /** Human-readable detail. */
112
127
  detail?: string;
113
128
  }
@@ -601,11 +616,17 @@ interface PipelineState {
601
616
  emitted: EmittedResource[];
602
617
  /** Desired XR status patches (from this.xr.status assignments). */
603
618
  xrStatusPatches: Record<string, unknown>;
619
+ /**
620
+ * Resources blocked because at least one explicit graph dependency is not
621
+ * yet Ready. Maps the blocked resource's id → list of dependency target ids
622
+ * still awaiting readiness. Populated by `sequence`.
623
+ */
624
+ dependencyBlocks?: Map<string, string[]>;
604
625
  }
605
626
  type ResourceClassification = 'emit' | 'blocked' | 'external';
606
627
  interface DiagnosticReport {
607
628
  resource: string;
608
- reason: 'pending' | 'cycle' | 'not-found';
629
+ reason: 'pending' | 'cycle' | 'not-found' | 'dependency';
609
630
  pendingPaths?: Array<{
610
631
  path: string;
611
632
  waitingOn: {
@@ -615,6 +636,8 @@ interface DiagnosticReport {
615
636
  }>;
616
637
  cycle?: string[];
617
638
  detail?: string;
639
+ /** For `reason: 'dependency'` — list of dependency target ids the resource is waiting on. */
640
+ waitingOn?: string[];
618
641
  }
619
642
  interface EmittedResource {
620
643
  /** The construct path (used as resource name in Crossplane). */
@@ -688,6 +711,11 @@ declare function resolve(state: PipelineState): PipelineState;
688
711
  * - A resource is 'blocked' if it still has Pending markers in its desired document.
689
712
  * - External resources are classified as 'external' (never emitted).
690
713
  * - Circular dependencies are detected via the graph's topological sort.
714
+ * - After the Pending-based pass, an explicit-dependency pass runs to a
715
+ * fixed point: any resource classified `emit` is downgraded to `blocked`
716
+ * if a graph dependency target is itself blocked, an unobserved external,
717
+ * or an `emit` resource whose observed state is not yet Ready
718
+ * (`evaluateReadiness`).
691
719
  */
692
720
  declare function sequence(state: PipelineState): PipelineState;
693
721
  //#endregion
@@ -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/token-registry.ts","../src/tracking/write-proxy.ts","../src/core/composition.ts","../src/core/context.ts","../src/readiness/types.ts","../src/readiness/defaults.ts","../src/readiness/evaluate.ts","../src/core/resource.ts","../src/logging/types.ts","../src/logging/context.ts","../src/pipeline/types.ts","../src/pipeline/diagnose.ts","../src/pipeline/emit.ts","../src/pipeline/hydrate.ts","../src/pipeline/resolve.ts","../src/pipeline/sequence.ts","../src/pipeline/index.ts","../src/run.ts"],"mappings":";;;;;;;;AAeA;;;;;;;;UAAiB,gBAAA;EAQS;EANxB,EAAA,EAAI,MAAA;EAAJ;EAEA,eAAA,EAAiB,MAAA;EAAjB;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;EAAjC;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;AAAA;;;;;UASlB,iBAAA;EAAA;EAEf,SAAA,EAAW,eAAA;;;;;;;EAOX,gBAAA,EAAkB,eAAA;EAMK;EAJvB,iBAAA,EAAmB,uBAAA;EATR;EAWX,QAAA,EAAU,MAAA;EAJQ;EAMlB,WAAA,EAAa,UAAA;EAJM;;;;EASnB,gBAAA;AAAA;;UAIe,eAAA;EAAA;EAEf,IAAA;;EAEA,QAAA,EAAU,MAAM;EAFhB;EAIA,KAAA;EAFU;;;;AAQD;EAAT,SAAA;AAAA;;UAIe,uBAAA;EAEf;EAAA,MAAA;EACA,UAAA;EACA,IAAA;EAIA;EAFA,IAAA;EAES;EAAT,SAAA;AAAA;;;;;UAOe,eAAA;EAQf;EANA,IAAA;EAQU;EANV,UAAA;EAUe;EARf,IAAA;;EAEA,YAAA;EAQA;EANA,UAAA;AAAA;;UAIe,UAAA;EAQb;EANF,QAAA;EAMiC;EAJjC,MAAA;EASA;EAP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AAA,EAAS,eAAA;EdFwB;EcIjC,eAAA,EAAiB,MAAA;AAAA;AAAA,KAGP,sBAAA;AAAA,UAEK,gBAAA;EACf,QAAA;EACA,MAAA;EACA,YAAA,GAAe,KAAK;IAClB,IAAA;IACA,SAAA;MAAa,QAAA;MAAkB,IAAA;IAAA;EAAA;EAEjC,KAAA;EACA,MAAA;AAAA;AAAA,UAGe,eAAA;EdAf;EcEA,IAAA;EdAA;EcEA,QAAA,EAAU,MAAA;EdAV;EcEA,SAAA;EdAA;EcEA,WAAA,EAAa,UAAU;EdGvB;;AAAgB;AAIlB;;EcDE,SAAA;AAAA;;;;;;AdxCF;;;;;;;iBeMgB,QAAA,CAAS,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AfN7D;;;;;;;iBgBSgB,IAAA,CAAK,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AhBTzD;;;iBiBLgB,OAAA,CAAQ,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AjBK5D;;;;;iBkBFgB,OAAA,CAAQ,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;AlBE5D;;;;;;iBmBDgB,QAAA,CAAS,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;;UCW5C,aAAA;EpBFG;EoBIlB,WAAA,EAAa,WAAA;EpBJW;EoBMxB,gBAAA,EAAkB,WAAA,SAAoB,MAAA;EpBZlC;EoBcJ,gBAAA,EAAkB,WAAA,SAAoB,MAAA;AAAA;;;;;;iBAQxB,WAAA,CAAY,KAAA,EAAO,aAAA,GAAgB,aAAa;;;;;ApBxBhE;;;;;;;;;;;;iBqBegB,cAAA,yCAAA,CACd,gBAAA,YAA4B,WAAA,CAAY,KAAA,EAAO,OAAA,EAAS,QAAA,GACxD,KAAA,EAAO,gBAAA,GACN,iBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/contract.ts","../src/tracking/types.ts","../src/tracking/dependency-graph.ts","../src/tracking/read-proxy.ts","../src/tracking/token-registry.ts","../src/tracking/write-proxy.ts","../src/core/composition.ts","../src/core/context.ts","../src/readiness/types.ts","../src/readiness/defaults.ts","../src/readiness/evaluate.ts","../src/core/resource.ts","../src/logging/types.ts","../src/logging/context.ts","../src/pipeline/types.ts","../src/pipeline/diagnose.ts","../src/pipeline/emit.ts","../src/pipeline/hydrate.ts","../src/pipeline/resolve.ts","../src/pipeline/sequence.ts","../src/pipeline/index.ts","../src/run.ts"],"mappings":";;;;;;;;AAeA;;;;;;;;UAAiB,gBAAA;EAQS;EANxB,EAAA,EAAI,MAAA;EAAJ;EAEA,eAAA,EAAiB,MAAA;EAAjB;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;EAAjC;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;AAAA;;;;;UASlB,iBAAA;EAAA;EAEf,SAAA,EAAW,eAAA;;;;;;;EAOX,gBAAA,EAAkB,eAAA;EAMK;EAJvB,iBAAA,EAAmB,uBAAA;EATR;EAWX,QAAA,EAAU,MAAA;EAJQ;EAMlB,WAAA,EAAa,UAAA;EAJM;;;;EASnB,gBAAA;AAAA;;UAIe,eAAA;EAAA;;;;;EAMf,QAAA;EAOA;;;;EAFA,IAAA;EAYS;EAVT,SAAA;EAce;EAZf,QAAA,EAAU,MAAM;;EAEhB,KAAA;EAYA;;;;;EANA,SAAA;AAAA;AAmBF;AAAA,UAfiB,uBAAA;;EAEf,MAAA;EACA,UAAA;EACA,IAAA;EAiBA;EAfA,IAAA;EAmBA;EAjBA,SAAA;AAAA;AAmBU;AAIZ;;;AAJY,UAZK,eAAA;EAkBf;EAhBA,QAAA;EAoBA;EAlBA,IAAA;EAmBE;EAjBF,SAAA;EAkBe;EAhBf,UAAA;EAmBA;EAjBA,IAAA;EAqBA;EAnBA,UAAA;AAAA;AA4BF;AAAA,UAxBiB,UAAA;;EAEf,QAAA;EAuBA;EArBA,MAAA;EAqBI;EAnBJ,YAAA,GAAe,KAAK;IAClB,IAAA;IACA,SAAA;MAAa,QAAA;MA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notFoundIds.has(dep);
1007
1007
  })) diagnostics.push(diag);
1008
+ if (state.dependencyBlocks) for (const [resourceId, waitingOn] of state.dependencyBlocks) {
1009
+ if (diagnostics.some((d) => d.resource === resourceId)) continue;
1010
+ const rootCauses = waitingOn.filter((id) => !blockedIds.has(id) && !notFoundIds.has(id) && !state.dependencyBlocks?.has(id));
1011
+ if (rootCauses.length === 0) continue;
1012
+ diagnostics.push({
1013
+ resource: resourceId,
1014
+ reason: "dependency",
1015
+ waitingOn: rootCauses
1016
+ });
1017
+ }
1008
1018
  return {
1009
1019
  ...state,
1010
1020
  diagnostics
@@ -1291,96 +1301,6 @@ function resolvePendingTemplate(template, resourceById) {
1291
1301
  return result;
1292
1302
  }
1293
1303
  //#endregion
1294
- //#region src/pipeline/sequence.ts
1295
- /**
1296
- * SEQUENCE phase: topological sort and classification.
1297
- *
1298
- * - Runs topological sort on the dependency graph.
1299
- * - Classifies each resource as 'emit', 'blocked', or 'external'.
1300
- * - A resource is 'blocked' if it still has Pending markers in its desired document.
1301
- * - External resources are classified as 'external' (never emitted).
1302
- * - Circular dependencies are detected via the graph's topological sort.
1303
- */
1304
- function sequence(state) {
1305
- const classification = /* @__PURE__ */ new Map();
1306
- const sortResult = state.graph.topologicalSort();
1307
- for (const resource of state.resources) {
1308
- const ref = getResourceRef(resource);
1309
- if (isExternal(resource)) {
1310
- classification.set(ref.id, "external");
1311
- continue;
1312
- }
1313
- if (containsPending(getDesiredDocument(resource))) classification.set(ref.id, "blocked");
1314
- else classification.set(ref.id, "emit");
1315
- }
1316
- if (sortResult.order === null && sortResult.cycle) {
1317
- for (const id of sortResult.cycle) if (classification.get(id) !== "external") classification.set(id, "blocked");
1318
- }
1319
- return {
1320
- ...state,
1321
- classification
1322
- };
1323
- }
1324
- /**
1325
- * Recursively check if an object contains any Pending markers.
1326
- */
1327
- function containsPending(obj) {
1328
- if (obj === null || obj === void 0) return false;
1329
- if (Pending.is(obj)) return true;
1330
- if (PendingTemplate.is(obj)) return true;
1331
- if (typeof obj !== "object") return false;
1332
- if (Array.isArray(obj)) return obj.some(containsPending);
1333
- for (const value of Object.values(obj)) if (containsPending(value)) return true;
1334
- return false;
1335
- }
1336
- //#endregion
1337
- //#region src/pipeline/index.ts
1338
- /**
1339
- * Run the full rendering pipeline.
1340
- *
1341
- * Phases: hydrate → resolve → sequence → diagnose → emit
1342
- */
1343
- function runPipeline(input) {
1344
- const resources = collectResources(input.composition);
1345
- let state = {
1346
- composition: input.composition,
1347
- resources,
1348
- graph: input.composition.graph,
1349
- observedComposed: input.observedComposed,
1350
- observedRequired: input.observedRequired,
1351
- classification: /* @__PURE__ */ new Map(),
1352
- diagnostics: [],
1353
- emitted: [],
1354
- xrStatusPatches: {}
1355
- };
1356
- state = hydrate(state);
1357
- state = resolve(state);
1358
- state = sequence(state);
1359
- state = diagnose(state);
1360
- state = emit(state);
1361
- return state;
1362
- }
1363
- /**
1364
- * Collect all Resource instances from the composition's construct tree.
1365
- */
1366
- function collectResources(composition) {
1367
- const resources = [];
1368
- collectFromNode(composition, resources);
1369
- return resources;
1370
- }
1371
- function collectFromNode(construct, resources) {
1372
- for (const child of construct.node.children) {
1373
- if (isResourceInstance(child)) resources.push(child);
1374
- collectFromNode(child, resources);
1375
- }
1376
- }
1377
- function isResourceInstance(obj) {
1378
- if (obj === null || typeof obj !== "object") return false;
1379
- const r = obj;
1380
- if (!("resource" in r) || r.resource === null || typeof r.resource !== "object") return false;
1381
- return "autoReady" in r.resource;
1382
- }
1383
- //#endregion
1384
1304
  //#region src/readiness/defaults.ts
1385
1305
  /**
1386
1306
  * Checks if the resource has a `Ready` condition with status `True`.
@@ -1393,6 +1313,18 @@ function conditionReady(observed) {
1393
1313
  return ready.status === "True";
1394
1314
  }
1395
1315
  /**
1316
+ * Vetoes readiness when a `Synced` condition is explicitly `False` (Crossplane
1317
+ * provider reconciliation error). Returns `undefined` otherwise so this check
1318
+ * does not by itself imply readiness — it only blocks it.
1319
+ */
1320
+ function syncedNotFalse(observed) {
1321
+ const conditions = observed.status?.conditions;
1322
+ if (!conditions || !Array.isArray(conditions)) return void 0;
1323
+ const synced = conditions.find((c) => c.type === "Synced");
1324
+ if (!synced) return void 0;
1325
+ return synced.status === "False" ? false : void 0;
1326
+ }
1327
+ /**
1396
1328
  * Checks if the resource has `status.ready === true`.
1397
1329
  */
1398
1330
  function statusReady(observed) {
@@ -1417,6 +1349,11 @@ const DEFAULT_CHECKS = [
1417
1349
  priority: 100,
1418
1350
  name: "conditionReady"
1419
1351
  },
1352
+ {
1353
+ fn: syncedNotFalse,
1354
+ priority: 100,
1355
+ name: "syncedNotFalse"
1356
+ },
1420
1357
  {
1421
1358
  fn: statusReady,
1422
1359
  priority: 200,
@@ -1487,6 +1424,171 @@ function evaluateReadiness(checks, observed) {
1487
1424
  return false;
1488
1425
  }
1489
1426
  //#endregion
1427
+ //#region src/pipeline/sequence.ts
1428
+ /**
1429
+ * SEQUENCE phase: topological sort and classification.
1430
+ *
1431
+ * - Runs topological sort on the dependency graph.
1432
+ * - Classifies each resource as 'emit', 'blocked', or 'external'.
1433
+ * - A resource is 'blocked' if it still has Pending markers in its desired document.
1434
+ * - External resources are classified as 'external' (never emitted).
1435
+ * - Circular dependencies are detected via the graph's topological sort.
1436
+ * - After the Pending-based pass, an explicit-dependency pass runs to a
1437
+ * fixed point: any resource classified `emit` is downgraded to `blocked`
1438
+ * if a graph dependency target is itself blocked, an unobserved external,
1439
+ * or an `emit` resource whose observed state is not yet Ready
1440
+ * (`evaluateReadiness`).
1441
+ */
1442
+ function sequence(state) {
1443
+ const classification = /* @__PURE__ */ new Map();
1444
+ const sortResult = state.graph.topologicalSort();
1445
+ const byId = /* @__PURE__ */ new Map();
1446
+ for (const resource of state.resources) byId.set(getResourceRef(resource).id, resource);
1447
+ for (const resource of state.resources) {
1448
+ const ref = getResourceRef(resource);
1449
+ if (isExternal(resource)) {
1450
+ classification.set(ref.id, "external");
1451
+ continue;
1452
+ }
1453
+ if (containsPending(getDesiredDocument(resource))) classification.set(ref.id, "blocked");
1454
+ else classification.set(ref.id, "emit");
1455
+ }
1456
+ if (sortResult.order === null && sortResult.cycle) {
1457
+ for (const id of sortResult.cycle) if (classification.get(id) !== "external") classification.set(id, "blocked");
1458
+ }
1459
+ const dependencyBlocks = /* @__PURE__ */ new Map();
1460
+ const isTargetSatisfied = (depId) => {
1461
+ const cls = classification.get(depId);
1462
+ if (cls === void 0) return true;
1463
+ if (cls === "blocked") return false;
1464
+ const target = byId.get(depId);
1465
+ if (!target) return true;
1466
+ if (cls === "external") return Object.keys(getObservedDocument(target)).length > 0;
1467
+ const observed = state.observedComposed.get(depId);
1468
+ if (!observed) return false;
1469
+ return evaluateReadiness([...getReadyChecks(target), ...DEFAULT_CHECKS], observed);
1470
+ };
1471
+ let changed = true;
1472
+ while (changed) {
1473
+ changed = false;
1474
+ for (const resource of state.resources) {
1475
+ const ref = getResourceRef(resource);
1476
+ if (classification.get(ref.id) !== "emit") continue;
1477
+ const deps = state.graph.getDependencies(ref.id);
1478
+ if (deps.size === 0) continue;
1479
+ const unsatisfied = [];
1480
+ for (const depId of deps) {
1481
+ if (depId === ref.id) continue;
1482
+ if (!isTargetSatisfied(depId)) unsatisfied.push(depId);
1483
+ }
1484
+ if (unsatisfied.length > 0) {
1485
+ classification.set(ref.id, "blocked");
1486
+ dependencyBlocks.set(ref.id, unsatisfied);
1487
+ changed = true;
1488
+ }
1489
+ }
1490
+ }
1491
+ return {
1492
+ ...state,
1493
+ classification,
1494
+ dependencyBlocks
1495
+ };
1496
+ }
1497
+ /**
1498
+ * Recursively check if an object contains any Pending markers.
1499
+ */
1500
+ function containsPending(obj) {
1501
+ if (obj === null || obj === void 0) return false;
1502
+ if (Pending.is(obj)) return true;
1503
+ if (PendingTemplate.is(obj)) return true;
1504
+ if (typeof obj !== "object") return false;
1505
+ if (Array.isArray(obj)) return obj.some(containsPending);
1506
+ for (const value of Object.values(obj)) if (containsPending(value)) return true;
1507
+ return false;
1508
+ }
1509
+ //#endregion
1510
+ //#region src/pipeline/index.ts
1511
+ /**
1512
+ * Run the full rendering pipeline.
1513
+ *
1514
+ * Phases: hydrate → resolve → sequence → diagnose → emit
1515
+ */
1516
+ function runPipeline(input) {
1517
+ const resources = collectResources(input.composition);
1518
+ linkConstructDependencies(input.composition);
1519
+ let state = {
1520
+ composition: input.composition,
1521
+ resources,
1522
+ graph: input.composition.graph,
1523
+ observedComposed: input.observedComposed,
1524
+ observedRequired: input.observedRequired,
1525
+ classification: /* @__PURE__ */ new Map(),
1526
+ diagnostics: [],
1527
+ emitted: [],
1528
+ xrStatusPatches: {}
1529
+ };
1530
+ state = hydrate(state);
1531
+ state = resolve(state);
1532
+ state = sequence(state);
1533
+ state = diagnose(state);
1534
+ state = emit(state);
1535
+ return state;
1536
+ }
1537
+ /**
1538
+ * Collect all Resource instances from the composition's construct tree.
1539
+ */
1540
+ function collectResources(composition) {
1541
+ const resources = [];
1542
+ collectFromNode(composition, resources);
1543
+ return resources;
1544
+ }
1545
+ function collectFromNode(construct, resources) {
1546
+ for (const child of construct.node.children) {
1547
+ if (isResourceInstance(child)) resources.push(child);
1548
+ collectFromNode(child, resources);
1549
+ }
1550
+ }
1551
+ function isResourceInstance(obj) {
1552
+ if (obj === null || typeof obj !== "object") return false;
1553
+ const r = obj;
1554
+ if (!("resource" in r) || r.resource === null || typeof r.resource !== "object") return false;
1555
+ return "autoReady" in r.resource;
1556
+ }
1557
+ /**
1558
+ * Translate constructs-level `node.addDependency()` calls into explicit edges
1559
+ * on the dependency graph. For every construct C in the tree, every Resource
1560
+ * under C is made to depend on every Resource under each of C's dependency
1561
+ * targets. This way, blocking on construct-level dependencies fans out to
1562
+ * every leaf Resource the user expects.
1563
+ */
1564
+ function linkConstructDependencies(composition) {
1565
+ const graph = composition.graph;
1566
+ const visit = (c) => {
1567
+ const deps = c.node.dependencies;
1568
+ if (deps && deps.length > 0) {
1569
+ const dependents = collectResourcesUnder(c);
1570
+ if (dependents.length > 0) for (const dep of deps) {
1571
+ const targets = collectResourcesUnder(dep);
1572
+ for (const d of dependents) for (const t of targets) {
1573
+ if (d === t) continue;
1574
+ graph.addExplicitDependency(getResourceRef(d), getResourceRef(t));
1575
+ }
1576
+ }
1577
+ }
1578
+ for (const child of c.node.children) visit(child);
1579
+ };
1580
+ visit(composition);
1581
+ }
1582
+ function collectResourcesUnder(c) {
1583
+ const out = [];
1584
+ const walk = (n) => {
1585
+ if (isResourceInstance(n)) out.push(n);
1586
+ for (const child of n.node.children) walk(child);
1587
+ };
1588
+ walk(c);
1589
+ return out;
1590
+ }
1591
+ //#endregion
1490
1592
  //#region src/run.ts
1491
1593
  /**
1492
1594
  * Run a composition class with the given input and return a plain-data result.
@@ -1523,19 +1625,25 @@ function runComposition(CompositionClass, input) {
1523
1625
  observedRequired
1524
1626
  });
1525
1627
  const resources = state.emitted.map((emitted) => {
1628
+ const k8sName = extractMetadataName(emitted.document);
1629
+ const namespace = extractMetadataNamespace(emitted.document);
1526
1630
  if (emitted.preserved) return {
1527
- name: emitted.name,
1631
+ nodePath: emitted.name,
1528
1632
  document: emitted.document,
1529
1633
  ready: false,
1530
- preserved: true
1634
+ preserved: true,
1635
+ ...k8sName ? { name: k8sName } : {},
1636
+ ...namespace ? { namespace } : {}
1531
1637
  };
1532
1638
  const allChecks = [...emitted.readyChecks, ...DEFAULT_CHECKS];
1533
1639
  const observed = observedComposed.get(`Composition/${emitted.name}`);
1534
1640
  const ready = emitted.autoReady ? evaluateReadiness(allChecks, observed) : true;
1535
1641
  return {
1536
- name: emitted.name,
1642
+ nodePath: emitted.name,
1537
1643
  document: emitted.document,
1538
- ready
1644
+ ready,
1645
+ ...k8sName ? { name: k8sName } : {},
1646
+ ...namespace ? { namespace } : {}
1539
1647
  };
1540
1648
  });
1541
1649
  const externalResources = [];
@@ -1557,18 +1665,19 @@ function runComposition(CompositionClass, input) {
1557
1665
  if (isExternal(resource)) continue;
1558
1666
  const ref = getResourceRef(resource);
1559
1667
  if (state.classification.get(ref.id) !== "blocked") continue;
1560
- const name = ref.id.startsWith("Composition/") ? ref.id.slice(12) : ref.id;
1668
+ const nodePath = ref.id.startsWith("Composition/") ? ref.id.slice(12) : ref.id;
1561
1669
  const desired = getDesiredDocument(resource);
1562
1670
  const apiVersion = typeof desired.apiVersion === "string" ? desired.apiVersion : "";
1563
1671
  const kind = typeof desired.kind === "string" ? desired.kind : "";
1564
- const metadata = desired.metadata && typeof desired.metadata === "object" ? desired.metadata : void 0;
1565
- const resourceName = metadata && typeof metadata.name === "string" ? metadata.name : void 0;
1566
- const waitingFor = describeWaitingFor(name, state.diagnostics);
1672
+ const k8sName = extractMetadataName(desired);
1673
+ const namespace = extractMetadataNamespace(desired);
1674
+ const waitingFor = describeWaitingFor(nodePath, state.diagnostics);
1567
1675
  blockedResources.push({
1568
- name,
1676
+ nodePath,
1569
1677
  apiVersion,
1570
1678
  kind,
1571
- ...resourceName ? { resourceName } : {},
1679
+ ...k8sName ? { name: k8sName } : {},
1680
+ ...namespace ? { namespace } : {},
1572
1681
  ...waitingFor && waitingFor.length > 0 ? { waitingFor } : {}
1573
1682
  });
1574
1683
  }
@@ -1592,10 +1701,25 @@ function describeWaitingFor(name, diagnostics) {
1592
1701
  if (!diag) return void 0;
1593
1702
  if (diag.reason === "cycle") return [`circular dependency: ${(diag.cycle ?? []).join(" → ")}`];
1594
1703
  if (diag.reason === "not-found") return [diag.detail ?? "external resource not found"];
1704
+ if (diag.reason === "dependency" && diag.waitingOn && diag.waitingOn.length > 0) return diag.waitingOn.map((dep) => {
1705
+ return `${dep.startsWith("Composition/") ? dep.slice(12) : dep} to be Ready`;
1706
+ });
1595
1707
  if (diag.pendingPaths && diag.pendingPaths.length > 0) return diag.pendingPaths.map((p) => {
1596
1708
  return `${p.waitingOn.resource.startsWith("Composition/") ? p.waitingOn.resource.slice(12) : p.waitingOn.resource}.${p.waitingOn.path}`;
1597
1709
  });
1598
1710
  }
1711
+ function extractMetadataName(doc) {
1712
+ const metadata = doc.metadata;
1713
+ if (!metadata || typeof metadata !== "object") return void 0;
1714
+ const name = metadata.name;
1715
+ return typeof name === "string" && name.length > 0 ? name : void 0;
1716
+ }
1717
+ function extractMetadataNamespace(doc) {
1718
+ const metadata = doc.metadata;
1719
+ if (!metadata || typeof metadata !== "object") return void 0;
1720
+ const namespace = metadata.namespace;
1721
+ return typeof namespace === "string" && namespace.length > 0 ? namespace : void 0;
1722
+ }
1599
1723
  //#endregion
1600
1724
  export { Composition, Construct, DEFAULT_CHECKS, DependencyGraph, EdgeCollector, Pending, PendingTemplate, Resource, compositionStorage, createPrimitiveReadProxy, createReadProxy, createTokenRegistry, createWriteProxy, diagnose, emit, evaluateReadiness, getCompositionContext, getDesiredDocument, getExternalRef, getLogger, getObservedDocument, getReadProxyMeta, getReadyChecks, getResourceInternals, getResourceRef, getXrDesiredStatus, hydrate, hydrateObserved, isExternal, isReadProxy, resolve, runComposition, runPipeline, sequence, tokenRegistryStorage, withLogger };
1601
1725
 
@@ -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/types.ts","../src/tracking/token-registry.ts","../src/tracking/read-proxy.ts","../src/tracking/write-proxy.ts","../src/core/resource.ts","../src/logging/context.ts","../src/pipeline/diagnose.ts","../src/pipeline/emit.ts","../src/pipeline/hydrate.ts","../src/pipeline/resolve.ts","../src/pipeline/sequence.ts","../src/pipeline/index.ts","../src/readiness/defaults.ts","../src/readiness/evaluate.ts","../src/run.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { DependencyGraph, EdgeCollector } from '../tracking/index.js';\n\n/**\n * Runtime context passed into a Composition during construction\n * via AsyncLocalStorage. Holds everything the Composition needs\n * without relying on static state or globalThis.\n */\nexport interface CompositionContext {\n /** Observed XR data. */\n xr: Record<string, unknown>;\n /** Full Crossplane function pipeline context (all keys). */\n pipelineContext: ReadonlyMap<string, unknown>;\n /** Pre-populated data for existing resources (from prior iterations). */\n requiredResources: ReadonlyMap<string, Record<string, unknown>>;\n /** Pre-populated data for composed resources (from prior iterations), keyed by `Composition/{path}`. */\n observedComposed: 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 /**\n * When `true`, the runtime injects a structured `status.xplane` payload on\n * the XR containing `emittedResources` and `blockedResources`. Defaults to\n * `false` because writing this field requires the XRD's `openAPIV3Schema`\n * to declare `status.xplane` (or `status` to allow unknown fields) — typed\n * patches will otherwise be rejected by Crossplane.\n *\n * To enable, set in your composition's constructor:\n *\n * ```ts\n * this.emitXplaneStatus = true;\n * ```\n *\n * and add the following to your XRD's status schema:\n *\n * ```yaml\n * status:\n * properties:\n * xplane:\n * type: object\n * x-kubernetes-preserve-unknown-fields: true\n * ```\n */\n emitXplaneStatus = false;\n\n constructor() {\n // Use 'Composition' as the root construct ID\n super(undefined as unknown as Construct, 'Composition');\n\n const ctx = getCompositionContext();\n\n this.graph = ctx.graph;\n this.collector = ctx.collector;\n\n // Set context values on the construct tree so Resources can find them\n this.node.setContext('xplane:graph', ctx.graph);\n this.node.setContext('xplane:collector', ctx.collector);\n\n // Set XR metadata on tree for Resource.uniqueName()\n const xrMeta = ctx.xr.metadata as { name?: string; namespace?: string } | undefined;\n if (xrMeta) {\n this.node.setContext('xplane:xr-meta', xrMeta);\n }\n\n // Build the XR proxy\n this.xr = createXrProxy<TSpec, TStatus>(ctx);\n }\n\n /**\n * Read-only accessor for Crossplane function pipeline context.\n * Keys are the context keys set by Crossplane or prior functions in the pipeline.\n */\n get pipelineContext(): PipelineContextAccessor<TContext> {\n const ctx = getCompositionContext();\n return {\n get<K extends keyof TContext>(key: K): TContext[K] | undefined {\n return ctx.pipelineContext.get(key as string) as TContext[K] | undefined;\n },\n has(key: keyof TContext): boolean {\n return ctx.pipelineContext.has(key as string);\n },\n keys(): IterableIterator<keyof TContext> {\n return ctx.pipelineContext.keys() as IterableIterator<keyof TContext>;\n },\n };\n }\n}\n\n/** Typed read-only interface for pipeline context. */\nexport interface PipelineContextAccessor<TContext extends object = Record<string, unknown>> {\n get<K extends keyof TContext>(key: K): TContext[K] | undefined;\n has(key: keyof TContext): boolean;\n keys(): IterableIterator<keyof TContext>;\n}\n\n// ─── XR Proxy ─────────────────────────────────────────────────────────────────\n\n/**\n * Creates the \"desired-first, fallback-to-observed\" proxy for the XR.\n *\n * - Reading `xr.spec.*` reads from observed XR spec (creates ReadProxy for tracking)\n * - Writing `xr.status.*` writes to a desired-status store (emitted as composite status)\n * - Other reads fall through to observed\n */\nfunction createXrProxy<TSpec, TStatus>(ctx: {\n xr: Record<string, unknown>;\n graph: DependencyGraph;\n collector: EdgeCollector;\n}): XrProxy<TSpec, TStatus> {\n const xrObserved = ctx.xr;\n const xrDesiredStatus: Record<string, unknown> = {};\n\n // The XR ref for dependency tracking\n const xrRef = { id: '__xr__' };\n ctx.graph.addResource(xrRef);\n\n const statusProxy = new Proxy(xrDesiredStatus, {\n get(_target, prop) {\n if (typeof prop === 'symbol') return undefined;\n const key = String(prop);\n // Desired-first\n if (key in xrDesiredStatus) return xrDesiredStatus[key];\n // Fallback to observed status\n const observedStatus = xrObserved.status as Record<string, unknown> | undefined;\n if (observedStatus && key in observedStatus) {\n return observedStatus[key];\n }\n return undefined;\n },\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n xrDesiredStatus[String(prop)] = value;\n return true;\n },\n has(_target, prop) {\n if (typeof prop === 'symbol') return false;\n const key = String(prop);\n if (key in xrDesiredStatus) return true;\n const observedStatus = xrObserved.status as Record<string, unknown> | undefined;\n return observedStatus ? key in observedStatus : false;\n },\n });\n\n const proxy = new Proxy({} as XrProxy<TSpec, TStatus>, {\n get(_target, prop) {\n if (typeof prop === 'symbol') return undefined;\n const key = String(prop);\n if (key === 'status') return statusProxy;\n // Everything else reads from observed XR\n if (key in xrObserved) return xrObserved[key];\n return undefined;\n },\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n const key = String(prop);\n if (key === 'status') {\n // Allow replacing entire status\n Object.assign(xrDesiredStatus, value as object);\n return true;\n }\n // Writes to other top-level XR fields are unusual but allowed\n (xrObserved as Record<string, unknown>)[key] = value;\n return true;\n },\n has(_target, prop) {\n if (typeof prop === 'symbol') return false;\n return String(prop) in xrObserved || String(prop) === 'status';\n },\n });\n\n return proxy;\n}\n\n/**\n * Extract the desired XR status from a Composition instance.\n * Used by the emit pipeline phase to produce composite status output.\n */\nexport function getXrDesiredStatus(composition: Composition): Record<string, unknown> {\n // Access the internal status proxy target\n const statusProxy = composition.xr.status;\n // Collect all keys from the status proxy.\n // We intentionally return raw values (including ReadProxy references) so\n // that the emit phase can resolve them from observed resource data.\n const result: Record<string, unknown> = {};\n if (statusProxy && typeof statusProxy === 'object') {\n for (const key of Object.keys(statusProxy)) {\n const value = (statusProxy as Record<string, unknown>)[key];\n if (value != null) {\n result[key] = value;\n }\n }\n }\n return result;\n}\n","import type { DependencyEdge, ResourceRef } from './types.js';\n\n/**\n * Tracks dependency relationships between resources as a directed acyclic graph.\n * Edges are added as resources reference each other's observed state.\n */\nexport class DependencyGraph {\n private readonly _adjacency = new Map<string, Set<string>>();\n private readonly _resources = new Map<string, ResourceRef>();\n private readonly _edges: DependencyEdge[] = [];\n\n addResource(ref: ResourceRef): void {\n this._resources.set(ref.id, ref);\n if (!this._adjacency.has(ref.id)) {\n this._adjacency.set(ref.id, new Set());\n }\n }\n\n addEdge(edge: DependencyEdge): void {\n this.addResource(edge.from);\n this.addResource(edge.to);\n this._adjacency.get(edge.to.id)!.add(edge.from.id);\n this._edges.push(edge);\n }\n\n addEdges(edges: ReadonlyArray<DependencyEdge>): void {\n for (const edge of edges) this.addEdge(edge);\n }\n\n addExplicitDependency(dependent: ResourceRef, dependency: ResourceRef): void {\n this.addResource(dependent);\n this.addResource(dependency);\n this._adjacency.get(dependent.id)!.add(dependency.id);\n }\n\n /** Get the set of resource IDs that `resourceId` depends on. */\n getDependencies(resourceId: string): ReadonlySet<string> {\n return this._adjacency.get(resourceId) ?? new Set();\n }\n\n get resourceIds(): ReadonlyArray<string> {\n return [...this._resources.keys()];\n }\n\n get edges(): ReadonlyArray<DependencyEdge> {\n return this._edges;\n }\n\n /**\n * Returns a topological ordering of resources.\n * If a cycle is detected, returns { order: null, cycle: string[] }.\n */\n topologicalSort(): { order: string[] } | { order: null; cycle: string[] } {\n const visited = new Set<string>();\n const visiting = new Set<string>();\n const sorted: string[] = [];\n\n const visit = (id: string): string[] | null => {\n if (visited.has(id)) return null;\n if (visiting.has(id)) {\n // Build cycle path\n return [...visiting, id];\n }\n visiting.add(id);\n const deps = this._adjacency.get(id);\n if (deps) {\n for (const depId of deps) {\n const cycle = visit(depId);\n if (cycle) return cycle;\n }\n }\n visiting.delete(id);\n visited.add(id);\n sorted.push(id);\n return null;\n };\n\n for (const id of this._resources.keys()) {\n const cycle = visit(id);\n if (cycle) {\n // Trim cycle to start from the repeated node\n const start = cycle[cycle.length - 1]!;\n const startIdx = cycle.indexOf(start);\n return { order: null, cycle: cycle.slice(startIdx) };\n }\n }\n return { order: sorted };\n }\n}\n","/** Identifies a resource in the dependency graph. */\nexport interface ResourceRef {\n readonly id: string;\n}\n\n/** A dependency edge between two resources at specific field paths. */\nexport interface DependencyEdge {\n /** Resource being read from (observed state). */\n readonly from: ResourceRef;\n /** Path in the source resource's observed data. */\n readonly fromPath: string;\n /** Resource being written to (desired state). */\n readonly to: ResourceRef;\n /** Path in the target resource's desired data. */\n readonly toPath: string;\n}\n\n/**\n * A Pending marker stored in a desired document when a ReadProxy value\n * is assigned. Carries full source info so the resolve phase knows\n * where to look for the concrete value.\n */\nconst PENDING_TAG: unique symbol = Symbol.for('xplane.pending') as unknown as typeof PENDING_TAG;\n\nexport class Pending {\n static readonly TAG = PENDING_TAG;\n readonly [PENDING_TAG] = true;\n\n constructor(\n /** The resource that owns the observed data. */\n readonly source: ResourceRef,\n /** The path within that resource's observed data. */\n readonly path: string,\n ) {}\n\n static is(value: unknown): value is Pending {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_TAG] === true\n );\n }\n}\n\n/** Metadata associated with a ReadProxy instance. */\nexport interface ReadProxyMeta {\n readonly owner: ResourceRef;\n readonly path: string;\n}\n\n// ─── PendingTemplate ─────────────────────────────────────────────────────────\n\n/**\n * A Pending-like marker for strings produced by template literals that\n * interpolate one or more unresolved ReadProxy values.\n *\n * Holds the template structure so the resolve phase can reconstruct the\n * final string once all dependency slots are available.\n *\n * Invariant: parts.length === slots.length + 1\n * result = parts[0] + resolved[0] + parts[1] + … + resolved[n-1] + parts[n]\n */\nconst PENDING_TEMPLATE_TAG: unique symbol = Symbol.for(\n 'xplane.pendingTemplate',\n) as unknown as typeof PENDING_TEMPLATE_TAG;\n\nexport class PendingTemplate {\n static readonly TAG = PENDING_TEMPLATE_TAG;\n readonly [PENDING_TEMPLATE_TAG] = true;\n\n constructor(\n /** Literal text segments between (and around) pending slots. */\n readonly parts: readonly string[],\n /** The pending slots — each maps to an entry in a resource's observed state. */\n readonly slots: ReadonlyArray<{ source: ResourceRef; path: string }>,\n ) {}\n\n static is(value: unknown): value is PendingTemplate {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_TEMPLATE_TAG] === true\n );\n }\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\nimport type { ReadProxyMeta, ResourceRef } from './types.js';\nimport { PendingTemplate } from './types.js';\n\n// ─── Token Registry ───────────────────────────────────────────────────────────\n\nexport interface TokenRegistry {\n readonly byToken: Map<string, ReadProxyMeta>;\n readonly byKey: Map<string, string>;\n counter: number;\n}\n\n/**\n * Per-run AsyncLocalStorage for the template-literal token registry.\n * Kept separate from compositionStorage (core/) to avoid circular deps.\n */\nexport const tokenRegistryStorage = new AsyncLocalStorage<TokenRegistry>();\n\nexport function createTokenRegistry(): TokenRegistry {\n return { byToken: new Map(), byKey: new Map(), counter: 0 };\n}\n\n/**\n * Get or create a stable token for a given (owner, path) pair.\n * Returns null when no registry is active (outside of a composition run).\n */\nexport function getOrCreateToken(owner: ResourceRef, path: string): string | null {\n const registry = tokenRegistryStorage.getStore();\n if (!registry) return null;\n\n const key = `${owner.id}\\0${path}`;\n const existing = registry.byKey.get(key);\n if (existing !== undefined) return existing;\n\n const token = `__pending__tpl_${registry.counter++}__`;\n registry.byToken.set(token, { owner, path });\n registry.byKey.set(key, token);\n return token;\n}\n\nexport function lookupToken(token: string): ReadProxyMeta | undefined {\n return tokenRegistryStorage.getStore()?.byToken.get(token);\n}\n\n// ─── String Processing ────────────────────────────────────────────────────────\n\nconst TEMPLATE_TOKEN_RE = /__pending__tpl_\\d+__/g;\n\n/**\n * Scan a string for pending template tokens. If any are found, calls\n * `onSlot` for each registered token and returns a PendingTemplate.\n * Returns the original string if no tokens are found or none are registered.\n */\nexport function processStringValue(\n value: string,\n onSlot: (meta: ReadProxyMeta) => void,\n): PendingTemplate | string {\n const parts: string[] = [];\n const slots: Array<{ source: ResourceRef; path: string }> = [];\n let lastIndex = 0;\n let hasSlots = false;\n\n // Reset lastIndex before iterating (regex is stateful)\n TEMPLATE_TOKEN_RE.lastIndex = 0;\n\n for (const match of value.matchAll(TEMPLATE_TOKEN_RE)) {\n const meta = lookupToken(match[0]!);\n if (!meta) continue; // token not in registry — treat as literal\n\n hasSlots = true;\n parts.push(value.slice(lastIndex, match.index!));\n slots.push({ source: meta.owner, path: meta.path });\n onSlot(meta);\n lastIndex = match.index! + match[0]!.length;\n }\n\n if (!hasSlots) return value;\n\n parts.push(value.slice(lastIndex));\n return new PendingTemplate(parts, slots);\n}\n","import { getOrCreateToken } from './token-registry.js';\nimport type { ReadProxyMeta, ResourceRef } from './types.js';\n\n/**\n * WeakMap storing metadata for ReadProxy instances.\n * This avoids polluting proxy objects with symbols.\n */\nconst proxyMeta = new WeakMap<object, ReadProxyMeta>();\n\n/** Sentinel symbol to identify ReadProxy instances. */\nconst READ_PROXY_TAG = Symbol.for('xplane.readProxy');\n\n/**\n * Check if a value is a ReadProxy.\n */\nexport function isReadProxy(value: unknown): value is object {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[READ_PROXY_TAG] === true\n );\n}\n\n/**\n * Get the metadata for a ReadProxy value.\n */\nexport function getReadProxyMeta(value: unknown): ReadProxyMeta | undefined {\n if (!isReadProxy(value)) return undefined;\n return proxyMeta.get(value as object);\n}\n\n/**\n * Creates a ReadProxy that wraps observed data.\n *\n * - Property access navigates into the data, building up the path.\n * - Missing paths return `undefined` (no placeholder proxies).\n * - The proxy carries owner + path metadata so that when it's assigned\n * to a WriteProxy, the dependency edge can be recorded.\n */\nexport function createReadProxy<T extends object>(\n target: T,\n owner: ResourceRef,\n basePath: string,\n): T {\n const proxy = new Proxy(target, {\n get(obj, prop, receiver) {\n // Identity checks\n if (prop === READ_PROXY_TAG) return true;\n if (typeof prop === 'symbol') return Reflect.get(obj, prop, receiver);\n if (prop === 'toJSON') return () => obj;\n\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const value = Reflect.get(obj, prop, receiver);\n\n if (value === undefined || value === null) {\n // Return a \"leaf\" proxy with undefined target — carries metadata\n // for dependency edge creation but resolves to undefined\n return createLeafReadProxy(owner, childPath);\n }\n\n if (typeof value === 'object') {\n // Wrap nested objects so path accumulates\n return createReadProxy(value as object, owner, childPath);\n }\n\n // Primitive — wrap in a tagged object so it can carry metadata\n // when assigned to a WriteProxy\n return createPrimitiveReadProxy(value as string | number | boolean, owner, childPath);\n },\n\n has(obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return Reflect.has(obj, prop);\n },\n });\n\n proxyMeta.set(proxy, { owner, path: basePath });\n return proxy as T;\n}\n\n/**\n * A \"leaf\" ReadProxy for paths that don't exist in observed data yet.\n * Carries metadata for edge creation. Resolves to `undefined` when\n * coerced to a primitive.\n */\nfunction createLeafReadProxy(owner: ResourceRef, path: string): object {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n const getToken = () => getOrCreateToken(owner, path) ?? `__pending__${owner.id}__${path}`;\n const proxy = new Proxy(target, {\n get(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n if (prop === Symbol.toPrimitive) return () => getToken();\n if (typeof prop === 'symbol') return undefined;\n if (prop === 'toJSON') return () => undefined;\n if (prop === 'toString') return () => getToken();\n if (prop === 'valueOf') return () => proxy;\n // Nested access on a leaf — still a leaf with extended path\n return createLeafReadProxy(owner, `${path}.${String(prop)}`);\n },\n has(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return false;\n },\n });\n proxyMeta.set(proxy, { owner, path });\n return proxy;\n}\n\n/**\n * Wraps a concrete primitive value so it carries ReadProxy metadata.\n * This allows the WriteProxy to detect it during assignment and\n * record the dependency edge, while the value itself resolves correctly.\n */\nexport function createPrimitiveReadProxy(\n value: string | number | boolean,\n owner: ResourceRef,\n path: string,\n): object {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n const proxy = new Proxy(target, {\n get(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n if (prop === Symbol.toPrimitive) return () => value;\n if (prop === 'valueOf') return () => value;\n if (prop === 'toString') return () => String(value);\n if (prop === 'toJSON') return () => value;\n if (typeof prop === 'symbol') return undefined;\n // Navigating into a primitive — leaf\n return createLeafReadProxy(owner, `${path}.${String(prop)}`);\n },\n has(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return false;\n },\n });\n proxyMeta.set(proxy, { owner, path });\n return proxy;\n}\n","import {\n createPrimitiveReadProxy,\n createReadProxy,\n getReadProxyMeta,\n isReadProxy,\n} from './read-proxy.js';\nimport { processStringValue } from './token-registry.js';\nimport { type DependencyEdge, Pending, type ResourceRef } from './types.js';\n\n/**\n * Collector that accumulates dependency edges discovered during\n * WriteProxy assignments.\n */\nexport class EdgeCollector {\n private readonly _edges: DependencyEdge[] = [];\n\n add(edge: DependencyEdge): void {\n // Deduplicate\n const exists = this._edges.some(\n (e) =>\n e.from.id === edge.from.id &&\n e.fromPath === edge.fromPath &&\n e.to.id === edge.to.id &&\n e.toPath === edge.toPath,\n );\n if (!exists) this._edges.push(edge);\n }\n\n get edges(): ReadonlyArray<DependencyEdge> {\n return this._edges;\n }\n}\n\nexport interface WriteProxyOptions {\n /** The resource that owns this desired document. */\n owner: ResourceRef;\n /** The collector to record edges into. */\n collector: EdgeCollector;\n /** Base path prefix (e.g., \"spec\" when wrapping the spec subtree). */\n basePath?: string;\n /** Optional observed state at the same path for fallback reads. */\n observed?: Record<string, unknown>;\n}\n\n/**\n * Creates a WriteProxy that wraps a desired document.\n *\n * - Writes store values in the target.\n * - When a ReadProxy value is assigned, it records a dependency edge\n * and stores a Pending marker if the value is not yet concrete.\n * - Reads return the stored value (desired-first).\n */\nexport function createWriteProxy<T extends object>(target: T, opts: WriteProxyOptions): T {\n const { owner, collector, basePath = '', observed } = opts;\n\n return new Proxy(target, {\n get(obj, prop, receiver) {\n if (typeof prop === 'symbol') return Reflect.get(obj, prop, receiver);\n if (prop === 'toJSON') return () => obj;\n\n const value = Reflect.get(obj, prop, receiver);\n\n // If the value is a nested object (not a Pending), wrap it recursively\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const childObserved =\n observed && String(prop) in observed && typeof observed[String(prop)] === 'object'\n ? (observed[String(prop)] as Record<string, unknown>)\n : undefined;\n return createWriteProxy(value as object, {\n owner,\n collector,\n basePath: childPath,\n observed: childObserved,\n });\n }\n\n // If value is undefined and observed has data at this path, fall through to ReadProxy\n if (value === undefined && observed && String(prop) in observed) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const obsValue = observed[String(prop)];\n if (typeof obsValue === 'object' && obsValue !== null) {\n return createReadProxy(obsValue as object, owner, childPath);\n }\n if (obsValue !== undefined && obsValue !== null) {\n return createPrimitiveReadProxy(obsValue as string | number | boolean, owner, childPath);\n }\n }\n\n // If value is undefined and observed doesn't have it either, return a leaf ReadProxy\n // so that cross-resource references create proper dependency edges and Pending markers\n if (value === undefined && observed !== undefined) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n return createReadProxy(Object.create(null) as object, owner, childPath);\n }\n\n return value;\n },\n\n set(obj, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(obj, prop, value);\n\n const targetPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n\n // Check if the value being assigned is a ReadProxy\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value);\n if (meta && meta.owner.id !== owner.id) {\n // Record dependency edge\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: targetPath,\n });\n\n // Try to extract a concrete value via Symbol.toPrimitive\n const primitive = tryExtractPrimitive(value);\n if (primitive !== undefined) {\n // The value is already concrete (primitive from observed data)\n return Reflect.set(obj, prop, primitive);\n }\n\n // Not concrete — store a Pending marker\n return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));\n }\n\n // Self-reference or XR — try to extract value\n const primitive = tryExtractPrimitive(value);\n if (primitive !== undefined) {\n return Reflect.set(obj, prop, primitive);\n }\n\n // XR leaf with no value — store Pending\n if (meta) {\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: targetPath,\n });\n return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));\n }\n }\n\n // String with pending template tokens\n if (typeof value === 'string') {\n const processed = processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: targetPath });\n });\n return Reflect.set(obj, prop, processed);\n }\n\n // Plain object — deep-process to catch nested ReadProxy values\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n const processed = deepProcessValue(value, owner, targetPath, collector);\n return Reflect.set(obj, prop, processed);\n }\n\n return Reflect.set(obj, prop, value);\n },\n\n deleteProperty(obj, prop) {\n return Reflect.deleteProperty(obj, prop);\n },\n }) as T;\n}\n\n/**\n * Try to extract a primitive value from a ReadProxy via Symbol.toPrimitive.\n * Returns `undefined` if the proxy represents a non-existent (leaf) value.\n */\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\n/**\n * Deep-process a plain object/array being assigned to a WriteProxy.\n * Replaces any nested ReadProxy values with Pending markers or concrete values.\n */\nfunction deepProcessValue(\n value: unknown,\n owner: ResourceRef,\n basePath: string,\n collector: EdgeCollector,\n): unknown {\n if (value === null || value === undefined) return value;\n\n if (typeof value === 'string') {\n return processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: basePath });\n });\n }\n\n if (typeof value !== 'object') return value;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value)!;\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: basePath,\n });\n const primitive = tryExtractPrimitive(value as object);\n if (primitive !== undefined) return primitive;\n return new Pending(meta.owner, meta.path);\n }\n\n if (Array.isArray(value as object)) {\n return (value as unknown[]).map((item, i) =>\n deepProcessValue(item, owner, `${basePath}[${i}]`, collector),\n );\n }\n\n // Plain object — recurse\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = deepProcessValue(val, owner, `${basePath}.${key}`, collector);\n }\n return result;\n}\n","import { Construct } from 'constructs';\n\nimport type { ReadyCheck, ReadyCheckFn } from '../readiness/index.js';\nimport {\n createPrimitiveReadProxy,\n createReadProxy,\n createWriteProxy,\n type DependencyGraph,\n type EdgeCollector,\n getReadProxyMeta,\n isReadProxy,\n Pending,\n type ResourceRef,\n} from '../tracking/index.js';\nimport { processStringValue } from '../tracking/token-registry.js';\nimport { compositionStorage } from './context.js';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/** Minimal shape for a Kubernetes resource — only apiVersion + kind required. */\nexport interface KubernetesResource {\n apiVersion: string;\n kind: string;\n metadata?: {\n name?: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n/** Props passed to the Resource constructor — becomes the desired document. */\nexport interface ResourceProps {\n apiVersion: string;\n kind: string;\n [key: string]: unknown;\n}\n\n/** Framework configuration accessible via `resource.resource`. */\nexport interface ResourceConfig {\n autoReady: boolean;\n addReadyCheck(fn: ReadyCheckFn, priority?: number): void;\n}\n\n/** Internal metadata stored per Resource (not exposed on the proxy). */\ninterface ResourceInternals {\n /** Unique reference for the dependency graph. */\n ref: ResourceRef;\n /** The desired document (what the user wrote). */\n desired: Record<string, unknown>;\n /** The observed document (populated by the hydrate phase). */\n observed: Record<string, unknown>;\n /** Whether this is an external (existing) resource. */\n external: boolean;\n /** For external resources: the lookup key. */\n externalRef?: ExternalResourceRef;\n /** Framework config. */\n config: ResourceConfig;\n /** Custom readiness checks registered by the composition author. */\n readyChecks: ReadyCheck[];\n /** The dependency graph. */\n graph: DependencyGraph;\n /** The edge collector. */\n collector: EdgeCollector;\n}\n\nexport interface ExternalResourceRef {\n apiVersion: string;\n kind: string;\n name: unknown;\n namespace?: string;\n refKey: string;\n}\n\n// ─── WeakMap stores for internal data ─────────────────────────────────────────\n\nconst internals = new WeakMap<Resource, ResourceInternals>();\n\n// ─── Resource class ───────────────────────────────────────────────────────────\n\n/**\n * A Kubernetes resource within a Composition.\n *\n * The Resource instance acts as a \"desired-first, fallback-to-observed\" proxy:\n * - Reading a path that exists in the desired document returns the desired value.\n * - Reading a path that does NOT exist in desired falls through to a tracked\n * ReadProxy over observed state (creates dependency edges).\n * - Writing always goes to the desired document.\n *\n * The only reserved properties are `node` (from Construct) and `resource`\n * (framework config namespace).\n */\nexport class Resource extends Construct {\n readonly resource: ResourceConfig;\n declare metadata: {\n name?: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n\n constructor(scope: Construct, id: string, props: ResourceProps) {\n super(scope, id);\n\n const graph = scope.node.tryGetContext('xplane:graph') as DependencyGraph;\n const collector = scope.node.tryGetContext('xplane:collector') as EdgeCollector;\n\n if (!graph || !collector) {\n throw new Error('Resource must be created within a Composition tree.');\n }\n\n const ref: ResourceRef = { id: this.node.path };\n graph.addResource(ref);\n\n const readyChecks: ReadyCheck[] = [];\n const config: ResourceConfig = {\n autoReady: true,\n addReadyCheck(fn: ReadyCheckFn, priority = 50) {\n readyChecks.push({ fn, priority });\n },\n };\n this.resource = config;\n\n // Process props — deep scan for ReadProxy values in the desired doc\n const desired = processDesiredProps(props, ref, collector);\n\n const internal: ResourceInternals = {\n ref,\n desired,\n observed: {},\n external: false,\n config,\n readyChecks,\n graph,\n collector,\n };\n internals.set(this, internal);\n\n // Pre-hydrate composed resources from observed data if available — so that\n // proxy reads during sibling construction (e.g. `Secret.fromExistingByName(this, other.status.x)`)\n // return real values instead of pending tokens that bake into construct IDs.\n const ctx = compositionStorage.getStore();\n if (ctx) {\n const observed = ctx.observedComposed.get(this.node.path);\n if (observed) {\n Object.assign(internal.observed, observed);\n }\n }\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 // Patch node.host so that node.findAll() (used by .with()) starts from the\n // proxy rather than the raw instance. Without this, applyTo() receives the\n // raw Resource where declared-only fields like `spec` are undefined at runtime.\n // biome-ignore lint/suspicious/noExplicitAny: patching constructs Node internals is intentional\n (this.node as any).host = proxy;\n\n // biome-ignore lint/correctness/noConstructorReturn: Proxy wrapping is intentional\n return proxy;\n }\n\n /**\n * Look up an existing cluster resource by name.\n * Returns a Resource that only has observed state (no desired output).\n *\n * The `name` parameter accepts either a plain string or a PrimitiveReadProxy\n * (returned when reading a tracked property like `ns.metadata.labels['x']`).\n * Proxies are coerced to their underlying string via `Symbol.toPrimitive`.\n */\n static fromExistingByName(\n scope: Construct,\n apiVersion: string,\n kind: string,\n name: unknown,\n namespace?: string,\n ): Resource {\n const resolvedName = coerceToString(name);\n const refKey = computeRefKey(apiVersion, kind, resolvedName, namespace);\n const id = `__existing__${refKey.replace(/\\//g, '_')}`;\n\n const instance = new Resource(scope, id, { apiVersion, kind });\n const internal = internals.get(instance)!;\n internal.external = true;\n internal.externalRef = { apiVersion, kind, name: resolvedName ?? name, namespace, refKey };\n\n // Pre-hydrate from context if observed data is already available (from a prior iteration)\n const ctx = compositionStorage.getStore();\n if (ctx) {\n const observed = ctx.requiredResources.get(refKey);\n if (observed) {\n Object.assign(internal.observed, observed);\n }\n }\n\n return instance;\n }\n\n /**\n * Generate a deterministic unique name based on the XR identity and construct path.\n * Useful for resource fields that need unique names (e.g., AWS resource names).\n */\n static uniqueName(\n scope: Construct,\n options: {\n maxLength?: number;\n separator?: string;\n allowedPattern?: RegExp;\n extra?: string;\n } = {},\n ): string {\n const maxLength = options.maxLength ?? 63;\n const separator = options.separator ?? '-';\n const allowedPattern = options.allowedPattern ?? /[^a-zA-Z0-9]/g;\n const escapedSep = separator.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const collapseRe = new RegExp(`${escapedSep}+`, 'g');\n\n const clean = (s: string) =>\n s\n .replace(/\\s+/g, '')\n .replace(allowedPattern, separator)\n .replace(collapseRe, separator)\n .replace(new RegExp(`^${escapedSep}|${escapedSep}$`, 'g'), '');\n\n const xrMeta = scope.node.tryGetContext('xplane:xr-meta') as\n | { name?: string; namespace?: string }\n | undefined;\n\n const parts: string[] = [];\n if (xrMeta?.namespace) parts.push(clean(xrMeta.namespace));\n if (xrMeta?.name) parts.push(clean(xrMeta.name));\n for (const s of scope.node.scopes.slice(1)) {\n const c = clean(s.node.id);\n if (c) parts.push(c);\n }\n if (options.extra) {\n const c = clean(options.extra);\n if (c) parts.push(c);\n }\n\n const full = parts.join(separator);\n const hash = shortHash(full);\n const withHash = `${full}${separator}${hash}`;\n\n if (withHash.length <= maxLength) return withHash;\n const prefix = full.slice(0, maxLength - hash.length - separator.length);\n return `${prefix}${separator}${hash}`;\n }\n\n /**\n * Like {@link uniqueName} but produces names compliant with RFC 1123 DNS labels:\n * lowercase alphanumeric characters and hyphens only, starting and ending with\n * an alphanumeric character. Suitable for use as Kubernetes resource names.\n */\n static uniqueNameRfc1123(\n scope: Construct,\n options: {\n maxLength?: number;\n extra?: string;\n } = {},\n ): string {\n const maxLength = options.maxLength ?? 63;\n\n const clean = (s: string) =>\n s\n .toLowerCase()\n .replace(/\\s+/g, '')\n .replace(/[^a-z0-9-]/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n\n const xrMeta = scope.node.tryGetContext('xplane:xr-meta') as\n | { name?: string; namespace?: string }\n | undefined;\n\n const parts: string[] = [];\n if (xrMeta?.namespace) parts.push(clean(xrMeta.namespace));\n if (xrMeta?.name) parts.push(clean(xrMeta.name));\n for (const s of scope.node.scopes.slice(1)) {\n const c = clean(s.node.id);\n if (c) parts.push(c);\n }\n if (options.extra) {\n const c = clean(options.extra);\n if (c) parts.push(c);\n }\n\n const full = parts.join('-');\n const hash = shortHash(full);\n const withHash = `${full}-${hash}`;\n\n if (withHash.length <= maxLength) return withHash;\n const prefix = full.slice(0, maxLength - hash.length - 1);\n const trimmedPrefix = prefix.replace(/-+$/, '');\n return trimmedPrefix ? `${trimmedPrefix}-${hash}` : hash;\n }\n}\n\n// ─── Internal accessors (used by pipeline phases) ─────────────────────────────\n\nexport function getResourceInternals(resource: Resource): ResourceInternals {\n const internal = internals.get(resource);\n if (!internal) throw new Error('Resource internals not found');\n return internal;\n}\n\nexport function getResourceRef(resource: Resource): ResourceRef {\n return getResourceInternals(resource).ref;\n}\n\nexport function getDesiredDocument(resource: Resource): Record<string, unknown> {\n return getResourceInternals(resource).desired;\n}\n\nexport function getObservedDocument(resource: Resource): Record<string, unknown> {\n return getResourceInternals(resource).observed;\n}\n\nexport function hydrateObserved(resource: Resource, data: Record<string, unknown>): void {\n const internal = getResourceInternals(resource);\n Object.assign(internal.observed, data);\n}\n\nexport function isExternal(resource: Resource): boolean {\n return getResourceInternals(resource).external;\n}\n\nexport function getExternalRef(resource: Resource): ExternalResourceRef | undefined {\n return getResourceInternals(resource).externalRef;\n}\n\nexport function getReadyChecks(resource: Resource): ReadyCheck[] {\n return getResourceInternals(resource).readyChecks;\n}\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\n/**\n * Coerce a value to a string, handling PrimitiveReadProxy objects that wrap\n * primitive values behind a `Symbol.toPrimitive` method.\n * Returns `undefined` if the value cannot be resolved to a string.\n */\nfunction coerceToString(value: unknown): string | undefined {\n if (typeof value === 'string') return value;\n if (\n value != null &&\n typeof (value as { [Symbol.toPrimitive]?: unknown })[Symbol.toPrimitive] === 'function'\n ) {\n return String(value);\n }\n return undefined;\n}\n\nexport function computeRefKey(\n apiVersion: string,\n kind: string,\n name: string | undefined,\n namespace?: string,\n): string {\n const namePart = name ?? '__unresolved__';\n if (namespace) return `${apiVersion}/${kind}/${namespace}/${namePart}`;\n return `${apiVersion}/${kind}/${namePart}`;\n}\n\nfunction shortHash(s: string): string {\n let h = 5381;\n for (let i = 0; i < s.length; i++) {\n h = ((h << 5) + h) ^ s.charCodeAt(i);\n h = h >>> 0;\n }\n return h.toString(16).padStart(8, '0');\n}\n\n/**\n * Process the desired props — deep-scan for ReadProxy values and replace them\n * with Pending markers (recording edges in the collector).\n */\nfunction processDesiredProps(\n props: ResourceProps,\n owner: ResourceRef,\n collector: EdgeCollector,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n result[key] = processValue(value, owner, key, collector);\n }\n return result;\n}\n\nfunction processValue(\n value: unknown,\n owner: ResourceRef,\n path: string,\n collector: EdgeCollector,\n): unknown {\n if (value === null || value === undefined) return value;\n\n if (typeof value === 'string') {\n return processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: path });\n });\n }\n\n if (typeof value !== 'object') return value;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value)!;\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: path,\n });\n // Try to get concrete value\n const prim = tryExtractPrimitive(value);\n if (prim !== undefined) return prim;\n return new Pending(meta.owner, meta.path);\n }\n\n if (Array.isArray(value as object)) {\n return (value as unknown[]).map((item, i) =>\n processValue(item, owner, `${path}[${i}]`, collector),\n );\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = processValue(val, owner, `${path}.${key}`, collector);\n }\n return result;\n}\n\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\n/**\n * Creates the \"desired-first, fallback-to-observed\" proxy around a Resource.\n */\nfunction createResourceProxy(resource: Resource, internal: ResourceInternals): Resource {\n const { ref, desired, collector } = internal;\n\n const proxy = new Proxy(resource, {\n get(target, prop, receiver) {\n // Framework reserved properties\n if (prop === 'node') return Reflect.get(target, prop, receiver);\n if (prop === 'resource') return Reflect.get(target, prop, receiver);\n if (typeof prop === 'symbol') return Reflect.get(target, prop, receiver);\n\n // Prototype methods and inherited Construct methods (e.g. .with(), .toString())\n if (prop === 'constructor') return Reflect.get(target, prop, receiver);\n const protoValue = Reflect.get(target, prop, receiver);\n if (typeof protoValue === 'function') return protoValue.bind(proxy);\n\n // Check desired first\n if (prop in desired) {\n const value = desired[String(prop)];\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n // Return a WriteProxy so nested writes go to desired\n // Pass observed at the same path for fallback reads\n const observed = internal.observed;\n const observedAtPath =\n String(prop) in observed && typeof observed[String(prop)] === 'object'\n ? (observed[String(prop)] as Record<string, unknown>)\n : {};\n return createWriteProxy(value as object, {\n owner: ref,\n collector,\n basePath: String(prop),\n observed: observedAtPath,\n });\n }\n return value;\n }\n\n // Fallback to observed via ReadProxy\n const observed = internal.observed;\n if (String(prop) in observed) {\n const value = observed[String(prop)];\n if (typeof value === 'object' && value !== null) {\n return createReadProxy(value as object, ref, String(prop));\n }\n // Primitive observed value — wrap in ReadProxy for tracking\n return createPrimitiveReadProxyFromResource(value, ref, String(prop));\n }\n\n // Path exists in neither — return a lazy-init proxy that behaves as a\n // ReadProxy for reads but auto-initializes the path in desired on write.\n return createLazyInitProxy(desired, ref, collector, String(prop));\n },\n\n set(target, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(target, prop, value);\n if (prop === 'resource') return Reflect.set(target, prop, value);\n\n // All writes go to desired, processing ReadProxy values\n const path = String(prop);\n desired[path] = processValue(value, ref, path, collector);\n return true;\n },\n\n has(target, prop) {\n if (typeof prop === 'symbol') return Reflect.has(target, prop);\n if (prop === 'node' || prop === 'resource') return true;\n return prop in desired || prop in internal.observed;\n },\n }) as Resource;\n\n // Store internal mapping for the proxy too, so internals.get(proxy) works\n internals.set(proxy, internal);\n return proxy;\n}\n\n/**\n * Wrap a primitive observed value so it carries ReadProxy metadata\n * for dependency tracking when assigned elsewhere.\n */\nfunction createPrimitiveReadProxyFromResource(\n value: unknown,\n owner: ResourceRef,\n path: string,\n): unknown {\n if (value === null || value === undefined) return value;\n return createPrimitiveReadProxy(value as string | number | boolean, owner, path);\n}\n\n/**\n * Creates a proxy for a path that exists in neither desired nor observed.\n * - Reading nested properties returns ReadProxy leaves (for dependency tracking).\n * - Writing a nested property auto-initializes the path in desired and stores the value.\n */\nfunction createLazyInitProxy(\n desired: Record<string, unknown>,\n owner: ResourceRef,\n collector: EdgeCollector,\n basePath: string,\n): object {\n const readProxy = createReadProxy({} as object, owner, basePath);\n\n return new Proxy(readProxy as object, {\n get(target, prop, receiver) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop, receiver);\n // Delegate reads to the ReadProxy (for tracking)\n return Reflect.get(target, prop, receiver);\n },\n\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n // Auto-initialize the parent object in desired\n let container = desired[basePath] as Record<string, unknown> | undefined;\n if (!container || typeof container !== 'object') {\n container = {};\n desired[basePath] = container;\n }\n container[String(prop)] = processValue(\n value,\n owner,\n `${basePath}.${String(prop)}`,\n collector,\n );\n return true;\n },\n });\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { XplaneLogger } from './types.js';\n\nconst noopLogger: XplaneLogger = {\n debug() {},\n info() {},\n warn() {},\n};\n\nconst loggerStorage = new AsyncLocalStorage<XplaneLogger>();\n\n/**\n * Get the current logger from async context.\n * Returns a no-op logger if none has been set (silent by default).\n */\nexport function getLogger(): XplaneLogger {\n return loggerStorage.getStore() ?? noopLogger;\n}\n\n/**\n * Run a function with a logger available in async context.\n * All code within `fn` (and any nested async calls) can access\n * the logger via `getLogger()`.\n */\nexport function withLogger<T>(logger: XplaneLogger, fn: () => T): T {\n return loggerStorage.run(logger, fn);\n}\n","import {\n getDesiredDocument,\n getExternalRef,\n getObservedDocument,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { Pending } from '../tracking/index.js';\n\nimport type { DiagnosticReport, PipelineState } from './types.js';\n\n/**\n * DIAGNOSE phase: produce structured diagnostics for blocked resources.\n *\n * For each resource classified as 'blocked':\n * - Find all Pending markers in the desired document\n * - Report what they're waiting on (source resource + path)\n *\n * For circular dependencies (detected in sequence phase):\n * - Produce a 'cycle' diagnostic with the full cycle path\n */\nexport function diagnose(state: PipelineState): PipelineState {\n const diagnostics: DiagnosticReport[] = [];\n\n // Check for cycles from the graph\n const sortResult = state.graph.topologicalSort();\n if (sortResult.order === null && sortResult.cycle) {\n const firstCycleMember = sortResult.cycle[0];\n if (firstCycleMember) {\n diagnostics.push({\n resource: firstCycleMember,\n reason: 'cycle',\n cycle: sortResult.cycle,\n });\n }\n }\n\n // Report external resources that were required but not found.\n // Skip externals whose lookup name is itself unresolved (still a pending\n // template token, or non-string): the handler never sent a require for\n // them, so they aren't \"not found\" — they are downstream-blocked, and the\n // root cause (whatever upstream they're waiting on) will be reported on\n // its own.\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 if (typeof ref.name !== 'string' || ref.name.startsWith('__pending__')) continue;\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} '${ref.name}'${nsDisplay} was required but not found by Crossplane`,\n });\n }\n\n // For each blocked resource, find pending paths\n const pendingDiagnostics: DiagnosticReport[] = [];\n for (const resource of state.resources) {\n if (isExternal(resource)) continue;\n\n const ref = getResourceRef(resource);\n const classification = state.classification.get(ref.id);\n if (classification !== 'blocked') continue;\n\n // Skip if already reported as cycle member\n if (sortResult.order === null && sortResult.cycle?.includes(ref.id)) continue;\n\n const desired = getDesiredDocument(resource);\n const pendingPaths = findPendingPaths(desired, '');\n\n if (pendingPaths.length > 0) {\n pendingDiagnostics.push({\n resource: ref.id,\n reason: 'pending',\n pendingPaths,\n });\n }\n }\n\n // Filter out cascading diagnostics: only keep pending diagnostics that have\n // at least one dependency that is NOT itself blocked or not-found.\n // This surfaces only root causes rather than the full dependency cascade.\n const notFoundIds = new Set(\n diagnostics.filter((d) => d.reason === 'not-found').map((d) => d.resource),\n );\n const blockedIds = new Set(pendingDiagnostics.map((d) => d.resource));\n\n for (const diag of pendingDiagnostics) {\n const isRootCause = diag.pendingPaths?.some((p) => {\n const dep = p.waitingOn.resource;\n // If waiting on something that isn't blocked or not-found, this IS a root cause\n return !blockedIds.has(dep) && !notFoundIds.has(dep);\n });\n if (isRootCause) {\n diagnostics.push(diag);\n }\n }\n\n return { ...state, diagnostics };\n}\n\n/**\n * Recursively find all Pending markers in a document and report their source.\n */\nfunction findPendingPaths(\n obj: unknown,\n basePath: string,\n): Array<{ path: string; waitingOn: { resource: string; path: string } }> {\n const results: Array<{ path: string; waitingOn: { resource: string; path: string } }> = [];\n\n if (obj === null || obj === undefined) return results;\n if (Pending.is(obj)) {\n results.push({\n path: basePath,\n waitingOn: { resource: obj.source.id, path: obj.path },\n });\n return results;\n }\n if (typeof obj !== 'object') return results;\n\n if (Array.isArray(obj)) {\n for (let i = 0; i < obj.length; i++) {\n const childPath = basePath ? `${basePath}[${i}]` : `[${i}]`;\n results.push(...findPendingPaths(obj[i], childPath));\n }\n return results;\n }\n\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n const childPath = basePath ? `${basePath}.${key}` : key;\n results.push(...findPendingPaths(value, childPath));\n }\n return results;\n}\n","import { getXrDesiredStatus } from '../core/composition.js';\nimport {\n getDesiredDocument,\n getObservedDocument,\n getReadyChecks,\n getResourceInternals,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { getReadProxyMeta, isReadProxy } from '../tracking/index.js';\nimport { PendingTemplate } from '../tracking/types.js';\n\nimport type { EmittedResource, PipelineState } from './types.js';\n\n/**\n * EMIT phase: serialize each resource classified as 'emit' into a plain\n * Kubernetes resource document ready for Crossplane.\n *\n * Also extracts the XR desired status from this.xr.status assignments.\n *\n * For resources classified as 'blocked' that have previously-observed state,\n * emits the observed document as-is (marked `preserved: true`) so that\n * Crossplane does not delete them while their dependencies are still resolving.\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\n if (classification === 'emit') {\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 } else if (classification === 'blocked') {\n // If this resource has been observed before (i.e. Crossplane already created it),\n // emit the observed document stripped of server-managed fields so Crossplane does\n // not delete it while its dependencies are still pending.\n const observed = getObservedDocument(resource);\n if (Object.keys(observed).length === 0) continue;\n\n const name = ref.id.startsWith('Composition/') ? ref.id.slice('Composition/'.length) : ref.id;\n\n emitted.push({\n name,\n document: stripServerFields(deepClean(observed)),\n autoReady: false,\n readyChecks: [],\n preserved: true,\n });\n }\n }\n\n // Extract XR status and resolve any ReadProxy values using observed data\n const resourceById = new Map(state.resources.map((r) => [getResourceRef(r).id, r]));\n const rawStatus = getXrDesiredStatus(state.composition);\n const xrStatusPatches = resolveXrStatus(rawStatus, resourceById);\n\n return { ...state, emitted, xrStatusPatches };\n}\n\n/**\n * Deep-clone an object, stripping any remaining framework internals.\n * This produces a clean JSON-serializable Kubernetes document.\n */\nfunction deepClean(obj: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n result[key] = cleanValue(value);\n }\n\n return result;\n}\n\nfunction cleanValue(value: unknown): unknown {\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n if (PendingTemplate.is(value)) {\n // Should never reach emit — indicates a bug in the pipeline\n throw new Error(\n `PendingTemplate reached emit phase — resource should have been classified as blocked. Parts: ${JSON.stringify(value.parts)}`,\n );\n }\n\n if (Array.isArray(value)) {\n return value.map(cleanValue);\n }\n\n // Plain objects — recurse\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = cleanValue(val);\n }\n return result;\n}\n\n/**\n * Strip server-managed Kubernetes fields from an observed document before\n * emitting it as a preserved desired resource.\n *\n * These fields are set by the API server / controllers and must not appear\n * in the desired state — including them causes Crossplane to try propagating\n * them (e.g. `uid`) into XR resourceRefs fields that the XRD schema may not\n * declare, resulting in a typed-patch validation failure.\n */\nconst SERVER_MANAGED_METADATA = new Set([\n 'uid',\n 'resourceVersion',\n 'generation',\n 'creationTimestamp',\n 'deletionTimestamp',\n 'deletionGracePeriodSeconds',\n 'managedFields',\n 'ownerReferences',\n 'selfLink',\n]);\n\nfunction stripServerFields(doc: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...doc };\n\n // Remove top-level status — it is managed by the controller, not desired state\n delete result.status;\n\n // Strip server-managed metadata sub-fields\n if (result.metadata && typeof result.metadata === 'object') {\n const meta = { ...(result.metadata as Record<string, unknown>) };\n for (const field of SERVER_MANAGED_METADATA) {\n delete meta[field];\n }\n result.metadata = meta;\n }\n\n return result;\n}\n\n/**\n * Resolve ReadProxy values in XR status using observed resource data.\n * This is needed because XR status is written at construction time (before hydration),\n * so read proxy references need to be resolved post-hydration.\n */\nfunction resolveXrStatus(\n status: Record<string, unknown>,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(status)) {\n const resolved = resolveStatusValue(value, resourceById);\n if (resolved !== undefined) {\n result[key] = resolved;\n }\n }\n return result;\n}\n\nfunction resolveStatusValue(\n value: unknown,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): unknown {\n if (value === null || value === undefined) return undefined;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value);\n if (!meta) return undefined;\n\n // Try to extract a concrete primitive (already resolved read proxy)\n const prim = tryExtractPrimitive(value as object);\n if (prim !== undefined) return prim;\n\n // Leaf proxy — try to resolve from observed data\n const resource = resourceById.get(meta.owner.id);\n if (!resource) return undefined;\n const observed = getObservedDocument(resource);\n return getNestedValue(observed, meta.path);\n }\n\n if (Array.isArray(value)) {\n return value.map((v) => resolveStatusValue(v, resourceById)).filter((v) => v != null);\n }\n\n if (typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const resolved = resolveStatusValue(v, resourceById);\n if (resolved !== undefined) {\n out[k] = resolved;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n }\n\n return value;\n}\n\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values — skip them\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split('.');\n let current: unknown = obj;\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n","import { getExternalRef, hydrateObserved, isExternal } from '../core/resource.js';\n\nimport type { PipelineState } from './types.js';\n\n/**\n * HYDRATE phase: feed observed state from Crossplane into each resource.\n *\n * - Composed resources are matched by their construct path (resource name).\n * - External resources are matched by their refKey.\n */\nexport function hydrate(state: PipelineState): PipelineState {\n for (const resource of state.resources) {\n if (isExternal(resource)) {\n const ref = getExternalRef(resource);\n if (ref) {\n const observed = state.observedRequired.get(ref.refKey);\n if (observed) {\n hydrateObserved(resource, observed);\n }\n }\n } else {\n // Match by construct path\n const name = resource.node.path;\n const observed = state.observedComposed.get(name);\n if (observed) {\n hydrateObserved(resource, observed);\n }\n }\n }\n\n return state;\n}\n","import { getDesiredDocument, getObservedDocument, getResourceRef } from '../core/resource.js';\nimport { Pending, PendingTemplate } from '../tracking/index.js';\n\nimport type { PipelineState } from './types.js';\n\n/**\n * RESOLVE phase: walk dependency edges and replace Pending markers\n * with concrete values from observed state where available.\n *\n * For each resource's desired document, recursively find Pending values.\n * Look up the source resource's observed state at the source path.\n * If concrete → replace. If not available → leave Pending in place.\n */\nexport function resolve(state: PipelineState): PipelineState {\n // Build a lookup: resource id → Resource instance\n const resourceById = new Map(state.resources.map((r) => [getResourceRef(r).id, r]));\n\n for (const resource of state.resources) {\n const desired = getDesiredDocument(resource);\n resolvePending(desired, resourceById);\n }\n\n return state;\n}\n\n/**\n * Recursively walk an object and resolve any Pending markers.\n */\nfunction resolvePending(\n obj: Record<string, unknown>,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): void {\n for (const [key, value] of Object.entries(obj)) {\n if (Pending.is(value)) {\n const sourceResource = resourceById.get(value.source.id);\n if (sourceResource) {\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, value.path);\n if (resolved !== undefined) {\n obj[key] = resolved;\n }\n // else: leave Pending in place — still unresolved\n }\n } else if (PendingTemplate.is(value)) {\n const resolved = resolvePendingTemplate(value, resourceById);\n if (resolved !== undefined) obj[key] = resolved;\n } else if (Array.isArray(value)) {\n resolveArray(value, resourceById);\n } else if (value !== null && typeof value === 'object') {\n resolvePending(value as Record<string, unknown>, resourceById);\n }\n }\n}\n\nfunction resolveArray(\n arr: unknown[],\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): void {\n for (let i = 0; i < arr.length; i++) {\n const value = arr[i];\n if (Pending.is(value)) {\n const sourceResource = resourceById.get(value.source.id);\n if (sourceResource) {\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, value.path);\n if (resolved !== undefined) {\n arr[i] = resolved;\n }\n }\n } else if (PendingTemplate.is(value)) {\n const resolved = resolvePendingTemplate(value, resourceById);\n if (resolved !== undefined) arr[i] = resolved;\n } else if (Array.isArray(value)) {\n resolveArray(value, resourceById);\n } else if (value !== null && typeof value === 'object') {\n resolvePending(value as Record<string, unknown>, resourceById);\n }\n }\n}\n\n/**\n * Get a nested value from an object by dot-separated path.\n */\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const segments = path.split('.');\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (current === null || current === undefined) return undefined;\n if (typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n\n return current;\n}\n\n/**\n * Attempt to resolve all slots of a PendingTemplate.\n * Returns the reconstructed string if all slots resolve, undefined otherwise.\n */\nfunction resolvePendingTemplate(\n template: PendingTemplate,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): string | undefined {\n const values: string[] = [];\n for (const slot of template.slots) {\n const sourceResource = resourceById.get(slot.source.id);\n if (!sourceResource) return undefined;\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, slot.path);\n if (resolved === undefined || resolved === null) return undefined;\n values.push(String(resolved));\n }\n let result = template.parts[0]!;\n for (let i = 0; i < values.length; i++) {\n result += values[i] + template.parts[i + 1]!;\n }\n return result;\n}\n","import { getDesiredDocument, getResourceRef, isExternal } from '../core/resource.js';\nimport { Pending, PendingTemplate } from '../tracking/index.js';\n\nimport type { PipelineState, ResourceClassification } from './types.js';\n\n/**\n * SEQUENCE phase: topological sort and classification.\n *\n * - Runs topological sort on the dependency graph.\n * - Classifies each resource as 'emit', 'blocked', or 'external'.\n * - A resource is 'blocked' if it still has Pending markers in its desired document.\n * - External resources are classified as 'external' (never emitted).\n * - Circular dependencies are detected via the graph's topological sort.\n */\nexport function sequence(state: PipelineState): PipelineState {\n const classification = new Map<string, ResourceClassification>();\n\n // Run topological sort for cycle detection\n const sortResult = state.graph.topologicalSort();\n\n // Classify each resource\n for (const resource of state.resources) {\n const ref = getResourceRef(resource);\n\n if (isExternal(resource)) {\n classification.set(ref.id, 'external');\n continue;\n }\n\n // Check if this resource has any remaining Pending markers\n const desired = getDesiredDocument(resource);\n const hasPending = containsPending(desired);\n\n if (hasPending) {\n classification.set(ref.id, 'blocked');\n } else {\n classification.set(ref.id, 'emit');\n }\n }\n\n // If there's a cycle, mark all cycle members as blocked\n if (sortResult.order === null && sortResult.cycle) {\n for (const id of sortResult.cycle) {\n if (classification.get(id) !== 'external') {\n classification.set(id, 'blocked');\n }\n }\n }\n\n return { ...state, classification };\n}\n\n/**\n * Recursively check if an object contains any Pending markers.\n */\nfunction containsPending(obj: unknown): boolean {\n if (obj === null || obj === undefined) return false;\n if (Pending.is(obj)) return true;\n if (PendingTemplate.is(obj)) return true;\n if (typeof obj !== 'object') return false;\n\n if (Array.isArray(obj)) {\n return obj.some(containsPending);\n }\n\n for (const value of Object.values(obj as Record<string, unknown>)) {\n if (containsPending(value)) return true;\n }\n return false;\n}\n","import type { Composition } from '../core/composition.js';\nimport type { Resource } from '../core/resource.js';\n\nimport { diagnose } from './diagnose.js';\nimport { emit } from './emit.js';\nimport { hydrate } from './hydrate.js';\nimport { resolve } from './resolve.js';\nimport { sequence } from './sequence.js';\nimport type { PipelineState } from './types.js';\n\nexport { diagnose } from './diagnose.js';\nexport { emit } from './emit.js';\nexport { hydrate } from './hydrate.js';\nexport { resolve } from './resolve.js';\nexport { sequence } from './sequence.js';\nexport type {\n DiagnosticReport,\n EmittedResource,\n PipelineState,\n ResourceClassification,\n} from './types.js';\n\n/**\n * Input to the pipeline — provided by the handler or simulator.\n */\nexport interface PipelineInput {\n /** The constructed Composition instance. */\n composition: Composition;\n /** Observed composed resources from Crossplane (keyed by resource name). */\n observedComposed: ReadonlyMap<string, Record<string, unknown>>;\n /** Observed existing/required resources (keyed by refKey). */\n observedRequired: ReadonlyMap<string, Record<string, unknown>>;\n}\n\n/**\n * Run the full rendering pipeline.\n *\n * Phases: hydrate → resolve → sequence → diagnose → emit\n */\nexport function runPipeline(input: PipelineInput): PipelineState {\n const resources = collectResources(input.composition);\n\n const initialState: PipelineState = {\n composition: input.composition,\n resources,\n graph: input.composition.graph,\n observedComposed: input.observedComposed,\n observedRequired: input.observedRequired,\n classification: new Map(),\n diagnostics: [],\n emitted: [],\n xrStatusPatches: {},\n };\n\n // Run phases sequentially — each transforms the state\n let state = initialState;\n state = hydrate(state);\n state = resolve(state);\n state = sequence(state);\n state = diagnose(state);\n state = emit(state);\n\n return state;\n}\n\n/**\n * Collect all Resource instances from the composition's construct tree.\n */\nfunction collectResources(composition: Composition): Resource[] {\n const resources: Resource[] = [];\n collectFromNode(composition, resources);\n return resources;\n}\n\nfunction collectFromNode(construct: import('constructs').Construct, resources: Resource[]): void {\n for (const child of construct.node.children) {\n // Check if it's a Resource (has our internals)\n if (isResourceInstance(child)) {\n resources.push(child as Resource);\n }\n // Recurse into children\n collectFromNode(child, resources);\n }\n}\n\nfunction isResourceInstance(obj: unknown): obj is Resource {\n if (obj === null || typeof obj !== 'object') return false;\n const r = obj as Record<string, unknown>;\n if (!('resource' in r) || r.resource === null || typeof r.resource !== 'object') return false;\n return 'autoReady' in (r.resource as object);\n}\n","import type { ReadyCheck } from './types.js';\n\n/**\n * Checks if the resource has a `Ready` condition with status `True`.\n */\nexport function conditionReady(observed: Record<string, unknown>): boolean | undefined {\n const status = observed.status as Record<string, unknown> | undefined;\n const conditions = status?.conditions as Array<Record<string, unknown>> | undefined;\n if (!conditions || !Array.isArray(conditions)) return undefined;\n\n const ready = conditions.find((c) => c.type === 'Ready');\n if (!ready) return undefined;\n\n return ready.status === 'True';\n}\n\n/**\n * Checks if the resource has `status.ready === true`.\n */\nexport function statusReady(observed: Record<string, unknown>): boolean | undefined {\n const status = observed.status as Record<string, unknown> | undefined;\n if (status === undefined) return undefined;\n if (!('ready' in status)) return undefined;\n\n return status.ready === true;\n}\n\n/**\n * Fallback: resource exists in observed state → ready.\n * Always returns `true` (only called when observed is defined).\n */\nexport function exists(_observed: Record<string, unknown>): boolean {\n return true;\n}\n\n/**\n * Built-in default readiness checks, appended at low priority.\n */\nexport const DEFAULT_CHECKS: ReadyCheck[] = [\n { fn: conditionReady, priority: 100, name: 'conditionReady' },\n { fn: statusReady, priority: 200, name: 'statusReady' },\n { fn: exists, priority: 1000, name: 'exists' },\n];\n","import { getLogger } from '../logging/index.js';\n\nimport type { ReadyCheck } from './types.js';\n\n/**\n * Evaluate readiness for a resource by running checks grouped by priority.\n *\n * - If `observed` is undefined, the resource doesn't exist yet → not ready.\n * - Checks are grouped by priority (ascending). Within a group, all checks\n * are AND-ed: if any returns `false`, the resource is not ready. If at least\n * one returns `true` and none return `false`, the resource is ready.\n * If all return `undefined`, cascade to the next priority group.\n * - Final fallback (no group had a definitive answer): not ready.\n */\nexport function evaluateReadiness(\n checks: ReadyCheck[],\n observed: Record<string, unknown> | undefined,\n): boolean {\n const log = getLogger();\n\n if (!observed) {\n log.debug('readiness: resource not observed, not ready');\n return false;\n }\n\n // Group checks by priority\n const groups = new Map<number, ReadyCheck[]>();\n for (const check of checks) {\n const group = groups.get(check.priority);\n if (group) {\n group.push(check);\n } else {\n groups.set(check.priority, [check]);\n }\n }\n\n // Process groups in ascending priority order\n const priorities = [...groups.keys()].sort((a, b) => a - b);\n\n for (const priority of priorities) {\n const group = groups.get(priority)!;\n let hasTrue = false;\n let hasFalse = false;\n const results: Array<{ name: string; result: boolean | undefined }> = [];\n\n for (const check of group) {\n const result = check.fn(observed);\n results.push({ name: check.name ?? 'anonymous', result });\n\n if (result === false) {\n hasFalse = true;\n break; // Short-circuit: one false in the group → not ready\n }\n if (result === true) {\n hasTrue = true;\n }\n }\n\n log.debug('readiness: evaluated group', { priority, results });\n\n if (hasFalse) {\n log.debug('readiness: group returned false, not ready', { priority });\n return false;\n }\n if (hasTrue) {\n log.debug('readiness: group returned true, ready', { priority });\n return true;\n }\n // All undefined → cascade to next group\n }\n\n log.debug('readiness: no group had definitive answer, not ready');\n return false;\n}\n","import type {\n BlockedResource,\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 { getDesiredDocument, getExternalRef, getResourceRef, isExternal } from './core/resource.js';\nimport { runPipeline } from './pipeline/index.js';\nimport { DEFAULT_CHECKS, evaluateReadiness } from './readiness/index.js';\nimport { DependencyGraph, EdgeCollector } from './tracking/index.js';\nimport { createTokenRegistry, tokenRegistryStorage } from './tracking/token-registry.js';\n\n/**\n * Run a composition class with the given input and return a plain-data result.\n *\n * This is the single entry point that bridges the composition author's class\n * with the runtime. It handles:\n * 1. Setting up internal context (DependencyGraph, EdgeCollector, ALS)\n * 2. Instantiating the Composition class\n * 3. Running the full pipeline (hydrate → resolve → sequence → diagnose → emit)\n * 4. Evaluating readiness per resource\n * 5. Returning a fully serializable CompositionResult\n *\n * The runtime never needs to access framework internals — everything it needs\n * is in the returned plain-data structure.\n */\nexport function runComposition<TSpec, TStatus, TContext extends object>(\n CompositionClass: new () => Composition<TSpec, TStatus, TContext>,\n input: CompositionInput,\n): CompositionResult {\n // Convert plain Records to Maps for the internal pipeline\n const observedComposed = new Map(Object.entries(input.observedComposed));\n const observedRequired = new Map(Object.entries(input.observedRequired));\n\n // Set up internal context\n const graph = new DependencyGraph();\n const collector = new EdgeCollector();\n const pipelineContext = new Map(Object.entries(input.pipelineContext));\n\n const ctx: CompositionContext = {\n xr: input.xr,\n pipelineContext,\n requiredResources: observedRequired,\n observedComposed,\n graph,\n collector,\n };\n\n // Instantiate composition within ALS context\n const composition = compositionStorage.run(ctx, () =>\n tokenRegistryStorage.run(createTokenRegistry(), () => new CompositionClass()),\n ) as Composition;\n\n // Run the pipeline\n const state = runPipeline({ composition, observedComposed, observedRequired });\n\n // Build the result — plain data only\n const resources: DesiredResource[] = state.emitted.map((emitted) => {\n if (emitted.preserved) {\n // Blocked resource being emitted as its observed state — mark not ready.\n return { name: emitted.name, document: emitted.document, ready: false, preserved: true };\n }\n const allChecks = [...emitted.readyChecks, ...DEFAULT_CHECKS];\n // Look up observed using the full construct path (Composition/{name})\n const observed = observedComposed.get(`Composition/${emitted.name}`);\n const ready = emitted.autoReady ? evaluateReadiness(allChecks, observed) : true;\n\n return {\n name: emitted.name,\n document: emitted.document,\n ready,\n };\n });\n\n const externalResources: ExternalResourceRequest[] = [];\n for (const resource of state.resources) {\n if (!isExternal(resource)) continue;\n const ref = getExternalRef(resource);\n if (!ref || typeof ref.name !== 'string') continue;\n if (ref.name.startsWith('__pending__')) continue;\n\n externalResources.push({\n refKey: ref.refKey,\n apiVersion: ref.apiVersion,\n kind: ref.kind,\n name: ref.name,\n ...(ref.namespace ? { namespace: ref.namespace } : {}),\n });\n }\n\n // Collect blocked resource info so the handler can preserve observed state\n // in desired (preventing accidental deletion), prevent premature XR readiness,\n // and surface a structured `status.xplane.blockedResources` entry on the XR.\n const blockedResources: BlockedResource[] = [];\n for (const resource of state.resources) {\n if (isExternal(resource)) continue;\n const ref = getResourceRef(resource);\n if (state.classification.get(ref.id) !== 'blocked') continue;\n const name = ref.id.startsWith('Composition/') ? ref.id.slice('Composition/'.length) : ref.id;\n const desired = getDesiredDocument(resource);\n const apiVersion = typeof desired.apiVersion === 'string' ? desired.apiVersion : '';\n const kind = typeof desired.kind === 'string' ? desired.kind : '';\n const metadata =\n desired.metadata && typeof desired.metadata === 'object'\n ? (desired.metadata as Record<string, unknown>)\n : undefined;\n const resourceName = metadata && typeof metadata.name === 'string' ? metadata.name : undefined;\n const waitingFor = describeWaitingFor(name, state.diagnostics);\n blockedResources.push({\n name,\n apiVersion,\n kind,\n ...(resourceName ? { resourceName } : {}),\n ...(waitingFor && waitingFor.length > 0 ? { waitingFor } : {}),\n });\n }\n\n return {\n resources,\n blockedResources,\n externalResources,\n xrStatus: state.xrStatusPatches,\n diagnostics: state.diagnostics,\n emitXplaneStatus: composition.emitXplaneStatus === true,\n };\n}\n\n/**\n * Build a human-readable `waitingFor` list for a blocked resource from the\n * matching diagnostic. Each entry describes one thing the resource is waiting\n * on (one entry per pending path, or a single entry for cycle/not-found).\n */\nfunction describeWaitingFor(\n name: string,\n diagnostics: ReadonlyArray<{\n resource: string;\n reason: 'pending' | 'cycle' | 'not-found';\n pendingPaths?: Array<{ path: string; waitingOn: { resource: string; path: string } }>;\n cycle?: string[];\n detail?: string;\n }>,\n): string[] | undefined {\n const id = `Composition/${name}`;\n const diag = diagnostics.find((d) => d.resource === id || d.resource === name);\n if (!diag) return undefined;\n\n if (diag.reason === 'cycle') {\n return [`circular dependency: ${(diag.cycle ?? []).join(' → ')}`];\n }\n if (diag.reason === 'not-found') {\n return [diag.detail ?? 'external resource not found'];\n }\n if (diag.pendingPaths && diag.pendingPaths.length > 0) {\n return diag.pendingPaths.map((p) => {\n const dep = p.waitingOn.resource.startsWith('Composition/')\n ? p.waitingOn.resource.slice('Composition/'.length)\n : p.waitingOn.resource;\n return `${dep}.${p.waitingOn.path}`;\n });\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;AA6BA,MAAa,qBAAqB,IAAI,kBAAsC;;;;;AAM5E,SAAgB,wBAA4C;CAC1D,MAAM,MAAM,mBAAmB,SAAS;CACxC,IAAI,KAAK,OAAO;CAEhB,MAAM,IAAI,MACR,sGACF;AACF;;;;;;;;;;;;;;;;;;;;;ACeA,IAAa,cAAb,cAIUA,YAAU;;;;;CAKlB;;CAGA;;CAGA;;;;;;;;;;;;;;;;;;;;;;;;CAyBA,mBAAmB;CAEnB,cAAc;EAEZ,MAAM,KAAA,GAAmC,aAAa;EAEtD,MAAM,MAAM,sBAAsB;EAElC,KAAK,QAAQ,IAAI;EACjB,KAAK,YAAY,IAAI;EAGrB,KAAK,KAAK,WAAW,gBAAgB,IAAI,KA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Aa,MAAM,EAAE,aAAa,IAAI;CAC7E,IAAI,CAAC,MAAM,OAAO,KAAA;CAElB,IAAI,KAAK,WAAW,SAClB,OAAO,CAAC,yBAAyB,KAAK,SAAS,CAAC,GAAG,KAAK,KAAK,GAAG;CAElE,IAAI,KAAK,WAAW,aAClB,OAAO,CAAC,KAAK,UAAU,6BAA6B;CAEtD,IAAI,KAAK,gBAAgB,KAAK,aAAa,SAAS,GAClD,OAAO,KAAK,aAAa,KAAK,MAAM;EAIlC,OAAO,GAHK,EAAE,UAAU,SAAS,WAAW,cAAc,IACtD,EAAE,UAAU,SAAS,MAAM,EAAqB,IAChD,EAAE,UAAU,SACF,GAAG,EAAE,UAAU;CAC/B,CAAC;AAGL"}
1
+ {"version":3,"file":"index.mjs","names":["Construct","tryExtractPrimitive","Construct","tryExtractPrimitive","getNestedValue"],"sources":["../src/core/context.ts","../src/core/composition.ts","../src/tracking/dependency-graph.ts","../src/tracking/types.ts","../src/tracking/token-registry.ts","../src/tracking/read-proxy.ts","../src/tracking/write-proxy.ts","../src/core/resource.ts","../src/logging/context.ts","../src/pipeline/diagnose.ts","../src/pipeline/emit.ts","../src/pipeline/hydrate.ts","../src/pipeline/resolve.ts","../src/readiness/defaults.ts","../src/readiness/evaluate.ts","../src/pipeline/sequence.ts","../src/pipeline/index.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 /** Pre-populated data for composed resources (from prior iterations), keyed by `Composition/{path}`. */\n observedComposed: 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 /**\n * When `true`, the runtime injects a structured `status.xplane` payload on\n * the XR containing `emittedResources` and `blockedResources`. Defaults to\n * `false` because writing this field requires the XRD's `openAPIV3Schema`\n * to declare `status.xplane` (or `status` to allow unknown fields) — typed\n * patches will otherwise be rejected by Crossplane.\n *\n * To enable, set in your composition's constructor:\n *\n * ```ts\n * this.emitXplaneStatus = true;\n * ```\n *\n * and add the following to your XRD's status schema:\n *\n * ```yaml\n * status:\n * properties:\n * xplane:\n * type: object\n * x-kubernetes-preserve-unknown-fields: true\n * ```\n */\n emitXplaneStatus = false;\n\n constructor() {\n // Use 'Composition' as the root construct ID\n super(undefined as unknown as Construct, 'Composition');\n\n const ctx = getCompositionContext();\n\n this.graph = ctx.graph;\n this.collector = ctx.collector;\n\n // Set context values on the construct tree so Resources can find them\n this.node.setContext('xplane:graph', ctx.graph);\n this.node.setContext('xplane:collector', ctx.collector);\n\n // Set XR metadata on tree for Resource.uniqueName()\n const xrMeta = ctx.xr.metadata as { name?: string; namespace?: string } | undefined;\n if (xrMeta) {\n this.node.setContext('xplane:xr-meta', xrMeta);\n }\n\n // Build the XR proxy\n this.xr = createXrProxy<TSpec, TStatus>(ctx);\n }\n\n /**\n * Read-only accessor for Crossplane function pipeline context.\n * Keys are the context keys set by Crossplane or prior functions in the pipeline.\n */\n get pipelineContext(): PipelineContextAccessor<TContext> {\n const ctx = getCompositionContext();\n return {\n get<K extends keyof TContext>(key: K): TContext[K] | undefined {\n return ctx.pipelineContext.get(key as string) as TContext[K] | undefined;\n },\n has(key: keyof TContext): boolean {\n return ctx.pipelineContext.has(key as string);\n },\n keys(): IterableIterator<keyof TContext> {\n return ctx.pipelineContext.keys() as IterableIterator<keyof TContext>;\n },\n };\n }\n}\n\n/** Typed read-only interface for pipeline context. */\nexport interface PipelineContextAccessor<TContext extends object = Record<string, unknown>> {\n get<K extends keyof TContext>(key: K): TContext[K] | undefined;\n has(key: keyof TContext): boolean;\n keys(): IterableIterator<keyof TContext>;\n}\n\n// ─── XR Proxy ─────────────────────────────────────────────────────────────────\n\n/**\n * Creates the \"desired-first, fallback-to-observed\" proxy for the XR.\n *\n * - Reading `xr.spec.*` reads from observed XR spec (creates ReadProxy for tracking)\n * - Writing `xr.status.*` writes to a desired-status store (emitted as composite status)\n * - Other reads fall through to observed\n */\nfunction createXrProxy<TSpec, TStatus>(ctx: {\n xr: Record<string, unknown>;\n graph: DependencyGraph;\n collector: EdgeCollector;\n}): XrProxy<TSpec, TStatus> {\n const xrObserved = ctx.xr;\n const xrDesiredStatus: Record<string, unknown> = {};\n\n // The XR ref for dependency tracking\n const xrRef = { id: '__xr__' };\n ctx.graph.addResource(xrRef);\n\n const statusProxy = new Proxy(xrDesiredStatus, {\n get(_target, prop) {\n if (typeof prop === 'symbol') return undefined;\n const key = String(prop);\n // Desired-first\n if (key in xrDesiredStatus) return xrDesiredStatus[key];\n // Fallback to observed status\n const observedStatus = xrObserved.status as Record<string, unknown> | undefined;\n if (observedStatus && key in observedStatus) {\n return observedStatus[key];\n }\n return undefined;\n },\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n xrDesiredStatus[String(prop)] = value;\n return true;\n },\n has(_target, prop) {\n if (typeof prop === 'symbol') return false;\n const key = String(prop);\n if (key in xrDesiredStatus) return true;\n const observedStatus = xrObserved.status as Record<string, unknown> | undefined;\n return observedStatus ? key in observedStatus : false;\n },\n });\n\n const proxy = new Proxy({} as XrProxy<TSpec, TStatus>, {\n get(_target, prop) {\n if (typeof prop === 'symbol') return undefined;\n const key = String(prop);\n if (key === 'status') return statusProxy;\n // Everything else reads from observed XR\n if (key in xrObserved) return xrObserved[key];\n return undefined;\n },\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n const key = String(prop);\n if (key === 'status') {\n // Allow replacing entire status\n Object.assign(xrDesiredStatus, value as object);\n return true;\n }\n // Writes to other top-level XR fields are unusual but allowed\n (xrObserved as Record<string, unknown>)[key] = value;\n return true;\n },\n has(_target, prop) {\n if (typeof prop === 'symbol') return false;\n return String(prop) in xrObserved || String(prop) === 'status';\n },\n });\n\n return proxy;\n}\n\n/**\n * Extract the desired XR status from a Composition instance.\n * Used by the emit pipeline phase to produce composite status output.\n */\nexport function getXrDesiredStatus(composition: Composition): Record<string, unknown> {\n // Access the internal status proxy target\n const statusProxy = composition.xr.status;\n // Collect all keys from the status proxy.\n // We intentionally return raw values (including ReadProxy references) so\n // that the emit phase can resolve them from observed resource data.\n const result: Record<string, unknown> = {};\n if (statusProxy && typeof statusProxy === 'object') {\n for (const key of Object.keys(statusProxy)) {\n const value = (statusProxy as Record<string, unknown>)[key];\n if (value != null) {\n result[key] = value;\n }\n }\n }\n return result;\n}\n","import type { DependencyEdge, ResourceRef } from './types.js';\n\n/**\n * Tracks dependency relationships between resources as a directed acyclic graph.\n * Edges are added as resources reference each other's observed state.\n */\nexport class DependencyGraph {\n private readonly _adjacency = new Map<string, Set<string>>();\n private readonly _resources = new Map<string, ResourceRef>();\n private readonly _edges: DependencyEdge[] = [];\n\n addResource(ref: ResourceRef): void {\n this._resources.set(ref.id, ref);\n if (!this._adjacency.has(ref.id)) {\n this._adjacency.set(ref.id, new Set());\n }\n }\n\n addEdge(edge: DependencyEdge): void {\n this.addResource(edge.from);\n this.addResource(edge.to);\n this._adjacency.get(edge.to.id)!.add(edge.from.id);\n this._edges.push(edge);\n }\n\n addEdges(edges: ReadonlyArray<DependencyEdge>): void {\n for (const edge of edges) this.addEdge(edge);\n }\n\n addExplicitDependency(dependent: ResourceRef, dependency: ResourceRef): void {\n this.addResource(dependent);\n this.addResource(dependency);\n this._adjacency.get(dependent.id)!.add(dependency.id);\n }\n\n /** Get the set of resource IDs that `resourceId` depends on. */\n getDependencies(resourceId: string): ReadonlySet<string> {\n return this._adjacency.get(resourceId) ?? new Set();\n }\n\n get resourceIds(): ReadonlyArray<string> {\n return [...this._resources.keys()];\n }\n\n get edges(): ReadonlyArray<DependencyEdge> {\n return this._edges;\n }\n\n /**\n * Returns a topological ordering of resources.\n * If a cycle is detected, returns { order: null, cycle: string[] }.\n */\n topologicalSort(): { order: string[] } | { order: null; cycle: string[] } {\n const visited = new Set<string>();\n const visiting = new Set<string>();\n const sorted: string[] = [];\n\n const visit = (id: string): string[] | null => {\n if (visited.has(id)) return null;\n if (visiting.has(id)) {\n // Build cycle path\n return [...visiting, id];\n }\n visiting.add(id);\n const deps = this._adjacency.get(id);\n if (deps) {\n for (const depId of deps) {\n const cycle = visit(depId);\n if (cycle) return cycle;\n }\n }\n visiting.delete(id);\n visited.add(id);\n sorted.push(id);\n return null;\n };\n\n for (const id of this._resources.keys()) {\n const cycle = visit(id);\n if (cycle) {\n // Trim cycle to start from the repeated node\n const start = cycle[cycle.length - 1]!;\n const startIdx = cycle.indexOf(start);\n return { order: null, cycle: cycle.slice(startIdx) };\n }\n }\n return { order: sorted };\n }\n}\n","/** Identifies a resource in the dependency graph. */\nexport interface ResourceRef {\n readonly id: string;\n}\n\n/** A dependency edge between two resources at specific field paths. */\nexport interface DependencyEdge {\n /** Resource being read from (observed state). */\n readonly from: ResourceRef;\n /** Path in the source resource's observed data. */\n readonly fromPath: string;\n /** Resource being written to (desired state). */\n readonly to: ResourceRef;\n /** Path in the target resource's desired data. */\n readonly toPath: string;\n}\n\n/**\n * A Pending marker stored in a desired document when a ReadProxy value\n * is assigned. Carries full source info so the resolve phase knows\n * where to look for the concrete value.\n */\nconst PENDING_TAG: unique symbol = Symbol.for('xplane.pending') as unknown as typeof PENDING_TAG;\n\nexport class Pending {\n static readonly TAG = PENDING_TAG;\n readonly [PENDING_TAG] = true;\n\n constructor(\n /** The resource that owns the observed data. */\n readonly source: ResourceRef,\n /** The path within that resource's observed data. */\n readonly path: string,\n ) {}\n\n static is(value: unknown): value is Pending {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_TAG] === true\n );\n }\n}\n\n/** Metadata associated with a ReadProxy instance. */\nexport interface ReadProxyMeta {\n readonly owner: ResourceRef;\n readonly path: string;\n}\n\n// ─── PendingTemplate ─────────────────────────────────────────────────────────\n\n/**\n * A Pending-like marker for strings produced by template literals that\n * interpolate one or more unresolved ReadProxy values.\n *\n * Holds the template structure so the resolve phase can reconstruct the\n * final string once all dependency slots are available.\n *\n * Invariant: parts.length === slots.length + 1\n * result = parts[0] + resolved[0] + parts[1] + … + resolved[n-1] + parts[n]\n */\nconst PENDING_TEMPLATE_TAG: unique symbol = Symbol.for(\n 'xplane.pendingTemplate',\n) as unknown as typeof PENDING_TEMPLATE_TAG;\n\nexport class PendingTemplate {\n static readonly TAG = PENDING_TEMPLATE_TAG;\n readonly [PENDING_TEMPLATE_TAG] = true;\n\n constructor(\n /** Literal text segments between (and around) pending slots. */\n readonly parts: readonly string[],\n /** The pending slots — each maps to an entry in a resource's observed state. */\n readonly slots: ReadonlyArray<{ source: ResourceRef; path: string }>,\n ) {}\n\n static is(value: unknown): value is PendingTemplate {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[PENDING_TEMPLATE_TAG] === true\n );\n }\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\nimport type { ReadProxyMeta, ResourceRef } from './types.js';\nimport { PendingTemplate } from './types.js';\n\n// ─── Token Registry ───────────────────────────────────────────────────────────\n\nexport interface TokenRegistry {\n readonly byToken: Map<string, ReadProxyMeta>;\n readonly byKey: Map<string, string>;\n counter: number;\n}\n\n/**\n * Per-run AsyncLocalStorage for the template-literal token registry.\n * Kept separate from compositionStorage (core/) to avoid circular deps.\n */\nexport const tokenRegistryStorage = new AsyncLocalStorage<TokenRegistry>();\n\nexport function createTokenRegistry(): TokenRegistry {\n return { byToken: new Map(), byKey: new Map(), counter: 0 };\n}\n\n/**\n * Get or create a stable token for a given (owner, path) pair.\n * Returns null when no registry is active (outside of a composition run).\n */\nexport function getOrCreateToken(owner: ResourceRef, path: string): string | null {\n const registry = tokenRegistryStorage.getStore();\n if (!registry) return null;\n\n const key = `${owner.id}\\0${path}`;\n const existing = registry.byKey.get(key);\n if (existing !== undefined) return existing;\n\n const token = `__pending__tpl_${registry.counter++}__`;\n registry.byToken.set(token, { owner, path });\n registry.byKey.set(key, token);\n return token;\n}\n\nexport function lookupToken(token: string): ReadProxyMeta | undefined {\n return tokenRegistryStorage.getStore()?.byToken.get(token);\n}\n\n// ─── String Processing ────────────────────────────────────────────────────────\n\nconst TEMPLATE_TOKEN_RE = /__pending__tpl_\\d+__/g;\n\n/**\n * Scan a string for pending template tokens. If any are found, calls\n * `onSlot` for each registered token and returns a PendingTemplate.\n * Returns the original string if no tokens are found or none are registered.\n */\nexport function processStringValue(\n value: string,\n onSlot: (meta: ReadProxyMeta) => void,\n): PendingTemplate | string {\n const parts: string[] = [];\n const slots: Array<{ source: ResourceRef; path: string }> = [];\n let lastIndex = 0;\n let hasSlots = false;\n\n // Reset lastIndex before iterating (regex is stateful)\n TEMPLATE_TOKEN_RE.lastIndex = 0;\n\n for (const match of value.matchAll(TEMPLATE_TOKEN_RE)) {\n const meta = lookupToken(match[0]!);\n if (!meta) continue; // token not in registry — treat as literal\n\n hasSlots = true;\n parts.push(value.slice(lastIndex, match.index!));\n slots.push({ source: meta.owner, path: meta.path });\n onSlot(meta);\n lastIndex = match.index! + match[0]!.length;\n }\n\n if (!hasSlots) return value;\n\n parts.push(value.slice(lastIndex));\n return new PendingTemplate(parts, slots);\n}\n","import { getOrCreateToken } from './token-registry.js';\nimport type { ReadProxyMeta, ResourceRef } from './types.js';\n\n/**\n * WeakMap storing metadata for ReadProxy instances.\n * This avoids polluting proxy objects with symbols.\n */\nconst proxyMeta = new WeakMap<object, ReadProxyMeta>();\n\n/** Sentinel symbol to identify ReadProxy instances. */\nconst READ_PROXY_TAG = Symbol.for('xplane.readProxy');\n\n/**\n * Check if a value is a ReadProxy.\n */\nexport function isReadProxy(value: unknown): value is object {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as Record<symbol, unknown>)[READ_PROXY_TAG] === true\n );\n}\n\n/**\n * Get the metadata for a ReadProxy value.\n */\nexport function getReadProxyMeta(value: unknown): ReadProxyMeta | undefined {\n if (!isReadProxy(value)) return undefined;\n return proxyMeta.get(value as object);\n}\n\n/**\n * Creates a ReadProxy that wraps observed data.\n *\n * - Property access navigates into the data, building up the path.\n * - Missing paths return `undefined` (no placeholder proxies).\n * - The proxy carries owner + path metadata so that when it's assigned\n * to a WriteProxy, the dependency edge can be recorded.\n */\nexport function createReadProxy<T extends object>(\n target: T,\n owner: ResourceRef,\n basePath: string,\n): T {\n const proxy = new Proxy(target, {\n get(obj, prop, receiver) {\n // Identity checks\n if (prop === READ_PROXY_TAG) return true;\n if (typeof prop === 'symbol') return Reflect.get(obj, prop, receiver);\n if (prop === 'toJSON') return () => obj;\n\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const value = Reflect.get(obj, prop, receiver);\n\n if (value === undefined || value === null) {\n // Return a \"leaf\" proxy with undefined target — carries metadata\n // for dependency edge creation but resolves to undefined\n return createLeafReadProxy(owner, childPath);\n }\n\n if (typeof value === 'object') {\n // Wrap nested objects so path accumulates\n return createReadProxy(value as object, owner, childPath);\n }\n\n // Primitive — wrap in a tagged object so it can carry metadata\n // when assigned to a WriteProxy\n return createPrimitiveReadProxy(value as string | number | boolean, owner, childPath);\n },\n\n has(obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return Reflect.has(obj, prop);\n },\n });\n\n proxyMeta.set(proxy, { owner, path: basePath });\n return proxy as T;\n}\n\n/**\n * A \"leaf\" ReadProxy for paths that don't exist in observed data yet.\n * Carries metadata for edge creation. Resolves to `undefined` when\n * coerced to a primitive.\n */\nfunction createLeafReadProxy(owner: ResourceRef, path: string): object {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n const getToken = () => getOrCreateToken(owner, path) ?? `__pending__${owner.id}__${path}`;\n const proxy = new Proxy(target, {\n get(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n if (prop === Symbol.toPrimitive) return () => getToken();\n if (typeof prop === 'symbol') return undefined;\n if (prop === 'toJSON') return () => undefined;\n if (prop === 'toString') return () => getToken();\n if (prop === 'valueOf') return () => proxy;\n // Nested access on a leaf — still a leaf with extended path\n return createLeafReadProxy(owner, `${path}.${String(prop)}`);\n },\n has(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return false;\n },\n });\n proxyMeta.set(proxy, { owner, path });\n return proxy;\n}\n\n/**\n * Wraps a concrete primitive value so it carries ReadProxy metadata.\n * This allows the WriteProxy to detect it during assignment and\n * record the dependency edge, while the value itself resolves correctly.\n */\nexport function createPrimitiveReadProxy(\n value: string | number | boolean,\n owner: ResourceRef,\n path: string,\n): object {\n const target = Object.create(null) as Record<string | symbol, unknown>;\n const proxy = new Proxy(target, {\n get(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n if (prop === Symbol.toPrimitive) return () => value;\n if (prop === 'valueOf') return () => value;\n if (prop === 'toString') return () => String(value);\n if (prop === 'toJSON') return () => value;\n if (typeof prop === 'symbol') return undefined;\n // Navigating into a primitive — leaf\n return createLeafReadProxy(owner, `${path}.${String(prop)}`);\n },\n has(_obj, prop) {\n if (prop === READ_PROXY_TAG) return true;\n return false;\n },\n });\n proxyMeta.set(proxy, { owner, path });\n return proxy;\n}\n","import {\n createPrimitiveReadProxy,\n createReadProxy,\n getReadProxyMeta,\n isReadProxy,\n} from './read-proxy.js';\nimport { processStringValue } from './token-registry.js';\nimport { type DependencyEdge, Pending, type ResourceRef } from './types.js';\n\n/**\n * Collector that accumulates dependency edges discovered during\n * WriteProxy assignments.\n */\nexport class EdgeCollector {\n private readonly _edges: DependencyEdge[] = [];\n\n add(edge: DependencyEdge): void {\n // Deduplicate\n const exists = this._edges.some(\n (e) =>\n e.from.id === edge.from.id &&\n e.fromPath === edge.fromPath &&\n e.to.id === edge.to.id &&\n e.toPath === edge.toPath,\n );\n if (!exists) this._edges.push(edge);\n }\n\n get edges(): ReadonlyArray<DependencyEdge> {\n return this._edges;\n }\n}\n\nexport interface WriteProxyOptions {\n /** The resource that owns this desired document. */\n owner: ResourceRef;\n /** The collector to record edges into. */\n collector: EdgeCollector;\n /** Base path prefix (e.g., \"spec\" when wrapping the spec subtree). */\n basePath?: string;\n /** Optional observed state at the same path for fallback reads. */\n observed?: Record<string, unknown>;\n}\n\n/**\n * Creates a WriteProxy that wraps a desired document.\n *\n * - Writes store values in the target.\n * - When a ReadProxy value is assigned, it records a dependency edge\n * and stores a Pending marker if the value is not yet concrete.\n * - Reads return the stored value (desired-first).\n */\nexport function createWriteProxy<T extends object>(target: T, opts: WriteProxyOptions): T {\n const { owner, collector, basePath = '', observed } = opts;\n\n return new Proxy(target, {\n get(obj, prop, receiver) {\n if (typeof prop === 'symbol') return Reflect.get(obj, prop, receiver);\n if (prop === 'toJSON') return () => obj;\n\n const value = Reflect.get(obj, prop, receiver);\n\n // If the value is a nested object (not a Pending), wrap it recursively\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const childObserved =\n observed && String(prop) in observed && typeof observed[String(prop)] === 'object'\n ? (observed[String(prop)] as Record<string, unknown>)\n : undefined;\n return createWriteProxy(value as object, {\n owner,\n collector,\n basePath: childPath,\n observed: childObserved,\n });\n }\n\n // If value is undefined and observed has data at this path, fall through to ReadProxy\n if (value === undefined && observed && String(prop) in observed) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n const obsValue = observed[String(prop)];\n if (typeof obsValue === 'object' && obsValue !== null) {\n return createReadProxy(obsValue as object, owner, childPath);\n }\n if (obsValue !== undefined && obsValue !== null) {\n return createPrimitiveReadProxy(obsValue as string | number | boolean, owner, childPath);\n }\n }\n\n // If value is undefined and observed doesn't have it either, return a leaf ReadProxy\n // so that cross-resource references create proper dependency edges and Pending markers\n if (value === undefined && observed !== undefined) {\n const childPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n return createReadProxy(Object.create(null) as object, owner, childPath);\n }\n\n return value;\n },\n\n set(obj, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(obj, prop, value);\n\n const targetPath = basePath ? `${basePath}.${String(prop)}` : String(prop);\n\n // Check if the value being assigned is a ReadProxy\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value);\n if (meta && meta.owner.id !== owner.id) {\n // Record dependency edge\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: targetPath,\n });\n\n // Try to extract a concrete value via Symbol.toPrimitive\n const primitive = tryExtractPrimitive(value);\n if (primitive !== undefined) {\n // The value is already concrete (primitive from observed data)\n return Reflect.set(obj, prop, primitive);\n }\n\n // Not concrete — store a Pending marker\n return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));\n }\n\n // Self-reference or XR — try to extract value\n const primitive = tryExtractPrimitive(value);\n if (primitive !== undefined) {\n return Reflect.set(obj, prop, primitive);\n }\n\n // XR leaf with no value — store Pending\n if (meta) {\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: targetPath,\n });\n return Reflect.set(obj, prop, new Pending(meta.owner, meta.path));\n }\n }\n\n // String with pending template tokens\n if (typeof value === 'string') {\n const processed = processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: targetPath });\n });\n return Reflect.set(obj, prop, processed);\n }\n\n // Plain object — deep-process to catch nested ReadProxy values\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n const processed = deepProcessValue(value, owner, targetPath, collector);\n return Reflect.set(obj, prop, processed);\n }\n\n return Reflect.set(obj, prop, value);\n },\n\n deleteProperty(obj, prop) {\n return Reflect.deleteProperty(obj, prop);\n },\n }) as T;\n}\n\n/**\n * Try to extract a primitive value from a ReadProxy via Symbol.toPrimitive.\n * Returns `undefined` if the proxy represents a non-existent (leaf) value.\n */\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\n/**\n * Deep-process a plain object/array being assigned to a WriteProxy.\n * Replaces any nested ReadProxy values with Pending markers or concrete values.\n */\nfunction deepProcessValue(\n value: unknown,\n owner: ResourceRef,\n basePath: string,\n collector: EdgeCollector,\n): unknown {\n if (value === null || value === undefined) return value;\n\n if (typeof value === 'string') {\n return processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: basePath });\n });\n }\n\n if (typeof value !== 'object') return value;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value)!;\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: basePath,\n });\n const primitive = tryExtractPrimitive(value as object);\n if (primitive !== undefined) return primitive;\n return new Pending(meta.owner, meta.path);\n }\n\n if (Array.isArray(value as object)) {\n return (value as unknown[]).map((item, i) =>\n deepProcessValue(item, owner, `${basePath}[${i}]`, collector),\n );\n }\n\n // Plain object — recurse\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = deepProcessValue(val, owner, `${basePath}.${key}`, collector);\n }\n return result;\n}\n","import { Construct } from 'constructs';\n\nimport type { ReadyCheck, ReadyCheckFn } from '../readiness/index.js';\nimport {\n createPrimitiveReadProxy,\n createReadProxy,\n createWriteProxy,\n type DependencyGraph,\n type EdgeCollector,\n getReadProxyMeta,\n isReadProxy,\n Pending,\n type ResourceRef,\n} from '../tracking/index.js';\nimport { processStringValue } from '../tracking/token-registry.js';\nimport { compositionStorage } from './context.js';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/** Minimal shape for a Kubernetes resource — only apiVersion + kind required. */\nexport interface KubernetesResource {\n apiVersion: string;\n kind: string;\n metadata?: {\n name?: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n/** Props passed to the Resource constructor — becomes the desired document. */\nexport interface ResourceProps {\n apiVersion: string;\n kind: string;\n [key: string]: unknown;\n}\n\n/** Framework configuration accessible via `resource.resource`. */\nexport interface ResourceConfig {\n autoReady: boolean;\n addReadyCheck(fn: ReadyCheckFn, priority?: number): void;\n}\n\n/** Internal metadata stored per Resource (not exposed on the proxy). */\ninterface ResourceInternals {\n /** Unique reference for the dependency graph. */\n ref: ResourceRef;\n /** The desired document (what the user wrote). */\n desired: Record<string, unknown>;\n /** The observed document (populated by the hydrate phase). */\n observed: Record<string, unknown>;\n /** Whether this is an external (existing) resource. */\n external: boolean;\n /** For external resources: the lookup key. */\n externalRef?: ExternalResourceRef;\n /** Framework config. */\n config: ResourceConfig;\n /** Custom readiness checks registered by the composition author. */\n readyChecks: ReadyCheck[];\n /** The dependency graph. */\n graph: DependencyGraph;\n /** The edge collector. */\n collector: EdgeCollector;\n}\n\nexport interface ExternalResourceRef {\n apiVersion: string;\n kind: string;\n name: unknown;\n namespace?: string;\n refKey: string;\n}\n\n// ─── WeakMap stores for internal data ─────────────────────────────────────────\n\nconst internals = new WeakMap<Resource, ResourceInternals>();\n\n// ─── Resource class ───────────────────────────────────────────────────────────\n\n/**\n * A Kubernetes resource within a Composition.\n *\n * The Resource instance acts as a \"desired-first, fallback-to-observed\" proxy:\n * - Reading a path that exists in the desired document returns the desired value.\n * - Reading a path that does NOT exist in desired falls through to a tracked\n * ReadProxy over observed state (creates dependency edges).\n * - Writing always goes to the desired document.\n *\n * The only reserved properties are `node` (from Construct) and `resource`\n * (framework config namespace).\n */\nexport class Resource extends Construct {\n readonly resource: ResourceConfig;\n declare metadata: {\n name?: string;\n namespace?: string;\n labels?: Record<string, string>;\n annotations?: Record<string, string>;\n [key: string]: unknown;\n };\n\n constructor(scope: Construct, id: string, props: ResourceProps) {\n super(scope, id);\n\n const graph = scope.node.tryGetContext('xplane:graph') as DependencyGraph;\n const collector = scope.node.tryGetContext('xplane:collector') as EdgeCollector;\n\n if (!graph || !collector) {\n throw new Error('Resource must be created within a Composition tree.');\n }\n\n const ref: ResourceRef = { id: this.node.path };\n graph.addResource(ref);\n\n const readyChecks: ReadyCheck[] = [];\n const config: ResourceConfig = {\n autoReady: true,\n addReadyCheck(fn: ReadyCheckFn, priority = 50) {\n readyChecks.push({ fn, priority });\n },\n };\n this.resource = config;\n\n // Process props — deep scan for ReadProxy values in the desired doc\n const desired = processDesiredProps(props, ref, collector);\n\n const internal: ResourceInternals = {\n ref,\n desired,\n observed: {},\n external: false,\n config,\n readyChecks,\n graph,\n collector,\n };\n internals.set(this, internal);\n\n // Pre-hydrate composed resources from observed data if available — so that\n // proxy reads during sibling construction (e.g. `Secret.fromExistingByName(this, other.status.x)`)\n // return real values instead of pending tokens that bake into construct IDs.\n const ctx = compositionStorage.getStore();\n if (ctx) {\n const observed = ctx.observedComposed.get(this.node.path);\n if (observed) {\n Object.assign(internal.observed, observed);\n }\n }\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 // Patch node.host so that node.findAll() (used by .with()) starts from the\n // proxy rather than the raw instance. Without this, applyTo() receives the\n // raw Resource where declared-only fields like `spec` are undefined at runtime.\n // biome-ignore lint/suspicious/noExplicitAny: patching constructs Node internals is intentional\n (this.node as any).host = proxy;\n\n // biome-ignore lint/correctness/noConstructorReturn: Proxy wrapping is intentional\n return proxy;\n }\n\n /**\n * Look up an existing cluster resource by name.\n * Returns a Resource that only has observed state (no desired output).\n *\n * The `name` parameter accepts either a plain string or a PrimitiveReadProxy\n * (returned when reading a tracked property like `ns.metadata.labels['x']`).\n * Proxies are coerced to their underlying string via `Symbol.toPrimitive`.\n */\n static fromExistingByName(\n scope: Construct,\n apiVersion: string,\n kind: string,\n name: unknown,\n namespace?: string,\n ): Resource {\n const resolvedName = coerceToString(name);\n const refKey = computeRefKey(apiVersion, kind, resolvedName, namespace);\n const id = `__existing__${refKey.replace(/\\//g, '_')}`;\n\n const instance = new Resource(scope, id, { apiVersion, kind });\n const internal = internals.get(instance)!;\n internal.external = true;\n internal.externalRef = { apiVersion, kind, name: resolvedName ?? name, namespace, refKey };\n\n // Pre-hydrate from context if observed data is already available (from a prior iteration)\n const ctx = compositionStorage.getStore();\n if (ctx) {\n const observed = ctx.requiredResources.get(refKey);\n if (observed) {\n Object.assign(internal.observed, observed);\n }\n }\n\n return instance;\n }\n\n /**\n * Generate a deterministic unique name based on the XR identity and construct path.\n * Useful for resource fields that need unique names (e.g., AWS resource names).\n */\n static uniqueName(\n scope: Construct,\n options: {\n maxLength?: number;\n separator?: string;\n allowedPattern?: RegExp;\n extra?: string;\n } = {},\n ): string {\n const maxLength = options.maxLength ?? 63;\n const separator = options.separator ?? '-';\n const allowedPattern = options.allowedPattern ?? /[^a-zA-Z0-9]/g;\n const escapedSep = separator.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const collapseRe = new RegExp(`${escapedSep}+`, 'g');\n\n const clean = (s: string) =>\n s\n .replace(/\\s+/g, '')\n .replace(allowedPattern, separator)\n .replace(collapseRe, separator)\n .replace(new RegExp(`^${escapedSep}|${escapedSep}$`, 'g'), '');\n\n const xrMeta = scope.node.tryGetContext('xplane:xr-meta') as\n | { name?: string; namespace?: string }\n | undefined;\n\n const parts: string[] = [];\n if (xrMeta?.namespace) parts.push(clean(xrMeta.namespace));\n if (xrMeta?.name) parts.push(clean(xrMeta.name));\n for (const s of scope.node.scopes.slice(1)) {\n const c = clean(s.node.id);\n if (c) parts.push(c);\n }\n if (options.extra) {\n const c = clean(options.extra);\n if (c) parts.push(c);\n }\n\n const full = parts.join(separator);\n const hash = shortHash(full);\n const withHash = `${full}${separator}${hash}`;\n\n if (withHash.length <= maxLength) return withHash;\n const prefix = full.slice(0, maxLength - hash.length - separator.length);\n return `${prefix}${separator}${hash}`;\n }\n\n /**\n * Like {@link uniqueName} but produces names compliant with RFC 1123 DNS labels:\n * lowercase alphanumeric characters and hyphens only, starting and ending with\n * an alphanumeric character. Suitable for use as Kubernetes resource names.\n */\n static uniqueNameRfc1123(\n scope: Construct,\n options: {\n maxLength?: number;\n extra?: string;\n } = {},\n ): string {\n const maxLength = options.maxLength ?? 63;\n\n const clean = (s: string) =>\n s\n .toLowerCase()\n .replace(/\\s+/g, '')\n .replace(/[^a-z0-9-]/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n\n const xrMeta = scope.node.tryGetContext('xplane:xr-meta') as\n | { name?: string; namespace?: string }\n | undefined;\n\n const parts: string[] = [];\n if (xrMeta?.namespace) parts.push(clean(xrMeta.namespace));\n if (xrMeta?.name) parts.push(clean(xrMeta.name));\n for (const s of scope.node.scopes.slice(1)) {\n const c = clean(s.node.id);\n if (c) parts.push(c);\n }\n if (options.extra) {\n const c = clean(options.extra);\n if (c) parts.push(c);\n }\n\n const full = parts.join('-');\n const hash = shortHash(full);\n const withHash = `${full}-${hash}`;\n\n if (withHash.length <= maxLength) return withHash;\n const prefix = full.slice(0, maxLength - hash.length - 1);\n const trimmedPrefix = prefix.replace(/-+$/, '');\n return trimmedPrefix ? `${trimmedPrefix}-${hash}` : hash;\n }\n}\n\n// ─── Internal accessors (used by pipeline phases) ─────────────────────────────\n\nexport function getResourceInternals(resource: Resource): ResourceInternals {\n const internal = internals.get(resource);\n if (!internal) throw new Error('Resource internals not found');\n return internal;\n}\n\nexport function getResourceRef(resource: Resource): ResourceRef {\n return getResourceInternals(resource).ref;\n}\n\nexport function getDesiredDocument(resource: Resource): Record<string, unknown> {\n return getResourceInternals(resource).desired;\n}\n\nexport function getObservedDocument(resource: Resource): Record<string, unknown> {\n return getResourceInternals(resource).observed;\n}\n\nexport function hydrateObserved(resource: Resource, data: Record<string, unknown>): void {\n const internal = getResourceInternals(resource);\n Object.assign(internal.observed, data);\n}\n\nexport function isExternal(resource: Resource): boolean {\n return getResourceInternals(resource).external;\n}\n\nexport function getExternalRef(resource: Resource): ExternalResourceRef | undefined {\n return getResourceInternals(resource).externalRef;\n}\n\nexport function getReadyChecks(resource: Resource): ReadyCheck[] {\n return getResourceInternals(resource).readyChecks;\n}\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\n/**\n * Coerce a value to a string, handling PrimitiveReadProxy objects that wrap\n * primitive values behind a `Symbol.toPrimitive` method.\n * Returns `undefined` if the value cannot be resolved to a string.\n */\nfunction coerceToString(value: unknown): string | undefined {\n if (typeof value === 'string') return value;\n if (\n value != null &&\n typeof (value as { [Symbol.toPrimitive]?: unknown })[Symbol.toPrimitive] === 'function'\n ) {\n return String(value);\n }\n return undefined;\n}\n\nexport function computeRefKey(\n apiVersion: string,\n kind: string,\n name: string | undefined,\n namespace?: string,\n): string {\n const namePart = name ?? '__unresolved__';\n if (namespace) return `${apiVersion}/${kind}/${namespace}/${namePart}`;\n return `${apiVersion}/${kind}/${namePart}`;\n}\n\nfunction shortHash(s: string): string {\n let h = 5381;\n for (let i = 0; i < s.length; i++) {\n h = ((h << 5) + h) ^ s.charCodeAt(i);\n h = h >>> 0;\n }\n return h.toString(16).padStart(8, '0');\n}\n\n/**\n * Process the desired props — deep-scan for ReadProxy values and replace them\n * with Pending markers (recording edges in the collector).\n */\nfunction processDesiredProps(\n props: ResourceProps,\n owner: ResourceRef,\n collector: EdgeCollector,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(props)) {\n result[key] = processValue(value, owner, key, collector);\n }\n return result;\n}\n\nfunction processValue(\n value: unknown,\n owner: ResourceRef,\n path: string,\n collector: EdgeCollector,\n): unknown {\n if (value === null || value === undefined) return value;\n\n if (typeof value === 'string') {\n return processStringValue(value, (meta) => {\n collector.add({ from: meta.owner, fromPath: meta.path, to: owner, toPath: path });\n });\n }\n\n if (typeof value !== 'object') return value;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value)!;\n collector.add({\n from: meta.owner,\n fromPath: meta.path,\n to: owner,\n toPath: path,\n });\n // Try to get concrete value\n const prim = tryExtractPrimitive(value);\n if (prim !== undefined) return prim;\n return new Pending(meta.owner, meta.path);\n }\n\n if (Array.isArray(value as object)) {\n return (value as unknown[]).map((item, i) =>\n processValue(item, owner, `${path}[${i}]`, collector),\n );\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = processValue(val, owner, `${path}.${key}`, collector);\n }\n return result;\n}\n\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\n/**\n * Creates the \"desired-first, fallback-to-observed\" proxy around a Resource.\n */\nfunction createResourceProxy(resource: Resource, internal: ResourceInternals): Resource {\n const { ref, desired, collector } = internal;\n\n const proxy = new Proxy(resource, {\n get(target, prop, receiver) {\n // Framework reserved properties\n if (prop === 'node') return Reflect.get(target, prop, receiver);\n if (prop === 'resource') return Reflect.get(target, prop, receiver);\n if (typeof prop === 'symbol') return Reflect.get(target, prop, receiver);\n\n // Prototype methods and inherited Construct methods (e.g. .with(), .toString())\n if (prop === 'constructor') return Reflect.get(target, prop, receiver);\n const protoValue = Reflect.get(target, prop, receiver);\n if (typeof protoValue === 'function') return protoValue.bind(proxy);\n\n // Check desired first\n if (prop in desired) {\n const value = desired[String(prop)];\n if (typeof value === 'object' && value !== null && !Pending.is(value)) {\n // Return a WriteProxy so nested writes go to desired\n // Pass observed at the same path for fallback reads\n const observed = internal.observed;\n const observedAtPath =\n String(prop) in observed && typeof observed[String(prop)] === 'object'\n ? (observed[String(prop)] as Record<string, unknown>)\n : {};\n return createWriteProxy(value as object, {\n owner: ref,\n collector,\n basePath: String(prop),\n observed: observedAtPath,\n });\n }\n return value;\n }\n\n // Fallback to observed via ReadProxy\n const observed = internal.observed;\n if (String(prop) in observed) {\n const value = observed[String(prop)];\n if (typeof value === 'object' && value !== null) {\n return createReadProxy(value as object, ref, String(prop));\n }\n // Primitive observed value — wrap in ReadProxy for tracking\n return createPrimitiveReadProxyFromResource(value, ref, String(prop));\n }\n\n // Path exists in neither — return a lazy-init proxy that behaves as a\n // ReadProxy for reads but auto-initializes the path in desired on write.\n return createLazyInitProxy(desired, ref, collector, String(prop));\n },\n\n set(target, prop, value) {\n if (typeof prop === 'symbol') return Reflect.set(target, prop, value);\n if (prop === 'resource') return Reflect.set(target, prop, value);\n\n // All writes go to desired, processing ReadProxy values\n const path = String(prop);\n desired[path] = processValue(value, ref, path, collector);\n return true;\n },\n\n has(target, prop) {\n if (typeof prop === 'symbol') return Reflect.has(target, prop);\n if (prop === 'node' || prop === 'resource') return true;\n return prop in desired || prop in internal.observed;\n },\n }) as Resource;\n\n // Store internal mapping for the proxy too, so internals.get(proxy) works\n internals.set(proxy, internal);\n return proxy;\n}\n\n/**\n * Wrap a primitive observed value so it carries ReadProxy metadata\n * for dependency tracking when assigned elsewhere.\n */\nfunction createPrimitiveReadProxyFromResource(\n value: unknown,\n owner: ResourceRef,\n path: string,\n): unknown {\n if (value === null || value === undefined) return value;\n return createPrimitiveReadProxy(value as string | number | boolean, owner, path);\n}\n\n/**\n * Creates a proxy for a path that exists in neither desired nor observed.\n * - Reading nested properties returns ReadProxy leaves (for dependency tracking).\n * - Writing a nested property auto-initializes the path in desired and stores the value.\n */\nfunction createLazyInitProxy(\n desired: Record<string, unknown>,\n owner: ResourceRef,\n collector: EdgeCollector,\n basePath: string,\n): object {\n const readProxy = createReadProxy({} as object, owner, basePath);\n\n return new Proxy(readProxy as object, {\n get(target, prop, receiver) {\n if (typeof prop === 'symbol') return Reflect.get(target, prop, receiver);\n // Delegate reads to the ReadProxy (for tracking)\n return Reflect.get(target, prop, receiver);\n },\n\n set(_target, prop, value) {\n if (typeof prop === 'symbol') return false;\n // Auto-initialize the parent object in desired\n let container = desired[basePath] as Record<string, unknown> | undefined;\n if (!container || typeof container !== 'object') {\n container = {};\n desired[basePath] = container;\n }\n container[String(prop)] = processValue(\n value,\n owner,\n `${basePath}.${String(prop)}`,\n collector,\n );\n return true;\n },\n });\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { XplaneLogger } from './types.js';\n\nconst noopLogger: XplaneLogger = {\n debug() {},\n info() {},\n warn() {},\n};\n\nconst loggerStorage = new AsyncLocalStorage<XplaneLogger>();\n\n/**\n * Get the current logger from async context.\n * Returns a no-op logger if none has been set (silent by default).\n */\nexport function getLogger(): XplaneLogger {\n return loggerStorage.getStore() ?? noopLogger;\n}\n\n/**\n * Run a function with a logger available in async context.\n * All code within `fn` (and any nested async calls) can access\n * the logger via `getLogger()`.\n */\nexport function withLogger<T>(logger: XplaneLogger, fn: () => T): T {\n return loggerStorage.run(logger, fn);\n}\n","import {\n getDesiredDocument,\n getExternalRef,\n getObservedDocument,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { Pending } from '../tracking/index.js';\n\nimport type { DiagnosticReport, PipelineState } from './types.js';\n\n/**\n * DIAGNOSE phase: produce structured diagnostics for blocked resources.\n *\n * For each resource classified as 'blocked':\n * - Find all Pending markers in the desired document\n * - Report what they're waiting on (source resource + path)\n *\n * For circular dependencies (detected in sequence phase):\n * - Produce a 'cycle' diagnostic with the full cycle path\n */\nexport function diagnose(state: PipelineState): PipelineState {\n const diagnostics: DiagnosticReport[] = [];\n\n // Check for cycles from the graph\n const sortResult = state.graph.topologicalSort();\n if (sortResult.order === null && sortResult.cycle) {\n const firstCycleMember = sortResult.cycle[0];\n if (firstCycleMember) {\n diagnostics.push({\n resource: firstCycleMember,\n reason: 'cycle',\n cycle: sortResult.cycle,\n });\n }\n }\n\n // Report external resources that were required but not found.\n // Skip externals whose lookup name is itself unresolved (still a pending\n // template token, or non-string): the handler never sent a require for\n // them, so they aren't \"not found\" — they are downstream-blocked, and the\n // root cause (whatever upstream they're waiting on) will be reported on\n // its own.\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 if (typeof ref.name !== 'string' || ref.name.startsWith('__pending__')) continue;\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} '${ref.name}'${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 // Emit `dependency` diagnostics for resources blocked by explicit\n // construct-level dependencies (node.addDependency). Only surface those\n // whose waiting targets are not themselves blocked/not-found — same root-\n // cause filtering as for pending diagnostics.\n if (state.dependencyBlocks) {\n for (const [resourceId, waitingOn] of state.dependencyBlocks) {\n // Skip if already covered by a cycle/not-found/pending diagnostic.\n if (diagnostics.some((d) => d.resource === resourceId)) continue;\n const rootCauses = waitingOn.filter(\n (id) => !blockedIds.has(id) && !notFoundIds.has(id) && !state.dependencyBlocks?.has(id),\n );\n if (rootCauses.length === 0) continue;\n diagnostics.push({\n resource: resourceId,\n reason: 'dependency',\n waitingOn: rootCauses,\n });\n }\n }\n\n return { ...state, diagnostics };\n}\n\n/**\n * Recursively find all Pending markers in a document and report their source.\n */\nfunction findPendingPaths(\n obj: unknown,\n basePath: string,\n): Array<{ path: string; waitingOn: { resource: string; path: string } }> {\n const results: Array<{ path: string; waitingOn: { resource: string; path: string } }> = [];\n\n if (obj === null || obj === undefined) return results;\n if (Pending.is(obj)) {\n results.push({\n path: basePath,\n waitingOn: { resource: obj.source.id, path: obj.path },\n });\n return results;\n }\n if (typeof obj !== 'object') return results;\n\n if (Array.isArray(obj)) {\n for (let i = 0; i < obj.length; i++) {\n const childPath = basePath ? `${basePath}[${i}]` : `[${i}]`;\n results.push(...findPendingPaths(obj[i], childPath));\n }\n return results;\n }\n\n for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {\n const childPath = basePath ? `${basePath}.${key}` : key;\n results.push(...findPendingPaths(value, childPath));\n }\n return results;\n}\n","import { getXrDesiredStatus } from '../core/composition.js';\nimport {\n getDesiredDocument,\n getObservedDocument,\n getReadyChecks,\n getResourceInternals,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { getReadProxyMeta, isReadProxy } from '../tracking/index.js';\nimport { PendingTemplate } from '../tracking/types.js';\n\nimport type { EmittedResource, PipelineState } from './types.js';\n\n/**\n * EMIT phase: serialize each resource classified as 'emit' into a plain\n * Kubernetes resource document ready for Crossplane.\n *\n * Also extracts the XR desired status from this.xr.status assignments.\n *\n * For resources classified as 'blocked' that have previously-observed state,\n * emits the observed document as-is (marked `preserved: true`) so that\n * Crossplane does not delete them while their dependencies are still resolving.\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\n if (classification === 'emit') {\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 } else if (classification === 'blocked') {\n // If this resource has been observed before (i.e. Crossplane already created it),\n // emit the observed document stripped of server-managed fields so Crossplane does\n // not delete it while its dependencies are still pending.\n const observed = getObservedDocument(resource);\n if (Object.keys(observed).length === 0) continue;\n\n const name = ref.id.startsWith('Composition/') ? ref.id.slice('Composition/'.length) : ref.id;\n\n emitted.push({\n name,\n document: stripServerFields(deepClean(observed)),\n autoReady: false,\n readyChecks: [],\n preserved: true,\n });\n }\n }\n\n // Extract XR status and resolve any ReadProxy values using observed data\n const resourceById = new Map(state.resources.map((r) => [getResourceRef(r).id, r]));\n const rawStatus = getXrDesiredStatus(state.composition);\n const xrStatusPatches = resolveXrStatus(rawStatus, resourceById);\n\n return { ...state, emitted, xrStatusPatches };\n}\n\n/**\n * Deep-clone an object, stripping any remaining framework internals.\n * This produces a clean JSON-serializable Kubernetes document.\n */\nfunction deepClean(obj: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n result[key] = cleanValue(value);\n }\n\n return result;\n}\n\nfunction cleanValue(value: unknown): unknown {\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n if (PendingTemplate.is(value)) {\n // Should never reach emit — indicates a bug in the pipeline\n throw new Error(\n `PendingTemplate reached emit phase — resource should have been classified as blocked. Parts: ${JSON.stringify(value.parts)}`,\n );\n }\n\n if (Array.isArray(value)) {\n return value.map(cleanValue);\n }\n\n // Plain objects — recurse\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n result[key] = cleanValue(val);\n }\n return result;\n}\n\n/**\n * Strip server-managed Kubernetes fields from an observed document before\n * emitting it as a preserved desired resource.\n *\n * These fields are set by the API server / controllers and must not appear\n * in the desired state — including them causes Crossplane to try propagating\n * them (e.g. `uid`) into XR resourceRefs fields that the XRD schema may not\n * declare, resulting in a typed-patch validation failure.\n */\nconst SERVER_MANAGED_METADATA = new Set([\n 'uid',\n 'resourceVersion',\n 'generation',\n 'creationTimestamp',\n 'deletionTimestamp',\n 'deletionGracePeriodSeconds',\n 'managedFields',\n 'ownerReferences',\n 'selfLink',\n]);\n\nfunction stripServerFields(doc: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = { ...doc };\n\n // Remove top-level status — it is managed by the controller, not desired state\n delete result.status;\n\n // Strip server-managed metadata sub-fields\n if (result.metadata && typeof result.metadata === 'object') {\n const meta = { ...(result.metadata as Record<string, unknown>) };\n for (const field of SERVER_MANAGED_METADATA) {\n delete meta[field];\n }\n result.metadata = meta;\n }\n\n return result;\n}\n\n/**\n * Resolve ReadProxy values in XR status using observed resource data.\n * This is needed because XR status is written at construction time (before hydration),\n * so read proxy references need to be resolved post-hydration.\n */\nfunction resolveXrStatus(\n status: Record<string, unknown>,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(status)) {\n const resolved = resolveStatusValue(value, resourceById);\n if (resolved !== undefined) {\n result[key] = resolved;\n }\n }\n return result;\n}\n\nfunction resolveStatusValue(\n value: unknown,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): unknown {\n if (value === null || value === undefined) return undefined;\n\n if (isReadProxy(value)) {\n const meta = getReadProxyMeta(value);\n if (!meta) return undefined;\n\n // Try to extract a concrete primitive (already resolved read proxy)\n const prim = tryExtractPrimitive(value as object);\n if (prim !== undefined) return prim;\n\n // Leaf proxy — try to resolve from observed data\n const resource = resourceById.get(meta.owner.id);\n if (!resource) return undefined;\n const observed = getObservedDocument(resource);\n return getNestedValue(observed, meta.path);\n }\n\n if (Array.isArray(value)) {\n return value.map((v) => resolveStatusValue(v, resourceById)).filter((v) => v != null);\n }\n\n if (typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n const resolved = resolveStatusValue(v, resourceById);\n if (resolved !== undefined) {\n out[k] = resolved;\n }\n }\n return Object.keys(out).length > 0 ? out : undefined;\n }\n\n return value;\n}\n\nfunction tryExtractPrimitive(proxy: object): string | number | boolean | undefined {\n const toPrim = (proxy as Record<symbol, unknown>)[Symbol.toPrimitive];\n if (typeof toPrim === 'function') {\n const result = (toPrim as () => unknown)();\n if (result !== undefined && result !== null && typeof result !== 'object') {\n // Leaf proxy placeholders are not real values — skip them\n if (typeof result === 'string' && result.startsWith('__pending__')) return undefined;\n return result as string | number | boolean;\n }\n }\n return undefined;\n}\n\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split('.');\n let current: unknown = obj;\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n","import { getExternalRef, hydrateObserved, isExternal } from '../core/resource.js';\n\nimport type { PipelineState } from './types.js';\n\n/**\n * HYDRATE phase: feed observed state from Crossplane into each resource.\n *\n * - Composed resources are matched by their construct path (resource name).\n * - External resources are matched by their refKey.\n */\nexport function hydrate(state: PipelineState): PipelineState {\n for (const resource of state.resources) {\n if (isExternal(resource)) {\n const ref = getExternalRef(resource);\n if (ref) {\n const observed = state.observedRequired.get(ref.refKey);\n if (observed) {\n hydrateObserved(resource, observed);\n }\n }\n } else {\n // Match by construct path\n const name = resource.node.path;\n const observed = state.observedComposed.get(name);\n if (observed) {\n hydrateObserved(resource, observed);\n }\n }\n }\n\n return state;\n}\n","import { getDesiredDocument, getObservedDocument, getResourceRef } from '../core/resource.js';\nimport { Pending, PendingTemplate } from '../tracking/index.js';\n\nimport type { PipelineState } from './types.js';\n\n/**\n * RESOLVE phase: walk dependency edges and replace Pending markers\n * with concrete values from observed state where available.\n *\n * For each resource's desired document, recursively find Pending values.\n * Look up the source resource's observed state at the source path.\n * If concrete → replace. If not available → leave Pending in place.\n */\nexport function resolve(state: PipelineState): PipelineState {\n // Build a lookup: resource id → Resource instance\n const resourceById = new Map(state.resources.map((r) => [getResourceRef(r).id, r]));\n\n for (const resource of state.resources) {\n const desired = getDesiredDocument(resource);\n resolvePending(desired, resourceById);\n }\n\n return state;\n}\n\n/**\n * Recursively walk an object and resolve any Pending markers.\n */\nfunction resolvePending(\n obj: Record<string, unknown>,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): void {\n for (const [key, value] of Object.entries(obj)) {\n if (Pending.is(value)) {\n const sourceResource = resourceById.get(value.source.id);\n if (sourceResource) {\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, value.path);\n if (resolved !== undefined) {\n obj[key] = resolved;\n }\n // else: leave Pending in place — still unresolved\n }\n } else if (PendingTemplate.is(value)) {\n const resolved = resolvePendingTemplate(value, resourceById);\n if (resolved !== undefined) obj[key] = resolved;\n } else if (Array.isArray(value)) {\n resolveArray(value, resourceById);\n } else if (value !== null && typeof value === 'object') {\n resolvePending(value as Record<string, unknown>, resourceById);\n }\n }\n}\n\nfunction resolveArray(\n arr: unknown[],\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): void {\n for (let i = 0; i < arr.length; i++) {\n const value = arr[i];\n if (Pending.is(value)) {\n const sourceResource = resourceById.get(value.source.id);\n if (sourceResource) {\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, value.path);\n if (resolved !== undefined) {\n arr[i] = resolved;\n }\n }\n } else if (PendingTemplate.is(value)) {\n const resolved = resolvePendingTemplate(value, resourceById);\n if (resolved !== undefined) arr[i] = resolved;\n } else if (Array.isArray(value)) {\n resolveArray(value, resourceById);\n } else if (value !== null && typeof value === 'object') {\n resolvePending(value as Record<string, unknown>, resourceById);\n }\n }\n}\n\n/**\n * Get a nested value from an object by dot-separated path.\n */\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n const segments = path.split('.');\n let current: unknown = obj;\n\n for (const segment of segments) {\n if (current === null || current === undefined) return undefined;\n if (typeof current !== 'object') return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n\n return current;\n}\n\n/**\n * Attempt to resolve all slots of a PendingTemplate.\n * Returns the reconstructed string if all slots resolve, undefined otherwise.\n */\nfunction resolvePendingTemplate(\n template: PendingTemplate,\n resourceById: ReadonlyMap<string, import('../core/resource.js').Resource>,\n): string | undefined {\n const values: string[] = [];\n for (const slot of template.slots) {\n const sourceResource = resourceById.get(slot.source.id);\n if (!sourceResource) return undefined;\n const observed = getObservedDocument(sourceResource);\n const resolved = getNestedValue(observed, slot.path);\n if (resolved === undefined || resolved === null) return undefined;\n values.push(String(resolved));\n }\n let result = template.parts[0]!;\n for (let i = 0; i < values.length; i++) {\n result += values[i] + template.parts[i + 1]!;\n }\n return result;\n}\n","import 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 * Vetoes readiness when a `Synced` condition is explicitly `False` (Crossplane\n * provider reconciliation error). Returns `undefined` otherwise so this check\n * does not by itself imply readiness — it only blocks it.\n */\nexport function syncedNotFalse(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 synced = conditions.find((c) => c.type === 'Synced');\n if (!synced) return undefined;\n\n return synced.status === 'False' ? false : undefined;\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: syncedNotFalse, priority: 100, name: 'syncedNotFalse' },\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 { Resource } from '../core/resource.js';\nimport {\n getDesiredDocument,\n getObservedDocument,\n getReadyChecks,\n getResourceRef,\n isExternal,\n} from '../core/resource.js';\nimport { DEFAULT_CHECKS, evaluateReadiness } from '../readiness/index.js';\nimport { Pending, PendingTemplate } from '../tracking/index.js';\n\nimport type { PipelineState, ResourceClassification } from './types.js';\n\n/**\n * SEQUENCE phase: topological sort and classification.\n *\n * - Runs topological sort on the dependency graph.\n * - Classifies each resource as 'emit', 'blocked', or 'external'.\n * - A resource is 'blocked' if it still has Pending markers in its desired document.\n * - External resources are classified as 'external' (never emitted).\n * - Circular dependencies are detected via the graph's topological sort.\n * - After the Pending-based pass, an explicit-dependency pass runs to a\n * fixed point: any resource classified `emit` is downgraded to `blocked`\n * if a graph dependency target is itself blocked, an unobserved external,\n * or an `emit` resource whose observed state is not yet Ready\n * (`evaluateReadiness`).\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 // Index resources by id for dependency lookup\n const byId = new Map<string, Resource>();\n for (const resource of state.resources) byId.set(getResourceRef(resource).id, resource);\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 // Fixed-point: propagate explicit-dependency blocks. A resource is blocked\n // if any of its graph dependency targets is not yet satisfied.\n const dependencyBlocks = new Map<string, string[]>();\n const isTargetSatisfied = (depId: string): boolean => {\n const cls = classification.get(depId);\n if (cls === undefined) return true; // unknown dep id → don't gate on it\n if (cls === 'blocked') return false;\n const target = byId.get(depId);\n if (!target) return true;\n if (cls === 'external') {\n // External is satisfied iff Crossplane returned a hydrated observed doc.\n return Object.keys(getObservedDocument(target)).length > 0;\n }\n // cls === 'emit' — require the target to be Ready in observed state.\n const observed = state.observedComposed.get(depId);\n if (!observed) return false;\n const checks = [...getReadyChecks(target), ...DEFAULT_CHECKS];\n return evaluateReadiness(checks, observed);\n };\n\n let changed = true;\n while (changed) {\n changed = false;\n for (const resource of state.resources) {\n const ref = getResourceRef(resource);\n if (classification.get(ref.id) !== 'emit') continue;\n const deps = state.graph.getDependencies(ref.id);\n if (deps.size === 0) continue;\n const unsatisfied: string[] = [];\n for (const depId of deps) {\n if (depId === ref.id) continue;\n if (!isTargetSatisfied(depId)) unsatisfied.push(depId);\n }\n if (unsatisfied.length > 0) {\n classification.set(ref.id, 'blocked');\n dependencyBlocks.set(ref.id, unsatisfied);\n changed = true;\n }\n }\n }\n\n return { ...state, classification, dependencyBlocks };\n}\n\n/**\n * Recursively check if an object contains any Pending markers.\n */\nfunction containsPending(obj: unknown): boolean {\n if (obj === null || obj === undefined) return false;\n if (Pending.is(obj)) return true;\n if (PendingTemplate.is(obj)) return true;\n if (typeof obj !== 'object') return false;\n\n if (Array.isArray(obj)) {\n return obj.some(containsPending);\n }\n\n for (const value of Object.values(obj as Record<string, unknown>)) {\n if (containsPending(value)) return true;\n }\n return false;\n}\n","import type { Composition } from '../core/composition.js';\nimport type { Resource } from '../core/resource.js';\nimport { getResourceRef } 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 linkConstructDependencies(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\n/**\n * Translate constructs-level `node.addDependency()` calls into explicit edges\n * on the dependency graph. For every construct C in the tree, every Resource\n * under C is made to depend on every Resource under each of C's dependency\n * targets. This way, blocking on construct-level dependencies fans out to\n * every leaf Resource the user expects.\n */\nexport function linkConstructDependencies(composition: Composition): void {\n const graph = composition.graph;\n const visit = (c: import('constructs').Construct): void => {\n const deps = c.node.dependencies;\n if (deps && deps.length > 0) {\n const dependents = collectResourcesUnder(c);\n if (dependents.length > 0) {\n for (const dep of deps) {\n const targets = collectResourcesUnder(dep);\n for (const d of dependents) {\n for (const t of targets) {\n if (d === t) continue;\n graph.addExplicitDependency(getResourceRef(d), getResourceRef(t));\n }\n }\n }\n }\n }\n for (const child of c.node.children) visit(child);\n };\n visit(composition);\n}\n\nfunction collectResourcesUnder(c: import('constructs').Construct): Resource[] {\n const out: Resource[] = [];\n const walk = (n: import('constructs').Construct): void => {\n if (isResourceInstance(n)) out.push(n);\n for (const child of n.node.children) walk(child);\n };\n walk(c);\n return out;\n}\n","import type {\n BlockedResource,\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 { getDesiredDocument, getExternalRef, getResourceRef, isExternal } from './core/resource.js';\nimport { runPipeline } from './pipeline/index.js';\nimport { DEFAULT_CHECKS, evaluateReadiness } from './readiness/index.js';\nimport { DependencyGraph, EdgeCollector } from './tracking/index.js';\nimport { createTokenRegistry, tokenRegistryStorage } from './tracking/token-registry.js';\n\n/**\n * Run a composition class with the given input and return a plain-data result.\n *\n * This is the single entry point that bridges the composition author's class\n * with the runtime. It handles:\n * 1. Setting up internal context (DependencyGraph, EdgeCollector, ALS)\n * 2. Instantiating the Composition class\n * 3. Running the full pipeline (hydrate → resolve → sequence → diagnose → emit)\n * 4. Evaluating readiness per resource\n * 5. Returning a fully serializable CompositionResult\n *\n * The runtime never needs to access framework internals — everything it needs\n * is in the returned plain-data structure.\n */\nexport function runComposition<TSpec, TStatus, TContext extends object>(\n CompositionClass: new () => Composition<TSpec, TStatus, TContext>,\n input: CompositionInput,\n): CompositionResult {\n // Convert plain Records to Maps for the internal pipeline\n const observedComposed = new Map(Object.entries(input.observedComposed));\n const observedRequired = new Map(Object.entries(input.observedRequired));\n\n // Set up internal context\n const graph = new DependencyGraph();\n const collector = new EdgeCollector();\n const pipelineContext = new Map(Object.entries(input.pipelineContext));\n\n const ctx: CompositionContext = {\n xr: input.xr,\n pipelineContext,\n requiredResources: observedRequired,\n observedComposed,\n graph,\n collector,\n };\n\n // Instantiate composition within ALS context\n const composition = compositionStorage.run(ctx, () =>\n tokenRegistryStorage.run(createTokenRegistry(), () => new CompositionClass()),\n ) as Composition;\n\n // Run the pipeline\n const state = runPipeline({ composition, observedComposed, observedRequired });\n\n // Build the result — plain data only\n const resources: DesiredResource[] = state.emitted.map((emitted) => {\n const k8sName = extractMetadataName(emitted.document);\n const namespace = extractMetadataNamespace(emitted.document);\n if (emitted.preserved) {\n // Blocked resource being emitted as its observed state — mark not ready.\n return {\n nodePath: emitted.name,\n document: emitted.document,\n ready: false,\n preserved: true,\n ...(k8sName ? { name: k8sName } : {}),\n ...(namespace ? { namespace } : {}),\n };\n }\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 nodePath: emitted.name,\n document: emitted.document,\n ready,\n ...(k8sName ? { name: k8sName } : {}),\n ...(namespace ? { namespace } : {}),\n };\n });\n\n const externalResources: ExternalResourceRequest[] = [];\n for (const resource of state.resources) {\n if (!isExternal(resource)) continue;\n const ref = getExternalRef(resource);\n if (!ref || typeof ref.name !== 'string') continue;\n if (ref.name.startsWith('__pending__')) continue;\n\n externalResources.push({\n refKey: ref.refKey,\n apiVersion: ref.apiVersion,\n kind: ref.kind,\n name: ref.name,\n ...(ref.namespace ? { namespace: ref.namespace } : {}),\n });\n }\n\n // Collect blocked resource info so the handler can preserve observed state\n // in desired (preventing accidental deletion), prevent premature XR readiness,\n // and surface a structured `status.xplane.blockedResources` entry on the XR.\n const blockedResources: BlockedResource[] = [];\n for (const resource of state.resources) {\n if (isExternal(resource)) continue;\n const ref = getResourceRef(resource);\n if (state.classification.get(ref.id) !== 'blocked') continue;\n const nodePath = ref.id.startsWith('Composition/')\n ? ref.id.slice('Composition/'.length)\n : ref.id;\n const desired = getDesiredDocument(resource);\n const apiVersion = typeof desired.apiVersion === 'string' ? desired.apiVersion : '';\n const kind = typeof desired.kind === 'string' ? desired.kind : '';\n const k8sName = extractMetadataName(desired);\n const namespace = extractMetadataNamespace(desired);\n const waitingFor = describeWaitingFor(nodePath, state.diagnostics);\n blockedResources.push({\n nodePath,\n apiVersion,\n kind,\n ...(k8sName ? { name: k8sName } : {}),\n ...(namespace ? { namespace } : {}),\n ...(waitingFor && waitingFor.length > 0 ? { waitingFor } : {}),\n });\n }\n\n return {\n resources,\n blockedResources,\n externalResources,\n xrStatus: state.xrStatusPatches,\n diagnostics: state.diagnostics,\n emitXplaneStatus: composition.emitXplaneStatus === true,\n };\n}\n\n/**\n * Build a human-readable `waitingFor` list for a blocked resource from the\n * matching diagnostic. Each entry describes one thing the resource is waiting\n * on (one entry per pending path, or a single entry for cycle/not-found).\n */\nfunction describeWaitingFor(\n name: string,\n diagnostics: ReadonlyArray<{\n resource: string;\n reason: 'pending' | 'cycle' | 'not-found' | 'dependency';\n pendingPaths?: Array<{ path: string; waitingOn: { resource: string; path: string } }>;\n cycle?: string[];\n detail?: string;\n waitingOn?: string[];\n }>,\n): string[] | undefined {\n const id = `Composition/${name}`;\n const diag = diagnostics.find((d) => d.resource === id || d.resource === name);\n if (!diag) return undefined;\n\n if (diag.reason === 'cycle') {\n return [`circular dependency: ${(diag.cycle ?? []).join(' → ')}`];\n }\n if (diag.reason === 'not-found') {\n return [diag.detail ?? 'external resource not found'];\n }\n if (diag.reason === 'dependency' && diag.waitingOn && diag.waitingOn.length > 0) {\n return diag.waitingOn.map((dep) => {\n const stripped = dep.startsWith('Composition/') ? dep.slice('Composition/'.length) : dep;\n return `${stripped} to be Ready`;\n });\n }\n if (diag.pendingPaths && diag.pendingPaths.length > 0) {\n return diag.pendingPaths.map((p) => {\n const dep = p.waitingOn.resource.startsWith('Composition/')\n ? p.waitingOn.resource.slice('Composition/'.length)\n : p.waitingOn.resource;\n return `${dep}.${p.waitingOn.path}`;\n });\n }\n return undefined;\n}\n\nfunction extractMetadataName(doc: Record<string, unknown>): string | undefined {\n const metadata = doc.metadata;\n if (!metadata || typeof metadata !== 'object') return undefined;\n const name = (metadata as Record<string, unknown>).name;\n return typeof name === 'string' && name.length > 0 ? name : undefined;\n}\n\nfunction extractMetadataNamespace(doc: Record<string, unknown>): string | undefined {\n const metadata = doc.metadata;\n if (!metadata || typeof metadata !== 'object') return undefined;\n const namespace = (metadata as Record<string, unknown>).namespace;\n return typeof namespace === 'string' && namespace.length > 0 ? namespace : undefined;\n}\n"],"mappings":";;;;;;;;AA6BA,MAAa,qBAAqB,IAAI,kBAAsC;;;;;AAM5E,SAAgB,wBAA4C;CAC1D,MAAM,MAAM,mBAAmB,SAAS;CACxC,IAAI,KAAK,OAAO;CAEhB,MAAM,IAAI,MACR,sGACF;AACF;;;;;;;;;;;;;;;;;;;;;ACeA,IAAa,cAAb,cAIUA,YAAU;;;;;CAKlB;;CAGA;;CAGA;;;;;;;;;;;;;;;;;;;;;;;;CAyBA,mBAAmB;CAEnB,cAAc;EAEZ,MAAM,KAAA,GAAmC,aAAa;EAEtD,MAAM,MAAM,sBAAsB;EAElC,KAAK,QAAQ,IAAI;EACjB,KAAK,YAAY,IAAI;EAGrB,KAAK,KAAK,WAAW,gBAAgB,IAAI,KAAK;EAC9C,KAAK,KAAK,WAAW,oBAAoB,IAAI,SAAS;EAGtD,MAAM,SAAS,IAAI,GAAG;EACtB,IAAI,QACF,KAAK,KAAK,WAAW,kBAAkB,MAAM;EAI/C,KAAK,KAAK,cAA8B,GAAG;CAC7C;;;;;CAMA,IAAI,kBAAqD;EACvD,MAAM,MAAM,sBAAsB;EAClC,OAAO;GACL,IAA8B,KAAiC;IAC7D,OAAO,IAAI,gBAAgB,IAAI,GAAa;GAC9C;GACA,IAAI,KAA8B;IAChC,OAAO,IAAI,gBAAgB,IAAI,GAAa;GAC9C;GACA,OAAyC;IACvC,OAAO,IAAI,gBAAgB,KAAK;GAClC;EACF;CACF;AACF;;;;;;;;AAkBA,SAAS,cAA8B,KAIX;CAC1B,MAAM,aAAa,IAAI;CACvB,MAAM,kBAA2C,CAAC;CAIlD,IAAI,MAAM,YAAY,EADN,IAAI,SACM,CAAC;CAE3B,MAAM,cAAc,IAAI,MAAM,iBAAiB;EAC7C,IAAI,SAAS,MAAM;GACjB,IAAI,OAAO,SAAS,U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,KAAK,QAAQ;EAEjC,OAAO,GADU,IAAI,WAAW,cAAc,IAAI,IAAI,MAAM,EAAqB,IAAI,IAClE;CACrB,CAAC;CAEH,IAAI,KAAK,gBAAgB,KAAK,aAAa,SAAS,GAClD,OAAO,KAAK,aAAa,KAAK,MAAM;EAIlC,OAAO,GAHK,EAAE,UAAU,SAAS,WAAW,cAAc,IACtD,EAAE,UAAU,SAAS,MAAM,EAAqB,IAChD,EAAE,UAAU,SACF,GAAG,EAAE,UAAU;CAC/B,CAAC;AAGL;AAEA,SAAS,oBAAoB,KAAkD;CAC7E,MAAM,WAAW,IAAI;CACrB,IAAI,CAAC,YAAY,OAAO,aAAa,UAAU,OAAO,KAAA;CACtD,MAAM,OAAQ,SAAqC;CACnD,OAAO,OAAO,SAAS,YAAY,KAAK,SAAS,IAAI,OAAO,KAAA;AAC9D;AAEA,SAAS,yBAAyB,KAAkD;CAClF,MAAM,WAAW,IAAI;CACrB,IAAI,CAAC,YAAY,OAAO,aAAa,UAAU,OAAO,KAAA;CACtD,MAAM,YAAa,SAAqC;CACxD,OAAO,OAAO,cAAc,YAAY,UAAU,SAAS,IAAI,YAAY,KAAA;AAC7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xplane/core",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "description": "Core CDK-style composition library for Crossplane functions",
6
6
  "license": "Apache-2.0",