@empire-builder-kit/nx 1.0.0-rc.46 → 1.0.0-rc.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/generators.json +11 -1
  2. package/package.json +3 -3
  3. package/src/aws-authority/stage-authority.d.ts +30 -2
  4. package/src/aws-authority/stage-authority.js +220 -25
  5. package/src/developer-agent/generator-planning.js +99 -6
  6. package/src/developer-agent/model.d.ts +7 -3
  7. package/src/developer-agent/model.js +1 -0
  8. package/src/developer-agent/operation-registry.d.ts +1 -0
  9. package/src/developer-agent/operation-registry.js +43 -2
  10. package/src/developer-agent/planning.js +5 -2
  11. package/src/developer-agent/preview-changes.js +10 -0
  12. package/src/developer-agent/validation.js +7 -3
  13. package/src/developer-agent/workspace-inspection.js +51 -4
  14. package/src/executors/deployment-plan/deployment-plan.js +3 -0
  15. package/src/executors/dev-doctor/dev-doctor.d.ts +25 -3
  16. package/src/executors/dev-doctor/dev-doctor.js +136 -49
  17. package/src/executors/dev-setup/dev-setup.d.ts +18 -1
  18. package/src/executors/dev-setup/dev-setup.js +320 -196
  19. package/src/executors/foundation-preflight/foundation-preflight.js +9 -1
  20. package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js +2 -2
  21. package/src/executors/infrastructure-plan/infrastructure-plan.js +10 -3
  22. package/src/executors/local-deploy/local-deploy.d.ts +15 -0
  23. package/src/executors/local-deploy/local-deploy.js +96 -14
  24. package/src/executors/sst-lifecycle/logging-preflight.js +12 -1
  25. package/src/executors/sst-lifecycle/run-sst-command.js +51 -5
  26. package/src/foundation/cost-estimate.js +1 -1
  27. package/src/foundation/identity-domain-parent-ready.d.ts +91 -0
  28. package/src/foundation/identity-domain-parent-ready.js +333 -0
  29. package/src/foundation/identity-domain.d.ts +94 -0
  30. package/src/foundation/identity-domain.js +115 -0
  31. package/src/foundation/index.d.ts +2 -0
  32. package/src/foundation/index.js +7 -0
  33. package/src/foundation/preflight.js +17 -1
  34. package/src/foundation/root-site-readiness.d.ts +27 -0
  35. package/src/foundation/root-site-readiness.js +78 -0
  36. package/src/foundation/root-site.d.ts +81 -0
  37. package/src/foundation/root-site.js +268 -0
  38. package/src/generators/framework-prerequisites.d.ts +2 -0
  39. package/src/generators/framework-prerequisites.js +34 -0
  40. package/src/generators/function/function-registration.d.ts +24 -0
  41. package/src/generators/function/function-registration.js +66 -0
  42. package/src/generators/function/function.d.ts +16 -1
  43. package/src/generators/function/function.js +101 -18
  44. package/src/generators/function/schema.d.ts +1 -0
  45. package/src/generators/function/schema.json +6 -0
  46. package/src/generators/function-access/function-access.d.ts +14 -0
  47. package/src/generators/function-access/function-access.js +141 -0
  48. package/src/generators/function-access/schema.d.ts +6 -0
  49. package/src/generators/function-access/schema.json +25 -0
  50. package/src/generators/post-generation-install.d.ts +1 -1
  51. package/src/generators/post-generation-install.js +1 -1
  52. package/src/generators/preset/dependency-overrides.d.ts +1 -1
  53. package/src/generators/preset/dependency-overrides.js +1 -1
  54. package/src/generators/preset/workspace-files-adopter-skills.js +14 -0
  55. package/src/generators/preset/workspace-files-developer-agent.js +17 -11
  56. package/src/generators/preset/workspace-files-stage-authority.js +58 -1
  57. package/src/generators/preset/workspace-files-thin-deploy.d.ts +11 -0
  58. package/src/generators/preset/workspace-files-thin-deploy.js +47 -4
  59. package/src/generators/preset/workspace-files-thin-docs.js +33 -5
  60. package/src/generators/preset/workspace-files.js +207 -13
  61. package/src/generators/repository-policy/repository-policy.js +2 -1
  62. package/src/generators/repository-policy/schema.d.ts +2 -0
  63. package/src/generators/repository-policy/schema.json +7 -2
  64. package/src/generators/site/built-in-site-documentation-files.d.ts +2 -0
  65. package/src/generators/site/built-in-site-documentation-files.js +92 -0
  66. package/src/generators/site/built-in-site-files.d.ts +8 -0
  67. package/src/generators/site/built-in-site-files.js +40 -0
  68. package/src/generators/site/built-in-site-infrastructure-files.d.ts +2 -0
  69. package/src/generators/site/built-in-site-infrastructure-files.js +275 -0
  70. package/src/generators/site/built-in-site-plan.d.ts +19 -0
  71. package/src/generators/site/built-in-site-plan.js +65 -0
  72. package/src/generators/site/built-in-site-project-files.d.ts +3 -0
  73. package/src/generators/site/built-in-site-project-files.js +258 -0
  74. package/src/generators/site/built-in-site-script-files.d.ts +2 -0
  75. package/src/generators/site/built-in-site-script-files.js +306 -0
  76. package/src/generators/site/built-in-site-shared.d.ts +9 -0
  77. package/src/generators/site/built-in-site-shared.js +21 -0
  78. package/src/generators/site/built-in-site-smoke-files.d.ts +2 -0
  79. package/src/generators/site/built-in-site-smoke-files.js +37 -0
  80. package/src/generators/site/built-in-site-sst-config-files.d.ts +2 -0
  81. package/src/generators/site/built-in-site-sst-config-files.js +39 -0
  82. package/src/generators/site/built-in-site-web-files.d.ts +2 -0
  83. package/src/generators/site/built-in-site-web-files.js +284 -0
  84. package/src/generators/site/schema.d.ts +4 -0
  85. package/src/generators/site/schema.json +20 -0
  86. package/src/generators/site/site.d.ts +13 -0
  87. package/src/generators/site/site.js +221 -0
  88. package/src/generators/slice/built-in-plan-alarm-identity.d.ts +9 -0
  89. package/src/generators/slice/built-in-plan-alarm-identity.js +8 -1
  90. package/src/generators/slice/built-in-plan-api-contract-files.js +18 -0
  91. package/src/generators/slice/built-in-plan-async-work-files.js +18 -0
  92. package/src/generators/slice/built-in-plan-data-files.js +116 -11
  93. package/src/generators/slice/built-in-plan-foundation-files.d.ts +12 -0
  94. package/src/generators/slice/built-in-plan-foundation-files.js +114 -5
  95. package/src/generators/slice/built-in-plan-frontend-files.js +2 -271
  96. package/src/generators/slice/built-in-plan-frontend-header-proof.d.ts +6 -0
  97. package/src/generators/slice/built-in-plan-frontend-header-proof.js +282 -0
  98. package/src/generators/slice/built-in-plan-infrastructure-files.js +151 -237
  99. package/src/generators/slice/built-in-plan-key-value-cleanup.js +4 -3
  100. package/src/generators/slice/built-in-plan-log-group-helpers.d.ts +29 -0
  101. package/src/generators/slice/built-in-plan-log-group-helpers.js +130 -0
  102. package/src/generators/slice/built-in-plan-metadata-files.js +21 -4
  103. package/src/generators/slice/built-in-plan-next-build-authority.d.ts +5 -0
  104. package/src/generators/slice/built-in-plan-next-build-authority.js +124 -0
  105. package/src/generators/slice/built-in-plan-operations-files.d.ts +6 -0
  106. package/src/generators/slice/built-in-plan-operations-files.js +107 -219
  107. package/src/generators/slice/built-in-plan-performance-files.js +6 -1
  108. package/src/generators/slice/built-in-plan-reliability-files.js +12 -8
  109. package/src/generators/slice/built-in-plan-shared.d.ts +1 -1
  110. package/src/generators/slice/built-in-plan-shared.js +1 -1
  111. package/src/generators/slice/built-in-plan-sst-config.d.ts +49 -0
  112. package/src/generators/slice/built-in-plan-sst-config.js +160 -0
  113. package/src/generators/slice/built-in-plan-testing-files.js +92 -49
  114. package/src/generators/slice/built-in-plan-verification-files.js +15 -4
  115. package/src/generators/slice/built-in-plan-web-files.js +65 -0
  116. package/src/generators/slice/deployed-smoke-diagnostics.d.ts +35 -0
  117. package/src/generators/slice/deployed-smoke-diagnostics.js +189 -0
  118. package/src/generators/slice/deployed-smoke-readiness.d.ts +7 -0
  119. package/src/generators/slice/deployed-smoke-readiness.js +118 -23
  120. package/src/generators/slice/persistence-contract.js +2 -2
  121. package/src/generators/slice/pnpm-launch-script.d.ts +13 -0
  122. package/src/generators/slice/pnpm-launch-script.js +28 -0
  123. package/src/generators/slice/slice.js +27 -0
  124. package/src/generators/upgrade/custom-domain-notice.d.ts +19 -0
  125. package/src/generators/upgrade/custom-domain-notice.js +38 -0
  126. package/src/generators/upgrade/external-blueprint-compositions.d.ts +84 -0
  127. package/src/generators/upgrade/external-blueprint-compositions.js +478 -0
  128. package/src/generators/upgrade/framework-package-upgrade.d.ts +58 -0
  129. package/src/generators/upgrade/framework-package-upgrade.js +78 -0
  130. package/src/generators/upgrade/function-authentication-notice.d.ts +29 -0
  131. package/src/generators/upgrade/function-authentication-notice.js +74 -0
  132. package/src/generators/upgrade/schema.json +2 -2
  133. package/src/generators/upgrade/upgrade-plan.d.ts +52 -0
  134. package/src/generators/upgrade/upgrade-plan.js +406 -0
  135. package/src/generators/upgrade/upgrade.d.ts +1 -35
  136. package/src/generators/upgrade/upgrade.js +259 -593
  137. package/src/generators/workload/workload.js +60 -4
  138. package/src/git-policy/github-bootstrap.d.ts +6 -5
  139. package/src/git-policy/github-bootstrap.js +6 -4
  140. package/src/local-dev/fleet-process.d.ts +9 -2
  141. package/src/local-dev/fleet-process.js +27 -7
  142. package/src/local-dev/gateway-daemon.d.ts +1 -1
  143. package/src/local-dev/gateway-daemon.js +6 -4
  144. package/src/local-dev/portless.d.ts +5 -0
  145. package/src/local-dev/portless.js +5 -0
  146. package/src/local-dev/process-group.d.ts +10 -0
  147. package/src/local-dev/process-group.js +33 -0
  148. package/src/local-dev/tls.js +31 -2
  149. package/src/local-dev/trust-store.d.ts +42 -0
  150. package/src/local-dev/trust-store.js +87 -0
  151. package/src/ownership/composition.d.ts +7 -0
  152. package/src/ownership/composition.js +64 -56
  153. package/src/ownership/index.d.ts +1 -0
  154. package/src/ownership/index.js +1 -0
  155. package/src/ownership/record.d.ts +19 -0
  156. package/src/ownership/record.js +26 -2
  157. package/src/ownership/site-record.d.ts +18 -0
  158. package/src/ownership/site-record.js +105 -0
  159. package/src/repository-policy/deployment-plan.d.ts +3 -0
  160. package/src/repository-policy/deployment-plan.js +33 -4
  161. package/src/repository-policy/index.d.ts +1 -0
  162. package/src/repository-policy/index.js +1 -0
  163. package/src/repository-policy/policy.d.ts +13 -1
  164. package/src/repository-policy/policy.js +55 -1
  165. package/src/repository-policy/public-dns.d.ts +65 -0
  166. package/src/repository-policy/public-dns.js +168 -0
  167. package/src/schemas/generated-ownership-v2.json +6 -0
  168. package/src/schemas/repository-policy-v1.json +67 -1
  169. package/src/supply-chain/blueprint-trust-git.js +24 -0
  170. package/src/supply-chain/blueprint-verification-authority.js +21 -3
  171. package/src/supply-chain/generated-blueprint-trust-command.js +15 -0
  172. package/src/work-markers/work-markers.js +4 -1
  173. package/src/workspace-deployment/ownership.d.ts +15 -0
  174. package/src/workspace-deployment/ownership.js +19 -3
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_DELIVERY_LANE = exports.DELIVERY_LANES = exports.DEPLOYMENT_PROFILES = exports.REPOSITORY_MODE_PRESETS = exports.SLICE_PRODUCTION_STATUSES = exports.DEFAULT_RECOVERY_PRODUCTION_FOUNDATION_PROFILE = exports.PRODUCTION_FOUNDATION_PROFILES = exports.PRODUCTION_APPROVAL_MODES = exports.PRODUCTION_ACCESS_VALUES = exports.REPOSITORY_POLICY_SCHEMA_URL = exports.REPOSITORY_POLICY_SCHEMA_VERSION = exports.REPOSITORY_POLICY_FILE = void 0;
3
+ exports.DEFAULT_DELIVERY_LANE = exports.DELIVERY_LANES = exports.DEPLOYMENT_PROFILES = exports.REPOSITORY_MODE_PRESETS = exports.ROOT_SITE_PRODUCTION_STATUSES = exports.SLICE_PRODUCTION_STATUSES = exports.DEFAULT_RECOVERY_PRODUCTION_FOUNDATION_PROFILE = exports.PRODUCTION_FOUNDATION_PROFILES = exports.PRODUCTION_APPROVAL_MODES = exports.PRODUCTION_ACCESS_VALUES = exports.REPOSITORY_POLICY_SCHEMA_URL = exports.REPOSITORY_POLICY_SCHEMA_VERSION = exports.REPOSITORY_POLICY_FILE = void 0;
4
4
  exports.deliveryLaneOf = deliveryLaneOf;
