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

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 (103) hide show
  1. package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
  2. package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
  3. package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
  4. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +80 -0
  5. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  6. package/dist/esm/bootstrap/bootstrap.schemas.js +69 -0
  7. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  8. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +4 -0
  9. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  10. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +16 -0
  11. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  12. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
  13. package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
  14. package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
  15. package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
  16. package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -1
  17. package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
  18. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
  19. package/dist/esm/config-authoring.entry.d.ts.map +1 -1
  20. package/dist/esm/config-authoring.entry.js.map +1 -1
  21. package/dist/esm/index.d.ts.map +1 -1
  22. package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
  23. package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
  24. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
  25. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
  26. package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
  27. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
  28. package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
  29. package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
  30. package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
  31. package/dist/esm/project-config/define-saas-config.js.map +1 -1
  32. package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
  33. package/dist/esm/project-config/index.d.ts.map +1 -1
  34. package/dist/esm/project-config/loader.d.ts.map +1 -1
  35. package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -1
  36. package/dist/esm/project-config/provider-companion-discovery.d.ts +14 -0
  37. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  38. package/dist/esm/project-config/provider-companion-discovery.js +73 -1
  39. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  40. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +1 -1
  41. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
  42. package/dist/esm/project-config/provider-runtime-artifacts.js +57 -6
  43. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
  44. package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -1
  45. package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -1
  46. package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
  47. package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
  48. package/dist/esm/project-config/shared/backing-services.schemas.d.ts +25 -0
  49. package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
  50. package/dist/esm/project-config/shared/backing-services.schemas.js +25 -0
  51. package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
  52. package/dist/esm/project-config/shared/cdn.example.d.ts.map +1 -1
  53. package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -1
  54. package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
  55. package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
  56. package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
  57. package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
  58. package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
  59. package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
  60. package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
  61. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  62. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  63. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +11 -0
  64. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
  65. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
  66. package/dist/esm/project-config/shared/infra-service.schemas.d.ts.map +1 -1
  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.map +1 -1
  69. package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
  70. package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
  71. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -1
  72. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
  73. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts +76 -0
  74. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -1
  75. package/dist/esm/project-config/shared/minion-resource-access.validation.js +76 -1
  76. package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
  77. package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
  78. package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
  79. package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -1
  80. package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
  81. package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
  82. package/dist/esm/registry/companion-api.schemas.d.ts.map +1 -1
  83. package/dist/esm/registry/digest.schemas.d.ts.map +1 -1
  84. package/dist/esm/registry/index.d.ts.map +1 -1
  85. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
  86. package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
  87. package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
  88. package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
  89. package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -1
  90. package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
  91. package/dist/esm/release/framework-release.constants.js.map +1 -1
  92. package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -1
  93. package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
  94. package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
  95. package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
  96. package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
  97. package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
  98. package/dist/esm/workspace-scope/index.d.ts.map +1 -1
  99. package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
  100. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
  101. package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
  102. package/dist/tsconfig.build.tsbuildinfo +1 -1
  103. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"provider-companion-discovery.js","sourceRoot":"","sources":["../../../../src/project-config/provider-companion-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CA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CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,OAAO,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CACtB,SAA8C;IAE9C,OAAO,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport {\n ProviderCompanionContributionSchema,\n type ProviderCompanionContribution,\n type ProviderCompanionRuntimeTarget,\n type RuntimeOwnerCompanionExports,\n} from '@wildo-ai/saas-models';\nimport type { WildoSaasConfig } from './define-saas-config';\nimport { loadPackageCompanionExport, resolvePackageCompanionEntryPath } from './loader';\n\n/**\n * `providerPackage` was added by #330 and is the point of that slice on this file.\n *\n * The other four owner kinds are RUNTIME OWNERS declared in `wildo.saas.config.ts` — an application's\n * own services, libraries, minions and workers. Walking only those is what made a provider shipped as\n * its own npm package invisible to discovery (audit finding PL-1): the package is a DEPENDENCY, not a\n * runtime owner, so nothing ever asked it what it contributes, and an application had to hand-author a\n * contribution for a provider whose own package already knew everything about it.\n */\nexport enum ProviderContributionOwnerKind {\n /** A service package declared in `wildo.saas.config.ts` — the application's backend or a frontend. */\n SERVICE = 'service',\n /** A shared library package of the application. */\n LIBRARY = 'library',\n /** A minion runtime, keyed by its minion name. */\n MINION = 'minion',\n /** A Node worker runtime, keyed by its worker name. */\n WORKER = 'worker',\n /**\n * A provider shipped as its own npm package (#330) — a DEPENDENCY rather than a runtime owner,\n * which is why it needed its own walk and its own member. The value stays camelCase because it is\n * substituted into operator-facing diagnostics beside the four above.\n */\n PROVIDER_PACKAGE = 'providerPackage',\n}\n\n/**\n * Package-name prefixes whose dependencies are treated as provider packages.\n *\n * `@wildo-ai/provider-` is the framework convention (#337 D3). An application's OWN provider packages\n * are admitted through the scope of its root manifest — an application published as `@acme/…` gets\n * `@acme/provider-…` for free — so a private provider needs no configuration to be discovered, and a\n * dependency belonging to somebody else's scope is never executed by this walk.\n */\nexport const FRAMEWORK_PROVIDER_PACKAGE_PREFIX = '@wildo-ai/provider-';\n\n/**\n * The framework's own scraped catalogue, admitted by exact NAME because it does not fit the prefix.\n *\n * Paul decided on 2026-09-06 that the transposed catalogue ships as ONE package with a subpath per\n * vendor — `@wildo-ai/providers/slack` — rather than as 697 packages. The prefix above predates that\n * decision and describes the shape it replaced, and `'@wildo-ai/providers'.startsWith('@wildo-ai/provider-')`\n * is **false**: the `s` is not a `-`.\n *\n * So discovery could not see the catalogue at all. What it DID admit, measured 2026-09-07, was\n * `@wildo-ai/provider-simulators` — the test doubles — and nothing else in the repository matches the\n * prefix. A rule that admits only the simulator of a thing is worse than no rule, because it looks\n * like coverage.\n *\n * An exact name rather than a loosened prefix (`@wildo-ai/provider`, no hyphen) on purpose: that\n * would also admit any future `@wildo-ai/providerfoo`, and the catalogue is ONE known package, not a\n * family. The prefix keeps serving the family it was written for — an application's own\n * `@acme/provider-thing`.\n */\nexport const FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE = '@wildo-ai/providers';\n\ninterface ProviderContributionOwner {\n kind: ProviderContributionOwnerKind;\n key: string;\n packageRoot: string;\n}\n\ninterface ProviderContributionTarget extends ProviderContributionOwner {\n ownerLabel: string;\n}\n\nexport interface DiscoveredProviderCompanionContribution extends ProviderCompanionContribution {\n owner: ProviderContributionOwner;\n}\n\nexport interface DiscoverSaasProviderCompanionContributionsResult {\n contributions: DiscoveredProviderCompanionContribution[];\n}\n\nexport async function discoverSaasProviderCompanionContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<DiscoverSaasProviderCompanionContributionsResult> {\n const contributions: DiscoveredProviderCompanionContribution[] = [];\n\n const runtimeOwnerTargets = resolveContributionTargets(input.saasRoot, input.saasConfig);\n\n for (const target of [\n ...runtimeOwnerTargets,\n ...resolveProviderPackageTargets(input.saasRoot, runtimeOwnerTargets),\n ]) {\n const companionExports = await tryLoadRuntimeOwnerCompanionExports(target.packageRoot);\n if (!companionExports) {\n continue;\n }\n\n const parsedContributions = ProviderCompanionContributionSchema.array().parse(\n companionExports.providerContributions ?? [],\n );\n\n contributions.push(\n ...parsedContributions.map((contribution) => ({\n ...contribution,\n owner: {\n kind: target.kind,\n key: target.key,\n packageRoot: target.packageRoot,\n },\n })),\n );\n }\n\n return { contributions };\n}\n\n/**\n * Walk an application's provider contributions and VALIDATE them — one step, because the two must\n * never come apart (#334).\n *\n * The walk was already shared; what was duplicated is the PAIRING. `wildo config sync` and\n * `wildo lock check` each called the walker and then, separately, the validator — and the validator\n * sits outside the walker, so a consumer that forgot it would compute a lockfile section from\n * contributions nobody had checked against the authored scope. Three correct call sites with nothing\n * making a fourth correct is the shape `.claude/rules/invariant-call-site-enumeration.md` is about.\n *\n * The caller still LOADS the config. That is deliberate rather than an omission: loading is one line\n * each caller already owns with its own error handling, it is not the part that can silently come\n * apart, and folding it in here would put the load behind a seam that the sync service's own tests\n * mock — `loadSaasConfig` mocked as a module export is not seen by a caller INSIDE this module, so\n * those tests would have had to mock this function instead and would then no longer exercise the real\n * discovery and the real validation they exist to check.\n */\nexport async function resolveValidatedSaasProviderContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<DiscoveredProviderCompanionContribution[]> {\n const { contributions } = await discoverSaasProviderCompanionContributions(input);\n validateDiscoveredSaasProviderContributions({\n saasConfig: input.saasConfig,\n discoveredContributions: contributions,\n });\n return contributions;\n}\n\nexport function validateDiscoveredSaasProviderContributions(input: {\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services' | 'minions' | 'workers'>;\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n}): void {\n const { saasConfig, discoveredContributions } = input;\n const errors: string[] = [];\n const declaredModuleIds = new Set(Object.keys(saasConfig.modules ?? {}));\n const declaredServiceKeys = new Set(Object.keys(saasConfig.services ?? {}));\n const serviceKeyToFrontendType = new Map<string, string>(\n Object.entries(saasConfig.services ?? {})\n .filter(([, definition]) => definition.frontendType !== undefined)\n .map(([serviceKey, definition]) => [serviceKey, definition.frontendType as string]),\n );\n const declaredFrontendServiceKeys = new Set(serviceKeyToFrontendType.keys());\n const declaredFrontendTypes = new Set(serviceKeyToFrontendType.values());\n const declaredMinionKeys = new Set(Object.keys(saasConfig.minions ?? {}));\n const declaredWorkerKeys = new Set(Object.keys(saasConfig.workers ?? {}));\n\n for (const contribution of discoveredContributions) {\n if (contribution.sourceModuleId && !declaredModuleIds.has(contribution.sourceModuleId)) {\n errors.push(\n `${describeContribution(contribution)} references sourceModuleId \"${contribution.sourceModuleId}\" ` +\n 'but that module is not declared in wildo.saas.config.ts.',\n );\n }\n\n const dependencyNames = readRuntimeReachablePackageNames(contribution.owner.packageRoot);\n const runtimePackageName = extractPackageName(contribution.runtimeImportPath);\n if (!dependencyNames.has(runtimePackageName)) {\n errors.push(\n `${describeContribution(contribution)} declares runtimeImportPath \"${contribution.runtimeImportPath}\" ` +\n `but ${contribution.owner.kind} \"${contribution.owner.key}\" does not depend on \"${runtimePackageName}\".`,\n );\n }\n\n for (const target of contribution.runtimeTargets) {\n switch (target.kind) {\n case 'frontendService':\n if (!declaredFrontendTypes.has(target.serviceType)) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but no service with that frontendType is declared in wildo.saas.config.ts.',\n );\n } else if (!contribution.frontendEntry) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but does not provide a frontendEntry payload for bootstrap materialization.',\n );\n }\n break;\n case 'minion':\n if (!declaredMinionKeys.has(target.minionKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown minion \"${target.minionKey}\".`,\n );\n }\n break;\n case 'worker':\n if (!declaredWorkerKeys.has(target.workerKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown worker \"${target.workerKey}\".`,\n );\n }\n break;\n case 'backend':\n case 'companion':\n break;\n }\n }\n }\n\n const runtimeScopes = saasConfig.providers.scopes;\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'backend',\n providers: runtimeScopes.backend?.providers ?? {},\n matchesTarget: (target) => target.kind === 'backend',\n });\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'companion',\n providers: runtimeScopes.companion?.providers ?? {},\n matchesTarget: (target) => target.kind === 'companion',\n });\n\n for (const [serviceKey, scope] of Object.entries(runtimeScopes.frontendServices ?? {})) {\n if (!declaredServiceKeys.has(serviceKey)) {\n errors.push(`Provider scope references unknown frontend service \"${serviceKey}\".`);\n continue;\n }\n if (!declaredFrontendServiceKeys.has(serviceKey)) {\n errors.push(\n `Provider scope references non-frontend service \"${serviceKey}\". ` +\n 'Only services with a frontendType may appear under providers.scopes.frontendServices.',\n );\n continue;\n }\n const serviceType = serviceKeyToFrontendType.get(serviceKey);\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `frontendServices.${serviceKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'frontendService' && target.serviceType === serviceType,\n });\n }\n\n for (const [minionKey, scope] of Object.entries(runtimeScopes.minions ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `minions.${minionKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'minion' && target.minionKey === minionKey,\n });\n }\n\n for (const [workerKey, scope] of Object.entries(runtimeScopes.workers ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `workers.${workerKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'worker' && target.workerKey === workerKey,\n });\n }\n\n if (errors.length > 0) {\n throw new Error(\n `Provider companion-export discovery validation failed:\\n- ${errors.join('\\n- ')}`,\n );\n }\n}\n\nfunction resolveContributionTargets(\n saasRoot: string,\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>,\n): ProviderContributionTarget[] {\n const shouldIncludeBackendServices = hasAnyProviders(saasConfig.providers.scopes.backend?.providers);\n const frontendServiceProviderScopes = Object.entries(saasConfig.providers.scopes.frontendServices ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([serviceKey]) => serviceKey);\n const minionProviderScopes = Object.entries(saasConfig.providers.scopes.minions ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([minionKey]) => minionKey);\n const workerProviderScopes = Object.entries(saasConfig.providers.scopes.workers ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([workerKey]) => workerKey);\n\n return [\n ...Object.entries(saasConfig.services)\n .filter(([key, definition]) => (\n definition.frontendType\n ? frontendServiceProviderScopes.includes(key)\n : shouldIncludeBackendServices\n ))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.SERVICE,\n key,\n ownerLabel: `service \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.libraries ?? {}).map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.LIBRARY,\n key,\n ownerLabel: `library \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.minions ?? {})\n .filter(([key]) => minionProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.MINION,\n key,\n ownerLabel: `minion \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.workers ?? {})\n .filter(([key]) => workerProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.WORKER,\n key,\n ownerLabel: `worker \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ];\n}\n\n/**\n * Every provider PACKAGE this application depends on, as a contribution target.\n *\n * Candidates come from the application root manifest AND from each runtime owner's manifest, because\n * both layouts are real: a scaffolded application declares its provider packages in the runtime owner\n * that imports them (`backend-api`), while a workspace root may hoist them. The union is deduplicated\n * by resolved package root, so a package declared in both places is walked once.\n *\n * A candidate that cannot be resolved on disk is SKIPPED rather than refused. The manifest is the\n * declaration and `node_modules` is the install; a name declared but not installed is an install\n * problem that `pnpm install` reports far better than a config-sync stack trace would, and refusing\n * here would make `wildo config sync` unrunnable in exactly the state where an operator runs it to\n * find out what is wrong.\n */\nfunction resolveProviderPackageTargets(\n saasRoot: string,\n runtimeOwnerTargets: ProviderContributionTarget[],\n): ProviderContributionTarget[] {\n const prefixes = resolveProviderPackagePrefixes(saasRoot);\n const searchRoots = [saasRoot, ...runtimeOwnerTargets.map((target) => target.packageRoot)];\n\n const candidateNames = new Set<string>();\n for (const searchRoot of searchRoots) {\n for (const dependencyName of readRuntimeReachablePackageNames(searchRoot)) {\n if (dependencyName === FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE || prefixes.some((prefix) => dependencyName.startsWith(prefix))) {\n candidateNames.add(dependencyName);\n }\n }\n }\n\n const targetsByRoot = new Map<string, ProviderContributionTarget>();\n for (const packageName of [...candidateNames].sort()) {\n const packageRoot = resolveProviderPackageRoot(packageName, searchRoots);\n if (!packageRoot || targetsByRoot.has(packageRoot)) {\n continue;\n }\n targetsByRoot.set(packageRoot, {\n kind: ProviderContributionOwnerKind.PROVIDER_PACKAGE,\n key: packageName,\n ownerLabel: `provider package \"${packageName}\"`,\n packageRoot,\n });\n }\n\n return [...targetsByRoot.values()];\n}\n\n/**\n * The framework prefix, plus the application's own scope when its root manifest has one.\n *\n * Deriving the second from the root package name rather than reading it from configuration keeps the\n * \"one declaration\" promise of #330 intact: installing `@acme/provider-thing` in an `@acme` application\n * and scoping the ref is the whole of it — there is no third place to remember.\n */\nfunction resolveProviderPackagePrefixes(saasRoot: string): string[] {\n const prefixes = [FRAMEWORK_PROVIDER_PACKAGE_PREFIX];\n const rootPackageName = readPackageName(saasRoot);\n const scope = rootPackageName?.startsWith('@') ? rootPackageName.split('/')[0] : undefined;\n if (scope && scope !== '@wildo-ai') {\n prefixes.push(`${scope}/provider-`);\n }\n return prefixes;\n}\n\n/**\n * Locate an installed package's ROOT DIRECTORY, which is what the companion-entry resolver needs.\n *\n * The direct `node_modules` probe comes first because it is what pnpm actually produces — a symlink\n * per importer — and because it works for a package whose `exports` map declares no `./package.json`,\n * which `require.resolve` cannot see past. `createRequire` is the fallback for hoisted or otherwise\n * unusual layouts; it resolves the companion subpath (the one door every provider package declares)\n * and walks up to the manifest that names the package.\n */\nfunction resolveProviderPackageRoot(packageName: string, searchRoots: string[]): string | undefined {\n /*\n * The name comes from a manifest and is spliced into a filesystem path, so a segment that is `.` or\n * `..` would walk OUT of `node_modules` — and the prefix gate would not stop it, since\n * `@wildo-ai/provider-x/../../elsewhere` starts with the framework prefix. npm forbids such a name,\n * which is precisely why nothing downstream would question it; the check costs one line and is the\n * only thing standing between an authored dependency name and an arbitrary directory whose\n * companion entry this walk EXECUTES.\n */\n const segments = packageName.split('/');\n if (segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {\n return undefined;\n }\n\n for (const searchRoot of searchRoots) {\n const candidate = join(searchRoot, 'node_modules', ...segments);\n if (existsSync(join(candidate, 'package.json'))) {\n return candidate;\n }\n }\n\n for (const searchRoot of searchRoots) {\n try {\n const resolved = createRequire(join(searchRoot, 'package.json')).resolve(`${packageName}/companion`);\n let directory = dirname(resolved);\n while (directory !== dirname(directory)) {\n if (readPackageName(directory) === packageName) {\n return directory;\n }\n directory = dirname(directory);\n }\n } catch {\n // Not resolvable from this root; try the next one, then give up quietly (see the JSDoc above).\n }\n }\n\n return undefined;\n}\n\nfunction readPackageName(packageRoot: string): string | undefined {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return undefined;\n }\n try {\n return (JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { name?: string }).name;\n } catch {\n return undefined;\n }\n}\n\nasync function tryLoadRuntimeOwnerCompanionExports(\n packageRoot: string,\n): Promise<RuntimeOwnerCompanionExports | undefined> {\n try {\n resolvePackageCompanionEntryPath(packageRoot);\n } catch {\n return undefined;\n }\n\n return loadPackageCompanionExport<RuntimeOwnerCompanionExports>(packageRoot);\n}\n\nfunction validateRuntimeScopeAgainstDiscovery(input: {\n errors: string[];\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n scopeLabel: string;\n providers: NonNullable<WildoSaasConfig['providers']['scopes']['backend']>['providers'];\n matchesTarget: (target: ProviderCompanionRuntimeTarget) => boolean;\n}): void {\n const { errors, discoveredContributions, matchesTarget, providers, scopeLabel } = input;\n\n for (const [providerRef, authoredSelection] of Object.entries(providers)) {\n const matchingContributions = discoveredContributions.filter(\n (contribution) => contribution.ref === providerRef\n && contribution.runtimeTargets.some(matchesTarget),\n );\n\n if (matchingContributions.length === 0) {\n errors.push(\n `Provider \"${providerRef}\" is authored in scope \"${scopeLabel}\" but no companion export contributes it for that runtime.`,\n );\n continue;\n }\n\n const discoveredEngineCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.engineCapabilities),\n );\n const discoveredProviderCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.providerCapabilities),\n );\n const discoveredProtocols = new Set(\n matchingContributions.flatMap((contribution) => contribution.protocols),\n );\n\n for (const capability of authoredSelection.engineCapabilities) {\n if (!discoveredEngineCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares engine capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const capability of authoredSelection.providerCapabilities) {\n if (!discoveredProviderCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares provider capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const protocol of authoredSelection.protocols) {\n if (!discoveredProtocols.has(protocol)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares protocol \"${protocol}\" ` +\n 'but discovery does not report that protocol for the same runtime.',\n );\n }\n }\n }\n}\n\nfunction describeContribution(contribution: DiscoveredProviderCompanionContribution): string {\n return `Provider contribution \"${contribution.ref}\" from ${contribution.owner.kind} \"${contribution.owner.key}\"`;\n}\n\nfunction readRuntimeReachablePackageNames(packageRoot: string): Set<string> {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return new Set<string>();\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n };\n\n return new Set([\n ...(packageJson.name ? [packageJson.name] : []),\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ...Object.keys(packageJson.optionalDependencies ?? {}),\n ]);\n}\n\nfunction extractPackageName(importPath: string): string {\n if (importPath.startsWith('@')) {\n const [scope, pkg] = importPath.split('/');\n return `${scope}/${pkg}`;\n }\n return importPath.split('/')[0] ?? importPath;\n}\n\nfunction hasAnyProviders(\n providers: Record<string, unknown> | undefined,\n): boolean {\n return Boolean(providers && Object.keys(providers).length > 0);\n}\n"]}
