@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
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ /**
3
+ * Generated diagnostic functions for the Slice deployed smoke runner,
4
+ * `scripts/run-smoke-deployed.mjs`. Each constant is JavaScript source the
5
+ * runner template embeds; the runner supplies the free identifiers named in
6
+ * each comment.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.playwrightOutputTailFunctions = exports.deployedSmokeOwnershipFindingFunctions = void 0;
10
+ /**
11
+ * `ownershipRegionFinding(ownership, region)` and
12
+ * `ownershipErrorFinding(error)` classify the workspace stage ownership
13
+ * preflight. Only an owner mismatch or an access-denied error is
14
+ * `authorization-denied`; a missing credential source or a Region mismatch is
15
+ * `prerequisite-missing`, and anything else is `infrastructure-unavailable`.
16
+ * Summaries never carry a bare account id or another workspace's identity;
17
+ * the shared sanitizer withholds any cause matching a protected shape.
18
+ *
19
+ * Free identifier: `sanitizeTestingEvidenceSummary`.
20
+ */
21
+ exports.deployedSmokeOwnershipFindingFunctions = String.raw `const ownershipRequirement =
22
+ 'Deployed smoke requires this workspace to own the exact account, Region, and canonical stage tuple.';
23
+ const ownershipDeniedErrorNames = [
24
+ 'AccessDenied',
25
+ 'AccessDeniedException',
26
+ 'NotAuthorizedException',
27
+ 'UnauthorizedException',
28
+ 'UnauthorizedOperation',
29
+ ];
30
+
31
+ // The sanitizer withholds a whole value that matches a protected shape, so
32
+ // it runs first; a bare account id then survives only as a placeholder.
33
+ function redactedOwnershipText(value) {
34
+ return sanitizeTestingEvidenceSummary(value).replace(
35
+ /(?<!\d)\d{12}(?!\d)/g,
36
+ '[account-id]',
37
+ );
38
+ }
39
+
40
+ function ownershipFinding(classification, detail) {
41
+ return {
42
+ classification,
43
+ summary: (ownershipRequirement + ' ' + detail).slice(0, 1024),
44
+ };
45
+ }
46
+
47
+ function ownershipRegionFinding(ownership, region) {
48
+ return region === ownership.region
49
+ ? undefined
50
+ : ownershipFinding(
51
+ 'prerequisite-missing',
52
+ 'AWS_REGION differs from the workspace owner Region ' + ownership.region + '.',
53
+ );
54
+ }
55
+
56
+ function ownershipErrorFinding(error) {
57
+ const name =
58
+ error && typeof error === 'object' && typeof error.name === 'string'
59
+ ? error.name.replace(/[^A-Za-z0-9_-]/g, '').slice(0, 80) || 'Error'
60
+ : 'UnknownError';
61
+ const message =
62
+ error && typeof error === 'object' && typeof error.message === 'string'
63
+ ? error.message
64
+ : '';
65
+ // The ownership assertion's typed refusal is the published denial: its
66
+ // message names the account and the other owner, so the summary stays the
67
+ // fixed requirement the packed contract and earlier evidence pin.
68
+ if (name === 'WorkspaceStageOwnershipError') {
69
+ return { classification: 'authorization-denied', summary: ownershipRequirement };
70
+ }
71
+ return ownershipFinding(
72
+ ownershipDeniedErrorNames.includes(name)
73
+ ? 'authorization-denied'
74
+ : name === 'CredentialsProviderError'
75
+ ? 'prerequisite-missing'
76
+ : 'infrastructure-unavailable',
77
+ 'The ownership check failed with ' + name + ': ' + redactedOwnershipText(message),
78
+ );
79
+ }
80
+ `;
81
+ /**
82
+ * `retainPlaywrightOutputTail(outputPath, tailPath, secrets)` keeps at most
83
+ * the last 4 KiB of a failed Playwright run's combined output at `tailPath`
84
+ * (mode 0600). Every verbatim or URI-encoded occurrence of a known synthetic
85
+ * credential or email inside the bytes read, overlapping ones merged, and any
86
+ * bare account id is replaced before the cut; other encodings are not
87
+ * recognized. A secret that started before the bytes read, a
88
+ * split account id or a split character can only sit before the first line
89
+ * break after a cut, so a cut tail keeps only whole lines; a secret holding
90
+ * a line break withholds the tail. Output that still matches a protected
91
+ * shape is withheld. It removes `outputPath` and returns whether a tail was
92
+ * kept.
93
+ *
94
+ * Free identifiers: `closeSync`, `inspectTestingEvidenceArtifact`,
95
+ * `openSync`, `readSync`, `rmSync`, `statSync`, `writeFileSync`.
96
+ */
97
+ exports.playwrightOutputTailFunctions = String.raw `const playwrightOutputTailBytes = 4096;
98
+ const playwrightOutputTailNote =
99
+ 'A bounded, scrubbed Playwright output tail is kept beside the smoke evidence.';
100
+
101
+ // Replaces every occurrence of every value, overlapping ones as one range.
102
+ function replaceKnownValues(text, values, marker) {
103
+ const ranges = [];
104
+ for (const value of values) {
105
+ for (let at = text.indexOf(value); at >= 0; at = text.indexOf(value, at + 1)) {
106
+ ranges.push([at, at + value.length]);
107
+ }
108
+ }
109
+ ranges.sort((left, right) => left[0] - right[0]);
110
+ let replaced = '';
111
+ let cursor = 0;
112
+ for (let index = 0; index < ranges.length; index += 1) {
113
+ const start = ranges[index][0];
114
+ let end = ranges[index][1];
115
+ while (index + 1 < ranges.length && ranges[index + 1][0] < end) {
116
+ index += 1;
117
+ end = Math.max(end, ranges[index][1]);
118
+ }
119
+ replaced += text.slice(cursor, start) + marker;
120
+ cursor = end;
121
+ }
122
+ return replaced + text.slice(cursor);
123
+ }
124
+
125
+ function retainPlaywrightOutputTail(outputPath, tailPath, secrets) {
126
+ rmSync(tailPath, { force: true });
127
+ // Each secret also as a URL would encode it, such as an email's @ as %40.
128
+ const known = [
129
+ ...new Set(
130
+ secrets
131
+ .filter((value) => typeof value === 'string' && value.length > 0)
132
+ .flatMap((value) => [value, encodeURIComponent(value)]),
133
+ ),
134
+ ];
135
+ let text;
136
+ let cut;
137
+ try {
138
+ if (known.some((value) => /[\r\n]/.test(value))) return false;
139
+ const size = statSync(outputPath).size;
140
+ const length = Math.min(
141
+ size,
142
+ playwrightOutputTailBytes +
143
+ Math.max(0, ...known.map((value) => Buffer.byteLength(value))),
144
+ );
145
+ const bytes = Buffer.alloc(length);
146
+ const descriptor = openSync(outputPath, 'r');
147
+ try {
148
+ readSync(descriptor, bytes, 0, length, size - length);
149
+ } finally {
150
+ closeSync(descriptor);
151
+ }
152
+ cut = length < size;
153
+ text = bytes.toString('utf8');
154
+ } catch {
155
+ return false;
156
+ } finally {
157
+ rmSync(outputPath, { force: true });
158
+ }
159
+ let tail = Buffer.from(
160
+ replaceKnownValues(text, known, '[synthetic-credential]').replace(
161
+ /(?<!\d)\d{12}(?!\d)/g,
162
+ '[account-id]',
163
+ ),
164
+ 'utf8',
165
+ );
166
+ if (tail.byteLength > playwrightOutputTailBytes) {
167
+ tail = tail.subarray(-playwrightOutputTailBytes);
168
+ cut = true;
169
+ }
170
+ text = tail.toString('utf8');
171
+ if (cut) {
172
+ const lineBreak = text.indexOf('\n');
173
+ text = lineBreak < 0 ? '' : text.slice(lineBreak + 1);
174
+ }
175
+ if (text.trim().length === 0) return false;
176
+ const inspection = inspectTestingEvidenceArtifact({ contents: text });
177
+ writeFileSync(
178
+ tailPath,
179
+ inspection.safe
180
+ ? text
181
+ : 'Playwright output withheld because it matched protected ' +
182
+ inspection.detections.join(', ') +
183
+ ' data.\n',
184
+ { encoding: 'utf8', mode: 0o600 },
185
+ );
186
+ return true;
187
+ }
188
+ `;
189
+ //# sourceMappingURL=deployed-smoke-diagnostics.js.map
@@ -1,2 +1,9 @@
1
1
  /** Managed post-deployment prerequisite, not a replacement for browser proof. */