5
5
  exports.normalizeDeploymentAccountId = normalizeDeploymentAccountId;
6
6
  exports.requiresGithubDeployment = requiresGithubDeployment;
@@ -18,6 +18,7 @@ exports.validateRepositoryOperatingPolicyMigrationProvenance = validateRepositor
18
18
  exports.readRepositoryOperatingPolicy = readRepositoryOperatingPolicy;
19
19
  exports.createIncubationRepositoryPolicy = createIncubationRepositoryPolicy;
20
20
  exports.applyRepositoryPolicyChange = applyRepositoryPolicyChange;
21
+ exports.rootSiteProductionStatus = rootSiteProductionStatus;
21
22
  exports.evaluateRepositoryPolicyRequest = evaluateRepositoryPolicyRequest;
22
23
  exports.assertRepositoryPolicyRequest = assertRepositoryPolicyRequest;
23
24
  const node_crypto_1 = require("node:crypto");
@@ -28,6 +29,8 @@ const node_path_1 = require("node:path");
28
29
  const validation_js_1 = require("../validation.js");
29
30
  const identity_js_1 = require("../workspace-deployment/identity.js");
30
31
  const migration_evidence_js_1 = require("../workspace-deployment/migration-evidence.js");
32
+ const public_dns_js_1 = require("./public-dns.js");
33
+ const root_site_js_1 = require("../foundation/root-site.js");
31
34
  exports.REPOSITORY_POLICY_FILE = 'ebk.repository-policy.json';
