@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
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FUNCTION_ACCESS_FACTORY_MARKERS = exports.FUNCTION_AUTHENTICATIONS = void 0;
4
+ exports.requireName = requireName;
5
+ exports.readFunctionWorkspaceName = readFunctionWorkspaceName;
6
+ exports.functionAuthenticationOf = functionAuthenticationOf;
3
7
  exports.createFunctionFilePlan = createFunctionFilePlan;
4
8
  exports.functionGenerator = functionGenerator;
5
9
  const observability_infrastructure_js_1 = require("../observability-infrastructure.js");
@@ -12,6 +16,7 @@ const logging_registry_js_1 = require("../logging-registry.js");
12
16
  const post_generation_install_js_1 = require("../post-generation-install.js");
13
17
  const workspace_files_js_1 = require("../preset/workspace-files.js");
14
18
  const built_in_plan_js_1 = require("../slice/built-in-plan.js");
19
+ const external_blueprint_compositions_js_1 = require("../upgrade/external-blueprint-compositions.js");
15
20
  function requireName(value, label) {
16
21
  const normalized = value.trim();
17
22
  if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(normalized)) {
@@ -19,6 +24,21 @@ function requireName(value, label) {
19
24
  }
20
25
  return normalized;
21
26
  }
27
+ /** The workspace name a generated Function's managed files carry. */
28
+ function readFunctionWorkspaceName(tree) {
29
+ const packageSource = tree.read('package.json', 'utf8');
30
+ if (packageSource === null) {
31
+ throw new Error('Workspace package.json is required.');
32
+ }
33
+ let packageName;
34
+ try {
35
+ packageName = JSON.parse(packageSource).name;
36
+ }
37
+ catch {
38
+ throw new Error('Workspace package.json must be valid JSON.');
39
+ }
40
+ return requireName(typeof packageName === 'string' ? packageName : '', 'Workspace name');
41
+ }
22
42
  function pascal(value) {
23
43
  return value
24
44
  .split('-')
@@ -38,14 +58,76 @@ function requireCompositionMarker(tree, path, marker) {
38
58
  throw new Error(`Product Slice composition marker ${marker} is missing from ${path}.`);
39
59
  }
40
60
  }