2
2
  export declare const deployedSmokeReadinessScript: string;
3
+ /**
4
+ * The same managed readiness, rendered for the workspace root site: one web
5
+ * target at the site's health route on the Foundation routerUrl origin, with
6
+ * the same bounds, transient set, CloudFront placeholder detection,
7
+ * confirmation window and wildcard-host refusal.
8
+ */
9
+ export declare function rootSiteDeployedSmokeReadinessScript(): string;
@@ -1,16 +1,89 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deployedSmokeReadinessScript = void 0;
4
- /** Managed post-deployment prerequisite, not a replacement for browser proof. */
5
- exports.deployedSmokeReadinessScript = String.raw `import { performance } from 'node:perf_hooks';
4
+ exports.rootSiteDeployedSmokeReadinessScript = rootSiteDeployedSmokeReadinessScript;
5
+ const root_site_js_1 = require("../../foundation/root-site.js");
6
+ const DEPLOYED_SMOKE_READINESS_VARIANTS = {
7
+ // Two targets, the Slice API and its web route, and a wait while a new
8
+ // Slice route still falls through to the root site.
9
+ slice: {
10
+ serviceRefusal: '!/^[a-z][a-z0-9-]*$/.test(input.service)',
11
+ targets: String.raw ` // A Slice API on the Foundation's api.<root> domain is mapped under
12
+ // /<service>; an execute-api origin has no path. Join, never resolve.
13
+ const api = endpoint(input.apiUrl, ['', '/' + input.service]);
14
+ const web = endpoint(input.webUrl, ['/' + input.service]);
15
+ targets = [
16
+ { name: 'api', url: new URL(api.pathname.replace(/\/$/, '') + '/health', api.origin).href, service: input.service },
17
+ { name: 'web', url: new URL('/' + input.service + '/api/health', web.origin).href, service: input.service + '-web' },
18
+ ];`,
19
+ hostRefusal: 'A deployed Slice URL must use the host of the Foundation routerUrl; upgrade the Slice, redeploy, and use its new webUrl output.',
20
+ fallthroughFunction: String.raw `
21
+ // The root site's managed proxy marks every response, its not-found pages
22
+ // included, so a Slice route that has not reached the serving edge yet is told
23
+ // apart from a Slice failure. A marked response of any status only waits; a
24
+ // pass still needs the exact Slice health.
25
+ function siteFallthrough(response) {
26
+ return response.headers.get('${root_site_js_1.ROOT_SITE_ROUTE_HEADER}') === '${root_site_js_1.ROOT_SITE_ROUTE_HEADER_VALUE}';
27
+ }
28
+ `,
29
+ fallthroughClassification: String.raw ` if (target.name === 'web' && siteFallthrough(response)) {
30
+ await response.body?.cancel().catch(() => {});
31
+ observation.edgeRouting = '${root_site_js_1.ROOT_SITE_READINESS_CONTRACT_TOKEN}';
32
+ edgeObservations += 1;
33
+ edgePending = true;
34
+ consecutive = 0;
35
+ ready = false;
36
+ break;
37
+ }
38
+ `,
39
+ // A new base-path mapping for api.<root>/<slice> briefly answers API
40
+ // Gateway's own not-found body while it propagates. Only that exact body
41
+ // waits, inside the 30-second bound; any other 404 still fails at once.
42
+ apiMappingClassification: String.raw ` if (target.name === 'api' && response.status === 404) {
43
+ let body;
44
+ try { body = new TextDecoder('utf-8', { fatal: true }).decode(await boundedBytes(response)); }
45
+ catch (error) { if (signal.aborted) throw error; }
46
+ if (body !== '{"message":"Not Found"}') {
47
+ return failed('infrastructure-unavailable', 'Deployed api readiness refused HTTP 404; verify the native deployment and exact output before retrying.');
48
+ }
49
+ observation.apiMapping = 'pending';
50
+ edgePending = false;
51
+ consecutive = 0;
52
+ ready = false;
53
+ break;
54
+ }
55
+ `,
56
+ edgeBoundSummary: 'The deployed web route was not served by the Router within 300 seconds: routing fell through to the placeholder origin, which CloudFront answered with its own error page, or to the root site, which answered with x-ebk-route: site.',
57
+ readinessSubject: 'API and web',
58
+ },
59
+ // One target, the site's health route on the Foundation routerUrl origin.
60
+ // The site's own marked responses are its answers, never a fallthrough.
61
+ site: {
62
+ serviceRefusal: `input.service !== '${root_site_js_1.ROOT_SITE_ROUTE_HEADER_VALUE}'`,
63
+ targets: String.raw ` const web = endpoint(input.webUrl, ['']);
64
+ targets = [
65
+ { name: 'web', url: new URL('/__ebk/health', web.origin).href, service: input.service },
66
+ ];`,
67
+ hostRefusal: 'The root site URL must use the host of the Foundation routerUrl; upgrade the root site, redeploy, and use its new webUrl output.',
68
+ fallthroughFunction: '',
69
+ fallthroughClassification: '',
70
+ apiMappingClassification: '',
71
+ edgeBoundSummary: 'The deployed root site route was not served by the Router within 300 seconds: CloudFront answered with its own error page because routing fell through to the placeholder origin.',
72
+ readinessSubject: 'root site',
73
+ },
74
+ };
75
+ function renderDeployedSmokeReadinessScript(variant) {
76
+ const { apiMappingClassification, edgeBoundSummary, fallthroughClassification, fallthroughFunction, hostRefusal, readinessSubject, serviceRefusal, targets, } = DEPLOYED_SMOKE_READINESS_VARIANTS[variant];
77
+ return String.raw `import { performance } from 'node:perf_hooks';
6
78
  import { setTimeout as delay } from 'node:timers/promises';