32
35
  exports.REPOSITORY_POLICY_SCHEMA_VERSION = 1;
33
36
  const MAX_REPOSITORY_POLICY_BYTES = 1024 * 1024;
@@ -47,6 +50,8 @@ exports.PRODUCTION_FOUNDATION_PROFILES = [
47
50
  ];
48
51
  exports.DEFAULT_RECOVERY_PRODUCTION_FOUNDATION_PROFILE = 'standard';
49
52
  exports.SLICE_PRODUCTION_STATUSES = ['blocked', 'pilot', 'ready'];
53
+ /** The root site has no pilot posture: production serves it or skips it. */
54
+ exports.ROOT_SITE_PRODUCTION_STATUSES = ['blocked', 'ready'];
50
55
  exports.REPOSITORY_MODE_PRESETS = [
51
56
  'incubation',
52
57
  'controlled-production',
@@ -191,7 +196,9 @@ const POLICY_PROPERTIES = new Set([
191
196
  'productionAccess',
192
197
  'productionApproval',
193
198
  'productionFoundation',
199
+ 'publicDns',
194
200
  'schemaVersion',
201
+ 'site',
195
202
  'slices',
196
203
  'workspaceDeploymentId',
197
204
  'workspaceDeploymentProvenance',
@@ -387,6 +394,13 @@ function validateRepositoryOperatingPolicy(value) {
387
394
  }
388
395
  }
389
396
  }
397
+ issues.push(...(0, public_dns_js_1.validateRepositoryPublicDns)({
398
+ activeStages: isOneOf(value.deploymentProfile, exports.DEPLOYMENT_PROFILES)
399
+ ? activeDeploymentStages(value.deploymentProfile)
400
+ : [],
401
+ deploymentRegion: value.deploymentRegion,
402
+ value: value.publicDns,
403
+ }));
390
404
  if (!isOneOf(value.productionAccess, exports.PRODUCTION_ACCESS_VALUES)) {
391
405
  issues.push({
392
406
  message: `must equal ${exports.PRODUCTION_ACCESS_VALUES.join(' or ')}`,
@@ -423,6 +437,23 @@ function validateRepositoryOperatingPolicy(value) {
423
437
  });
424
438
  }
425
439
  }
440
+ if (value.site !== undefined) {
441
+ if (!(0, validation_js_1.isRecord)(value.site)) {
442
+ issues.push({
443
+ message: 'must be an object with an explicit productionStatus',
444
+ path: 'policy.site',
445
+ });
446
+ }
447
+ else {
448
+ rejectUnknownProperties(value.site, new Set(['productionStatus']), 'policy.site', issues);
449
+ if (!isOneOf(value.site.productionStatus, exports.ROOT_SITE_PRODUCTION_STATUSES)) {
450
+ issues.push({
451
+ message: `must equal ${exports.ROOT_SITE_PRODUCTION_STATUSES.join(' or ')}`,
452
+ path: 'policy.site.productionStatus',
453
+ });
454
+ }
455
+ }
456
+ }
426
457
  if (!(0, validation_js_1.isRecord)(value.slices)) {
427
458
  issues.push({ message: 'must be an object', path: 'policy.slices' });
428
459
  }
@@ -435,6 +466,12 @@ function validateRepositoryOperatingPolicy(value) {
435
466
  path,
436
467
  });