1
+ {"version":3,"file":"provider-companion-discovery.js","sourceRoot":"","sources":["../../../src/project-config/provider-companion-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,W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,gBAAgB,IAAI,EAAE,CAAC;QAClD,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,oBAAoB,IAAI,EAAE,CAAC;KACvD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CAAC,UAAkB;IAC5C,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,OAAO,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CACtB,SAA8C;IAE9C,OAAO,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport {\n ProviderCompanionContributionSchema,\n type ProviderCompanionContribution,\n type ProviderCompanionRuntimeTarget,\n type RuntimeOwnerCompanionExports,\n} from '@wildo-ai/saas-models';\nimport type { WildoSaasConfig } from './define-saas-config';\nimport { loadPackageCompanionExport, resolvePackageCompanionEntryPath } from './loader';\n\n/**\n * `providerPackage` was added by #330 and is the point of that slice on this file.\n *\n * The other four owner kinds are RUNTIME OWNERS declared in `wildo.saas.config.ts` — an application's\n * own services, libraries, minions and workers. Walking only those is what made a provider shipped as\n * its own npm package invisible to discovery (audit finding PL-1): the package is a DEPENDENCY, not a\n * runtime owner, so nothing ever asked it what it contributes, and an application had to hand-author a\n * contribution for a provider whose own package already knew everything about it.\n */\nexport enum ProviderContributionOwnerKind {\n /** A service package declared in `wildo.saas.config.ts` — the application's backend or a frontend. */\n SERVICE = 'service',\n /** A shared library package of the application. */\n LIBRARY = 'library',\n /** A minion runtime, keyed by its minion name. */\n MINION = 'minion',\n /** A Node worker runtime, keyed by its worker name. */\n WORKER = 'worker',\n /**\n * A provider shipped as its own npm package (#330) — a DEPENDENCY rather than a runtime owner,\n * which is why it needed its own walk and its own member. The value stays camelCase because it is\n * substituted into operator-facing diagnostics beside the four above.\n */\n PROVIDER_PACKAGE = 'providerPackage',\n}\n\n/**\n * Package-name prefixes whose dependencies are treated as provider packages.\n *\n * `@wildo-ai/provider-` is the framework convention (#337 D3). An application's OWN provider packages\n * are admitted through the scope of its root manifest — an application published as `@acme/…` gets\n * `@acme/provider-…` for free — so a private provider needs no configuration to be discovered, and a\n * dependency belonging to somebody else's scope is never executed by this walk.\n */\nexport const FRAMEWORK_PROVIDER_PACKAGE_PREFIX = '@wildo-ai/provider-';\n\n/**\n * The framework's own scraped catalogue, admitted by exact NAME because it does not fit the prefix.\n *\n * Paul decided on 2026-09-06 that the transposed catalogue ships as ONE package with a subpath per\n * vendor — `@wildo-ai/providers/slack` — rather than as 697 packages. The prefix above predates that\n * decision and describes the shape it replaced, and `'@wildo-ai/providers'.startsWith('@wildo-ai/provider-')`\n * is **false**: the `s` is not a `-`.\n *\n * So discovery could not see the catalogue at all. What it DID admit, measured 2026-09-07, was\n * `@wildo-ai/provider-simulators` — the test doubles — and nothing else in the repository matches the\n * prefix. A rule that admits only the simulator of a thing is worse than no rule, because it looks\n * like coverage.\n *\n * An exact name rather than a loosened prefix (`@wildo-ai/provider`, no hyphen) on purpose: that\n * would also admit any future `@wildo-ai/providerfoo`, and the catalogue is ONE known package, not a\n * family. The prefix keeps serving the family it was written for — an application's own\n * `@acme/provider-thing`.\n */\nexport const FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE = '@wildo-ai/providers';\n\n/**\n * The ENGINE's own provider barrel, admitted exactly as the catalogue is.\n *\n * The engine ships 23 providers and exports them through `./companion` — the same shape every\n * provider package uses. Discovery did not admit it, so an application that wanted `resend` declared\n * it THREE times: the scope, a hand-authored `provider-contributions.ts` projecting the engine's own\n * metadata back at it, and the package dependency. The middle one carried no information the other\n * two lacked; config sync refused a scoped-but-uncontributed provider, so it was not optional either\n * (#358).\n *\n * A NAME rather than a prefix, for the reason the catalogue's own note gives: this is one known\n * package, not a family.\n */\nexport const FRAMEWORK_ENGINE_PROVIDER_PACKAGE = '@wildo-ai/external-connectors-private';\n\ninterface ProviderContributionOwner {\n kind: ProviderContributionOwnerKind;\n key: string;\n packageRoot: string;\n}\n\ninterface ProviderContributionTarget extends ProviderContributionOwner {\n ownerLabel: string;\n}\n\nexport interface DiscoveredProviderCompanionContribution extends ProviderCompanionContribution {\n owner: ProviderContributionOwner;\n}\n\nexport interface DiscoverSaasProviderCompanionContributionsResult {\n contributions: DiscoveredProviderCompanionContribution[];\n}\n\n/**\n * The runtime targets an application's SCOPES imply for one provider ref.\n *\n * ## Why a package's declared targets cannot be the answer\n *\n * A provider PACKAGE is shipped once and installed by many applications, so it cannot know any of\n * their runtime topologies. Measured 2026-09-09: all 682 catalogue vendors declare\n * `[{ kind: 'backend' }]` and every engine contribution declares `backend` (plus `companion` for the\n * model-ish ones). Those are defaults standing in for an answer the package is not able to give —\n * a minion key or a worker key exists only in `wildo.saas.config.ts`.\n *\n * The consequence was latent rather than theoretical: a CATALOGUE provider scoped to a minion would\n * have failed materialization with \"no discovered contribution supplies its secret-contract shape\n * for this runtime\", because the package declares a `backend` target and the minion scope looks for\n * a `minion` one. No application had scoped one to a minion yet, so nothing had reported it.\n *\n * ## Why the scopes ARE the answer\n *\n * `providers.scopes` is where an application says which runtimes reach which provider — it is the\n * same decision, already authored, in the place the runtime artifact is built from. Measured against\n * Wonder Todos' hand-authored projections: the scopes reproduce 9 of 10 target sets EXACTLY, and the\n * tenth is a SURPLUS (a `companion` target for a provider the companion scope does not name) which\n * the artifact discards anyway, since it is built from scope INTERSECT contribution.\n *\n * So nothing is lost by deriving, and what is gained is that an application declares a provider once.\n *\n * Applies to contributions discovered from a PACKAGE. A runtime owner's own companion barrel keeps\n * whatever it declares: that is the application's own file talking about itself, and an application\n * package is entitled to state a target the scopes do not.\n */\nfunction resolveScopeImpliedRuntimeTargets(\n providerRef: string,\n saasConfig: Pick<WildoSaasConfig, 'providers'>,\n): ProviderCompanionContribution['runtimeTargets'] {\n const scopes = saasConfig.providers?.scopes;\n if (!scopes) return [];\n const targets: ProviderCompanionContribution['runtimeTargets'] = [];\n\n if (scopes.backend?.providers?.[providerRef]) targets.push({ kind: 'backend' });\n if (scopes.companion?.providers?.[providerRef]) targets.push({ kind: 'companion' });\n for (const [minionKey, scope] of Object.entries(scopes.minions ?? {})) {\n if (scope?.providers?.[providerRef]) targets.push({ kind: 'minion', minionKey });\n }\n for (const [workerKey, scope] of Object.entries(scopes.workers ?? {})) {\n if (scope?.providers?.[providerRef]) targets.push({ kind: 'worker', workerKey });\n }\n return targets;\n}\n\nexport async function discoverSaasProviderCompanionContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<DiscoverSaasProviderCompanionContributionsResult> {\n const contributions: DiscoveredProviderCompanionContribution[] = [];\n\n const runtimeOwnerTargets = resolveContributionTargets(input.saasRoot, input.saasConfig);\n\n for (const target of [\n ...runtimeOwnerTargets,\n ...resolveProviderPackageTargets(input.saasRoot, runtimeOwnerTargets),\n ]) {\n const companionExports = await tryLoadRuntimeOwnerCompanionExports(target.packageRoot);\n if (!companionExports) {\n continue;\n }\n\n const parsedContributions = ProviderCompanionContributionSchema.array().parse(\n companionExports.providerContributions ?? [],\n );\n\n // A PACKAGE cannot know this application's runtime topology, so its declared targets are a\n // default and the SCOPES are the answer. A runtime owner's own barrel keeps what it declares —\n // see `resolveScopeImpliedRuntimeTargets`.\n const derivesTargetsFromScopes = target.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE;\n\n contributions.push(\n ...parsedContributions.map((contribution) => ({\n ...contribution,\n runtimeTargets: derivesTargetsFromScopes\n ? resolveScopeImpliedRuntimeTargets(contribution.ref, input.saasConfig)\n : contribution.runtimeTargets,\n owner: {\n kind: target.kind,\n key: target.key,\n packageRoot: target.packageRoot,\n },\n })),\n );\n }\n\n return { contributions };\n}\n\n/**\n * Walk an application's provider contributions and VALIDATE them — one step, because the two must\n * never come apart (#334).\n *\n * The walk was already shared; what was duplicated is the PAIRING. `wildo config sync` and\n * `wildo lock check` each called the walker and then, separately, the validator — and the validator\n * sits outside the walker, so a consumer that forgot it would compute a lockfile section from\n * contributions nobody had checked against the authored scope. Three correct call sites with nothing\n * making a fourth correct is the shape `.claude/rules/invariant-call-site-enumeration.md` is about.\n *\n * The caller still LOADS the config. That is deliberate rather than an omission: loading is one line\n * each caller already owns with its own error handling, it is not the part that can silently come\n * apart, and folding it in here would put the load behind a seam that the sync service's own tests\n * mock — `loadSaasConfig` mocked as a module export is not seen by a caller INSIDE this module, so\n * those tests would have had to mock this function instead and would then no longer exercise the real\n * discovery and the real validation they exist to check.\n */\nexport async function resolveValidatedSaasProviderContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<DiscoveredProviderCompanionContribution[]> {\n const { contributions } = await discoverSaasProviderCompanionContributions(input);\n validateDiscoveredSaasProviderContributions({\n saasConfig: input.saasConfig,\n discoveredContributions: contributions,\n });\n return contributions;\n}\n\nexport function validateDiscoveredSaasProviderContributions(input: {\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services' | 'minions' | 'workers'>;\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n}): void {\n const { saasConfig, discoveredContributions } = input;\n const errors: string[] = [];\n const declaredModuleIds = new Set(Object.keys(saasConfig.modules ?? {}));\n const declaredServiceKeys = new Set(Object.keys(saasConfig.services ?? {}));\n const serviceKeyToFrontendType = new Map<string, string>(\n Object.entries(saasConfig.services ?? {})\n .filter(([, definition]) => definition.frontendType !== undefined)\n .map(([serviceKey, definition]) => [serviceKey, definition.frontendType as string]),\n );\n const declaredFrontendServiceKeys = new Set(serviceKeyToFrontendType.keys());\n const declaredFrontendTypes = new Set(serviceKeyToFrontendType.values());\n const declaredMinionKeys = new Set(Object.keys(saasConfig.minions ?? {}));\n const declaredWorkerKeys = new Set(Object.keys(saasConfig.workers ?? {}));\n\n for (const contribution of discoveredContributions) {\n if (contribution.sourceModuleId && !declaredModuleIds.has(contribution.sourceModuleId)) {\n errors.push(\n `${describeContribution(contribution)} references sourceModuleId \"${contribution.sourceModuleId}\" ` +\n 'but that module is not declared in wildo.saas.config.ts.',\n );\n }\n\n const dependencyNames = readRuntimeReachablePackageNames(contribution.owner.packageRoot);\n const runtimePackageName = extractPackageName(contribution.runtimeImportPath);\n if (!dependencyNames.has(runtimePackageName)) {\n errors.push(\n `${describeContribution(contribution)} declares runtimeImportPath \"${contribution.runtimeImportPath}\" ` +\n `but ${contribution.owner.kind} \"${contribution.owner.key}\" does not depend on \"${runtimePackageName}\".`,\n );\n }\n\n for (const target of contribution.runtimeTargets) {\n switch (target.kind) {\n case 'frontendService':\n if (!declaredFrontendTypes.has(target.serviceType)) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but no service with that frontendType is declared in wildo.saas.config.ts.',\n );\n } else if (!contribution.frontendEntry) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but does not provide a frontendEntry payload for bootstrap materialization.',\n );\n }\n break;\n case 'minion':\n if (!declaredMinionKeys.has(target.minionKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown minion \"${target.minionKey}\".`,\n );\n }\n break;\n case 'worker':\n if (!declaredWorkerKeys.has(target.workerKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown worker \"${target.workerKey}\".`,\n );\n }\n break;\n case 'backend':\n case 'companion':\n break;\n }\n }\n }\n\n const runtimeScopes = saasConfig.providers.scopes;\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'backend',\n providers: runtimeScopes.backend?.providers ?? {},\n matchesTarget: (target) => target.kind === 'backend',\n });\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'companion',\n providers: runtimeScopes.companion?.providers ?? {},\n matchesTarget: (target) => target.kind === 'companion',\n });\n\n for (const [serviceKey, scope] of Object.entries(runtimeScopes.frontendServices ?? {})) {\n if (!declaredServiceKeys.has(serviceKey)) {\n errors.push(`Provider scope references unknown frontend service \"${serviceKey}\".`);\n continue;\n }\n if (!declaredFrontendServiceKeys.has(serviceKey)) {\n errors.push(\n `Provider scope references non-frontend service \"${serviceKey}\". ` +\n 'Only services with a frontendType may appear under providers.scopes.frontendServices.',\n );\n continue;\n }\n const serviceType = serviceKeyToFrontendType.get(serviceKey);\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `frontendServices.${serviceKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'frontendService' && target.serviceType === serviceType,\n });\n }\n\n for (const [minionKey, scope] of Object.entries(runtimeScopes.minions ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `minions.${minionKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'minion' && target.minionKey === minionKey,\n });\n }\n\n for (const [workerKey, scope] of Object.entries(runtimeScopes.workers ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `workers.${workerKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'worker' && target.workerKey === workerKey,\n });\n }\n\n if (errors.length > 0) {\n throw new Error(\n `Provider companion-export discovery validation failed:\\n- ${errors.join('\\n- ')}`,\n );\n }\n}\n\nfunction resolveContributionTargets(\n saasRoot: string,\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>,\n): ProviderContributionTarget[] {\n const shouldIncludeBackendServices = hasAnyProviders(saasConfig.providers.scopes.backend?.providers);\n const frontendServiceProviderScopes = Object.entries(saasConfig.providers.scopes.frontendServices ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([serviceKey]) => serviceKey);\n const minionProviderScopes = Object.entries(saasConfig.providers.scopes.minions ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([minionKey]) => minionKey);\n const workerProviderScopes = Object.entries(saasConfig.providers.scopes.workers ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([workerKey]) => workerKey);\n\n return [\n ...Object.entries(saasConfig.services)\n .filter(([key, definition]) => (\n definition.frontendType\n ? frontendServiceProviderScopes.includes(key)\n : shouldIncludeBackendServices\n ))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.SERVICE,\n key,\n ownerLabel: `service \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.libraries ?? {}).map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.LIBRARY,\n key,\n ownerLabel: `library \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.minions ?? {})\n .filter(([key]) => minionProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.MINION,\n key,\n ownerLabel: `minion \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.workers ?? {})\n .filter(([key]) => workerProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.WORKER,\n key,\n ownerLabel: `worker \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ];\n}\n\n/**\n * Every provider PACKAGE this application depends on, as a contribution target.\n *\n * Candidates come from the application root manifest AND from each runtime owner's manifest, because\n * both layouts are real: a scaffolded application declares its provider packages in the runtime owner\n * that imports them (`backend-api`), while a workspace root may hoist them. The union is deduplicated\n * by resolved package root, so a package declared in both places is walked once.\n *\n * A candidate that cannot be resolved on disk is SKIPPED rather than refused. The manifest is the\n * declaration and `node_modules` is the install; a name declared but not installed is an install\n * problem that `pnpm install` reports far better than a config-sync stack trace would, and refusing\n * here would make `wildo config sync` unrunnable in exactly the state where an operator runs it to\n * find out what is wrong.\n */\nfunction resolveProviderPackageTargets(\n saasRoot: string,\n runtimeOwnerTargets: ProviderContributionTarget[],\n): ProviderContributionTarget[] {\n const prefixes = resolveProviderPackagePrefixes(saasRoot);\n const searchRoots = [saasRoot, ...runtimeOwnerTargets.map((target) => target.packageRoot)];\n\n const candidateNames = new Set<string>();\n for (const searchRoot of searchRoots) {\n for (const dependencyName of readRuntimeReachablePackageNames(searchRoot)) {\n if (dependencyName === FRAMEWORK_PROVIDER_CATALOGUE_PACKAGE\n || dependencyName === FRAMEWORK_ENGINE_PROVIDER_PACKAGE\n || prefixes.some((prefix) => dependencyName.startsWith(prefix))) {\n candidateNames.add(dependencyName);\n }\n }\n }\n\n const targetsByRoot = new Map<string, ProviderContributionTarget>();\n for (const packageName of [...candidateNames].sort()) {\n const packageRoot = resolveProviderPackageRoot(packageName, searchRoots);\n if (!packageRoot || targetsByRoot.has(packageRoot)) {\n continue;\n }\n targetsByRoot.set(packageRoot, {\n kind: ProviderContributionOwnerKind.PROVIDER_PACKAGE,\n key: packageName,\n ownerLabel: `provider package \"${packageName}\"`,\n packageRoot,\n });\n }\n\n return [...targetsByRoot.values()];\n}\n\n/**\n * The framework prefix, plus the application's own scope when its root manifest has one.\n *\n * Deriving the second from the root package name rather than reading it from configuration keeps the\n * \"one declaration\" promise of #330 intact: installing `@acme/provider-thing` in an `@acme` application\n * and scoping the ref is the whole of it — there is no third place to remember.\n */\nfunction resolveProviderPackagePrefixes(saasRoot: string): string[] {\n const prefixes = [FRAMEWORK_PROVIDER_PACKAGE_PREFIX];\n const rootPackageName = readPackageName(saasRoot);\n const scope = rootPackageName?.startsWith('@') ? rootPackageName.split('/')[0] : undefined;\n if (scope && scope !== '@wildo-ai') {\n prefixes.push(`${scope}/provider-`);\n }\n return prefixes;\n}\n\n/**\n * Locate an installed package's ROOT DIRECTORY, which is what the companion-entry resolver needs.\n *\n * The direct `node_modules` probe comes first because it is what pnpm actually produces — a symlink\n * per importer — and because it works for a package whose `exports` map declares no `./package.json`,\n * which `require.resolve` cannot see past. `createRequire` is the fallback for hoisted or otherwise\n * unusual layouts; it resolves the companion subpath (the one door every provider package declares)\n * and walks up to the manifest that names the package.\n */\nfunction resolveProviderPackageRoot(packageName: string, searchRoots: string[]): string | undefined {\n /*\n * The name comes from a manifest and is spliced into a filesystem path, so a segment that is `.` or\n * `..` would walk OUT of `node_modules` — and the prefix gate would not stop it, since\n * `@wildo-ai/provider-x/../../elsewhere` starts with the framework prefix. npm forbids such a name,\n * which is precisely why nothing downstream would question it; the check costs one line and is the\n * only thing standing between an authored dependency name and an arbitrary directory whose\n * companion entry this walk EXECUTES.\n */\n const segments = packageName.split('/');\n if (segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {\n return undefined;\n }\n\n for (const searchRoot of searchRoots) {\n const candidate = join(searchRoot, 'node_modules', ...segments);\n if (existsSync(join(candidate, 'package.json'))) {\n return candidate;\n }\n }\n\n for (const searchRoot of searchRoots) {\n try {\n const resolved = createRequire(join(searchRoot, 'package.json')).resolve(`${packageName}/companion`);\n let directory = dirname(resolved);\n while (directory !== dirname(directory)) {\n if (readPackageName(directory) === packageName) {\n return directory;\n }\n directory = dirname(directory);\n }\n } catch {\n // Not resolvable from this root; try the next one, then give up quietly (see the JSDoc above).\n }\n }\n\n return undefined;\n}\n\nfunction readPackageName(packageRoot: string): string | undefined {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return undefined;\n }\n try {\n return (JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { name?: string }).name;\n } catch {\n return undefined;\n }\n}\n\nasync function tryLoadRuntimeOwnerCompanionExports(\n packageRoot: string,\n): Promise<RuntimeOwnerCompanionExports | undefined> {\n try {\n resolvePackageCompanionEntryPath(packageRoot);\n } catch {\n return undefined;\n }\n\n return loadPackageCompanionExport<RuntimeOwnerCompanionExports>(packageRoot);\n}\n\nfunction validateRuntimeScopeAgainstDiscovery(input: {\n errors: string[];\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n scopeLabel: string;\n providers: NonNullable<WildoSaasConfig['providers']['scopes']['backend']>['providers'];\n matchesTarget: (target: ProviderCompanionRuntimeTarget) => boolean;\n}): void {\n const { errors, discoveredContributions, matchesTarget, providers, scopeLabel } = input;\n\n for (const [providerRef, authoredSelection] of Object.entries(providers)) {\n const matchingContributions = discoveredContributions.filter(\n (contribution) => contribution.ref === providerRef\n && contribution.runtimeTargets.some(matchesTarget),\n );\n\n if (matchingContributions.length === 0) {\n errors.push(\n `Provider \"${providerRef}\" is authored in scope \"${scopeLabel}\" but no companion export contributes it for that runtime.`,\n );\n continue;\n }\n\n const discoveredEngineCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.engineCapabilities),\n );\n const discoveredProviderCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.providerCapabilities),\n );\n const discoveredProtocols = new Set(\n matchingContributions.flatMap((contribution) => contribution.protocols),\n );\n\n for (const capability of authoredSelection.engineCapabilities) {\n if (!discoveredEngineCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares engine capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const capability of authoredSelection.providerCapabilities) {\n if (!discoveredProviderCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares provider capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const protocol of authoredSelection.protocols) {\n if (!discoveredProtocols.has(protocol)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares protocol \"${protocol}\" ` +\n 'but discovery does not report that protocol for the same runtime.',\n );\n }\n }\n }\n}\n\nfunction describeContribution(contribution: DiscoveredProviderCompanionContribution): string {\n return `Provider contribution \"${contribution.ref}\" from ${contribution.owner.kind} \"${contribution.owner.key}\"`;\n}\n\nfunction readRuntimeReachablePackageNames(packageRoot: string): Set<string> {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return new Set<string>();\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n };\n\n return new Set([\n ...(packageJson.name ? [packageJson.name] : []),\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ...Object.keys(packageJson.optionalDependencies ?? {}),\n ]);\n}\n\nfunction extractPackageName(importPath: string): string {\n if (importPath.startsWith('@')) {\n const [scope, pkg] = importPath.split('/');\n return `${scope}/${pkg}`;\n }\n return importPath.split('/')[0] ?? importPath;\n}\n\nfunction hasAnyProviders(\n providers: Record<string, unknown> | undefined,\n): boolean {\n return Boolean(providers && Object.keys(providers).length > 0);\n}\n"]}
@@ -168,7 +168,7 @@ export interface MaterializedSaasProviderRuntimeArtifacts {
168
168
  artifacts: Partial<Record<ProviderRuntimeArtifactKind, SaasRuntimeProvidersArtifact>>;
169
169
  lockSection: SaasLockfileProvidersSection;
170
170
  }