7
79
 
8
80
  const totalLimitMs = 30_000;
9
- // Only a CloudFront-generated Router fallthrough extends readiness. The pinned
10
- // SST Router reads routing from an eventually consistent CloudFront
11
- // KeyValueStore; until a new Slice's route is visible at the serving edge the
12
- // request reaches the placeholder origin. Every other failure keeps the
13
- // thirty-second bound above.
81
+ // Only a Router fallthrough extends readiness. The pinned SST Router reads
82
+ // routing from an eventually consistent CloudFront KeyValueStore; until a new
83
+ // Slice's route is visible at the serving edge the request reaches the
84
+ // placeholder origin, which CloudFront answers with its own error page, or the
85
+ // workspace root site, which marks every response it handles. Every other
86
+ // failure keeps the thirty-second bound above.
14
87
  const edgeRouteLimitMs = 300_000;
15
88
  const requestLimitMs = 5_000;
16
89
  const retryDelayMs = 2_000;
@@ -30,14 +103,26 @@ const transientNetworkCodes = new Set([
30
103
  'UND_ERR_CONNECT_TIMEOUT', 'UND_ERR_SOCKET',
31
104
  ]);
32
105
 
33
- function endpoint(value, path) {
106
+ function endpoint(value, paths) {
34
107
  const url = new URL(value);
35
- if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash || url.pathname.replace(/\/$/, '') !== path) {
108
+ // WHATWG URL keeps '*' in a host. Refuse a '*' and any character outside
109
+ // letters, digits, '.' and '-' before any request; this is not a hostname
110
+ // validator. A Slice under a custom domain whose webUrl still names SST's
111
+ // wildcard alias host is refused here instead of reaching CloudFront.
112
+ if (!/^[a-z0-9.-]+$/.test(url.hostname)) throw new Error('non-dns-host');
113
+ if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash || !paths.includes(url.pathname.replace(/\/$/, ''))) {
36
114
  throw new Error('invalid-output');
37
115
  }
38
116
  return url;
39
117
  }
