@wildo-ai/platform-config-lib 1.1.5 → 1.1.7

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 (253) hide show
  1. package/dist/esm/_unimplemented/index.d.ts.map +1 -1
  2. package/dist/esm/_unimplemented/index.js.map +1 -1
  3. package/dist/esm/_unimplemented/soft-warn.d.ts.map +1 -1
  4. package/dist/esm/_unimplemented/soft-warn.js.map +1 -1
  5. package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts.map +1 -1
  6. package/dist/esm/_unimplemented/unimplemented-field-warning.js.map +1 -1
  7. package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
  8. package/dist/esm/bootstrap/application-backend-env.contracts.js.map +1 -1
  9. package/dist/esm/bootstrap/application-creation-verification-env.contracts.d.ts.map +1 -1
  10. package/dist/esm/bootstrap/application-creation-verification-env.contracts.js.map +1 -1
  11. package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
  12. package/dist/esm/bootstrap/bootstrap-planner.js.map +1 -1
  13. package/dist/esm/bootstrap/bootstrap.contracts.d.ts +3 -2
  14. package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
  15. package/dist/esm/bootstrap/bootstrap.contracts.js +3 -2
  16. package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
  17. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +47 -0
  18. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  19. package/dist/esm/bootstrap/bootstrap.schemas.js +8 -0
  20. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  21. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +12 -1
  22. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  23. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +12 -0
  24. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  25. package/dist/esm/bootstrap/platform-store-preconnect.d.ts +37 -0
  26. package/dist/esm/bootstrap/platform-store-preconnect.d.ts.map +1 -0
  27. package/dist/esm/bootstrap/platform-store-preconnect.js +43 -0
  28. package/dist/esm/bootstrap/platform-store-preconnect.js.map +1 -0
  29. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
  30. package/dist/esm/bootstrap/runtime-backing-service-access.js +8 -4
  31. package/dist/esm/bootstrap/runtime-backing-service-access.js.map +1 -1
  32. package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
  33. package/dist/esm/bootstrap/runtime-network-policy.js.map +1 -1
  34. package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
  35. package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
  36. package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -1
  37. package/dist/esm/bootstrap/runtime-platform-access.js.map +1 -1
  38. package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
  39. package/dist/esm/bootstrap/runtime-principal.contracts.js.map +1 -1
  40. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts +36 -3
  41. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
  42. package/dist/esm/bootstrap/runtime-topology.contracts.js +36 -13
  43. package/dist/esm/bootstrap/runtime-topology.contracts.js.map +1 -1
  44. package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts.map +1 -1
  45. package/dist/esm/bootstrap/wildo-owner-organization.contracts.js.map +1 -1
  46. package/dist/esm/config-authoring.entry.d.ts.map +1 -1
  47. package/dist/esm/config-authoring.entry.js.map +1 -1
  48. package/dist/esm/credentials/credential-generator.service.d.ts.map +1 -1
  49. package/dist/esm/credentials/credential-generator.service.js.map +1 -1
  50. package/dist/esm/index.d.ts +1 -0
  51. package/dist/esm/index.d.ts.map +1 -1
  52. package/dist/esm/index.js +1 -0
  53. package/dist/esm/index.js.map +1 -1
  54. package/dist/esm/lockfile/build-parallelism.d.ts.map +1 -1
  55. package/dist/esm/lockfile/build-parallelism.js.map +1 -1
  56. package/dist/esm/lockfile/canonical-json.d.ts.map +1 -1
  57. package/dist/esm/lockfile/canonical-json.js.map +1 -1
  58. package/dist/esm/lockfile/lockfile-io.d.ts +7 -1
  59. package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
  60. package/dist/esm/lockfile/lockfile-io.js +17 -3
  61. package/dist/esm/lockfile/lockfile-io.js.map +1 -1
  62. package/dist/esm/lockfile/materialize-infra-section.d.ts +27 -6
  63. package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
  64. package/dist/esm/lockfile/materialize-infra-section.js +23 -10
  65. package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
  66. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +455 -6
  67. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
  68. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +27 -0
  69. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
  70. package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts +13 -0
  71. package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts.map +1 -0
  72. package/dist/esm/project-config/application-public-pricing-catalog.loader.js +56 -0
  73. package/dist/esm/project-config/application-public-pricing-catalog.loader.js.map +1 -0
  74. package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
  75. package/dist/esm/project-config/define-framework-config.js.map +1 -1
  76. package/dist/esm/project-config/define-infra-env-config.d.ts +0 -27
  77. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
  78. package/dist/esm/project-config/define-infra-env-config.js +0 -2
  79. package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
  80. package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
  81. package/dist/esm/project-config/define-minion-config.js.map +1 -1
  82. package/dist/esm/project-config/define-saas-config.d.ts +52 -0
  83. package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
  84. package/dist/esm/project-config/define-saas-config.js +65 -15
  85. package/dist/esm/project-config/define-saas-config.js.map +1 -1
  86. package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
  87. package/dist/esm/project-config/define-worker-config.js.map +1 -1
  88. package/dist/esm/project-config/hosted-infra-env-config.d.ts.map +1 -1
  89. package/dist/esm/project-config/hosted-infra-env-config.js.map +1 -1
  90. package/dist/esm/project-config/index.d.ts +3 -0
  91. package/dist/esm/project-config/index.d.ts.map +1 -1
  92. package/dist/esm/project-config/index.js +3 -0
  93. package/dist/esm/project-config/index.js.map +1 -1
  94. package/dist/esm/project-config/loader.d.ts +11 -0
  95. package/dist/esm/project-config/loader.d.ts.map +1 -1
  96. package/dist/esm/project-config/loader.js +34 -7
  97. package/dist/esm/project-config/loader.js.map +1 -1
  98. package/dist/esm/project-config/minion-local-provider-registration.d.ts.map +1 -1
  99. package/dist/esm/project-config/minion-local-provider-registration.js.map +1 -1
  100. package/dist/esm/project-config/npm-version-range.d.ts +23 -0
  101. package/dist/esm/project-config/npm-version-range.d.ts.map +1 -0
  102. package/dist/esm/project-config/npm-version-range.js +175 -0
  103. package/dist/esm/project-config/npm-version-range.js.map +1 -0
  104. package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -1
  105. package/dist/esm/project-config/provider-catalog-types.js.map +1 -1
  106. package/dist/esm/project-config/provider-companion-discovery.d.ts +256 -30
  107. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  108. package/dist/esm/project-config/provider-companion-discovery.js +719 -40
  109. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  110. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +125 -2
  111. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
  112. package/dist/esm/project-config/provider-runtime-artifacts.js +283 -66
  113. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
  114. package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -1
  115. package/dist/esm/project-config/shared/application-creation-verification.schemas.js.map +1 -1
  116. package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -1
  117. package/dist/esm/project-config/shared/application-modules.schemas.js.map +1 -1
  118. package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
  119. package/dist/esm/project-config/shared/application-modules.utils.js.map +1 -1
  120. package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
  121. package/dist/esm/project-config/shared/auth.schemas.js.map +1 -1
  122. package/dist/esm/project-config/shared/backing-service-servability.d.ts +157 -0
  123. package/dist/esm/project-config/shared/backing-service-servability.d.ts.map +1 -0
  124. package/dist/esm/project-config/shared/backing-service-servability.js +256 -0
  125. package/dist/esm/project-config/shared/backing-service-servability.js.map +1 -0
  126. package/dist/esm/project-config/shared/backing-services.schemas.d.ts +62 -67
  127. package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
  128. package/dist/esm/project-config/shared/backing-services.schemas.js +71 -68
  129. package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
  130. package/dist/esm/project-config/shared/cdn.example.d.ts.map +1 -1
  131. package/dist/esm/project-config/shared/cdn.example.js.map +1 -1
  132. package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -1
  133. package/dist/esm/project-config/shared/cdn.schemas.js.map +1 -1
  134. package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
  135. package/dist/esm/project-config/shared/csp-defaults.js.map +1 -1
  136. package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
  137. package/dist/esm/project-config/shared/csp-emit.js +41 -2
  138. package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
  139. package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
  140. package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
  141. package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
  142. package/dist/esm/project-config/shared/data-services.schemas.js.map +1 -1
  143. package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
  144. package/dist/esm/project-config/shared/env-example-defaults.js.map +1 -1
  145. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  146. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  147. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +180 -4
  148. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
  149. package/dist/esm/project-config/shared/infra-providers.schemas.js +40 -0
  150. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
  151. package/dist/esm/project-config/shared/infra-service.schemas.d.ts.map +1 -1
  152. package/dist/esm/project-config/shared/infra-service.schemas.js.map +1 -1
  153. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
  154. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
  155. package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
  156. package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
  157. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -1
  158. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
  159. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -1
  160. package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
  161. package/dist/esm/project-config/shared/object-storage-session-policy.d.ts.map +1 -1
  162. package/dist/esm/project-config/shared/object-storage-session-policy.js.map +1 -1
  163. package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
  164. package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
  165. package/dist/esm/project-config/shared/platform-storage.schemas.d.ts.map +1 -1
  166. package/dist/esm/project-config/shared/platform-storage.schemas.js.map +1 -1
  167. package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -1
  168. package/dist/esm/project-config/shared/schema-version.schemas.js.map +1 -1
  169. package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
  170. package/dist/esm/project-config/shared/service-definitions.schemas.js.map +1 -1
  171. package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts.map +1 -1
  172. package/dist/esm/project-config/shared/systems-of-record-env.schemas.js.map +1 -1
  173. package/dist/esm/project-config/static-asset-import-noop.d.ts +26 -0
  174. package/dist/esm/project-config/static-asset-import-noop.d.ts.map +1 -0
  175. package/dist/esm/project-config/static-asset-import-noop.js +49 -0
  176. package/dist/esm/project-config/static-asset-import-noop.js.map +1 -0
  177. package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
  178. package/dist/esm/registry/artifact-domain.schemas.js.map +1 -1
  179. package/dist/esm/registry/digest.schemas.d.ts.map +1 -1
  180. package/dist/esm/registry/digest.schemas.js.map +1 -1
  181. package/dist/esm/registry/index.d.ts +3 -1
  182. package/dist/esm/registry/index.d.ts.map +1 -1
  183. package/dist/esm/registry/index.js +3 -1
  184. package/dist/esm/registry/index.js.map +1 -1
  185. package/dist/esm/registry/local-checkout-source.d.ts +31 -0
  186. package/dist/esm/registry/local-checkout-source.d.ts.map +1 -0
  187. package/dist/esm/registry/local-checkout-source.js +45 -0
  188. package/dist/esm/registry/local-checkout-source.js.map +1 -0
  189. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts +174 -14
  190. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
  191. package/dist/esm/registry/lockfile-modules-section.schemas.js +120 -11
  192. package/dist/esm/registry/lockfile-modules-section.schemas.js.map +1 -1
  193. package/dist/esm/registry/module-artifact.schemas.d.ts +79 -0
  194. package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
  195. package/dist/esm/registry/module-artifact.schemas.js +36 -0
  196. package/dist/esm/registry/module-artifact.schemas.js.map +1 -1
  197. package/dist/esm/registry/module-manifest.schemas.d.ts +393 -7
  198. package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
  199. package/dist/esm/registry/module-manifest.schemas.js +488 -40
  200. package/dist/esm/registry/module-manifest.schemas.js.map +1 -1
  201. package/dist/esm/registry/module-search.schemas.d.ts +80 -0
  202. package/dist/esm/registry/module-search.schemas.d.ts.map +1 -0
  203. package/dist/esm/registry/module-search.schemas.js +112 -0
  204. package/dist/esm/registry/module-search.schemas.js.map +1 -0
  205. package/dist/esm/registry/registry-config.schemas.d.ts +16 -0
  206. package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
  207. package/dist/esm/registry/registry-config.schemas.js +8 -0
  208. package/dist/esm/registry/registry-config.schemas.js.map +1 -1
  209. package/dist/esm/registry/registry-defaults.constants.d.ts.map +1 -1
  210. package/dist/esm/registry/registry-defaults.constants.js.map +1 -1
  211. package/dist/esm/registry/registry-errors.d.ts +126 -2
  212. package/dist/esm/registry/registry-errors.d.ts.map +1 -1
  213. package/dist/esm/registry/registry-errors.js +183 -14
  214. package/dist/esm/registry/registry-errors.js.map +1 -1
  215. package/dist/esm/registry/registry-keys.schemas.d.ts +80 -0
  216. package/dist/esm/registry/registry-keys.schemas.d.ts.map +1 -0
  217. package/dist/esm/registry/registry-keys.schemas.js +68 -0
  218. package/dist/esm/registry/registry-keys.schemas.js.map +1 -0
  219. package/dist/esm/registry/registry-section-schemas.constants.d.ts +25 -3
  220. package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -1
  221. package/dist/esm/registry/registry-section-schemas.constants.js.map +1 -1
  222. package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
  223. package/dist/esm/release/framework-release.constants.js.map +1 -1
  224. package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -1
  225. package/dist/esm/schemas/framework-info.schemas.js.map +1 -1
  226. package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
  227. package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -1
  228. package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
  229. package/dist/esm/schemas/platform-application-config.schemas.js.map +1 -1
  230. package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
  231. package/dist/esm/schemas/platform-application-secrets.schemas.js.map +1 -1
  232. package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
  233. package/dist/esm/schemas/platform-config.schemas.js.map +1 -1
  234. package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
  235. package/dist/esm/workspace-scope/application-subject-manifest.js.map +1 -1
  236. package/dist/esm/workspace-scope/index.d.ts.map +1 -1
  237. package/dist/esm/workspace-scope/index.js.map +1 -1
  238. package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
  239. package/dist/esm/workspace-scope/resolve-homes.js.map +1 -1
  240. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +13 -11
  241. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
  242. package/dist/esm/workspace-scope/workspace-homes.schemas.js +2 -2
  243. package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
  244. package/dist/esm/workspace-scope/workspace-scope-detector.d.ts.map +1 -1
  245. package/dist/esm/workspace-scope/workspace-scope-detector.js.map +1 -1
  246. package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
  247. package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
  248. package/dist/tsconfig.build.tsbuildinfo +1 -1
  249. package/package.json +7 -7
  250. package/dist/esm/registry/companion-api.schemas.d.ts +0 -176
  251. package/dist/esm/registry/companion-api.schemas.d.ts.map +0 -1
  252. package/dist/esm/registry/companion-api.schemas.js +0 -165
  253. package/dist/esm/registry/companion-api.schemas.js.map +0 -1