171
- export declare function materializeSaasProviderRuntimeArtifacts(config: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services'>, options?: {
171
+ export declare function materializeSaasProviderRuntimeArtifacts(config: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services'> & Partial<Pick<WildoSaasConfig, 'providerConfigurations'>>, options?: {
172
172
  generatedAt?: string;
173
173
  nodeWorkerKeys?: string[];
174
174
  discoveredContributions?: DiscoveredProviderCompanionContribution[];
@@ -1 +1 @@
1
- {"version":3,"file":"provider-runtime-artifacts.d.ts","sourceRoot":"","sources":["../../../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C,MAAM,CAAC,CAAA;CAAE,GAC3D;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACrC,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEN;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,GAAG,sCAAsC,CAqCzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,GAAG,IAAI,CA8BP;AAED,KAAK,2BAA2B,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,kBAAkB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1C,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAClC,CAAC,CAAC;CACJ,CAAC"}
1
+ {"version":3,"file":"provider-runtime-artifacts.d.ts","sourceRoot":"","sources":["../../../src/project-config/provider-runtime-artifacts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAOL,KAAK,sBAAsB,EAC5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;IACtB,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACrC,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEN;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,GAAG,sCAAsC,CAqCzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,GAAG,IAAI,CA8BP;AAED,KAAK,2BAA2B,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QACxB,kBAAkB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC1C,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAClC,CAAC,CAAC;CACJ,CAAC"}
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
3
  import { resolve as resolvePath } from 'node:path';
4
4
  import { z } from 'zod';
5
- import { FrontendProvidersBlockSchema, } from '@wildo-ai/saas-models';
5
+ import { FRONTEND_PROVIDER_PUBLIC_CONFIG_KEY, FrontendProviderPublicConfigError, FrontendProvidersBlockSchema, overlayFrontendProviderPublicConfig, } from '@wildo-ai/saas-models';
6
6
  import { SaasLockfileProvidersSectionSchema, } from '../lockfile/wildo-saas-lock.shared.schemas.js';
7
7
  import { getDeclaredApplicationModuleIds, getServiceBoundApplicationModuleIds, } from './shared/application-modules.utils.js';
8
8
  import { SaasProvidersScopesSchema, SaasProviderScopeSelectionSchema, } from './define-saas-config.js';
@@ -120,7 +120,11 @@ export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
120
120
  scopes: z.record(z.string(), RuntimeProviderScopeArtifactSchema).optional(),
121
121
  frontendProviderBootstraps: FrontendProviderBootstrapsSchema.optional(),
122
122
  });
123
- export function materializeSaasProviderRuntimeArtifacts(config, options) {
123
+ export function materializeSaasProviderRuntimeArtifacts(
124
+ // `providerConfigurations` is where an application supplies a frontend provider's public keys
125
+ // (#394 P3). Optional here so the lockfile check and every existing caller that narrows the
126
+ // config keep compiling; absent means "the application configured nothing", never a refusal.
127
+ config, options) {
124
128
  const scopes = SaasProvidersScopesSchema.parse(config.providers.scopes);
125
129
  const generatedAt = options?.generatedAt ?? new Date().toISOString();
126
130
  const modules = materializeModules(config);
@@ -144,6 +148,7 @@ export function materializeSaasProviderRuntimeArtifacts(config, options) {
144
148
  modules,
145
149
  nodeWorkerKeys: options?.nodeWorkerKeys,
146
150
  scopes,
151
+ providerConfigurations: config.providerConfigurations ?? {},
147
152
  });
148
153
  const artifacts = materializeRuntimeArtifacts({
149
154
  artifactMetadata,
@@ -153,6 +158,7 @@ export function materializeSaasProviderRuntimeArtifacts(config, options) {
153
158
  modules,
154
159
  nodeWorkerKeys: options?.nodeWorkerKeys,
155
160
  scopes,
161
+ providerConfigurations: config.providerConfigurations ?? {},
156
162
  });
157
163
  return { artifacts, lockSection };
158
164
  }
@@ -427,7 +433,7 @@ export function assertProviderRuntimeEnvInSync(input) {
427
433
  }
428
434
  }
429
435
  function materializeRuntimeArtifacts(input) {
430
- const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes } = input;
436
+ const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes, providerConfigurations } = input;
431
437
  const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
432
438
  const nodeWorkerScopes = scopes.workers
433
439
  ? Object.fromEntries(Object.entries(scopes.workers).filter(([workerKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(workerKey) : true))
@@ -442,6 +448,7 @@ function materializeRuntimeArtifacts(input) {
442
448
  discoveredContributions: discoveryContext.contributions,
443
449
  frontendServiceScopes: scopes.frontendServices ?? {},
444
450
  frontendServiceTypes,
451
+ providerConfigurations,
445
452
  }),
446
453
  scope: materializeRuntimeScope(scopes.backend ?? { providers: {}, selection: {} }),
447
454
  }),
