@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
@@ -10,11 +10,7 @@ async function runFleetSupervisorDaemon(startupPath) {
10
10
  return;
11
11
  handlingSignal = true;
12
12
  try {
13
- const selected = runtime.session.selectedSlices();
14
- if (selected.length > 0)
15
- await runtime.session.down(selected);
16
- await runtime.session.closeProxyWhenEmpty();
17
- await runtime.supervisor.stopGracefully();
13
+ await runtime.supervisor.stopForSignal();
18
14
  }
19
15
  catch (error) {
20
16
  handlingSignal = false;
@@ -57,5 +57,6 @@ export declare class FleetSupervisor {
57
57
  waitForIdle(): Promise<void>;
58
58
  waitUntilStopped(): Promise<void>;
59
59
  stopGracefully(): Promise<void>;
60
+ stopForSignal(): Promise<void>;
60
61
  }
61
62
  export {};
@@ -96,6 +96,7 @@ class FleetSupervisor {
96
96
  #shutdownGraceMs;
97
97
  #state;
98
98
  #stopping = false;
99
+ #stopOperation;
99
100
  constructor(options, effects = {}) {
100
101
  this.#adapters = options.adapters;
101
102
  this.#host = options.host;
@@ -422,22 +423,44 @@ class FleetSupervisor {
422
423
  return;
423
424
  await new Promise((resolvePromise) => this.#closedWaiters.push(resolvePromise));
424
425
  }
425
- async stopGracefully() {
426
+ stopGracefully() {
427
+ return this.#stop('empty');
428
+ }
429
+ stopForSignal() {
430
+ return this.#stop('down-selected');
431
+ }
432
+ #stop(mode) {
426
433
  if (this.#closed)
427
- return;
434
+ return Promise.resolve();
435
+ if (this.#stopOperation)
436
+ return this.#stopOperation;
428
437
  this.#stopping = true;
429
- await this.waitForIdle();
430
- try {
431
- this.#assertShutdownOwnership();
432
- await this.#host.closeProxyWhenEmpty();
433
- (0, fleet_runner_evidence_js_1.retireFleetRunnerEvidence)(this.#state, this.#paths, {
434
- security: this.#security,
435
- });
436
- }
437
- catch (error) {
438
+ this.#stopOperation = this.#finishStop(mode).catch((error) => {
438
439
  this.#stopping = false;
440
+ this.#stopOperation = undefined;
439
441
  throw error;
442
+ });
443
+ return this.#stopOperation;
444
+ }
445
+ async #finishStop(mode) {
446
+ await this.waitForIdle();
447
+ if (mode === 'down-selected') {
448
+ const selected = this.#host.selectedSlices();
449
+ if (selected.length > 0) {
450
+ try {
451
+ this.#syncSliceStates(await this.#host.down(selected));
452
+ }
453
+ finally {
454
+ this.#syncLiveSliceStates();
455
+ this.#persistState();
456
+ }
457
+ }
440
458
  }
459
+ this.#assertShutdownOwnership();
460
+ await this.#host.closeProxyWhenEmpty();
461
+ (0, fleet_runner_evidence_js_1.retireFleetRunnerEvidence)(this.#state, this.#paths, {
462
+ security: this.#security,
463
+ });
441
464
  if (this.#heartbeat)
442
465
  clearInterval(this.#heartbeat);
443
466
  this.#heartbeat = undefined;
@@ -1,4 +1,4 @@
1
1
  export declare function runGatewayDaemon(options: {
2
2
  appData: string;
3
- port?: number;
3
+ port: number;
4
4
  }): Promise<void>;
@@ -4,6 +4,8 @@ exports.runGatewayDaemon = runGatewayDaemon;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const gateway_js_1 = require("./gateway.js");
6
6
  const tls_js_1 = require("./tls.js");
7
+ // Started only by ebk dev setup --portless, which always passes the port of
8
+ // its selected forwarding model; there is no default port to bind.
7
9
  async function runGatewayDaemon(options) {
8
10
  const paths = (0, tls_js_1.localTlsPaths)(options.appData);
9
11
  if (process.platform !== 'win32')
@@ -13,7 +15,7 @@ async function runGatewayDaemon(options) {
13
15
  cert: (0, node_fs_1.readFileSync)(paths.leafCertificate),
14
16
  key: (0, node_fs_1.readFileSync)(paths.leafKey),
15
17
  });
16
- await gateway.listen(options.port ?? 443, paths.gatewaySocket);
18
+ await gateway.listen(options.port, paths.gatewaySocket);
17
19
  (0, node_fs_1.writeFileSync)(paths.gatewayPid, `${process.pid}\n`, { mode: 0o600 });
18
20
  const shutdown = async () => {
19
21
  await gateway.close().catch(() => undefined);
@@ -27,9 +29,9 @@ async function runGatewayDaemon(options) {
27
29
  }
28
30
  if (require.main === module) {
29
31
  const appData = process.argv[2];
30
- const port = Number(process.argv[3] ?? '443');
31
- if (!appData || !Number.isInteger(port)) {
32
- throw new Error('Usage: gateway-daemon <app-data> [port]');
32
+ const port = Number(process.argv[3]);
33
+ if (!appData || !process.argv[3] || !Number.isInteger(port)) {
34
+ throw new Error('Usage: gateway-daemon <app-data> <port>');
33
35
  }
34
36
  void runGatewayDaemon({ appData, port }).catch((error) => {
35
37
  process.stderr.write(`${error instanceof Error ? error.stack : String(error)}\n`);
@@ -11,5 +11,10 @@ export interface PortlessForwardPlan {
11
11
  platform: NodeJS.Platform;
12
12
  remove: PrivilegedCommand[];
13
13
  }
14
+ /**
15
+ * The forwarding model for the explicit `ebk dev setup --portless` opt-in.
16
+ * Plain setup never computes this plan, starts the gateway daemon, or binds a
17
+ * port; on Windows the daemon binds 443 directly only under this opt-in.
18
+ */
14
19
  export declare function createPortlessForwardPlan(targetPlatform?: NodeJS.Platform): PortlessForwardPlan;
15
20
  export declare function applyPrivilegedCommands(commands: readonly PrivilegedCommand[]): void;
@@ -5,6 +5,11 @@ exports.createPortlessForwardPlan = createPortlessForwardPlan;
5
5
  exports.applyPrivilegedCommands = applyPrivilegedCommands;
6
6
  const node_child_process_1 = require("node:child_process");
7
7
  exports.EBK_GATEWAY_INTERNAL_PORT = 54443;
8
+ /**
9
+ * The forwarding model for the explicit `ebk dev setup --portless` opt-in.
10
+ * Plain setup never computes this plan, starts the gateway daemon, or binds a
11
+ * port; on Windows the daemon binds 443 directly only under this opt-in.
12
+ */
8
13
  function createPortlessForwardPlan(targetPlatform = process.platform) {
9
14
  if (targetPlatform === 'win32') {
10
15
  return {
@@ -2,3 +2,13 @@ export declare const OWNED_PROCESS_SIGNAL_GRACE_MS = 10000;
2
2
  export declare const OWNED_PROCESS_KILL_WAIT_MS = 5000;
3
3
  /** Read-only existence check for an already-proved owned POSIX group. */
4
4
  export declare function exactOwnedProcessGroupExists(pid: number): boolean;
5
+ export interface ExactWindowsTaskkill {
6
+ executable: string;
7
+ systemRoot: string;
8
+ }
9
+ /** The canonical `%SystemRoot%\System32\taskkill.exe`, never a bare-name
10
+ * lookup: on Windows libuv searches the current directory (an adopter
11
+ * checkout) before PATH. Spawn it with `env: { SystemRoot }` and
12
+ * `shell: false`. The governed SST executor keeps its own copy of this check
13
+ * in run-sst-command.ts, where its spec pins the source text. */
14
+ export declare function exactWindowsTaskkill(environment: NodeJS.ProcessEnv): ExactWindowsTaskkill;
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OWNED_PROCESS_KILL_WAIT_MS = exports.OWNED_PROCESS_SIGNAL_GRACE_MS = void 0;
4
4
  exports.exactOwnedProcessGroupExists = exactOwnedProcessGroupExists;
5
+ exports.exactWindowsTaskkill = exactWindowsTaskkill;
6
+ const node_fs_1 = require("node:fs");
7
+ const node_path_1 = require("node:path");
5
8
  // The fleet owner must allow its SST child the same bounded settlement window.
6
9
  exports.OWNED_PROCESS_SIGNAL_GRACE_MS = 10_000;
7
10
  exports.OWNED_PROCESS_KILL_WAIT_MS = 5_000;
@@ -26,4 +29,34 @@ function exactOwnedProcessGroupExists(pid) {
26
29
  throw error;
27
30
  }
28
31
  }
32
+ /** The canonical `%SystemRoot%\System32\taskkill.exe`, never a bare-name
33
+ * lookup: on Windows libuv searches the current directory (an adopter
34
+ * checkout) before PATH. Spawn it with `env: { SystemRoot }` and
35
+ * `shell: false`. The governed SST executor keeps its own copy of this check
36
+ * in run-sst-command.ts, where its spec pins the source text. */
37
+ function exactWindowsTaskkill(environment) {
38
+ const values = new Set(Object.entries(environment)
39
+ .filter(([name, value]) => name.toLowerCase() === 'systemroot' &&
40
+ typeof value === 'string' &&
41
+ value.length > 0)
42
+ .map(([, value]) => value));
43
+ if (values.size !== 1) {
44
+ throw new Error('Windows process-tree termination requires exact SystemRoot.');
45
+ }
46
+ const systemRoot = values.values().next().value;
47
+ if (typeof systemRoot !== 'string' ||
48
+ !(0, node_path_1.isAbsolute)(systemRoot) ||
49
+ /[\0\r\n"]/u.test(systemRoot)) {
50
+ throw new Error('Windows process-tree termination has an unsafe SystemRoot.');
51
+ }
52
+ const requested = (0, node_path_1.join)(systemRoot, 'System32', 'taskkill.exe');
53
+ const metadata = (0, node_fs_1.lstatSync)(requested);
54
+ const canonical = (0, node_fs_1.realpathSync)(requested);
55
+ if (metadata.isSymbolicLink() ||
56
+ !metadata.isFile() ||
57
+ canonical.toLowerCase() !== requested.toLowerCase()) {
58
+ throw new Error('Windows taskkill authority is not exact.');
59
+ }
60
+ return { executable: canonical, systemRoot };
61
+ }
29
62
  //# sourceMappingURL=process-group.js.map
@@ -61,7 +61,11 @@ function createLocalIpcPath(base, identity) {
61
61
  .update((0, node_path_1.resolve)(base))
62
62
  .digest('hex')
63
63
  .slice(0, 16);
64
- const directory = (0, node_path_1.join)('/tmp', `ebk-${uid}-${baseDigest}`);
64
+ const directory = (0, node_path_1.join)(localIpcFallbackRoot(uid), `ebk-${uid}-${baseDigest}`);
65
+ const socket = (0, node_path_1.join)(directory, `.ebk-${digest}.sock`);
66
+ if (Buffer.byteLength(socket) > 95) {
67
+ throw new Error('Local IPC fallback root is too long for a socket path.');
68
+ }
65
69
  if ((0, node_fs_1.existsSync)(directory)) {
66
70
  const status = (0, node_fs_1.lstatSync)(directory);
67
71
  if (status.isSymbolicLink() ||
@@ -81,7 +85,32 @@ function createLocalIpcPath(base, identity) {
81
85
  (status.mode & 0o777) !== 0o700) {
82
86
  throw new Error('Local IPC directory is not current-user private.');
83
87
  }
84
- return (0, node_path_1.join)(directory, `.ebk-${digest}.sock`);
88
+ return socket;
89
+ }
90
+ /**
91
+ * Parent of the short per-base IPC directories. The framework's own test
92
+ * runners set `EBK_LOCAL_IPC_FALLBACK_ROOT` to a private per-run directory
93
+ * they remove afterwards, so long temporary bases still take this fallback
94
+ * without leaving one `/tmp` directory per base. An override must already be
95
+ * a current-user private directory; anything else fails closed.
96
+ */
97
+ function localIpcFallbackRoot(uid) {
98
+ const override = process.env.EBK_LOCAL_IPC_FALLBACK_ROOT;
99
+ if (override === undefined)
100
+ return '/tmp';
101
+ if (!(0, node_path_1.isAbsolute)(override)) {
102
+ throw new Error('Local IPC fallback root must be an absolute path.');
103
+ }
104
+ const root = (0, node_path_1.resolve)(override);
105
+ const status = (0, node_fs_1.lstatSync)(root, { throwIfNoEntry: false });
106
+ if (!status ||
107
+ status.isSymbolicLink() ||
108
+ !status.isDirectory() ||
109
+ status.uid !== uid ||
110
+ (status.mode & 0o777) !== 0o700) {
111
+ throw new Error('Local IPC fallback root is not current-user private.');
112
+ }
113
+ return root;
85
114
  }
86
115
  function openssl(args, cwd) {
87
116
  (0, node_child_process_1.execFileSync)('openssl', args, { cwd, stdio: 'pipe' });
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Operating-system trust-store plumbing shared by `ebk dev setup --trust` and
3
+ * `ebk dev doctor`. Every command goes through an injectable runner so the
4
+ * unit proofs assert exact argv without touching a real trust store.
5
+ */
6
+ export declare const EBK_LOCAL_ROOT_LABEL = "Empire Builder Kit Local Root";
7
+ export interface TrustCommandResult {
8
+ readonly error?: NodeJS.ErrnoException;
9
+ readonly status: number | null;
10
+ readonly stderr: string;
11
+ readonly stdout: string;
12
+ }
13
+ export interface TrustCommandOptions {
14
+ readonly env?: NodeJS.ProcessEnv;
15
+ /**
16
+ * Inherit the terminal so the operating system can show its own consent or
17
+ * credential prompt, which the human answers.
18
+ */
19
+ readonly interactive?: boolean;
20
+ readonly timeoutMs?: number;
21
+ }
22
+ export type TrustCommandRunner = (command: string, args: readonly string[], options?: TrustCommandOptions) => TrustCommandResult;
23
+ export declare const runTrustCommand: TrustCommandRunner;
24
+ export declare function trustCommandSucceeded(result: TrustCommandResult): boolean;
25
+ export declare function trustCommandMissing(result: TrustCommandResult): boolean;
26
+ /** Uppercase hexadecimal SHA-1, the key macOS and Windows use for trust. */
27
+ export declare function certificateSha1(certificatePath: string): string;
28
+ export declare function macosLoginKeychain(homeDirectory: string): string;
29
+ /**
30
+ * The same effect check on setup readback and in doctor: the exact leaf and
31
+ * intermediate must evaluate for TLS server use and the exact host through the
32
+ * user's effective trust settings.
33
+ */
34
+ export declare function macosVerifyCertArguments(leafCertificatePath: string, intermediateCertificatePath: string, hostname: string): string[];
35
+ /**
36
+ * The NSS shared database Chromium reads on Linux. Since M146 Chromium
37
+ * defaults to `$HOME/.local/share/pki/nssdb`, but an existing legacy
38
+ * `$HOME/.pki/nssdb` takes precedence
39
+ * (chromium/src docs/linux/cert_management.md).
40
+ */
41
+ export declare function chromiumNssDatabase(homeDirectory: string, pathExists?: (path: string) => boolean): string;
42
+ export declare function shellQuote(value: string): string;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runTrustCommand = exports.EBK_LOCAL_ROOT_LABEL = void 0;
4
+ exports.trustCommandSucceeded = trustCommandSucceeded;
5
+ exports.trustCommandMissing = trustCommandMissing;
6
+ exports.certificateSha1 = certificateSha1;
7
+ exports.macosLoginKeychain = macosLoginKeychain;
8
+ exports.macosVerifyCertArguments = macosVerifyCertArguments;
9
+ exports.chromiumNssDatabase = chromiumNssDatabase;
10
+ exports.shellQuote = shellQuote;
11
+ const node_child_process_1 = require("node:child_process");
12
+ const node_crypto_1 = require("node:crypto");
13
+ const node_fs_1 = require("node:fs");
14
+ const node_path_1 = require("node:path");
15
+ /**
16
+ * Operating-system trust-store plumbing shared by `ebk dev setup --trust` and
17
+ * `ebk dev doctor`. Every command goes through an injectable runner so the
18
+ * unit proofs assert exact argv without touching a real trust store.
19
+ */
20
+ exports.EBK_LOCAL_ROOT_LABEL = 'Empire Builder Kit Local Root';
21
+ const runTrustCommand = (command, args, options = {}) => {
22
+ const result = (0, node_child_process_1.spawnSync)(command, [...args], {
23
+ encoding: 'utf8',
24
+ ...(options.env ? { env: options.env } : {}),
25
+ stdio: options.interactive ? 'inherit' : ['ignore', 'pipe', 'pipe'],
26
+ ...(options.timeoutMs ? { timeout: options.timeoutMs } : {}),
27
+ windowsHide: true,
28
+ });
29
+ return {
30
+ ...(result.error
31
+ ? { error: result.error }
32
+ : undefined),
33
+ status: result.status,
34
+ stderr: typeof result.stderr === 'string' ? result.stderr : '',
35
+ stdout: typeof result.stdout === 'string' ? result.stdout : '',
36
+ };
37
+ };
38
+ exports.runTrustCommand = runTrustCommand;
39
+ function trustCommandSucceeded(result) {
40
+ return !result.error && result.status === 0;
41
+ }
42
+ function trustCommandMissing(result) {
43
+ return result.error?.code === 'ENOENT';
44
+ }
45
+ /** Uppercase hexadecimal SHA-1, the key macOS and Windows use for trust. */
46
+ function certificateSha1(certificatePath) {
47
+ return new node_crypto_1.X509Certificate((0, node_fs_1.readFileSync)(certificatePath)).fingerprint.replace(/:/g, '');
48
+ }
49
+ function macosLoginKeychain(homeDirectory) {
50
+ return (0, node_path_1.join)(homeDirectory, 'Library', 'Keychains', 'login.keychain-db');
51
+ }
52
+ /**
53
+ * The same effect check on setup readback and in doctor: the exact leaf and
54
+ * intermediate must evaluate for TLS server use and the exact host through the
55
+ * user's effective trust settings.
56
+ */
57
+ function macosVerifyCertArguments(leafCertificatePath, intermediateCertificatePath, hostname) {
58
+ return [
59
+ 'verify-cert',
60
+ '-L',
61
+ '-q',
62
+ '-c',
63
+ leafCertificatePath,
64
+ '-c',
65
+ intermediateCertificatePath,
66
+ '-p',
67
+ 'ssl',
68
+ '-n',
69
+ hostname,
70
+ ];
71
+ }
72
+ /**
73
+ * The NSS shared database Chromium reads on Linux. Since M146 Chromium
74
+ * defaults to `$HOME/.local/share/pki/nssdb`, but an existing legacy
75
+ * `$HOME/.pki/nssdb` takes precedence
76
+ * (chromium/src docs/linux/cert_management.md).
77
+ */
78
+ function chromiumNssDatabase(homeDirectory, pathExists = node_fs_1.existsSync) {
79
+ const legacy = (0, node_path_1.join)(homeDirectory, '.pki', 'nssdb');
80
+ return pathExists(legacy)
81
+ ? legacy
82
+ : (0, node_path_1.join)(homeDirectory, '.local', 'share', 'pki', 'nssdb');
83
+ }
84
+ function shellQuote(value) {
85
+ return `'${value.replace(/'/g, `'\\''`)}'`;
86
+ }
87
+ //# sourceMappingURL=trust-store.js.map
@@ -6,6 +6,12 @@ export interface CompositionOwnedPath {
6
6
  path: string;
7
7
  }
8
8
  export interface RecordCompositionOwnershipOptions {
9
+ /**
10
+ * Lets this call change a recorded Function's access. Only the generator
11
+ * that rewrites the Function's managed infrastructure in the same run may
12
+ * set it; every other writer keeps a Function's recorded access.
13
+ */
14
+ allowAccessChange?: boolean;
9
15
  compositions: GeneratedCompositionOwnership[];
10
16
  foundation?: GeneratedOwnershipRecord['foundation'];
11
17
  paths: CompositionOwnedPath[];
@@ -17,4 +23,5 @@ export declare function restampProductSliceOwnership(tree: Tree, slice: string,
17
23
  }): void;
18
24
  export declare function restampFoundationOwnership(tree: Tree): void;
19
25
  export declare function restampWorkspaceOwnership(tree: Tree): void;
26
+ export declare function restampSiteOwnership(tree: Tree): void;
20
27
  export declare function recordCompositionOwnership(tree: Tree, options: RecordCompositionOwnershipOptions): void;
@@ -3,83 +3,86 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.restampProductSliceOwnership = restampProductSliceOwnership;
4
4
  exports.restampFoundationOwnership = restampFoundationOwnership;
5
5
  exports.restampWorkspaceOwnership = restampWorkspaceOwnership;
6
+ exports.restampSiteOwnership = restampSiteOwnership;
6
7
  exports.recordCompositionOwnership = recordCompositionOwnership;
7
8
  const deterministic_order_js_1 = require("../deterministic-order.js");
8
9
  const node_path_1 = require("node:path");
9
10
  const json_ownership_js_1 = require("./json-ownership.js");
10
11
  const foundation_record_js_1 = require("./foundation-record.js");
11
12
  const record_js_1 = require("./record.js");
13
+ const site_record_js_1 = require("./site-record.js");
12
14
  const workspace_record_js_1 = require("./workspace-record.js");
13
15
  function json(value) {
14
16
  return `${JSON.stringify(value, null, 2)}\n`;
15
17
  }
16
- function restampProductSliceOwnership(tree, slice, options = {}) {
17
- const root = node_path_1.posix.join('packages', slice);
18
- const ownershipPath = node_path_1.posix.join(root, '.ebk/ownership.json');
19
- const source = tree.read(ownershipPath, 'utf8');
18
+ // One restamper for every ownership record kind. Each kind keeps its own
19
+ // validator, so the root site record stays stricter than the others.
20
+ function restampOwnershipRecord(tree, record) {
21
+ const source = tree.read(record.ownershipPath, 'utf8');
20
22
  if (source === null) {
21
- throw new Error(`Product Slice ownership metadata is missing at ${ownershipPath}.`);
23
+ throw new Error(`${record.label} ownership metadata is missing${record.namesMissingRecordPath ? ` at ${record.ownershipPath}` : ''}.`);
22
24
  }
23
- const result = (0, record_js_1.validateGeneratedOwnershipRecord)(JSON.parse(source));
25
+ const result = record.validate(JSON.parse(source));
24
26
  if (!result.valid) {
25
- throw new Error('Product Slice ownership metadata is invalid after generation.');
27
+ throw new Error(`${record.label} ownership metadata is invalid after generation.`);
26
28
  }
27
- tree.write(ownershipPath, json({
29
+ const paths = result.value.paths.map((entry) => {
30
+ if (record.preserveSeeded && entry.mode === 'seeded') {
31
+ return entry;
32
+ }
33
+ const contents = tree.read(record.root === '' ? entry.path : node_path_1.posix.join(record.root, entry.path), 'utf8');
34
+ if (contents === null) {
35
+ throw new Error(`Generated ${record.pathLabel} path does not exist: ${entry.path}.`);
36
+ }
37
+ return { ...entry, sha256: (0, json_ownership_js_1.hashOwnedContent)(contents, entry) };
38
+ });
39
+ tree.write(record.ownershipPath, json({
28
40
  ...result.value,
29
- paths: result.value.paths.map((entry) => {
30
- if (options.preserveSeeded && entry.mode === 'seeded') {
31
- return entry;
32
- }
33
- const contents = tree.read(node_path_1.posix.join(root, entry.path), 'utf8');
34
- if (contents === null) {
35
- throw new Error(`Generated owned path does not exist: ${entry.path}.`);
36
- }
37
- return { ...entry, sha256: (0, json_ownership_js_1.hashOwnedContent)(contents, entry) };
38
- }),
41
+ paths: record.sortPaths
42
+ ? paths.sort((left, right) => (0, deterministic_order_js_1.compareUtf16)(left.path, right.path))
43
+ : paths,
39
44
  }));
40
45
  }
46
+ function restampProductSliceOwnership(tree, slice, options = {}) {
47
+ const root = node_path_1.posix.join('packages', slice);
48
+ restampOwnershipRecord(tree, {
49
+ label: 'Product Slice',
50
+ namesMissingRecordPath: true,
51
+ ownershipPath: node_path_1.posix.join(root, '.ebk/ownership.json'),
52
+ pathLabel: 'owned',
53
+ preserveSeeded: options.preserveSeeded,
54
+ root,
55
+ validate: record_js_1.validateGeneratedOwnershipRecord,
56
+ });
57
+ }
41
58
  function restampFoundationOwnership(tree) {
42
59
  const root = 'packages/foundation';
43
- const ownershipPath = node_path_1.posix.join(root, '.ebk/ownership.json');
44
- const source = tree.read(ownershipPath, 'utf8');
45
- if (source === null) {
46
- throw new Error('Standard Foundation ownership metadata is missing.');
47
- }
48
- const result = (0, foundation_record_js_1.validateFoundationOwnershipRecord)(JSON.parse(source));
49
- if (!result.valid) {
50
- throw new Error('Standard Foundation ownership metadata is invalid after generation.');
51
- }
52
- tree.write(ownershipPath, json({
53
- ...result.value,
54
- paths: result.value.paths.map((entry) => {
55
- const contents = tree.read(node_path_1.posix.join(root, entry.path), 'utf8');
56
- if (contents === null) {
57
- throw new Error(`Generated Foundation path does not exist: ${entry.path}.`);
58
- }
59
- return { ...entry, sha256: (0, json_ownership_js_1.hashOwnedContent)(contents, entry) };
60
- }),
61
- }));
60
+ restampOwnershipRecord(tree, {
61
+ label: 'Standard Foundation',
62
+ ownershipPath: node_path_1.posix.join(root, '.ebk/ownership.json'),
63
+ pathLabel: 'Foundation',
64
+ root,
65
+ validate: foundation_record_js_1.validateFoundationOwnershipRecord,
66
+ });
62
67
  }
63
68
  function restampWorkspaceOwnership(tree) {
64
- const ownershipPath = '.ebk/ownership.json';
65
- const source = tree.read(ownershipPath, 'utf8');
66
- if (source === null) {
67
- throw new Error('Workspace ownership metadata is missing.');
68
- }
69
- const result = (0, workspace_record_js_1.validateWorkspaceOwnershipRecord)(JSON.parse(source));
70
- if (!result.valid) {
71
- throw new Error('Workspace ownership metadata is invalid after generation.');
72
- }
73
- tree.write(ownershipPath, json({
74
- ...result.value,
75
- paths: result.value.paths.map((entry) => {
76
- const contents = tree.read(entry.path, 'utf8');
77
- if (contents === null) {
78
- throw new Error(`Generated workspace path does not exist: ${entry.path}.`);
79
- }
80
- return { ...entry, sha256: (0, json_ownership_js_1.hashOwnedContent)(contents, entry) };
81
- }),
82
- }));
69
+ restampOwnershipRecord(tree, {
70
+ label: 'Workspace',
71
+ ownershipPath: '.ebk/ownership.json',
72
+ pathLabel: 'workspace',
73
+ root: '',
74
+ validate: workspace_record_js_1.validateWorkspaceOwnershipRecord,
75
+ });
76
+ }
77
+ function restampSiteOwnership(tree) {
78
+ restampOwnershipRecord(tree, {
79
+ label: 'Root site',
80
+ ownershipPath: site_record_js_1.SITE_OWNERSHIP_PATH,
81
+ pathLabel: 'root site',
82
+ root: node_path_1.posix.dirname(node_path_1.posix.dirname(site_record_js_1.SITE_OWNERSHIP_PATH)),
83
+ sortPaths: true,
84
+ validate: site_record_js_1.validateSiteOwnershipRecord,
85
+ });
83
86
  }
84
87
  function recordCompositionOwnership(tree, options) {
85
88
  const root = node_path_1.posix.join('packages', options.slice);
@@ -127,6 +130,11 @@ function recordCompositionOwnership(tree, options) {
127
130
  if (previous && previous.feature !== composition.feature) {
128
131
  throw new Error(`Composition ${composition.kind} ${composition.name} is already bound to feature ${previous.feature}.`);
129
132
  }
133
+ if (previous &&
134
+ previous.authentication !== composition.authentication &&
135
+ options.allowAccessChange !== true) {
136
+ throw new Error(`Composition ${composition.kind} ${composition.name} is recorded as ${previous.authentication ?? 'signed-in'}; only function-access changes who may call it.`);
137
+ }
130
138
  compositions.set(identity, composition);
131
139
  }
132
140
  const ownership = {
@@ -3,4 +3,5 @@ export * from './foundation-record.js';
3
3
  export * from './hash.js';
4
4
  export * from './json-ownership.js';
5
5
  export * from './record.js';
6
+ export * from './site-record.js';
6
7
  export * from './workspace-record.js';
@@ -6,5 +6,6 @@ tslib_1.__exportStar(require("./foundation-record.js"), exports);
6
6
  tslib_1.__exportStar(require("./hash.js"), exports);
7
7
  tslib_1.__exportStar(require("./json-ownership.js"), exports);
8
8
  tslib_1.__exportStar(require("./record.js"), exports);
9
+ tslib_1.__exportStar(require("./site-record.js"), exports);
9
10
  tslib_1.__exportStar(require("./workspace-record.js"), exports);
10
11
  //# sourceMappingURL=index.js.map
@@ -7,7 +7,14 @@ export declare const GENERATED_COMPOSITION_KINDS: readonly ["function", "job", "
7
7
  export type GeneratedPathMode = (typeof GENERATED_PATH_MODES)[number];
8
8
  export type GeneratedPathOrigin = (typeof GENERATED_PATH_ORIGINS)[number];
9
9
  export type GeneratedCompositionKind = (typeof GENERATED_COMPOSITION_KINDS)[number];
10
+ /**
11
+ * A Function's recorded access. Only an anonymous Function records it; an
12
+ * absent field means signed-in, so every Function recorded before the field
13
+ * existed requires a signed-in caller.
14
+ */
15
+ export declare const ANONYMOUS_FUNCTION_AUTHENTICATION = "anonymous";
10
16
  export interface GeneratedCompositionOwnership {
17
+ authentication?: typeof ANONYMOUS_FUNCTION_AUTHENTICATION;
11
18
  feature: string;
12
19
  kind: GeneratedCompositionKind;
13
20
  name: string;
@@ -78,7 +85,19 @@ export declare const generatedOwnershipSchema: {
78
85
  readonly compositions: {
79
86
  readonly items: {
80
87
  readonly additionalProperties: false;
88
+ readonly dependentSchemas: {
89
+ readonly authentication: {
90
+ readonly properties: {
91
+ readonly kind: {
92
+ readonly const: "function";
93
+ };
94
+ };
95
+ };
96
+ };
81
97
  readonly properties: {
98
+ readonly authentication: {
99
+ readonly const: "anonymous";
100
+ };
82
101
  readonly feature: {
83
102
  readonly pattern: string;
84
103
  readonly type: "string";