@@ -1,11 +1,12 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { existsSync, readFileSync } from 'node:fs';
3
- import { join, resolve as resolvePath } from 'node:path';
3
+ import { resolve as resolvePath } from 'node:path';
4
4
  import { z } from 'zod';
5
- import { FRONTEND_PROVIDER_PUBLIC_CONFIG_KEY, FrontendProviderPublicConfigError, FrontendProvidersBlockSchema, overlayFrontendProviderPublicConfig, } from '@wildo-ai/saas-models';
5
+ import { assertFrontendProvidersServeOnlyDeclaredKeys, assertNoSecretValueInFrontendProviders, FRONTEND_PROVIDER_PUBLIC_CONFIG_KEY, FrontendProviderPublicConfigError, FrontendProvidersBlockSchema, overlayFrontendProviderPublicConfig, resolveProviderConnectionRef, } 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';
9
+ import { resolveProviderBasePackage, selectOptedInProviderAugmentations, describeProviderRefClaimedByMoreThanOneImportPath, readSystemOfRecordFacetModuleSpecifier, } from './provider-companion-discovery.js';
9
10
  export const PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING = 'AUTO-GENERATED FILE. DO NOT EDIT. Regenerate with `wildo config sync`.';
10
11
  export const PROVIDER_RUNTIME_ARTIFACT_GENERATOR = 'wildo provider-runtime-artifact';