@@ -462,6 +469,7 @@ function materializeRuntimeArtifacts(input) {
462
469
  discoveredContributions: discoveryContext.contributions,
463
470
  frontendServiceScopes: scopes.frontendServices,
464
471
  frontendServiceTypes,
472
+ providerConfigurations,
465
473
  }),
466
474
  scopes: mapRecord(scopes.frontendServices, materializeRuntimeScope),
467
475
  })
@@ -510,7 +518,7 @@ function materializeRuntimeScope(scope) {
510
518
  });
511
519
  }
512
520
  function materializeFrontendProviderBootstraps(input) {
513
- const { discoveredContributions, frontendServiceScopes, frontendServiceTypes } = input;
521
+ const { discoveredContributions, frontendServiceScopes, frontendServiceTypes, providerConfigurations } = input;
514
522
  const entries = Object.entries(frontendServiceScopes).map(([serviceKey, scope]) => {
515
523
  const serviceType = frontendServiceTypes[serviceKey];
516
524
  if (!serviceType) {
@@ -534,13 +542,54 @@ function materializeFrontendProviderBootstraps(input) {
534
542
  }
535
543
  return [
536
544
  providerRef,
537
- matchingContribution[0].frontendEntry,
545
+ applyApplicationPublicConfig({
546
+ serviceKey,
547
+ providerRef,
548
+ entry: matchingContribution[0].frontendEntry,
549
+ supplied: providerConfigurations[providerRef]?.[FRONTEND_PROVIDER_PUBLIC_CONFIG_KEY],
550
+ discoveredContributions,
551
+ }),
538
552
  ];
539
553
  }));
540
554
  return [serviceKey, FrontendProvidersBlockSchema.parse({ providers })];
541
555
  });