41
- function createFunctionFilePlan(workspace, slice, name, feature = name) {
61
+ exports.FUNCTION_AUTHENTICATIONS = [
62
+ 'signed-in',
63
+ 'anonymous',
64
+ ];
65
+ /** The recorded access of a Function composition: absent means signed-in. */
66
+ function functionAuthenticationOf(composition) {
67
+ return composition.authentication === 'anonymous' ? 'anonymous' : 'signed-in';
68
+ }
69
+ /**
70
+ * The managed Slice product text a Function registration relies on: the
71
+ * lazily created API JWT authorizer that signed-in Functions attach to.
72
+ */
73
+ exports.FUNCTION_ACCESS_FACTORY_MARKERS = [
74
+ '\n const functionAccess = () => {\n',
75
+ '\n void functionAccess;',
76
+ ];
77
+ const SIGNED_IN_HANDLER_COMMENT = `// Signed-in Function: API Gateway admits only a caller with a valid Cognito
78
+ // access token, and context.actor is that verified caller (type 'user' or
79
+ // 'service'). Browser pages call it through this Slice's Next.js server, which
80
+ // sends the access token as a bearer token; a request with only the session
81
+ // cookie gets 401. Keep createHttpJsonHandler: it also refuses ID tokens and
82
+ // marks every response no-store, so never serve a cacheable response from this
83
+ // route. To make it public, run function-access --authentication=anonymous.
84
+ `;
85
+ const ANONYMOUS_HANDLER_COMMENT = `// Public route: EBK does not authenticate it and context.actor is never set.
86
+ // Treat every input as untrusted and verify any webhook signature yourself.
87
+ // To require a signed-in caller, run function-access --authentication=signed-in.
88
+ `;
89
+ function createFunctionFilePlan(workspace, slice, name, feature = name, authentication = 'signed-in') {
90
+ if (!exports.FUNCTION_AUTHENTICATIONS.includes(authentication)) {
91
+ throw new Error('Function authentication must be signed-in or anonymous.');
92
+ }
93
+ const signedIn = authentication === 'signed-in';
42
94
  const symbol = `${pascal(slice)}${pascal(name)}Function`;
43
95
  const register = `register${symbol}`;
44
96
  const infrastructurePath = `infra/functions/${name}.ts`;
97
+ const routeArguments = `{
98
+ ...(role ?? {}),
99
+ ebkRouteMaterialization: 'direct',
100
+ environment: { EBK_FUNCTION_AUTHENTICATION: '${authentication}', EBK_STAGE: $app.stage },
101
+ handler: 'api/${name}.handler',
102
+ link: links,
103
+ logging: { format: 'json', logGroup: logGroup.name },
104
+ transform: {
105
+ function: {
106
+ loggingConfig: {
107
+ applicationLogLevel: 'TRACE',
108
+ logFormat: 'JSON',
109
+ logGroup: logGroup.name,
110
+ systemLogLevel: 'INFO',
111
+ },
112
+ },
113
+ },
114
+ }`;
115
+ const route = signedIn
116
+ ? ` api.route(
117
+ 'ANY /functions/${name}',
118
+ ${routeArguments.split('\n').join('\n ')},
119
+ // API Gateway refuses a request without a valid Cognito access token. It
120
+ // is set on the Route resource, not through \`auth\`, so the existing route
121
+ // stays registered in every preview while the authorizer id is unknown.
122
+ { transform: { route: functionAccess() } },
123
+ );\n`
124
+ : ` // Public route: it has no authorizer and the runtime never sets
125
+ // context.actor.
126
+ api.route('ANY /functions/${name}', ${routeArguments});\n`;
45
127
  const files = {
46
- [`api/${name}.ts`]: `import { createHttpJsonHandler } from '@empire-builder-kit/runtime';\n\nexport const handler = createHttpJsonHandler({\n component: 'function-${name}',\n feature: '${feature}',\n operation: '${name}',\n slice: '${slice}',\n workspace: '${workspace}',\n async handle({ context }) {\n return { actor: context.actor?.id ?? null, function: '${name}', ok: true };\n },\n});\n`,
128
+ [`api/${name}.ts`]: `${signedIn ? SIGNED_IN_HANDLER_COMMENT : ANONYMOUS_HANDLER_COMMENT}import { createHttpJsonHandler } from '@empire-builder-kit/runtime';\n\nexport const handler = createHttpJsonHandler({\n component: 'function-${name}',\n feature: '${feature}',\n operation: '${name}',\n slice: '${slice}',\n workspace: '${workspace}',\n async handle({ context }) {\n return { actor: context.actor?.id ?? null, function: '${name}', ok: true };\n },\n});\n`,
47
129
  [`api/${name}.spec.ts`]: `import { describe, expect, it } from 'vitest';\nimport { handler } from './${name}.js';\n\ndescribe('${name} function', () => {\n it('returns its generated identity', async () => {\n const response = await handler({ requestContext: { requestId: 'test-request' } });\n expect(response.statusCode).toBe(200);\n expect(JSON.parse(response.body).data).toMatchObject({ function: '${name}', ok: true });\n });\n});\n`,
48
- [`infra/functions/${name}.ts`]: `import { createManagedLogGroupContract } from '@empire-builder-kit/nx/foundation';\n\nexport function ${register}(\n api: any,\n router: any,\n alertTopicArn: any,\n role?: { role: string },\n links: any[] = [],\n) {\n const contract = createManagedLogGroupContract({\n component: 'function-${name}',\n slice: '${slice}',\n stage: $app.stage,\n workspace: '${workspace}',\n });\n const logGroup = new aws.cloudwatch.LogGroup('${pascal(slice)}${pascal(name)}Logs', {\n logGroupClass: contract.logGroupClass,\n name: contract.name,\n retentionInDays: contract.retentionInDays,\n tags: contract.tags,\n });\n const dataProtection = new aws.cloudwatch.LogDataProtectionPolicy(\n '${pascal(slice)}${pascal(name)}LogDataProtection',\n {\n logGroupName: logGroup.name,\n policyDocument: JSON.stringify(contract.dataProtectionPolicy),\n },\n { dependsOn: [logGroup] },\n );\n const dataProtectionAlarm = new aws.cloudwatch.MetricAlarm(\n '${pascal(slice)}${pascal(name)}LogDataProtectionFindings',\n {\n alarmActions: [alertTopicArn],\n comparisonOperator: 'GreaterThanOrEqualToThreshold',\n dimensions: { LogGroupName: logGroup.name },\n evaluationPeriods: 1,\n metricName: 'LogEventsWithFindings',\n namespace: 'AWS/Logs',\n period: 300,\n statistic: 'Sum',\n threshold: 1,\n treatMissingData: 'notBreaching',\n },\n { dependsOn: [dataProtection] },\n );\n const functionPath = '/functions/${name}';\n const routerPath = '/${slice}/api/functions/${name}';\n api.route('ANY /functions/${name}', {\n ...(role ?? {}),\n ebkRouteMaterialization: 'direct',\n environment: { EBK_STAGE: $app.stage },\n handler: 'api/${name}.handler',\n link: links,\n logging: { format: 'json', logGroup: logGroup.name },\n transform: {\n function: {\n loggingConfig: {\n applicationLogLevel: 'TRACE',\n logFormat: 'JSON',\n logGroup: logGroup.name,\n systemLogLevel: 'INFO',\n },\n },\n },\n });\n router.route(routerPath, api.url, {\n rewrite: { regex: \`^\${routerPath}$\`, to: functionPath },\n });\n return { dataProtection, dataProtectionAlarm, logGroup };\n}\n`,
130
+ [`infra/functions/${name}.ts`]: `import { createManagedLogGroupContract } from '@empire-builder-kit/nx/foundation';\n\nexport function ${register}(\n api: any,\n router: any,\n alertTopicArn: any,\n role?: { role: string },\n links: any[] = [],\n${signedIn ? ` functionAccess?: () => Record<string, unknown>,\n) {\n if (functionAccess === undefined) {\n throw new Error('A signed-in Function requires its Slice function access.');\n }\n` : ') {\n'} const contract = createManagedLogGroupContract({\n component: 'function-${name}',\n slice: '${slice}',\n stage: $app.stage,\n workspace: '${workspace}',\n });\n const logGroup = new aws.cloudwatch.LogGroup('${pascal(slice)}${pascal(name)}Logs', {\n logGroupClass: contract.logGroupClass,\n name: contract.name,\n retentionInDays: contract.retentionInDays,\n tags: contract.tags,\n });\n const dataProtection = new aws.cloudwatch.LogDataProtectionPolicy(\n '${pascal(slice)}${pascal(name)}LogDataProtection',\n {\n logGroupName: logGroup.name,\n policyDocument: JSON.stringify(contract.dataProtectionPolicy),\n },\n { dependsOn: [logGroup] },\n );\n const dataProtectionAlarm = new aws.cloudwatch.MetricAlarm(\n '${pascal(slice)}${pascal(name)}LogDataProtectionFindings',\n {\n alarmActions: [alertTopicArn],\n comparisonOperator: 'GreaterThanOrEqualToThreshold',\n dimensions: { LogGroupName: logGroup.name },\n evaluationPeriods: 1,\n metricName: 'LogEventsWithFindings',\n namespace: 'AWS/Logs',\n period: 300,\n statistic: 'Sum',\n threshold: 1,\n treatMissingData: 'notBreaching',\n },\n { dependsOn: [dataProtection] },\n );\n const functionPath = '/functions/${name}';\n const routerPath = '/${slice}/api/functions/${name}';\n${route} router.route(routerPath, api.url, {\n rewrite: {\n regex: \`^\${routerPath}$\`,\n // A custom-domain API is mapped under /<slice>; keep that prefix when\n // the Foundation Router forwards to api.<root>.\n to: api.url.apply(\n (url: string) =>\n new URL(url).pathname.replace(/\\/$/, '') + functionPath,\n ),\n },\n });\n return { dataProtection, dataProtectionAlarm, logGroup };\n}\n`,
49
131
  };
50
132
  const infrastructureSource = files[infrastructurePath] ?? '';
51
133
  if (!infrastructureSource.includes(' role?: { role: string },') ||
@@ -66,20 +148,13 @@ function createFunctionFilePlan(workspace, slice, name, feature = name) {
66
148
  };
67
149
  }
68
150
  async function functionGenerator(tree, options) {
69
- const packageSource = tree.read('package.json', 'utf8');
70
- if (packageSource === null) {
71
- throw new Error('Workspace package.json is required.');
72
- }
73
- let packageName;
74
- try {
75
- packageName = JSON.parse(packageSource).name;
76
- }
77
- catch {
78
- throw new Error('Workspace package.json must be valid JSON.');
79
- }
80
- const workspace = requireName(typeof packageName === 'string' ? packageName : '', 'Workspace name');
151
+ const workspace = readFunctionWorkspaceName(tree);
81
152
  const slice = requireName(options.slice, 'Product Slice name');
82
153
  const name = requireName(options.name, 'Function name');
154
+ const authentication = options.authentication ?? 'signed-in';
155
+ if (!exports.FUNCTION_AUTHENTICATIONS.includes(authentication)) {
156
+ throw new Error('Function --authentication must be signed-in or anonymous.');
157
+ }
83
158
  (0, observability_policy_js_1.requireObservabilityPolicyFromTree)(tree);
84
159
  (0, post_generation_install_js_1.assertPostGenerationInstallWorkspaceAvailable)(tree, `generator:function:${slice}:${name}`);
85
160
  const sliceRoot = node_path_1.posix.join('packages', slice);
@@ -98,8 +173,12 @@ async function functionGenerator(tree, options) {
98
173
  requireCompositionMarker(tree, intentPath, '// <ebk:native-runtime-intent-contributions:end>');
99
174
  requireCompositionMarker(tree, productPath, '// <ebk:composition-imports:end>');
100
175
  requireCompositionMarker(tree, productPath, '// <ebk:function-registrations:end>');
176
+ const productSource = tree.read(productPath, 'utf8') ?? '';
177
+ if (exports.FUNCTION_ACCESS_FACTORY_MARKERS.some((marker) => productSource.split(marker).length !== 2)) {
178
+ throw new Error((0, external_blueprint_compositions_js_1.upgradeSliceFirst)(tree, sliceRoot, `Product Slice ${slice} has no managed Function access in ${productPath}`));
179
+ }
101
180
  const loggingRegistration = (0, logging_registry_js_1.planSliceLoggingComponentRegistration)(tree, sliceRoot, `function-${name}`);
102
- const plan = createFunctionFilePlan(workspace, slice, name, feature);
181
+ const plan = createFunctionFilePlan(workspace, slice, name, feature, authentication);
103
182
  for (const [path, contents] of Object.entries(plan.files)) {
104
183
  tree.write(node_path_1.posix.join(sliceRoot, path), contents);
105
184
  }
@@ -110,7 +189,7 @@ async function functionGenerator(tree, options) {
110
189
  foundation.router,
111
190
  foundation.discovery.alertTopicArn,
112
191
  nativeAuthority.permissions('${name}-function'),
113
- secretLinksFor('${name}-function'),
192
+ secretLinksFor('${name}-function'),${authentication === 'signed-in' ? '\n functionAccess,' : ''}
114
193
  );`);
115
194
  replaceMarker(tree, topologyPath, '// <ebk:native-runtime-extensions:end>', ` { id: '${name}', kind: 'function' },`);
116
195
  replaceMarker(tree, intentPath, '// <ebk:native-runtime-intent-contributions:end>', ` ...extensionWorkloadRoleIntentContributions(context, topology, '${name}', 'function'),`);
@@ -122,7 +201,11 @@ async function functionGenerator(tree, options) {
122
201
  await (0, formatting_js_1.formatChangedTreeToFixedPoint)(tree, restoreProtectedFiles);
123
202
  }
124
203
  (0, index_js_1.recordCompositionOwnership)(tree, {
125
- compositions: [{ feature, kind: 'function', name }],
204
+ compositions: [
205
+ authentication === 'anonymous'
206
+ ? { authentication, feature, kind: 'function', name }
207
+ : { feature, kind: 'function', name },
208
+ ],
126
209
  paths: [
127
210
  ...plan.paths,
128
211
  { path: 'infra/product.ts' },
@@ -1,4 +1,5 @@
1
1
  export interface FunctionGeneratorSchema {
2
+ authentication?: 'anonymous' | 'signed-in';
2
3
  feature: string;
3
4
  name: string;
4
5
  skipFormat?: boolean;
@@ -5,6 +5,12 @@
5
5
  "type": "object",
6
6
  "additionalProperties": false,
7
7
  "properties": {
8
+ "authentication": {
9
+ "type": "string",
10
+ "enum": ["signed-in", "anonymous"],
11
+ "default": "signed-in",
12
+ "description": "Who may call this Function: signed-in (API Gateway requires a Cognito access token from the Slice's web or machine clients) or anonymous (a public route, such as a webhook that verifies its own signature)."
13
+ },
8
14
  "feature": {
9
15
  "type": "string",
10
16
  "description": "Existing Slice feature id",
@@ -0,0 +1,14 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ import type { FunctionAccessGeneratorSchema } from './schema.js';
3
+ export interface FunctionAccessLogger {
4
+ info(message: string): void;
5
+ warn(message: string): void;
6
+ }
7
+ /**
8
+ * Changes who may call one existing Function: its managed
9
+ * `infra/functions/<name>.ts`, its registration in the managed
10
+ * `infra/product.ts` and its ownership entry change together, and nothing
11
+ * else does. Seeded handlers and specs keep the adopter's copy.
12
+ */
13
+ export declare function functionAccessGenerator(tree: Tree, options: FunctionAccessGeneratorSchema, output?: FunctionAccessLogger): Promise<void>;
14
+ export default functionAccessGenerator;
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.functionAccessGenerator = functionAccessGenerator;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const node_path_1 = require("node:path");
6
+ const index_js_1 = require("../../ownership/index.js");
7
+ const formatting_js_1 = require("../formatting.js");
8
+ const function_js_1 = require("../function/function.js");
9
+ const function_registration_js_1 = require("../function/function-registration.js");
10
+ const post_generation_install_js_1 = require("../post-generation-install.js");
11
+ const workspace_files_js_1 = require("../preset/workspace-files.js");
12
+ const built_in_plan_js_1 = require("../slice/built-in-plan.js");
13
+ const external_blueprint_compositions_js_1 = require("../upgrade/external-blueprint-compositions.js");
14
+ const function_authentication_notice_js_1 = require("../upgrade/function-authentication-notice.js");
15
+ const PRODUCT_PATH = 'infra/product.ts';
16
+ function describeAccess(slice, name, authentication) {
17
+ return authentication === 'signed-in'
18
+ ? `From its next deploy, API Gateway refuses, with 401, any request without a valid Cognito access token from the Slice's web client or machine clients, on /${slice}/api/functions/${name} and on the Slice API path, and the handler receives the verified caller as context.actor. Browser pages call it through the Slice's Next.js server, which sends the access token as a bearer token; a browser request that carries only the session cookie is refused.`
19
+ : `From its next deploy, it is a public route on /${slice}/api/functions/${name} and on the Slice API path, with no authentication and no context.actor; only the Router path has the WAF. Treat every input as untrusted and verify any webhook signature in the handler.`;
20
+ }
21
+ /**
22
+ * Changes who may call one existing Function: its managed
23
+ * `infra/functions/<name>.ts`, its registration in the managed
24
+ * `infra/product.ts` and its ownership entry change together, and nothing
25
+ * else does. Seeded handlers and specs keep the adopter's copy.
26
+ */
27
+ async function functionAccessGenerator(tree, options, output = devkit_1.logger) {
28
+ const workspace = (0, function_js_1.readFunctionWorkspaceName)(tree);
29
+ const slice = (0, function_js_1.requireName)(options.slice ?? '', 'Product Slice name');
30
+ const name = (0, function_js_1.requireName)(options.name ?? '', 'Function name');
31
+ const target = options.authentication;
32
+ if (!function_js_1.FUNCTION_AUTHENTICATIONS.includes(target)) {
33
+ throw new Error('function-access --authentication must be signed-in or anonymous.');
34
+ }
35
+ (0, post_generation_install_js_1.assertPostGenerationInstallWorkspaceAvailable)(tree, `generator:function-access:${slice}:${name}`);
36
+ const sliceRoot = node_path_1.posix.join('packages', slice);
37
+ const ownershipPath = node_path_1.posix.join(sliceRoot, '.ebk/ownership.json');
38
+ const ownershipSource = tree.read(ownershipPath, 'utf8');
39
+ if (ownershipSource === null) {
40
+ throw new Error(`${slice} is not an EBK v1 Product Slice.`);
41
+ }
42
+ let parsed;
43
+ try {
44
+ parsed = JSON.parse(ownershipSource);
45
+ }
46
+ catch {
47
+ throw new Error(`Product Slice ownership metadata is not valid JSON at ${ownershipPath}.`);
48
+ }
49
+ const ownership = (0, index_js_1.validateGeneratedOwnershipRecord)(parsed);
50
+ if (!ownership.valid || ownership.value.slice !== slice) {
51
+ throw new Error(`Product Slice ownership metadata is invalid at ${ownershipPath}.`);
52
+ }
53
+ const composition = ownership.value.compositions.find((entry) => entry.kind === 'function' && entry.name === name);
54
+ if (composition === undefined) {
55
+ throw new Error(`Function ${name} is not a recorded Function of Product Slice ${slice}.`);
56
+ }
57
+ const infrastructurePath = `infra/functions/${name}.ts`;
58
+ const drifted = [];
59
+ const sources = new Map();
60
+ for (const path of [infrastructurePath, PRODUCT_PATH]) {
61
+ const entry = ownership.value.paths.find((candidate) => candidate.path === path);
62
+ const source = tree.read(node_path_1.posix.join(sliceRoot, path), 'utf8');
63
+ if (entry === undefined ||
64
+ entry.mode !== 'managed' ||
65
+ source === null ||
66
+ (0, index_js_1.hashOwnedContent)(source, entry) !== entry.sha256) {
67
+ drifted.push(path);
68
+ }
69
+ else {
70
+ sources.set(path, source);
71
+ }
72
+ }
73
+ if (drifted.length > 0) {
74
+ throw new Error((0, external_blueprint_compositions_js_1.upgradeSliceFirst)(tree, sliceRoot, `function-access refuses user-modified managed files in Product Slice ${slice}: ${drifted.join(', ')}`, {
75
+ first: 'Restore them first.',
76
+ step: '. Restore them, or run the Slice upgrade, first.',
77
+ }));
78
+ }
79
+ const infrastructure = sources.get(infrastructurePath) ?? '';
80
+ const product = sources.get(PRODUCT_PATH) ?? '';
81
+ if (function_js_1.FUNCTION_ACCESS_FACTORY_MARKERS.some((marker) => product.split(marker).length !== 2)) {
82
+ throw new Error((0, external_blueprint_compositions_js_1.upgradeSliceFirst)(tree, sliceRoot, `Product Slice ${slice} has no managed Function access in ${node_path_1.posix.join(sliceRoot, PRODUCT_PATH)}`));
83
+ }
84
+ const current = (0, function_authentication_notice_js_1.currentFunctionAccess)(name, infrastructure);
85
+ if (current === 'unauthenticated') {
86
+ throw new Error((0, external_blueprint_compositions_js_1.upgradeSliceFirst)(tree, sliceRoot, `Function ${name} has no access setting in its managed ${infrastructurePath}`));
87
+ }
88
+ const plan = (0, function_js_1.createFunctionFilePlan)(workspace, slice, name, composition.feature, target);
89
+ const located = (0, function_registration_js_1.locateFunctionRegistration)(product, plan.register, name);
90
+ if ((0, function_registration_js_1.functionRegistrationAccess)(located.registration, name) !== current) {
91
+ throw new Error((0, external_blueprint_compositions_js_1.upgradeSliceFirst)(tree, sliceRoot, `Function ${name}'s registration in ${PRODUCT_PATH} does not match its managed ${infrastructurePath}`, { step: '; run the Slice upgrade first.' }));
92
+ }
93
+ const recorded = (0, function_js_1.functionAuthenticationOf)(composition);
94
+ const label = `[ebk-function-access] ${slice}/${name}`;
95
+ if (current === target && recorded === target) {
96
+ output.info(`${label}: already ${target}; nothing changed.`);
97
+ return;
98
+ }
99
+ const rendered = plan.files[infrastructurePath];
100
+ if (rendered === undefined) {
101
+ throw new Error(`Function plan did not render ${infrastructurePath}.`);
102
+ }
103
+ tree.write(node_path_1.posix.join(sliceRoot, infrastructurePath), rendered);
104
+ tree.write(node_path_1.posix.join(sliceRoot, PRODUCT_PATH), product.slice(0, located.start) +
105
+ (0, function_registration_js_1.setFunctionRegistrationAccess)(located.registration, name, target) +
106
+ product.slice(located.end));
107
+ if (!options.skipFormat) {
108
+ const slicePrefix = `${sliceRoot}/`;
109
+ const restoreProtectedFiles = (0, formatting_js_1.createTreeFileRestorer)(tree, (path) => (0, workspace_files_js_1.isRawWorkspaceAuthorityPath)(path) ||
110
+ (path.startsWith(slicePrefix) &&
111
+ (0, built_in_plan_js_1.isBuiltInSliceFormatSensitivePath)(path.slice(slicePrefix.length))));
112
+ await (0, formatting_js_1.formatChangedTreeToFixedPoint)(tree, restoreProtectedFiles);
113
+ }
114
+ const entry = target === 'anonymous'
115
+ ? {
116
+ authentication: 'anonymous',
117
+ feature: composition.feature,
118
+ kind: 'function',
119
+ name,
120
+ }
121
+ : { feature: composition.feature, kind: 'function', name };
122
+ (0, index_js_1.recordCompositionOwnership)(tree, {
123
+ allowAccessChange: true,
124
+ compositions: [entry],
125
+ paths: [{ path: infrastructurePath }, { path: PRODUCT_PATH }],
126
+ slice,
127
+ });
128
+ if (!options.skipFormat) {
129
+ await (0, formatting_js_1.formatTreeFileToFixedPoint)(tree, ownershipPath);
130
+ }
131
+ const change = current === target
132
+ ? `stays ${target}; its ownership entry now records ${target} (it recorded ${recorded})`
133
+ : `${current} -> ${target}`;
134
+ const message = `${label}: ${change}. ${describeAccess(slice, name, target)} Changed: ${node_path_1.posix.join(sliceRoot, infrastructurePath)}, its registration in ${node_path_1.posix.join(sliceRoot, PRODUCT_PATH)} and its entry in ${ownershipPath}; the seeded handler and spec keep your copy. Deploy the Slice to apply it.`;
135
+ if (target === 'anonymous')
136
+ output.warn(message);
137
+ else
138
+ output.info(message);
139
+ }
140
+ exports.default = functionAccessGenerator;
141
+ //# sourceMappingURL=function-access.js.map
@@ -0,0 +1,6 @@
1
+ export interface FunctionAccessGeneratorSchema {
2
+ authentication: 'anonymous' | 'signed-in';
3
+ name: string;
4
+ skipFormat?: boolean;
5
+ slice: string;
6
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "EmpireBuilderKitFunctionAccess",
4
+ "title": "Change who may call an existing Function of an EBK v1 Product Slice",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "authentication": {
9
+ "type": "string",
10
+ "enum": ["signed-in", "anonymous"],
11
+ "description": "Who may call the Function from its next deploy: signed-in (API Gateway requires a Cognito access token from the Slice's web or machine clients) or anonymous (a public route, such as a webhook that verifies its own signature)."
12
+ },
13
+ "name": {
14
+ "type": "string",
15
+ "description": "Existing Function name",
16
+ "$default": { "$source": "argv", "index": 0 }
17
+ },
18
+ "skipFormat": { "type": "boolean", "default": false },
19
+ "slice": {
20
+ "type": "string",
21
+ "description": "Owning Product Slice"
22
+ }
23
+ },
24
+ "required": ["authentication", "name", "slice"]
25
+ }
@@ -30,7 +30,7 @@ export interface PostGenerationInstallScope {
30
30
  roots: string[];
31
31
  }
32
32
  export interface PostGenerationInstallOperation {
33
- generator: 'slice' | 'workload';
33
+ generator: 'site' | 'slice' | 'workload';
34
34
  id: string;
35
35
  key: string;
36
36
  request: Record<string, unknown>;
@@ -1686,7 +1686,7 @@ function parseRecord(source) {
1686
1686
  !Number.isInteger(record.revision) ||
1687
1687
  record.revision < 0 ||
1688
1688
  !isRecord(operation) ||
1689
- !['slice', 'workload'].includes(operation.generator) ||
1689
+ !['site', 'slice', 'workload'].includes(operation.generator) ||
1690
1690
  typeof operation.id !== 'string' ||
1691
1691
  !isRecord(operation.request) ||
1692
1692
  !stringArray(operation.resumeArguments) ||
@@ -33,7 +33,7 @@ export declare const DEFAULT_DEPENDENCY_OVERRIDES: {
33
33
  readonly '@node-minify/core@9.0.2>glob@10.3.3': "10.5.0";
34
34
  readonly 'axios@1.18.1': "1.20.0";
35
35
  readonly 'brace-expansion@5.0.9': "5.0.12";
36
- readonly 'follow-redirects@1.16.0': "1.16.1";
36
+ readonly 'follow-redirects@1.16.0': "1.16.2";
37
37
  readonly 'smol-toml@1.6.1': "1.9.0";
38
38
  };
39
39
  };
@@ -36,7 +36,7 @@ exports.DEFAULT_DEPENDENCY_OVERRIDES = {
36
36
  '@node-minify/core@9.0.2>glob@10.3.3': '10.5.0',
37
37
  'axios@1.18.1': '1.20.0',
38
38
  'brace-expansion@5.0.9': '5.0.12',
39
- 'follow-redirects@1.16.0': '1.16.1',
39
+ 'follow-redirects@1.16.0': '1.16.2',
40
40
  'smol-toml@1.6.1': '1.9.0',
41
41
  },
42
42
  };
@@ -134,6 +134,16 @@ with \`billing:db-generate\`, never by hand.
134
134
  Run the affected tests/typecheck/ownership checks reported by context, then
135
135
  the hot browser/API/event journey. See the develop/verify skill. A feature is
136
136
  not done merely because its generated file exists or the page loads.
137
+
138
+ A public page that belongs at the Router's \`/\` goes in the optional root
139
+ site (\`packages/site\`, from \`pnpm nx g @empire-builder-kit/nx:site\`), not
140
+ in a Slice. Add it under the site's seeded \`web/src/app/\` and run
141
+ \`pnpm nx run site:verify\`: its route check refuses a top-level segment that
142
+ names a Slice and a public directory that prefixes one. Link between the site
143
+ and a Slice with a plain \`<a>\`, not \`next/link\`. The site has no sign-in,
144
+ API or mutating route in 1.0; link to the Slice's sign-in instead. It shares
145
+ the origin with every Slice, so keep its CSP strict, including
146
+ \`worker-src 'none'\`.
137
147
  `,
138
148
  },
