@powerhousedao/switchboard 6.3.0-dev.9 → 6.4.0-next.1

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 (68) hide show
  1. package/.tsbuild/test/boot-helpers.d.ts +2 -1
  2. package/.tsbuild/test/boot-helpers.d.ts.map +1 -1
  3. package/.tsbuild/test/boot-identity-files.test.d.ts +2 -0
  4. package/.tsbuild/test/boot-identity-files.test.d.ts.map +1 -0
  5. package/.tsbuild/tsconfig.tsbuildinfo +1 -1
  6. package/CHANGELOG.md +59 -0
  7. package/README.md +12 -10
  8. package/dist/boot.d.mts +1 -1
  9. package/dist/boot.mjs +1 -1
  10. package/dist/config/from-env.d.mts +1 -1
  11. package/dist/config/from-env.d.mts.map +1 -1
  12. package/dist/config/from-env.mjs +3 -3
  13. package/dist/config/schema.d.mts +1 -1
  14. package/dist/config/schema.mjs +3 -3
  15. package/dist/{from-env-DKK_wPrO.mjs → from-env-CLImR6qa.mjs} +4 -28
  16. package/dist/from-env-CLImR6qa.mjs.map +1 -0
  17. package/dist/index.mjs +3 -3
  18. package/dist/migrate.mjs +9 -4
  19. package/dist/migrate.mjs.map +1 -1
  20. package/dist/{plugin-host-tTjDTNz0.d.mts → plugin-host-Z-4Ruypj.d.mts} +19 -2
  21. package/dist/plugin-host-Z-4Ruypj.d.mts.map +1 -0
  22. package/dist/plugins/ai.d.mts +1 -1
  23. package/dist/plugins/attachments.d.mts +1 -1
  24. package/dist/plugins/attachments.mjs +3 -3
  25. package/dist/plugins/mcp.d.mts +1 -1
  26. package/dist/plugins/privacy.d.mts +1 -1
  27. package/dist/plugins/workflows.d.mts +2 -2
  28. package/dist/plugins/workflows.mjs +3 -3
  29. package/dist/{schema-BJ-OFAox.mjs → schema-BbwISVSO.mjs} +15 -13
  30. package/dist/schema-BbwISVSO.mjs.map +1 -0
  31. package/dist/{schema-w1lShimw.d.mts → schema-CZsLzAZg.d.mts} +9 -4
  32. package/dist/schema-CZsLzAZg.d.mts.map +1 -0
  33. package/dist/{server-BS-PFzoK.mjs → server-BMRdMNvC.mjs} +172 -244
  34. package/dist/server-BMRdMNvC.mjs.map +1 -0
  35. package/dist/server.d.mts +2 -2
  36. package/dist/server.d.mts.map +1 -1
  37. package/dist/server.mjs +4 -4
  38. package/dist/{types-Bk4T4D9F.d.mts → types-Crizw8W4.d.mts} +13 -8
  39. package/dist/types-Crizw8W4.d.mts.map +1 -0
  40. package/dist/{utils-Cm0TE6dP.mjs → utils-D8yHRVjT.mjs} +4 -18
  41. package/dist/{utils-Cm0TE6dP.mjs.map → utils-D8yHRVjT.mjs.map} +1 -1
  42. package/dist/utils.d.mts +1 -6
  43. package/dist/utils.d.mts.map +1 -1
  44. package/dist/utils.mjs +4 -4
  45. package/dist/{workflows-mdYUh3Us.mjs → workflows-D2r6IKou.mjs} +4 -4
  46. package/dist/{workflows-mdYUh3Us.mjs.map → workflows-D2r6IKou.mjs.map} +1 -1
  47. package/package.json +17 -17
  48. package/test/ai-gateway.test.ts +0 -2
  49. package/test/boot-auth-config.test.ts +1 -1
  50. package/test/boot-helpers.ts +3 -1
  51. package/test/boot-identity-files.test.ts +68 -0
  52. package/test/boot-mcp-auth.test.ts +0 -1
  53. package/test/boot-mcp-enabled.test.ts +0 -2
  54. package/test/boot-port-zero.test.ts +1 -2
  55. package/test/boot-ready-drives.test.ts +1 -2
  56. package/test/config-from-env.test.ts +0 -9
  57. package/test/config-merge.test.ts +47 -47
  58. package/test/config-schema.test.ts +16 -4
  59. package/test/default-composition.test.ts +61 -65
  60. package/test/default-drive-protocol-versions.test.ts +13 -6
  61. package/test/default-drive-slug.test.ts +6 -11
  62. package/test/plugin-presence.test.ts +15 -16
  63. package/dist/from-env-DKK_wPrO.mjs.map +0 -1
  64. package/dist/plugin-host-tTjDTNz0.d.mts.map +0 -1
  65. package/dist/schema-BJ-OFAox.mjs.map +0 -1
  66. package/dist/schema-w1lShimw.d.mts.map +0 -1
  67. package/dist/server-BS-PFzoK.mjs.map +0 -1
  68. package/dist/types-Bk4T4D9F.d.mts.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/switchboard",