437
468
  }
469
+ if ((0, root_site_js_1.isReservedRootSiteName)(slice)) {
470
+ issues.push({
471
+ message: `is reserved for the workspace root site. ${root_site_js_1.ROOT_SITE_RENAME_GUIDANCE}`,
472
+ path,
473
+ });
474
+ }
438
475
  if (!(0, validation_js_1.isRecord)(entry)) {
439
476
  issues.push({ message: 'must be an object', path });
440
477
  continue;
@@ -651,6 +688,8 @@ function applyRepositoryPolicyChange(current, change) {
651
688
  for (const entry of Object.values(next.slices)) {
652
689
  entry.productionStatus = 'blocked';
653
690
  }
691
+ if (next.site)
692
+ next.site.productionStatus = 'blocked';
654
693
  }
655
694
  else if (change.preset === 'controlled-production') {
656
695
  next.productionAccess = 'controlled';
@@ -698,14 +737,23 @@ function applyRepositoryPolicyChange(current, change) {
698
737
  if (!SLICE_NAME_PATTERN.test(slice)) {
699
738
  throw new Error(`Product Slice name ${slice} must use lowercase letters, numbers, and hyphens.`);
700
739
  }
740
+ if ((0, root_site_js_1.isReservedRootSiteName)(slice)) {
741
+ throw new Error(root_site_js_1.ROOT_SITE_RESERVED_SLICE_NAME_MESSAGE);
742
+ }
701
743
  next.slices[slice] = { productionStatus };
702
744
  }
745
+ if (change.site !== undefined) {
746
+ next.site = { productionStatus: change.site };
747
+ }
703
748
  const result = validateRepositoryOperatingPolicy(next);
704
749
  if (!result.valid) {
705
750
  throw new Error(`Repository Operating Policy change is invalid:\n${formatRepositoryPolicyIssues(result.issues)}`);
706
751
  }
707
752
  return result.value;
708
753
  }
754
+ function rootSiteProductionStatus(policy) {
755
+ return policy.site?.productionStatus ?? 'blocked';
756
+ }
709
757
  function evaluateRepositoryPolicyRequest(policy, request) {
710
758
  const reasons = [];
711
759
  const projectNames = new Set();
@@ -736,6 +784,12 @@ function evaluateRepositoryPolicyRequest(policy, request) {
736
784
  const profile = policy.productionFoundation.profile;
737
785
  if (!recoveryAction) {
738
786
  for (const project of request.projects) {
787
+ if (project.kind === 'site') {
788
+ if (rootSiteProductionStatus(policy) === 'blocked') {
789
+ reasons.push('The root site is blocked for production deployment; set site.productionStatus to ready after review.');
790
+ }
791
+ continue;
792
+ }
739
793
  if (project.kind !== 'slice')
740
794
  continue;
741
795
  const status = policy.slices[project.name]?.productionStatus ?? 'blocked';
@@ -0,0 +1,65 @@
1
+ import { type ValidationIssue } from '../validation.js';
2
+ import type { CanonicalDeploymentStage, RepositoryOperatingPolicy } from './policy.js';
3
+ /**
4
+ * One reviewed public Route 53 hosted zone for one canonical stage. The stage
5
+ * deployment authority grants direct record writes only in this zone, and the
6
+ * generated Foundation passes the same zone to SST. Bindings exist only in the
7
+ * `aws` partition.
8
+ */
9
+ export interface PublicDnsBinding {
10
+ hostedZoneId: string;
11
+ rootDomain: string;
12
+ }
13
+ export type RepositoryPublicDns = Partial<Record<CanonicalDeploymentStage, PublicDnsBinding>>;
14
+ export type RouterPublicDomain = {
15
+ kind: 'cloudfront';
16
+ } | ({
17
+ kind: 'custom-domain';
18
+ } & PublicDnsBinding);
19
+ /** Route 53 hosted-zone IDs: `Z` plus at most 31 upper-case alphanumerics,
20
+ * without an ARN or `/hostedzone/` prefix. */
21
+ export declare const PUBLIC_DNS_HOSTED_ZONE_ID_PATTERN: RegExp;
22
+ /** Lower-case LDH names with bounded labels, no wildcard, trailing dot,
23
+ * scheme, or port. */
24
+ export declare const PUBLIC_DNS_ROOT_DOMAIN_PATTERN: RegExp;
25
+ export declare function validateRepositoryPublicDns(input: {
26
+ activeStages: readonly CanonicalDeploymentStage[];
27
+ deploymentRegion: unknown;
28
+ value: unknown;
29
+ }): ValidationIssue[];
30
+ /** The committed binding for one canonical stage, or undefined. */
31
+ export declare function repositoryPublicDnsForStage(policy: Pick<RepositoryOperatingPolicy, 'publicDns'>, stage: string): PublicDnsBinding | undefined;
32
+ /**
33
+ * Resolves the generated Foundation's public domain. The committed
34
+ * `publicDns.<stage>` binding is the only switch: with a binding the stage
35
+ * serves its `rootDomain`, whether or not `EBK_ROOT_DOMAIN` is set, so a
36
+ * stage deployed by the generated Deploy workflow (which never sets it) and a
37
+ * local redeploy with the variable unset both keep the domain. Without a
38
+ * binding the Router keeps its CloudFront URL. `EBK_ROOT_DOMAIN` is an
39
+ * optional cross-check: when set it must equal the binding's `rootDomain`,
40
+ * and setting it with no binding for the same canonical stage refuses. Both
41
+ * refusals happen before Foundation constructs any resource, because the
42
+ * stage authority grants record writes only in the bound zone.
43
+ */
44
+ export declare function resolveFoundationPublicDomain(input: {
45
+ configuredRootDomain: string | undefined;
46
+ policy: Pick<RepositoryOperatingPolicy, 'publicDns'>;
47
+ stage: string;
48
+ }): RouterPublicDomain;
49
+ /**
50
+ * Resolves the generated Foundation Router domain. Without `EBK_ROOT_DOMAIN`
51
+ * the Router keeps its CloudFront URL, even when a binding exists. With it,
52
+ * the committed binding for the same canonical stage must exist and match
53
+ * exactly; otherwise Foundation refuses before constructing any resource,
54
+ * because the stage authority grants record writes only in that zone.
55
+ *
56
+ * @deprecated Only a managed Foundation generated before the binding became
57
+ * the switch calls this. Installing new packages alone must not move such a
58
+ * stage to its custom domain before its Foundation upgrade is applied; the
59
+ * current generated Foundation calls {@link resolveFoundationPublicDomain}.
60
+ */
61
+ export declare function resolveRouterPublicDomain(input: {
62
+ configuredRootDomain: string | undefined;
63
+ policy: Pick<RepositoryOperatingPolicy, 'publicDns'>;
64
+ stage: string;
65
+ }): RouterPublicDomain;
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PUBLIC_DNS_ROOT_DOMAIN_PATTERN = exports.PUBLIC_DNS_HOSTED_ZONE_ID_PATTERN = void 0;
4
+ exports.validateRepositoryPublicDns = validateRepositoryPublicDns;
5
+ exports.repositoryPublicDnsForStage = repositoryPublicDnsForStage;
6
+ exports.resolveFoundationPublicDomain = resolveFoundationPublicDomain;
7
+ exports.resolveRouterPublicDomain = resolveRouterPublicDomain;
8
+ const validation_js_1 = require("../validation.js");
9
+ /** Route 53 hosted-zone IDs: `Z` plus at most 31 upper-case alphanumerics,
10
+ * without an ARN or `/hostedzone/` prefix. */
11
+ exports.PUBLIC_DNS_HOSTED_ZONE_ID_PATTERN = /^Z[A-Z0-9]{1,31}$/u;
12
+ /** Lower-case LDH names with bounded labels, no wildcard, trailing dot,
13
+ * scheme, or port. */
14
+ exports.PUBLIC_DNS_ROOT_DOMAIN_PATTERN = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/u;
15
+ const CANONICAL_STAGES = [
16
+ 'development',
17
+ 'staging',
18
+ 'production',
19
+ ];
20
+ const NON_COMMERCIAL_PARTITION_REGION = /^(?:cn|us-gov)-/u;
21
+ function validateRepositoryPublicDns(input) {
22
+ const { activeStages, value } = input;
23
+ if (value === undefined)
24
+ return [];
25
+ if (!(0, validation_js_1.isRecord)(value)) {
26
+ return [
27
+ {
28
+ message: 'must map canonical stages to { hostedZoneId, rootDomain } bindings',
29
+ path: 'policy.publicDns',
30
+ },
31
+ ];
32
+ }
33
+ const issues = [];
34
+ if (typeof input.deploymentRegion === 'string' &&
35
+ NON_COMMERCIAL_PARTITION_REGION.test(input.deploymentRegion)) {
36
+ issues.push({
37
+ message: 'is supported only in the aws partition; remove it for a China or GovCloud deployment Region',
38
+ path: 'policy.publicDns',
39
+ });
40
+ }
41
+ for (const key of Object.keys(value)) {
42
+ if (!activeStages.some((stage) => stage === key)) {
43
+ issues.push({
44
+ message: 'is not an active canonical stage; reconcile the retained DNS binding explicitly before changing the deployment profile',
45
+ path: `policy.publicDns.${key}`,
46
+ });
47
+ }
48
+ }
49
+ const zones = new Map();
50
+ const roots = new Map();
51
+ for (const stage of CANONICAL_STAGES) {
52
+ const binding = value[stage];
53
+ if (binding === undefined || !activeStages.includes(stage))
54
+ continue;
55
+ const path = `policy.publicDns.${stage}`;
56
+ if (!(0, validation_js_1.isRecord)(binding)) {
57
+ issues.push({
58
+ message: 'must contain hostedZoneId and rootDomain',
59
+ path,
60
+ });
61
+ continue;
62
+ }
63
+ for (const key of Object.keys(binding)) {
64
+ if (key !== 'hostedZoneId' && key !== 'rootDomain') {
65
+ issues.push({
66
+ message: 'is not an allowed property',
67
+ path: `${path}.${key}`,
68
+ });
69
+ }
70
+ }
71
+ const { hostedZoneId, rootDomain } = binding;
72
+ if (typeof hostedZoneId !== 'string' ||
73
+ !exports.PUBLIC_DNS_HOSTED_ZONE_ID_PATTERN.test(hostedZoneId)) {
74
+ issues.push({
75
+ message: 'must be one public Route 53 hosted-zone ID: Z followed by at most 31 upper-case letters or digits, without an ARN or /hostedzone/ prefix',
76
+ path: `${path}.hostedZoneId`,
77
+ });
78
+ }
79
+ else {
80
+ // Record writes are scoped by zone, not by name, so two stages sharing
81
+ // one zone could rewrite each other's records. Hosted-zone IDs are
82
+ // globally unique, so this also refuses a cross-account reuse.
83
+ const previous = zones.get(hostedZoneId);
84
+ if (previous) {
85
+ issues.push({
86
+ message: `reuses the hosted zone bound to policy.publicDns.${previous}; bind each stage to its own zone, for example a delegated subdomain zone`,
87
+ path: `${path}.hostedZoneId`,
88
+ });
89
+ }
90
+ zones.set(hostedZoneId, stage);
91
+ }
92
+ if (typeof rootDomain !== 'string' ||
93
+ !exports.PUBLIC_DNS_ROOT_DOMAIN_PATTERN.test(rootDomain)) {
94
+ issues.push({
95
+ message: 'must be a lower-case ASCII DNS name with bounded labels, without a wildcard, trailing dot, scheme, or port',
96
+ path: `${path}.rootDomain`,
97
+ });
98
+ }
99
+ else {
100
+ const previous = roots.get(rootDomain);
101
+ if (previous) {
102
+ issues.push({
103
+ message: `reuses the root domain of policy.publicDns.${previous}`,
104
+ path: `${path}.rootDomain`,
105
+ });
106
+ }
107
+ roots.set(rootDomain, stage);
108
+ }
109
+ }
110
+ return issues;
111
+ }
112
+ /** The committed binding for one canonical stage, or undefined. */
113
+ function repositoryPublicDnsForStage(policy, stage) {
114
+ const binding = CANONICAL_STAGES.includes(stage)
115
+ ? policy.publicDns?.[stage]
116
+ : undefined;
117
+ return binding
118
+ ? { hostedZoneId: binding.hostedZoneId, rootDomain: binding.rootDomain }
119
+ : undefined;
120
+ }
121
+ /**
122
+ * Resolves the generated Foundation's public domain. The committed
123
+ * `publicDns.<stage>` binding is the only switch: with a binding the stage
124
+ * serves its `rootDomain`, whether or not `EBK_ROOT_DOMAIN` is set, so a
125
+ * stage deployed by the generated Deploy workflow (which never sets it) and a
126
+ * local redeploy with the variable unset both keep the domain. Without a
127
+ * binding the Router keeps its CloudFront URL. `EBK_ROOT_DOMAIN` is an
128
+ * optional cross-check: when set it must equal the binding's `rootDomain`,
129
+ * and setting it with no binding for the same canonical stage refuses. Both
130
+ * refusals happen before Foundation constructs any resource, because the
131
+ * stage authority grants record writes only in the bound zone.
132
+ */
133
+ function resolveFoundationPublicDomain(input) {
134
+ const domain = input.configuredRootDomain?.trim();
135
+ const binding = repositoryPublicDnsForStage(input.policy, input.stage);
136
+ if (!domain) {
137
+ return binding
138
+ ? { kind: 'custom-domain', ...binding }
139
+ : { kind: 'cloudfront' };
140
+ }
141
+ return resolveRouterPublicDomain(input);
142
+ }
143
+ /**
144
+ * Resolves the generated Foundation Router domain. Without `EBK_ROOT_DOMAIN`
145
+ * the Router keeps its CloudFront URL, even when a binding exists. With it,
146
+ * the committed binding for the same canonical stage must exist and match
147
+ * exactly; otherwise Foundation refuses before constructing any resource,
148
+ * because the stage authority grants record writes only in that zone.
149
+ *
150
+ * @deprecated Only a managed Foundation generated before the binding became
151
+ * the switch calls this. Installing new packages alone must not move such a
152
+ * stage to its custom domain before its Foundation upgrade is applied; the
153
+ * current generated Foundation calls {@link resolveFoundationPublicDomain}.
154
+ */
155
+ function resolveRouterPublicDomain(input) {
156
+ const domain = input.configuredRootDomain?.trim();
157
+ if (!domain)
158
+ return { kind: 'cloudfront' };
159
+ const binding = repositoryPublicDnsForStage(input.policy, input.stage);
160
+ if (!binding) {
161
+ throw new Error(`EBK_ROOT_DOMAIN requires a committed publicDns.${input.stage} binding in ebk.repository-policy.json. Add { "hostedZoneId": "<public hosted-zone ID>", "rootDomain": "<root domain>" } for this stage, then re-render and re-apply the stage authority; or unset EBK_ROOT_DOMAIN to keep the CloudFront URL.`);
162
+ }
163
+ if (domain !== binding.rootDomain) {
164
+ throw new Error(`EBK_ROOT_DOMAIN must exactly match publicDns.${input.stage}.rootDomain in ebk.repository-policy.json.`);
165
+ }
166
+ return { kind: 'custom-domain', ...binding };
167
+ }
168
+ //# sourceMappingURL=public-dns.js.map
@@ -15,7 +15,13 @@
15
15
  "compositions": {
16
16
  "items": {
17
17
  "additionalProperties": false,
18
+ "dependentSchemas": {
19
+ "authentication": {
20
+ "properties": { "kind": { "const": "function" } }
21
+ }
22
+ },
18
23
  "properties": {
24
+ "authentication": { "const": "anonymous" },
19
25
  "feature": {
20
26
  "pattern": "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$",
21
27
  "type": "string"
@@ -2,6 +2,49 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://empirebuilderkit.dev/schemas/repository-policy-v1.json",
4
4
  "title": "Empire Builder Kit repository operating policy v1",
5
+ "$defs": {
6
+ "publicDnsBinding": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "required": ["hostedZoneId", "rootDomain"],
10
+ "properties": {
11
+ "hostedZoneId": {
12
+ "type": "string",
13
+ "pattern": "^Z[A-Z0-9]{1,31}$",
14
+ "description": "Public Route 53 hosted-zone ID without an ARN or /hostedzone/ prefix."
15
+ },
16
+ "rootDomain": {
17
+ "type": "string",
18
+ "pattern": "^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$",
19
+ "description": "Lower-case root domain the Foundation serves for this stage; EBK_ROOT_DOMAIN, if set, must match it exactly."
20
+ }
21
+ }
22
+ }
23
+ },
24
+ "allOf": [
25
+ {
26
+ "if": {
27
+ "required": ["deploymentProfile"],
28
+ "type": "object",
29
+ "properties": { "deploymentProfile": { "const": "starter" } }
30
+ },
31
+ "then": {
32
+ "properties": {
33
+ "publicDns": { "type": "object", "properties": { "staging": false } }
34
+ }
35
+ }
36
+ },
37
+ {
38
+ "if": {
39
+ "type": "object",
40
+ "required": ["deploymentRegion"],
41
+ "properties": {
42
+ "deploymentRegion": { "type": "string", "pattern": "^(cn|us-gov)-" }
43
+ }
44
+ },
45
+ "then": { "not": { "required": ["publicDns"] } }
46
+ }
47
+ ],
5
48
  "type": "object",
6
49
  "additionalProperties": false,
7
50
  "required": [
@@ -110,10 +153,23 @@
110
153
  }
111
154
  }
112
155
  },
156
+ "site": {
157
+ "type": "object",
158
+ "additionalProperties": false,
159
+ "required": ["productionStatus"],
160
+ "properties": {
161
+ "productionStatus": {
162
+ "type": "string",
163
+ "enum": ["blocked", "ready"]
164
+ }
165
+ },
166
+ "description": "Optional production posture of the workspace root site at the Router's /. Absent means blocked."
167
+ },
113
168
  "slices": {
114
169
  "type": "object",
115
170
  "propertyNames": {
116
- "pattern": "^[a-z0-9][a-z0-9-]*$"
171
+ "pattern": "^[a-z0-9][a-z0-9-]*$",
172
+ "not": { "const": "site" }
117
173
  },
118
174
  "additionalProperties": {
119
175
  "type": "object",
@@ -127,6 +183,16 @@
127
183
  }
128
184
  }
129
185
  },
186
+ "publicDns": {
187
+ "type": "object",
188
+ "additionalProperties": false,
189
+ "properties": {
190
+ "development": { "$ref": "#/$defs/publicDnsBinding" },
191
+ "staging": { "$ref": "#/$defs/publicDnsBinding" },
192
+ "production": { "$ref": "#/$defs/publicDnsBinding" }
193
+ },
194
+ "description": "Optional per-stage public Route 53 binding for a custom Router domain, aws partition only. The stage deployment authority grants A, AAAA and CNAME record writes only in this hosted zone, and the binding alone makes Foundation serve rootDomain; EBK_ROOT_DOMAIN, if set, must equal it. Bind each stage to its own zone."
195
+ },
130
196
  "workspaceDeploymentId": {
131
197
  "type": "string",
132
198
  "pattern": "^ebkws-[a-f0-9]{32}$",
@@ -20,6 +20,8 @@ const validation_js_1 = require("../validation.js");
20
20
  const foundation_record_js_1 = require("../ownership/foundation-record.js");
21
21
  const record_js_1 = require("../ownership/record.js");
22
22
  const workspace_record_js_1 = require("../ownership/workspace-record.js");
23
+ const site_record_js_1 = require("../ownership/site-record.js");
24
+ const root_site_js_1 = require("../foundation/root-site.js");
23
25
  const blueprint_verification_authority_js_1 = require("./blueprint-verification-authority.js");
24
26
  const blueprint_trust_js_1 = require("./blueprint-trust.js");
25
27
  const errors_js_1 = require("./errors.js");
@@ -424,6 +426,16 @@ function historicalOwnershipRecord(commit, path, value) {
424
426
  }
425
427
  return [];
426
428
  }
429
+ // The root site has no Blueprint. Its record is valid only at packages/site.
430
+ // History keeps any Slice record as it was committed, so a workspace
431
+ // that renamed a Slice named site before the reservation still verifies.
432
+ if ((0, site_record_js_1.isSiteOwnershipRecord)(value)) {
433
+ if (path !== site_record_js_1.SITE_OWNERSHIP_PATH ||
434
+ !(0, site_record_js_1.validateSiteOwnershipRecord)(value).valid) {
435
+ throw new errors_js_1.SupplyChainError('supply-chain-blueprint-untrusted', `${commit}:${path}`, 'historical root site ownership is malformed or outside packages/site');
436
+ }
437
+ return [];
438
+ }
427
439
  const validation = (0, record_js_1.validateGeneratedOwnershipRecord)(value);
428
440
  const slice = path.split('/')[1];
429
441
  if (!validation.valid || validation.value.slice !== slice) {
@@ -1343,6 +1355,18 @@ function executionSnapshotOwnedPaths(workspaceRoot) {
1343
1355
  addOwnedPaths(prefix, foundation.value.paths);
1344
1356
  continue;
1345
1357
  }
1358
+ // packages/site holds only the root site, and its record belongs only
1359
+ // there.
1360
+ if (entry.name === root_site_js_1.ROOT_SITE_NAME || (0, site_record_js_1.isSiteOwnershipRecord)(value)) {
1361
+ const site = (0, site_record_js_1.validateSiteOwnershipRecord)(value);
1362
+ if (entry.name !== root_site_js_1.ROOT_SITE_NAME || !site.valid) {
1363
+ throw new errors_js_1.SupplyChainError('supply-chain-blueprint-untrusted', ownershipPath, entry.name === root_site_js_1.ROOT_SITE_NAME
1364
+ ? 'workspace execution snapshot requires valid root site ownership at packages/site, which is reserved for the workspace root site'
1365
+ : 'workspace execution snapshot refuses root site ownership outside packages/site');
1366
+ }
1367
+ addOwnedPaths(prefix, site.value.paths);
1368
+ continue;
1369
+ }
1346
1370
  const generated = (0, record_js_1.validateGeneratedOwnershipRecord)(value);
1347
1371
  if (!generated.valid || generated.value.slice !== entry.name) {
1348
1372
  throw new errors_js_1.SupplyChainError('supply-chain-blueprint-untrusted', ownershipPath, 'workspace execution snapshot requires valid unambiguous Slice ownership');
@@ -15,6 +15,8 @@ const yaml_1 = require("yaml");
15
15
  const resolver_js_1 = require("../blueprints/resolver.js");
16
16
  const foundation_record_js_1 = require("../ownership/foundation-record.js");
17
17
  const record_js_1 = require("../ownership/record.js");
18
+ const site_record_js_1 = require("../ownership/site-record.js");
19
+ const root_site_js_1 = require("../foundation/root-site.js");
18
20
  const pnpm_toolchain_authority_js_1 = require("./pnpm-toolchain-authority.js");
19
21
  exports.BLUEPRINT_VERIFICATION_VITEST_CONFIG_SOURCE = 'export default {};\n';
20
22
  const MAX_CONFIGURATION_BYTES = 5 * 1024 * 1024;
@@ -447,12 +449,18 @@ function isNativeArtifactDependencyBoundary(workspaceRoot, path, candidate) {
447
449
  const dependencyRoot = (0, node_path_1.join)(workspaceRoot, 'packages', slice, 'node_modules');
448
450
  try {
449
451
  const metadata = (0, node_fs_1.lstatSync)(dependencyRoot);
452
+ const target = (0, node_fs_1.readlinkSync)(candidate);
453
+ // Compare the literal link text, not a lexically resolved form: `resolve`
454
+ // and the JavaScript `realpathSync` collapse `..` without following the
455
+ // link before it, so `<link>/..` could name the dependency root while the
456
+ // kernel resolves elsewhere. Only the exact absolute or exact relative
457
+ // spelling is a boundary, and the native realpath must agree physically.
450
458
  return (metadata.isDirectory() &&
451
459
  !metadata.isSymbolicLink() &&
452
460
  (0, node_fs_1.realpathSync)(dependencyRoot) === dependencyRoot &&
453
- (0, node_path_1.toNamespacedPath)((0, node_path_1.resolve)((0, node_path_1.dirname)(candidate), (0, node_fs_1.readlinkSync)(candidate))) ===
454
- (0, node_path_1.toNamespacedPath)(dependencyRoot) &&
455
- (0, node_fs_1.realpathSync)(candidate) === dependencyRoot);
461
+ ((0, node_path_1.toNamespacedPath)(target) === (0, node_path_1.toNamespacedPath)(dependencyRoot) ||
462
+ target === (0, node_path_1.relative)((0, node_path_1.dirname)(candidate), dependencyRoot)) &&
463
+ node_fs_1.realpathSync.native(candidate) === node_fs_1.realpathSync.native(dependencyRoot));
456
464
  }
457
465
  catch {
458
466
  return false;
@@ -611,6 +619,16 @@ function externalBlueprintOwnershipRoots(workspace) {
611
619
  continue;
612
620
  throw new Error('Developer-Agent Blueprint ownership preflight found malformed Foundation ownership.');
613
621
  }
622
+ // The root site has no Blueprint; packages/site holds only its record.
623
+ if (entry.name === root_site_js_1.ROOT_SITE_NAME || (0, site_record_js_1.isSiteOwnershipRecord)(value)) {
624
+ if (entry.name === root_site_js_1.ROOT_SITE_NAME &&
625
+ (0, site_record_js_1.validateSiteOwnershipRecord)(value).valid) {
626
+ continue;
627
+ }
628
+ throw new Error(entry.name === root_site_js_1.ROOT_SITE_NAME
629
+ ? 'Developer-Agent Blueprint ownership preflight requires valid root site ownership at packages/site, which is reserved for the workspace root site.'
630
+ : `Developer-Agent Blueprint ownership preflight found root site ownership outside packages/site, for ${entry.name}.`);
631
+ }
614
632
  const generated = (0, record_js_1.validateGeneratedOwnershipRecord)(value);
615
633
  if (!generated.valid || generated.value.slice !== entry.name) {
616
634
  throw new Error(`Developer-Agent Blueprint ownership preflight found malformed or ambiguous ownership for ${entry.name}.`);
@@ -39,6 +39,7 @@ import {
39
39
  hashGeneratedContent,
40
40
  hashOwnedContent,
41
41
  validateFoundationOwnershipRecord,
42
+ validateSiteOwnershipRecord,
42
43
  } from '@empire-builder-kit/nx/ownership';
43
44
  import { createHash, randomBytes } from 'node:crypto';
44
45
  import {
@@ -289,6 +290,20 @@ function ownershipInventory() {
289
290
  }
290
291
  continue;
291
292
  }
293
+ // The root site has no Blueprint. packages/site holds only its record,
294
+ // and its record belongs only there.
295
+ if (entry.name === 'site' || value?.kind === 'site') {
296
+ const site = validateSiteOwnershipRecord(value);
297
+ if (entry.name !== 'site' || !site.valid) {
298
+ throw new Error(
299
+ ownershipPath +
300
+ (entry.name === 'site'
301
+ ? ' must be valid root site ownership; packages/site is reserved for the workspace root site.'
302
+ : ' is root site ownership outside packages/site.'),
303
+ );
304
+ }
305
+ continue;
306
+ }
292
307
  ownership.push({ path: ownershipPath, value });
293
308
  if (ownership.length > MAX_SLICE_COUNT) {
294
309
  throw new Error('Generated Slice ownership exceeds 1,000 records.');
@@ -147,6 +147,9 @@ function ownershipValidation(value) {
147
147
  if (record.kind === 'foundation') {
148
148
  return (0, index_js_1.validateFoundationOwnershipRecord)(value);
149
149
  }
150
+ if (record.kind === 'site') {
151
+ return (0, index_js_1.validateSiteOwnershipRecord)(value);
152
+ }
150
153
  if ('slice' in record || 'blueprint' in record) {
151
154
  return (0, index_js_1.validateGeneratedOwnershipRecord)(value);
152
155
  }
@@ -154,7 +157,7 @@ function ownershipValidation(value) {
154
157
  return {
155
158
  issues: [
156
159
  {
157
- message: 'must identify a workspace, Foundation, or Product Slice',
160
+ message: 'must identify a workspace, Foundation, root site or Product Slice',
158
161
  path: 'ownership',
159
162
  },
160
163
  ],
@@ -54,6 +54,21 @@ export type WorkspaceStageOwnershipInspection = {
54
54
  stage: CanonicalDeploymentStage;
55
55
  status: 'conflict';
56
56
  };
57
+ /**
58
+ * The refusal `assertWorkspaceStageOwnership` throws for a tuple this
59
+ * workspace does not own. `status` and `reason` carry the inspection's
60
+ * outcome, so a caller classifies the refusal without reading its message.
61
+ */
62
+ export declare class WorkspaceStageOwnershipError extends Error {
63
+ readonly status: 'conflict' | 'unclaimed';
64
+ readonly reason?: Extract<WorkspaceStageOwnershipInspection, {
65
+ status: 'conflict';
66
+ }>['reason'];
67
+ readonly name = "WorkspaceStageOwnershipError";
68
+ constructor(message: string, status: 'conflict' | 'unclaimed', reason?: Extract<WorkspaceStageOwnershipInspection, {
69
+ status: 'conflict';
70
+ }>['reason']);
71
+ }
57
72
  export interface WorkspaceStageOwnershipInspectionOptions {
58
73
  client?: Pick<SSMClient, 'send'>;
59
74
  clientFactory?: (configuration: SSMClientConfig) => Pick<SSMClient, 'send'>;