11
12
  /**
@@ -111,6 +112,30 @@ const RuntimeProviderModulesArtifactSchema = z.strictObject({
111
112
  * `import("@wildo-ai/saas-models")` and reaches no relative `node_modules` path at all.
112
113
  */
113
114
  const FrontendProviderBootstrapsSchema = z.record(z.string().min(1), FrontendProvidersBlockSchema);
115
+ /**
116
+ * One opted-in AUGMENTATION of a provider, as the host's loader needs it (#1672).
117
+ *
118
+ * `operationIds` is recorded so the loader can refuse a package whose installed code delivers a different set
119
+ * from the one `wildo config sync` validated — a stale artifact, or a package upgraded without a resync —
120
+ * instead of admitting operations nobody checked for collisions.
121
+ *
122
+ * `basePackageName` / `basePackageVersion` record which base the augmentation was composed against. Nothing
123
+ * refuses on them here; declaring and enforcing a compatible base range is #1731's, and this is its seam.
124
+ */
125
+ export const RuntimeProviderAugmentationArtifactSchema = z.strictObject({
126
+ packageName: z.string().min(1),
127
+ packageVersion: z.string().min(1),
128
+ runtimeImportPath: z.string().min(1),
129
+ operationIds: z.array(z.string().min(1)).min(1),
130
+ /**
131
+ * Every vendor scope the augmentation's operations declare (#1671) — recorded so the loader can refuse installed code
132
+ * that needs scopes sync never validated, and so a connection asks a person to consent only to what an opted-in
133
+ * package declared. Absent when it declares none.
134
+ */
135
+ requiredScopes: z.array(z.string().min(1)).min(1).optional(),
136
+ basePackageName: z.string().min(1).optional(),
137
+ basePackageVersion: z.string().min(1).optional(),
138
+ });
114
139
  export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
115
140
  __AUTOGENERATED__: z.literal(PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING),
116
141
  generatedBy: z.literal(PROVIDER_RUNTIME_ARTIFACT_GENERATOR),
@@ -143,6 +168,15 @@ export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
143
168
  * `./companion` is found through.
144
169
  */
145
170
  systemOfRecordFacetModules: z.array(z.string().min(1)).optional(),
171
+ /**
172
+ * `baseRef` -> the opted-in augmentations the host applies to that provider, sorted by package name (#1672).
173
+ *
174
+ * Only refs in this artifact's scope, and only packages the application names under
175
+ * `providers.augmentations` — an installed augmentation that is not opted in never appears here, and the
176
+ * loader applies nothing this map does not name. Absent when nothing is augmented, which keeps every
177
+ * artifact of an application without augmentations byte-identical to what it was.
178
+ */
179
+ providerRuntimeAugmentations: z.record(z.string().min(1), z.array(RuntimeProviderAugmentationArtifactSchema).min(1)).optional(),
146
180
  providerGraphDigest: z.string().min(1),
147
181
  lockfileSectionDigest: z.string().min(1),