3
3
  "type": "module",
4
- "version": "6.3.0-dev.9",
4
+ "version": "6.4.0-next.1",
5
5
  "main": "dist/index.mjs",
6
6
  "exports": {
7
7
  ".": {
@@ -99,23 +99,23 @@
99
99
  "@opentelemetry/sdk-node": "^0.218.0",
100
100
  "@opentelemetry/sdk-trace-base": "^2.7.1",
101
101
  "@opentelemetry/semantic-conventions": "^1.41.1",
102
- "@powerhousedao/config": "6.3.0-dev.9",
103
- "@powerhousedao/host-core": "6.3.0-dev.9",
104
- "@powerhousedao/opentelemetry-instrumentation-reactor": "6.3.0-dev.9",
105
- "@powerhousedao/reactor": "6.3.0-dev.9",
106
- "@powerhousedao/reactor-api": "6.3.0-dev.9",
107
- "@powerhousedao/reactor-attachments": "6.3.0-dev.9",
108
- "@powerhousedao/reactor-drive": "6.3.0-dev.9",
109
- "@powerhousedao/reactor-group": "6.3.0-dev.9",
110
- "@powerhousedao/reactor-privacy": "6.3.0-dev.9",
111
- "@powerhousedao/reactor-workflow": "6.3.0-dev.9",
112
- "@powerhousedao/shared": "6.3.0-dev.9",
113
- "@powerhousedao/workflow": "6.3.0-dev.9",
102
+ "@powerhousedao/config": "6.4.0-next.1",
103
+ "@powerhousedao/host-core": "6.4.0-next.1",
104
+ "@powerhousedao/opentelemetry-instrumentation-reactor": "6.4.0-next.1",
105
+ "@powerhousedao/reactor": "6.4.0-next.1",
106
+ "@powerhousedao/reactor-api": "6.4.0-next.1",
107
+ "@powerhousedao/reactor-attachments": "6.4.0-next.1",
108
+ "@powerhousedao/reactor-drive": "6.4.0-next.1",
109
+ "@powerhousedao/reactor-group": "6.4.0-next.1",
110
+ "@powerhousedao/reactor-privacy": "6.4.0-next.1",
111
+ "@powerhousedao/reactor-workflow": "6.4.0-next.1",
112
+ "@powerhousedao/shared": "6.4.0-next.1",
113
+ "@powerhousedao/workflow": "6.4.0-next.1",
114
114
  "@pyroscope/nodejs": "^0.4.5",
115
- "@renown/sdk": "6.3.0-dev.9",
115
+ "@renown/sdk": "6.4.0-next.1",
116
116
  "@sentry/node": "^10.53.1",
117
117
  "@sentry/opentelemetry": "^10.53.1",
118
- "document-model": "6.3.0-dev.9",
118
+ "document-model": "6.4.0-next.1",
119
119
  "dotenv": "^16.4.7",
120
120
  "express": "^4.22.1",
121
121
  "graphql": "^16",
@@ -131,7 +131,7 @@
131
131
  "@openfeature/core": "1.9.1",
132
132
  "@openfeature/env-var-provider": "0.3.1",
133
133
  "@openfeature/server-sdk": "1.19.0",
134
- "@powerhousedao/vetra": "6.3.0-dev.9",
134
+ "@powerhousedao/vetra": "6.4.0-next.1",
135
135
  "@types/express": "^4.17.25",
136
136
  "@types/node": "25.2.3",
137
137
  "@types/pg": "8.16.0",
@@ -143,7 +143,7 @@
143
143
  "vitest": "5.0.3"
144
144
  },
145
145
  "peerDependencies": {
146
- "@powerhousedao/vetra": "6.3.0-dev.9",
146
+ "@powerhousedao/vetra": "6.4.0-next.1",
147
147
  "react": ">=19.0.0",
148
148
  "vite": "^8.0.0"
149
149
  },
@@ -45,7 +45,6 @@ const ENV_KEYS = [
45
45
  "PH_REACTOR_DATABASE_URL",
46
46
  "PH_WORKFLOWS_SECRETS_MASTER_KEY",
47
47
  "MCP_ENABLED",
48
- "FEATURE_PLUGIN_HOST_ENABLED",
49
48
  "AUTH_ENABLED",
50
49
  "ADMINS",
51
50
  "RESOLVE_CALLER_IDENTITY",
@@ -178,7 +177,6 @@ beforeAll(async () => {
178
177
  for (const name of ENV_KEYS) delete process.env[name];
179
178
  process.env.PH_REACTOR_DATABASE_URL = join(tempRoot, "reactor-storage");
180
179
  process.env.PH_WORKFLOWS_SECRETS_MASTER_KEY = randomBytes(32).toString("hex");
181
- process.env.FEATURE_PLUGIN_HOST_ENABLED = "1";
182
180
  const configFile = join(tempRoot, "powerhouse.config.json");
183
181
  await writeFile(
184
182
  configFile,
@@ -118,7 +118,7 @@ describe("booting Switchboard with auth", () => {
118
118
  await expect(
119
119
  bootsWithAuth({ file: {}, env: { ACCESS: "members" } }),
120
120
  ).rejects.toThrow(
121
- "ACCESS=members is not supported; use ACCESS=licensed with Vetra's gate",
121
+ "ACCESS=members is not supported: use ACCESS=open (the default) or ACCESS=licensed",
122
122
  );
123
123
  }, 60_000);
124
124
 
@@ -3,7 +3,8 @@ import { callerOverEnv } from "../src/config/merge.js";
3
3
  import type { SwitchboardConfigInput } from "../src/config/schema.js";
4
4
  import { startSwitchboard, type SwitchboardDeps } from "../src/server.mjs";
5
5
 
6
- /** Boots the way an edge does: the caller's layer over `env`'s. */
6
+ /** Boots the way an edge does: the caller's layer over `env`'s. A
7
+ * `deps.pluginComposition` is a declared composition, as the runner passes. */
7
8
  export function bootSwitchboard(
8
9
  config: SwitchboardConfigInput,
9
10
  deps: SwitchboardDeps = {},
@@ -13,6 +14,7 @@ export function bootSwitchboard(
13
14
  callerOverEnv(
14
15
  switchboardConfigFromEnv(env, { logger: deps.logger }),
15
16
  config,
17
+ { declaredComposition: deps.pluginComposition !== undefined },
16
18
  ),
17
19
  deps,
18
20
  );
@@ -0,0 +1,68 @@
1
+ import { existsSync } from "node:fs";
2
+ import { mkdir, mkdtemp, rm } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import type { ILogger } from "document-model";
6
+ import { describe, expect, it, vi } from "vitest";
7
+ import type { startSwitchboard } from "../src/server.mjs";
8
+ import { bootSwitchboard } from "./boot-helpers.js";
9
+
10
+ function stubLogger(): ILogger {
11
+ const logger = {
12
+ verbose: vi.fn(),
13
+ debug: vi.fn(),
14
+ info: vi.fn(),
15
+ warn: vi.fn(),
16
+ error: vi.fn(),
17
+ child: vi.fn(),
18
+ };
19
+ logger.child.mockReturnValue(logger);
20
+ return logger as unknown as ILogger;
21
+ }
22
+
23
+ /**
24
+ * A switchboard whose identity names both of its files (`identity.keypairPath`
25
+ * and `identity.storagePath`) keeps them there: nothing lands in the `.ph` of
26
+ * the working directory, which is the project's when a package's switchboard
27
+ * runs in it.
28
+ */
29
+ describe("booting Switchboard with both identity files named", () => {
30
+ it("writes the keypair and the Renown user file there, and nothing under <cwd>/.ph", async () => {
31
+ const tempRoot = await mkdtemp(join(tmpdir(), "switchboard-identity-"));
32
+ const cwd = join(tempRoot, "project");
33
+ await mkdir(cwd);
34
+ const identity = join(tempRoot, "studio", "switchboard");
35
+ const previousCwd = process.cwd();
36
+ const previousDb = process.env.PH_REACTOR_DATABASE_URL;
37
+ process.env.PH_REACTOR_DATABASE_URL = join(tempRoot, "reactor-storage");
38
+ process.chdir(cwd);
39
+ let switchboard: Awaited<ReturnType<typeof startSwitchboard>> | undefined;
40
+ try {
41
+ switchboard = await bootSwitchboard(
42
+ {
43
+ server: { port: 0 },
44
+ storage: { readModel: { url: join(tempRoot, "read-model") } },
45
+ features: { workflows: false, mcp: false },
46
+ packages: { disableLocal: true },
47
+ identity: {
48
+ keypairPath: join(identity, ".keypair.json"),
49
+ storagePath: join(identity, ".renown.json"),
50
+ },
51
+ },
52
+ { logger: stubLogger() },
53
+ );
54
+ expect(existsSync(join(identity, ".keypair.json"))).toBe(true);
55
+ expect(existsSync(join(identity, ".renown.json"))).toBe(true);
56
+ expect(existsSync(join(cwd, ".ph"))).toBe(false);
57
+ await switchboard.shutdown();
58
+ switchboard = undefined;
59
+ expect(existsSync(join(cwd, ".ph"))).toBe(false);
60
+ } finally {
61
+ await switchboard?.shutdown();
62
+ process.chdir(previousCwd);
63
+ if (previousDb === undefined) delete process.env.PH_REACTOR_DATABASE_URL;
64
+ else process.env.PH_REACTOR_DATABASE_URL = previousDb;
65
+ await rm(tempRoot, { recursive: true, force: true, maxRetries: 10 });
66
+ }
67
+ }, 60_000);
68
+ });
@@ -52,7 +52,6 @@ const CALLERS: Caller[] = [...USERS, "anonymous"];
52
52
  const ENV_KEYS = [
53
53
  "PH_REACTOR_DATABASE_URL",
54
54
  "MCP_ENABLED",
55
- "FEATURE_PLUGIN_HOST_ENABLED",
56
55
  "AUTH_ENABLED",
57
56
  "ADMINS",
58
57
  "RESOLVE_CALLER_IDENTITY",
@@ -35,13 +35,11 @@ async function withSwitchboard(
35
35
  // resolution): under a declared one the mcp plugin owns options.mcp and
36
36
  // an MCP_ENABLED true is deliberately inert (presence in the composition
37
37
  // is the switch — rewire plan R2.2).
38
- "FEATURE_PLUGIN_HOST_ENABLED",
39
38
  ...Object.keys(env),
40
39
  ];
41
40
  const previous = names.map((name) => [name, process.env[name]] as const);
42
41
  process.env.PH_REACTOR_DATABASE_URL = join(tempRoot, "reactor-storage");
43
42
  delete process.env.MCP_ENABLED;
44
- delete process.env.FEATURE_PLUGIN_HOST_ENABLED;
45
43
  Object.assign(process.env, env);
46
44
  let switchboard: Awaited<ReturnType<typeof startSwitchboard>> | undefined;
47
45
 
@@ -21,14 +21,13 @@ function stubLogger(): ILogger {
21
21
  return logger as unknown as ILogger;
22
22
  }
23
23
 
24
- const ENV = ["PH_REACTOR_DATABASE_URL", "FEATURE_PLUGIN_HOST_ENABLED"];
24
+ const ENV = ["PH_REACTOR_DATABASE_URL"];
25
25
  let previousEnv: (readonly [string, string | undefined])[] = [];
26
26
  let tempRoots: string[] = [];
27
27
  let running: Switchboard[] = [];
28
28
 
29
29
  beforeEach(() => {
30
30
  previousEnv = ENV.map((name) => [name, process.env[name]] as const);
31
- delete process.env.FEATURE_PLUGIN_HOST_ENABLED;
32
31
  });
33
32
 
34
33
  afterEach(async () => {
@@ -24,14 +24,13 @@ function stubLogger(): ILogger {
24
24
  return logger as unknown as ILogger;
25
25
  }
26
26
 
27
- const ENV = ["PH_REACTOR_DATABASE_URL", "FEATURE_PLUGIN_HOST_ENABLED"];
27
+ const ENV = ["PH_REACTOR_DATABASE_URL"];
28
28
  let previousEnv: (readonly [string, string | undefined])[] = [];
29
29
  let tempRoots: string[] = [];
30
30
  let running: Promise<Switchboard>[] = [];
31
31
 
32
32
  beforeEach(() => {
33
33
  previousEnv = ENV.map((name) => [name, process.env[name]] as const);
34
- delete process.env.FEATURE_PLUGIN_HOST_ENABLED;
35
34
  });
36
35
 
37
36
  afterEach(async () => {
@@ -26,7 +26,6 @@ import { EnvVarProvider } from "@openfeature/env-var-provider";
26
26
  import { OpenFeature } from "@openfeature/server-sdk";
27
27
  import { binSwitchboardConfig } from "../src/config/bin.js";
28
28
  import { inspectionThrottleFromEnv } from "../src/inspection-throttle.mjs";
29
- import { pluginHostFromEnv } from "../src/plugin-host.mjs";
30
29
  import { resolvePrivacy } from "../src/privacy.mjs";
31
30
  import { resolveProjectionWorkerOptions } from "../src/projection-worker.mjs";
32
31
  import { resolveReactorFeatureFlags } from "../src/reactor-feature-flags.mjs";
@@ -136,7 +135,6 @@ const KEYS = [
136
135
  "MCP_ENABLED",
137
136
  "PH_WORKFLOWS_ENABLED",
138
137
  "DOCUMENT_MODEL_SUBGRAPHS_ENABLED",
139
- "FEATURE_PLUGIN_HOST_ENABLED",
140
138
  "PH_PRIVACY_ENABLED",
141
139
  "PH_PRIVACY_DEPLOYMENT_SECRET",
142
140
  "PH_PRIVACY_INTERVAL_MS",
@@ -176,7 +174,6 @@ const ROWS: Record<string, Env> = {
176
174
  DYNAMIC_MODEL_LOADING: "true",
177
175
  PH_REGISTRY_URL: "http://localhost:8080",
178
176
  PH_REGISTRY_PACKAGES: "@acme/a, @acme/b",
179
- FEATURE_PLUGIN_HOST_ENABLED: "1",
180
177
  PH_CATCH_UP_PRIORITY: "3",
181
178
  },
182
179
  "Postgres with workers": {
@@ -329,12 +326,6 @@ describe("switchboardConfigFromEnv matches today's env reads", () => {
329
326
  await expect(
330
327
  featureFlags.getBooleanValue("DOCUMENT_MODEL_SUBGRAPHS_ENABLED", true),
331
328
  ).resolves.toBe(config.features.documentModelSubgraphs);
332
- // Unset stays unset: it selects the default composition, not the flag.
333
- expect(config.features.pluginHost).toBe(
334
- row.FEATURE_PLUGIN_HOST_ENABLED === undefined
335
- ? undefined
336
- : pluginHostFromEnv(row),
337
- );
338
329
  });
339
330
 
340
331
  it("protocol", () => {
@@ -14,12 +14,23 @@ type Env = Record<string, string | undefined>;
14
14
 
15
15
  const silent = { warn: () => undefined } as unknown as ILogger;
16
16
 
17
- function resolved(env: Env, caller: SwitchboardConfigInput): SwitchboardConfig {
17
+ function resolved(
18
+ env: Env,
19
+ caller: SwitchboardConfigInput,
20
+ declaredComposition = false,
21
+ ): SwitchboardConfig {
18
22
  return switchboardConfigSchema.parse(
19
- callerOverEnv(switchboardConfigFromEnv(env, { logger: silent }), caller),
23
+ callerOverEnv(switchboardConfigFromEnv(env, { logger: silent }), caller, {
24
+ declaredComposition,
25
+ }),
20
26
  );
21
27
  }
22
28
 
29
+ /** As `resolved`, for a caller that boots a declared plugin composition. */
30
+ function declared(env: Env, caller: SwitchboardConfigInput): SwitchboardConfig {
31
+ return resolved(env, caller, true);
32
+ }
33
+
23
34
  describe("mergeSwitchboardConfig", () => {
24
35
  it("lets a later layer win per key and keeps the rest", () => {
25
36
  expect(
@@ -215,85 +226,78 @@ describe("callerOverEnv keeps each key's precedence", () => {
215
226
  },
216
227
  );
217
228
 
218
- it("lets PH_WORKFLOWS_ENABLED switch workflows off under the plugin host", () => {
219
- const env = {
220
- FEATURE_PLUGIN_HOST_ENABLED: "1",
221
- PH_WORKFLOWS_ENABLED: "false",
222
- };
223
- expect(resolved(env, {}).features.workflows).toBe(false);
229
+ it("lets PH_WORKFLOWS_ENABLED switch workflows off under a declared composition", () => {
230
+ const env = { PH_WORKFLOWS_ENABLED: "false" };
231
+ expect(declared(env, {}).features.workflows).toBe(false);
224
232
  expect(
225
- resolved(env, { features: { workflows: true } }).features.workflows,
233
+ declared(env, { features: { workflows: true } }).features.workflows,
226
234
  ).toBe(false);
227
235
  });
228
236
 
229
- it("ignores an env true for MCP_ENABLED and PH_WORKFLOWS_ENABLED under the plugin host", () => {
230
- const env = {
231
- FEATURE_PLUGIN_HOST_ENABLED: "1",
232
- MCP_ENABLED: "true",
233
- PH_WORKFLOWS_ENABLED: "true",
234
- };
235
- const host = resolved(env, {});
236
- expect(host.features.pluginHost).toBe(true);
237
+ it("ignores an env true for MCP_ENABLED and PH_WORKFLOWS_ENABLED under a declared composition", () => {
238
+ const env = { MCP_ENABLED: "true", PH_WORKFLOWS_ENABLED: "true" };
239
+ const host = declared(env, {});
237
240
  expect(host.features.mcp).toBeUndefined();
238
241
  expect(host.features.workflows).toBeUndefined();
239
- const withCaller = resolved(env, {
242
+ const withCaller = declared(env, {
240
243
  features: { mcp: false, workflows: true },
241
244
  });
242
245
  expect(withCaller.features.mcp).toBe(false);
243
246
  expect(withCaller.features.workflows).toBe(true);
244
- // Not carved: classic on both paths.
247
+ // Not carved: the same under both compositions.
245
248
  expect(
246
- resolved({ ...env, INSPECTION_ENABLED: "false" }, {}).inspection.enabled,
249
+ declared({ ...env, INSPECTION_ENABLED: "false" }, {}).inspection.enabled,
247
250
  ).toBe(false);
248
251
  });
252
+
253
+ it("FEATURE_PLUGIN_HOST_ENABLED declares nothing any more", () => {
254
+ const env = {
255
+ FEATURE_PLUGIN_HOST_ENABLED: "1",
256
+ MCP_ENABLED: "true",
257
+ PH_WORKFLOWS_ENABLED: "true",
258
+ };
259
+ const config = resolved(env, {});
260
+ expect(config.features.mcp).toBe(true);
261
+ expect(config.features.workflows).toBe(true);
262
+ });
249
263
  });
250
264
 
251
265
  describe("an env false always wins", () => {
252
- const host = { FEATURE_PLUGIN_HOST_ENABLED: "1" };
253
-
254
- it("MCP_ENABLED=false beats a caller's mcp, classic and plugin host", () => {
266
+ it("MCP_ENABLED=false beats a caller's mcp, default and declared composition", () => {
255
267
  const caller = { features: { mcp: true } };
256
268
  expect(resolved({ MCP_ENABLED: "false" }, caller).features.mcp).toBe(false);
257
- expect(
258
- resolved({ ...host, MCP_ENABLED: "false" }, caller).features.mcp,
259
- ).toBe(false);
260
- expect(resolved({ ...host, MCP_ENABLED: "false" }, {}).features.mcp).toBe(
261
- false,
262
- );
269
+ expect(declared({ MCP_ENABLED: "false" }, caller).features.mcp).toBe(false);
270
+ expect(declared({ MCP_ENABLED: "false" }, {}).features.mcp).toBe(false);
263
271
  });
264
272
 
265
- it("MCP_ENABLED=false beats the bin's own features.mcp under the plugin host", () => {
273
+ it("MCP_ENABLED=false beats the bin's own features.mcp", () => {
266
274
  const config = switchboardConfigSchema.parse(
267
275
  binSwitchboardConfig(
268
- { ...host, MCP_ENABLED: "false" },
276
+ { MCP_ENABLED: "false" },
269
277
  { migratePglite: false, logger: silent },
270
278
  ),
271
279
  );
272
- expect(config.features.pluginHost).toBe(true);
273
280
  expect(config.features.mcp).toBe(false);
274
281
  });
275
282
 
276
- it("DOCUMENT_MODEL_SUBGRAPHS_ENABLED=false beats a caller's, classic and plugin host", () => {
283
+ it("DOCUMENT_MODEL_SUBGRAPHS_ENABLED=false beats a caller's, default and declared composition", () => {
277
284
  const caller = { features: { documentModelSubgraphs: true } };
278
285
  const env = { DOCUMENT_MODEL_SUBGRAPHS_ENABLED: "false" };
279
286
  expect(resolved(env, caller).features.documentModelSubgraphs).toBe(false);
280
- expect(
281
- resolved({ ...host, ...env }, caller).features.documentModelSubgraphs,
282
- ).toBe(false);
287
+ expect(declared(env, caller).features.documentModelSubgraphs).toBe(false);
283
288
  });
284
289
 
285
- it("PH_WORKFLOWS_ENABLED=false beats a caller's, classic and plugin host", () => {
290
+ it("PH_WORKFLOWS_ENABLED=false beats a caller's, default and declared composition", () => {
286
291
  const caller = { features: { workflows: true } };
287
292
  expect(
288
293
  resolved({ PH_WORKFLOWS_ENABLED: "false" }, caller).features.workflows,
289
294
  ).toBe(false);
290
295
  expect(
291
- resolved({ ...host, PH_WORKFLOWS_ENABLED: "false" }, caller).features
292
- .workflows,
296
+ declared({ PH_WORKFLOWS_ENABLED: "false" }, caller).features.workflows,
293
297
  ).toBe(false);
294
298
  });
295
299
 
296
- it("PH_PRIVACY_ENABLED=false beats a caller's, classic and plugin host", () => {
300
+ it("PH_PRIVACY_ENABLED=false beats a caller's, default and declared composition", () => {
297
301
  const caller = {
298
302
  features: {
299
303
  privacy: { enabled: true, deploymentSecret: "x".repeat(32) },
@@ -301,21 +305,17 @@ describe("an env false always wins", () => {
301
305
  };
302
306
  const env = { PH_PRIVACY_ENABLED: "false" };
303
307
  expect(resolved(env, caller).features.privacy.enabled).toBe(false);
304
- expect(resolved({ ...host, ...env }, caller).features.privacy.enabled).toBe(
305
- false,
306
- );
308
+ expect(declared(env, caller).features.privacy.enabled).toBe(false);
307
309
  expect(
308
310
  resolved({ PH_PRIVACY_ENABLED: "true" }, caller).features.privacy.enabled,
309
311
  ).toBe(true);
310
312
  });
311
313
 
312
- it("INSPECTION_ENABLED=false beats a caller's, classic and plugin host", () => {
314
+ it("INSPECTION_ENABLED=false beats a caller's, default and declared composition", () => {
313
315
  const caller = { inspection: { enabled: true } };
314
316
  const env = { INSPECTION_ENABLED: "false" };
315
317
  expect(resolved(env, caller).inspection.enabled).toBe(false);
316
- expect(resolved({ ...host, ...env }, caller).inspection.enabled).toBe(
317
- false,
318
- );
318
+ expect(declared(env, caller).inspection.enabled).toBe(false);
319
319
  });
320
320
  });
321
321
 
@@ -62,18 +62,16 @@ describe("switchboardConfigSchema", () => {
62
62
  documentModelSubgraphs: true,
63
63
  privacy: { enabled: false },
64
64
  });
65
- // Unset is its own state: the plugin host with the default composition.
66
- expect(config.features.pluginHost).toBeUndefined();
67
65
  expect(config.attachments).toEqual({ storage: { kind: "filesystem" } });
68
66
  expect(config.auth.documentPermissions).toEqual({ enabled: false });
69
67
  expect(config.auth.access).toEqual({ mode: "open" });
70
68
  });
71
69
 
72
- it("refuses ACCESS=members, pointing at licensed", () => {
70
+ it("refuses ACCESS=members like any other unknown value", () => {
73
71
  expect(() =>
74
72
  switchboardConfigSchema.parse({ auth: { access: { mode: "members" } } }),
75
73
  ).toThrow(
76
- "ACCESS=members is not supported; use ACCESS=licensed with Vetra's gate",
74
+ "ACCESS=members is not supported: use ACCESS=open (the default) or ACCESS=licensed",
77
75
  );
78
76
  });
79
77
 
@@ -173,6 +171,20 @@ describe("switchboardConfigLayerSchema", () => {
173
171
  expect(layer.safeParse({ server: { basePath: "/x" } }).success).toBe(true);
174
172
  });
175
173
 
174
+ it("takes the identity's Renown user file next to its keypair", () => {
175
+ const identity = {
176
+ keypairPath: "/id/.keypair.json",
177
+ storagePath: "/id/.renown.json",
178
+ };
179
+ expect(layer.parse({ identity })).toEqual({ identity });
180
+ expect(switchboardConfigSchema.parse({ identity }).identity).toEqual(
181
+ identity,
182
+ );
183
+ expect(layer.safeParse({ identity: { storagePath: 1 } }).success).toBe(
184
+ false,
185
+ );
186
+ });
187
+
176
188
  it("emits a JSON Schema once the map key is omitted", () => {
177
189
  const schema = z.toJSONSchema(
178
190
  switchboardConfigLayerSchema(["processorConfig"]),