@wildo-ai/platform-config-lib 1.1.1 → 1.1.3

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 (91) hide show
  1. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +67 -1
  2. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  3. package/dist/esm/bootstrap/bootstrap.schemas.js +51 -2
  4. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  5. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +2 -3
  6. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  7. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +2 -3
  8. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  9. package/dist/esm/bootstrap/runtime-network-topology.d.ts +0 -1
  10. package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
  11. package/dist/esm/bootstrap/runtime-network-topology.js +0 -2
  12. package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
  13. package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts +52 -0
  14. package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts.map +1 -0
  15. package/dist/esm/bootstrap/wildo-owner-organization.contracts.js +5 -0
  16. package/dist/esm/bootstrap/wildo-owner-organization.contracts.js.map +1 -0
  17. package/dist/esm/config-authoring.entry.d.ts +1 -2
  18. package/dist/esm/config-authoring.entry.d.ts.map +1 -1
  19. package/dist/esm/config-authoring.entry.js +35 -2
  20. package/dist/esm/config-authoring.entry.js.map +1 -1
  21. package/dist/esm/index.d.ts +1 -0
  22. package/dist/esm/index.d.ts.map +1 -1
  23. package/dist/esm/index.js +1 -0
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +0 -20
  26. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
  27. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +0 -1
  28. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
  29. package/dist/esm/project-config/define-framework-config.d.ts +4 -4
  30. package/dist/esm/project-config/define-infra-env-config.d.ts +3 -39
  31. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
  32. package/dist/esm/project-config/define-infra-env-config.js +2 -2
  33. package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
  34. package/dist/esm/project-config/define-saas-config.d.ts +378 -14
  35. package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
  36. package/dist/esm/project-config/define-saas-config.js +122 -11
  37. package/dist/esm/project-config/define-saas-config.js.map +1 -1
  38. package/dist/esm/project-config/provider-companion-discovery.d.ts +74 -1
  39. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  40. package/dist/esm/project-config/provider-companion-discovery.js +203 -6
  41. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  42. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +42 -16
  43. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
  44. package/dist/esm/project-config/provider-runtime-artifacts.js +75 -6
  45. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
  46. package/dist/esm/project-config/shared/backing-services.schemas.d.ts +7 -43
  47. package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
  48. package/dist/esm/project-config/shared/backing-services.schemas.js +13 -30
  49. package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
  50. package/dist/esm/project-config/shared/csp-emit.d.ts +36 -5
  51. package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
  52. package/dist/esm/project-config/shared/csp-emit.js +65 -5
  53. package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
  54. package/dist/esm/project-config/shared/csp.schemas.d.ts +46 -10
  55. package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
  56. package/dist/esm/project-config/shared/csp.schemas.js +45 -10
  57. package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
  58. package/dist/esm/project-config/shared/environment.schemas.d.ts +8 -6
  59. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  60. package/dist/esm/project-config/shared/environment.schemas.js +7 -5
  61. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  62. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +18 -3
  63. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
  64. package/dist/esm/project-config/shared/infra-providers.schemas.js +34 -2
  65. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
  66. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts +0 -2
  67. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
  68. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js +0 -2
  69. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
  70. package/dist/esm/project-config/shared/k8s-utils.d.ts +70 -10
  71. package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
  72. package/dist/esm/project-config/shared/k8s-utils.js +75 -11
  73. package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
  74. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts +15 -15
  75. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js +15 -15
  76. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
  77. package/dist/esm/project-config/shared/platform-services.schemas.d.ts +30 -0
  78. package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
  79. package/dist/esm/project-config/shared/platform-services.schemas.js +31 -0
  80. package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
  81. package/dist/esm/release/framework-release.constants.d.ts +24 -19
  82. package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
  83. package/dist/esm/release/framework-release.constants.js +24 -19
  84. package/dist/esm/release/framework-release.constants.js.map +1 -1
  85. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +14 -0
  86. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
  87. package/dist/esm/workspace-scope/workspace-homes.schemas.js +2 -0
  88. package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
  89. package/dist/tsconfig.build.tsbuildinfo +1 -1
  90. package/package.json +7 -7
  91. package/dist/esm/.builder.pid +0 -9
@@ -75,7 +75,7 @@ const RuntimeProviderScopeArtifactSchema = z.strictObject({
75
75
  providers: z.record(z.string(), SaasProviderScopeSelectionSchema).default({}),
76
76
  selection: z.record(z.string(), z.strictObject({
77
77
  primary: z.string().min(1),
78
- fallbacks: z.array(z.string().min(1)).default([]),
78
+ whenUnavailable: z.array(z.string().min(1)).default([]),
79
79
  })).default({}),
80
80
  });