542
556
  return entries.length > 0 ? Object.fromEntries(entries) : undefined;
543
557
  }
558
+ /**
559
+ * Overlays what the application supplied under `providerConfigurations[ref].frontend_sdk` onto the
560
+ * module's authored `publicConfig` (#394 P3) — the FIRST of the two sites that produce a
561
+ * `FrontendProviderEntry` from a module; the backend fallback is the other, and both call the one
562
+ * function in `saas-models` so they cannot disagree about what crosses.
563
+ *
564
+ * The forbidden set is built from the SAME vendor's non-frontend contributions: a frontend provider
565
+ * owns no secrets (`secretsContractShape: []` by construction), so the only secrets that could be
566
+ * typed into its bag are the backend module's, and those are exactly what this walk has in hand.
567
+ */
568
+ function applyApplicationPublicConfig(input) {
569
+ const { serviceKey, providerRef, entry, supplied, discoveredContributions } = input;
570
+ if (supplied === undefined)
571
+ return entry;
572
+ const forbiddenKeys = new Set(discoveredContributions
573
+ .filter((contribution) => contribution.ref === providerRef
574
+ && contribution.runtimeTargets.some((target) => target.kind !== 'frontendService'))
575
+ .flatMap((contribution) => contribution.secretsContractShape.flatMap((slot) => [slot.slug, slot.envVarName])));
576
+ try {
577
+ const publicConfig = overlayFrontendProviderPublicConfig({
578
+ providerRef,
579
+ authored: entry.publicConfig,
580
+ supplied,
581
+ declaredKeys: entry.publicConfigKeys,
582
+ forbiddenKeys,
583
+ });
584
+ return publicConfig === undefined ? entry : { ...entry, publicConfig };
585
+ }
586
+ catch (error) {
587
+ if (error instanceof FrontendProviderPublicConfigError) {
588
+ throw new Error(`Cannot materialize frontend bootstrap for service "${serviceKey}": ${error.message}`);
589
+ }
590
+ throw error;
591
+ }
592
+ }
544
593
  function buildFrontendProviderBootstrapDigestInput(input) {
545
594
  const bootstraps = materializeFrontendProviderBootstraps(input);
546
595
  if (!bootstraps) {
@@ -686,7 +735,7 @@ function buildProviderRuntimeDiscoveryContext(input) {
686
735
  };
687
736
  }
688
737
  function buildArtifactMetadata(input) {
689
- const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes } = input;
738
+ const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes, providerConfigurations } = input;
690
739
  const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
691
740
  return {
692
741
  backend: buildSingleScopeArtifactMetadata({
@@ -700,6 +749,7 @@ function buildArtifactMetadata(input) {
700
749
  discoveredContributions: discoveryContext.contributions,
701
750
  frontendServiceScopes: scopes.frontendServices ?? {},
702
751
  frontendServiceTypes,
752
+ providerConfigurations,
703
753
  }),
704
754
  runtimeLockSection: lockSection.runtimeScopes.backend ?? {},
705
755
  scopes,
@@ -728,6 +778,7 @@ function buildArtifactMetadata(input) {
728
778
  discoveredContributions: discoveryContext.contributions,
729
779
  frontendServiceScopes: scopes.frontendServices ?? {},
730
780
  frontendServiceTypes,
781
+ providerConfigurations,
731
782
  }),
732
783
  runtimeLockSection: lockSection.runtimeScopes.frontendServices ?? {},
733
784
  scopes,