@empire-builder-kit/nx 1.0.0-rc.45 → 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 (187) 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 +109 -9
  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 +44 -3
  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/github-bootstrap/github-bootstrap.d.ts +3 -0
  22. package/src/executors/github-bootstrap/github-bootstrap.js +28 -0
  23. package/src/executors/github-bootstrap/schema.json +14 -0
  24. package/src/executors/infrastructure-plan/infrastructure-plan.js +10 -3
  25. package/src/executors/local-deploy/local-deploy.d.ts +15 -0
  26. package/src/executors/local-deploy/local-deploy.js +96 -14
  27. package/src/executors/sst-lifecycle/logging-preflight.js +12 -1
  28. package/src/executors/sst-lifecycle/run-sst-command.js +51 -5
  29. package/src/foundation/cost-estimate.js +1 -1
  30. package/src/foundation/identity-domain-parent-ready.d.ts +91 -0
  31. package/src/foundation/identity-domain-parent-ready.js +333 -0
  32. package/src/foundation/identity-domain.d.ts +94 -0
  33. package/src/foundation/identity-domain.js +115 -0
  34. package/src/foundation/index.d.ts +2 -0
  35. package/src/foundation/index.js +7 -0
  36. package/src/foundation/preflight.js +17 -1
  37. package/src/foundation/root-site-readiness.d.ts +27 -0
  38. package/src/foundation/root-site-readiness.js +78 -0
  39. package/src/foundation/root-site.d.ts +81 -0
  40. package/src/foundation/root-site.js +268 -0
  41. package/src/generators/framework-prerequisites.d.ts +2 -0
  42. package/src/generators/framework-prerequisites.js +34 -0
  43. package/src/generators/function/function-registration.d.ts +24 -0
  44. package/src/generators/function/function-registration.js +66 -0
  45. package/src/generators/function/function.d.ts +16 -1
  46. package/src/generators/function/function.js +101 -18
  47. package/src/generators/function/schema.d.ts +1 -0
  48. package/src/generators/function/schema.json +6 -0
  49. package/src/generators/function-access/function-access.d.ts +14 -0
  50. package/src/generators/function-access/function-access.js +141 -0
  51. package/src/generators/function-access/schema.d.ts +6 -0
  52. package/src/generators/function-access/schema.json +25 -0
  53. package/src/generators/post-generation-install.d.ts +1 -1
  54. package/src/generators/post-generation-install.js +1 -1
  55. package/src/generators/preset/dependency-overrides.d.ts +1 -1
  56. package/src/generators/preset/dependency-overrides.js +1 -1
  57. package/src/generators/preset/workspace-files-adopter-skills.js +14 -0
  58. package/src/generators/preset/workspace-files-developer-agent.js +17 -11
  59. package/src/generators/preset/workspace-files-stage-authority.js +58 -1
  60. package/src/generators/preset/workspace-files-thin-deploy.d.ts +11 -0
  61. package/src/generators/preset/workspace-files-thin-deploy.js +52 -5
  62. package/src/generators/preset/workspace-files-thin-docs.js +33 -5
  63. package/src/generators/preset/workspace-files.js +238 -41
  64. package/src/generators/repository-policy/repository-policy.js +2 -1
  65. package/src/generators/repository-policy/schema.d.ts +2 -0
  66. package/src/generators/repository-policy/schema.json +7 -2
  67. package/src/generators/site/built-in-site-documentation-files.d.ts +2 -0
  68. package/src/generators/site/built-in-site-documentation-files.js +92 -0
  69. package/src/generators/site/built-in-site-files.d.ts +8 -0
  70. package/src/generators/site/built-in-site-files.js +40 -0
  71. package/src/generators/site/built-in-site-infrastructure-files.d.ts +2 -0
  72. package/src/generators/site/built-in-site-infrastructure-files.js +275 -0
  73. package/src/generators/site/built-in-site-plan.d.ts +19 -0
  74. package/src/generators/site/built-in-site-plan.js +65 -0
  75. package/src/generators/site/built-in-site-project-files.d.ts +3 -0
  76. package/src/generators/site/built-in-site-project-files.js +258 -0
  77. package/src/generators/site/built-in-site-script-files.d.ts +2 -0
  78. package/src/generators/site/built-in-site-script-files.js +306 -0
  79. package/src/generators/site/built-in-site-shared.d.ts +9 -0
  80. package/src/generators/site/built-in-site-shared.js +21 -0
  81. package/src/generators/site/built-in-site-smoke-files.d.ts +2 -0
  82. package/src/generators/site/built-in-site-smoke-files.js +37 -0
  83. package/src/generators/site/built-in-site-sst-config-files.d.ts +2 -0
  84. package/src/generators/site/built-in-site-sst-config-files.js +39 -0
  85. package/src/generators/site/built-in-site-web-files.d.ts +2 -0
  86. package/src/generators/site/built-in-site-web-files.js +284 -0
  87. package/src/generators/site/schema.d.ts +4 -0
  88. package/src/generators/site/schema.json +20 -0
  89. package/src/generators/site/site.d.ts +13 -0
  90. package/src/generators/site/site.js +221 -0
  91. package/src/generators/slice/built-in-plan-alarm-identity.d.ts +9 -0
  92. package/src/generators/slice/built-in-plan-alarm-identity.js +8 -1
  93. package/src/generators/slice/built-in-plan-api-contract-files.js +18 -0
  94. package/src/generators/slice/built-in-plan-async-work-files.js +18 -0
  95. package/src/generators/slice/built-in-plan-data-files.js +126 -14
  96. package/src/generators/slice/built-in-plan-foundation-files.d.ts +12 -0
  97. package/src/generators/slice/built-in-plan-foundation-files.js +114 -5
  98. package/src/generators/slice/built-in-plan-frontend-files.js +2 -271
  99. package/src/generators/slice/built-in-plan-frontend-header-proof.d.ts +6 -0
  100. package/src/generators/slice/built-in-plan-frontend-header-proof.js +282 -0
  101. package/src/generators/slice/built-in-plan-infrastructure-files.js +151 -237
  102. package/src/generators/slice/built-in-plan-key-value-cleanup.js +4 -3
  103. package/src/generators/slice/built-in-plan-log-group-helpers.d.ts +29 -0
  104. package/src/generators/slice/built-in-plan-log-group-helpers.js +130 -0
  105. package/src/generators/slice/built-in-plan-metadata-files.js +25 -5
  106. package/src/generators/slice/built-in-plan-next-build-authority.d.ts +5 -0
  107. package/src/generators/slice/built-in-plan-next-build-authority.js +124 -0
  108. package/src/generators/slice/built-in-plan-operations-files.d.ts +6 -0
  109. package/src/generators/slice/built-in-plan-operations-files.js +107 -219
  110. package/src/generators/slice/built-in-plan-performance-files.js +6 -1
  111. package/src/generators/slice/built-in-plan-release-files.js +0 -1
  112. package/src/generators/slice/built-in-plan-reliability-files.js +12 -8
  113. package/src/generators/slice/built-in-plan-shared.d.ts +1 -1
  114. package/src/generators/slice/built-in-plan-shared.js +1 -1
  115. package/src/generators/slice/built-in-plan-sst-config.d.ts +49 -0
  116. package/src/generators/slice/built-in-plan-sst-config.js +160 -0
  117. package/src/generators/slice/built-in-plan-testing-files.js +92 -49
  118. package/src/generators/slice/built-in-plan-verification-files.js +15 -5
  119. package/src/generators/slice/built-in-plan-web-files.js +69 -5
  120. package/src/generators/slice/built-in-plan.js +1 -2
  121. package/src/generators/slice/deployed-smoke-diagnostics.d.ts +35 -0
  122. package/src/generators/slice/deployed-smoke-diagnostics.js +189 -0
  123. package/src/generators/slice/deployed-smoke-readiness.d.ts +7 -0
  124. package/src/generators/slice/deployed-smoke-readiness.js +118 -23
  125. package/src/generators/slice/persistence-contract.js +2 -2
  126. package/src/generators/slice/pnpm-launch-script.d.ts +13 -0
  127. package/src/generators/slice/pnpm-launch-script.js +28 -0
  128. package/src/generators/slice/slice.js +27 -0
  129. package/src/generators/upgrade/custom-domain-notice.d.ts +19 -0
  130. package/src/generators/upgrade/custom-domain-notice.js +38 -0
  131. package/src/generators/upgrade/external-blueprint-compositions.d.ts +84 -0
  132. package/src/generators/upgrade/external-blueprint-compositions.js +478 -0
  133. package/src/generators/upgrade/framework-package-upgrade.d.ts +58 -0
  134. package/src/generators/upgrade/framework-package-upgrade.js +78 -0
  135. package/src/generators/upgrade/function-authentication-notice.d.ts +29 -0
  136. package/src/generators/upgrade/function-authentication-notice.js +74 -0
  137. package/src/generators/upgrade/schema.json +2 -2
  138. package/src/generators/upgrade/upgrade-plan.d.ts +52 -0
  139. package/src/generators/upgrade/upgrade-plan.js +406 -0
  140. package/src/generators/upgrade/upgrade.d.ts +1 -35
  141. package/src/generators/upgrade/upgrade.js +347 -595
  142. package/src/generators/workload/reliability-registration.d.ts +1 -1
  143. package/src/generators/workload/reliability-registration.js +9 -9
  144. package/src/generators/workload/workload.d.ts +1 -1
  145. package/src/generators/workload/workload.js +87 -13
  146. package/src/git-policy/github-bootstrap.d.ts +24 -5
  147. package/src/git-policy/github-bootstrap.js +105 -10
  148. package/src/local-dev/fleet-process.d.ts +9 -2
  149. package/src/local-dev/fleet-process.js +27 -7
  150. package/src/local-dev/fleet-session.js +41 -4
  151. package/src/local-dev/fleet-supervisor-daemon.js +1 -5
  152. package/src/local-dev/fleet-supervisor.d.ts +1 -0
  153. package/src/local-dev/fleet-supervisor.js +34 -11
  154. package/src/local-dev/gateway-daemon.d.ts +1 -1
  155. package/src/local-dev/gateway-daemon.js +6 -4
  156. package/src/local-dev/portless.d.ts +5 -0
  157. package/src/local-dev/portless.js +5 -0
  158. package/src/local-dev/process-group.d.ts +10 -0
  159. package/src/local-dev/process-group.js +33 -0
  160. package/src/local-dev/tls.js +31 -2
  161. package/src/local-dev/trust-store.d.ts +42 -0
  162. package/src/local-dev/trust-store.js +87 -0
  163. package/src/ownership/composition.d.ts +7 -0
  164. package/src/ownership/composition.js +64 -56
  165. package/src/ownership/index.d.ts +1 -0
  166. package/src/ownership/index.js +1 -0
  167. package/src/ownership/record.d.ts +19 -0
  168. package/src/ownership/record.js +26 -2
  169. package/src/ownership/site-record.d.ts +18 -0
  170. package/src/ownership/site-record.js +105 -0
  171. package/src/repository-policy/deployment-plan.d.ts +3 -0
  172. package/src/repository-policy/deployment-plan.js +33 -4
  173. package/src/repository-policy/index.d.ts +1 -0
  174. package/src/repository-policy/index.js +1 -0
  175. package/src/repository-policy/policy.d.ts +13 -1
  176. package/src/repository-policy/policy.js +55 -1
  177. package/src/repository-policy/public-dns.d.ts +65 -0
  178. package/src/repository-policy/public-dns.js +168 -0
  179. package/src/schemas/generated-ownership-v2.json +6 -0
  180. package/src/schemas/repository-policy-v1.json +67 -1
  181. package/src/supply-chain/blueprint-trust-git.js +24 -0
  182. package/src/supply-chain/blueprint-verification-authority.js +42 -3
  183. package/src/supply-chain/generated-blueprint-trust-command.js +15 -0
  184. package/src/supply-chain/sbom.js +74 -12
  185. package/src/work-markers/work-markers.js +4 -1
  186. package/src/workspace-deployment/ownership.d.ts +15 -0
  187. package/src/workspace-deployment/ownership.js +19 -3