40
118
 
119
+ // The code of a failed request, such as ENOTFOUND or UND_ERR_SOCKET, as a
120
+ // bounded token; anything else is recorded as 'unknown'.
121
+ function networkErrorCode(error) {
122
+ const code = error?.cause?.code ?? error?.code;
123
+ return typeof code === 'string' && /^[A-Z][A-Z0-9_]{0,31}$/.test(code) ? code : 'unknown';
124
+ }
125
+
41
126
  function responseCorrelation(response) {
42
127
  const requestId = response.headers.get('x-amz-cf-id');
43
128
  const pop = response.headers.get('x-amz-cf-pop');
@@ -87,7 +172,7 @@ async function edgeRouteUnavailable(response) {
87
172
  if (!/<title>\s*ERROR: The request could not be satisfied\s*<\/title>/i.test(page)) return undefined;
88
173
  return { edgeRouting: 'unavailable', originDnsPage: /resolve the origin domain name/i.test(page) };
89
174
  }
90
-
175
+ ${fallthroughFunction}
91
176
  // Dependency injection is internal fixture support; the generated runner has
92
177
  // no environment/CLI override for endpoints, TLS, policy or timing.
93
178
  export async function waitForDeployedSmokeReadiness(input, runtime = {}) {
@@ -114,14 +199,10 @@ export async function waitForDeployedSmokeReadiness(input, runtime = {}) {
114
199
  });
115
200
  let targets;
116
201
  try {
117
- if (!/^[a-z][a-z0-9-]*$/.test(input.service) || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(input.sourceCommit) || !['development', 'staging', 'production'].includes(input.stage)) throw new Error('invalid-identity');
118
- const api = endpoint(input.apiUrl, '');
119
- const web = endpoint(input.webUrl, '/' + input.service);
120
- targets = [
121
- { name: 'api', url: new URL('/health', api).href, service: input.service },
122
- { name: 'web', url: new URL('/' + input.service + '/api/health', web.origin).href, service: input.service + '-web' },
123
- ];
124
- } catch {
202
+ if (${serviceRefusal} || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(input.sourceCommit) || !['development', 'staging', 'production'].includes(input.stage)) throw new Error('invalid-identity');
203
+ ${targets}
204
+ } catch (error) {
205
+ if (error?.message === 'non-dns-host') return failed('environment-drift', "Deployed smoke outputs name a host with '*' or a character other than letters, digits, '.' and '-'. ${hostRefusal}");
125
206
  return failed('environment-drift', 'Deployed readiness requires exact credential-free HTTPS outputs and service/stage/build identity.');
126
207
  }
127
208
  // The round cap also bounds receipts if a fixture or monotonic clock stalls.
@@ -147,7 +228,7 @@ export async function waitForDeployedSmokeReadiness(input, runtime = {}) {
147
228
  });