148
182
  artifactKind: z.enum([
@@ -182,13 +216,20 @@ config, options) {
182
216
  }
183
217
  const discoveryContext = buildProviderRuntimeDiscoveryContext({
184
218
  discoveredContributions: options?.discoveredContributions,
219
+ discoveredAugmentations: selectOptedInProviderAugmentations(config, options?.discoveredAugmentations ?? []),
185
220
  frontendServiceTypes,
221
+ sharedConnections: config.providers.sharedConnections,
222
+ ...(options?.discoveredSystemOfRecordFacetModules !== undefined ? { systemOfRecordFacetModules: options.discoveredSystemOfRecordFacetModules } : {}),
186
223
  });
224
+ const admittedPackages = [...(options?.admittedProviderPackages ?? [])]
225
+ .sort((left, right) => left.packageName.localeCompare(right.packageName));
187
226
  const lockSection = SaasLockfileProvidersSectionSchema.parse({
188
227
  runtimeScopes: materializeLockRuntimeScopes({
189
228
  scopes,
190
229
  discoveryContext,
191
230
  }),
231
+ // Absent when nothing is listed, so the lock of every application without a listing is byte-identical (#1676).
232
+ ...(admittedPackages.length > 0 ? { admittedPackages } : {}),
192
233
  });
193
234
  const artifactMetadata = buildArtifactMetadata({
194
235
  discoveryContext,
@@ -245,6 +286,8 @@ export function selectScopedProviderRuntimeArtifact(artifact, scopeKey) {
245
286
  // sibling's packages would tell this host it can load something it never declared.
246
287
  providerRuntimeImports: Object.fromEntries(Object.entries(artifact.providerRuntimeImports ?? {})
247
288
  .filter(([providerRef]) => projectedProviderRefs.includes(providerRef))),
289
+ // Narrowed for the same reason: a host applies augmentations only to the providers IT declares (#1672).
290
+ providerRuntimeAugmentations: narrowRuntimeAugmentations(artifact.providerRuntimeAugmentations, projectedProviderRefs),
248
291
  frontendProviderBootstraps: artifact.frontendProviderBootstraps?.[scopeKey]
249
292
  ? { [scopeKey]: artifact.frontendProviderBootstraps[scopeKey] }
250
293
  : undefined,
@@ -252,6 +295,14 @@ export function selectScopedProviderRuntimeArtifact(artifact, scopeKey) {
252
295
  scopes: undefined,
253
296
  });
254
297
  }
298
+ /**
299
+ * The augmentation map restricted to the given refs, or `undefined` when none remain — so a per-host projection
300
+ * of an artifact that augments only a sibling's provider carries no field at all.
301
+ */
302
+ export function narrowRuntimeAugmentations(augmentations, providerRefs) {
303
+ const narrowed = Object.entries(augmentations ?? {}).filter(([providerRef]) => providerRefs.includes(providerRef));
304
+ return narrowed.length === 0 ? undefined : Object.fromEntries(narrowed);
305
+ }
255
306
  /**
256
307
  * Resolve the absolute path to the canonical
257
308
  * `frontend-services.runtime-providers.generated.json` artifact under
@@ -301,6 +352,15 @@ export function loadMaterializedFrontendProviders(input) {
301
352
  if (!parsedBlock.success) {
302
353
  throw staleGeneratedArtifactError(artifactPath, parsedBlock.error.issues);
303
354
  }
355
+ // The website and documentation builds bake this block into pages served to every visitor (and
356
+ // `wildo dev sync-csp` composes their policy from it), and nothing re-runs the overlay here (#1705).
357
+ // An artifact a sync wrote before a schema was mandatory carries entries with no key list that no gate
358
+ // ever held — so the reader refuses it and names the remedy rather than publishing it. The secret-VALUE
359
+ // screen ran when the artifact was written, by its one writer; a build has no environment secrets.
360
+ assertFrontendProvidersServeOnlyDeclaredKeys({
361
+ producer: `Reading ${artifactPath} for frontend service "${serviceKey}"`,
362
+ providers: parsedBlock.data.providers,
363
+ });
304
364
  return parsedBlock.data;
305
365
  }
306
366
  /**
@@ -557,6 +617,7 @@ function materializeRuntimeArtifactFile(input) {
557
617
  providerRefs: input.metadata.providerRefs,
558
618
  providerRuntimeImports: input.metadata.providerRuntimeImports,
559
619
  systemOfRecordFacetModules: input.metadata.systemOfRecordFacetModules,
620
+ providerRuntimeAugmentations: input.metadata.providerRuntimeAugmentations,
560
621
  providerGraphDigest: input.metadata.providerGraphDigest,
561
622
  lockfileSectionDigest: input.metadata.lockfileSectionDigest,
562
623
  artifactKind: input.artifactKind,
@@ -617,13 +678,17 @@ function materializeFrontendProviderBootstraps(input) {
617
678
  * function in `saas-models` so they cannot disagree about what crosses.
618
679
  *
619
680
  * The forbidden set is built from the SAME vendor's non-frontend contributions: a frontend provider
620
- * owns no secrets (`secretsContractShape: []` by construction), so the only secrets that could be
621
- * typed into its bag are the backend module's, and those are exactly what this walk has in hand.
681
+ * owns no secrets (`secretsContractShape: []` by construction), so the only secret NAMES that could
682
+ * be typed into its bag are the backend module's, and those are exactly what this walk has in hand.
683
+ *
684
+ * Runs for EVERY entry, supplied or not (#1705): the overlay is also where an entry with no readable
685
+ * key list is refused and where the module's own and any contribution-mapped keys are held to that
686
+ * list. Returning early when nothing was supplied skipped both. Secret VALUES are not compared here —
687
+ * this walk holds no secrets — but by the one publisher of these artifacts before it writes them
688
+ * ({@link assertFrontendProviderBootstrapsCarryNoSecretValue}).
622
689
  */
623
690
  function applyApplicationPublicConfig(input) {
624
691
  const { serviceKey, providerRef, entry, supplied, discoveredContributions } = input;
625
- if (supplied === undefined)
626
- return entry;
627
692
  const forbiddenKeys = new Set(discoveredContributions
628
693
  .filter((contribution) => contribution.ref === providerRef
629
694
  && contribution.runtimeTargets.some((target) => target.kind !== 'frontendService'))
@@ -636,7 +701,7 @@ function applyApplicationPublicConfig(input) {
636
701
  declaredKeys: entry.publicConfigKeys,
637
702
  forbiddenKeys,
638
703
  });
639
- return publicConfig === undefined ? entry : { ...entry, publicConfig };
704
+ return publicConfig === undefined || publicConfig === entry.publicConfig ? entry : { ...entry, publicConfig };
640
705
  }
641
706
  catch (error) {
642
707
  if (error instanceof FrontendProviderPublicConfigError) {
@@ -645,6 +710,35 @@ function applyApplicationPublicConfig(input) {
645
710
  throw error;
646
711
  }
647
712
  }
713
+ /**
714
+ * Refuses a set of materialized provider runtime artifacts when any frontend provider they would
715
+ * SERVE carries one of the environment's secret values (#1705).
716
+ *
717
+ * Walks every `frontendProviderBootstraps` block of every artifact kind — the backend artifact (whose
718
+ * blocks the backend serves on `/application-config` and bakes into its generated module) and the
719
+ * frontend-services artifact (which the website and documentation builds read) — so no served copy is
720
+ * screened while another is not. The comparison itself is the shared
721
+ * `assertNoSecretValueInFrontendProviders`, which the backend runs over what it serves too.
722
+ *
723
+ * Its one caller is the one writer of these artifacts, `wildo config sync`, and it must run BEFORE
724
+ * anything is written: a refused artifact that already reached disk would be picked up by a watcher
725
+ * and served.
726
+ */
727
+ export function assertFrontendProviderBootstrapsCarryNoSecretValue(input) {
728
+ for (const artifact of Object.values(input.artifacts)) {
729
+ for (const [serviceKey, block] of Object.entries(artifact?.frontendProviderBootstraps ?? {})) {
730
+ assertNoSecretValueInFrontendProviders({
731
+ producer: `${input.producer} (${artifact.artifactKind} artifact, frontend service "${serviceKey}")`,
732
+ providers: block.providers,
733
+ secrets: input.secrets,
734
+ });
735
+ }
736
+ }
737
+ }
738
+ /** Whether any materialized artifact would serve a frontend provider at all — the only case that needs secrets to screen. */
739
+ export function materializedArtifactsServeFrontendProviders(artifacts) {
740
+ return Object.values(artifacts).some((artifact) => Object.values(artifact?.frontendProviderBootstraps ?? {}).some((block) => Object.keys(block.providers).length > 0));
741
+ }
648
742
  function buildFrontendProviderBootstrapDigestInput(input) {
649
743
  const bootstraps = materializeFrontendProviderBootstraps(input);
650
744
  if (!bootstraps) {
@@ -654,12 +748,25 @@ function buildFrontendProviderBootstrapDigestInput(input) {
654
748
  serviceKey,
655
749
  Object.fromEntries(Object.entries(block.providers).map(([providerRef, providerEntry]) => [
656
750
  providerRef,
657
- {
658
- metadata: providerEntry.metadata,
751
+ /*
752
+ * The WHOLE served entry, not a hand-picked subset (#1743). This used to name four
753
+ * fields — metadata, capabilities, protocols, publicConfig — and so every field added to
754
+ * the entry later (the CSP footprint, scripts, the SDK descriptor, components, the
755
+ * declared public-config keys, the fronted storage, and now the vendor's compliance
756
+ * profile) changed the SERVED artifact without moving its digest: the exact "old artifact
757
+ * reported as current" the `providerConfigurations` note above exists to prevent, and a
758
+ * processor register reading such an artifact would name yesterday's regions. Spreading
759
+ * the entry makes a new field a digest input by default rather than by someone
760
+ * remembering. The two arrays are still sorted so their authoring order is not a change,
761
+ * and a key present as `undefined` is dropped because the artifact is written as JSON,
762
+ * where it does not exist — two producers that differ only in spelling "absent" must not
763
+ * differ in digest.
764
+ */
765
+ pruneUndefined({
766
+ ...providerEntry,
659
767
  providerCapabilities: [...providerEntry.providerCapabilities].sort(),
660
768
  protocols: [...providerEntry.protocols].sort(),
661
- publicConfig: providerEntry.publicConfig,
662
- },
769
+ }),
663
770
  ])),
664
771
  ]));
665
772
  }
@@ -678,30 +785,35 @@ function materializeLockRuntimeScopes(input) {
678
785
  const { scopes, discoveryContext } = input;
679
786
  return pruneUndefined({
680
787
  backend: scopes.backend
681
- ? materializeLockScope(scopes.backend.providers, discoveryContext.contributions, discoveryContext.backend.matchesRuntimeTarget)
788
+ ? materializeLockScope(scopes.backend.providers, discoveryContext, discoveryContext.backend.matchesRuntimeTarget, discoveryContext.augmentations)
682
789
  : undefined,
683
790
  companion: scopes.companion
684
- ? materializeLockScope(scopes.companion.providers, discoveryContext.contributions, discoveryContext.companion.matchesRuntimeTarget)
791
+ ? materializeLockScope(scopes.companion.providers, discoveryContext, discoveryContext.companion.matchesRuntimeTarget, discoveryContext.augmentations)
685
792
  : undefined,
686
793
  frontendServices: scopes.frontendServices
687
- ? mapRecord(scopes.frontendServices, (scope, serviceKey) => materializeLockScope(scope.providers, discoveryContext.contributions, discoveryContext.frontendServices.matchesRuntimeTarget(serviceKey)))
794
+ ? mapRecord(scopes.frontendServices, (scope, serviceKey) => materializeLockScope(scope.providers, discoveryContext, discoveryContext.frontendServices.matchesRuntimeTarget(serviceKey),
795
+ // A browser facet merges no augmentation (#1672): a browser reaches an augmented operation only through
796
+ // the backend's operation door, so recording one here would describe code this facet never loads.
797
+ []))
688
798
  : undefined,
689
799
  minions: scopes.minions
690
- ? mapRecord(scopes.minions, (scope, minionKey) => materializeLockScope(scope.providers, discoveryContext.contributions, discoveryContext.minions.matchesRuntimeTarget(minionKey)))
800
+ ? mapRecord(scopes.minions, (scope, minionKey) => materializeLockScope(scope.providers, discoveryContext, discoveryContext.minions.matchesRuntimeTarget(minionKey), discoveryContext.augmentations))
691
801
  : undefined,
692
802
  workers: scopes.workers
693
- ? mapRecord(scopes.workers, (scope, workerKey) => materializeLockScope(scope.providers, discoveryContext.contributions, discoveryContext.workers.matchesRuntimeTarget(workerKey)))
803
+ ? mapRecord(scopes.workers, (scope, workerKey) => materializeLockScope(scope.providers, discoveryContext, discoveryContext.workers.matchesRuntimeTarget(workerKey), discoveryContext.augmentations))
694
804
  : undefined,
695
805
  });
696
806
  }
697
- function materializeLockScope(providers, discoveredContributions, matchesRuntimeTarget) {
807
+ function materializeLockScope(providers, discoveryContext, matchesRuntimeTarget, augmentations) {
698
808
  return mapRecord(providers, (selection, ref) => {
699
809
  const matchingContributions = findMatchingDiscoveredContributions({
700
- discoveredContributions,
810
+ discoveredContributions: discoveryContext.contributions,
701
811
  matchesRuntimeTarget,
702
812
  providerRef: ref,
703
813
  });
704
814
  const secretsContractShape = resolveProviderSecretsContractShape(ref, matchingContributions);
815
+ const recordedAugmentations = buildRuntimeAugmentations([ref], matchingContributions, augmentations)[ref];
816
+ const connectionRef = resolveProviderConnectionRef(discoveryContext.sharedConnections, ref);
705
817
  return {
706
818
  ref,
707
819
  digest: digestJson({
@@ -714,6 +826,22 @@ function materializeLockScope(providers, discoveredContributions, matchesRuntime
714
826
  // assurance-control: WILDO.SECRETS.CONTRACT_INTEGRITY — lock drift
715
827
  // covers the values-free provider contract without persisting secret values.
716
828
  secretsContractDigest: digestJson({ ref, secretsContractShape }),
829
+ // Third-party code admitted to this provider's grant (#1672), recorded so a lock diff shows it ARRIVING —
830
+ // and moving: a new package, a new version or a changed operation set each change this entry. Absent
831
+ // when nothing is augmented, and deliberately NOT folded into `secretsContractDigest` (an augmentation
832
+ // changes no secret) or `digest` (which would re-key every provider's lock entry for a field most never carry).
833
+ // The connection whose grant this ref spends (#1725), only when it is ANOTHER ref's: a lock diff then shows a
834
+ // ref joining or leaving a shared connection, while every undeclared ref's entry keeps its bytes.
835
+ ...(connectionRef === ref ? {} : { connectionRef }),
836
+ ...(recordedAugmentations === undefined ? {} : {
837
+ augmentations: recordedAugmentations.map((augmentation) => ({
838
+ packageName: augmentation.packageName,
839
+ packageVersion: augmentation.packageVersion,
840
+ operationIdsDigest: digestJson(augmentation.operationIds),
841
+ // A package that starts asking for a new scope changes what a person is asked to consent to (#1671).
842
+ ...(augmentation.requiredScopes === undefined ? {} : { requiredScopesDigest: digestJson(augmentation.requiredScopes) }),
843
+ })),
844
+ }),
717
845
  };
718
846
  });
719
847
  }
@@ -766,6 +894,9 @@ function buildProviderRuntimeDiscoveryContext(input) {
766
894
  const { frontendServiceTypes } = input;
767
895
  return {
768
896
  contributions,
897
+ sharedConnections: input.sharedConnections,
898
+ augmentations: input.discoveredAugmentations,
899
+ systemOfRecordFacetModules: input.systemOfRecordFacetModules,
769
900
  backend: {
770
901
  matchesRuntimeTarget: (target) => target.kind === 'backend',
771
902
  },
@@ -791,6 +922,7 @@ function buildProviderRuntimeDiscoveryContext(input) {
791
922
  }
792
923
  function buildArtifactMetadata(input) {
793
924
  const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes, providerConfigurations } = input;
925
+ const augmentations = discoveryContext.augmentations;
794
926
  /*
795
927
  * Computed ONCE for every artifact kind, because a vendor facet is not scoped to a runtime the way
796
928
  * a provider is: it says what a vendor NEEDS, which does not change between a backend and a
@@ -798,11 +930,15 @@ function buildArtifactMetadata(input) {
798
930
  * alone), and recording it everywhere is what keeps that a policy of the RUNTIME rather than a
799
931
  * property of the artifact.
800
932
  */
801
- const systemOfRecordFacetModules = discoverSystemOfRecordFacetModules(discoveryContext.contributions);
933
+ const systemOfRecordFacetModules = discoveryContext.systemOfRecordFacetModules !== undefined
934
+ ? [...discoveryContext.systemOfRecordFacetModules].sort()
935
+ : discoverSystemOfRecordFacetModules(discoveryContext.contributions);
802
936
  const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
803
937
  return {
804
938
  backend: buildSingleScopeArtifactMetadata({
939
+ runtimeLabel: 'the backend',
805
940
  systemOfRecordFacetModules,
941
+ augmentations,
806
942
  modules,
807
943
  providers: scopes.backend?.providers ?? {},
808
944
  matchingContributions: findMatchingDiscoveredContributions({
@@ -822,7 +958,9 @@ function buildArtifactMetadata(input) {
822
958
  scopes,
823
959
  }),
824
960
  companion: buildSingleScopeArtifactMetadata({
961
+ runtimeLabel: 'the companion',
825
962
  systemOfRecordFacetModules,
963
+ augmentations,
826
964
  modules,
827
965
  providers: scopes.companion?.providers ?? {},
828
966
  matchingContributions: findMatchingDiscoveredContributions({
@@ -833,7 +971,16 @@ function buildArtifactMetadata(input) {
833
971
  scopes,
834
972
  }),
835
973
  frontendServices: buildMultiScopeArtifactMetadata({
974
+ runtimeKindLabel: 'frontend service',
975
+ /*
976
+ * Per service only: one ref legitimately has a different browser module per frontend type (posthog is
977
+ * `…-public/app` for the SaaS app and `…-public/website` for the site), and no runtime loads this
978
+ * artifact's merged import map — a browser receives its providers through its bootstrap entries.
979
+ */
980
+ oneImportPathAcrossScopes: false,
836
981
  systemOfRecordFacetModules,
982
+ // No augmentation reaches a browser facet — see `materializeLockRuntimeScopes`.
983
+ augmentations: [],
837
984
  keyedProviders: Object.fromEntries(Object.entries(scopes.frontendServices ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers])),
838
985
  matchingContributionsByScope: Object.fromEntries(Object.keys(scopes.frontendServices ?? {}).map((scopeKey) => [
839
986
  scopeKey,
@@ -853,7 +1000,11 @@ function buildArtifactMetadata(input) {
853
1000
  scopes,
854
1001
  }),
855
1002
  minions: buildMultiScopeArtifactMetadata({
1003
+ runtimeKindLabel: 'minion',
1004
+ // Every minion reads its ref's path from this one merged map, so two minions may not disagree either.
1005
+ oneImportPathAcrossScopes: true,
856
1006
  systemOfRecordFacetModules,
1007
+ augmentations,
857
1008
  keyedProviders: Object.fromEntries(Object.entries(scopes.minions ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers])),
858
1009
  matchingContributionsByScope: Object.fromEntries(Object.keys(scopes.minions ?? {}).map((scopeKey) => [
859
1010
  scopeKey,
@@ -867,7 +1018,11 @@ function buildArtifactMetadata(input) {
867
1018
  scopes,
868
1019
  }),
869
1020
  nodeWorkers: buildMultiScopeArtifactMetadata({
1021
+ runtimeKindLabel: 'worker',
1022
+ // Every worker reads its ref's path from this one merged map, so two workers may not disagree either.
1023
+ oneImportPathAcrossScopes: true,
870
1024
  systemOfRecordFacetModules,
1025
+ augmentations,
871
1026
  keyedProviders: Object.fromEntries(Object.entries(scopes.workers ?? {})
872
1027
  .filter(([scopeKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)
873
1028
  .map(([scopeKey, scope]) => [scopeKey, scope.providers])),
@@ -890,12 +1045,14 @@ function buildArtifactMetadata(input) {
890
1045
  function buildSingleScopeArtifactMetadata(input) {
891
1046
  const providerRefs = Object.keys(input.providers).sort();
892
1047
  const normalizedContributions = normalizeDiscoveredContributionsForDigest(input.matchingContributions);
893
- const providerGraphDigestInput = input.extraArtifactState
1048
+ const providerRuntimeAugmentations = buildRuntimeAugmentations(providerRefs, input.matchingContributions, input.augmentations);
1049
+ const hasAugmentations = Object.keys(providerRuntimeAugmentations).length > 0;
1050
+ const providerGraphDigestInput = withAugmentationsForDigest(input.extraArtifactState
894
1051
  ? {
895
1052
  providerGraph: normalizedContributions,
896
1053
  extraArtifactState: input.extraArtifactState,
897
1054
  }
898
- : normalizedContributions;
1055
+ : normalizedContributions, providerRuntimeAugmentations);
899
1056
  return {
900
1057
  sourceDigest: digestJson({
901
1058
  modules: input.modules,
@@ -903,9 +1060,11 @@ function buildSingleScopeArtifactMetadata(input) {
903
1060
  providerGraph: normalizedContributions,
904
1061
  scopes: input.scopes,
905
1062
  extraArtifactState: input.extraArtifactState,
1063
+ ...(hasAugmentations ? { augmentations: providerRuntimeAugmentations } : {}),
906
1064
  }),
907
1065
  providerRefs,
908
- providerRuntimeImports: buildProviderRuntimeImports(providerRefs, input.matchingContributions),
1066
+ providerRuntimeImports: buildProviderRuntimeImports(providerRefs, input.matchingContributions, input.runtimeLabel),
1067
+ ...(hasAugmentations ? { providerRuntimeAugmentations } : {}),
909
1068
  systemOfRecordFacetModules: input.systemOfRecordFacetModules,
910
1069
  providerGraphDigest: digestJson(providerGraphDigestInput),
911
1070
  lockfileSectionDigest: digestJson(input.runtimeLockSection),
@@ -917,12 +1076,15 @@ function buildMultiScopeArtifactMetadata(input) {
917
1076
  scopeKey,
918
1077
  normalizeDiscoveredContributionsForDigest(contributions),
919
1078
  ]));
920
- const providerGraphDigestInput = input.extraArtifactState
1079
+ const allMatchingContributions = Object.values(input.matchingContributionsByScope).flat();
1080
+ const providerRuntimeAugmentations = buildRuntimeAugmentations(providerRefs, allMatchingContributions, input.augmentations);
1081
+ const hasAugmentations = Object.keys(providerRuntimeAugmentations).length > 0;
1082
+ const providerGraphDigestInput = withAugmentationsForDigest(input.extraArtifactState
921
1083
  ? {
922
1084
  providerGraphByScope: normalizedContributionsByScope,
923
1085
  extraArtifactState: input.extraArtifactState,
924
1086
  }
925
- : normalizedContributionsByScope;
1087
+ : normalizedContributionsByScope, providerRuntimeAugmentations);
926
1088
  return {
927
1089
  sourceDigest: digestJson({
928
1090
  keyedProviders: input.keyedProviders,
@@ -930,35 +1092,28 @@ function buildMultiScopeArtifactMetadata(input) {
930
1092
  providerGraphByScope: normalizedContributionsByScope,
931
1093
  scopes: input.scopes,
932
1094
  extraArtifactState: input.extraArtifactState,
1095
+ ...(hasAugmentations ? { augmentations: providerRuntimeAugmentations } : {}),
933
1096
  }),
934
1097
  providerRefs,
935
- providerRuntimeImports: buildProviderRuntimeImports(providerRefs, Object.values(input.matchingContributionsByScope).flat()),
1098
+ providerRuntimeImports: buildMultiScopeProviderRuntimeImports(providerRefs, input),
1099
+ ...(hasAugmentations ? { providerRuntimeAugmentations } : {}),
936
1100
  systemOfRecordFacetModules: input.systemOfRecordFacetModules,
937
1101
  providerGraphDigest: digestJson(providerGraphDigestInput),
938
1102
  lockfileSectionDigest: digestJson(input.runtimeLockSection),
939
1103
  };
940
1104
  }
941
1105
  /**
942
- * Which packages ship SYSTEM-OF-RECORD VENDOR FACETS (#1057).
943
- *
944
- * ## Read from the MANIFEST, never by loading
945
- *
946
- * A package contributes facets by declaring an `./systems-of-record` export — the same door
947
- * `./companion` is found through, and the same reason: a build-time consumer has no business
948
- * EVALUATING a vendor facet to learn that one exists. Loading would also make the discovery depend
949
- * on the package compiling, which is a different question from whether it declares the surface.
950
- *
951
- * ## Derived from the contribution walk rather than from a second walk
1106
+ * Which packages ship SYSTEM-OF-RECORD VENDOR FACETS (#1057) — the FALLBACK used when a caller supplies no
1107
+ * walk answer (`discoveredSystemOfRecordFacetModules`).
952
1108
  *
953
- * Every candidate package root is already visited to load its companion exports, so the facet
954
- * question is answered from what that walk found. The consequence, stated because it is a real
955
- * bound: a package that ships facets and NO provider contributions is not discovered, because
956
- * nothing would have visited it. That package does not exist today (the catalogue ships 651
957
- * contributions), and the day one does, this function needs the walk's targets rather than its
958
- * results — which is a change here and nowhere else.
1109
+ * Derived from the contributions' package roots, so it is bounded by what the walk's RESULTS contain: a
1110
+ * package that ships facets or facet augmentations and NO provider contribution is not found here. That
1111
+ * package now exists (#1675), which is why discovery answers from its TARGETS
1112
+ * (`DiscoverSaasProviderCompanionContributionsResult.systemOfRecordFacetModules`) and every `wildo` caller
1113
+ * passes that answer. Kept for a caller that builds an artifact from contributions alone (tests, the proofs).
959
1114
  *
960
- * Sorted, so the artifact does not churn on filesystem order, and de-duplicated because one package
961
- * root contributes hundreds of providers and exactly one facet module.
1115
+ * Sorted, so the artifact does not churn on filesystem order, and de-duplicated because one package root
1116
+ * contributes hundreds of providers and exactly one facet module.
962
1117
  */
963
1118
  function discoverSystemOfRecordFacetModules(contributions) {
964
1119
  const specifiers = new Set();
@@ -968,25 +1123,39 @@ function discoverSystemOfRecordFacetModules(contributions) {
968
1123
  if (packageRoot === undefined || visitedRoots.has(packageRoot))
969
1124
  continue;
970
1125
  visitedRoots.add(packageRoot);
971
- let manifest;
972
- try {
973
- manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf-8'));
974
- }
975
- catch {
976
- // Unreadable or absent: the companion walk already tolerates that, and a package we could not
977
- // read is not one we can say anything about.
978
- continue;
979
- }
980
- if (manifest.exports?.[SYSTEM_OF_RECORD_FACET_SUBPATH] === undefined)
981
- continue;
982
- if (typeof manifest.name !== 'string' || manifest.name.length === 0)
983
- continue;
984
- specifiers.add(`${manifest.name}${SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1)}`);
1126
+ const specifier = readSystemOfRecordFacetModuleSpecifier(packageRoot);
1127
+ if (specifier !== undefined)
1128
+ specifiers.add(specifier);
985
1129
  }
986
1130
  return [...specifiers].sort();
987
1131
  }
988
- /** The export a package declares to contribute system-of-record vendor facets. */
989
- const SYSTEM_OF_RECORD_FACET_SUBPATH = './systems-of-record';
1132
+ /**
1133
+ * The merged import map of a multi-scope artifact. Every scope is checked on its own first, so a refusal names the
1134
+ * scope that disagrees with itself; then, where the runtimes load from the merged map, across scopes.
1135
+ */
1136
+ function buildMultiScopeProviderRuntimeImports(providerRefs, input) {
1137
+ for (const [scopeKey, contributions] of Object.entries(input.matchingContributionsByScope).sort(([left], [right]) => left.localeCompare(right))) {
1138
+ buildProviderRuntimeImports(Object.keys(input.keyedProviders[scopeKey] ?? {}), contributions, `${input.runtimeKindLabel} "${scopeKey}"`);
1139
+ }
1140
+ const allMatchingContributions = Object.values(input.matchingContributionsByScope).flat();
1141
+ if (input.oneImportPathAcrossScopes) {
1142
+ return buildProviderRuntimeImports(providerRefs, allMatchingContributions, `every ${input.runtimeKindLabel}`);
1143
+ }
1144
+ /*
1145
+ * Not loaded by any runtime (see the caller), and each scope already has one path per ref: keep the historical
1146
+ * deterministic merge, the sorted-first path per ref, so the artifact does not churn.
1147
+ */
1148
+ const inScope = new Set(providerRefs);
1149
+ const candidatesByRef = new Map();
1150
+ for (const contribution of allMatchingContributions) {
1151
+ if (!inScope.has(contribution.ref))
1152
+ continue;
1153
+ candidatesByRef.set(contribution.ref, [...(candidatesByRef.get(contribution.ref) ?? []), contribution.runtimeImportPath]);
1154
+ }
1155
+ return Object.fromEntries([...candidatesByRef.entries()]
1156
+ .sort(([left], [right]) => left.localeCompare(right))
1157
+ .map(([ref, candidates]) => [ref, [...candidates].sort()[0]]));
1158
+ }
990
1159
  /**
991
1160
  * Project the per-ref runtime import path a host dynamic-imports.
992
1161
  *
@@ -995,13 +1164,15 @@ const SYSTEM_OF_RECORD_FACET_SUBPATH = './systems-of-record';
995
1164
  * engine's on-demand map, and the single fail-loud refusal in the backend registry names it if that
996
1165
  * map does not hold it either.
997
1166
  *
998
- * When several contributions claim one ref with DIFFERENT import paths, the sorted-first path wins
999
- * — deterministically, so the artifact does not churn. Divergence is possible today only between an
1000
- * application's hand-authored engine projection (`@wildo-ai/saas-backend-lib`) and the engine's own
1001
- * companion export, and neither is consulted for an engine-shipped ref, so the choice cannot change
1002
- * which module a host loads. A package provider is contributed by exactly one package.
1167
+ * When several contributions claim one ref with DIFFERENT import paths, the artifact REFUSES (#2014): the
1168
+ * sorted-first path used to win silently, so a second package contributing a ref the application's own copy
1169
+ * (`@<app>/provider-asana`) also contributes decided which module loaded — the #2014 case was a leftover install of
1170
+ * the since-archived provider catalogue, whose `asana` subpath sorted first.
1171
+ * Discovery validation refuses the same case through the same predicate,
1172
+ * {@link describeProviderRefClaimedByMoreThanOneImportPath}; this is the second site, so an artifact can never
1173
+ * be built from contributions that skipped validation. `runtimeLabel` names the runtime in the refusal.
1003
1174
  */
1004
- function buildProviderRuntimeImports(providerRefs, contributions) {
1175
+ function buildProviderRuntimeImports(providerRefs, contributions, runtimeLabel) {
1005
1176
  const inScope = new Set(providerRefs);
1006
1177
  const candidatesByRef = new Map();
1007
1178
  for (const contribution of contributions) {
@@ -1012,9 +1183,55 @@ function buildProviderRuntimeImports(providerRefs, contributions) {
1012
1183
  candidates.add(contribution.runtimeImportPath);
1013
1184
  candidatesByRef.set(contribution.ref, candidates);
1014
1185
  }
1186
+ const refusals = [...candidatesByRef.keys()]
1187
+ .sort()
1188
+ .map((ref) => describeProviderRefClaimedByMoreThanOneImportPath(ref, runtimeLabel, contributions))
1189
+ .filter((refusal) => refusal !== undefined);
1190
+ if (refusals.length > 0) {
1191
+ throw new Error(`Provider runtime artifact refused:\n- ${refusals.join('\n- ')}`);
1192
+ }
1015
1193
  return Object.fromEntries([...candidatesByRef.entries()]
1016
1194
  .sort(([left], [right]) => left.localeCompare(right))
1017
- .map(([ref, candidates]) => [ref, [...candidates].sort()[0]]));
1195
+ .map(([ref, candidates]) => [ref, [...candidates][0]]));
1196
+ }
1197
+ /**
1198
+ * The opted-in augmentations of the given refs, per ref, sorted by package name (#1672).
1199
+ *
1200
+ * A ref no scope-matched contribution covers gets none: an augmentation applies to a provider the host actually
1201
+ * loads. The base package is read from the base's contribution — its runtime import path's package, and that
1202
+ * package's installed version when discovery walked it — and recorded for #1731; nothing here refuses on it.
1203
+ */
1204
+ function buildRuntimeAugmentations(providerRefs, matchingContributions, augmentations) {
1205
+ const result = {};
1206
+ for (const ref of [...providerRefs].sort()) {
1207
+ const base = [...matchingContributions]
1208
+ .filter((contribution) => contribution.ref === ref)
1209
+ .sort((left, right) => left.runtimeImportPath.localeCompare(right.runtimeImportPath))[0];
1210
+ if (base === undefined)
1211
+ continue;
1212
+ const entries = augmentations
1213
+ .filter((augmentation) => augmentation.augments === ref && augmentation.packageVersion !== undefined)
1214
+ .map((augmentation) => RuntimeProviderAugmentationArtifactSchema.parse({
1215
+ packageName: augmentation.packageName,
1216
+ packageVersion: augmentation.packageVersion,
1217
+ runtimeImportPath: augmentation.runtimeImportPath,
1218
+ operationIds: [...augmentation.operationIds],
1219
+ ...(augmentation.requiredScopes.length === 0 ? {} : { requiredScopes: [...augmentation.requiredScopes] }),
1220
+ ...resolveProviderBasePackage(base),
1221
+ }))
1222
+ .sort((left, right) => left.packageName.localeCompare(right.packageName));
1223
+ if (entries.length > 0)
1224
+ result[ref] = entries;
1225
+ }
1226
+ return result;
1227
+ }
1228
+ /**
1229
+ * Fold augmentations into a provider-graph digest input only when there are some, so the digest of every
1230
+ * artifact that augments nothing is byte-identical to what it was before augmentation existed — a running host
1231
+ * compares these digests, and an unrelated field must not read as drift.
1232
+ */
1233
+ function withAugmentationsForDigest(digestInput, augmentations) {
1234
+ return Object.keys(augmentations).length === 0 ? digestInput : { providerGraph: digestInput, augmentations };
1018
1235
  }
1019
1236
  function findMatchingDiscoveredContributions(input) {
1020
1237
  return input.discoveredContributions.flatMap((contribution) => {