@@ -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;
@@ -439,6 +441,31 @@ function isBlueprintVerificationExecutionAuthorityPath(path) {
439
441
  /^(?:vite|vitest)\.config\.[a-z0-9]+$/u.test(name) ||
440
442
  /^packages\/[^/]+\/\.ebk\/ownership\.json$/u.test(normalized));
441
443
  }
444
+ function isNativeArtifactDependencyBoundary(workspaceRoot, path, candidate) {
445
+ const match = /^packages\/([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\/\.sst\/artifacts\/[^/]+\/node_modules$/u.exec(path);
446
+ const slice = match?.[1];
447
+ if (!slice)
448
+ return false;
449
+ const dependencyRoot = (0, node_path_1.join)(workspaceRoot, 'packages', slice, 'node_modules');
450
+ try {
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.
458
+ return (metadata.isDirectory() &&
459
+ !metadata.isSymbolicLink() &&
460
+ (0, node_fs_1.realpathSync)(dependencyRoot) === 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));
464
+ }
465
+ catch {
466
+ return false;
467
+ }
468
+ }
442
469
  /**
443
470
  * Inventories every execution-loader configuration outside bounded generated,
444
471
  * dependency, cache, and evidence directories. Forbidden ambient config is
@@ -467,15 +494,17 @@ function assertNoMutableBlueprintVerificationConfiguration(workspace) {
467
494
  const path = directoryPath
468
495
  ? `${directoryPath}/${entry.name}`
469
496
  : entry.name;
470
- const skippedDirectory = entry.isDirectory() &&
471
- SKIPPED_CONFIGURATION_DIRECTORIES.has(entry.name.toLowerCase());
497
+ const candidate = (0, node_path_1.join)(directory, entry.name);
498
+ const skippedDirectory = (entry.isDirectory() &&
499
+ SKIPPED_CONFIGURATION_DIRECTORIES.has(entry.name.toLowerCase())) ||
500
+ (entry.isSymbolicLink() &&
501
+ isNativeArtifactDependencyBoundary(workspaceRoot, path, candidate));
472
502
  if (entry.isSymbolicLink() && !skippedDirectory) {
473
503
  throw new Error(`Blueprint verification configuration inventory refuses symbolic-link authority at ${path}.`);
474
504
  }
475
505
  if (forbiddenConfigurationName(entry.name)) {
476
506
  throw new Error(`Blueprint verification refuses mutable environment or package-manager configuration at ${path}.`);
477
507
  }
478
- const candidate = (0, node_path_1.join)(directory, entry.name);
479
508
  if (protectedConfigurationName(entry.name)) {
480
509
  const metadata = (0, node_fs_1.lstatSync)(candidate);
481
510
  const child = (0, node_path_1.relative)(workspaceRoot, candidate);
@@ -590,6 +619,16 @@ function externalBlueprintOwnershipRoots(workspace) {
590
619
  continue;
591
620
  throw new Error('Developer-Agent Blueprint ownership preflight found malformed Foundation ownership.');
592
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
+ }
593
632
  const generated = (0, record_js_1.validateGeneratedOwnershipRecord)(value);
594
633
  if (!generated.valid || generated.value.slice !== entry.name) {
595
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.');
@@ -160,7 +160,8 @@ function createCycloneDxComponentsFromInventory(input) {
160
160
  }));
161
161
  }
162
162
  function canonicalTimestamp(value, path) {
163
- if (!Number.isFinite(Date.parse(value)) ||
163
+ if (typeof value !== 'string' ||
164
+ !Number.isFinite(Date.parse(value)) ||
164
165
  new Date(value).toISOString() !== value) {
165
166
  throw new errors_js_1.SupplyChainError('supply-chain-input-invalid', path, 'must be a canonical ISO-8601 timestamp');
166
167
  }
@@ -775,8 +776,11 @@ function bindingInput(value) {
775
776
  }
776
777
  function createSupplyChainReleaseBinding(input) {
777
778
  canonicalTimestamp(input.createdAt, 'createdAt');
778
- if (!common_js_1.SUPPLY_CHAIN_REFERENCE.test(input.releaseId) ||
779
- !common_js_1.SUPPLY_CHAIN_SHA256.test(input.releaseManifestDigest) ||
779
+ if (typeof input.releaseId !== 'string' ||
780
+ common_js_1.SUPPLY_CHAIN_REFERENCE.exec(input.releaseId)?.[0] !== input.releaseId ||
781
+ typeof input.releaseManifestDigest !== 'string' ||
782
+ common_js_1.SUPPLY_CHAIN_SHA256.exec(input.releaseManifestDigest)?.[0] !==
783
+ input.releaseManifestDigest ||
780
784
  input.artifacts.length === 0 ||
781
785
  (0, common_js_1.hasSensitiveSupplyChainShape)(input)) {
782
786
  throw new errors_js_1.SupplyChainError('supply-chain-input-invalid', 'releaseBinding', 'must bind at least one artifact to an exact release manifest');
@@ -785,11 +789,21 @@ function createSupplyChainReleaseBinding(input) {
785
789
  const artifacts = [...input.artifacts]
786
790
  .sort((left, right) => (0, deterministic_order_js_1.compareUtf16)(left.bindingId, right.bindingId))
787
791
  .map((artifact, index) => {
788
- if (!common_js_1.SUPPLY_CHAIN_REFERENCE.test(artifact.bindingId) ||
789
- !common_js_1.SUPPLY_CHAIN_SHA256.test(artifact.candidateDigest) ||
790
- !common_js_1.SUPPLY_CHAIN_SHA256.test(artifact.contentDigest) ||
791
- !common_js_1.SUPPLY_CHAIN_SHA256.test(artifact.sbomDigest) ||
792
- !/^urn:uuid:[a-f0-9-]{36}$/.test(artifact.sbomSerialNumber) ||
792
+ if (typeof artifact.bindingId !== 'string' ||
793
+ common_js_1.SUPPLY_CHAIN_REFERENCE.exec(artifact.bindingId)?.[0] !==
794
+ artifact.bindingId ||
795
+ typeof artifact.candidateDigest !== 'string' ||
796
+ common_js_1.SUPPLY_CHAIN_SHA256.exec(artifact.candidateDigest)?.[0] !==
797
+ artifact.candidateDigest ||
798
+ typeof artifact.contentDigest !== 'string' ||
799
+ common_js_1.SUPPLY_CHAIN_SHA256.exec(artifact.contentDigest)?.[0] !==
800
+ artifact.contentDigest ||
801
+ typeof artifact.sbomDigest !== 'string' ||
802
+ common_js_1.SUPPLY_CHAIN_SHA256.exec(artifact.sbomDigest)?.[0] !==
803
+ artifact.sbomDigest ||
804
+ typeof artifact.sbomSerialNumber !== 'string' ||
805
+ /^urn:uuid:[a-f0-9-]{36}$/.exec(artifact.sbomSerialNumber)?.[0] !==
806
+ artifact.sbomSerialNumber ||
793
807
  seen.has(artifact.bindingId)) {
794
808
  throw new errors_js_1.SupplyChainError('supply-chain-input-invalid', `releaseBinding.artifacts[${index}]`, 'must uniquely bind artifact and SBOM digests');
795
809
  }
@@ -810,14 +824,62 @@ function createSupplyChainReleaseBinding(input) {
810
824
  };
811
825
  }
812
826
  function validateSupplyChainReleaseBinding(value, expected) {
827
+ const exactKeys = (record, keys) => [Object.prototype, null].includes(Object.getPrototypeOf(record)) &&
828
+ Object.keys(record).sort(deterministic_order_js_1.compareUtf16).join('\0') ===
829
+ [...keys].sort(deterministic_order_js_1.compareUtf16).join('\0');
813
830
  if (!(0, validation_js_1.isRecord)(value) ||
831
+ !exactKeys(value, [
832
+ 'artifacts',
833
+ 'createdAt',
834
+ 'kind',
835
+ 'materialDigest',
836
+ 'releaseId',
837
+ 'releaseManifestDigest',
838
+ 'schemaVersion',
839
+ ]) ||
814
840
  value.kind !== exports.SUPPLY_CHAIN_RELEASE_BINDING_KIND ||
815
841
  value.schemaVersion !== exports.SUPPLY_CHAIN_SBOM_SCHEMA_VERSION ||
816
- !common_js_1.SUPPLY_CHAIN_SHA256.test(String(value.materialDigest)) ||
817
- !Array.isArray(value.artifacts)) {
818
- throw new errors_js_1.SupplyChainError('supply-chain-input-invalid', 'releaseBinding', 'must be an EBK supply-chain release binding v1');
842
+ typeof value.materialDigest !== 'string' ||
843
+ common_js_1.SUPPLY_CHAIN_SHA256.exec(value.materialDigest)?.[0] !==
844
+ value.materialDigest ||
845
+ typeof value.createdAt !== 'string' ||
846
+ typeof value.releaseId !== 'string' ||
847
+ typeof value.releaseManifestDigest !== 'string' ||
848
+ !Array.isArray(value.artifacts) ||
849
+ !value.artifacts.length) {
850
+ throw new errors_js_1.SupplyChainError('supply-chain-input-invalid', 'releaseBinding', 'must be an exact EBK supply-chain release binding v1');
851
+ }
852
+ const artifacts = [];
853
+ for (const artifact of value.artifacts) {
854
+ if (!(0, validation_js_1.isRecord)(artifact) ||
855
+ !exactKeys(artifact, [
856
+ 'bindingId',
857
+ 'candidateDigest',
858
+ 'contentDigest',
859
+ 'sbomDigest',
860
+ 'sbomSerialNumber',
861
+ ]) ||
862
+ typeof artifact.bindingId !== 'string' ||
863
+ typeof artifact.candidateDigest !== 'string' ||
864
+ typeof artifact.contentDigest !== 'string' ||
865
+ typeof artifact.sbomDigest !== 'string' ||
866
+ typeof artifact.sbomSerialNumber !== 'string') {
867
+ throw new errors_js_1.SupplyChainError('supply-chain-input-invalid', 'releaseBinding.artifacts', 'must contain exact string artifact fields');
868
+ }
869
+ artifacts.push({
870
+ bindingId: artifact.bindingId,
871
+ candidateDigest: artifact.candidateDigest,
872
+ contentDigest: artifact.contentDigest,
873
+ sbomDigest: artifact.sbomDigest,
874
+ sbomSerialNumber: artifact.sbomSerialNumber,
875
+ });
819
876
  }
820
- const recreated = createSupplyChainReleaseBinding(value);
877
+ const recreated = createSupplyChainReleaseBinding({
878
+ artifacts,
879
+ createdAt: value.createdAt,
880
+ releaseId: value.releaseId,
881
+ releaseManifestDigest: value.releaseManifestDigest,
882
+ });
821
883
  if (recreated.materialDigest !== value.materialDigest) {
822
884
  throw new errors_js_1.SupplyChainError('supply-chain-artifact-mismatch', 'releaseBinding.materialDigest', 'does not match the canonical binding bytes');
823
885
  }
@@ -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'>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WORKSPACE_STAGE_OWNERSHIP_SCHEMA_VERSION = void 0;
3
+ exports.WorkspaceStageOwnershipError = exports.WORKSPACE_STAGE_OWNERSHIP_SCHEMA_VERSION = void 0;
4
4
  exports.workspaceStageOwnerParameterName = workspaceStageOwnerParameterName;
5
5
  exports.workspaceStageOwnerParameterArn = workspaceStageOwnerParameterArn;
6
6
  exports.createWorkspaceStageOwnerRecord = createWorkspaceStageOwnerRecord;
@@ -22,6 +22,22 @@ exports.WORKSPACE_STAGE_OWNERSHIP_SCHEMA_VERSION = 1;
22
22
  const ACCOUNT_ID = /^\d{12}$/u;
23
23
  const REGION = /^[a-z]{2}(?:-gov)?-[a-z]+(?:-[a-z]+)*-\d$/u;
24
24
  const WORKSPACE_NAME = /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/u;
25
+ /**
26
+ * The refusal `assertWorkspaceStageOwnership` throws for a tuple this
27
+ * workspace does not own. `status` and `reason` carry the inspection's
28
+ * outcome, so a caller classifies the refusal without reading its message.
29
+ */
30
+ class WorkspaceStageOwnershipError extends Error {
31
+ status;
32
+ reason;
33
+ name = 'WorkspaceStageOwnershipError';
34
+ constructor(message, status, reason) {
35
+ super(message);
36
+ this.status = status;
37
+ this.reason = reason;
38
+ }
39
+ }
40
+ exports.WorkspaceStageOwnershipError = WorkspaceStageOwnershipError;
25
41
  function partitionForRegion(region) {
26
42
  if (region.startsWith('cn-'))
27
43
  return 'aws-cn';
@@ -364,14 +380,14 @@ async function inspectWorkspaceStageOwnership(input, options = {}) {
364
380
  async function assertWorkspaceStageOwnership(input, options = {}) {
365
381
  const result = await inspectWorkspaceStageOwnership(input, options);
366
382
  if (result.status === 'unclaimed') {
367
- throw new Error(`AWS tuple ${result.accountId}/${result.region}/${result.stage} has no EBK workspace owner claim. Apply the exact generated workspace-owner claim before authority or SST lifecycle operations. Existing deployments require committed migration evidence; they are never claimed implicitly.`);
383
+ throw new WorkspaceStageOwnershipError(`AWS tuple ${result.accountId}/${result.region}/${result.stage} has no EBK workspace owner claim. Apply the exact generated workspace-owner claim before authority or SST lifecycle operations. Existing deployments require committed migration evidence; they are never claimed implicitly.`, 'unclaimed');
368
384
  }
369
385
  if (result.status === 'conflict') {
370
386
  const target = requireTarget(input);
371
387
  const actual = result.actualOwner
372
388
  ? result.actualOwner.workspaceDeploymentId
373
389
  : result.reason;
374
- throw new Error(`AWS tuple ${result.accountId}/${result.region}/${result.stage} is owned by ${actual}, not ${target.workspaceName} (${result.expectedOwner.workspaceDeploymentId}). No SST child or AWS application mutation is permitted.`);
390
+ throw new WorkspaceStageOwnershipError(`AWS tuple ${result.accountId}/${result.region}/${result.stage} is owned by ${actual}, not ${target.workspaceName} (${result.expectedOwner.workspaceDeploymentId}). No SST child or AWS application mutation is permitted.`, 'conflict', result.reason);
375
391
  }
376
392
  return result;
377
393
  }