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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/LICENSE +34 -0
  2. package/dist/esm/.builder.pid +9 -0
  3. package/dist/esm/_unimplemented/index.d.ts +3 -0
  4. package/dist/esm/_unimplemented/index.d.ts.map +1 -0
  5. package/dist/esm/_unimplemented/index.js +3 -0
  6. package/dist/esm/_unimplemented/index.js.map +1 -0
  7. package/dist/esm/_unimplemented/soft-warn.d.ts +124 -0
  8. package/dist/esm/_unimplemented/soft-warn.d.ts.map +1 -0
  9. package/dist/esm/_unimplemented/soft-warn.js +170 -0
  10. package/dist/esm/_unimplemented/soft-warn.js.map +1 -0
  11. package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts +137 -0
  12. package/dist/esm/_unimplemented/unimplemented-field-warning.d.ts.map +1 -0
  13. package/dist/esm/_unimplemented/unimplemented-field-warning.js +153 -0
  14. package/dist/esm/_unimplemented/unimplemented-field-warning.js.map +1 -0
  15. package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
  16. package/dist/esm/bootstrap/application-backend-env.contracts.js +1 -1
  17. package/dist/esm/bootstrap/application-backend-env.contracts.js.map +1 -1
  18. package/dist/esm/bootstrap/application-creation-verification-env.contracts.d.ts +13 -0
  19. package/dist/esm/bootstrap/application-creation-verification-env.contracts.d.ts.map +1 -0
  20. package/dist/esm/bootstrap/application-creation-verification-env.contracts.js +14 -0
  21. package/dist/esm/bootstrap/application-creation-verification-env.contracts.js.map +1 -0
  22. package/dist/esm/bootstrap/bootstrap-planner.d.ts +1 -1
  23. package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
  24. package/dist/esm/bootstrap/bootstrap-planner.js +1 -1
  25. package/dist/esm/bootstrap/bootstrap-planner.js.map +1 -1
  26. package/dist/esm/bootstrap/bootstrap.contracts.d.ts +141 -37
  27. package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
  28. package/dist/esm/bootstrap/bootstrap.contracts.js +104 -18
  29. package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
  30. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +430 -421
  31. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  32. package/dist/esm/bootstrap/bootstrap.schemas.js +383 -21
  33. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  34. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +213 -8
  35. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  36. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +230 -5
  37. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  38. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts +79 -0
  39. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -0
  40. package/dist/esm/bootstrap/runtime-backing-service-access.js +83 -0
  41. package/dist/esm/bootstrap/runtime-backing-service-access.js.map +1 -0
  42. package/dist/esm/bootstrap/runtime-network-policy.d.ts +63 -0
  43. package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -0
  44. package/dist/esm/bootstrap/runtime-network-policy.js +104 -0
  45. package/dist/esm/bootstrap/runtime-network-policy.js.map +1 -0
  46. package/dist/esm/bootstrap/runtime-network-topology.d.ts +78 -0
  47. package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -0
  48. package/dist/esm/bootstrap/runtime-network-topology.js +134 -0
  49. package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -0
  50. package/dist/esm/bootstrap/runtime-platform-access.d.ts +67 -0
  51. package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -0
  52. package/dist/esm/bootstrap/runtime-platform-access.js +57 -0
  53. package/dist/esm/bootstrap/runtime-platform-access.js.map +1 -0
  54. package/dist/esm/bootstrap/runtime-principal.contracts.d.ts +173 -0
  55. package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -0
  56. package/dist/esm/bootstrap/runtime-principal.contracts.js +218 -0
  57. package/dist/esm/bootstrap/runtime-principal.contracts.js.map +1 -0
  58. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts +112 -1
  59. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
  60. package/dist/esm/bootstrap/runtime-topology.contracts.js +141 -8
  61. package/dist/esm/bootstrap/runtime-topology.contracts.js.map +1 -1
  62. package/dist/esm/config-authoring.entry.d.ts +3 -0
  63. package/dist/esm/config-authoring.entry.d.ts.map +1 -0
  64. package/dist/esm/config-authoring.entry.js +5 -0
  65. package/dist/esm/config-authoring.entry.js.map +1 -0
  66. package/dist/esm/credentials/credential-generator.service.d.ts.map +1 -1
  67. package/dist/esm/credentials/credential-generator.service.js +1 -1
  68. package/dist/esm/credentials/credential-generator.service.js.map +1 -1
  69. package/dist/esm/index.d.ts +30 -15
  70. package/dist/esm/index.d.ts.map +1 -1
  71. package/dist/esm/index.js +16 -1
  72. package/dist/esm/index.js.map +1 -1
  73. package/dist/esm/lockfile/canonical-json.d.ts +41 -0
  74. package/dist/esm/lockfile/canonical-json.d.ts.map +1 -0
  75. package/dist/esm/lockfile/canonical-json.js +56 -0
  76. package/dist/esm/lockfile/canonical-json.js.map +1 -0
  77. package/dist/esm/lockfile/lockfile-io.d.ts +231 -0
  78. package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -0
  79. package/dist/esm/lockfile/lockfile-io.js +303 -0
  80. package/dist/esm/lockfile/lockfile-io.js.map +1 -0
  81. package/dist/esm/lockfile/materialize-infra-section.d.ts +99 -0
  82. package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -0
  83. package/dist/esm/lockfile/materialize-infra-section.js +153 -0
  84. package/dist/esm/lockfile/materialize-infra-section.js.map +1 -0
  85. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +522 -0
  86. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -0
  87. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +116 -0
  88. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -0
  89. package/dist/esm/project-config/define-framework-config.d.ts +36 -10
  90. package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
  91. package/dist/esm/project-config/define-framework-config.js +67 -3
  92. package/dist/esm/project-config/define-framework-config.js.map +1 -1
  93. package/dist/esm/project-config/define-infra-env-config.d.ts +570 -0
  94. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -0
  95. package/dist/esm/project-config/define-infra-env-config.js +726 -0
  96. package/dist/esm/project-config/define-infra-env-config.js.map +1 -0
  97. package/dist/esm/project-config/define-minion-config.d.ts +221 -23
  98. package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
  99. package/dist/esm/project-config/define-minion-config.js +228 -11
  100. package/dist/esm/project-config/define-minion-config.js.map +1 -1
  101. package/dist/esm/project-config/define-saas-config.d.ts +427 -218
  102. package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
  103. package/dist/esm/project-config/define-saas-config.js +704 -75
  104. package/dist/esm/project-config/define-saas-config.js.map +1 -1
  105. package/dist/esm/project-config/define-worker-config.d.ts +106 -10
  106. package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
  107. package/dist/esm/project-config/define-worker-config.js +99 -9
  108. package/dist/esm/project-config/define-worker-config.js.map +1 -1
  109. package/dist/esm/project-config/index.d.ts +28 -21
  110. package/dist/esm/project-config/index.d.ts.map +1 -1
  111. package/dist/esm/project-config/index.js +14 -7
  112. package/dist/esm/project-config/index.js.map +1 -1
  113. package/dist/esm/project-config/loader.d.ts +120 -10
  114. package/dist/esm/project-config/loader.d.ts.map +1 -1
  115. package/dist/esm/project-config/loader.js +290 -38
  116. package/dist/esm/project-config/loader.js.map +1 -1
  117. package/dist/esm/project-config/minion-local-provider-registration.d.ts +69 -0
  118. package/dist/esm/project-config/minion-local-provider-registration.d.ts.map +1 -0
  119. package/dist/esm/project-config/minion-local-provider-registration.js +72 -0
  120. package/dist/esm/project-config/minion-local-provider-registration.js.map +1 -0
  121. package/dist/esm/project-config/provider-catalog-types.d.ts +12 -0
  122. package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -0
  123. package/dist/esm/project-config/provider-catalog-types.js +49 -0
  124. package/dist/esm/project-config/provider-catalog-types.js.map +1 -0
  125. package/dist/esm/project-config/provider-companion-discovery.d.ts +24 -0
  126. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -0
  127. package/dist/esm/project-config/provider-companion-discovery.js +244 -0
  128. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -0
  129. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +297 -0
  130. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -0
  131. package/dist/esm/project-config/provider-runtime-artifacts.js +860 -0
  132. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -0
  133. package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts +18 -0
  134. package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -0
  135. package/dist/esm/project-config/shared/application-creation-verification.schemas.js +25 -0
  136. package/dist/esm/project-config/shared/application-creation-verification.schemas.js.map +1 -0
  137. package/dist/esm/project-config/shared/application-modules.schemas.d.ts +10 -2
  138. package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -1
  139. package/dist/esm/project-config/shared/application-modules.schemas.js +12 -1
  140. package/dist/esm/project-config/shared/application-modules.schemas.js.map +1 -1
  141. package/dist/esm/project-config/shared/application-modules.utils.d.ts +2 -1
  142. package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
  143. package/dist/esm/project-config/shared/application-modules.utils.js +6 -1
  144. package/dist/esm/project-config/shared/application-modules.utils.js.map +1 -1
  145. package/dist/esm/project-config/shared/auth.schemas.d.ts +102 -0
  146. package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -0
  147. package/dist/esm/project-config/shared/auth.schemas.js +100 -0
  148. package/dist/esm/project-config/shared/auth.schemas.js.map +1 -0
  149. package/dist/esm/project-config/shared/backing-services.schemas.d.ts +316 -39
  150. package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
  151. package/dist/esm/project-config/shared/backing-services.schemas.js +359 -24
  152. package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
  153. package/dist/esm/project-config/shared/cdn.example.d.ts +14 -0
  154. package/dist/esm/project-config/shared/cdn.example.d.ts.map +1 -0
  155. package/dist/esm/project-config/shared/cdn.example.js +38 -0
  156. package/dist/esm/project-config/shared/cdn.example.js.map +1 -0
  157. package/dist/esm/project-config/shared/cdn.schemas.d.ts +182 -0
  158. package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -0
  159. package/dist/esm/project-config/shared/cdn.schemas.js +151 -0
  160. package/dist/esm/project-config/shared/cdn.schemas.js.map +1 -0
  161. package/dist/esm/project-config/shared/csp-defaults.d.ts +92 -0
  162. package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -0
  163. package/dist/esm/project-config/shared/csp-defaults.js +195 -0
  164. package/dist/esm/project-config/shared/csp-defaults.js.map +1 -0
  165. package/dist/esm/project-config/shared/csp-emit.d.ts +106 -0
  166. package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -0
  167. package/dist/esm/project-config/shared/csp-emit.js +305 -0
  168. package/dist/esm/project-config/shared/csp-emit.js.map +1 -0
  169. package/dist/esm/project-config/shared/csp.schemas.d.ts +266 -0
  170. package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -0
  171. package/dist/esm/project-config/shared/csp.schemas.js +281 -0
  172. package/dist/esm/project-config/shared/csp.schemas.js.map +1 -0
  173. package/dist/esm/project-config/shared/data-services.schemas.d.ts +45 -9
  174. package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
  175. package/dist/esm/project-config/shared/data-services.schemas.js +45 -9
  176. package/dist/esm/project-config/shared/data-services.schemas.js.map +1 -1
  177. package/dist/esm/project-config/shared/env-example-defaults.d.ts +0 -1
  178. package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
  179. package/dist/esm/project-config/shared/env-example-defaults.js +1 -2
  180. package/dist/esm/project-config/shared/env-example-defaults.js.map +1 -1
  181. package/dist/esm/project-config/shared/environment.schemas.d.ts +134 -8
  182. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  183. package/dist/esm/project-config/shared/environment.schemas.js +185 -2
  184. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  185. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +779 -0
  186. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -0
  187. package/dist/esm/project-config/shared/infra-providers.schemas.js +210 -0
  188. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -0
  189. package/dist/esm/project-config/shared/infra-service.schemas.d.ts +18 -0
  190. package/dist/esm/project-config/shared/infra-service.schemas.d.ts.map +1 -0
  191. package/dist/esm/project-config/shared/infra-service.schemas.js +16 -0
  192. package/dist/esm/project-config/shared/infra-service.schemas.js.map +1 -0
  193. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts +83 -1
  194. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
  195. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js +99 -2
  196. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
  197. package/dist/esm/project-config/shared/k8s-utils.d.ts +51 -7
  198. package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
  199. package/dist/esm/project-config/shared/k8s-utils.js +59 -12
  200. package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
  201. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts +31 -0
  202. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -0
  203. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js +32 -0
  204. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -0
  205. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts +142 -0
  206. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -0
  207. package/dist/esm/project-config/shared/minion-resource-access.validation.js +159 -0
  208. package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -0
  209. package/dist/esm/project-config/shared/object-storage-session-policy.d.ts +100 -0
  210. package/dist/esm/project-config/shared/object-storage-session-policy.d.ts.map +1 -0
  211. package/dist/esm/project-config/shared/object-storage-session-policy.js +130 -0
  212. package/dist/esm/project-config/shared/object-storage-session-policy.js.map +1 -0
  213. package/dist/esm/project-config/shared/platform-services.schemas.d.ts +9 -14
  214. package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
  215. package/dist/esm/project-config/shared/platform-services.schemas.js +13 -9
  216. package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
  217. package/dist/esm/project-config/shared/schema-version.schemas.d.ts +15 -0
  218. package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -0
  219. package/dist/esm/project-config/shared/schema-version.schemas.js +40 -0
  220. package/dist/esm/project-config/shared/schema-version.schemas.js.map +1 -0
  221. package/dist/esm/project-config/shared/service-definitions.schemas.d.ts +283 -8
  222. package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
  223. package/dist/esm/project-config/shared/service-definitions.schemas.js +325 -8
  224. package/dist/esm/project-config/shared/service-definitions.schemas.js.map +1 -1
  225. package/dist/esm/registry/artifact-domain.schemas.d.ts +54 -0
  226. package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -0
  227. package/dist/esm/registry/artifact-domain.schemas.js +40 -0
  228. package/dist/esm/registry/artifact-domain.schemas.js.map +1 -0
  229. package/dist/esm/registry/companion-api.schemas.d.ts +176 -0
  230. package/dist/esm/registry/companion-api.schemas.d.ts.map +1 -0
  231. package/dist/esm/registry/companion-api.schemas.js +165 -0
  232. package/dist/esm/registry/companion-api.schemas.js.map +1 -0
  233. package/dist/esm/registry/digest.schemas.d.ts +20 -0
  234. package/dist/esm/registry/digest.schemas.d.ts.map +1 -0
  235. package/dist/esm/registry/digest.schemas.js +21 -0
  236. package/dist/esm/registry/digest.schemas.js.map +1 -0
  237. package/dist/esm/registry/index.d.ts +33 -0
  238. package/dist/esm/registry/index.d.ts.map +1 -0
  239. package/dist/esm/registry/index.js +33 -0
  240. package/dist/esm/registry/index.js.map +1 -0
  241. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts +107 -0
  242. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -0
  243. package/dist/esm/registry/lockfile-modules-section.schemas.js +67 -0
  244. package/dist/esm/registry/lockfile-modules-section.schemas.js.map +1 -0
  245. package/dist/esm/registry/module-artifact.schemas.d.ts +94 -0
  246. package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -0
  247. package/dist/esm/registry/module-artifact.schemas.js +69 -0
  248. package/dist/esm/registry/module-artifact.schemas.js.map +1 -0
  249. package/dist/esm/registry/module-manifest.schemas.d.ts +134 -0
  250. package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -0
  251. package/dist/esm/registry/module-manifest.schemas.js +155 -0
  252. package/dist/esm/registry/module-manifest.schemas.js.map +1 -0
  253. package/dist/esm/registry/registry-config.schemas.d.ts +31 -0
  254. package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -0
  255. package/dist/esm/registry/registry-config.schemas.js +24 -0
  256. package/dist/esm/registry/registry-config.schemas.js.map +1 -0
  257. package/dist/esm/registry/registry-defaults.constants.d.ts +37 -0
  258. package/dist/esm/registry/registry-defaults.constants.d.ts.map +1 -0
  259. package/dist/esm/registry/registry-defaults.constants.js +37 -0
  260. package/dist/esm/registry/registry-defaults.constants.js.map +1 -0
  261. package/dist/esm/registry/registry-errors.d.ts +109 -0
  262. package/dist/esm/registry/registry-errors.d.ts.map +1 -0
  263. package/dist/esm/registry/registry-errors.js +185 -0
  264. package/dist/esm/registry/registry-errors.js.map +1 -0
  265. package/dist/esm/registry/registry-section-schemas.constants.d.ts +39 -0
  266. package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -0
  267. package/dist/esm/registry/registry-section-schemas.constants.js +22 -0
  268. package/dist/esm/registry/registry-section-schemas.constants.js.map +1 -0
  269. package/dist/esm/release/framework-release.constants.d.ts +26 -1
  270. package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
  271. package/dist/esm/release/framework-release.constants.js +27 -2
  272. package/dist/esm/release/framework-release.constants.js.map +1 -1
  273. package/dist/esm/schemas/framework-info.schemas.d.ts +1 -1
  274. package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -1
  275. package/dist/esm/schemas/framework-info.schemas.js +1 -1
  276. package/dist/esm/schemas/framework-info.schemas.js.map +1 -1
  277. package/dist/esm/schemas/framework-secrets.schemas.d.ts +5 -5
  278. package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
  279. package/dist/esm/schemas/framework-secrets.schemas.js +1 -1
  280. package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -1
  281. package/dist/esm/schemas/platform-application-config.schemas.d.ts +1 -1
  282. package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
  283. package/dist/esm/schemas/platform-application-config.schemas.js +11 -2
  284. package/dist/esm/schemas/platform-application-config.schemas.js.map +1 -1
  285. package/dist/esm/schemas/platform-application-secrets.schemas.d.ts +7 -7
  286. package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
  287. package/dist/esm/schemas/platform-application-secrets.schemas.js +17 -2
  288. package/dist/esm/schemas/platform-application-secrets.schemas.js.map +1 -1
  289. package/dist/esm/schemas/platform-config.schemas.d.ts +12 -13
  290. package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
  291. package/dist/esm/schemas/platform-config.schemas.js +15 -3
  292. package/dist/esm/schemas/platform-config.schemas.js.map +1 -1
  293. package/dist/esm/workspace-scope/application-subject-manifest.d.ts +26 -0
  294. package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -0
  295. package/dist/esm/workspace-scope/application-subject-manifest.js +43 -0
  296. package/dist/esm/workspace-scope/application-subject-manifest.js.map +1 -0
  297. package/dist/esm/workspace-scope/index.d.ts +5 -2
  298. package/dist/esm/workspace-scope/index.d.ts.map +1 -1
  299. package/dist/esm/workspace-scope/index.js +4 -1
  300. package/dist/esm/workspace-scope/index.js.map +1 -1
  301. package/dist/esm/workspace-scope/resolve-homes.d.ts +20 -0
  302. package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -0
  303. package/dist/esm/workspace-scope/resolve-homes.js +62 -0
  304. package/dist/esm/workspace-scope/resolve-homes.js.map +1 -0
  305. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +211 -0
  306. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -0
  307. package/dist/esm/workspace-scope/workspace-homes.schemas.js +113 -0
  308. package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -0
  309. package/dist/esm/workspace-scope/workspace-scope-detector.d.ts +10 -5
  310. package/dist/esm/workspace-scope/workspace-scope-detector.d.ts.map +1 -1
  311. package/dist/esm/workspace-scope/workspace-scope-detector.js +22 -36
  312. package/dist/esm/workspace-scope/workspace-scope-detector.js.map +1 -1
  313. package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts +147 -58
  314. package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
  315. package/dist/esm/workspace-scope/workspace-scope.schemas.js +174 -78
  316. package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
  317. package/dist/tsconfig.build.tsbuildinfo +1 -1
  318. package/package.json +31 -17
  319. package/dist/esm/credentials/credentials-provisioner.service.d.ts +0 -190
  320. package/dist/esm/credentials/credentials-provisioner.service.d.ts.map +0 -1
  321. package/dist/esm/credentials/credentials-provisioner.service.js +0 -278
  322. package/dist/esm/credentials/credentials-provisioner.service.js.map +0 -1
  323. package/dist/esm/infra-managers/infra-manager.models.d.ts +0 -146
  324. package/dist/esm/infra-managers/infra-manager.models.d.ts.map +0 -1
  325. package/dist/esm/infra-managers/infra-manager.models.js +0 -2
  326. package/dist/esm/infra-managers/infra-manager.models.js.map +0 -1
  327. package/dist/esm/infra-managers/mongo-atlas-manager.service.d.ts +0 -64
  328. package/dist/esm/infra-managers/mongo-atlas-manager.service.d.ts.map +0 -1
  329. package/dist/esm/infra-managers/mongo-atlas-manager.service.js +0 -307
  330. package/dist/esm/infra-managers/mongo-atlas-manager.service.js.map +0 -1
  331. package/dist/esm/infra-managers/postgresql-manager.service.d.ts +0 -115
  332. package/dist/esm/infra-managers/postgresql-manager.service.d.ts.map +0 -1
  333. package/dist/esm/infra-managers/postgresql-manager.service.js +0 -403
  334. package/dist/esm/infra-managers/postgresql-manager.service.js.map +0 -1
  335. package/dist/esm/infra-managers/rabbitmq-manager.service.d.ts +0 -64
  336. package/dist/esm/infra-managers/rabbitmq-manager.service.d.ts.map +0 -1
  337. package/dist/esm/infra-managers/rabbitmq-manager.service.js +0 -288
  338. package/dist/esm/infra-managers/rabbitmq-manager.service.js.map +0 -1
  339. package/dist/esm/infra-managers/redis-manager.service.d.ts +0 -78
  340. package/dist/esm/infra-managers/redis-manager.service.d.ts.map +0 -1
  341. package/dist/esm/infra-managers/redis-manager.service.js +0 -326
  342. package/dist/esm/infra-managers/redis-manager.service.js.map +0 -1
  343. package/dist/esm/project-config/define-infra-config.d.ts +0 -128
  344. package/dist/esm/project-config/define-infra-config.d.ts.map +0 -1
  345. package/dist/esm/project-config/define-infra-config.js +0 -87
  346. package/dist/esm/project-config/define-infra-config.js.map +0 -1
  347. package/dist/esm/project-config/define-platform-config.d.ts +0 -65
  348. package/dist/esm/project-config/define-platform-config.d.ts.map +0 -1
  349. package/dist/esm/project-config/define-platform-config.js +0 -22
  350. package/dist/esm/project-config/define-platform-config.js.map +0 -1
  351. package/dist/esm/project-config/define-platform-env-config.d.ts +0 -41
  352. package/dist/esm/project-config/define-platform-env-config.d.ts.map +0 -1
  353. package/dist/esm/project-config/define-platform-env-config.js +0 -45
  354. package/dist/esm/project-config/define-platform-env-config.js.map +0 -1
  355. package/dist/esm/project-config/define-project-config.d.ts +0 -38
  356. package/dist/esm/project-config/define-project-config.d.ts.map +0 -1
  357. package/dist/esm/project-config/define-project-config.js +0 -57
  358. package/dist/esm/project-config/define-project-config.js.map +0 -1
  359. package/dist/esm/project-config/define-sharing-policy.d.ts +0 -35
  360. package/dist/esm/project-config/define-sharing-policy.d.ts.map +0 -1
  361. package/dist/esm/project-config/define-sharing-policy.js +0 -30
  362. package/dist/esm/project-config/define-sharing-policy.js.map +0 -1
  363. package/dist/esm/project-config/sharing-policy-validation.d.ts +0 -40
  364. package/dist/esm/project-config/sharing-policy-validation.d.ts.map +0 -1
  365. package/dist/esm/project-config/sharing-policy-validation.js +0 -143
  366. package/dist/esm/project-config/sharing-policy-validation.js.map +0 -1
  367. package/dist/esm/runtime-bridge/platform-runtime-bridge.contracts.d.ts +0 -23
  368. package/dist/esm/runtime-bridge/platform-runtime-bridge.contracts.d.ts.map +0 -1
  369. package/dist/esm/runtime-bridge/platform-runtime-bridge.contracts.js +0 -13
  370. package/dist/esm/runtime-bridge/platform-runtime-bridge.contracts.js.map +0 -1
  371. package/src/bootstrap/application-backend-env.contracts.ts +0 -17
  372. package/src/bootstrap/bootstrap-planner.ts +0 -46
  373. package/src/bootstrap/bootstrap.contracts.ts +0 -251
  374. package/src/bootstrap/bootstrap.schemas.ts +0 -164
  375. package/src/bootstrap/platform-runtime-env.contracts.ts +0 -99
  376. package/src/bootstrap/runtime-topology.contracts.ts +0 -102
  377. package/src/credentials/credential-generator.service.ts +0 -39
  378. package/src/index.ts +0 -16
  379. package/src/project-config/__tests__/application-modules.utils.test.ts +0 -53
  380. package/src/project-config/__tests__/define-framework-config.test.ts +0 -43
  381. package/src/project-config/__tests__/define-saas-config.test.ts +0 -210
  382. package/src/project-config/__tests__/loader.test.ts +0 -100
  383. package/src/project-config/define-framework-config.ts +0 -44
  384. package/src/project-config/define-infra-config.ts +0 -168
  385. package/src/project-config/define-minion-config.ts +0 -27
  386. package/src/project-config/define-platform-config.ts +0 -28
  387. package/src/project-config/define-platform-env-config.ts +0 -59
  388. package/src/project-config/define-project-config.ts +0 -63
  389. package/src/project-config/define-saas-config.ts +0 -171
  390. package/src/project-config/define-sharing-policy.ts +0 -36
  391. package/src/project-config/define-worker-config.ts +0 -27
  392. package/src/project-config/index.ts +0 -23
  393. package/src/project-config/loader.ts +0 -220
  394. package/src/project-config/shared/application-modules.schemas.ts +0 -12
  395. package/src/project-config/shared/application-modules.utils.ts +0 -65
  396. package/src/project-config/shared/backing-services.schemas.ts +0 -59
  397. package/src/project-config/shared/data-services.schemas.ts +0 -58
  398. package/src/project-config/shared/env-example-defaults.ts +0 -50
  399. package/src/project-config/shared/environment.schemas.ts +0 -136
  400. package/src/project-config/shared/infrastructure-defaults.schemas.ts +0 -47
  401. package/src/project-config/shared/k8s-utils.ts +0 -56
  402. package/src/project-config/shared/platform-services.schemas.ts +0 -33
  403. package/src/project-config/shared/service-definitions.schemas.ts +0 -38
  404. package/src/project-config/sharing-policy-validation.ts +0 -159
  405. package/src/release/framework-release.constants.ts +0 -2
  406. package/src/schemas/__tests__/platform-config.schemas.test.ts +0 -90
  407. package/src/schemas/framework-info.schemas.ts +0 -13
  408. package/src/schemas/framework-secrets.schemas.ts +0 -19
  409. package/src/schemas/platform-application-config.schemas.ts +0 -25
  410. package/src/schemas/platform-application-secrets.schemas.ts +0 -78
  411. package/src/schemas/platform-config.schemas.ts +0 -45
  412. package/src/workspace-scope/index.ts +0 -2
  413. package/src/workspace-scope/workspace-scope-detector.ts +0 -98
  414. package/src/workspace-scope/workspace-scope.schemas.ts +0 -224