81
81
  const RuntimeProviderModulesArtifactSchema = z.strictObject({
@@ -93,6 +93,19 @@ export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
93
93
  generatedAt: z.string().datetime({ offset: true }),
94
94
  sourceDigest: z.string().min(1),
95
95
  providerRefs: z.array(z.string().min(1)).default([]),
96
+ /**
97
+ * `providerRef` -> the package specifier a host dynamic-imports to obtain that provider's backend
98
+ * module (#330).
99
+ *
100
+ * `providerRefs` says WHICH providers a process may expose; this says WHERE each one comes from,
101
+ * and it is what makes a provider shipped as its own npm package loadable at all. Derived from
102
+ * the discovered contribution whose `runtimeTargets` match the host — never authored.
103
+ *
104
+ * Optional, so an artifact written before this field existed still parses. Every ref such an
105
+ * artifact names is engine-shipped, and a host resolves those from the engine's own on-demand map
106
+ * without consulting this record, so an un-resynced application is unaffected.
107
+ */
108
+ providerRuntimeImports: z.record(z.string().min(1), z.string().min(1)).optional(),
96
109
  providerGraphDigest: z.string().min(1),
97
110
  lockfileSectionDigest: z.string().min(1),
98
111
  artifactKind: z.enum([
@@ -170,6 +183,11 @@ export function selectScopedProviderRuntimeArtifact(artifact, scopeKey) {
170
183
  return SaasRuntimeProvidersArtifactSchema.parse({
171
184
  ...artifact,
172
185
  providerRefs: projectedProviderRefs,
186
+ // Narrowed for the same reason `providerRefs` is recomputed above: the multi-scope artifact's
187
+ // import map is the union across every host, and a per-host projection that advertised a
188
+ // sibling's packages would tell this host it can load something it never declared.
189
+ providerRuntimeImports: Object.fromEntries(Object.entries(artifact.providerRuntimeImports ?? {})
190
+ .filter(([providerRef]) => projectedProviderRefs.includes(providerRef))),
173
191
  frontendProviderBootstraps: artifact.frontendProviderBootstraps?.[scopeKey]
174
192
  ? { [scopeKey]: artifact.frontendProviderBootstraps[scopeKey] }
175
193
  : undefined,
@@ -215,11 +233,30 @@ export function loadMaterializedFrontendProviders(input) {
215
233
  if (!existsSync(artifactPath)) {
216
234
  return undefined;
217
235
  }
218
- const artifact = SaasRuntimeProvidersArtifactSchema.parse(JSON.parse(readFileSync(artifactPath, 'utf8')));
219
- const providerBlock = artifact.frontendProviderBootstraps?.[serviceKey];
220
- return providerBlock === undefined
221
- ? undefined
222
- : FrontendProvidersBlockSchema.parse(providerBlock);
236
+ const parsedArtifact = SaasRuntimeProvidersArtifactSchema.safeParse(JSON.parse(readFileSync(artifactPath, 'utf8')));
237
+ if (!parsedArtifact.success) {
238
+ throw staleGeneratedArtifactError(artifactPath, parsedArtifact.error.issues);
239
+ }
240
+ const providerBlock = parsedArtifact.data.frontendProviderBootstraps?.[serviceKey];
241
+ if (providerBlock === undefined)
242
+ return undefined;
243
+ const parsedBlock = FrontendProvidersBlockSchema.safeParse(providerBlock);
244
+ if (!parsedBlock.success) {
245
+ throw staleGeneratedArtifactError(artifactPath, parsedBlock.error.issues);
246
+ }
247
+ return parsedBlock.data;
248
+ }
249
+ /**
250
+ * A materialized artifact that does not satisfy the current schema was almost always generated
251
+ * before the contract changed (#328 added the provider identity to every frontend entry). A raw
252
+ * Zod issue list reads as a logic defect in the consumer; the remedy is regeneration, so the
253
+ * error names it. The backend's `applyProviderRuntime` says the same thing for its own reader —
254
+ * one message, two readers.
255
+ */
256
+ function staleGeneratedArtifactError(artifactPath, issues) {
257
+ return new Error(`The generated provider runtime artifact at ${artifactPath} does not satisfy the current contract — it was most `
258
+ + 'likely generated before the contract changed. Regenerate it with `wildo config sync`. Issues: '
259
+ + issues.map((issue) => `${issue.path.map(String).join('.')}: ${issue.message}`).join('; '));
223
260
  }
224
261
  export function renderProviderRuntimeGeneratedModule(artifact) {
225
262
  const artifactLiteral = JSON.stringify(artifact, null, 2);
@@ -456,6 +493,7 @@ function materializeRuntimeArtifactFile(input) {
456
493
  generatedAt: input.generatedAt,
457
494
  sourceDigest: input.metadata.sourceDigest,
458
495
  providerRefs: input.metadata.providerRefs,
496
+ providerRuntimeImports: input.metadata.providerRuntimeImports,
459
497
  providerGraphDigest: input.metadata.providerGraphDigest,
460
498
  lockfileSectionDigest: input.metadata.lockfileSectionDigest,
461
499
  artifactKind: input.artifactKind,
@@ -745,6 +783,7 @@ function buildSingleScopeArtifactMetadata(input) {
745
783
  extraArtifactState: input.extraArtifactState,
746
784
  }),
747
785
  providerRefs,
786
+ providerRuntimeImports: buildProviderRuntimeImports(providerRefs, input.matchingContributions),
748
787
  providerGraphDigest: digestJson(providerGraphDigestInput),
749
788
  lockfileSectionDigest: digestJson(input.runtimeLockSection),
750
789
  };
@@ -770,10 +809,40 @@ function buildMultiScopeArtifactMetadata(input) {
770
809
  extraArtifactState: input.extraArtifactState,
771
810
  }),
772
811
  providerRefs,
812
+ providerRuntimeImports: buildProviderRuntimeImports(providerRefs, Object.values(input.matchingContributionsByScope).flat()),
773
813
  providerGraphDigest: digestJson(providerGraphDigestInput),
774
814
  lockfileSectionDigest: digestJson(input.runtimeLockSection),
775
815
  };
776
816
  }
817
+ /**
818
+ * Project the per-ref runtime import path a host dynamic-imports.
819
+ *
820
+ * Only refs actually in scope are recorded, so a per-host artifact never advertises a sibling's
821
+ * packages. A ref no contribution covers is simply absent: the host then resolves it from the
822
+ * engine's on-demand map, and the single fail-loud refusal in the backend registry names it if that
823
+ * map does not hold it either.
824
+ *
825
+ * When several contributions claim one ref with DIFFERENT import paths, the sorted-first path wins
826
+ * — deterministically, so the artifact does not churn. Divergence is possible today only between an
827
+ * application's hand-authored engine projection (`@wildo-ai/saas-backend-lib`) and the engine's own
828
+ * companion export, and neither is consulted for an engine-shipped ref, so the choice cannot change
829
+ * which module a host loads. A package provider is contributed by exactly one package.
830
+ */
831
+ function buildProviderRuntimeImports(providerRefs, contributions) {
832
+ const inScope = new Set(providerRefs);
833
+ const candidatesByRef = new Map();
834
+ for (const contribution of contributions) {
835
+ if (!inScope.has(contribution.ref)) {
836
+ continue;
837
+ }
838
+ const candidates = candidatesByRef.get(contribution.ref) ?? new Set();
839
+ candidates.add(contribution.runtimeImportPath);
840
+ candidatesByRef.set(contribution.ref, candidates);
841
+ }
842
+ return Object.fromEntries([...candidatesByRef.entries()]
843
+ .sort(([left], [right]) => left.localeCompare(right))
844
+ .map(([ref, candidates]) => [ref, [...candidates].sort()[0]]));
845
+ }
777
846
  function findMatchingDiscoveredContributions(input) {
778
847
  return input.discoveredContributions.flatMap((contribution) => {
779
848
  if (input.providerRef && contribution.ref !== input.providerRef) {
@@ -1 +1 @@
1
- {"version":3,"file":"provider-runtime-artifacts.js","sourceRoot":"","sources":["../../../../src/project-config/provider-runtime-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,4BAA4B,GAG7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kCAAkC,GAGnC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,GACpC,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,yBAAyB,EACzB,gCAAg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C,KAAK,CAAC,KAAK,CAAC;QAC9C,QAAQ,EAAE,KAAK,CAAC,GAAG;QACnB,sBAAsB,EAAE,KAAK,CAAC,iBAAiB;QAC/C,mBAAmB,EAAE,KAAK,CAAC,cAAc;QACzC,YAAY,EAAE,KAAK,CAAC,cAAc;KACnC,CAAC,CAAC,CAAC;SACH,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QACtB,GAAG,EAAE,YAAY,CAAC,GAAG;QACrB,KAAK,EAAE,qBAAqB,CAAC,YAAY,CAAC,KAAK,CAAC;QAChD,iBAAiB,EAAE,YAAY,CAAC,iBAAiB;QACjD,cAAc,EAAE,YAAY,CAAC,cAAc;QAC3C,kBAAkB,EAAE,CAAC,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC,IAAI,EAAE;QAC/D,oBAAoB,EAAE,CAAC,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC,IAAI,EAAE;QACnE,SAAS,EAAE,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE;QAC7C,oBAAoB,EAAE,YAAY,CAAC,oBAAoB;QACvD,aAAa,EAAE,YAAY,CAAC,aAAa;YACvC,CAAC,CAAC;gBACA,QAAQ,EAAE,YAAY,CAAC,aAAa,CAAC,QAAQ;gBAC7C,oBAAoB,EAAE,CAAC,GAAG,YAAY,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,IAAI,EAAE;gBACjF,SAAS,EAAE,CAAC,GAAG,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE;gBAC3D,YAAY,EAAE,YAAY,CAAC,aAAa,CAAC,YAAY;aACtD;YACD,CAAC,CAAC,SAAS;QACb,cAAc,EAAE,YAAY,CAAC,cAAc;KAC5C,CAAC,CAAC,CAAC;AACR,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { resolve as resolvePath } from 'node:path';\nimport { z } from 'zod';\nimport {\n AppFrontendType,\n FrontendProvidersBlockSchema,\n type FrontendProviderEntry,\n type FrontendProvidersBlock,\n} from '@wildo-ai/saas-models';\nimport {\n SaasLockfileProvidersSectionSchema,\n type SaasLockfileProvidersSection,\n type SaasLockfileRuntimeScopesProviders,\n} from '../lockfile/wildo-saas-lock.shared.schemas';\nimport {\n getDeclaredApplicationModuleIds,\n getServiceBoundApplicationModuleIds,\n} from './shared/application-modules.utils';\nimport type { ApplicationModules } from './shared/application-modules.schemas';\nimport {\n SaasProvidersScopesSchema,\n SaasProviderScopeSelectionSchema,\n type SaasProviderScopeSelection,\n type SaasProvidersScopes,\n type WildoSaasConfig,\n} from './define-saas-config';\nimport type { DiscoveredProviderCompanionContribution } from './provider-companion-discovery';\n\nexport const PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING =\n 'AUTO-GENERATED FILE. DO NOT EDIT. Regenerate with `wildo config sync`.';\n\nexport const PROVIDER_RUNTIME_ARTIFACT_GENERATOR = 'wildo provider-runtime-artifact';\n\n/**\n * Canonical relative paths (from saas root) for the per-runtime-kind\n * provider artifact JSON files emitted by `wildo config sync`.\n *\n * Moved from `.wildo-saas/providers/` → `.wildo-saas/generated/providers/`\n * on 2026-05-06 to group ALL CLI-generated runtime topology artifacts\n * under the `.wildo-saas/generated/` namespace (sibling to other\n * generated state). The legacy `.wildo-saas/providers/` location is\n * cleaned up by `cleanupLegacyProviderJsonArtifacts` in the CLI sync\n * so operators don't end up with two copies after the migration.\n */\nexport const PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS = {\n backend: '.wildo-saas/generated/providers/backend.runtime-providers.generated.json',\n companion: '.wildo-saas/generated/providers/companion.runtime-providers.generated.json',\n frontendServices: '.wildo-saas/generated/providers/frontend-services.runtime-providers.generated.json',\n minions: '.wildo-saas/generated/providers/minions.runtime-providers.generated.json',\n nodeWorkers: '.wildo-saas/generated/providers/node-workers.runtime-providers.generated.json',\n} as const;\n\n/**\n * Legacy paths (pre-2026-05-06) for the per-runtime-kind provider\n * artifact JSON files. These are NOT written anymore — kept here so\n * `wildo config sync` can clean them up if they exist on disk from a\n * pre-migration sync. Drop this constant entirely once Wonder Todos\n * + downstream apps have all run a post-migration sync at least once.\n */\nexport const LEGACY_PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS = {\n backend: '.wildo-saas/providers/backend.runtime-providers.generated.json',\n companion: '.wildo-saas/providers/companion.runtime-providers.generated.json',\n frontendServices: '.wildo-saas/providers/frontend-services.runtime-providers.generated.json',\n minions: '.wildo-saas/providers/minions.runtime-providers.generated.json',\n nodeWorkers: '.wildo-saas/providers/node-workers.runtime-providers.generated.json',\n} as const;\n\nexport type ProviderRuntimeArtifactKind = keyof typeof PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS;\n\nexport const PROVIDER_RUNTIME_GENERATED_MODULE_RELATIVE_PATH =\n 'src/generated/wildo-provider-runtime.generated.ts';\n\n/**\n * Canonical lockfile section path the provider-materialization\n * subsystem owns end-to-end. Used by the post-mutation provider sync\n * runner + materialization-hook return types and pinned by tests\n * (`provider-sync-runner.test.ts`, `provider-materialization-hook.test.ts`).\n *\n * Defined here as a single-source constant — used to live as a\n * literal in 3+ places across `wildo-module-client` (third-pass\n * review C-L1).\n */\nexport const PROVIDER_LOCK_SECTION_PATH = 'sections.providers.runtimeScopes' as const;\n\n/**\n * Per-worker generated env file written by `wildo config sync`. Carries\n * provider topology env vars derived from the materialized scope.\n *\n * This file is the **single delivery channel** non-Node workers (Rust /\n * Java / etc.) receive for provider topology — there is no executable\n * JS bundle in their case (Step 5b in\n * `.claude/plans/provider-migration-continuation.md`). Node workers\n * receive both this file and the per-package\n * `wildo-provider-runtime.generated.ts` source module; reading either\n * surface yields a consistent view because they share the same digest.\n *\n * The file is auto-generated and overwritten on every sync. Operator-\n * authored secrets and per-env config stay in the worker's `.env` (not\n * touched by `wildo config sync`); workers should load both files at\n * boot — operator vars from `.env` and provider vars from this file —\n * so the two channels never collide.\n */\nexport const PROVIDER_RUNTIME_GENERATED_ENV_FILE_NAME = '.wildo-providers.env';\n\nconst RuntimeProviderScopeArtifactSchema = z.strictObject({\n providers: z.record(z.string(), SaasProviderScopeSelectionSchema).default({}),\n selection: z.record(\n z.string(),\n z.strictObject({\n primary: z.string().min(1),\n fallbacks: z.array(z.string().min(1)).default([]),\n }),\n ).default({}),\n});\n\nconst RuntimeProviderModulesArtifactSchema = z.strictObject({\n declaredModules: z.record(\n z.string(),\n z.strictObject({\n services: z.array(z.string().min(1)),\n haveSamlIntegration: z.boolean().optional(),\n }),\n ).default({}),\n moduleIds: z.array(z.string().min(1)).default([]),\n moduleIdsByService: z.record(z.string(), z.array(z.string().min(1))).default({}),\n});\nexport type RuntimeProviderModulesArtifact = z.infer<typeof RuntimeProviderModulesArtifactSchema>;\n\nconst FrontendProviderBootstrapsSchema = z.record(\n z.string().min(1),\n FrontendProvidersBlockSchema,\n);\n\nexport const SaasRuntimeProvidersArtifactSchema = z.strictObject({\n __AUTOGENERATED__: z.literal(PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING),\n generatedBy: z.literal(PROVIDER_RUNTIME_ARTIFACT_GENERATOR),\n generatedAt: z.string().datetime({ offset: true }),\n sourceDigest: z.string().min(1),\n providerRefs: z.array(z.string().min(1)).default([]),\n providerGraphDigest: z.string().min(1),\n lockfileSectionDigest: z.string().min(1),\n artifactKind: z.enum([\n 'backend',\n 'companion',\n 'frontendServices',\n 'minions',\n 'nodeWorkers',\n ]),\n modules: RuntimeProviderModulesArtifactSchema,\n scope: RuntimeProviderScopeArtifactSchema.optional(),\n scopes: z.record(z.string(), RuntimeProviderScopeArtifactSchema).optional(),\n frontendProviderBootstraps: FrontendProviderBootstrapsSchema.optional(),\n});\nexport type SaasRuntimeProvidersArtifact = z.infer<typeof SaasRuntimeProvidersArtifactSchema>;\n\nexport interface MaterializedSaasProviderRuntimeArtifacts {\n artifacts: Partial<Record<ProviderRuntimeArtifactKind, SaasRuntimeProvidersArtifact>>;\n lockSection: SaasLockfileProvidersSection;\n}\n\nexport function materializeSaasProviderRuntimeArtifacts(\n config: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services'>,\n options?: {\n generatedAt?: string;\n nodeWorkerKeys?: string[];\n discoveredContributions?: DiscoveredProviderCompanionContribution[];\n },\n): MaterializedSaasProviderRuntimeArtifacts {\n const scopes = SaasProvidersScopesSchema.parse(config.providers.scopes);\n const generatedAt = options?.generatedAt ?? new Date().toISOString();\n const modules = materializeModules(config);\n const frontendServiceTypes: Record<string, AppFrontendType> = Object.fromEntries(\n Object.entries(config.services ?? {})\n .filter(([, definition]) => definition.frontendType !== undefined)\n .map(([serviceKey, definition]) => [serviceKey, definition.frontendType as AppFrontendType]),\n );\n const discoveryContext = buildProviderRuntimeDiscoveryContext({\n discoveredContributions: options?.discoveredContributions,\n frontendServiceTypes,\n });\n\n const lockSection = SaasLockfileProvidersSectionSchema.parse({\n runtimeScopes: materializeLockRuntimeScopes({\n scopes,\n discoveryContext,\n }),\n });\n const artifactMetadata = buildArtifactMetadata({\n discoveryContext,\n frontendServiceTypes,\n lockSection,\n modules,\n nodeWorkerKeys: options?.nodeWorkerKeys,\n scopes,\n });\n\n const artifacts = materializeRuntimeArtifacts({\n artifactMetadata,\n discoveryContext,\n frontendServiceTypes,\n generatedAt,\n modules,\n nodeWorkerKeys: options?.nodeWorkerKeys,\n scopes,\n });\n\n return { artifacts, lockSection };\n}\n\nexport function selectScopedProviderRuntimeArtifact(\n artifact: SaasRuntimeProvidersArtifact,\n scopeKey: string,\n): SaasRuntimeProvidersArtifact {\n if (!artifact.scopes) {\n throw new Error(`Provider runtime artifact '${artifact.artifactKind}' does not contain keyed scopes.`);\n }\n\n const scope = artifact.scopes[scopeKey];\n if (!scope) {\n throw new Error(`Provider runtime artifact '${artifact.artifactKind}' does not contain scope '${scopeKey}'.`);\n }\n\n // Recompute `providerRefs` from the projected per-host scope rather\n // than carrying the parent multi-scope union forward unchanged. The\n // multi-scope artifact's `providerRefs` is the union across all\n // hosts (`buildMultiScopeArtifactMetadata`); preserving that union\n // on a single-scope projection makes the per-host artifact internally\n // inconsistent — `scope.providers` would describe one host while\n // `providerRefs` would describe siblings too. The boot-time\n // `assertProviderRuntimeEnvInSync` guard treats `providerRefs.length > 0`\n // as \"this host has providers to reconcile\" — without this\n // recomputation, an empty-scope host would inherit the union and\n // trip the env-missing guard even though its `.wildo-providers.env`\n // was deliberately not written. Recomputation also tightens\n // `BackendProviderRegistry`'s filter (today defended by an empty-list\n // fallback) so the per-host artifact accurately advertises only the\n // refs it should resolve.\n const projectedProviderRefs = Object.keys(scope.providers).sort();\n\n return SaasRuntimeProvidersArtifactSchema.parse({\n ...artifact,\n providerRefs: projectedProviderRefs,\n frontendProviderBootstraps: artifact.frontendProviderBootstraps?.[scopeKey]\n ? { [scopeKey]: artifact.frontendProviderBootstraps[scopeKey] }\n : undefined,\n scope,\n scopes: undefined,\n });\n}\n\n/**\n * Resolve the absolute path to the canonical\n * `frontend-services.runtime-providers.generated.json` artifact under\n * `<saasRoot>/.wildo-saas/generated/providers/`.\n *\n * Build-time consumers (Wonder Todos website + tech-doc) call this\n * instead of hardcoding the relative path so the artifact location\n * stays canonical (single source of truth is\n * `PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS`).\n */\nexport function resolveFrontendServicesArtifactPath(saasRoot: string): string {\n return resolvePath(saasRoot, PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS.frontendServices);\n}\n\n/**\n * Read + project the materialized frontend-services artifact for the\n * given service key. Returns `undefined` if the artifact file is\n * missing (sync hasn't run yet / clean checkout) or if the service\n * has no provider bootstrap entry.\n *\n * The single source of truth for build-time loading of the frontend\n * provider bootstraps. Replaces the (previously duplicated)\n * `loadMaterializedFrontendProviders` helpers that lived in\n * `saas-technical-doc/src/build/load-materialized-frontend-providers.ts`\n * and inline in `examples/wonder-todos/website/src/website-site-context.ts`.\n *\n * Both consumers used identical control flow:\n * 1. existsSync() short-circuit\n * 2. JSON.parse + SaasRuntimeProvidersArtifactSchema.parse\n * 3. frontendProviderBootstraps[serviceKey] lookup\n * 4. FrontendProvidersBlockSchema.parse on the per-service block\n * Centralized 2026-05-06 so a future schema/path change only\n * requires editing this function.\n */\nexport function loadMaterializedFrontendProviders(input: {\n artifactPath: string;\n serviceKey: string;\n}): FrontendProvidersBlock | undefined {\n const { artifactPath, serviceKey } = input;\n\n if (!existsSync(artifactPath)) {\n return undefined;\n }\n\n const artifact = SaasRuntimeProvidersArtifactSchema.parse(\n JSON.parse(readFileSync(artifactPath, 'utf8')),\n );\n const providerBlock = artifact.frontendProviderBootstraps?.[serviceKey];\n\n return providerBlock === undefined\n ? undefined\n : FrontendProvidersBlockSchema.parse(providerBlock);\n}\n\nexport function renderProviderRuntimeGeneratedModule(\n artifact: SaasRuntimeProvidersArtifact,\n): string {\n const artifactLiteral = JSON.stringify(artifact, null, 2);\n\n return [\n '/**',\n ` * ${PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING}`,\n ' *',\n ' * This module is generated from wildo.saas.config.ts by `wildo config sync`.',\n ' * It contains environment-independent provider topology only.',\n ' */',\n '',\n // Intentionally NOT `as const` — the generated artifact is *data*, not a\n // frozen literal-typed tuple. Each host (backend / companion / minion /\n // worker) casts the imported value to its own narrowed runtime-artifact\n // type (`ProviderRuntimeArtifact`, `MinionProviderRuntimeArtifact`, …).\n // `as const` would infer `readonly` tuples (e.g. `readonly [\"openai\"]`)\n // that fail TS2352 against the schema-inferred mutable `string[]` shape.\n // Contract conformance is enforced upstream by\n // `SaasRuntimeProvidersArtifactSchema.parse(...)` at materialization time,\n // so widening the TS surface here costs no runtime safety.\n `export const WILDO_PROVIDER_RUNTIME = ${artifactLiteral};`,\n '',\n 'export default WILDO_PROVIDER_RUNTIME;',\n '',\n ].join('\\n');\n}\n\n/**\n * Canonical worker provider env-var keys. All workers receive the same\n * three keys regardless of language; the values are stable across runs\n * as long as the authored scope and discovered contributions don't\n * change.\n *\n * - `WILDO_PROVIDER_REFS` — comma-separated list of authored refs (sorted).\n * Cheap to read from any language (no JSON parser needed).\n * - `WILDO_PROVIDER_TOPOLOGY_JSON` — the per-worker `scope` block from\n * the materialized artifact, JSON-encoded. Workers that want\n * structured access (capability/protocol set) parse this; workers\n * that only need ref membership read `WILDO_PROVIDER_REFS`.\n * - `WILDO_PROVIDER_RUNTIME_DIGEST` — the artifact's `sourceDigest`.\n * Workers can fail-closed at boot if their copy of the env-file\n * disagrees with the lockfile section digest the platform expects.\n */\nexport const PROVIDER_RUNTIME_ENV_KEYS = {\n REFS: 'WILDO_PROVIDER_REFS',\n TOPOLOGY_JSON: 'WILDO_PROVIDER_TOPOLOGY_JSON',\n RUNTIME_DIGEST: 'WILDO_PROVIDER_RUNTIME_DIGEST',\n} as const;\n\n/**\n * Render the per-worker provider env-file body. Inputs:\n * - `scope` — the per-worker scope block from\n * `WildoSaasConfig.providers.scopes.workers[<workerKey>]`. Carries\n * the authored providers + capability/protocol declarations that\n * this worker needs to resolve at runtime.\n * - `sourceDigest` — `SaasRuntimeProvidersArtifact.sourceDigest`\n * (from the lockfile or the corresponding generated artifact).\n *\n * Output: a deterministic dotenv body — sorted refs, stable JSON\n * key ordering — so re-running `wildo config sync` with no upstream\n * changes produces a byte-identical file.\n */\nexport function renderProviderRuntimeEnvFile(input: {\n scope: SaasProviderScopeSelections;\n sourceDigest: string;\n}): string {\n const refs = Object.keys(input.scope.providers).sort();\n const topology: Record<string, {\n engineCapabilities: string[];\n providerCapabilities: string[];\n protocols: string[];\n }> = {};\n for (const ref of refs) {\n const selection = input.scope.providers[ref];\n topology[ref] = {\n engineCapabilities: [...selection.engineCapabilities].sort(),\n providerCapabilities: [...selection.providerCapabilities].sort(),\n protocols: [...selection.protocols].sort(),\n };\n }\n\n return [\n `# ${PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING}`,\n '#',\n '# This file is regenerated on every `wildo config sync`. Do not edit by hand.',\n '# Operator-authored secrets / per-env config stay in `.env` and are never touched here.',\n '',\n `${PROVIDER_RUNTIME_ENV_KEYS.REFS}=${refs.join(',')}`,\n `${PROVIDER_RUNTIME_ENV_KEYS.TOPOLOGY_JSON}=${JSON.stringify(topology)}`,\n `${PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST}=${input.sourceDigest}`,\n '',\n ].join('\\n');\n}\n\n/**\n * Result of comparing the runtime host's typed\n * `wildo-provider-runtime.generated.ts` module against its\n * `.wildo-providers.env` file at boot.\n *\n * Drift between the two indicates the operator regenerated one surface\n * but not the other — typically: edited `wildo.saas.config.ts` and\n * re-ran `wildo config sync` while the env file was cached, or vice\n * versa. Either case the runtime would silently boot with mismatched\n * topology unless someone reconciles. See\n * `assertProviderRuntimeEnvInSync` for the fail-closed assertion.\n */\nexport type ProviderRuntimeEnvReconciliationResult =\n | { kind: 'in-sync' }\n | { kind: 'env-missing'; missingKeys: ReadonlyArray<string> }\n | {\n kind: 'refs-mismatch';\n envRefs: ReadonlyArray<string>;\n artifactRefs: ReadonlyArray<string>;\n }\n | {\n kind: 'digest-mismatch';\n envDigest: string;\n artifactDigest: string;\n };\n\n/**\n * Reconcile a runtime artifact's typed projection against the\n * `.wildo-providers.env` mounted into the same process. Pure function\n * so callers can decide how to surface the result (throw / log / ignore).\n *\n * The env file is materialized by `renderProviderRuntimeEnvFile` for\n * EVERY runtime host that is a minion or worker; the typed module is\n * imported by the same hosts. Both should agree on\n * `(providerRefs, sourceDigest)` exactly. Drift means stale sync.\n *\n * Hosts that don't receive an env file (backend, companion, frontend\n * services per `provider-runtime-sync.service.ts`) MUST NOT call this —\n * `WILDO_PROVIDER_*` keys won't be set and every call returns\n * `env-missing`.\n */\nexport function reconcileProviderRuntimeEnv(input: {\n artifactProviderRefs: ReadonlyArray<string>;\n artifactSourceDigest: string;\n env?: NodeJS.ProcessEnv;\n}): ProviderRuntimeEnvReconciliationResult {\n const env = input.env ?? process.env;\n const envRefsRaw = env[PROVIDER_RUNTIME_ENV_KEYS.REFS];\n const envDigest = env[PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST];\n\n const missingKeys: string[] = [];\n if (envRefsRaw === undefined) missingKeys.push(PROVIDER_RUNTIME_ENV_KEYS.REFS);\n if (envDigest === undefined) missingKeys.push(PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST);\n if (missingKeys.length > 0) {\n return { kind: 'env-missing', missingKeys };\n }\n\n // Filter empty entries so trailing-comma input (e.g. `'openai,'`) or\n // operator-edited stray whitespace don't produce confusing `''`\n // entries in mismatch diagnostics. Materializer never emits trailing\n // commas, but defense-in-depth keeps the helper robust to anything\n // that lands the env file via dotenv loaders or hand-edits.\n const envRefs = envRefsRaw!\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0)\n .sort();\n const artifactRefs = [...input.artifactProviderRefs].sort();\n\n if (envRefs.length !== artifactRefs.length || envRefs.some((ref, i) => ref !== artifactRefs[i])) {\n return { kind: 'refs-mismatch', envRefs, artifactRefs };\n }\n\n if (envDigest !== input.artifactSourceDigest) {\n return {\n kind: 'digest-mismatch',\n envDigest: envDigest!,\n artifactDigest: input.artifactSourceDigest,\n };\n }\n\n return { kind: 'in-sync' };\n}\n\n/**\n * Fail-closed wrapper around `reconcileProviderRuntimeEnv`. Throws on\n * any divergence, returns silently when in sync. Designed to be called\n * once at runtime-host boot (minion / Node-worker startup) so a stale\n * `.wildo-providers.env` surfaces immediately instead of being masked\n * by `process.env` drift.\n *\n * Throws a plain `Error` (not `WildoError_Backend`) because this runs\n * BEFORE the DI container has built the error builder — the failure\n * mode here is \"the container can't be trusted to boot at all\".\n */\nexport function assertProviderRuntimeEnvInSync(input: {\n artifactProviderRefs: ReadonlyArray<string>;\n artifactSourceDigest: string;\n hostKind: 'minion' | 'node-worker';\n hostKey: string;\n env?: NodeJS.ProcessEnv;\n}): void {\n const result = reconcileProviderRuntimeEnv(input);\n switch (result.kind) {\n case 'in-sync':\n return;\n case 'env-missing':\n throw new Error(\n `[provider-runtime-env] ${input.hostKind} '${input.hostKey}' booted without `\n + `provider env vars (${result.missingKeys.join(', ')}). The `\n + `\\`.wildo-providers.env\\` file should be mounted into this process — check `\n + `the docker-compose \\`env_file:\\` directive, the K8s ConfigMap mount, or the `\n + `dotenv loader. Re-run \\`wildo config sync\\` to regenerate if missing.`,\n );\n case 'refs-mismatch':\n throw new Error(\n `[provider-runtime-env] ${input.hostKind} '${input.hostKey}' detected stale provider topology. `\n + `\\`.wildo-providers.env\\` advertises refs [${result.envRefs.join(', ')}] but the `\n + `imported \\`wildo-provider-runtime.generated.ts\\` module declares `\n + `[${result.artifactRefs.join(', ')}]. Run \\`wildo config sync\\` to regenerate `\n + `both surfaces from the same \\`wildo.saas.config.ts\\` source.`,\n );\n case 'digest-mismatch':\n throw new Error(\n `[provider-runtime-env] ${input.hostKind} '${input.hostKey}' detected provider runtime digest drift. `\n + `\\`.wildo-providers.env\\` carries digest '${result.envDigest}' but the imported `\n + `\\`wildo-provider-runtime.generated.ts\\` module carries '${result.artifactDigest}'. `\n + `Refs match, but per-provider capabilities/protocols may differ. `\n + `Run \\`wildo config sync\\` to regenerate.`,\n );\n }\n}\n\ntype SaasProviderScopeSelections = {\n providers: Record<string, {\n engineCapabilities: ReadonlyArray<string>;\n providerCapabilities: ReadonlyArray<string>;\n protocols: ReadonlyArray<string>;\n }>;\n};\n\nfunction materializeRuntimeArtifacts(input: {\n artifactMetadata: ProviderRuntimeArtifactMetadataByKind;\n discoveryContext: ProviderRuntimeDiscoveryContext;\n frontendServiceTypes: Record<string, AppFrontendType>;\n generatedAt: string;\n modules: RuntimeProviderModulesArtifact;\n nodeWorkerKeys?: string[];\n scopes: SaasProvidersScopes;\n}): MaterializedSaasProviderRuntimeArtifacts['artifacts'] {\n const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes } = input;\n const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;\n const nodeWorkerScopes = scopes.workers\n ? Object.fromEntries(\n Object.entries(scopes.workers).filter(([workerKey]) =>\n nodeWorkerKeySet ? nodeWorkerKeySet.has(workerKey) : true,\n ),\n )\n : undefined;\n\n return pruneUndefined({\n backend: materializeRuntimeArtifactFile({\n artifactKind: 'backend',\n generatedAt,\n modules,\n metadata: artifactMetadata.backend,\n frontendProviderBootstraps: materializeFrontendProviderBootstraps({\n discoveredContributions: discoveryContext.contributions,\n frontendServiceScopes: scopes.frontendServices ?? {},\n frontendServiceTypes,\n }),\n scope: materializeRuntimeScope(scopes.backend ?? { providers: {}, selection: {} }),\n }),\n companion: materializeRuntimeArtifactFile({\n artifactKind: 'companion',\n generatedAt,\n modules,\n metadata: artifactMetadata.companion,\n scope: materializeRuntimeScope(scopes.companion ?? { providers: {}, selection: {} }),\n }),\n frontendServices: scopes.frontendServices\n ? materializeRuntimeArtifactFile({\n artifactKind: 'frontendServices',\n generatedAt,\n modules,\n metadata: artifactMetadata.frontendServices,\n frontendProviderBootstraps: materializeFrontendProviderBootstraps({\n discoveredContributions: discoveryContext.contributions,\n frontendServiceScopes: scopes.frontendServices,\n frontendServiceTypes,\n }),\n scopes: mapRecord(scopes.frontendServices, materializeRuntimeScope),\n })\n : undefined,\n minions: scopes.minions\n ? materializeRuntimeArtifactFile({\n artifactKind: 'minions',\n generatedAt,\n modules,\n metadata: artifactMetadata.minions,\n scopes: mapRecord(scopes.minions, materializeRuntimeScope),\n })\n : undefined,\n nodeWorkers: nodeWorkerScopes && Object.keys(nodeWorkerScopes).length > 0\n ? materializeRuntimeArtifactFile({\n artifactKind: 'nodeWorkers',\n generatedAt,\n modules,\n metadata: artifactMetadata.nodeWorkers,\n scopes: mapRecord(nodeWorkerScopes, materializeRuntimeScope),\n })\n : undefined,\n });\n}\n\nfunction materializeRuntimeArtifactFile(input: {\n artifactKind: ProviderRuntimeArtifactKind;\n generatedAt: string;\n metadata: ProviderRuntimeArtifactMetadata;\n modules: RuntimeProviderModulesArtifact;\n frontendProviderBootstraps?: Record<string, FrontendProvidersBlock>;\n scope?: z.infer<typeof RuntimeProviderScopeArtifactSchema>;\n scopes?: Record<string, z.infer<typeof RuntimeProviderScopeArtifactSchema>>;\n}): SaasRuntimeProvidersArtifact {\n return SaasRuntimeProvidersArtifactSchema.parse({\n __AUTOGENERATED__: PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING,\n generatedBy: PROVIDER_RUNTIME_ARTIFACT_GENERATOR,\n generatedAt: input.generatedAt,\n sourceDigest: input.metadata.sourceDigest,\n providerRefs: input.metadata.providerRefs,\n providerGraphDigest: input.metadata.providerGraphDigest,\n lockfileSectionDigest: input.metadata.lockfileSectionDigest,\n artifactKind: input.artifactKind,\n modules: input.modules,\n scope: input.scope,\n scopes: input.scopes,\n frontendProviderBootstraps: input.frontendProviderBootstraps,\n });\n}\n\nfunction materializeRuntimeScope(scope: NonNullable<SaasProvidersScopes['backend']>) {\n return RuntimeProviderScopeArtifactSchema.parse({\n providers: scope.providers,\n selection: scope.selection ?? {},\n });\n}\n\nfunction materializeFrontendProviderBootstraps(input: {\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n frontendServiceScopes: NonNullable<SaasProvidersScopes['frontendServices']>;\n frontendServiceTypes: Record<string, AppFrontendType>;\n}): Record<string, FrontendProvidersBlock> | undefined {\n const { discoveredContributions, frontendServiceScopes, frontendServiceTypes } = input;\n const entries = Object.entries(frontendServiceScopes).map(([serviceKey, scope]) => {\n const serviceType = frontendServiceTypes[serviceKey];\n if (!serviceType) {\n throw new Error(\n `Cannot materialize frontend bootstrap for service \"${serviceKey}\": ` +\n `service has no frontendType — only services with a frontendType may appear under providers.scopes.frontendServices.`,\n );\n }\n const providers = Object.fromEntries(Object.keys(scope.providers).map((providerRef) => {\n const matchingContribution = discoveredContributions.filter(\n (contribution) =>\n contribution.ref === providerRef\n && contribution.runtimeTargets.some(\n (target) => target.kind === 'frontendService' && target.serviceType === serviceType,\n ),\n );\n\n if (matchingContribution.length === 0) {\n throw new Error(\n `Cannot materialize frontend bootstrap for service \"${serviceKey}\" (type \"${serviceType}\"): ` +\n `provider \"${providerRef}\" has no discovered frontend companion contribution.`,\n );\n }\n\n if (matchingContribution.some((contribution) => !contribution.frontendEntry)) {\n throw new Error(\n `Cannot materialize frontend bootstrap for service \"${serviceKey}\": ` +\n `provider \"${providerRef}\" is missing frontendEntry on at least one discovered contribution.`,\n );\n }\n\n if (matchingContribution.length > 1) {\n throw new Error(\n `Cannot materialize frontend bootstrap for service \"${serviceKey}\": ` +\n `provider \"${providerRef}\" is contributed more than once for the same runtime.`,\n );\n }\n\n return [\n providerRef,\n matchingContribution[0].frontendEntry as FrontendProviderEntry,\n ] as const;\n }));\n\n return [serviceKey, FrontendProvidersBlockSchema.parse({ providers })] as const;\n });\n\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n}\n\nfunction buildFrontendProviderBootstrapDigestInput(input: {\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n frontendServiceScopes: NonNullable<SaasProvidersScopes['frontendServices']>;\n frontendServiceTypes: Record<string, AppFrontendType>;\n}): Record<string, unknown> | undefined {\n const bootstraps = materializeFrontendProviderBootstraps(input);\n if (!bootstraps) {\n return undefined;\n }\n\n return Object.fromEntries(\n Object.entries(bootstraps).map(([serviceKey, block]) => [\n serviceKey,\n Object.fromEntries(\n Object.entries(block.providers).map(([providerRef, providerEntry]) => [\n providerRef,\n {\n metadata: providerEntry.metadata,\n providerCapabilities: [...providerEntry.providerCapabilities].sort(),\n protocols: [...providerEntry.protocols].sort(),\n publicConfig: providerEntry.publicConfig,\n },\n ]),\n ),\n ]),\n );\n}\n\nfunction materializeModules(\n config: Pick<WildoSaasConfig, 'modules' | 'services'>,\n): RuntimeProviderModulesArtifact {\n const modules = (config.modules ?? {}) as NonNullable<ApplicationModules>;\n return RuntimeProviderModulesArtifactSchema.parse({\n declaredModules: modules,\n moduleIds: getDeclaredApplicationModuleIds(modules),\n moduleIdsByService: Object.fromEntries(\n Object.keys(config.services ?? {}).map((serviceKey) => [\n serviceKey,\n getServiceBoundApplicationModuleIds(modules, serviceKey),\n ]),\n ),\n });\n}\n\nfunction materializeLockRuntimeScopes(input: {\n scopes: SaasProvidersScopes;\n discoveryContext: ProviderRuntimeDiscoveryContext;\n}): SaasLockfileRuntimeScopesProviders {\n const { scopes, discoveryContext } = input;\n return pruneUndefined({\n backend: scopes.backend\n ? materializeLockScope(\n scopes.backend.providers,\n discoveryContext.contributions,\n discoveryContext.backend.matchesRuntimeTarget,\n )\n : undefined,\n companion: scopes.companion\n ? materializeLockScope(\n scopes.companion.providers,\n discoveryContext.contributions,\n discoveryContext.companion.matchesRuntimeTarget,\n )\n : undefined,\n frontendServices: scopes.frontendServices\n ? mapRecord(\n scopes.frontendServices,\n (scope, serviceKey) => materializeLockScope(\n scope.providers,\n discoveryContext.contributions,\n discoveryContext.frontendServices.matchesRuntimeTarget(serviceKey),\n ),\n )\n : undefined,\n minions: scopes.minions\n ? mapRecord(\n scopes.minions,\n (scope, minionKey) => materializeLockScope(\n scope.providers,\n discoveryContext.contributions,\n discoveryContext.minions.matchesRuntimeTarget(minionKey),\n ),\n )\n : undefined,\n workers: scopes.workers\n ? mapRecord(\n scopes.workers,\n (scope, workerKey) => materializeLockScope(\n scope.providers,\n discoveryContext.contributions,\n discoveryContext.workers.matchesRuntimeTarget(workerKey),\n ),\n )\n : undefined,\n });\n}\n\nfunction materializeLockScope(\n providers: Record<string, SaasProviderScopeSelection>,\n discoveredContributions: DiscoveredProviderCompanionContribution[],\n matchesRuntimeTarget: (target: DiscoveredProviderCompanionContribution['runtimeTargets'][number]) => boolean,\n): SaasLockfileRuntimeScopesProviders['backend'] {\n return mapRecord(providers, (selection, ref) => {\n const matchingContributions = findMatchingDiscoveredContributions({\n discoveredContributions,\n matchesRuntimeTarget,\n providerRef: ref,\n });\n const secretsContractShape = resolveProviderSecretsContractShape(ref, matchingContributions);\n\n return {\n ref,\n digest: digestJson({\n selection,\n providerGraph: normalizeDiscoveredContributionsForDigest(matchingContributions),\n }),\n engineCapabilities: selection.engineCapabilities,\n providerCapabilities: selection.providerCapabilities,\n protocols: selection.protocols,\n // assurance-control: WILDO.SECRETS.CONTRACT_INTEGRITY — lock drift\n // covers the values-free provider contract without persisting secret values.\n secretsContractDigest: digestJson({ ref, secretsContractShape }),\n };\n });\n}\n\n/**\n * Resolves one authoritative values-free secret contract for a provider in a\n * concrete runtime scope.\n *\n * Multiple runtime owners may legitimately contribute the same provider, but\n * they must agree on its secret requirements. Missing discovery and divergent\n * shapes fail closed: hashing either state as an empty contract would make the\n * lockfile claim integrity evidence it does not possess.\n */\nfunction resolveProviderSecretsContractShape(\n providerRef: string,\n matchingContributions: DiscoveredProviderCompanionContribution[],\n): DiscoveredProviderCompanionContribution['secretsContractShape'] {\n if (matchingContributions.length === 0) {\n throw new Error(\n `Cannot materialize provider lock entry for \"${providerRef}\": no discovered contribution supplies its secret-contract shape for this runtime.`,\n );\n }\n\n const canonicalShape = matchingContributions[0].secretsContractShape;\n const canonicalDigestInput = stableStringify(canonicalShape);\n for (const contribution of matchingContributions.slice(1)) {\n if (stableStringify(contribution.secretsContractShape) !== canonicalDigestInput) {\n throw new Error(\n `Cannot materialize provider lock entry for \"${providerRef}\": discovered runtime owners disagree on its secret-contract shape.`,\n );\n }\n }\n\n return canonicalShape;\n}\n\nfunction digestJson(value: unknown): string {\n return `sha256:${createHash('sha256').update(stableStringify(value)).digest('hex')}`;\n}\n\nfunction stableStringify(value: unknown): string {\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(',')}]`;\n }\n if (value && typeof value === 'object') {\n const record = value as Record<string, unknown>;\n return `{${Object.keys(record)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`)\n .join(',')}}`;\n }\n return JSON.stringify(value);\n}\n\nfunction mapRecord<TValue, TResult>(\n record: Record<string, TValue>,\n mapper: (value: TValue, key: string) => TResult,\n): Record<string, TResult> {\n return Object.fromEntries(\n Object.entries(record).map(([key, value]) => [key, mapper(value, key)]),\n );\n}\n\nfunction pruneUndefined<T extends Record<string, unknown>>(record: T): T {\n return Object.fromEntries(\n Object.entries(record).filter(([, value]) => value !== undefined),\n ) as T;\n}\n\ninterface ProviderRuntimeArtifactMetadata {\n sourceDigest: string;\n providerRefs: string[];\n providerGraphDigest: string;\n lockfileSectionDigest: string;\n}\n\ninterface ProviderRuntimeArtifactMetadataByKind {\n backend: ProviderRuntimeArtifactMetadata;\n companion: ProviderRuntimeArtifactMetadata;\n frontendServices: ProviderRuntimeArtifactMetadata;\n minions: ProviderRuntimeArtifactMetadata;\n nodeWorkers: ProviderRuntimeArtifactMetadata;\n}\n\ninterface RuntimeContributionMatcherFactory {\n matchesRuntimeTarget: (target: DiscoveredProviderCompanionContribution['runtimeTargets'][number]) => boolean;\n}\n\ninterface ScopedRuntimeContributionMatcherFactory {\n matchesRuntimeTarget: (\n scopeKey: string,\n ) => (target: DiscoveredProviderCompanionContribution['runtimeTargets'][number]) => boolean;\n}\n\ninterface ProviderRuntimeDiscoveryContext {\n contributions: DiscoveredProviderCompanionContribution[];\n backend: RuntimeContributionMatcherFactory;\n companion: RuntimeContributionMatcherFactory;\n frontendServices: ScopedRuntimeContributionMatcherFactory;\n minions: ScopedRuntimeContributionMatcherFactory;\n workers: ScopedRuntimeContributionMatcherFactory;\n}\n\nfunction buildProviderRuntimeDiscoveryContext(input: {\n discoveredContributions?: DiscoveredProviderCompanionContribution[];\n frontendServiceTypes: Record<string, AppFrontendType>;\n}): ProviderRuntimeDiscoveryContext {\n const contributions = input.discoveredContributions ?? [];\n const { frontendServiceTypes } = input;\n\n return {\n contributions,\n backend: {\n matchesRuntimeTarget: (target) => target.kind === 'backend',\n },\n companion: {\n matchesRuntimeTarget: (target) => target.kind === 'companion',\n },\n frontendServices: {\n matchesRuntimeTarget: (serviceKey) => {\n const serviceType = frontendServiceTypes[serviceKey];\n // Service has no frontendType ⇒ no contribution can match it.\n if (!serviceType) return () => false;\n return (target) => target.kind === 'frontendService' && target.serviceType === serviceType;\n },\n },\n minions: {\n matchesRuntimeTarget: (minionKey) => (target) => target.kind === 'minion' && target.minionKey === minionKey,\n },\n workers: {\n matchesRuntimeTarget: (workerKey) => (target) => target.kind === 'worker' && target.workerKey === workerKey,\n },\n };\n}\n\nfunction buildArtifactMetadata(input: {\n discoveryContext: ProviderRuntimeDiscoveryContext;\n frontendServiceTypes: Record<string, AppFrontendType>;\n lockSection: SaasLockfileProvidersSection;\n modules: RuntimeProviderModulesArtifact;\n nodeWorkerKeys?: string[];\n scopes: SaasProvidersScopes;\n}): ProviderRuntimeArtifactMetadataByKind {\n const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes } = input;\n const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;\n\n return {\n backend: buildSingleScopeArtifactMetadata({\n modules,\n providers: scopes.backend?.providers ?? {},\n matchingContributions: findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.backend.matchesRuntimeTarget,\n }),\n extraArtifactState: buildFrontendProviderBootstrapDigestInput({\n discoveredContributions: discoveryContext.contributions,\n frontendServiceScopes: scopes.frontendServices ?? {},\n frontendServiceTypes,\n }),\n runtimeLockSection: lockSection.runtimeScopes.backend ?? {},\n scopes,\n }),\n companion: buildSingleScopeArtifactMetadata({\n modules,\n providers: scopes.companion?.providers ?? {},\n matchingContributions: findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.companion.matchesRuntimeTarget,\n }),\n runtimeLockSection: lockSection.runtimeScopes.companion ?? {},\n scopes,\n }),\n frontendServices: buildMultiScopeArtifactMetadata({\n keyedProviders: Object.fromEntries(\n Object.entries(scopes.frontendServices ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers]),\n ),\n matchingContributionsByScope: Object.fromEntries(\n Object.keys(scopes.frontendServices ?? {}).map((scopeKey) => [\n scopeKey,\n findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.frontendServices.matchesRuntimeTarget(scopeKey),\n }),\n ]),\n ),\n modules,\n extraArtifactState: buildFrontendProviderBootstrapDigestInput({\n discoveredContributions: discoveryContext.contributions,\n frontendServiceScopes: scopes.frontendServices ?? {},\n frontendServiceTypes,\n }),\n runtimeLockSection: lockSection.runtimeScopes.frontendServices ?? {},\n scopes,\n }),\n minions: buildMultiScopeArtifactMetadata({\n keyedProviders: Object.fromEntries(\n Object.entries(scopes.minions ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers]),\n ),\n matchingContributionsByScope: Object.fromEntries(\n Object.keys(scopes.minions ?? {}).map((scopeKey) => [\n scopeKey,\n findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.minions.matchesRuntimeTarget(scopeKey),\n }),\n ]),\n ),\n modules,\n runtimeLockSection: lockSection.runtimeScopes.minions ?? {},\n scopes,\n }),\n nodeWorkers: buildMultiScopeArtifactMetadata({\n keyedProviders: Object.fromEntries(\n Object.entries(scopes.workers ?? {})\n .filter(([scopeKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)\n .map(([scopeKey, scope]) => [scopeKey, scope.providers]),\n ),\n matchingContributionsByScope: Object.fromEntries(\n Object.keys(scopes.workers ?? {})\n .filter((scopeKey) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)\n .map((scopeKey) => [\n scopeKey,\n findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.workers.matchesRuntimeTarget(scopeKey),\n }),\n ]),\n ),\n modules,\n runtimeLockSection: Object.fromEntries(\n Object.entries(lockSection.runtimeScopes.workers ?? {})\n .filter(([scopeKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true),\n ),\n scopes,\n }),\n };\n}\n\nfunction buildSingleScopeArtifactMetadata(input: {\n matchingContributions: DiscoveredProviderCompanionContribution[];\n modules: RuntimeProviderModulesArtifact;\n providers: Record<string, SaasProviderScopeSelection>;\n extraArtifactState?: Record<string, unknown>;\n runtimeLockSection: Record<string, unknown>;\n scopes: SaasProvidersScopes;\n}): ProviderRuntimeArtifactMetadata {\n const providerRefs = Object.keys(input.providers).sort();\n const normalizedContributions = normalizeDiscoveredContributionsForDigest(input.matchingContributions);\n const providerGraphDigestInput = input.extraArtifactState\n ? {\n providerGraph: normalizedContributions,\n extraArtifactState: input.extraArtifactState,\n }\n : normalizedContributions;\n\n return {\n sourceDigest: digestJson({\n modules: input.modules,\n providers: input.providers,\n providerGraph: normalizedContributions,\n scopes: input.scopes,\n extraArtifactState: input.extraArtifactState,\n }),\n providerRefs,\n providerGraphDigest: digestJson(providerGraphDigestInput),\n lockfileSectionDigest: digestJson(input.runtimeLockSection),\n };\n}\n\nfunction buildMultiScopeArtifactMetadata(input: {\n keyedProviders: Record<string, Record<string, SaasProviderScopeSelection>>;\n matchingContributionsByScope: Record<string, DiscoveredProviderCompanionContribution[]>;\n modules: RuntimeProviderModulesArtifact;\n extraArtifactState?: Record<string, unknown>;\n runtimeLockSection: Record<string, unknown>;\n scopes: SaasProvidersScopes;\n}): ProviderRuntimeArtifactMetadata {\n const providerRefs = [...new Set(\n Object.values(input.keyedProviders).flatMap((providers) => Object.keys(providers)),\n )].sort();\n const normalizedContributionsByScope = Object.fromEntries(\n Object.entries(input.matchingContributionsByScope).map(([scopeKey, contributions]) => [\n scopeKey,\n normalizeDiscoveredContributionsForDigest(contributions),\n ]),\n );\n\n const providerGraphDigestInput = input.extraArtifactState\n ? {\n providerGraphByScope: normalizedContributionsByScope,\n extraArtifactState: input.extraArtifactState,\n }\n : normalizedContributionsByScope;\n\n return {\n sourceDigest: digestJson({\n keyedProviders: input.keyedProviders,\n modules: input.modules,\n providerGraphByScope: normalizedContributionsByScope,\n scopes: input.scopes,\n extraArtifactState: input.extraArtifactState,\n }),\n providerRefs,\n providerGraphDigest: digestJson(providerGraphDigestInput),\n lockfileSectionDigest: digestJson(input.runtimeLockSection),\n };\n}\n\nfunction findMatchingDiscoveredContributions(input: {\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n matchesRuntimeTarget: (target: DiscoveredProviderCompanionContribution['runtimeTargets'][number]) => boolean;\n providerRef?: string;\n}): DiscoveredProviderCompanionContribution[] {\n return input.discoveredContributions.flatMap((contribution) => {\n if (input.providerRef && contribution.ref !== input.providerRef) {\n return [];\n }\n const runtimeTargets = contribution.runtimeTargets.filter(input.matchesRuntimeTarget);\n if (runtimeTargets.length === 0) {\n return [];\n }\n return [{ ...contribution, runtimeTargets }];\n });\n}\n\n/**\n * The portion of a contribution's `owner` that may enter a digest.\n *\n * **`packageRoot` is deliberately excluded, and this is the whole point of the\n * function.** Discovery builds it as `resolve(saasRoot, definition.path)` — an\n * ABSOLUTE filesystem path — so hashing it makes every value derived from this\n * normalizer a property of WHERE THE REPOSITORY HAPPENS TO BE CHECKED OUT\n * rather than of the provider graph.\n *\n * That is not a theoretical concern; it was measured on 2026-08-30. The same\n * Wonder Todos tree, materialized from its real directory and from a symlink to\n * it, produced two different lock digests for every provider in every scope\n * (`sha256:f7eeb2d6…` vs `sha256:d933b95a…` for backend `anthropic`), and a dump\n * of the two contribution sets differed in `owner.packageRoot` and nothing else.\n * The consequences were both real:\n *\n * - `examples/wonder-todos/.wildo-saas/wildo-saas.lock.json` carried 22 digests\n * scoped to whichever checkout last ran `wildo config sync`, so the\n * `Lockfile Drift Check` gate — which runs at `/home/runner/work/…` — could\n * never have agreed with a committed value regardless of actual drift.\n * - The same input feeds `sourceDigest` / `providerGraphDigest` in the generated\n * runtime artifacts and `.wildo-providers.env`, so artifacts generated on a\n * developer's machine and re-materialized under a container's `/app` would\n * trip the `digest-mismatch` runtime diagnostic while describing an identical\n * provider graph.\n *\n * `kind` + `key` already identify an owner uniquely (both are record keys within\n * their config block), so nothing distinguishing is lost. What IS given up is\n * that relocating an owner package without changing its contribution content no\n * longer moves the digest — accepted deliberately: a repository-layout change is\n * not a provider-contract change, and if that signal is ever wanted it must\n * arrive as a saas-root-RELATIVE path, never an absolute one.\n */\nfunction projectOwnerForDigest(\n owner: DiscoveredProviderCompanionContribution['owner'],\n): { kind: string; key: string } {\n return { kind: owner.kind, key: owner.key };\n}\n\nfunction normalizeDiscoveredContributionsForDigest(\n contributions: DiscoveredProviderCompanionContribution[],\n): Array<Record<string, unknown>> {\n return [...contributions]\n .sort((left, right) => stableStringify({\n leftOwner: projectOwnerForDigest(left.owner),\n leftRef: left.ref,\n leftRuntimeImportPath: left.runtimeImportPath,\n leftSourceModuleId: left.sourceModuleId,\n leftTargets: left.runtimeTargets,\n }).localeCompare(stableStringify({\n rightOwner: projectOwnerForDigest(right.owner),\n rightRef: right.ref,\n rightRuntimeImportPath: right.runtimeImportPath,\n rightSourceModuleId: right.sourceModuleId,\n rightTargets: right.runtimeTargets,\n })))\n .map((contribution) => ({\n ref: contribution.ref,\n owner: projectOwnerForDigest(contribution.owner),\n runtimeImportPath: contribution.runtimeImportPath,\n runtimeTargets: contribution.runtimeTargets,\n engineCapabilities: [...contribution.engineCapabilities].sort(),\n providerCapabilities: [...contribution.providerCapabilities].sort(),\n protocols: [...contribution.protocols].sort(),\n secretsContractShape: contribution.secretsContractShape,\n frontendEntry: contribution.frontendEntry\n ? {\n metadata: contribution.frontendEntry.metadata,\n providerCapabilities: [...contribution.frontendEntry.providerCapabilities].sort(),\n protocols: [...contribution.frontendEntry.protocols].sort(),\n publicConfig: contribution.frontendEntry.publicConfig,\n }\n : undefined,\n sourceModuleId: contribution.sourceModuleId,\n }));\n}\n"]}
1
+ {"version":3,"file":"provider-runtime-artifacts.js","sourceRoot":"","sources":["../../../../src/project-config/provider-runtime-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,W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Y,CAAC,aAAa,CAAC,YAAY;aACtD;YACD,CAAC,CAAC,SAAS;QACb,cAAc,EAAE,YAAY,CAAC,cAAc;KAC5C,CAAC,CAAC,CAAC;AACR,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { resolve as resolvePath } from 'node:path';\nimport { z } from 'zod';\nimport {\n AppFrontendType,\n FrontendProvidersBlockSchema,\n type FrontendProviderEntry,\n type FrontendProvidersBlock,\n} from '@wildo-ai/saas-models';\nimport {\n SaasLockfileProvidersSectionSchema,\n type SaasLockfileProvidersSection,\n type SaasLockfileRuntimeScopesProviders,\n} from '../lockfile/wildo-saas-lock.shared.schemas';\nimport {\n getDeclaredApplicationModuleIds,\n getServiceBoundApplicationModuleIds,\n} from './shared/application-modules.utils';\nimport type { ApplicationModules } from './shared/application-modules.schemas';\nimport {\n SaasProvidersScopesSchema,\n SaasProviderScopeSelectionSchema,\n type SaasProviderScopeSelection,\n type SaasProvidersScopes,\n type WildoSaasConfig,\n} from './define-saas-config';\nimport type { DiscoveredProviderCompanionContribution } from './provider-companion-discovery';\n\nexport const PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING =\n 'AUTO-GENERATED FILE. DO NOT EDIT. Regenerate with `wildo config sync`.';\n\nexport const PROVIDER_RUNTIME_ARTIFACT_GENERATOR = 'wildo provider-runtime-artifact';\n\n/**\n * Canonical relative paths (from saas root) for the per-runtime-kind\n * provider artifact JSON files emitted by `wildo config sync`.\n *\n * Moved from `.wildo-saas/providers/` → `.wildo-saas/generated/providers/`\n * on 2026-05-06 to group ALL CLI-generated runtime topology artifacts\n * under the `.wildo-saas/generated/` namespace (sibling to other\n * generated state). The legacy `.wildo-saas/providers/` location is\n * cleaned up by `cleanupLegacyProviderJsonArtifacts` in the CLI sync\n * so operators don't end up with two copies after the migration.\n */\nexport const PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS = {\n backend: '.wildo-saas/generated/providers/backend.runtime-providers.generated.json',\n companion: '.wildo-saas/generated/providers/companion.runtime-providers.generated.json',\n frontendServices: '.wildo-saas/generated/providers/frontend-services.runtime-providers.generated.json',\n minions: '.wildo-saas/generated/providers/minions.runtime-providers.generated.json',\n nodeWorkers: '.wildo-saas/generated/providers/node-workers.runtime-providers.generated.json',\n} as const;\n\n/**\n * Legacy paths (pre-2026-05-06) for the per-runtime-kind provider\n * artifact JSON files. These are NOT written anymore — kept here so\n * `wildo config sync` can clean them up if they exist on disk from a\n * pre-migration sync. Drop this constant entirely once Wonder Todos\n * + downstream apps have all run a post-migration sync at least once.\n */\nexport const LEGACY_PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS = {\n backend: '.wildo-saas/providers/backend.runtime-providers.generated.json',\n companion: '.wildo-saas/providers/companion.runtime-providers.generated.json',\n frontendServices: '.wildo-saas/providers/frontend-services.runtime-providers.generated.json',\n minions: '.wildo-saas/providers/minions.runtime-providers.generated.json',\n nodeWorkers: '.wildo-saas/providers/node-workers.runtime-providers.generated.json',\n} as const;\n\nexport type ProviderRuntimeArtifactKind = keyof typeof PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS;\n\nexport const PROVIDER_RUNTIME_GENERATED_MODULE_RELATIVE_PATH =\n 'src/generated/wildo-provider-runtime.generated.ts';\n\n/**\n * Canonical lockfile section path the provider-materialization\n * subsystem owns end-to-end. Used by the post-mutation provider sync\n * runner + materialization-hook return types and pinned by tests\n * (`provider-sync-runner.test.ts`, `provider-materialization-hook.test.ts`).\n *\n * Defined here as a single-source constant — used to live as a\n * literal in 3+ places across `wildo-module-client` (third-pass\n * review C-L1).\n */\nexport const PROVIDER_LOCK_SECTION_PATH = 'sections.providers.runtimeScopes' as const;\n\n/**\n * Per-worker generated env file written by `wildo config sync`. Carries\n * provider topology env vars derived from the materialized scope.\n *\n * This file is the **single delivery channel** non-Node workers (Rust /\n * Java / etc.) receive for provider topology — there is no executable\n * JS bundle in their case (Step 5b in\n * `.claude/plans/provider-migration-continuation.md`). Node workers\n * receive both this file and the per-package\n * `wildo-provider-runtime.generated.ts` source module; reading either\n * surface yields a consistent view because they share the same digest.\n *\n * The file is auto-generated and overwritten on every sync. Operator-\n * authored secrets and per-env config stay in the worker's `.env` (not\n * touched by `wildo config sync`); workers should load both files at\n * boot — operator vars from `.env` and provider vars from this file —\n * so the two channels never collide.\n */\nexport const PROVIDER_RUNTIME_GENERATED_ENV_FILE_NAME = '.wildo-providers.env';\n\nconst RuntimeProviderScopeArtifactSchema = z.strictObject({\n providers: z.record(z.string(), SaasProviderScopeSelectionSchema).default({}),\n selection: z.record(\n z.string(),\n z.strictObject({\n primary: z.string().min(1),\n whenUnavailable: z.array(z.string().min(1)).default([]),\n }),\n ).default({}),\n});\n\nconst RuntimeProviderModulesArtifactSchema = z.strictObject({\n declaredModules: z.record(\n z.string(),\n z.strictObject({\n services: z.array(z.string().min(1)),\n haveSamlIntegration: z.boolean().optional(),\n }),\n ).default({}),\n moduleIds: z.array(z.string().min(1)).default([]),\n moduleIdsByService: z.record(z.string(), z.array(z.string().min(1))).default({}),\n});\nexport type RuntimeProviderModulesArtifact = z.infer<typeof RuntimeProviderModulesArtifactSchema>;\n\n/**\n * The per-service frontend bootstrap map, ANNOTATED through a nominal interface rather than inferred.\n *\n * `FrontendProvidersBlockSchema` transitively references three atoms that `@wildo-ai/saas-models`\n * publishes from `/public-runtime` alone, so a consumer that resolves this package's dependency to\n * SOURCE — the minion and worker libraries do, deliberately — has no public specifier through which\n * to NAME them. While the artifact object stayed small TypeScript inlined the shape and nobody\n * noticed; the moment it grew one member past the inline threshold it needed the name and refused:\n * `TS2742 … cannot be named without a reference to\n * node_modules/@wildo-ai/saas-models/src/external-providers/provider-frontend-surface.shared.schemas`.\n *\n * An INTERFACE is what stops the expansion — a type alias is written out structurally in the emitted\n * declaration and takes the unnameable atoms with it, while an interface is written by name. The\n * underlying defect is a root-exported contract depending on a subpath-only module\n * (`package-public-entrypoints.md`, \"The root barrel must not DEPEND on a subpath-only surface\");\n * that module is the frozen provider contract, so it is filed as #356 rather than fixed here. Runtime\n * behaviour and the inferred field type are unchanged.\n */\nexport interface RuntimeProviderFrontendBootstraps {\n [serviceKey: string]: FrontendProvidersBlock;\n}\n\nconst FrontendProviderBootstrapsSchema: z.ZodType<RuntimeProviderFrontendBootstraps> = z.record(\n z.string().min(1),\n FrontendProvidersBlockSchema,\n);\n\nexport const SaasRuntimeProvidersArtifactSchema = z.strictObject({\n __AUTOGENERATED__: z.literal(PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING),\n generatedBy: z.literal(PROVIDER_RUNTIME_ARTIFACT_GENERATOR),\n generatedAt: z.string().datetime({ offset: true }),\n sourceDigest: z.string().min(1),\n providerRefs: z.array(z.string().min(1)).default([]),\n /**\n * `providerRef` -> the package specifier a host dynamic-imports to obtain that provider's backend\n * module (#330).\n *\n * `providerRefs` says WHICH providers a process may expose; this says WHERE each one comes from,\n * and it is what makes a provider shipped as its own npm package loadable at all. Derived from\n * the discovered contribution whose `runtimeTargets` match the host — never authored.\n *\n * Optional, so an artifact written before this field existed still parses. Every ref such an\n * artifact names is engine-shipped, and a host resolves those from the engine's own on-demand map\n * without consulting this record, so an un-resynced application is unaffected.\n */\n providerRuntimeImports: z.record(z.string().min(1), z.string().min(1)).optional(),\n providerGraphDigest: z.string().min(1),\n lockfileSectionDigest: z.string().min(1),\n artifactKind: z.enum([\n 'backend',\n 'companion',\n 'frontendServices',\n 'minions',\n 'nodeWorkers',\n ]),\n modules: RuntimeProviderModulesArtifactSchema,\n scope: RuntimeProviderScopeArtifactSchema.optional(),\n scopes: z.record(z.string(), RuntimeProviderScopeArtifactSchema).optional(),\n frontendProviderBootstraps: FrontendProviderBootstrapsSchema.optional(),\n});\nexport type SaasRuntimeProvidersArtifact = z.infer<typeof SaasRuntimeProvidersArtifactSchema>;\n\nexport interface MaterializedSaasProviderRuntimeArtifacts {\n artifacts: Partial<Record<ProviderRuntimeArtifactKind, SaasRuntimeProvidersArtifact>>;\n lockSection: SaasLockfileProvidersSection;\n}\n\nexport function materializeSaasProviderRuntimeArtifacts(\n config: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services'>,\n options?: {\n generatedAt?: string;\n nodeWorkerKeys?: string[];\n discoveredContributions?: DiscoveredProviderCompanionContribution[];\n },\n): MaterializedSaasProviderRuntimeArtifacts {\n const scopes = SaasProvidersScopesSchema.parse(config.providers.scopes);\n const generatedAt = options?.generatedAt ?? new Date().toISOString();\n const modules = materializeModules(config);\n const frontendServiceTypes: Record<string, AppFrontendType> = Object.fromEntries(\n Object.entries(config.services ?? {})\n .filter(([, definition]) => definition.frontendType !== undefined)\n .map(([serviceKey, definition]) => [serviceKey, definition.frontendType as AppFrontendType]),\n );\n const discoveryContext = buildProviderRuntimeDiscoveryContext({\n discoveredContributions: options?.discoveredContributions,\n frontendServiceTypes,\n });\n\n const lockSection = SaasLockfileProvidersSectionSchema.parse({\n runtimeScopes: materializeLockRuntimeScopes({\n scopes,\n discoveryContext,\n }),\n });\n const artifactMetadata = buildArtifactMetadata({\n discoveryContext,\n frontendServiceTypes,\n lockSection,\n modules,\n nodeWorkerKeys: options?.nodeWorkerKeys,\n scopes,\n });\n\n const artifacts = materializeRuntimeArtifacts({\n artifactMetadata,\n discoveryContext,\n frontendServiceTypes,\n generatedAt,\n modules,\n nodeWorkerKeys: options?.nodeWorkerKeys,\n scopes,\n });\n\n return { artifacts, lockSection };\n}\n\nexport function selectScopedProviderRuntimeArtifact(\n artifact: SaasRuntimeProvidersArtifact,\n scopeKey: string,\n): SaasRuntimeProvidersArtifact {\n if (!artifact.scopes) {\n throw new Error(`Provider runtime artifact '${artifact.artifactKind}' does not contain keyed scopes.`);\n }\n\n const scope = artifact.scopes[scopeKey];\n if (!scope) {\n throw new Error(`Provider runtime artifact '${artifact.artifactKind}' does not contain scope '${scopeKey}'.`);\n }\n\n // Recompute `providerRefs` from the projected per-host scope rather\n // than carrying the parent multi-scope union forward unchanged. The\n // multi-scope artifact's `providerRefs` is the union across all\n // hosts (`buildMultiScopeArtifactMetadata`); preserving that union\n // on a single-scope projection makes the per-host artifact internally\n // inconsistent — `scope.providers` would describe one host while\n // `providerRefs` would describe siblings too. The boot-time\n // `assertProviderRuntimeEnvInSync` guard treats `providerRefs.length > 0`\n // as \"this host has providers to reconcile\" — without this\n // recomputation, an empty-scope host would inherit the union and\n // trip the env-missing guard even though its `.wildo-providers.env`\n // was deliberately not written. Recomputation also tightens\n // `BackendProviderRegistry`'s filter (today defended by an empty-list\n // fallback) so the per-host artifact accurately advertises only the\n // refs it should resolve.\n const projectedProviderRefs = Object.keys(scope.providers).sort();\n\n return SaasRuntimeProvidersArtifactSchema.parse({\n ...artifact,\n providerRefs: projectedProviderRefs,\n // Narrowed for the same reason `providerRefs` is recomputed above: the multi-scope artifact's\n // import map is the union across every host, and a per-host projection that advertised a\n // sibling's packages would tell this host it can load something it never declared.\n providerRuntimeImports: Object.fromEntries(\n Object.entries(artifact.providerRuntimeImports ?? {})\n .filter(([providerRef]) => projectedProviderRefs.includes(providerRef)),\n ),\n frontendProviderBootstraps: artifact.frontendProviderBootstraps?.[scopeKey]\n ? { [scopeKey]: artifact.frontendProviderBootstraps[scopeKey] }\n : undefined,\n scope,\n scopes: undefined,\n });\n}\n\n/**\n * Resolve the absolute path to the canonical\n * `frontend-services.runtime-providers.generated.json` artifact under\n * `<saasRoot>/.wildo-saas/generated/providers/`.\n *\n * Build-time consumers (Wonder Todos website + tech-doc) call this\n * instead of hardcoding the relative path so the artifact location\n * stays canonical (single source of truth is\n * `PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS`).\n */\nexport function resolveFrontendServicesArtifactPath(saasRoot: string): string {\n return resolvePath(saasRoot, PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS.frontendServices);\n}\n\n/**\n * Read + project the materialized frontend-services artifact for the\n * given service key. Returns `undefined` if the artifact file is\n * missing (sync hasn't run yet / clean checkout) or if the service\n * has no provider bootstrap entry.\n *\n * The single source of truth for build-time loading of the frontend\n * provider bootstraps. Replaces the (previously duplicated)\n * `loadMaterializedFrontendProviders` helpers that lived in\n * `saas-technical-doc/src/build/load-materialized-frontend-providers.ts`\n * and inline in `examples/wonder-todos/website/src/website-site-context.ts`.\n *\n * Both consumers used identical control flow:\n * 1. existsSync() short-circuit\n * 2. JSON.parse + SaasRuntimeProvidersArtifactSchema.parse\n * 3. frontendProviderBootstraps[serviceKey] lookup\n * 4. FrontendProvidersBlockSchema.parse on the per-service block\n * Centralized 2026-05-06 so a future schema/path change only\n * requires editing this function.\n */\nexport function loadMaterializedFrontendProviders(input: {\n artifactPath: string;\n serviceKey: string;\n}): FrontendProvidersBlock | undefined {\n const { artifactPath, serviceKey } = input;\n\n if (!existsSync(artifactPath)) {\n return undefined;\n }\n\n const parsedArtifact = SaasRuntimeProvidersArtifactSchema.safeParse(\n JSON.parse(readFileSync(artifactPath, 'utf8')),\n );\n if (!parsedArtifact.success) {\n throw staleGeneratedArtifactError(artifactPath, parsedArtifact.error.issues);\n }\n const providerBlock = parsedArtifact.data.frontendProviderBootstraps?.[serviceKey];\n if (providerBlock === undefined) return undefined;\n\n const parsedBlock = FrontendProvidersBlockSchema.safeParse(providerBlock);\n if (!parsedBlock.success) {\n throw staleGeneratedArtifactError(artifactPath, parsedBlock.error.issues);\n }\n return parsedBlock.data;\n}\n\n/**\n * A materialized artifact that does not satisfy the current schema was almost always generated\n * before the contract changed (#328 added the provider identity to every frontend entry). A raw\n * Zod issue list reads as a logic defect in the consumer; the remedy is regeneration, so the\n * error names it. The backend's `applyProviderRuntime` says the same thing for its own reader —\n * one message, two readers.\n */\nfunction staleGeneratedArtifactError(artifactPath: string, issues: ReadonlyArray<{ path: PropertyKey[]; message: string }>): Error {\n return new Error(\n `The generated provider runtime artifact at ${artifactPath} does not satisfy the current contract — it was most `\n + 'likely generated before the contract changed. Regenerate it with `wildo config sync`. Issues: '\n + issues.map((issue) => `${issue.path.map(String).join('.')}: ${issue.message}`).join('; '),\n );\n}\n\nexport function renderProviderRuntimeGeneratedModule(\n artifact: SaasRuntimeProvidersArtifact,\n): string {\n const artifactLiteral = JSON.stringify(artifact, null, 2);\n\n return [\n '/**',\n ` * ${PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING}`,\n ' *',\n ' * This module is generated from wildo.saas.config.ts by `wildo config sync`.',\n ' * It contains environment-independent provider topology only.',\n ' */',\n '',\n // Intentionally NOT `as const` — the generated artifact is *data*, not a\n // frozen literal-typed tuple. Each host (backend / companion / minion /\n // worker) casts the imported value to its own narrowed runtime-artifact\n // type (`ProviderRuntimeArtifact`, `MinionProviderRuntimeArtifact`, …).\n // `as const` would infer `readonly` tuples (e.g. `readonly [\"openai\"]`)\n // that fail TS2352 against the schema-inferred mutable `string[]` shape.\n // Contract conformance is enforced upstream by\n // `SaasRuntimeProvidersArtifactSchema.parse(...)` at materialization time,\n // so widening the TS surface here costs no runtime safety.\n `export const WILDO_PROVIDER_RUNTIME = ${artifactLiteral};`,\n '',\n 'export default WILDO_PROVIDER_RUNTIME;',\n '',\n ].join('\\n');\n}\n\n/**\n * Canonical worker provider env-var keys. All workers receive the same\n * three keys regardless of language; the values are stable across runs\n * as long as the authored scope and discovered contributions don't\n * change.\n *\n * - `WILDO_PROVIDER_REFS` — comma-separated list of authored refs (sorted).\n * Cheap to read from any language (no JSON parser needed).\n * - `WILDO_PROVIDER_TOPOLOGY_JSON` — the per-worker `scope` block from\n * the materialized artifact, JSON-encoded. Workers that want\n * structured access (capability/protocol set) parse this; workers\n * that only need ref membership read `WILDO_PROVIDER_REFS`.\n * - `WILDO_PROVIDER_RUNTIME_DIGEST` — the artifact's `sourceDigest`.\n * Workers can fail-closed at boot if their copy of the env-file\n * disagrees with the lockfile section digest the platform expects.\n */\nexport const PROVIDER_RUNTIME_ENV_KEYS = {\n REFS: 'WILDO_PROVIDER_REFS',\n TOPOLOGY_JSON: 'WILDO_PROVIDER_TOPOLOGY_JSON',\n RUNTIME_DIGEST: 'WILDO_PROVIDER_RUNTIME_DIGEST',\n} as const;\n\n/**\n * Render the per-worker provider env-file body. Inputs:\n * - `scope` — the per-worker scope block from\n * `WildoSaasConfig.providers.scopes.workers[<workerKey>]`. Carries\n * the authored providers + capability/protocol declarations that\n * this worker needs to resolve at runtime.\n * - `sourceDigest` — `SaasRuntimeProvidersArtifact.sourceDigest`\n * (from the lockfile or the corresponding generated artifact).\n *\n * Output: a deterministic dotenv body — sorted refs, stable JSON\n * key ordering — so re-running `wildo config sync` with no upstream\n * changes produces a byte-identical file.\n */\nexport function renderProviderRuntimeEnvFile(input: {\n scope: SaasProviderScopeSelections;\n sourceDigest: string;\n}): string {\n const refs = Object.keys(input.scope.providers).sort();\n const topology: Record<string, {\n engineCapabilities: string[];\n providerCapabilities: string[];\n protocols: string[];\n }> = {};\n for (const ref of refs) {\n const selection = input.scope.providers[ref];\n topology[ref] = {\n engineCapabilities: [...selection.engineCapabilities].sort(),\n providerCapabilities: [...selection.providerCapabilities].sort(),\n protocols: [...selection.protocols].sort(),\n };\n }\n\n return [\n `# ${PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING}`,\n '#',\n '# This file is regenerated on every `wildo config sync`. Do not edit by hand.',\n '# Operator-authored secrets / per-env config stay in `.env` and are never touched here.',\n '',\n `${PROVIDER_RUNTIME_ENV_KEYS.REFS}=${refs.join(',')}`,\n `${PROVIDER_RUNTIME_ENV_KEYS.TOPOLOGY_JSON}=${JSON.stringify(topology)}`,\n `${PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST}=${input.sourceDigest}`,\n '',\n ].join('\\n');\n}\n\n/**\n * Result of comparing the runtime host's typed\n * `wildo-provider-runtime.generated.ts` module against its\n * `.wildo-providers.env` file at boot.\n *\n * Drift between the two indicates the operator regenerated one surface\n * but not the other — typically: edited `wildo.saas.config.ts` and\n * re-ran `wildo config sync` while the env file was cached, or vice\n * versa. Either case the runtime would silently boot with mismatched\n * topology unless someone reconciles. See\n * `assertProviderRuntimeEnvInSync` for the fail-closed assertion.\n */\nexport type ProviderRuntimeEnvReconciliationResult =\n | { kind: 'in-sync' }\n | { kind: 'env-missing'; missingKeys: ReadonlyArray<string> }\n | {\n kind: 'refs-mismatch';\n envRefs: ReadonlyArray<string>;\n artifactRefs: ReadonlyArray<string>;\n }\n | {\n kind: 'digest-mismatch';\n envDigest: string;\n artifactDigest: string;\n };\n\n/**\n * Reconcile a runtime artifact's typed projection against the\n * `.wildo-providers.env` mounted into the same process. Pure function\n * so callers can decide how to surface the result (throw / log / ignore).\n *\n * The env file is materialized by `renderProviderRuntimeEnvFile` for\n * EVERY runtime host that is a minion or worker; the typed module is\n * imported by the same hosts. Both should agree on\n * `(providerRefs, sourceDigest)` exactly. Drift means stale sync.\n *\n * Hosts that don't receive an env file (backend, companion, frontend\n * services per `provider-runtime-sync.service.ts`) MUST NOT call this —\n * `WILDO_PROVIDER_*` keys won't be set and every call returns\n * `env-missing`.\n */\nexport function reconcileProviderRuntimeEnv(input: {\n artifactProviderRefs: ReadonlyArray<string>;\n artifactSourceDigest: string;\n env?: NodeJS.ProcessEnv;\n}): ProviderRuntimeEnvReconciliationResult {\n const env = input.env ?? process.env;\n const envRefsRaw = env[PROVIDER_RUNTIME_ENV_KEYS.REFS];\n const envDigest = env[PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST];\n\n const missingKeys: string[] = [];\n if (envRefsRaw === undefined) missingKeys.push(PROVIDER_RUNTIME_ENV_KEYS.REFS);\n if (envDigest === undefined) missingKeys.push(PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST);\n if (missingKeys.length > 0) {\n return { kind: 'env-missing', missingKeys };\n }\n\n // Filter empty entries so trailing-comma input (e.g. `'openai,'`) or\n // operator-edited stray whitespace don't produce confusing `''`\n // entries in mismatch diagnostics. Materializer never emits trailing\n // commas, but defense-in-depth keeps the helper robust to anything\n // that lands the env file via dotenv loaders or hand-edits.\n const envRefs = envRefsRaw!\n .split(',')\n .map((s) => s.trim())\n .filter((s) => s.length > 0)\n .sort();\n const artifactRefs = [...input.artifactProviderRefs].sort();\n\n if (envRefs.length !== artifactRefs.length || envRefs.some((ref, i) => ref !== artifactRefs[i])) {\n return { kind: 'refs-mismatch', envRefs, artifactRefs };\n }\n\n if (envDigest !== input.artifactSourceDigest) {\n return {\n kind: 'digest-mismatch',\n envDigest: envDigest!,\n artifactDigest: input.artifactSourceDigest,\n };\n }\n\n return { kind: 'in-sync' };\n}\n\n/**\n * Fail-closed wrapper around `reconcileProviderRuntimeEnv`. Throws on\n * any divergence, returns silently when in sync. Designed to be called\n * once at runtime-host boot (minion / Node-worker startup) so a stale\n * `.wildo-providers.env` surfaces immediately instead of being masked\n * by `process.env` drift.\n *\n * Throws a plain `Error` (not `WildoError_Backend`) because this runs\n * BEFORE the DI container has built the error builder — the failure\n * mode here is \"the container can't be trusted to boot at all\".\n */\nexport function assertProviderRuntimeEnvInSync(input: {\n artifactProviderRefs: ReadonlyArray<string>;\n artifactSourceDigest: string;\n hostKind: 'minion' | 'node-worker';\n hostKey: string;\n env?: NodeJS.ProcessEnv;\n}): void {\n const result = reconcileProviderRuntimeEnv(input);\n switch (result.kind) {\n case 'in-sync':\n return;\n case 'env-missing':\n throw new Error(\n `[provider-runtime-env] ${input.hostKind} '${input.hostKey}' booted without `\n + `provider env vars (${result.missingKeys.join(', ')}). The `\n + `\\`.wildo-providers.env\\` file should be mounted into this process — check `\n + `the docker-compose \\`env_file:\\` directive, the K8s ConfigMap mount, or the `\n + `dotenv loader. Re-run \\`wildo config sync\\` to regenerate if missing.`,\n );\n case 'refs-mismatch':\n throw new Error(\n `[provider-runtime-env] ${input.hostKind} '${input.hostKey}' detected stale provider topology. `\n + `\\`.wildo-providers.env\\` advertises refs [${result.envRefs.join(', ')}] but the `\n + `imported \\`wildo-provider-runtime.generated.ts\\` module declares `\n + `[${result.artifactRefs.join(', ')}]. Run \\`wildo config sync\\` to regenerate `\n + `both surfaces from the same \\`wildo.saas.config.ts\\` source.`,\n );\n case 'digest-mismatch':\n throw new Error(\n `[provider-runtime-env] ${input.hostKind} '${input.hostKey}' detected provider runtime digest drift. `\n + `\\`.wildo-providers.env\\` carries digest '${result.envDigest}' but the imported `\n + `\\`wildo-provider-runtime.generated.ts\\` module carries '${result.artifactDigest}'. `\n + `Refs match, but per-provider capabilities/protocols may differ. `\n + `Run \\`wildo config sync\\` to regenerate.`,\n );\n }\n}\n\ntype SaasProviderScopeSelections = {\n providers: Record<string, {\n engineCapabilities: ReadonlyArray<string>;\n providerCapabilities: ReadonlyArray<string>;\n protocols: ReadonlyArray<string>;\n }>;\n};\n\nfunction materializeRuntimeArtifacts(input: {\n artifactMetadata: ProviderRuntimeArtifactMetadataByKind;\n discoveryContext: ProviderRuntimeDiscoveryContext;\n frontendServiceTypes: Record<string, AppFrontendType>;\n generatedAt: string;\n modules: RuntimeProviderModulesArtifact;\n nodeWorkerKeys?: string[];\n scopes: SaasProvidersScopes;\n}): MaterializedSaasProviderRuntimeArtifacts['artifacts'] {\n const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes } = input;\n const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;\n const nodeWorkerScopes = scopes.workers\n ? Object.fromEntries(\n Object.entries(scopes.workers).filter(([workerKey]) =>\n nodeWorkerKeySet ? nodeWorkerKeySet.has(workerKey) : true,\n ),\n )\n : undefined;\n\n return pruneUndefined({\n backend: materializeRuntimeArtifactFile({\n artifactKind: 'backend',\n generatedAt,\n modules,\n metadata: artifactMetadata.backend,\n frontendProviderBootstraps: materializeFrontendProviderBootstraps({\n discoveredContributions: discoveryContext.contributions,\n frontendServiceScopes: scopes.frontendServices ?? {},\n frontendServiceTypes,\n }),\n scope: materializeRuntimeScope(scopes.backend ?? { providers: {}, selection: {} }),\n }),\n companion: materializeRuntimeArtifactFile({\n artifactKind: 'companion',\n generatedAt,\n modules,\n metadata: artifactMetadata.companion,\n scope: materializeRuntimeScope(scopes.companion ?? { providers: {}, selection: {} }),\n }),\n frontendServices: scopes.frontendServices\n ? materializeRuntimeArtifactFile({\n artifactKind: 'frontendServices',\n generatedAt,\n modules,\n metadata: artifactMetadata.frontendServices,\n frontendProviderBootstraps: materializeFrontendProviderBootstraps({\n discoveredContributions: discoveryContext.contributions,\n frontendServiceScopes: scopes.frontendServices,\n frontendServiceTypes,\n }),\n scopes: mapRecord(scopes.frontendServices, materializeRuntimeScope),\n })\n : undefined,\n minions: scopes.minions\n ? materializeRuntimeArtifactFile({\n artifactKind: 'minions',\n generatedAt,\n modules,\n metadata: artifactMetadata.minions,\n scopes: mapRecord(scopes.minions, materializeRuntimeScope),\n })\n : undefined,\n nodeWorkers: nodeWorkerScopes && Object.keys(nodeWorkerScopes).length > 0\n ? materializeRuntimeArtifactFile({\n artifactKind: 'nodeWorkers',\n generatedAt,\n modules,\n metadata: artifactMetadata.nodeWorkers,\n scopes: mapRecord(nodeWorkerScopes, materializeRuntimeScope),\n })\n : undefined,\n });\n}\n\nfunction materializeRuntimeArtifactFile(input: {\n artifactKind: ProviderRuntimeArtifactKind;\n generatedAt: string;\n metadata: ProviderRuntimeArtifactMetadata;\n modules: RuntimeProviderModulesArtifact;\n frontendProviderBootstraps?: Record<string, FrontendProvidersBlock>;\n scope?: z.infer<typeof RuntimeProviderScopeArtifactSchema>;\n scopes?: Record<string, z.infer<typeof RuntimeProviderScopeArtifactSchema>>;\n}): SaasRuntimeProvidersArtifact {\n return SaasRuntimeProvidersArtifactSchema.parse({\n __AUTOGENERATED__: PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING,\n generatedBy: PROVIDER_RUNTIME_ARTIFACT_GENERATOR,\n generatedAt: input.generatedAt,\n sourceDigest: input.metadata.sourceDigest,\n providerRefs: input.metadata.providerRefs,\n providerRuntimeImports: input.metadata.providerRuntimeImports,\n providerGraphDigest: input.metadata.providerGraphDigest,\n lockfileSectionDigest: input.metadata.lockfileSectionDigest,\n artifactKind: input.artifactKind,\n modules: input.modules,\n scope: input.scope,\n scopes: input.scopes,\n frontendProviderBootstraps: input.frontendProviderBootstraps,\n });\n}\n\nfunction materializeRuntimeScope(scope: NonNullable<SaasProvidersScopes['backend']>) {\n return RuntimeProviderScopeArtifactSchema.parse({\n providers: scope.providers,\n selection: scope.selection ?? {},\n });\n}\n\nfunction materializeFrontendProviderBootstraps(input: {\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n frontendServiceScopes: NonNullable<SaasProvidersScopes['frontendServices']>;\n frontendServiceTypes: Record<string, AppFrontendType>;\n}): Record<string, FrontendProvidersBlock> | undefined {\n const { discoveredContributions, frontendServiceScopes, frontendServiceTypes } = input;\n const entries = Object.entries(frontendServiceScopes).map(([serviceKey, scope]) => {\n const serviceType = frontendServiceTypes[serviceKey];\n if (!serviceType) {\n throw new Error(\n `Cannot materialize frontend bootstrap for service \"${serviceKey}\": ` +\n `service has no frontendType — only services with a frontendType may appear under providers.scopes.frontendServices.`,\n );\n }\n const providers = Object.fromEntries(Object.keys(scope.providers).map((providerRef) => {\n const matchingContribution = discoveredContributions.filter(\n (contribution) =>\n contribution.ref === providerRef\n && contribution.runtimeTargets.some(\n (target) => target.kind === 'frontendService' && target.serviceType === serviceType,\n ),\n );\n\n if (matchingContribution.length === 0) {\n throw new Error(\n `Cannot materialize frontend bootstrap for service \"${serviceKey}\" (type \"${serviceType}\"): ` +\n `provider \"${providerRef}\" has no discovered frontend companion contribution.`,\n );\n }\n\n if (matchingContribution.some((contribution) => !contribution.frontendEntry)) {\n throw new Error(\n `Cannot materialize frontend bootstrap for service \"${serviceKey}\": ` +\n `provider \"${providerRef}\" is missing frontendEntry on at least one discovered contribution.`,\n );\n }\n\n if (matchingContribution.length > 1) {\n throw new Error(\n `Cannot materialize frontend bootstrap for service \"${serviceKey}\": ` +\n `provider \"${providerRef}\" is contributed more than once for the same runtime.`,\n );\n }\n\n return [\n providerRef,\n matchingContribution[0].frontendEntry as FrontendProviderEntry,\n ] as const;\n }));\n\n return [serviceKey, FrontendProvidersBlockSchema.parse({ providers })] as const;\n });\n\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n}\n\nfunction buildFrontendProviderBootstrapDigestInput(input: {\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n frontendServiceScopes: NonNullable<SaasProvidersScopes['frontendServices']>;\n frontendServiceTypes: Record<string, AppFrontendType>;\n}): Record<string, unknown> | undefined {\n const bootstraps = materializeFrontendProviderBootstraps(input);\n if (!bootstraps) {\n return undefined;\n }\n\n return Object.fromEntries(\n Object.entries(bootstraps).map(([serviceKey, block]) => [\n serviceKey,\n Object.fromEntries(\n Object.entries(block.providers).map(([providerRef, providerEntry]) => [\n providerRef,\n {\n metadata: providerEntry.metadata,\n providerCapabilities: [...providerEntry.providerCapabilities].sort(),\n protocols: [...providerEntry.protocols].sort(),\n publicConfig: providerEntry.publicConfig,\n },\n ]),\n ),\n ]),\n );\n}\n\nfunction materializeModules(\n config: Pick<WildoSaasConfig, 'modules' | 'services'>,\n): RuntimeProviderModulesArtifact {\n const modules = (config.modules ?? {}) as NonNullable<ApplicationModules>;\n return RuntimeProviderModulesArtifactSchema.parse({\n declaredModules: modules,\n moduleIds: getDeclaredApplicationModuleIds(modules),\n moduleIdsByService: Object.fromEntries(\n Object.keys(config.services ?? {}).map((serviceKey) => [\n serviceKey,\n getServiceBoundApplicationModuleIds(modules, serviceKey),\n ]),\n ),\n });\n}\n\nfunction materializeLockRuntimeScopes(input: {\n scopes: SaasProvidersScopes;\n discoveryContext: ProviderRuntimeDiscoveryContext;\n}): SaasLockfileRuntimeScopesProviders {\n const { scopes, discoveryContext } = input;\n return pruneUndefined({\n backend: scopes.backend\n ? materializeLockScope(\n scopes.backend.providers,\n discoveryContext.contributions,\n discoveryContext.backend.matchesRuntimeTarget,\n )\n : undefined,\n companion: scopes.companion\n ? materializeLockScope(\n scopes.companion.providers,\n discoveryContext.contributions,\n discoveryContext.companion.matchesRuntimeTarget,\n )\n : undefined,\n frontendServices: scopes.frontendServices\n ? mapRecord(\n scopes.frontendServices,\n (scope, serviceKey) => materializeLockScope(\n scope.providers,\n discoveryContext.contributions,\n discoveryContext.frontendServices.matchesRuntimeTarget(serviceKey),\n ),\n )\n : undefined,\n minions: scopes.minions\n ? mapRecord(\n scopes.minions,\n (scope, minionKey) => materializeLockScope(\n scope.providers,\n discoveryContext.contributions,\n discoveryContext.minions.matchesRuntimeTarget(minionKey),\n ),\n )\n : undefined,\n workers: scopes.workers\n ? mapRecord(\n scopes.workers,\n (scope, workerKey) => materializeLockScope(\n scope.providers,\n discoveryContext.contributions,\n discoveryContext.workers.matchesRuntimeTarget(workerKey),\n ),\n )\n : undefined,\n });\n}\n\nfunction materializeLockScope(\n providers: Record<string, SaasProviderScopeSelection>,\n discoveredContributions: DiscoveredProviderCompanionContribution[],\n matchesRuntimeTarget: (target: DiscoveredProviderCompanionContribution['runtimeTargets'][number]) => boolean,\n): SaasLockfileRuntimeScopesProviders['backend'] {\n return mapRecord(providers, (selection, ref) => {\n const matchingContributions = findMatchingDiscoveredContributions({\n discoveredContributions,\n matchesRuntimeTarget,\n providerRef: ref,\n });\n const secretsContractShape = resolveProviderSecretsContractShape(ref, matchingContributions);\n\n return {\n ref,\n digest: digestJson({\n selection,\n providerGraph: normalizeDiscoveredContributionsForDigest(matchingContributions),\n }),\n engineCapabilities: selection.engineCapabilities,\n providerCapabilities: selection.providerCapabilities,\n protocols: selection.protocols,\n // assurance-control: WILDO.SECRETS.CONTRACT_INTEGRITY — lock drift\n // covers the values-free provider contract without persisting secret values.\n secretsContractDigest: digestJson({ ref, secretsContractShape }),\n };\n });\n}\n\n/**\n * Resolves one authoritative values-free secret contract for a provider in a\n * concrete runtime scope.\n *\n * Multiple runtime owners may legitimately contribute the same provider, but\n * they must agree on its secret requirements. Missing discovery and divergent\n * shapes fail closed: hashing either state as an empty contract would make the\n * lockfile claim integrity evidence it does not possess.\n */\nfunction resolveProviderSecretsContractShape(\n providerRef: string,\n matchingContributions: DiscoveredProviderCompanionContribution[],\n): DiscoveredProviderCompanionContribution['secretsContractShape'] {\n if (matchingContributions.length === 0) {\n throw new Error(\n `Cannot materialize provider lock entry for \"${providerRef}\": no discovered contribution supplies its secret-contract shape for this runtime.`,\n );\n }\n\n const canonicalShape = matchingContributions[0].secretsContractShape;\n const canonicalDigestInput = stableStringify(canonicalShape);\n for (const contribution of matchingContributions.slice(1)) {\n if (stableStringify(contribution.secretsContractShape) !== canonicalDigestInput) {\n throw new Error(\n `Cannot materialize provider lock entry for \"${providerRef}\": discovered runtime owners disagree on its secret-contract shape.`,\n );\n }\n }\n\n return canonicalShape;\n}\n\nfunction digestJson(value: unknown): string {\n return `sha256:${createHash('sha256').update(stableStringify(value)).digest('hex')}`;\n}\n\nfunction stableStringify(value: unknown): string {\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(',')}]`;\n }\n if (value && typeof value === 'object') {\n const record = value as Record<string, unknown>;\n return `{${Object.keys(record)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`)\n .join(',')}}`;\n }\n return JSON.stringify(value);\n}\n\nfunction mapRecord<TValue, TResult>(\n record: Record<string, TValue>,\n mapper: (value: TValue, key: string) => TResult,\n): Record<string, TResult> {\n return Object.fromEntries(\n Object.entries(record).map(([key, value]) => [key, mapper(value, key)]),\n );\n}\n\nfunction pruneUndefined<T extends Record<string, unknown>>(record: T): T {\n return Object.fromEntries(\n Object.entries(record).filter(([, value]) => value !== undefined),\n ) as T;\n}\n\ninterface ProviderRuntimeArtifactMetadata {\n sourceDigest: string;\n providerRefs: string[];\n providerRuntimeImports: Record<string, string>;\n providerGraphDigest: string;\n lockfileSectionDigest: string;\n}\n\ninterface ProviderRuntimeArtifactMetadataByKind {\n backend: ProviderRuntimeArtifactMetadata;\n companion: ProviderRuntimeArtifactMetadata;\n frontendServices: ProviderRuntimeArtifactMetadata;\n minions: ProviderRuntimeArtifactMetadata;\n nodeWorkers: ProviderRuntimeArtifactMetadata;\n}\n\ninterface RuntimeContributionMatcherFactory {\n matchesRuntimeTarget: (target: DiscoveredProviderCompanionContribution['runtimeTargets'][number]) => boolean;\n}\n\ninterface ScopedRuntimeContributionMatcherFactory {\n matchesRuntimeTarget: (\n scopeKey: string,\n ) => (target: DiscoveredProviderCompanionContribution['runtimeTargets'][number]) => boolean;\n}\n\ninterface ProviderRuntimeDiscoveryContext {\n contributions: DiscoveredProviderCompanionContribution[];\n backend: RuntimeContributionMatcherFactory;\n companion: RuntimeContributionMatcherFactory;\n frontendServices: ScopedRuntimeContributionMatcherFactory;\n minions: ScopedRuntimeContributionMatcherFactory;\n workers: ScopedRuntimeContributionMatcherFactory;\n}\n\nfunction buildProviderRuntimeDiscoveryContext(input: {\n discoveredContributions?: DiscoveredProviderCompanionContribution[];\n frontendServiceTypes: Record<string, AppFrontendType>;\n}): ProviderRuntimeDiscoveryContext {\n const contributions = input.discoveredContributions ?? [];\n const { frontendServiceTypes } = input;\n\n return {\n contributions,\n backend: {\n matchesRuntimeTarget: (target) => target.kind === 'backend',\n },\n companion: {\n matchesRuntimeTarget: (target) => target.kind === 'companion',\n },\n frontendServices: {\n matchesRuntimeTarget: (serviceKey) => {\n const serviceType = frontendServiceTypes[serviceKey];\n // Service has no frontendType ⇒ no contribution can match it.\n if (!serviceType) return () => false;\n return (target) => target.kind === 'frontendService' && target.serviceType === serviceType;\n },\n },\n minions: {\n matchesRuntimeTarget: (minionKey) => (target) => target.kind === 'minion' && target.minionKey === minionKey,\n },\n workers: {\n matchesRuntimeTarget: (workerKey) => (target) => target.kind === 'worker' && target.workerKey === workerKey,\n },\n };\n}\n\nfunction buildArtifactMetadata(input: {\n discoveryContext: ProviderRuntimeDiscoveryContext;\n frontendServiceTypes: Record<string, AppFrontendType>;\n lockSection: SaasLockfileProvidersSection;\n modules: RuntimeProviderModulesArtifact;\n nodeWorkerKeys?: string[];\n scopes: SaasProvidersScopes;\n}): ProviderRuntimeArtifactMetadataByKind {\n const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes } = input;\n const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;\n\n return {\n backend: buildSingleScopeArtifactMetadata({\n modules,\n providers: scopes.backend?.providers ?? {},\n matchingContributions: findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.backend.matchesRuntimeTarget,\n }),\n extraArtifactState: buildFrontendProviderBootstrapDigestInput({\n discoveredContributions: discoveryContext.contributions,\n frontendServiceScopes: scopes.frontendServices ?? {},\n frontendServiceTypes,\n }),\n runtimeLockSection: lockSection.runtimeScopes.backend ?? {},\n scopes,\n }),\n companion: buildSingleScopeArtifactMetadata({\n modules,\n providers: scopes.companion?.providers ?? {},\n matchingContributions: findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.companion.matchesRuntimeTarget,\n }),\n runtimeLockSection: lockSection.runtimeScopes.companion ?? {},\n scopes,\n }),\n frontendServices: buildMultiScopeArtifactMetadata({\n keyedProviders: Object.fromEntries(\n Object.entries(scopes.frontendServices ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers]),\n ),\n matchingContributionsByScope: Object.fromEntries(\n Object.keys(scopes.frontendServices ?? {}).map((scopeKey) => [\n scopeKey,\n findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.frontendServices.matchesRuntimeTarget(scopeKey),\n }),\n ]),\n ),\n modules,\n extraArtifactState: buildFrontendProviderBootstrapDigestInput({\n discoveredContributions: discoveryContext.contributions,\n frontendServiceScopes: scopes.frontendServices ?? {},\n frontendServiceTypes,\n }),\n runtimeLockSection: lockSection.runtimeScopes.frontendServices ?? {},\n scopes,\n }),\n minions: buildMultiScopeArtifactMetadata({\n keyedProviders: Object.fromEntries(\n Object.entries(scopes.minions ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers]),\n ),\n matchingContributionsByScope: Object.fromEntries(\n Object.keys(scopes.minions ?? {}).map((scopeKey) => [\n scopeKey,\n findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.minions.matchesRuntimeTarget(scopeKey),\n }),\n ]),\n ),\n modules,\n runtimeLockSection: lockSection.runtimeScopes.minions ?? {},\n scopes,\n }),\n nodeWorkers: buildMultiScopeArtifactMetadata({\n keyedProviders: Object.fromEntries(\n Object.entries(scopes.workers ?? {})\n .filter(([scopeKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)\n .map(([scopeKey, scope]) => [scopeKey, scope.providers]),\n ),\n matchingContributionsByScope: Object.fromEntries(\n Object.keys(scopes.workers ?? {})\n .filter((scopeKey) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)\n .map((scopeKey) => [\n scopeKey,\n findMatchingDiscoveredContributions({\n discoveredContributions: discoveryContext.contributions,\n matchesRuntimeTarget: discoveryContext.workers.matchesRuntimeTarget(scopeKey),\n }),\n ]),\n ),\n modules,\n runtimeLockSection: Object.fromEntries(\n Object.entries(lockSection.runtimeScopes.workers ?? {})\n .filter(([scopeKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true),\n ),\n scopes,\n }),\n };\n}\n\nfunction buildSingleScopeArtifactMetadata(input: {\n matchingContributions: DiscoveredProviderCompanionContribution[];\n modules: RuntimeProviderModulesArtifact;\n providers: Record<string, SaasProviderScopeSelection>;\n extraArtifactState?: Record<string, unknown>;\n runtimeLockSection: Record<string, unknown>;\n scopes: SaasProvidersScopes;\n}): ProviderRuntimeArtifactMetadata {\n const providerRefs = Object.keys(input.providers).sort();\n const normalizedContributions = normalizeDiscoveredContributionsForDigest(input.matchingContributions);\n const providerGraphDigestInput = input.extraArtifactState\n ? {\n providerGraph: normalizedContributions,\n extraArtifactState: input.extraArtifactState,\n }\n : normalizedContributions;\n\n return {\n sourceDigest: digestJson({\n modules: input.modules,\n providers: input.providers,\n providerGraph: normalizedContributions,\n scopes: input.scopes,\n extraArtifactState: input.extraArtifactState,\n }),\n providerRefs,\n providerRuntimeImports: buildProviderRuntimeImports(providerRefs, input.matchingContributions),\n providerGraphDigest: digestJson(providerGraphDigestInput),\n lockfileSectionDigest: digestJson(input.runtimeLockSection),\n };\n}\n\nfunction buildMultiScopeArtifactMetadata(input: {\n keyedProviders: Record<string, Record<string, SaasProviderScopeSelection>>;\n matchingContributionsByScope: Record<string, DiscoveredProviderCompanionContribution[]>;\n modules: RuntimeProviderModulesArtifact;\n extraArtifactState?: Record<string, unknown>;\n runtimeLockSection: Record<string, unknown>;\n scopes: SaasProvidersScopes;\n}): ProviderRuntimeArtifactMetadata {\n const providerRefs = [...new Set(\n Object.values(input.keyedProviders).flatMap((providers) => Object.keys(providers)),\n )].sort();\n const normalizedContributionsByScope = Object.fromEntries(\n Object.entries(input.matchingContributionsByScope).map(([scopeKey, contributions]) => [\n scopeKey,\n normalizeDiscoveredContributionsForDigest(contributions),\n ]),\n );\n\n const providerGraphDigestInput = input.extraArtifactState\n ? {\n providerGraphByScope: normalizedContributionsByScope,\n extraArtifactState: input.extraArtifactState,\n }\n : normalizedContributionsByScope;\n\n return {\n sourceDigest: digestJson({\n keyedProviders: input.keyedProviders,\n modules: input.modules,\n providerGraphByScope: normalizedContributionsByScope,\n scopes: input.scopes,\n extraArtifactState: input.extraArtifactState,\n }),\n providerRefs,\n providerRuntimeImports: buildProviderRuntimeImports(\n providerRefs,\n Object.values(input.matchingContributionsByScope).flat(),\n ),\n providerGraphDigest: digestJson(providerGraphDigestInput),\n lockfileSectionDigest: digestJson(input.runtimeLockSection),\n };\n}\n\n/**\n * Project the per-ref runtime import path a host dynamic-imports.\n *\n * Only refs actually in scope are recorded, so a per-host artifact never advertises a sibling's\n * packages. A ref no contribution covers is simply absent: the host then resolves it from the\n * engine's on-demand map, and the single fail-loud refusal in the backend registry names it if that\n * map does not hold it either.\n *\n * When several contributions claim one ref with DIFFERENT import paths, the sorted-first path wins\n * — deterministically, so the artifact does not churn. Divergence is possible today only between an\n * application's hand-authored engine projection (`@wildo-ai/saas-backend-lib`) and the engine's own\n * companion export, and neither is consulted for an engine-shipped ref, so the choice cannot change\n * which module a host loads. A package provider is contributed by exactly one package.\n */\nfunction buildProviderRuntimeImports(\n providerRefs: string[],\n contributions: DiscoveredProviderCompanionContribution[],\n): Record<string, string> {\n const inScope = new Set(providerRefs);\n const candidatesByRef = new Map<string, Set<string>>();\n\n for (const contribution of contributions) {\n if (!inScope.has(contribution.ref)) {\n continue;\n }\n const candidates = candidatesByRef.get(contribution.ref) ?? new Set<string>();\n candidates.add(contribution.runtimeImportPath);\n candidatesByRef.set(contribution.ref, candidates);\n }\n\n return Object.fromEntries(\n [...candidatesByRef.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([ref, candidates]) => [ref, [...candidates].sort()[0]]),\n );\n}\n\nfunction findMatchingDiscoveredContributions(input: {\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n matchesRuntimeTarget: (target: DiscoveredProviderCompanionContribution['runtimeTargets'][number]) => boolean;\n providerRef?: string;\n}): DiscoveredProviderCompanionContribution[] {\n return input.discoveredContributions.flatMap((contribution) => {\n if (input.providerRef && contribution.ref !== input.providerRef) {\n return [];\n }\n const runtimeTargets = contribution.runtimeTargets.filter(input.matchesRuntimeTarget);\n if (runtimeTargets.length === 0) {\n return [];\n }\n return [{ ...contribution, runtimeTargets }];\n });\n}\n\n/**\n * The portion of a contribution's `owner` that may enter a digest.\n *\n * **`packageRoot` is deliberately excluded, and this is the whole point of the\n * function.** Discovery builds it as `resolve(saasRoot, definition.path)` — an\n * ABSOLUTE filesystem path — so hashing it makes every value derived from this\n * normalizer a property of WHERE THE REPOSITORY HAPPENS TO BE CHECKED OUT\n * rather than of the provider graph.\n *\n * That is not a theoretical concern; it was measured on 2026-08-30. The same\n * Wonder Todos tree, materialized from its real directory and from a symlink to\n * it, produced two different lock digests for every provider in every scope\n * (`sha256:f7eeb2d6…` vs `sha256:d933b95a…` for backend `anthropic`), and a dump\n * of the two contribution sets differed in `owner.packageRoot` and nothing else.\n * The consequences were both real:\n *\n * - `examples/wonder-todos/.wildo-saas/wildo-saas.lock.json` carried 22 digests\n * scoped to whichever checkout last ran `wildo config sync`, so the\n * `Lockfile Drift Check` gate — which runs at `/home/runner/work/…` — could\n * never have agreed with a committed value regardless of actual drift.\n * - The same input feeds `sourceDigest` / `providerGraphDigest` in the generated\n * runtime artifacts and `.wildo-providers.env`, so artifacts generated on a\n * developer's machine and re-materialized under a container's `/app` would\n * trip the `digest-mismatch` runtime diagnostic while describing an identical\n * provider graph.\n *\n * `kind` + `key` already identify an owner uniquely (both are record keys within\n * their config block), so nothing distinguishing is lost. What IS given up is\n * that relocating an owner package without changing its contribution content no\n * longer moves the digest — accepted deliberately: a repository-layout change is\n * not a provider-contract change, and if that signal is ever wanted it must\n * arrive as a saas-root-RELATIVE path, never an absolute one.\n */\nfunction projectOwnerForDigest(\n owner: DiscoveredProviderCompanionContribution['owner'],\n): { kind: string; key: string } {\n return { kind: owner.kind, key: owner.key };\n}\n\nfunction normalizeDiscoveredContributionsForDigest(\n contributions: DiscoveredProviderCompanionContribution[],\n): Array<Record<string, unknown>> {\n return [...contributions]\n .sort((left, right) => stableStringify({\n leftOwner: projectOwnerForDigest(left.owner),\n leftRef: left.ref,\n leftRuntimeImportPath: left.runtimeImportPath,\n leftSourceModuleId: left.sourceModuleId,\n leftTargets: left.runtimeTargets,\n }).localeCompare(stableStringify({\n rightOwner: projectOwnerForDigest(right.owner),\n rightRef: right.ref,\n rightRuntimeImportPath: right.runtimeImportPath,\n rightSourceModuleId: right.sourceModuleId,\n rightTargets: right.runtimeTargets,\n })))\n .map((contribution) => ({\n ref: contribution.ref,\n owner: projectOwnerForDigest(contribution.owner),\n runtimeImportPath: contribution.runtimeImportPath,\n runtimeTargets: contribution.runtimeTargets,\n engineCapabilities: [...contribution.engineCapabilities].sort(),\n providerCapabilities: [...contribution.providerCapabilities].sort(),\n protocols: [...contribution.protocols].sort(),\n secretsContractShape: contribution.secretsContractShape,\n frontendEntry: contribution.frontendEntry\n ? {\n metadata: contribution.frontendEntry.metadata,\n providerCapabilities: [...contribution.frontendEntry.providerCapabilities].sort(),\n protocols: [...contribution.frontendEntry.protocols].sort(),\n publicConfig: contribution.frontendEntry.publicConfig,\n }\n : undefined,\n sourceModuleId: contribution.sourceModuleId,\n }));\n}\n"]}