148
229
  observation = { endpoint: target.name, status: response.status, ...timing(), ...responseCorrelation(response) };
149
230
  observations.push(observation);
150
- if (response.status !== 200) {
231
+ ${fallthroughClassification}${apiMappingClassification} if (response.status !== 200) {
151
232
  if (!transientStatuses.has(response.status)) {
152
233
  await response.body?.cancel();
153
234
  return failed('infrastructure-unavailable', 'Deployed ' + target.name + ' readiness refused HTTP ' + response.status + '; verify the native deployment and exact output before retrying.');
@@ -171,8 +252,10 @@ export async function waitForDeployedSmokeReadiness(input, runtime = {}) {
171
252
  if (input.signal?.aborted) return failed('infrastructure-unavailable', 'Deployed readiness was interrupted before smoke setup.');
172
253
  const transient = signal.aborted || transientNetworkCodes.has(error?.cause?.code ?? error?.code);
173
254
  // One row per request: a body failure after headers annotates that row.
174
- if (observation) observation.body = signal.aborted ? 'timeout' : 'network-error';
175
- else observations.push({ endpoint: target.name, status: signal.aborted ? 'timeout' : 'network-error', ...timing() });
255
+ // A network error keeps only its error code, never its message.
256
+ const failure = signal.aborted ? {} : { code: networkErrorCode(error) };
257
+ if (observation) Object.assign(observation, { body: signal.aborted ? 'timeout' : 'network-error', ...failure });
258
+ else observations.push({ endpoint: target.name, status: signal.aborted ? 'timeout' : 'network-error', ...failure, ...timing() });
176
259
  if (!transient) return failed('infrastructure-unavailable', 'Deployed readiness transport failed; verify endpoint and certificate configuration before retrying.');
177
260
  edgePending = false;
178
261
  consecutive = 0;
@@ -206,9 +289,21 @@ export async function waitForDeployedSmokeReadiness(input, runtime = {}) {
206
289
  return failed('infrastructure-unavailable', 'Deployed readiness reached its bounded attempt count before its time bound; inspect the readiness clock and native diagnostics before another governed attempt.');
207
290
  }
208
291
  if (edgePending) {
209
- return failed('infrastructure-unavailable', 'The deployed web route was not served by the Router within 300 seconds: CloudFront answered with its own error page because routing fell through to the placeholder origin. Inspect Router KeyValueStore propagation before another governed attempt.');
292
+ return failed('infrastructure-unavailable', '${edgeBoundSummary} Inspect Router KeyValueStore propagation before another governed attempt.');
210
293
  }
211
- return failed('infrastructure-unavailable', 'The expected deployed API and web build did not become ready within the 30-second bound for unavailability other than Router edge propagation; inspect native diagnostics before another governed attempt.');
294
+ return failed('infrastructure-unavailable', 'The expected deployed ${readinessSubject} build did not become ready within the 30-second bound for unavailability other than Router edge propagation; inspect native diagnostics before another governed attempt.');
212
295
  }
213
296
  `;
297
+ }
298
+ /** Managed post-deployment prerequisite, not a replacement for browser proof. */
299
+ exports.deployedSmokeReadinessScript = renderDeployedSmokeReadinessScript('slice');
300
+ /**
301
+ * The same managed readiness, rendered for the workspace root site: one web
302
+ * target at the site's health route on the Foundation routerUrl origin, with
303
+ * the same bounds, transient set, CloudFront placeholder detection,
304
+ * confirmation window and wildcard-host refusal.
305
+ */
306
+ function rootSiteDeployedSmokeReadinessScript() {
307
+ return renderDeployedSmokeReadinessScript('site');
308
+ }
214
309
  //# sourceMappingURL=deployed-smoke-readiness.js.map
@@ -18,10 +18,10 @@ function standardPersistenceContract(options) {
18
18
  Object.keys(current).some((key) => !['kind', 'schemaVersion', 'defaultStore'].includes(key)))
19
19
  throw new Error('Standard persistence declaration is invalid; no store may be inferred or reassigned.');
20
20
  if (current.defaultStore === 'postgres')
21
- throw new Error('This prerelease Standard Slice uses a PostgreSQL-backed framework core. Automatic upgrade is unsupported. Preserve its data and infrastructure, then complete an explicit repository-owned migration or rebuild before adopting the DynamoDB core. No files have been changed.');
21
+ throw new Error('This Standard Slice declares a PostgreSQL-backed framework core, which only Slices generated by a prerelease earlier than 1.0.0-rc.39 carried. Automatic upgrade is unsupported. Preserve its data and infrastructure, then complete an explicit repository-owned migration or rebuild before adopting the DynamoDB core, as docs/upgrades.md describes under "RC.39 single-core persistence and Foundation contract break". No files have been changed.');
22
22
  }
23
23
  else if (options.existingStandardRequirement) {
24
- throw new Error('Existing Standard Slice is missing its persisted storage declaration. Automatic prerelease conversion is unsupported; preserve its data and infrastructure and complete an explicit repository-owned migration or rebuild. No files have been changed.');
24
+ throw new Error('Existing Standard Slice is missing its persisted storage declaration (data/persistence.json), which a Slice generated by a prerelease earlier than 1.0.0-rc.39 can lack. Automatic conversion of such a Slice is unsupported; preserve its data and infrastructure and complete an explicit repository-owned migration or rebuild. No files have been changed.');
25
25
  }
26
26
  return {
27
27
  kind: 'ebk-standard-persistence',
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The generated `pnpmLaunch(args, platform, comspec)` function that the Slice
3
+ * and root site deployed smoke runners use to start pnpm. It returns the
4
+ * command and arguments for a `spawnSync` call with `shell: false`.
5
+ *
6
+ * On native Windows pnpm is a `.cmd` shim, which Node cannot spawn without a
7
+ * shell. The function runs it through `cmd.exe /d /s /c` instead. Each runner
8
+ * passes only constant arguments, and the function refuses any argument that
9
+ * is not a plain token, so the one command line cmd.exe reads holds no
10
+ * metacharacter and needs no quoting beyond Node's own. On every other
11
+ * platform it returns `pnpm` and the arguments unchanged.
12
+ */
13
+ export declare const pnpmLaunchFunction: string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pnpmLaunchFunction = void 0;
4
+ /**
5
+ * The generated `pnpmLaunch(args, platform, comspec)` function that the Slice
6
+ * and root site deployed smoke runners use to start pnpm. It returns the
7
+ * command and arguments for a `spawnSync` call with `shell: false`.
8
+ *
9
+ * On native Windows pnpm is a `.cmd` shim, which Node cannot spawn without a
10
+ * shell. The function runs it through `cmd.exe /d /s /c` instead. Each runner
11
+ * passes only constant arguments, and the function refuses any argument that
12
+ * is not a plain token, so the one command line cmd.exe reads holds no
13
+ * metacharacter and needs no quoting beyond Node's own. On every other
14
+ * platform it returns `pnpm` and the arguments unchanged.
15
+ */
16
+ exports.pnpmLaunchFunction = String.raw `// pnpm is a .cmd shim on native Windows, which spawn cannot start without a
17
+ // shell, so it runs through cmd.exe. Arguments are constants and must be plain
18
+ // tokens: the cmd.exe command line then holds no metacharacter.
19
+ function pnpmLaunch(args, platform = process.platform, comspec = process.env.ComSpec) {
20
+ if (!args.every((value) => /^[A-Za-z0-9=._-]+$/.test(value))) {
21
+ throw new Error('pnpm launch arguments must be plain constant tokens.');
22
+ }
23
+ return platform === 'win32'
24
+ ? { command: comspec ?? 'cmd.exe', args: ['/d', '/s', '/c', ['pnpm.cmd', ...args].join(' ')] }
25
+ : { command: 'pnpm', args };
26
+ }
27
+ `;
28
+ //# sourceMappingURL=pnpm-launch-script.js.map
@@ -8,6 +8,7 @@ const node_path_1 = require("node:path");
8
8
  const node_util_1 = require("node:util");
9
9
  const index_js_1 = require("../../blueprints/index.js");
10
10
  const index_js_2 = require("../../foundation/index.js");
11
+ const root_site_js_1 = require("../../foundation/root-site.js");
11
12
  const capability_plan_js_1 = require("../../foundation/capability-plan.js");
12
13
  const preview_changes_js_1 = require("../../developer-agent/preview-changes.js");
13
14
  const upgrade_js_1 = require("../upgrade/upgrade.js");
@@ -22,6 +23,7 @@ const built_in_plan_js_1 = require("./built-in-plan.js");
22
23
  const data_policy_review_seed_js_1 = require("./data-policy-review-seed.js");
23
24
  const tree_policy_js_1 = require("../repository-policy/tree-policy.js");
24
25
  const observability_policy_js_1 = require("../observability-policy.js");
26
+ const site_js_1 = require("../site/site.js");
25
27
  var built_in_plan_js_2 = require("./built-in-plan.js");
26
28
  Object.defineProperty(exports, "PRODUCT_PACKAGE_MANAGED_JSON_POINTERS", { enumerable: true, get: function () { return built_in_plan_js_2.PRODUCT_PACKAGE_MANAGED_JSON_POINTERS; } });
27
29
  Object.defineProperty(exports, "STANDARD_LOCAL_DEV_ADAPTER", { enumerable: true, get: function () { return built_in_plan_js_2.STANDARD_LOCAL_DEV_ADAPTER; } });
@@ -43,8 +45,32 @@ function requireSliceName(name) {
43
45
  if (value.length > 63 || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value)) {
44
46
  throw new Error('Slice name must start with a lowercase letter, contain at most 63 characters, and use only lowercase letters, numbers, and hyphens.');
45
47
  }
48
+ if ((0, root_site_js_1.isReservedRootSiteName)(value)) {
49
+ throw new Error(root_site_js_1.ROOT_SITE_RESERVED_SLICE_NAME_MESSAGE);
50
+ }
46
51
  return value;
47
52
  }
53
+ // The root site's routes are a reverse constraint on new Slice names: the
54
+ // Router gives the Slice precedence, so a name the site serves, or one a site
55
+ // public directory captures by prefix, would silently move that path.
56
+ function refuseRootSiteRouteConflict(tree, name) {
57
+ const source = tree.read(index_js_3.SITE_OWNERSHIP_PATH, 'utf8');
58
+ if (source === null)
59
+ return;
60
+ let recorded;
61
+ try {
62
+ recorded = JSON.parse(source);
63
+ }
64
+ catch {
65
+ throw new Error(root_site_js_1.ROOT_SITE_UNREADABLE_RECORD_MESSAGE);
66
+ }
67
+ if (!(0, index_js_3.isSiteOwnershipRecord)(recorded))
68
+ return;
69
+ const conflicts = (0, root_site_js_1.rootSiteSliceNameConflicts)((0, root_site_js_1.inspectRootSiteRoutes)({ files: (0, site_js_1.rootSiteWebFiles)(tree), sliceNames: [] }), name);
70
+ if (conflicts.length > 0) {
71
+ throw new Error(`Product Slice ${name} would collide with the workspace root site: ${conflicts.join('; ')}. Choose another name, or move that site route first.`);
72
+ }
73
+ }
48
74
  function workspaceScope(packageJson) {
49
75
  const name = packageJson.name?.trim();
50
76
  if (!name || !/^[a-z0-9][a-z0-9-]*$/.test(name)) {
@@ -212,6 +238,7 @@ async function sliceGenerator(tree, options) {
212
238
  if (tree.exists(root)) {
213
239
  throw new Error(`Product Slice ${name} already exists at ${root}.`);
214
240
  }
241
+ refuseRootSiteRouteConflict(tree, name);
215
242
  const packageJson = readJson(tree, 'package.json', 'Workspace package.json');
216
243
  const blueprint = (0, index_js_1.resolveBlueprint)({
217
244
  localAuthoringPackages: packageJson.ebk?.blueprints?.localAuthoringPackages ?? [],
@@ -0,0 +1,19 @@
1
+ import type { RepositoryOperatingPolicy } from '../../repository-policy/index.js';
2
+ /** The call a managed Foundation makes once the binding is its only switch. */
3
+ export declare const FOUNDATION_BINDING_SWITCH_CALL = "resolveFoundationPublicDomain(";
4
+ /**
5
+ * The Foundation upgrade report's notice for the custom-domain switch.
6
+ * After this upgrade a bound stage serves its
7
+ * `rootDomain` on its next deploy whether or not `EBK_ROOT_DOMAIN` is set, so
8
+ * a bound stage that was deployed without the variable (every bound stage
9
+ * that deploys only through GitHub) moves from its CloudFront URL to its
10
+ * custom domain. The workspace keeps no record of what a stage last served,
11
+ * so the notice is printed whenever a stage has a binding and the current
12
+ * managed Foundation still uses the variable-gated switch; that is exactly
13
+ * the upgrade that moves the switch, and the report prints it before
14
+ * `--apply` writes anything. Returns `null` when nothing moves.
15
+ */
16
+ export declare function foundationCustomDomainSwitchNotice(input: {
17
+ currentFoundationSource: string | null;
18
+ policy: Pick<RepositoryOperatingPolicy, 'publicDns'>;
19
+ }): string | null;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FOUNDATION_BINDING_SWITCH_CALL = void 0;
4
+ exports.foundationCustomDomainSwitchNotice = foundationCustomDomainSwitchNotice;
5
+ const CANONICAL_STAGES = ['development', 'staging', 'production'];
6
+ /** The call a managed Foundation makes once the binding is its only switch. */
7
+ exports.FOUNDATION_BINDING_SWITCH_CALL = 'resolveFoundationPublicDomain(';
8
+ /**
9
+ * The Foundation upgrade report's notice for the custom-domain switch.
10
+ * After this upgrade a bound stage serves its
11
+ * `rootDomain` on its next deploy whether or not `EBK_ROOT_DOMAIN` is set, so
12
+ * a bound stage that was deployed without the variable (every bound stage
13
+ * that deploys only through GitHub) moves from its CloudFront URL to its
14
+ * custom domain. The workspace keeps no record of what a stage last served,
15
+ * so the notice is printed whenever a stage has a binding and the current
16
+ * managed Foundation still uses the variable-gated switch; that is exactly
17
+ * the upgrade that moves the switch, and the report prints it before
18
+ * `--apply` writes anything. Returns `null` when nothing moves.
19
+ */
20
+ function foundationCustomDomainSwitchNotice(input) {
21
+ if (input.currentFoundationSource?.includes(exports.FOUNDATION_BINDING_SWITCH_CALL))
22
+ return null;
23
+ const bound = CANONICAL_STAGES.filter((stage) => input.policy.publicDns?.[stage] !== undefined);
24
+ if (bound.length === 0)
25
+ return null;
26
+ return [
27
+ `[ebk-upgrade] custom-domain-switch: after this Foundation upgrade the committed binding is the only custom-domain switch for ${bound.map((stage) => `publicDns.${stage}`).join(', ')}.`,
28
+ 'On its next deploy each bound stage serves its rootDomain whether or not EBK_ROOT_DOMAIN is set, including a stage deployed by the generated Deploy workflow.',
29
+ 'Before its next Foundation deploy, every bound stage needs its stage authority re-rendered from this release and re-applied, including a stage that was bound by an earlier release: the Route 53 grant is unchanged, but the bound render adds statements for the custom hostnames this release serves.',
30
+ 'A bound stage that was deployed without EBK_ROOT_DOMAIN moves from its CloudFront URL to its custom domain: the Router is updated in place, a certificate is issued, alias records are written, and the CloudFront URL stops answering.',
31
+ 'Each bound Slice, once upgraded and redeployed, serves its API only on https://api.<rootDomain>/<slice>; its execute-api URL stops answering, so update webhook registrations and any other caller that holds it.',
32
+ 'To keep a stage on its CloudFront URL, remove its binding, then re-render and re-apply the stage authority before deploying.',
33
+ // Area 2: the same deploy replaces each bound stage's identity domain.
34
+ 'Each bound stage also moves its identity domain from the Cognito prefix domain to auth.<rootDomain>: the prefix domain is removed before auth.<rootDomain> is created, so the token endpoint is unavailable until the new domain answers, which AWS documents as within five minutes, with up to one hour for its certificate. Each Slice uses the new token endpoint once it is redeployed.',
35
+ 'See "Unreleased: custom domains for bound stages" in docs/upgrades.md.',
36
+ ].join('\n');
37
+ }
38
+ //# sourceMappingURL=custom-domain-notice.js.map