@@ -0,0 +1,860 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { resolve as resolvePath } from 'node:path';
4
+ import { z } from 'zod';
5
+ import { FrontendProvidersBlockSchema, } from '@wildo-ai/saas-models';
6
+ import { SaasLockfileProvidersSectionSchema, } from '../lockfile/wildo-saas-lock.shared.schemas.js';
7
+ import { getDeclaredApplicationModuleIds, getServiceBoundApplicationModuleIds, } from './shared/application-modules.utils.js';
8
+ import { SaasProvidersScopesSchema, SaasProviderScopeSelectionSchema, } from './define-saas-config.js';
9
+ export const PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING = 'AUTO-GENERATED FILE. DO NOT EDIT. Regenerate with `wildo config sync`.';
10
+ export const PROVIDER_RUNTIME_ARTIFACT_GENERATOR = 'wildo provider-runtime-artifact';
11
+ /**
12
+ * Canonical relative paths (from saas root) for the per-runtime-kind
13
+ * provider artifact JSON files emitted by `wildo config sync`.
14
+ *
15
+ * Moved from `.wildo-saas/providers/` → `.wildo-saas/generated/providers/`
16
+ * on 2026-05-06 to group ALL CLI-generated runtime topology artifacts
17
+ * under the `.wildo-saas/generated/` namespace (sibling to other
18
+ * generated state). The legacy `.wildo-saas/providers/` location is
19
+ * cleaned up by `cleanupLegacyProviderJsonArtifacts` in the CLI sync
20
+ * so operators don't end up with two copies after the migration.
21
+ */
22
+ export const PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS = {
23
+ backend: '.wildo-saas/generated/providers/backend.runtime-providers.generated.json',
24
+ companion: '.wildo-saas/generated/providers/companion.runtime-providers.generated.json',
25
+ frontendServices: '.wildo-saas/generated/providers/frontend-services.runtime-providers.generated.json',
26
+ minions: '.wildo-saas/generated/providers/minions.runtime-providers.generated.json',
27
+ nodeWorkers: '.wildo-saas/generated/providers/node-workers.runtime-providers.generated.json',
28
+ };
29
+ /**
30
+ * Legacy paths (pre-2026-05-06) for the per-runtime-kind provider
31
+ * artifact JSON files. These are NOT written anymore — kept here so
32
+ * `wildo config sync` can clean them up if they exist on disk from a
33
+ * pre-migration sync. Drop this constant entirely once Wonder Todos
34
+ * + downstream apps have all run a post-migration sync at least once.
35
+ */
36
+ export const LEGACY_PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS = {
37
+ backend: '.wildo-saas/providers/backend.runtime-providers.generated.json',
38
+ companion: '.wildo-saas/providers/companion.runtime-providers.generated.json',
39
+ frontendServices: '.wildo-saas/providers/frontend-services.runtime-providers.generated.json',
40
+ minions: '.wildo-saas/providers/minions.runtime-providers.generated.json',
41
+ nodeWorkers: '.wildo-saas/providers/node-workers.runtime-providers.generated.json',
42
+ };
43
+ export const PROVIDER_RUNTIME_GENERATED_MODULE_RELATIVE_PATH = 'src/generated/wildo-provider-runtime.generated.ts';
44
+ /**
45
+ * Canonical lockfile section path the provider-materialization
46
+ * subsystem owns end-to-end. Used by the post-mutation provider sync
47
+ * runner + materialization-hook return types and pinned by tests
48
+ * (`provider-sync-runner.test.ts`, `provider-materialization-hook.test.ts`).
49
+ *
50
+ * Defined here as a single-source constant — used to live as a
51
+ * literal in 3+ places across `wildo-module-client` (third-pass
52
+ * review C-L1).
53
+ */
54
+ export const PROVIDER_LOCK_SECTION_PATH = 'sections.providers.runtimeScopes';
55
+ /**
56
+ * Per-worker generated env file written by `wildo config sync`. Carries
57
+ * provider topology env vars derived from the materialized scope.
58
+ *
59
+ * This file is the **single delivery channel** non-Node workers (Rust /
60
+ * Java / etc.) receive for provider topology — there is no executable
61
+ * JS bundle in their case (Step 5b in
62
+ * `.claude/plans/provider-migration-continuation.md`). Node workers
63
+ * receive both this file and the per-package
64
+ * `wildo-provider-runtime.generated.ts` source module; reading either
65
+ * surface yields a consistent view because they share the same digest.
66
+ *
67
+ * The file is auto-generated and overwritten on every sync. Operator-
68
+ * authored secrets and per-env config stay in the worker's `.env` (not
69
+ * touched by `wildo config sync`); workers should load both files at
70
+ * boot — operator vars from `.env` and provider vars from this file —
71
+ * so the two channels never collide.
72
+ */
73
+ export const PROVIDER_RUNTIME_GENERATED_ENV_FILE_NAME = '.wildo-providers.env';
74
+ const RuntimeProviderScopeArtifactSchema = z.strictObject({
75
+ providers: z.record(z.string(), SaasProviderScopeSelectionSchema).default({}),
76
+ selection: z.record(z.string(), z.strictObject({
77
+ primary: z.string().min(1),
78
+ fallbacks: z.array(z.string().min(1)).default([]),
79
+ })).default({}),
80
+ });
81
+ const RuntimeProviderModulesArtifactSchema = z.strictObject({
82
+ declaredModules: z.record(z.string(), z.strictObject({
83
+ services: z.array(z.string().min(1)),
84
+ haveSamlIntegration: z.boolean().optional(),
85
+ })).default({}),
86
+ moduleIds: z.array(z.string().min(1)).default([]),
87
+ moduleIdsByService: z.record(z.string(), z.array(z.string().min(1))).default({}),
88
+ });
89
+ const FrontendProviderBootstrapsSchema = z.record(z.string().min(1), FrontendProvidersBlockSchema);
90
+ export const SaasRuntimeProvidersArtifactSchema = z.strictObject({
91
+ __AUTOGENERATED__: z.literal(PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING),
92
+ generatedBy: z.literal(PROVIDER_RUNTIME_ARTIFACT_GENERATOR),
93
+ generatedAt: z.string().datetime({ offset: true }),
94
+ sourceDigest: z.string().min(1),
95
+ providerRefs: z.array(z.string().min(1)).default([]),
96
+ providerGraphDigest: z.string().min(1),
97
+ lockfileSectionDigest: z.string().min(1),
98
+ artifactKind: z.enum([
99
+ 'backend',
100
+ 'companion',
101
+ 'frontendServices',
102
+ 'minions',
103
+ 'nodeWorkers',
104
+ ]),
105
+ modules: RuntimeProviderModulesArtifactSchema,
106
+ scope: RuntimeProviderScopeArtifactSchema.optional(),
107
+ scopes: z.record(z.string(), RuntimeProviderScopeArtifactSchema).optional(),
108
+ frontendProviderBootstraps: FrontendProviderBootstrapsSchema.optional(),
109
+ });
110
+ export function materializeSaasProviderRuntimeArtifacts(config, options) {
111
+ const scopes = SaasProvidersScopesSchema.parse(config.providers.scopes);
112
+ const generatedAt = options?.generatedAt ?? new Date().toISOString();
113
+ const modules = materializeModules(config);
114
+ const frontendServiceTypes = Object.fromEntries(Object.entries(config.services ?? {})
115
+ .filter(([, definition]) => definition.frontendType !== undefined)
116
+ .map(([serviceKey, definition]) => [serviceKey, definition.frontendType]));
117
+ const discoveryContext = buildProviderRuntimeDiscoveryContext({
118
+ discoveredContributions: options?.discoveredContributions,
119
+ frontendServiceTypes,
120
+ });
121
+ const lockSection = SaasLockfileProvidersSectionSchema.parse({
122
+ runtimeScopes: materializeLockRuntimeScopes({
123
+ scopes,
124
+ discoveryContext,
125
+ }),
126
+ });
127
+ const artifactMetadata = buildArtifactMetadata({
128
+ discoveryContext,
129
+ frontendServiceTypes,
130
+ lockSection,
131
+ modules,
132
+ nodeWorkerKeys: options?.nodeWorkerKeys,
133
+ scopes,
134
+ });
135
+ const artifacts = materializeRuntimeArtifacts({
136
+ artifactMetadata,
137
+ discoveryContext,
138
+ frontendServiceTypes,
139
+ generatedAt,
140
+ modules,
141
+ nodeWorkerKeys: options?.nodeWorkerKeys,
142
+ scopes,
143
+ });
144
+ return { artifacts, lockSection };
145
+ }
146
+ export function selectScopedProviderRuntimeArtifact(artifact, scopeKey) {
147
+ if (!artifact.scopes) {
148
+ throw new Error(`Provider runtime artifact '${artifact.artifactKind}' does not contain keyed scopes.`);
149
+ }
150
+ const scope = artifact.scopes[scopeKey];
151
+ if (!scope) {
152
+ throw new Error(`Provider runtime artifact '${artifact.artifactKind}' does not contain scope '${scopeKey}'.`);
153
+ }
154
+ // Recompute `providerRefs` from the projected per-host scope rather
155
+ // than carrying the parent multi-scope union forward unchanged. The
156
+ // multi-scope artifact's `providerRefs` is the union across all
157
+ // hosts (`buildMultiScopeArtifactMetadata`); preserving that union
158
+ // on a single-scope projection makes the per-host artifact internally
159
+ // inconsistent — `scope.providers` would describe one host while
160
+ // `providerRefs` would describe siblings too. The boot-time
161
+ // `assertProviderRuntimeEnvInSync` guard treats `providerRefs.length > 0`
162
+ // as "this host has providers to reconcile" — without this
163
+ // recomputation, an empty-scope host would inherit the union and
164
+ // trip the env-missing guard even though its `.wildo-providers.env`
165
+ // was deliberately not written. Recomputation also tightens
166
+ // `BackendProviderRegistry`'s filter (today defended by an empty-list
167
+ // fallback) so the per-host artifact accurately advertises only the
168
+ // refs it should resolve.
169
+ const projectedProviderRefs = Object.keys(scope.providers).sort();
170
+ return SaasRuntimeProvidersArtifactSchema.parse({
171
+ ...artifact,
172
+ providerRefs: projectedProviderRefs,
173
+ frontendProviderBootstraps: artifact.frontendProviderBootstraps?.[scopeKey]
174
+ ? { [scopeKey]: artifact.frontendProviderBootstraps[scopeKey] }
175
+ : undefined,
176
+ scope,
177
+ scopes: undefined,
178
+ });
179
+ }
180
+ /**
181
+ * Resolve the absolute path to the canonical
182
+ * `frontend-services.runtime-providers.generated.json` artifact under
183
+ * `<saasRoot>/.wildo-saas/generated/providers/`.
184
+ *
185
+ * Build-time consumers (Wonder Todos website + tech-doc) call this
186
+ * instead of hardcoding the relative path so the artifact location
187
+ * stays canonical (single source of truth is
188
+ * `PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS`).
189
+ */
190
+ export function resolveFrontendServicesArtifactPath(saasRoot) {
191
+ return resolvePath(saasRoot, PROVIDER_RUNTIME_ARTIFACT_RELATIVE_PATHS.frontendServices);
192
+ }
193
+ /**
194
+ * Read + project the materialized frontend-services artifact for the
195
+ * given service key. Returns `undefined` if the artifact file is
196
+ * missing (sync hasn't run yet / clean checkout) or if the service
197
+ * has no provider bootstrap entry.
198
+ *
199
+ * The single source of truth for build-time loading of the frontend
200
+ * provider bootstraps. Replaces the (previously duplicated)
201
+ * `loadMaterializedFrontendProviders` helpers that lived in
202
+ * `saas-technical-doc/src/build/load-materialized-frontend-providers.ts`
203
+ * and inline in `examples/wonder-todos/website/src/website-site-context.ts`.
204
+ *
205
+ * Both consumers used identical control flow:
206
+ * 1. existsSync() short-circuit
207
+ * 2. JSON.parse + SaasRuntimeProvidersArtifactSchema.parse
208
+ * 3. frontendProviderBootstraps[serviceKey] lookup
209
+ * 4. FrontendProvidersBlockSchema.parse on the per-service block
210
+ * Centralized 2026-05-06 so a future schema/path change only
211
+ * requires editing this function.
212
+ */
213
+ export function loadMaterializedFrontendProviders(input) {
214
+ const { artifactPath, serviceKey } = input;
215
+ if (!existsSync(artifactPath)) {
216
+ return undefined;
217
+ }
218
+ const artifact = SaasRuntimeProvidersArtifactSchema.parse(JSON.parse(readFileSync(artifactPath, 'utf8')));
219
+ const providerBlock = artifact.frontendProviderBootstraps?.[serviceKey];
220
+ return providerBlock === undefined
221
+ ? undefined
222
+ : FrontendProvidersBlockSchema.parse(providerBlock);
223
+ }
224
+ export function renderProviderRuntimeGeneratedModule(artifact) {
225
+ const artifactLiteral = JSON.stringify(artifact, null, 2);
226
+ return [
227
+ '/**',
228
+ ` * ${PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING}`,
229
+ ' *',
230
+ ' * This module is generated from wildo.saas.config.ts by `wildo config sync`.',
231
+ ' * It contains environment-independent provider topology only.',
232
+ ' */',
233
+ '',
234
+ // Intentionally NOT `as const` — the generated artifact is *data*, not a
235
+ // frozen literal-typed tuple. Each host (backend / companion / minion /
236
+ // worker) casts the imported value to its own narrowed runtime-artifact
237
+ // type (`ProviderRuntimeArtifact`, `MinionProviderRuntimeArtifact`, …).
238
+ // `as const` would infer `readonly` tuples (e.g. `readonly ["openai"]`)
239
+ // that fail TS2352 against the schema-inferred mutable `string[]` shape.
240
+ // Contract conformance is enforced upstream by
241
+ // `SaasRuntimeProvidersArtifactSchema.parse(...)` at materialization time,
242
+ // so widening the TS surface here costs no runtime safety.
243
+ `export const WILDO_PROVIDER_RUNTIME = ${artifactLiteral};`,
244
+ '',
245
+ 'export default WILDO_PROVIDER_RUNTIME;',
246
+ '',
247
+ ].join('\n');
248
+ }
249
+ /**
250
+ * Canonical worker provider env-var keys. All workers receive the same
251
+ * three keys regardless of language; the values are stable across runs
252
+ * as long as the authored scope and discovered contributions don't
253
+ * change.
254
+ *
255
+ * - `WILDO_PROVIDER_REFS` — comma-separated list of authored refs (sorted).
256
+ * Cheap to read from any language (no JSON parser needed).
257
+ * - `WILDO_PROVIDER_TOPOLOGY_JSON` — the per-worker `scope` block from
258
+ * the materialized artifact, JSON-encoded. Workers that want
259
+ * structured access (capability/protocol set) parse this; workers
260
+ * that only need ref membership read `WILDO_PROVIDER_REFS`.
261
+ * - `WILDO_PROVIDER_RUNTIME_DIGEST` — the artifact's `sourceDigest`.
262
+ * Workers can fail-closed at boot if their copy of the env-file
263
+ * disagrees with the lockfile section digest the platform expects.
264
+ */
265
+ export const PROVIDER_RUNTIME_ENV_KEYS = {
266
+ REFS: 'WILDO_PROVIDER_REFS',
267
+ TOPOLOGY_JSON: 'WILDO_PROVIDER_TOPOLOGY_JSON',
268
+ RUNTIME_DIGEST: 'WILDO_PROVIDER_RUNTIME_DIGEST',
269
+ };
270
+ /**
271
+ * Render the per-worker provider env-file body. Inputs:
272
+ * - `scope` — the per-worker scope block from
273
+ * `WildoSaasConfig.providers.scopes.workers[<workerKey>]`. Carries
274
+ * the authored providers + capability/protocol declarations that
275
+ * this worker needs to resolve at runtime.
276
+ * - `sourceDigest` — `SaasRuntimeProvidersArtifact.sourceDigest`
277
+ * (from the lockfile or the corresponding generated artifact).
278
+ *
279
+ * Output: a deterministic dotenv body — sorted refs, stable JSON
280
+ * key ordering — so re-running `wildo config sync` with no upstream
281
+ * changes produces a byte-identical file.
282
+ */
283
+ export function renderProviderRuntimeEnvFile(input) {
284
+ const refs = Object.keys(input.scope.providers).sort();
285
+ const topology = {};
286
+ for (const ref of refs) {
287
+ const selection = input.scope.providers[ref];
288
+ topology[ref] = {
289
+ engineCapabilities: [...selection.engineCapabilities].sort(),
290
+ providerCapabilities: [...selection.providerCapabilities].sort(),
291
+ protocols: [...selection.protocols].sort(),
292
+ };
293
+ }
294
+ return [
295
+ `# ${PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING}`,
296
+ '#',
297
+ '# This file is regenerated on every `wildo config sync`. Do not edit by hand.',
298
+ '# Operator-authored secrets / per-env config stay in `.env` and are never touched here.',
299
+ '',
300
+ `${PROVIDER_RUNTIME_ENV_KEYS.REFS}=${refs.join(',')}`,
301
+ `${PROVIDER_RUNTIME_ENV_KEYS.TOPOLOGY_JSON}=${JSON.stringify(topology)}`,
302
+ `${PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST}=${input.sourceDigest}`,
303
+ '',
304
+ ].join('\n');
305
+ }
306
+ /**
307
+ * Reconcile a runtime artifact's typed projection against the
308
+ * `.wildo-providers.env` mounted into the same process. Pure function
309
+ * so callers can decide how to surface the result (throw / log / ignore).
310
+ *
311
+ * The env file is materialized by `renderProviderRuntimeEnvFile` for
312
+ * EVERY runtime host that is a minion or worker; the typed module is
313
+ * imported by the same hosts. Both should agree on
314
+ * `(providerRefs, sourceDigest)` exactly. Drift means stale sync.
315
+ *
316
+ * Hosts that don't receive an env file (backend, companion, frontend
317
+ * services per `provider-runtime-sync.service.ts`) MUST NOT call this —
318
+ * `WILDO_PROVIDER_*` keys won't be set and every call returns
319
+ * `env-missing`.
320
+ */
321
+ export function reconcileProviderRuntimeEnv(input) {
322
+ const env = input.env ?? process.env;
323
+ const envRefsRaw = env[PROVIDER_RUNTIME_ENV_KEYS.REFS];
324
+ const envDigest = env[PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST];
325
+ const missingKeys = [];
326
+ if (envRefsRaw === undefined)
327
+ missingKeys.push(PROVIDER_RUNTIME_ENV_KEYS.REFS);
328
+ if (envDigest === undefined)
329
+ missingKeys.push(PROVIDER_RUNTIME_ENV_KEYS.RUNTIME_DIGEST);
330
+ if (missingKeys.length > 0) {
331
+ return { kind: 'env-missing', missingKeys };
332
+ }
333
+ // Filter empty entries so trailing-comma input (e.g. `'openai,'`) or
334
+ // operator-edited stray whitespace don't produce confusing `''`
335
+ // entries in mismatch diagnostics. Materializer never emits trailing
336
+ // commas, but defense-in-depth keeps the helper robust to anything
337
+ // that lands the env file via dotenv loaders or hand-edits.
338
+ const envRefs = envRefsRaw
339
+ .split(',')
340
+ .map((s) => s.trim())
341
+ .filter((s) => s.length > 0)
342
+ .sort();
343
+ const artifactRefs = [...input.artifactProviderRefs].sort();
344
+ if (envRefs.length !== artifactRefs.length || envRefs.some((ref, i) => ref !== artifactRefs[i])) {
345
+ return { kind: 'refs-mismatch', envRefs, artifactRefs };
346
+ }
347
+ if (envDigest !== input.artifactSourceDigest) {
348
+ return {
349
+ kind: 'digest-mismatch',
350
+ envDigest: envDigest,
351
+ artifactDigest: input.artifactSourceDigest,
352
+ };
353
+ }
354
+ return { kind: 'in-sync' };
355
+ }
356
+ /**
357
+ * Fail-closed wrapper around `reconcileProviderRuntimeEnv`. Throws on
358
+ * any divergence, returns silently when in sync. Designed to be called
359
+ * once at runtime-host boot (minion / Node-worker startup) so a stale
360
+ * `.wildo-providers.env` surfaces immediately instead of being masked
361
+ * by `process.env` drift.
362
+ *
363
+ * Throws a plain `Error` (not `WildoError_Backend`) because this runs
364
+ * BEFORE the DI container has built the error builder — the failure
365
+ * mode here is "the container can't be trusted to boot at all".
366
+ */
367
+ export function assertProviderRuntimeEnvInSync(input) {
368
+ const result = reconcileProviderRuntimeEnv(input);
369
+ switch (result.kind) {
370
+ case 'in-sync':
371
+ return;
372
+ case 'env-missing':
373
+ throw new Error(`[provider-runtime-env] ${input.hostKind} '${input.hostKey}' booted without `
374
+ + `provider env vars (${result.missingKeys.join(', ')}). The `
375
+ + `\`.wildo-providers.env\` file should be mounted into this process — check `
376
+ + `the docker-compose \`env_file:\` directive, the K8s ConfigMap mount, or the `
377
+ + `dotenv loader. Re-run \`wildo config sync\` to regenerate if missing.`);
378
+ case 'refs-mismatch':
379
+ throw new Error(`[provider-runtime-env] ${input.hostKind} '${input.hostKey}' detected stale provider topology. `
380
+ + `\`.wildo-providers.env\` advertises refs [${result.envRefs.join(', ')}] but the `
381
+ + `imported \`wildo-provider-runtime.generated.ts\` module declares `
382
+ + `[${result.artifactRefs.join(', ')}]. Run \`wildo config sync\` to regenerate `
383
+ + `both surfaces from the same \`wildo.saas.config.ts\` source.`);
384
+ case 'digest-mismatch':
385
+ throw new Error(`[provider-runtime-env] ${input.hostKind} '${input.hostKey}' detected provider runtime digest drift. `
386
+ + `\`.wildo-providers.env\` carries digest '${result.envDigest}' but the imported `
387
+ + `\`wildo-provider-runtime.generated.ts\` module carries '${result.artifactDigest}'. `
388
+ + `Refs match, but per-provider capabilities/protocols may differ. `
389
+ + `Run \`wildo config sync\` to regenerate.`);
390
+ }
391
+ }
392
+ function materializeRuntimeArtifacts(input) {
393
+ const { artifactMetadata, discoveryContext, frontendServiceTypes, generatedAt, modules, nodeWorkerKeys, scopes } = input;
394
+ const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
395
+ const nodeWorkerScopes = scopes.workers
396
+ ? Object.fromEntries(Object.entries(scopes.workers).filter(([workerKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(workerKey) : true))
397
+ : undefined;
398
+ return pruneUndefined({
399
+ backend: materializeRuntimeArtifactFile({
400
+ artifactKind: 'backend',
401
+ generatedAt,
402
+ modules,
403
+ metadata: artifactMetadata.backend,
404
+ frontendProviderBootstraps: materializeFrontendProviderBootstraps({
405
+ discoveredContributions: discoveryContext.contributions,
406
+ frontendServiceScopes: scopes.frontendServices ?? {},
407
+ frontendServiceTypes,
408
+ }),
409
+ scope: materializeRuntimeScope(scopes.backend ?? { providers: {}, selection: {} }),
410
+ }),
411
+ companion: materializeRuntimeArtifactFile({
412
+ artifactKind: 'companion',
413
+ generatedAt,
414
+ modules,
415
+ metadata: artifactMetadata.companion,
416
+ scope: materializeRuntimeScope(scopes.companion ?? { providers: {}, selection: {} }),
417
+ }),
418
+ frontendServices: scopes.frontendServices
419
+ ? materializeRuntimeArtifactFile({
420
+ artifactKind: 'frontendServices',
421
+ generatedAt,
422
+ modules,
423
+ metadata: artifactMetadata.frontendServices,
424
+ frontendProviderBootstraps: materializeFrontendProviderBootstraps({
425
+ discoveredContributions: discoveryContext.contributions,
426
+ frontendServiceScopes: scopes.frontendServices,
427
+ frontendServiceTypes,
428
+ }),
429
+ scopes: mapRecord(scopes.frontendServices, materializeRuntimeScope),
430
+ })
431
+ : undefined,
432
+ minions: scopes.minions
433
+ ? materializeRuntimeArtifactFile({
434
+ artifactKind: 'minions',
435
+ generatedAt,
436
+ modules,
437
+ metadata: artifactMetadata.minions,
438
+ scopes: mapRecord(scopes.minions, materializeRuntimeScope),
439
+ })
440
+ : undefined,
441
+ nodeWorkers: nodeWorkerScopes && Object.keys(nodeWorkerScopes).length > 0
442
+ ? materializeRuntimeArtifactFile({
443
+ artifactKind: 'nodeWorkers',
444
+ generatedAt,
445
+ modules,
446
+ metadata: artifactMetadata.nodeWorkers,
447
+ scopes: mapRecord(nodeWorkerScopes, materializeRuntimeScope),
448
+ })
449
+ : undefined,
450
+ });
451
+ }
452
+ function materializeRuntimeArtifactFile(input) {
453
+ return SaasRuntimeProvidersArtifactSchema.parse({
454
+ __AUTOGENERATED__: PROVIDER_RUNTIME_ARTIFACT_AUTOGENERATED_WARNING,
455
+ generatedBy: PROVIDER_RUNTIME_ARTIFACT_GENERATOR,
456
+ generatedAt: input.generatedAt,
457
+ sourceDigest: input.metadata.sourceDigest,
458
+ providerRefs: input.metadata.providerRefs,
459
+ providerGraphDigest: input.metadata.providerGraphDigest,
460
+ lockfileSectionDigest: input.metadata.lockfileSectionDigest,
461
+ artifactKind: input.artifactKind,
462
+ modules: input.modules,
463
+ scope: input.scope,
464
+ scopes: input.scopes,
465
+ frontendProviderBootstraps: input.frontendProviderBootstraps,
466
+ });
467
+ }
468
+ function materializeRuntimeScope(scope) {
469
+ return RuntimeProviderScopeArtifactSchema.parse({
470
+ providers: scope.providers,
471
+ selection: scope.selection ?? {},
472
+ });
473
+ }
474
+ function materializeFrontendProviderBootstraps(input) {
475
+ const { discoveredContributions, frontendServiceScopes, frontendServiceTypes } = input;
476
+ const entries = Object.entries(frontendServiceScopes).map(([serviceKey, scope]) => {
477
+ const serviceType = frontendServiceTypes[serviceKey];
478
+ if (!serviceType) {
479
+ throw new Error(`Cannot materialize frontend bootstrap for service "${serviceKey}": ` +
480
+ `service has no frontendType — only services with a frontendType may appear under providers.scopes.frontendServices.`);
481
+ }
482
+ const providers = Object.fromEntries(Object.keys(scope.providers).map((providerRef) => {
483
+ const matchingContribution = discoveredContributions.filter((contribution) => contribution.ref === providerRef
484
+ && contribution.runtimeTargets.some((target) => target.kind === 'frontendService' && target.serviceType === serviceType));
485
+ if (matchingContribution.length === 0) {
486
+ throw new Error(`Cannot materialize frontend bootstrap for service "${serviceKey}" (type "${serviceType}"): ` +
487
+ `provider "${providerRef}" has no discovered frontend companion contribution.`);
488
+ }
489
+ if (matchingContribution.some((contribution) => !contribution.frontendEntry)) {
490
+ throw new Error(`Cannot materialize frontend bootstrap for service "${serviceKey}": ` +
491
+ `provider "${providerRef}" is missing frontendEntry on at least one discovered contribution.`);
492
+ }
493
+ if (matchingContribution.length > 1) {
494
+ throw new Error(`Cannot materialize frontend bootstrap for service "${serviceKey}": ` +
495
+ `provider "${providerRef}" is contributed more than once for the same runtime.`);
496
+ }
497
+ return [
498
+ providerRef,
499
+ matchingContribution[0].frontendEntry,
500
+ ];
501
+ }));
502
+ return [serviceKey, FrontendProvidersBlockSchema.parse({ providers })];
503
+ });
504
+ return entries.length > 0 ? Object.fromEntries(entries) : undefined;
505
+ }
506
+ function buildFrontendProviderBootstrapDigestInput(input) {
507
+ const bootstraps = materializeFrontendProviderBootstraps(input);
508
+ if (!bootstraps) {
509
+ return undefined;
510
+ }
511
+ return Object.fromEntries(Object.entries(bootstraps).map(([serviceKey, block]) => [
512
+ serviceKey,
513
+ Object.fromEntries(Object.entries(block.providers).map(([providerRef, providerEntry]) => [
514
+ providerRef,
515
+ {
516
+ metadata: providerEntry.metadata,
517
+ providerCapabilities: [...providerEntry.providerCapabilities].sort(),
518
+ protocols: [...providerEntry.protocols].sort(),
519
+ publicConfig: providerEntry.publicConfig,
520
+ },
521
+ ])),
522
+ ]));
523
+ }
524
+ function materializeModules(config) {
525
+ const modules = (config.modules ?? {});
526
+ return RuntimeProviderModulesArtifactSchema.parse({
527
+ declaredModules: modules,
528
+ moduleIds: getDeclaredApplicationModuleIds(modules),
529
+ moduleIdsByService: Object.fromEntries(Object.keys(config.services ?? {}).map((serviceKey) => [
530
+ serviceKey,
531
+ getServiceBoundApplicationModuleIds(modules, serviceKey),
532
+ ])),
533
+ });
534
+ }
535
+ function materializeLockRuntimeScopes(input) {
536
+ const { scopes, discoveryContext } = input;
537
+ return pruneUndefined({
538
+ backend: scopes.backend
539
+ ? materializeLockScope(scopes.backend.providers, discoveryContext.contributions, discoveryContext.backend.matchesRuntimeTarget)
540
+ : undefined,
541
+ companion: scopes.companion
542
+ ? materializeLockScope(scopes.companion.providers, discoveryContext.contributions, discoveryContext.companion.matchesRuntimeTarget)
543
+ : undefined,
544
+ frontendServices: scopes.frontendServices
545
+ ? mapRecord(scopes.frontendServices, (scope, serviceKey) => materializeLockScope(scope.providers, discoveryContext.contributions, discoveryContext.frontendServices.matchesRuntimeTarget(serviceKey)))
546
+ : undefined,
547
+ minions: scopes.minions
548
+ ? mapRecord(scopes.minions, (scope, minionKey) => materializeLockScope(scope.providers, discoveryContext.contributions, discoveryContext.minions.matchesRuntimeTarget(minionKey)))
549
+ : undefined,
550
+ workers: scopes.workers
551
+ ? mapRecord(scopes.workers, (scope, workerKey) => materializeLockScope(scope.providers, discoveryContext.contributions, discoveryContext.workers.matchesRuntimeTarget(workerKey)))
552
+ : undefined,
553
+ });
554
+ }
555
+ function materializeLockScope(providers, discoveredContributions, matchesRuntimeTarget) {
556
+ return mapRecord(providers, (selection, ref) => {
557
+ const matchingContributions = findMatchingDiscoveredContributions({
558
+ discoveredContributions,
559
+ matchesRuntimeTarget,
560
+ providerRef: ref,
561
+ });
562
+ const secretsContractShape = resolveProviderSecretsContractShape(ref, matchingContributions);
563
+ return {
564
+ ref,
565
+ digest: digestJson({
566
+ selection,
567
+ providerGraph: normalizeDiscoveredContributionsForDigest(matchingContributions),
568
+ }),
569
+ engineCapabilities: selection.engineCapabilities,
570
+ providerCapabilities: selection.providerCapabilities,
571
+ protocols: selection.protocols,
572
+ // assurance-control: WILDO.SECRETS.CONTRACT_INTEGRITY — lock drift
573
+ // covers the values-free provider contract without persisting secret values.
574
+ secretsContractDigest: digestJson({ ref, secretsContractShape }),
575
+ };
576
+ });
577
+ }
578
+ /**
579
+ * Resolves one authoritative values-free secret contract for a provider in a
580
+ * concrete runtime scope.
581
+ *
582
+ * Multiple runtime owners may legitimately contribute the same provider, but
583
+ * they must agree on its secret requirements. Missing discovery and divergent
584
+ * shapes fail closed: hashing either state as an empty contract would make the
585
+ * lockfile claim integrity evidence it does not possess.
586
+ */
587
+ function resolveProviderSecretsContractShape(providerRef, matchingContributions) {
588
+ if (matchingContributions.length === 0) {
589
+ throw new Error(`Cannot materialize provider lock entry for "${providerRef}": no discovered contribution supplies its secret-contract shape for this runtime.`);
590
+ }
591
+ const canonicalShape = matchingContributions[0].secretsContractShape;
592
+ const canonicalDigestInput = stableStringify(canonicalShape);
593
+ for (const contribution of matchingContributions.slice(1)) {
594
+ if (stableStringify(contribution.secretsContractShape) !== canonicalDigestInput) {
595
+ throw new Error(`Cannot materialize provider lock entry for "${providerRef}": discovered runtime owners disagree on its secret-contract shape.`);
596
+ }
597
+ }
598
+ return canonicalShape;
599
+ }
600
+ function digestJson(value) {
601
+ return `sha256:${createHash('sha256').update(stableStringify(value)).digest('hex')}`;
602
+ }
603
+ function stableStringify(value) {
604
+ if (Array.isArray(value)) {
605
+ return `[${value.map(stableStringify).join(',')}]`;
606
+ }
607
+ if (value && typeof value === 'object') {
608
+ const record = value;
609
+ return `{${Object.keys(record)
610
+ .sort()
611
+ .map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`)
612
+ .join(',')}}`;
613
+ }
614
+ return JSON.stringify(value);
615
+ }
616
+ function mapRecord(record, mapper) {
617
+ return Object.fromEntries(Object.entries(record).map(([key, value]) => [key, mapper(value, key)]));
618
+ }
619
+ function pruneUndefined(record) {
620
+ return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
621
+ }
622
+ function buildProviderRuntimeDiscoveryContext(input) {
623
+ const contributions = input.discoveredContributions ?? [];
624
+ const { frontendServiceTypes } = input;
625
+ return {
626
+ contributions,
627
+ backend: {
628
+ matchesRuntimeTarget: (target) => target.kind === 'backend',
629
+ },
630
+ companion: {
631
+ matchesRuntimeTarget: (target) => target.kind === 'companion',
632
+ },
633
+ frontendServices: {
634
+ matchesRuntimeTarget: (serviceKey) => {
635
+ const serviceType = frontendServiceTypes[serviceKey];
636
+ // Service has no frontendType ⇒ no contribution can match it.
637
+ if (!serviceType)
638
+ return () => false;
639
+ return (target) => target.kind === 'frontendService' && target.serviceType === serviceType;
640
+ },
641
+ },
642
+ minions: {
643
+ matchesRuntimeTarget: (minionKey) => (target) => target.kind === 'minion' && target.minionKey === minionKey,
644
+ },
645
+ workers: {
646
+ matchesRuntimeTarget: (workerKey) => (target) => target.kind === 'worker' && target.workerKey === workerKey,
647
+ },
648
+ };
649
+ }
650
+ function buildArtifactMetadata(input) {
651
+ const { discoveryContext, frontendServiceTypes, lockSection, modules, nodeWorkerKeys, scopes } = input;
652
+ const nodeWorkerKeySet = nodeWorkerKeys ? new Set(nodeWorkerKeys) : undefined;
653
+ return {
654
+ backend: buildSingleScopeArtifactMetadata({
655
+ modules,
656
+ providers: scopes.backend?.providers ?? {},
657
+ matchingContributions: findMatchingDiscoveredContributions({
658
+ discoveredContributions: discoveryContext.contributions,
659
+ matchesRuntimeTarget: discoveryContext.backend.matchesRuntimeTarget,
660
+ }),
661
+ extraArtifactState: buildFrontendProviderBootstrapDigestInput({
662
+ discoveredContributions: discoveryContext.contributions,
663
+ frontendServiceScopes: scopes.frontendServices ?? {},
664
+ frontendServiceTypes,
665
+ }),
666
+ runtimeLockSection: lockSection.runtimeScopes.backend ?? {},
667
+ scopes,
668
+ }),
669
+ companion: buildSingleScopeArtifactMetadata({
670
+ modules,
671
+ providers: scopes.companion?.providers ?? {},
672
+ matchingContributions: findMatchingDiscoveredContributions({
673
+ discoveredContributions: discoveryContext.contributions,
674
+ matchesRuntimeTarget: discoveryContext.companion.matchesRuntimeTarget,
675
+ }),
676
+ runtimeLockSection: lockSection.runtimeScopes.companion ?? {},
677
+ scopes,
678
+ }),
679
+ frontendServices: buildMultiScopeArtifactMetadata({
680
+ keyedProviders: Object.fromEntries(Object.entries(scopes.frontendServices ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers])),
681
+ matchingContributionsByScope: Object.fromEntries(Object.keys(scopes.frontendServices ?? {}).map((scopeKey) => [
682
+ scopeKey,
683
+ findMatchingDiscoveredContributions({
684
+ discoveredContributions: discoveryContext.contributions,
685
+ matchesRuntimeTarget: discoveryContext.frontendServices.matchesRuntimeTarget(scopeKey),
686
+ }),
687
+ ])),
688
+ modules,
689
+ extraArtifactState: buildFrontendProviderBootstrapDigestInput({
690
+ discoveredContributions: discoveryContext.contributions,
691
+ frontendServiceScopes: scopes.frontendServices ?? {},
692
+ frontendServiceTypes,
693
+ }),
694
+ runtimeLockSection: lockSection.runtimeScopes.frontendServices ?? {},
695
+ scopes,
696
+ }),
697
+ minions: buildMultiScopeArtifactMetadata({
698
+ keyedProviders: Object.fromEntries(Object.entries(scopes.minions ?? {}).map(([scopeKey, scope]) => [scopeKey, scope.providers])),
699
+ matchingContributionsByScope: Object.fromEntries(Object.keys(scopes.minions ?? {}).map((scopeKey) => [
700
+ scopeKey,
701
+ findMatchingDiscoveredContributions({
702
+ discoveredContributions: discoveryContext.contributions,
703
+ matchesRuntimeTarget: discoveryContext.minions.matchesRuntimeTarget(scopeKey),
704
+ }),
705
+ ])),
706
+ modules,
707
+ runtimeLockSection: lockSection.runtimeScopes.minions ?? {},
708
+ scopes,
709
+ }),
710
+ nodeWorkers: buildMultiScopeArtifactMetadata({
711
+ keyedProviders: Object.fromEntries(Object.entries(scopes.workers ?? {})
712
+ .filter(([scopeKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)
713
+ .map(([scopeKey, scope]) => [scopeKey, scope.providers])),
714
+ matchingContributionsByScope: Object.fromEntries(Object.keys(scopes.workers ?? {})
715
+ .filter((scopeKey) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)
716
+ .map((scopeKey) => [
717
+ scopeKey,
718
+ findMatchingDiscoveredContributions({
719
+ discoveredContributions: discoveryContext.contributions,
720
+ matchesRuntimeTarget: discoveryContext.workers.matchesRuntimeTarget(scopeKey),
721
+ }),
722
+ ])),
723
+ modules,
724
+ runtimeLockSection: Object.fromEntries(Object.entries(lockSection.runtimeScopes.workers ?? {})
725
+ .filter(([scopeKey]) => nodeWorkerKeySet ? nodeWorkerKeySet.has(scopeKey) : true)),
726
+ scopes,
727
+ }),
728
+ };
729
+ }
730
+ function buildSingleScopeArtifactMetadata(input) {
731
+ const providerRefs = Object.keys(input.providers).sort();
732
+ const normalizedContributions = normalizeDiscoveredContributionsForDigest(input.matchingContributions);
733
+ const providerGraphDigestInput = input.extraArtifactState
734
+ ? {
735
+ providerGraph: normalizedContributions,
736
+ extraArtifactState: input.extraArtifactState,
737
+ }
738
+ : normalizedContributions;
739
+ return {
740
+ sourceDigest: digestJson({
741
+ modules: input.modules,
742
+ providers: input.providers,
743
+ providerGraph: normalizedContributions,
744
+ scopes: input.scopes,
745
+ extraArtifactState: input.extraArtifactState,
746
+ }),
747
+ providerRefs,
748
+ providerGraphDigest: digestJson(providerGraphDigestInput),
749
+ lockfileSectionDigest: digestJson(input.runtimeLockSection),
750
+ };
751
+ }
752
+ function buildMultiScopeArtifactMetadata(input) {
753
+ const providerRefs = [...new Set(Object.values(input.keyedProviders).flatMap((providers) => Object.keys(providers)))].sort();
754
+ const normalizedContributionsByScope = Object.fromEntries(Object.entries(input.matchingContributionsByScope).map(([scopeKey, contributions]) => [
755
+ scopeKey,
756
+ normalizeDiscoveredContributionsForDigest(contributions),
757
+ ]));
758
+ const providerGraphDigestInput = input.extraArtifactState
759
+ ? {
760
+ providerGraphByScope: normalizedContributionsByScope,
761
+ extraArtifactState: input.extraArtifactState,
762
+ }
763
+ : normalizedContributionsByScope;
764
+ return {
765
+ sourceDigest: digestJson({
766
+ keyedProviders: input.keyedProviders,
767
+ modules: input.modules,
768
+ providerGraphByScope: normalizedContributionsByScope,
769
+ scopes: input.scopes,
770
+ extraArtifactState: input.extraArtifactState,
771
+ }),
772
+ providerRefs,
773
+ providerGraphDigest: digestJson(providerGraphDigestInput),
774
+ lockfileSectionDigest: digestJson(input.runtimeLockSection),
775
+ };
776
+ }
777
+ function findMatchingDiscoveredContributions(input) {
778
+ return input.discoveredContributions.flatMap((contribution) => {
779
+ if (input.providerRef && contribution.ref !== input.providerRef) {
780
+ return [];
781
+ }
782
+ const runtimeTargets = contribution.runtimeTargets.filter(input.matchesRuntimeTarget);
783
+ if (runtimeTargets.length === 0) {
784
+ return [];
785
+ }
786
+ return [{ ...contribution, runtimeTargets }];
787
+ });
788
+ }
789
+ /**
790
+ * The portion of a contribution's `owner` that may enter a digest.
791
+ *
792
+ * **`packageRoot` is deliberately excluded, and this is the whole point of the
793
+ * function.** Discovery builds it as `resolve(saasRoot, definition.path)` — an
794
+ * ABSOLUTE filesystem path — so hashing it makes every value derived from this
795
+ * normalizer a property of WHERE THE REPOSITORY HAPPENS TO BE CHECKED OUT
796
+ * rather than of the provider graph.
797
+ *
798
+ * That is not a theoretical concern; it was measured on 2026-08-30. The same
799
+ * Wonder Todos tree, materialized from its real directory and from a symlink to
800
+ * it, produced two different lock digests for every provider in every scope
801
+ * (`sha256:f7eeb2d6…` vs `sha256:d933b95a…` for backend `anthropic`), and a dump
802
+ * of the two contribution sets differed in `owner.packageRoot` and nothing else.
803
+ * The consequences were both real:
804
+ *
805
+ * - `examples/wonder-todos/.wildo-saas/wildo-saas.lock.json` carried 22 digests
806
+ * scoped to whichever checkout last ran `wildo config sync`, so the
807
+ * `Lockfile Drift Check` gate — which runs at `/home/runner/work/…` — could
808
+ * never have agreed with a committed value regardless of actual drift.
809
+ * - The same input feeds `sourceDigest` / `providerGraphDigest` in the generated
810
+ * runtime artifacts and `.wildo-providers.env`, so artifacts generated on a
811
+ * developer's machine and re-materialized under a container's `/app` would
812
+ * trip the `digest-mismatch` runtime diagnostic while describing an identical
813
+ * provider graph.
814
+ *
815
+ * `kind` + `key` already identify an owner uniquely (both are record keys within
816
+ * their config block), so nothing distinguishing is lost. What IS given up is
817
+ * that relocating an owner package without changing its contribution content no
818
+ * longer moves the digest — accepted deliberately: a repository-layout change is
819
+ * not a provider-contract change, and if that signal is ever wanted it must
820
+ * arrive as a saas-root-RELATIVE path, never an absolute one.
821
+ */
822
+ function projectOwnerForDigest(owner) {
823
+ return { kind: owner.kind, key: owner.key };
824
+ }
825
+ function normalizeDiscoveredContributionsForDigest(contributions) {
826
+ return [...contributions]
827
+ .sort((left, right) => stableStringify({
828
+ leftOwner: projectOwnerForDigest(left.owner),
829
+ leftRef: left.ref,
830
+ leftRuntimeImportPath: left.runtimeImportPath,
831
+ leftSourceModuleId: left.sourceModuleId,
832
+ leftTargets: left.runtimeTargets,
833
+ }).localeCompare(stableStringify({
834
+ rightOwner: projectOwnerForDigest(right.owner),
835
+ rightRef: right.ref,
836
+ rightRuntimeImportPath: right.runtimeImportPath,
837
+ rightSourceModuleId: right.sourceModuleId,
838
+ rightTargets: right.runtimeTargets,
839
+ })))
840
+ .map((contribution) => ({
841
+ ref: contribution.ref,
842
+ owner: projectOwnerForDigest(contribution.owner),
843
+ runtimeImportPath: contribution.runtimeImportPath,
844
+ runtimeTargets: contribution.runtimeTargets,
845
+ engineCapabilities: [...contribution.engineCapabilities].sort(),
846
+ providerCapabilities: [...contribution.providerCapabilities].sort(),
847
+ protocols: [...contribution.protocols].sort(),
848
+ secretsContractShape: contribution.secretsContractShape,
849
+ frontendEntry: contribution.frontendEntry
850
+ ? {
851
+ metadata: contribution.frontendEntry.metadata,
852
+ providerCapabilities: [...contribution.frontendEntry.providerCapabilities].sort(),
853
+ protocols: [...contribution.frontendEntry.protocols].sort(),
854
+ publicConfig: contribution.frontendEntry.publicConfig,
855
+ }
856
+ : undefined,
857
+ sourceModuleId: contribution.sourceModuleId,
858
+ }));
859
+ }
860
+ //# sourceMappingURL=provider-runtime-artifacts.js.map