139
149
  'ebk-develop-verify': {
@@ -228,6 +238,10 @@ authorize production or bypass a protected environment.
228
238
  Refresh, unlock and remove are separate owning Nx targets: inspect their
229
239
  actual options and operation \`target:<project>:<target>\`; do not substitute
230
240
  deploy or raw provider commands. Remove dependent Slices before Foundation.
241
+ With a root site, a stage deploys the Foundation, then the site, then the
242
+ Slices; \`ebk deploy development site\` selects the site. Remove the Slices,
243
+ then the site, then the Foundation. Production deploys the site only when
244
+ \`site.productionStatus\` is \`ready\` in \`ebk.repository-policy.json\`.
231
245
 
232
246
  Stop downstream work after infrastructure, migration, smoke or access-cleanup
233
247
  failure. Preserve native diagnostics and identify project/phase plus the next
@@ -134,11 +134,12 @@ Blueprint records, Repository Operating Policy, Git state, work markers, and dec
134
134
  contracts are the sources of truth. Neither Work Orchestration nor the Operations Console is
135
135
  required. A skill, MCP client, IDE, or hosted agent service is optional.
136
136
 
137
- The numeric JSON schema in this runbook is framework-internal and may change before stable v1.
138
- Do not publish an adapter or treat it as an independent public API until the repository-native
139
- CLI and Nx contract complete their live pilots. A local, unpublished wrapper (skill, MCP tool,
140
- or IDE command) that only invokes these same commands with \`--json\` is permitted under
141
- \`docs/developer-agent-adapters.md\` and must stay removable without changing the workflow.
137
+ The numeric JSON schema in this runbook is part of the \`ebk\` CLI's documented \`--json\` output
138
+ shapes and is versioned with the framework packages. Do not publish an adapter or treat it as an
139
+ independent public API until the repository-native CLI and Nx contract complete their live
140
+ pilots. A local, unpublished wrapper (skill, MCP tool, or IDE command) that only invokes these
141
+ same commands with \`--json\` is permitted under \`docs/developer-agent-adapters.md\` and must
142
+ stay removable without changing the workflow.
142
143
 
143
144
  ## Canonical loop
144
145
 
@@ -239,10 +240,12 @@ admit seeded paths.
239
240
 
240
241
  Typed generator requests add one closed \`generatorInput\` object and cannot supply
241
242
  \`selectedFiles\`. New Slice planning accepts only \`{"generator":"slice","name":"billing"}\`
242
- and the built-in Standard Blueprint. Function, Service, and Job planning requires exact
243
+ and the built-in Standard Blueprint. Root site planning accepts only
244
+ \`{"generator":"site"}\`: the root site is the one fixed \`packages/site\` project.
245
+ Function, Service, and Job planning requires exact
243
246
  \`generator\`, \`slice\`, \`feature\`, and \`name\` strings which must match inspected
244
247
  repository context. Upgrade planning accepts only an existing \`workspace\`, \`foundation\`,
245
- or Product Slice target:
248
+ root site (\`site\`), or Product Slice target:
246
249
 
247
250
  \`\`\`json
248
251
  {
@@ -280,10 +283,13 @@ and none may be reported as read-only proof.
280
283
 
281
284
  Installing a newer stable framework candidate intentionally creates version drift before
282
285
  ownership upgrade. Only the Upgrade operation for the exact target may consume its typed
283
- version-drift finding, and only in dependency order: workspace, then Foundation, then each
284
- Product Slice. Every identity disagreement, managed drift, package mismatch, wrong target,
285
- or prerequisite-layer drift remains blocking. Prerelease consumers regenerate cleanly
286
- instead of using this stable-line transition as beta compatibility.
286
+ version-drift finding, and only in dependency order: workspace, then Foundation, then the
287
+ root site and each Product Slice. Every identity disagreement, managed drift, package mismatch, wrong target,
288
+ or prerequisite-layer drift remains blocking. For stable \`1.0.0\`, a workspace generated by
289
+ \`1.0.0-rc.39\` or a later prerelease upgrades in place through this same sequence, after
290
+ each intervening release's documented upgrade steps. A workspace generated by
291
+ \`1.0.0-rc.38\` or earlier is rebuilt instead: generate a clean workspace and reapply
292
+ adopter-owned source and configuration.
287
293
 
288
294
  Bound inspection with \`--projects=<names>\`, \`--slice=<name>\`, and optional
289
295
  \`--feature=<name>\`. The emitted JSON context is at most 128 KiB. When linked worktrees
@@ -163,10 +163,60 @@ tags, production-name protections, and explicit protection-removal denies are
163
163
  the stable guardrails around the broader infrastructure service families. In
164
164
  commercial AWS, CloudFront, CloudFront-scope WAF, and edge ACM mutations use
165
165
  the us-east-1 control plane while application resources remain bound to the
166
- committed deployment Region. This prerelease does not claim Router edge support in
166
+ committed deployment Region. This release does not claim Router edge support in
167
167
  noncommercial partitions: CloudFront is unavailable inside GovCloud, and the
168
168
  China-partition CloudFront/WAF/edge-ACM control plane is not yet proven.
169
169
 
170
+ ## Public DNS
171
+
172
+ The deployment role has no Route 53 record authority unless the stage has a
173
+ committed binding in \`ebk.repository-policy.json\`:
174
+
175
+ \`\`\`json
176
+ "publicDns": {
177
+ "development": { "hostedZoneId": "Z0123456789EXAMPLE", "rootDomain": "example.com" }
178
+ }
179
+ \`\`\`
180
+
181
+ The binding is accepted only in the \`aws\` partition, only for an active stage,
182
+ and each stage needs its own hosted zone and root domain; a delegated subdomain
183
+ zone per stage is the supported layout. The rendered authority then allows
184
+ \`route53:ChangeResourceRecordSets\` on that one hosted-zone ARN for record types
185
+ A, AAAA, and CNAME only (the generated records listed below), and
186
+ \`manifest.json\` records the binding. NS, SOA, DS, MX, TXT, CAA, and every other
187
+ type stay denied in that zone, and every other zone stays denied. Name-level
188
+ scoping is not claimed: a bound stage can create, change, or delete any A,
189
+ AAAA, or CNAME name in its zone. If the zone is an apex zone shared with other
190
+ hostnames, those hostnames are in reach; prefer a delegated zone and alarm on
191
+ \`ChangeResourceRecordSets\` for the apex zone. Generated Foundation uses the
192
+ same binding as its only domain switch: a bound stage's Router serves
193
+ \`rootDomain\`, whether the stage is deployed locally or by the generated Deploy
194
+ workflow, and SST receives the exact zone ID. Without a binding the Router keeps
195
+ its CloudFront URL. \`EBK_ROOT_DOMAIN\` is optional: if set it must equal
196
+ \`rootDomain\` exactly, and Foundation refuses before constructing resources when
197
+ it differs or when it is set without a binding.
198
+
199
+ Generated stage infrastructure writes only alias records (A and AAAA) and each
200
+ certificate's ACM validation CNAME in the bound zone, for these names:
201
+
202
+ - \`rootDomain\` and \`*.<rootDomain>\`, the Foundation Router's aliases
203
+ - \`auth.<rootDomain>\`, the Foundation's Cognito identity domain
204
+ - \`api.<rootDomain>\`, the Foundation's API Gateway domain for Slice APIs
205
+
206
+ Cloud Map creates the generated private \`sst\` DNS namespace by forwarding its
207
+ own Route 53 requests with the deployment role's identity. Only those forwarded
208
+ requests (\`aws:CalledViaLast\` is \`servicediscovery.amazonaws.com\`) may create
209
+ a hosted zone or UPSERT an SOA record; the zone is unknown in advance, so the
210
+ resource is \`*\`. The SOA and UPSERT restriction applies when Route 53 supplies
211
+ the record-type and action keys on the forwarded request; if it does not, only
212
+ the Cloud Map service chain bounds the change. Through Cloud Map the role can
213
+ therefore also UPSERT the SOA
214
+ of any Cloud Map-managed zone in the account, including a pre-existing public
215
+ namespace zone, because \`servicediscovery:*\` is broad. Public and HTTP
216
+ namespace creation is denied. ECS writes the instance A and SRV records with
217
+ its own service-linked role. No health-check or Route 53 tag authority is
218
+ granted.
219
+
170
220
  When multiple stages share one AWS account, their application resources,
171
221
  runtime roles, data, and discovery remain separately named and tagged, but the
172
222
  native SST deployment role is account-scoped enough to reconcile SST's shared
@@ -435,6 +485,9 @@ const githubSubject = repository
435
485
  githubOwner + '@' + githubOwnerId + '/' + githubRepository + '@' + githubRepositoryId +
436
486
  ':environment:' + stage
437
487
  : undefined;
488
+ // The committed binding is the only source of direct Route 53 record
489
+ // authority: one exact public hosted zone, aws partition only.
490
+ const publicDns = policy.publicDns?.[stage];
438
491
  const plan = createStageAuthorityPlan({
439
492
  accountId,
440
493
  awsPrincipalArns: principals,
@@ -447,6 +500,7 @@ const plan = createStageAuthorityPlan({
447
500
  },
448
501
  }
449
502
  : {}),
503
+ ...(publicDns ? { publicHostedZoneId: publicDns.hostedZoneId } : {}),
450
504
  region,
451
505
  partition,
452
506
  stage,
@@ -500,6 +554,9 @@ const manifest = {
500
554
  kind: 'ebk-stage-authority-render',
501
555
  limitations: plan.limitations,
502
556
  profile: policy.deploymentProfile,
557
+ publicDns: publicDns
558
+ ? { hostedZoneId: publicDns.hostedZoneId, rootDomain: publicDns.rootDomain }
559
+ : null,
503
560
  region,
504
561
  schemaVersion: 1,
505
562
  stackName: plan.identity.stackName,
@@ -48,6 +48,17 @@ export declare function protectedBrowserInstallScript(): string;
48
48
  * canonical names never reach the lifecycle when the request is empty.
49
49
  */
50
50
  export declare function machineCredentialRequestScript(): string;
51
+ /**
52
+ * @internal Run exactly this generated script in the protected-runner fixture.
53
+ *
54
+ * Reads the deploying stage's optional database credential generation through
55
+ * a request name and exports the canonical variable only when it is set. An
56
+ * unset GitHub variable expands to '', which must not reach the Slice SST
57
+ * config, so the default bootstrap generation is kept when the request is
58
+ * empty. Every SQL Slice the deployment reaches rotates its generated
59
+ * database credential once when the requested generation is new.
60
+ */
61
+ export declare function databaseCredentialRequestScript(): string;
51
62
  /** @internal Exported for executable source-contract tests. */
52
63
  export declare function exactStageDeployerGuardScript(operation: string, accountVariable: string): string;
53
64
  /** @internal Shared verbatim by every generated protected workflow. */