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

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 (230) hide show
  1. package/dist/esm/bootstrap/application-backend-env.contracts.d.ts.map +1 -1
  2. package/dist/esm/bootstrap/bootstrap-planner.d.ts.map +1 -1
  3. package/dist/esm/bootstrap/bootstrap.contracts.d.ts +24 -1
  4. package/dist/esm/bootstrap/bootstrap.contracts.d.ts.map +1 -1
  5. package/dist/esm/bootstrap/bootstrap.contracts.js +25 -0
  6. package/dist/esm/bootstrap/bootstrap.contracts.js.map +1 -1
  7. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +117 -1
  8. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  9. package/dist/esm/bootstrap/bootstrap.schemas.js +63 -4
  10. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  11. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +24 -1
  12. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  13. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +24 -0
  14. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  15. package/dist/esm/bootstrap/platform-store-preconnect.d.ts +37 -0
  16. package/dist/esm/bootstrap/platform-store-preconnect.d.ts.map +1 -0
  17. package/dist/esm/bootstrap/platform-store-preconnect.js +43 -0
  18. package/dist/esm/bootstrap/platform-store-preconnect.js.map +1 -0
  19. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
  20. package/dist/esm/bootstrap/runtime-backing-service-access.js +8 -4
  21. package/dist/esm/bootstrap/runtime-backing-service-access.js.map +1 -1
  22. package/dist/esm/bootstrap/runtime-network-policy.d.ts.map +1 -1
  23. package/dist/esm/bootstrap/runtime-network-topology.d.ts.map +1 -1
  24. package/dist/esm/bootstrap/runtime-network-topology.js.map +1 -1
  25. package/dist/esm/bootstrap/runtime-platform-access.d.ts.map +1 -1
  26. package/dist/esm/bootstrap/runtime-principal.contracts.d.ts.map +1 -1
  27. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts +36 -3
  28. package/dist/esm/bootstrap/runtime-topology.contracts.d.ts.map +1 -1
  29. package/dist/esm/bootstrap/runtime-topology.contracts.js +36 -13
  30. package/dist/esm/bootstrap/runtime-topology.contracts.js.map +1 -1
  31. package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts +29 -0
  32. package/dist/esm/bootstrap/wildo-owner-organization.contracts.d.ts.map +1 -1
  33. package/dist/esm/bootstrap/wildo-owner-organization.contracts.js +39 -0
  34. package/dist/esm/bootstrap/wildo-owner-organization.contracts.js.map +1 -1
  35. package/dist/esm/config-authoring.entry.d.ts.map +1 -1
  36. package/dist/esm/config-authoring.entry.js.map +1 -1
  37. package/dist/esm/index.d.ts +2 -0
  38. package/dist/esm/index.d.ts.map +1 -1
  39. package/dist/esm/index.js +2 -0
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/esm/lockfile/build-parallelism.d.ts +40 -0
  42. package/dist/esm/lockfile/build-parallelism.d.ts.map +1 -0
  43. package/dist/esm/lockfile/build-parallelism.js +64 -0
  44. package/dist/esm/lockfile/build-parallelism.js.map +1 -0
  45. package/dist/esm/lockfile/lockfile-io.d.ts +7 -1
  46. package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
  47. package/dist/esm/lockfile/lockfile-io.js +17 -3
  48. package/dist/esm/lockfile/lockfile-io.js.map +1 -1
  49. package/dist/esm/lockfile/materialize-infra-section.d.ts +28 -7
  50. package/dist/esm/lockfile/materialize-infra-section.d.ts.map +1 -1
  51. package/dist/esm/lockfile/materialize-infra-section.js +24 -11
  52. package/dist/esm/lockfile/materialize-infra-section.js.map +1 -1
  53. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts +455 -6
  54. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.d.ts.map +1 -1
  55. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js +27 -0
  56. package/dist/esm/lockfile/wildo-saas-lock.shared.schemas.js.map +1 -1
  57. package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts +13 -0
  58. package/dist/esm/project-config/application-public-pricing-catalog.loader.d.ts.map +1 -0
  59. package/dist/esm/project-config/application-public-pricing-catalog.loader.js +56 -0
  60. package/dist/esm/project-config/application-public-pricing-catalog.loader.js.map +1 -0
  61. package/dist/esm/project-config/define-framework-config.d.ts.map +1 -1
  62. package/dist/esm/project-config/define-infra-env-config.d.ts +886 -29
  63. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
  64. package/dist/esm/project-config/define-infra-env-config.js +395 -16
  65. package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
  66. package/dist/esm/project-config/define-minion-config.d.ts.map +1 -1
  67. package/dist/esm/project-config/define-minion-config.js +1 -2
  68. package/dist/esm/project-config/define-minion-config.js.map +1 -1
  69. package/dist/esm/project-config/define-saas-config.d.ts +142 -25
  70. package/dist/esm/project-config/define-saas-config.d.ts.map +1 -1
  71. package/dist/esm/project-config/define-saas-config.js +229 -26
  72. package/dist/esm/project-config/define-saas-config.js.map +1 -1
  73. package/dist/esm/project-config/define-worker-config.d.ts.map +1 -1
  74. package/dist/esm/project-config/hosted-infra-env-config.d.ts +59 -0
  75. package/dist/esm/project-config/hosted-infra-env-config.d.ts.map +1 -0
  76. package/dist/esm/project-config/hosted-infra-env-config.js +187 -0
  77. package/dist/esm/project-config/hosted-infra-env-config.js.map +1 -0
  78. package/dist/esm/project-config/index.d.ts +6 -0
  79. package/dist/esm/project-config/index.d.ts.map +1 -1
  80. package/dist/esm/project-config/index.js +6 -0
  81. package/dist/esm/project-config/index.js.map +1 -1
  82. package/dist/esm/project-config/loader.d.ts +35 -0
  83. package/dist/esm/project-config/loader.d.ts.map +1 -1
  84. package/dist/esm/project-config/loader.js +148 -8
  85. package/dist/esm/project-config/loader.js.map +1 -1
  86. package/dist/esm/project-config/npm-version-range.d.ts +23 -0
  87. package/dist/esm/project-config/npm-version-range.d.ts.map +1 -0
  88. package/dist/esm/project-config/npm-version-range.js +175 -0
  89. package/dist/esm/project-config/npm-version-range.js.map +1 -0
  90. package/dist/esm/project-config/provider-catalog-types.d.ts.map +1 -1
  91. package/dist/esm/project-config/provider-companion-discovery.d.ts +288 -30
  92. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  93. package/dist/esm/project-config/provider-companion-discovery.js +795 -46
  94. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  95. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +192 -20
  96. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
  97. package/dist/esm/project-config/provider-runtime-artifacts.js +381 -42
  98. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
  99. package/dist/esm/project-config/shared/application-creation-verification.schemas.d.ts.map +1 -1
  100. package/dist/esm/project-config/shared/application-modules.schemas.d.ts.map +1 -1
  101. package/dist/esm/project-config/shared/application-modules.utils.d.ts.map +1 -1
  102. package/dist/esm/project-config/shared/auth.schemas.d.ts +14 -35
  103. package/dist/esm/project-config/shared/auth.schemas.d.ts.map +1 -1
  104. package/dist/esm/project-config/shared/auth.schemas.js +14 -35
  105. package/dist/esm/project-config/shared/auth.schemas.js.map +1 -1
  106. package/dist/esm/project-config/shared/backing-service-servability.d.ts +157 -0
  107. package/dist/esm/project-config/shared/backing-service-servability.d.ts.map +1 -0
  108. package/dist/esm/project-config/shared/backing-service-servability.js +256 -0
  109. package/dist/esm/project-config/shared/backing-service-servability.js.map +1 -0
  110. package/dist/esm/project-config/shared/backing-services.schemas.d.ts +66 -66
  111. package/dist/esm/project-config/shared/backing-services.schemas.d.ts.map +1 -1
  112. package/dist/esm/project-config/shared/backing-services.schemas.js +75 -67
  113. package/dist/esm/project-config/shared/backing-services.schemas.js.map +1 -1
  114. package/dist/esm/project-config/shared/cdn.example.d.ts.map +1 -1
  115. package/dist/esm/project-config/shared/cdn.schemas.d.ts.map +1 -1
  116. package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
  117. package/dist/esm/project-config/shared/csp-emit.d.ts.map +1 -1
  118. package/dist/esm/project-config/shared/csp-emit.js +41 -2
  119. package/dist/esm/project-config/shared/csp-emit.js.map +1 -1
  120. package/dist/esm/project-config/shared/csp.schemas.d.ts +11 -12
  121. package/dist/esm/project-config/shared/csp.schemas.d.ts.map +1 -1
  122. package/dist/esm/project-config/shared/csp.schemas.js +11 -12
  123. package/dist/esm/project-config/shared/csp.schemas.js.map +1 -1
  124. package/dist/esm/project-config/shared/data-services.schemas.d.ts.map +1 -1
  125. package/dist/esm/project-config/shared/env-example-defaults.d.ts.map +1 -1
  126. package/dist/esm/project-config/shared/environment.schemas.d.ts +152 -12
  127. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  128. package/dist/esm/project-config/shared/environment.schemas.js +186 -9
  129. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  130. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +185 -10
  131. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
  132. package/dist/esm/project-config/shared/infra-providers.schemas.js +40 -3
  133. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
  134. package/dist/esm/project-config/shared/infra-service.schemas.d.ts.map +1 -1
  135. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.d.ts.map +1 -1
  136. package/dist/esm/project-config/shared/infrastructure-defaults.schemas.js.map +1 -1
  137. package/dist/esm/project-config/shared/k8s-utils.d.ts.map +1 -1
  138. package/dist/esm/project-config/shared/k8s-utils.js.map +1 -1
  139. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.d.ts.map +1 -1
  140. package/dist/esm/project-config/shared/minion-platform-access.vocabulary.js.map +1 -1
  141. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts +77 -47
  142. package/dist/esm/project-config/shared/minion-resource-access.validation.d.ts.map +1 -1
  143. package/dist/esm/project-config/shared/minion-resource-access.validation.js +114 -52
  144. package/dist/esm/project-config/shared/minion-resource-access.validation.js.map +1 -1
  145. package/dist/esm/project-config/shared/platform-services.schemas.d.ts +50 -0
  146. package/dist/esm/project-config/shared/platform-services.schemas.d.ts.map +1 -1
  147. package/dist/esm/project-config/shared/platform-services.schemas.js +57 -0
  148. package/dist/esm/project-config/shared/platform-services.schemas.js.map +1 -1
  149. package/dist/esm/project-config/shared/platform-storage.schemas.d.ts +35 -0
  150. package/dist/esm/project-config/shared/platform-storage.schemas.d.ts.map +1 -0
  151. package/dist/esm/project-config/shared/platform-storage.schemas.js +37 -0
  152. package/dist/esm/project-config/shared/platform-storage.schemas.js.map +1 -0
  153. package/dist/esm/project-config/shared/schema-version.schemas.d.ts.map +1 -1
  154. package/dist/esm/project-config/shared/service-definitions.schemas.d.ts.map +1 -1
  155. package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts +81 -0
  156. package/dist/esm/project-config/shared/systems-of-record-env.schemas.d.ts.map +1 -0
  157. package/dist/esm/project-config/shared/systems-of-record-env.schemas.js +74 -0
  158. package/dist/esm/project-config/shared/systems-of-record-env.schemas.js.map +1 -0
  159. package/dist/esm/project-config/static-asset-import-noop.d.ts +26 -0
  160. package/dist/esm/project-config/static-asset-import-noop.d.ts.map +1 -0
  161. package/dist/esm/project-config/static-asset-import-noop.js +49 -0
  162. package/dist/esm/project-config/static-asset-import-noop.js.map +1 -0
  163. package/dist/esm/registry/artifact-domain.schemas.d.ts +1 -1
  164. package/dist/esm/registry/artifact-domain.schemas.d.ts.map +1 -1
  165. package/dist/esm/registry/companion-api.schemas.d.ts +0 -176
  166. package/dist/esm/registry/companion-api.schemas.d.ts.map +0 -1
  167. package/dist/esm/registry/companion-api.schemas.js.map +0 -1
  168. package/dist/esm/registry/digest.schemas.d.ts.map +1 -1
  169. package/dist/esm/registry/index.d.ts +3 -1
  170. package/dist/esm/registry/index.d.ts.map +1 -1
  171. package/dist/esm/registry/index.js +3 -1
  172. package/dist/esm/registry/index.js.map +1 -1
  173. package/dist/esm/registry/local-checkout-source.d.ts +31 -0
  174. package/dist/esm/registry/local-checkout-source.d.ts.map +1 -0
  175. package/dist/esm/registry/local-checkout-source.js +45 -0
  176. package/dist/esm/registry/local-checkout-source.js.map +1 -0
  177. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts +174 -14
  178. package/dist/esm/registry/lockfile-modules-section.schemas.d.ts.map +1 -1
  179. package/dist/esm/registry/lockfile-modules-section.schemas.js +120 -11
  180. package/dist/esm/registry/lockfile-modules-section.schemas.js.map +1 -1
  181. package/dist/esm/registry/module-artifact.schemas.d.ts +79 -0
  182. package/dist/esm/registry/module-artifact.schemas.d.ts.map +1 -1
  183. package/dist/esm/registry/module-artifact.schemas.js +36 -0
  184. package/dist/esm/registry/module-artifact.schemas.js.map +1 -1
  185. package/dist/esm/registry/module-manifest.schemas.d.ts +403 -23
  186. package/dist/esm/registry/module-manifest.schemas.d.ts.map +1 -1
  187. package/dist/esm/registry/module-manifest.schemas.js +502 -60
  188. package/dist/esm/registry/module-manifest.schemas.js.map +1 -1
  189. package/dist/esm/registry/module-search.schemas.d.ts +80 -0
  190. package/dist/esm/registry/module-search.schemas.d.ts.map +1 -0
  191. package/dist/esm/registry/module-search.schemas.js +112 -0
  192. package/dist/esm/registry/module-search.schemas.js.map +1 -0
  193. package/dist/esm/registry/registry-config.schemas.d.ts +16 -0
  194. package/dist/esm/registry/registry-config.schemas.d.ts.map +1 -1
  195. package/dist/esm/registry/registry-config.schemas.js +8 -0
  196. package/dist/esm/registry/registry-config.schemas.js.map +1 -1
  197. package/dist/esm/registry/registry-errors.d.ts +126 -2
  198. package/dist/esm/registry/registry-errors.d.ts.map +1 -1
  199. package/dist/esm/registry/registry-errors.js +183 -14
  200. package/dist/esm/registry/registry-errors.js.map +1 -1
  201. package/dist/esm/registry/registry-keys.schemas.d.ts +80 -0
  202. package/dist/esm/registry/registry-keys.schemas.d.ts.map +1 -0
  203. package/dist/esm/registry/registry-keys.schemas.js +68 -0
  204. package/dist/esm/registry/registry-keys.schemas.js.map +1 -0
  205. package/dist/esm/registry/registry-section-schemas.constants.d.ts +25 -3
  206. package/dist/esm/registry/registry-section-schemas.constants.d.ts.map +1 -1
  207. package/dist/esm/release/framework-release.constants.d.ts.map +1 -1
  208. package/dist/esm/release/framework-release.constants.js.map +1 -1
  209. package/dist/esm/schemas/framework-info.schemas.d.ts.map +1 -1
  210. package/dist/esm/schemas/framework-secrets.schemas.d.ts +12 -1
  211. package/dist/esm/schemas/framework-secrets.schemas.d.ts.map +1 -1
  212. package/dist/esm/schemas/framework-secrets.schemas.js +14 -1
  213. package/dist/esm/schemas/framework-secrets.schemas.js.map +1 -1
  214. package/dist/esm/schemas/platform-application-config.schemas.d.ts.map +1 -1
  215. package/dist/esm/schemas/platform-application-secrets.schemas.d.ts.map +1 -1
  216. package/dist/esm/schemas/platform-config.schemas.d.ts.map +1 -1
  217. package/dist/esm/workspace-scope/application-subject-manifest.d.ts.map +1 -1
  218. package/dist/esm/workspace-scope/index.d.ts.map +1 -1
  219. package/dist/esm/workspace-scope/resolve-homes.d.ts.map +1 -1
  220. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts +17 -14
  221. package/dist/esm/workspace-scope/workspace-homes.schemas.d.ts.map +1 -1
  222. package/dist/esm/workspace-scope/workspace-homes.schemas.js +8 -7
  223. package/dist/esm/workspace-scope/workspace-homes.schemas.js.map +1 -1
  224. package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts +15 -6
  225. package/dist/esm/workspace-scope/workspace-scope.schemas.d.ts.map +1 -1
  226. package/dist/esm/workspace-scope/workspace-scope.schemas.js +23 -9
  227. package/dist/esm/workspace-scope/workspace-scope.schemas.js.map +1 -1
  228. package/package.json +7 -7
  229. package/dist/esm/registry/companion-api.schemas.js +0 -165
  230. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -31,10 +31,75 @@ export declare enum WildoLocationType {
31
31
  REMOTE = "remote"
32
32
  }
33
33
  export declare function isLocalEnvironmentId(environmentId: string): boolean;
34
+ /**
35
+ * Where a docker-compose backing service keeps its DATA.
36
+ *
37
+ * The two members are not a performance knob with a fast and a slow setting — they answer a
38
+ * question about ownership, and the cost follows from the answer:
39
+ *
40
+ * - `HOST_PATH` — the data lives at an explicit path on the host
41
+ * (`<saas-root>/.wildo-saas/local_data/<service>/`), bind-mounted into the container. The
42
+ * operator chooses the disk, backups target a known directory, and the tree is the same one the
43
+ * Kind k8s lane hostPath-mounts at `/mnt/local-data/<service>/`. That control is why it is the
44
+ * REMOTE default: a production operator who has provisioned a dedicated data volume must be able
45
+ * to put the database on it, and a named volume would silently land it under
46
+ * `/var/lib/docker/volumes/` on the root disk.
47
+ * - `DOCKER_VOLUME` — the data lives in a Docker named volume, inside the container runtime's own
48
+ * storage. Nobody outside Docker addresses it, which is exactly what makes it right for a
49
+ * disposable development stack.
50
+ *
51
+ * ## Why LOCAL defaults to `DOCKER_VOLUME`
52
+ *
53
+ * On Linux a bind mount is a native path and costs nothing. On macOS and Windows the container
54
+ * runtime is a VM, and a host bind mount crosses a filesystem bridge — VirtioFS on macOS, 9p/
55
+ * VirtioFS through WSL2 on Windows. Databases do small fsync'd random writes, so every one of them
56
+ * becomes a round trip out of the VM.
57
+ *
58
+ * Measured on macOS (Apple Virtualization, 6 vCPU) on 2026-09-22 with the eight self-hosted backing
59
+ * services bind-mounted: the VM process held **13,786 host file descriptors** open across 14,168
60
+ * files and burned **383% CPU** in Docker Desktop's file-sharing process — sustained, a 321%
61
+ * average over 2 days 5 hours — while the containers themselves used 0.7 of a core and container
62
+ * block-IO accounting stayed flat, because none of that traffic reaches the VM's own block device.
63
+ * Roughly four cores of pure filesystem translation for 0.7 of a core of database work.
64
+ *
65
+ * The default is uniform across all three development operating systems rather than "volumes on
66
+ * macOS and Windows, host paths on Linux", so every developer and CI run exercise the same stack
67
+ * and a bug reproduces the same way everywhere. It costs a Linux developer nothing: a named volume
68
+ * is a native directory there too.
69
+ *
70
+ * Both members are authorable per environment (`localDataStorage`), so a remote operator who wants
71
+ * volumes and a local developer who wants to read the files from their file manager each say so.
72
+ *
73
+ * NOTE this governs DATA directories only. The two small secret FILES compose mounts read-only —
74
+ * immudb's state-signing key and mongot's sync-source password — are materialized from
75
+ * `secrets.json` onto the host and stay host mounts under every mode. They are read once at
76
+ * startup, so they carry none of the cost above, and they have nowhere else to come from.
77
+ */
78
+ export declare enum WildoLocalDataStorage {
79
+ DOCKER_VOLUME = "docker-volume",
80
+ HOST_PATH = "host-path"
81
+ }
82
+ /**
83
+ * The `localDataStorage` an environment gets when it authors none.
84
+ *
85
+ * Total over {@link WildoLocationType} rather than a conditional on one member, so a location type
86
+ * added to the vocabulary tomorrow is a compile error here instead of silently inheriting whichever
87
+ * branch happened to be the `else`.
88
+ */
89
+ export declare function resolveDefaultLocalDataStorage(locationType: WildoLocationType): WildoLocalDataStorage;
90
+ /**
91
+ * Ingress controller installed by Wildo's local and remote Kubernetes workflows.
92
+ * Import from `@wildo-ai/platform-config-lib`. Traefik owns both application
93
+ * routing and HTTP-01 challenge routing; selecting another controller is not
94
+ * supported by the generated installation contract.
95
+ */
96
+ export declare enum WildoKubernetesIngressClass {
97
+ TRAEFIK = "traefik"
98
+ }
34
99
  /**
35
100
  * K8s-internal cluster topology. Holds ONLY values that are genuinely
36
- * specific to a Kubernetes deployment (the namespace and the optional
37
- * ingress class).
101
+ * specific to a Kubernetes deployment: namespace, ingress class and
102
+ * per-service workload replica counts.
38
103
  *
39
104
  * The external/public hostname (where browsers and reverse proxies hit
40
105
  * us) is NOT here — it lives at the top level of `WildoInfraEnvConfig`
@@ -45,7 +110,10 @@ export declare function isLocalEnvironmentId(environmentId: string): boolean;
45
110
  */
46
111
  export declare const WildoKubernetesConfigSchema: z.ZodObject<{
47
112
  namespace: z.ZodString;
48
- ingressClass: z.ZodOptional<z.ZodString>;
113
+ services: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
114
+ replicas: z.ZodOptional<z.ZodNumber>;
115
+ }, z.core.$strict>>>;
116
+ ingressClass: z.ZodOptional<z.ZodLiteral<"traefik">>;
49
117
  }, z.core.$strip>;
50
118
  export type WildoKubernetesConfig = z.infer<typeof WildoKubernetesConfigSchema>;
51
119
  /**
@@ -148,10 +216,79 @@ export declare const WildoProviderSelectionOverridesSchema: z.ZodRecord<z.ZodEnu
148
216
  whenUnavailable: z.ZodOptional<z.ZodArray<z.ZodString>>;
149
217
  }, z.core.$strict>>;
150
218
  export type WildoProviderSelectionOverrides = z.infer<typeof WildoProviderSelectionOverridesSchema>;
219
+ /**
220
+ * Per-environment provider CONFIGURATION values — the half of `providerConfigurations` that exists once per
221
+ * DEPLOYMENT rather than once per application.
222
+ *
223
+ * `wildo.saas.config.ts > providerConfigurations` is authored once and reaches every environment. That is right for
224
+ * application POLICY a provider reads (an agent execution profile, which environments it may run in). It is wrong
225
+ * for an IDENTITY the vendor issued against one deployment: an OAuth client ID registered with the authorized
226
+ * redirect URIs of one environment, a frontend SDK DSN or site key, a picker `appId`. Authored in the SaaS config, the
227
+ * local development Google client — whose only redirect URI is `localhost` — would be the client staging and
228
+ * production send users to.
229
+ *
230
+ * This block carries those values for ONE environment, in exactly the SaaS block's
231
+ * `providerRef → protocolKind → key` shape, and {@link overlayEnvironmentProviderConfigurations} lays it over the
232
+ * SaaS block KEY BY KEY. An environment therefore states only what differs and inherits the rest, so the policy half
233
+ * is never restated per environment.
234
+ *
235
+ * It reaches both places a provider configuration is read, because the CLI applies the overlay where it knows the
236
+ * environment: the managed declaration each environment's apps-manager stores (backend readers — the OAuth2
237
+ * connection resolver, email/SMS senders, the provider registry) and the provider runtime artifacts a build bakes in
238
+ * (frontend `publicConfig`, the backend's generated provider module).
239
+ *
240
+ * NOT for secrets. This file is committed; a client secret, API key or signing secret stays in
241
+ * `secrets.json → providerEnv`. The CLI refuses a key named like one of the provider's declared secrets.
242
+ */
243
+ export declare const WildoEnvironmentProviderConfigurationsSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
244
+ export type WildoEnvironmentProviderConfigurations = z.infer<typeof WildoEnvironmentProviderConfigurationsSchema>;
245
+ /**
246
+ * The provider configuration ONE environment runs with: the application-level `providerConfigurations`, with the
247
+ * environment's {@link WildoEnvironmentProviderConfigurationsSchema} values laid over it key by key.
248
+ *
249
+ * Precedence is per key inside one `providerRef → protocolKind` bag, and the environment wins — the more specific
250
+ * layer, as `secrets.json → providerEnv` wins over `observability.llmObservability.providerEnv`. A bag the
251
+ * environment does not mention is carried unchanged; a bag only the environment declares is added. Neither input is
252
+ * mutated.
253
+ *
254
+ * Rejected: replacing a whole provider or protocol bag. That would force an environment to restate every
255
+ * environment-invariant key it shares with the application (an agent execution profile beside a client ID), and a
256
+ * restated copy is one that drifts from the original.
257
+ *
258
+ * Throws when the application layer holds a non-object at a protocol key the environment overlays: there is no key
259
+ * to lay a value over, and silently replacing it would discard the application's value without saying so.
260
+ */
261
+ export declare function overlayEnvironmentProviderConfigurations(applicationProviderConfigurations: Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>> | undefined, environmentProviderConfigurations: WildoEnvironmentProviderConfigurations | undefined): Record<string, Record<string, unknown> | undefined>;
151
262
  export declare enum DatabaseEngine {
152
263
  MONGODB = "mongodb",
153
264
  POSTGRESQL = "postgresql"
154
265
  }
266
+ /**
267
+ * The store an APPLICATION persists to when its environment authors no `applicationDatabase`.
268
+ *
269
+ * PostgreSQL — decided by Paul on 2026-09-24 (#1571), reversing 75cd1934f ("absence means MongoDB")
270
+ * and restoring the rule of 2e0194c41. This is the ONLY place the answer is written. Every reader of
271
+ * an application's engine goes through {@link resolveApplicationDatabaseEngine}, because the
272
+ * 2026-09-15 incident was two readers answering silence differently: provisioning chose PostgreSQL,
273
+ * the runtime chose MongoDB, Mongo provisioning was skipped, registration reported success, and the
274
+ * application died at boot with `Command update requires authentication`.
275
+ *
276
+ * Distinct from the PLATFORM's own store (`database` in the infra config) and from the engine's
277
+ * `DEFAULT_PERSISTENCE_ADAPTER` / `DATABASE_DEFAULT_ADAPTER` env default, which also governs
278
+ * platform services and is not what this decides. The application never falls through to that env
279
+ * default: the CLI writes the resolved adapter explicitly.
280
+ */
281
+ export declare const DEFAULT_APPLICATION_DATABASE_ENGINE: DatabaseEngine;
282
+ /**
283
+ * The engine an application persists to: its authored `applicationDatabase.engine`, or
284
+ * {@link DEFAULT_APPLICATION_DATABASE_ENGINE} when the environment authors none.
285
+ *
286
+ * Takes the declaration rather than a whole config so every carrier of it — the parsed infra config,
287
+ * `config.json`, a bootstrap request — answers through the same function.
288
+ */
289
+ export declare function resolveApplicationDatabaseEngine(applicationDatabase: {
290
+ readonly engine?: DatabaseEngine;
291
+ } | undefined): DatabaseEngine;
155
292
  export declare enum WildoImageTagStrategy {
156
293
  COMMIT_SHA = "commit-sha",
157
294
  BRANCH_NAME = "branch-name",
@@ -164,33 +301,36 @@ export declare const DockerComposeDeploymentSchema: z.ZodObject<{
164
301
  branch: z.ZodString;
165
302
  runtime: z.ZodLiteral<WildoDeploymentRuntime.DOCKER_COMPOSE>;
166
303
  imageTagStrategy: z.ZodDefault<z.ZodEnum<typeof WildoImageTagStrategy>>;
167
- }, z.core.$strip>;
304
+ }, z.core.$strict>;
168
305
  /**
169
- * Kubernetes deployment — includes registry, namespace, and scaling support.
306
+ * Kubernetes deployment — branch, namespace and tagging.
307
+ *
308
+ * No `registry`: an environment's images live at `remoteProvider.registryEndpoint`, the registry every deploy
309
+ * manifest pulls from and the deploy workflow pushes to. A separate field here could only repeat that value or
310
+ * contradict it — and it did contradict it, sending CI pushes to GHCR while the cluster pulled from the endpoint
311
+ * (#1165). Both deployment shapes are strict, so a leftover `registry` is refused rather than silently ignored.
170
312
  */
171
313
  export declare const KubernetesDeploymentSchema: z.ZodObject<{
172
314
  branch: z.ZodString;
173
315
  runtime: z.ZodLiteral<WildoDeploymentRuntime.KUBERNETES>;
174
- registry: z.ZodOptional<z.ZodString>;
175
316
  namespace: z.ZodOptional<z.ZodString>;
176
317
  imageTagStrategy: z.ZodDefault<z.ZodEnum<typeof WildoImageTagStrategy>>;
177
- }, z.core.$strip>;
318
+ }, z.core.$strict>;
178
319
  /**
179
320
  * Deployment configuration for CI/CD pipeline integration.
180
- * Discriminated on `runtime`: K8s-specific fields (`registry`, `namespace`)
181
- * are only available when `runtime` is `KUBERNETES`.
321
+ * Discriminated on `runtime`: the K8s-specific field (`namespace`)
322
+ * is only available when `runtime` is `KUBERNETES`.
182
323
  */
183
324
  export declare const WildoDeploymentConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
184
325
  branch: z.ZodString;
185
326
  runtime: z.ZodLiteral<WildoDeploymentRuntime.DOCKER_COMPOSE>;
186
327
  imageTagStrategy: z.ZodDefault<z.ZodEnum<typeof WildoImageTagStrategy>>;
187
- }, z.core.$strip>, z.ZodObject<{
328
+ }, z.core.$strict>, z.ZodObject<{
188
329
  branch: z.ZodString;
189
330
  runtime: z.ZodLiteral<WildoDeploymentRuntime.KUBERNETES>;
190
- registry: z.ZodOptional<z.ZodString>;
191
331
  namespace: z.ZodOptional<z.ZodString>;
192
332
  imageTagStrategy: z.ZodDefault<z.ZodEnum<typeof WildoImageTagStrategy>>;
193
- }, z.core.$strip>], "runtime">;
333
+ }, z.core.$strict>], "runtime">;
194
334
  export type WildoDeploymentConfig = z.infer<typeof WildoDeploymentConfigSchema>;
195
335
  /** @wildo_source:part:end platform.config.environment.deployment */
196
336
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"environment.schemas.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/environment.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;GAQG;AACH,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AA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AA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAEpG,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAED,oBAAY,qBAAqB;IAC/B,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;iBAIxC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;iBAMrC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;8BAGtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,oEAAoE;AAEpE;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACpB,MAAM,CAYR;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACpB,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kCAAkC;;;;iBAgB7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC"}
1
+ {"version":3,"file":"environment.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/project-config/shared/environment.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD;;;;;;;;GAQG;AACH,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,wBAAwB,aAMlC,CAAC;AACJ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,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AC;AAEH;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;+BAGtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,oEAAoE;AAEpE;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACpB,MAAM,CAYR;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GACpB,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kCAAkC;;;;iBAgB7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { EngineCapability } from '@wildo-ai/saas-models';
3
+ import { InfraServiceK8sSchema } from './infra-service.schemas.js';
3
4
  /**
4
5
  * @wildo_source:part:start platform.config.environment.deployment facet:layer:platform facet:family:infra
5
6
  *
@@ -38,10 +39,84 @@ export var WildoLocationType;
38
39
  export function isLocalEnvironmentId(environmentId) {
39
40
  return environmentId === WildoEnvironment.LOCAL;
40
41
  }
42
+ /**
43
+ * Where a docker-compose backing service keeps its DATA.
44
+ *
45
+ * The two members are not a performance knob with a fast and a slow setting — they answer a
46
+ * question about ownership, and the cost follows from the answer:
47
+ *
48
+ * - `HOST_PATH` — the data lives at an explicit path on the host
49
+ * (`<saas-root>/.wildo-saas/local_data/<service>/`), bind-mounted into the container. The
50
+ * operator chooses the disk, backups target a known directory, and the tree is the same one the
51
+ * Kind k8s lane hostPath-mounts at `/mnt/local-data/<service>/`. That control is why it is the
52
+ * REMOTE default: a production operator who has provisioned a dedicated data volume must be able
53
+ * to put the database on it, and a named volume would silently land it under
54
+ * `/var/lib/docker/volumes/` on the root disk.
55
+ * - `DOCKER_VOLUME` — the data lives in a Docker named volume, inside the container runtime's own
56
+ * storage. Nobody outside Docker addresses it, which is exactly what makes it right for a
57
+ * disposable development stack.
58
+ *
59
+ * ## Why LOCAL defaults to `DOCKER_VOLUME`
60
+ *
61
+ * On Linux a bind mount is a native path and costs nothing. On macOS and Windows the container
62
+ * runtime is a VM, and a host bind mount crosses a filesystem bridge — VirtioFS on macOS, 9p/
63
+ * VirtioFS through WSL2 on Windows. Databases do small fsync'd random writes, so every one of them
64
+ * becomes a round trip out of the VM.
65
+ *
66
+ * Measured on macOS (Apple Virtualization, 6 vCPU) on 2026-09-22 with the eight self-hosted backing
67
+ * services bind-mounted: the VM process held **13,786 host file descriptors** open across 14,168
68
+ * files and burned **383% CPU** in Docker Desktop's file-sharing process — sustained, a 321%
69
+ * average over 2 days 5 hours — while the containers themselves used 0.7 of a core and container
70
+ * block-IO accounting stayed flat, because none of that traffic reaches the VM's own block device.
71
+ * Roughly four cores of pure filesystem translation for 0.7 of a core of database work.
72
+ *
73
+ * The default is uniform across all three development operating systems rather than "volumes on
74
+ * macOS and Windows, host paths on Linux", so every developer and CI run exercise the same stack
75
+ * and a bug reproduces the same way everywhere. It costs a Linux developer nothing: a named volume
76
+ * is a native directory there too.
77
+ *
78
+ * Both members are authorable per environment (`localDataStorage`), so a remote operator who wants
79
+ * volumes and a local developer who wants to read the files from their file manager each say so.
80
+ *
81
+ * NOTE this governs DATA directories only. The two small secret FILES compose mounts read-only —
82
+ * immudb's state-signing key and mongot's sync-source password — are materialized from
83
+ * `secrets.json` onto the host and stay host mounts under every mode. They are read once at
84
+ * startup, so they carry none of the cost above, and they have nowhere else to come from.
85
+ */
86
+ export var WildoLocalDataStorage;
87
+ (function (WildoLocalDataStorage) {
88
+ WildoLocalDataStorage["DOCKER_VOLUME"] = "docker-volume";
89
+ WildoLocalDataStorage["HOST_PATH"] = "host-path";
90
+ })(WildoLocalDataStorage || (WildoLocalDataStorage = {}));
91
+ /**
92
+ * The `localDataStorage` an environment gets when it authors none.
93
+ *
94
+ * Total over {@link WildoLocationType} rather than a conditional on one member, so a location type
95
+ * added to the vocabulary tomorrow is a compile error here instead of silently inheriting whichever
96
+ * branch happened to be the `else`.
97
+ */
98
+ export function resolveDefaultLocalDataStorage(locationType) {
99
+ switch (locationType) {
100
+ case WildoLocationType.LOCAL:
101
+ return WildoLocalDataStorage.DOCKER_VOLUME;
102
+ case WildoLocationType.REMOTE:
103
+ return WildoLocalDataStorage.HOST_PATH;
104
+ }
105
+ }
106
+ /**
107
+ * Ingress controller installed by Wildo's local and remote Kubernetes workflows.
108
+ * Import from `@wildo-ai/platform-config-lib`. Traefik owns both application
109
+ * routing and HTTP-01 challenge routing; selecting another controller is not
110
+ * supported by the generated installation contract.
111
+ */
112
+ export var WildoKubernetesIngressClass;
113
+ (function (WildoKubernetesIngressClass) {
114
+ WildoKubernetesIngressClass["TRAEFIK"] = "traefik";
115
+ })(WildoKubernetesIngressClass || (WildoKubernetesIngressClass = {}));
41
116
  /**
42
117
  * K8s-internal cluster topology. Holds ONLY values that are genuinely
43
- * specific to a Kubernetes deployment (the namespace and the optional
44
- * ingress class).
118
+ * specific to a Kubernetes deployment: namespace, ingress class and
119
+ * per-service workload replica counts.
45
120
  *
46
121
  * The external/public hostname (where browsers and reverse proxies hit
47
122
  * us) is NOT here — it lives at the top level of `WildoInfraEnvConfig`
@@ -52,7 +127,19 @@ export function isLocalEnvironmentId(environmentId) {
52
127
  */
53
128
  export const WildoKubernetesConfigSchema = z.object({
54
129
  namespace: z.string().min(1),
55
- ingressClass: z.string().min(1).optional(),
130
+ /**
131
+ * Workload replica overrides keyed by authored SaaS service key (for example
132
+ * backendApi, app or website), never by generated image/deployment name.
133
+ * Platform service keys have their own renderer. Worker replicas remain in
134
+ * the worker declaration; a key without a generated application target is
135
+ * reported by application deployment generation rather than guessed.
136
+ */
137
+ services: z.record(z.string(), InfraServiceK8sSchema).optional(),
138
+ // Derive the literal from the named runtime vocabulary while accepting the
139
+ // natural authored spelling `ingressClass: 'traefik'` without an enum import.
140
+ ingressClass: z.literal(`${WildoKubernetesIngressClass.TRAEFIK}`, {
141
+ error: 'Wildo Kubernetes deployments support ingressClass traefik only; omit the field or select traefik.',
142
+ }).optional(),
56
143
  });
57
144
  /**
58
145
  * cert-manager `ClusterIssuer` selection for remote TLS. Both issuers are
@@ -193,11 +280,97 @@ export const WildoProviderSelectionOverrideEntrySchema = z.strictObject({
193
280
  whenUnavailable: z.array(z.string().min(1)).optional(),
194
281
  });
195
282
  export const WildoProviderSelectionOverridesSchema = z.partialRecord(z.enum(EngineCapability), WildoProviderSelectionOverrideEntrySchema);
283
+ /**
284
+ * Per-environment provider CONFIGURATION values — the half of `providerConfigurations` that exists once per
285
+ * DEPLOYMENT rather than once per application.
286
+ *
287
+ * `wildo.saas.config.ts > providerConfigurations` is authored once and reaches every environment. That is right for
288
+ * application POLICY a provider reads (an agent execution profile, which environments it may run in). It is wrong
289
+ * for an IDENTITY the vendor issued against one deployment: an OAuth client ID registered with the authorized
290
+ * redirect URIs of one environment, a frontend SDK DSN or site key, a picker `appId`. Authored in the SaaS config, the
291
+ * local development Google client — whose only redirect URI is `localhost` — would be the client staging and
292
+ * production send users to.
293
+ *
294
+ * This block carries those values for ONE environment, in exactly the SaaS block's
295
+ * `providerRef → protocolKind → key` shape, and {@link overlayEnvironmentProviderConfigurations} lays it over the
296
+ * SaaS block KEY BY KEY. An environment therefore states only what differs and inherits the rest, so the policy half
297
+ * is never restated per environment.
298
+ *
299
+ * It reaches both places a provider configuration is read, because the CLI applies the overlay where it knows the
300
+ * environment: the managed declaration each environment's apps-manager stores (backend readers — the OAuth2
301
+ * connection resolver, email/SMS senders, the provider registry) and the provider runtime artifacts a build bakes in
302
+ * (frontend `publicConfig`, the backend's generated provider module).
303
+ *
304
+ * NOT for secrets. This file is committed; a client secret, API key or signing secret stays in
305
+ * `secrets.json → providerEnv`. The CLI refuses a key named like one of the provider's declared secrets.
306
+ */
307
+ export const WildoEnvironmentProviderConfigurationsSchema = z.record(z.string().min(1), z.record(z.string().min(1), z.record(z.string().min(1), z.unknown())));
308
+ /**
309
+ * The provider configuration ONE environment runs with: the application-level `providerConfigurations`, with the
310
+ * environment's {@link WildoEnvironmentProviderConfigurationsSchema} values laid over it key by key.
311
+ *
312
+ * Precedence is per key inside one `providerRef → protocolKind` bag, and the environment wins — the more specific
313
+ * layer, as `secrets.json → providerEnv` wins over `observability.llmObservability.providerEnv`. A bag the
314
+ * environment does not mention is carried unchanged; a bag only the environment declares is added. Neither input is
315
+ * mutated.
316
+ *
317
+ * Rejected: replacing a whole provider or protocol bag. That would force an environment to restate every
318
+ * environment-invariant key it shares with the application (an agent execution profile beside a client ID), and a
319
+ * restated copy is one that drifts from the original.
320
+ *
321
+ * Throws when the application layer holds a non-object at a protocol key the environment overlays: there is no key
322
+ * to lay a value over, and silently replacing it would discard the application's value without saying so.
323
+ */
324
+ export function overlayEnvironmentProviderConfigurations(applicationProviderConfigurations, environmentProviderConfigurations) {
325
+ const resolved = {};
326
+ for (const [providerRef, protocols] of Object.entries(applicationProviderConfigurations ?? {})) {
327
+ resolved[providerRef] = protocols === undefined ? undefined : { ...protocols };
328
+ }
329
+ for (const [providerRef, environmentProtocols] of Object.entries(environmentProviderConfigurations ?? {})) {
330
+ const merged = { ...(resolved[providerRef] ?? {}) };
331
+ for (const [protocolKind, environmentValues] of Object.entries(environmentProtocols)) {
332
+ const applicationValues = merged[protocolKind];
333
+ if (applicationValues !== undefined && (applicationValues === null || typeof applicationValues !== 'object' || Array.isArray(applicationValues))) {
334
+ throw new Error(`providerConfigurations.${providerRef}.${protocolKind} is not an object in wildo.saas.config.ts, so the `
335
+ + 'environment\'s values for it cannot be laid over it key by key.');
336
+ }
337
+ merged[protocolKind] = { ...applicationValues, ...environmentValues };
338
+ }
339
+ resolved[providerRef] = merged;
340
+ }
341
+ return resolved;
342
+ }
196
343
  export var DatabaseEngine;
197
344
  (function (DatabaseEngine) {
198
345
  DatabaseEngine["MONGODB"] = "mongodb";
199
346
  DatabaseEngine["POSTGRESQL"] = "postgresql";
200
347
  })(DatabaseEngine || (DatabaseEngine = {}));
348
+ /**
349
+ * The store an APPLICATION persists to when its environment authors no `applicationDatabase`.
350
+ *
351
+ * PostgreSQL — decided by Paul on 2026-09-24 (#1571), reversing 75cd1934f ("absence means MongoDB")
352
+ * and restoring the rule of 2e0194c41. This is the ONLY place the answer is written. Every reader of
353
+ * an application's engine goes through {@link resolveApplicationDatabaseEngine}, because the
354
+ * 2026-09-15 incident was two readers answering silence differently: provisioning chose PostgreSQL,
355
+ * the runtime chose MongoDB, Mongo provisioning was skipped, registration reported success, and the
356
+ * application died at boot with `Command update requires authentication`.
357
+ *
358
+ * Distinct from the PLATFORM's own store (`database` in the infra config) and from the engine's
359
+ * `DEFAULT_PERSISTENCE_ADAPTER` / `DATABASE_DEFAULT_ADAPTER` env default, which also governs
360
+ * platform services and is not what this decides. The application never falls through to that env
361
+ * default: the CLI writes the resolved adapter explicitly.
362
+ */
363
+ export const DEFAULT_APPLICATION_DATABASE_ENGINE = DatabaseEngine.POSTGRESQL;
364
+ /**
365
+ * The engine an application persists to: its authored `applicationDatabase.engine`, or
366
+ * {@link DEFAULT_APPLICATION_DATABASE_ENGINE} when the environment authors none.
367
+ *
368
+ * Takes the declaration rather than a whole config so every carrier of it — the parsed infra config,
369
+ * `config.json`, a bootstrap request — answers through the same function.
370
+ */
371
+ export function resolveApplicationDatabaseEngine(applicationDatabase) {
372
+ return applicationDatabase?.engine ?? DEFAULT_APPLICATION_DATABASE_ENGINE;
373
+ }
201
374
  export var WildoImageTagStrategy;
202
375
  (function (WildoImageTagStrategy) {
203
376
  WildoImageTagStrategy["COMMIT_SHA"] = "commit-sha";
@@ -207,25 +380,29 @@ export var WildoImageTagStrategy;
207
380
  /**
208
381
  * Docker Compose deployment — no scaling, no K8s-specific fields.
209
382
  */
210
- export const DockerComposeDeploymentSchema = z.object({
383
+ export const DockerComposeDeploymentSchema = z.strictObject({
211
384
  branch: z.string().min(1),
212
385
  runtime: z.literal(WildoDeploymentRuntime.DOCKER_COMPOSE),
213
386
  imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),
214
387
  });
215
388
  /**
216
- * Kubernetes deployment — includes registry, namespace, and scaling support.
389
+ * Kubernetes deployment — branch, namespace and tagging.
390
+ *
391
+ * No `registry`: an environment's images live at `remoteProvider.registryEndpoint`, the registry every deploy
392
+ * manifest pulls from and the deploy workflow pushes to. A separate field here could only repeat that value or
393
+ * contradict it — and it did contradict it, sending CI pushes to GHCR while the cluster pulled from the endpoint
394
+ * (#1165). Both deployment shapes are strict, so a leftover `registry` is refused rather than silently ignored.
217
395
  */
218
- export const KubernetesDeploymentSchema = z.object({
396
+ export const KubernetesDeploymentSchema = z.strictObject({
219
397
  branch: z.string().min(1),
220
398
  runtime: z.literal(WildoDeploymentRuntime.KUBERNETES),
221
- registry: z.string().min(1).optional(),
222
399
  namespace: z.string().min(1).optional(),
223
400
  imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),
224
401
  });
225
402
  /**
226
403
  * Deployment configuration for CI/CD pipeline integration.
227
- * Discriminated on `runtime`: K8s-specific fields (`registry`, `namespace`)
228
- * are only available when `runtime` is `KUBERNETES`.
404
+ * Discriminated on `runtime`: the K8s-specific field (`namespace`)
405
+ * is only available when `runtime` is `KUBERNETES`.
229
406
  */
230
407
  export const WildoDeploymentConfigSchema = z.discriminatedUnion('runtime', [
231
408
  DockerComposeDeploymentSchema,
@@ -1 +1 @@
1
- {"version":3,"file":"environment.schemas.js","sourceRoot":"","sources":["../../../../src/project-config/shared/environment.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,mCAAe,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;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CAAC;IACzD;;;OAGG;IACH,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC/C;;;OAGG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C;;;OAGG;IACH,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EngineCapability } from '@wildo-ai/saas-models';\n\n/**\n * @wildo_source:part:start platform.config.environment.deployment facet:layer:platform facet:family:infra\n *\n * Convenience environment ids kept for common local/staging/production setups.\n *\n * The project model is no longer limited to a fixed environment set: remote\n * environment ids can be any slug-like value. Use `WildoEnvironmentIdSchema`\n * for authoritative validation.\n */\nexport enum WildoEnvironment {\n LOCAL = 'local',\n STAGING = 'staging',\n PRODUCTION = 'production',\n}\n\nexport const WildoEnvironmentIdSchema = z\n .string()\n .min(1)\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'environment ids must be lowercase alphanumeric with optional hyphen-separated segments',\n );\nexport type WildoEnvironmentId = z.infer<typeof WildoEnvironmentIdSchema>;\n\n/**\n * Deployment runtime targets for CI/CD workflows and infra config.\n *\n * Single source of truth for deployment runtime targets, used by both\n * platform-config-lib (developer-facing config) and wildo-cli (operational).\n */\nexport enum WildoDeploymentRuntime {\n DOCKER_COMPOSE = 'docker-compose',\n KUBERNETES = 'kubernetes',\n}\n\nexport enum WildoLocationType {\n LOCAL = 'local',\n REMOTE = 'remote',\n}\n\nexport function isLocalEnvironmentId(environmentId: string): boolean {\n return environmentId === WildoEnvironment.LOCAL;\n}\n\n/**\n * K8s-internal cluster topology. Holds ONLY values that are genuinely\n * specific to a Kubernetes deployment (the namespace and the optional\n * ingress class).\n *\n * The external/public hostname (where browsers and reverse proxies hit\n * us) is NOT here — it lives at the top level of `WildoInfraEnvConfig`\n * as `publicDomain` because it applies to BOTH `KUBERNETES` and\n * `DOCKER_COMPOSE` runtimes. See `external-public-domain-rename.md`\n * for the rationale (the previous `baseDomain` field on this object\n * conflated K8s-internal and reverse-proxy concerns).\n */\nexport const WildoKubernetesConfigSchema = z.object({\n namespace: z.string().min(1),\n ingressClass: z.string().min(1).optional(),\n});\nexport type WildoKubernetesConfig = z.infer<typeof WildoKubernetesConfigSchema>;\n\n/**\n * cert-manager `ClusterIssuer` selection for remote TLS. Both issuers are\n * always provisioned in the cluster (see `cluster-issuer.yaml.hbs`); this\n * picks which one an application's ingress annotation\n * (`cert-manager.io/cluster-issuer`) points at — i.e. which ACME endpoint\n * issues its per-ingress certificate.\n *\n * - `LETSENCRYPT_PROD` — real, browser-trusted certificates. The default,\n * because a remote deployment implies a real domain that browsers must\n * trust. Subject to Let's Encrypt production rate limits\n * (50 certs / registered domain / week).\n * - `LETSENCRYPT_STAGING` — untrusted test certificates with far higher\n * rate limits. Opt into this **while validating DNS + ingress on a new\n * cluster** so a misconfigured first deploy cannot exhaust the prod\n * quota, then flip to prod once issuance succeeds.\n */\nexport enum WildoTlsIssuer {\n LETSENCRYPT_PROD = 'letsencrypt-prod',\n LETSENCRYPT_STAGING = 'letsencrypt-staging',\n}\n\nexport const WildoRemoteProviderSchema = z.object({\n provider: z.string().min(1),\n registryEndpoint: z.string().min(1),\n region: z.string().min(1).optional(),\n /**\n * ACME registration email for Let's Encrypt (`ClusterIssuer.spec.acme.email`).\n * Optional at the schema level so non-TLS remote configs parse, but a\n * remote Kubernetes environment that terminates TLS should author it —\n * Let's Encrypt uses it for expiry warnings and account recovery.\n */\n acmeEmail: z.email().optional(),\n /**\n * Which cert-manager `ClusterIssuer` this environment's ingresses use.\n * Defaults to `LETSENCRYPT_PROD` downstream when unset. See {@link WildoTlsIssuer}.\n */\n tlsIssuer: z.enum(WildoTlsIssuer).optional(),\n});\nexport type WildoRemoteProvider = z.infer<typeof WildoRemoteProviderSchema>;\n\nexport const WildoLoggingConfigSchema = z.object({\n level: z.enum(['debug', 'info', 'warn', 'error']).default('info'),\n formattedConsoleErrors: z.boolean().optional(),\n});\nexport type WildoLoggingConfig = z.infer<typeof WildoLoggingConfigSchema>;\n\n/**\n * Per-environment OTLP telemetry (traces + metrics + logs) posture (Slice 2 Phase 5).\n *\n * `env-vars-builder` projects this block onto the standard `OTEL_*` env vars that the\n * `otel-preload.ts` SDK (in `saas-backend-lib`) reads BEFORE app code:\n * - `enabled` → `OTEL_ENABLED` (the master gate) + drives the `--import` preload wiring.\n * - `endpoint` → `OTEL_EXPORTER_OTLP_ENDPOINT` (the OTLP/HTTP collector/ingest URL).\n * The provider auth header (`OTEL_EXPORTER_OTLP_HEADERS`) is NOT authored here — it is\n * derived by `env-vars-builder` from the selected `OBSERVABILITY_TELEMETRY` provider's\n * secret (e.g. a BetterStack source token). Persisted into `PlatformEnvConfigJson.observability`\n * and hydrated back by `hydrateEnvironmentFromConfig`, mirroring `logging`.\n */\nexport const WildoObservabilityConfigSchema = z.object({\n /**\n * Master switch for OTLP telemetry. `true` → emit `OTEL_ENABLED=true` + wire the\n * `--import @wildo-ai/saas-backend-lib/otel-preload` preload; the preload starts the SDK.\n * `false`/omitted → a complete no-op (the preload self-gates).\n */\n enabled: z.boolean().default(false),\n /**\n * OTLP/HTTP endpoint (`OTEL_EXPORTER_OTLP_ENDPOINT`). Local dev: the local `otel-collector`\n * (`http://localhost:4318`). Remote: the selected provider's ingesting host (e.g. a BetterStack\n * source URL). When omitted, the OTLP exporters fall back to their own default\n * (`http://localhost:4318`), which is the local collector — convenient for local dev.\n */\n endpoint: z.string().optional(),\n /**\n * LLM-call observability env-layer posture — a SEPARATE signal from OTLP\n * telemetry (fed by the engine `AgentCallTraceSink` into the selected\n * `LLM_OBSERVABILITY` provider, e.g. PostHog `$ai_generation`), colocated\n * here because both are per-environment observability posture. Projected\n * onto the `WILDO_LLM_OBS_*` env vars INDEPENDENTLY of the OTLP `enabled`\n * gate — LLM-obs activation is provider-selection-driven, not\n * `OTEL_ENABLED`-driven.\n */\n llmObservability: z.object({\n /**\n * Forward prompt + completion content (`$ai_input` / `$ai_output_choices`)\n * to the LLM-observability provider (→ `WILDO_LLM_OBS_CAPTURE_CONTENT`).\n * Default FALSE: content is user/app data (PII) shipped to a third party —\n * opt in per environment (local dev typically true; production a\n * deliberate decision).\n */\n captureContent: z.boolean().default(false),\n /**\n * Fraction (0..1) of agent calls forwarded (→ `WILDO_LLM_OBS_SAMPLE_RATE`).\n * Omitted = capture every call.\n */\n sampleRate: z.number().min(0).max(1).optional(),\n /**\n * NON-SECRET env for the selected LLM-observability provider — connection\n * details the provider module reads from the runtime env (e.g. PostHog's\n * `POSTHOG_HOST` ingestion host and `POSTHOG_PROJECT_ID`). Projected\n * verbatim into the runtime env; the env-key names are provider-owned,\n * same vocabulary as `secrets.json → providerEnv`. Secrets (API keys)\n * do NOT belong here — they stay in `secrets.json → providerEnv`, which\n * also WINS on a key collision (secrets are the more specific layer).\n * This is the checked-in home for provider config that is not sensitive.\n */\n providerEnv: z.record(z.string(), z.string()).optional(),\n }).optional(),\n});\nexport type WildoObservabilityConfig = z.infer<typeof WildoObservabilityConfigSchema>;\n\n/**\n * Per-environment external-provider SELECTION override (2026-07-10).\n *\n * The app-wide primary/substitute selection for an `EngineCapability` lives in\n * `wildo.saas.config.ts` (`providers.scopes.backend.selection[capability]`) —\n * a single value shared by every environment. This block lets an environment\n * OVERRIDE that primary (and its substitutes) without touching the shared SaaS\n * config, so e.g. LOCAL can select the non-sending `email-preview` provider\n * for `EMAIL_TRANSACTIONAL` while staging/production keep `resend`.\n *\n * Semantics (mirrors the SaaS-side selection policy):\n * - `primary` — the ref that wins for this capability in this environment.\n * - `whenUnavailable` — ordered substitutes, used when a preceding ref is not AVAILABLE at\n * resolution time (undeclared, disabled, unconfigured). NOT failover: nothing retries a\n * second provider when a call to the first one fails.\n *\n * The referenced provider must still be DECLARED in\n * `providers.scopes.backend.providers` and available for the capability — the\n * backend's availability/enabled filtering is unchanged, so an override that\n * names an undeclared or capability-disabled provider resolves to nothing\n * (same fail-closed behaviour as an equivalent SaaS-side selection). FAN_OUT\n * capabilities ignore the override (every declared provider is active — a\n * primary/substitute is meaningless), matching the SaaS-side rule.\n *\n * `env-vars-builder` serializes this block to the `WILDO_PROVIDER_SELECTION_OVERRIDES`\n * backend env var (JSON); `ExternalProvidersRegistryBackendService` reads it and\n * applies it over the SaaS-config selection at capability-resolution time.\n * Persisted into `PlatformEnvConfigJson.providerSelection` and hydrated back by\n * `hydrateEnvironmentFromConfig`, mirroring `logging` / `observability`.\n */\nexport const WildoProviderSelectionOverrideEntrySchema = z.strictObject({\n primary: z.string().min(1),\n whenUnavailable: z.array(z.string().min(1)).optional(),\n});\nexport type WildoProviderSelectionOverrideEntry = z.infer<typeof WildoProviderSelectionOverrideEntrySchema>;\n\nexport const WildoProviderSelectionOverridesSchema = z.partialRecord(\n z.enum(EngineCapability),\n WildoProviderSelectionOverrideEntrySchema,\n);\nexport type WildoProviderSelectionOverrides = z.infer<typeof WildoProviderSelectionOverridesSchema>;\n\nexport enum DatabaseEngine {\n MONGODB = 'mongodb',\n POSTGRESQL = 'postgresql',\n}\n\nexport enum WildoImageTagStrategy {\n COMMIT_SHA = 'commit-sha',\n BRANCH_NAME = 'branch-name',\n SEMVER = 'semver',\n}\n\n/**\n * Docker Compose deployment — no scaling, no K8s-specific fields.\n */\nexport const DockerComposeDeploymentSchema = z.object({\n branch: z.string().min(1),\n runtime: z.literal(WildoDeploymentRuntime.DOCKER_COMPOSE),\n imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),\n});\n\n/**\n * Kubernetes deployment — includes registry, namespace, and scaling support.\n */\nexport const KubernetesDeploymentSchema = z.object({\n branch: z.string().min(1),\n runtime: z.literal(WildoDeploymentRuntime.KUBERNETES),\n registry: z.string().min(1).optional(),\n namespace: z.string().min(1).optional(),\n imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),\n});\n\n/**\n * Deployment configuration for CI/CD pipeline integration.\n * Discriminated on `runtime`: K8s-specific fields (`registry`, `namespace`)\n * are only available when `runtime` is `KUBERNETES`.\n */\nexport const WildoDeploymentConfigSchema = z.discriminatedUnion('runtime', [\n DockerComposeDeploymentSchema,\n KubernetesDeploymentSchema,\n]);\nexport type WildoDeploymentConfig = z.infer<typeof WildoDeploymentConfigSchema>;\n/** @wildo_source:part:end platform.config.environment.deployment */\n\n/**\n * Canonical namespace derivation for platform-managed application resources.\n *\n * Environment ids are part of the namespace because local and arbitrary remote\n * deployments must be isolated through generated names instead of hand-authored\n * checked-in values.\n */\nexport function buildApplicationNamespace(\n appSlug: string,\n environmentId: string,\n): string {\n const normalizedAppSlug = appSlug.trim();\n const normalizedEnvironmentId = environmentId.trim();\n\n if (!normalizedAppSlug) {\n throw new Error('appSlug is required to derive an application namespace');\n }\n if (!normalizedEnvironmentId) {\n throw new Error('environmentId is required to derive an application namespace');\n }\n\n return `${normalizedAppSlug}-${normalizedEnvironmentId}`;\n}\n\nexport function buildApplicationDatabaseUsername(\n appSlug: string,\n environmentId: string,\n): string {\n return `${buildApplicationNamespace(appSlug, environmentId)}_user`;\n}\n\n/**\n * Per-environment origins the DOCUMENTATION site must be built against.\n *\n * ## Why these are authored per environment rather than inferred\n *\n * A documentation bundle is STATIC: whatever origin it is built with is compiled into\n * the shipped JavaScript. The docs site deep-links anonymous readers into the SaaS app to\n * sign in, and exchanges a token against the backend, so a bundle built with the wrong\n * origin does not degrade — it silently points every reader at the wrong host.\n *\n * That is why `docusaurus.config.ts` refuses to complete a PRODUCTION build when these are\n * unset, and falls back to local defaults otherwise. The guard is correct; what was missing\n * was a declared source, so the values had to be remembered on a command line and were\n * therefore absent from every environment definition. Authoring them here puts them where\n * every other per-environment posture already lives, and `wildo config sync` carries them.\n *\n * Projected onto `WILDO_DOCS_API_BASE_URL`, `WILDO_DOCS_APP_URL` and\n * `WILDO_DOCS_FRONTEND_SERVICE_NAME` by `env-vars-builder`, mirroring `providerSelection`.\n *\n * Every member is optional: an application with no documentation site authors nothing, and\n * a local environment relies on the config's own dev defaults rather than restating ports\n * that the runtime already knows.\n */\nexport const WildoDocumentationSiteConfigSchema = z.object({\n /**\n * Backend origin the docs bundle calls for `/auth/token/exchange` and\n * `/auth/cross-frontend-handoff` — e.g. `https://api.example.com`.\n */\n apiBaseUrl: z.string().trim().min(1).optional(),\n /**\n * SaaS application origin the docs site deep-links anonymous readers to for sign-in —\n * e.g. `https://app.example.com`.\n */\n appUrl: z.string().trim().min(1).optional(),\n /**\n * Frontend service name the docs site identifies as when resolving its own providers.\n * Must match the service key declared in `wildo.saas.config.ts#frontendServices`.\n */\n frontendServiceName: z.string().trim().min(1).optional(),\n});\n\nexport type WildoDocumentationSiteConfig = z.infer<typeof WildoDocumentationSiteConfigSchema>;\n"]}
1
+ {"version":3,"file":"environment.schemas.js","sourceRoot":"","sources":["../../../../../src/project-config/shared/environment.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,uCAAmB,CAAA;IACnB,6CAAyB,CAAA;AAC3B,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,KAAK,C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CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC/C;;;OAGG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C;;;OAGG;IACH,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EngineCapability } from '@wildo-ai/saas-models';\nimport { InfraServiceK8sSchema } from './infra-service.schemas';\n\n/**\n * @wildo_source:part:start platform.config.environment.deployment facet:layer:platform facet:family:infra\n *\n * Convenience environment ids kept for common local/staging/production setups.\n *\n * The project model is no longer limited to a fixed environment set: remote\n * environment ids can be any slug-like value. Use `WildoEnvironmentIdSchema`\n * for authoritative validation.\n */\nexport enum WildoEnvironment {\n LOCAL = 'local',\n STAGING = 'staging',\n PRODUCTION = 'production',\n}\n\nexport const WildoEnvironmentIdSchema = z\n .string()\n .min(1)\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'environment ids must be lowercase alphanumeric with optional hyphen-separated segments',\n );\nexport type WildoEnvironmentId = z.infer<typeof WildoEnvironmentIdSchema>;\n\n/**\n * Deployment runtime targets for CI/CD workflows and infra config.\n *\n * Single source of truth for deployment runtime targets, used by both\n * platform-config-lib (developer-facing config) and wildo-cli (operational).\n */\nexport enum WildoDeploymentRuntime {\n DOCKER_COMPOSE = 'docker-compose',\n KUBERNETES = 'kubernetes',\n}\n\nexport enum WildoLocationType {\n LOCAL = 'local',\n REMOTE = 'remote',\n}\n\nexport function isLocalEnvironmentId(environmentId: string): boolean {\n return environmentId === WildoEnvironment.LOCAL;\n}\n\n/**\n * Where a docker-compose backing service keeps its DATA.\n *\n * The two members are not a performance knob with a fast and a slow setting — they answer a\n * question about ownership, and the cost follows from the answer:\n *\n * - `HOST_PATH` — the data lives at an explicit path on the host\n * (`<saas-root>/.wildo-saas/local_data/<service>/`), bind-mounted into the container. The\n * operator chooses the disk, backups target a known directory, and the tree is the same one the\n * Kind k8s lane hostPath-mounts at `/mnt/local-data/<service>/`. That control is why it is the\n * REMOTE default: a production operator who has provisioned a dedicated data volume must be able\n * to put the database on it, and a named volume would silently land it under\n * `/var/lib/docker/volumes/` on the root disk.\n * - `DOCKER_VOLUME` — the data lives in a Docker named volume, inside the container runtime's own\n * storage. Nobody outside Docker addresses it, which is exactly what makes it right for a\n * disposable development stack.\n *\n * ## Why LOCAL defaults to `DOCKER_VOLUME`\n *\n * On Linux a bind mount is a native path and costs nothing. On macOS and Windows the container\n * runtime is a VM, and a host bind mount crosses a filesystem bridge — VirtioFS on macOS, 9p/\n * VirtioFS through WSL2 on Windows. Databases do small fsync'd random writes, so every one of them\n * becomes a round trip out of the VM.\n *\n * Measured on macOS (Apple Virtualization, 6 vCPU) on 2026-09-22 with the eight self-hosted backing\n * services bind-mounted: the VM process held **13,786 host file descriptors** open across 14,168\n * files and burned **383% CPU** in Docker Desktop's file-sharing process — sustained, a 321%\n * average over 2 days 5 hours — while the containers themselves used 0.7 of a core and container\n * block-IO accounting stayed flat, because none of that traffic reaches the VM's own block device.\n * Roughly four cores of pure filesystem translation for 0.7 of a core of database work.\n *\n * The default is uniform across all three development operating systems rather than \"volumes on\n * macOS and Windows, host paths on Linux\", so every developer and CI run exercise the same stack\n * and a bug reproduces the same way everywhere. It costs a Linux developer nothing: a named volume\n * is a native directory there too.\n *\n * Both members are authorable per environment (`localDataStorage`), so a remote operator who wants\n * volumes and a local developer who wants to read the files from their file manager each say so.\n *\n * NOTE this governs DATA directories only. The two small secret FILES compose mounts read-only —\n * immudb's state-signing key and mongot's sync-source password — are materialized from\n * `secrets.json` onto the host and stay host mounts under every mode. They are read once at\n * startup, so they carry none of the cost above, and they have nowhere else to come from.\n */\nexport enum WildoLocalDataStorage {\n DOCKER_VOLUME = 'docker-volume',\n HOST_PATH = 'host-path',\n}\n\n/**\n * The `localDataStorage` an environment gets when it authors none.\n *\n * Total over {@link WildoLocationType} rather than a conditional on one member, so a location type\n * added to the vocabulary tomorrow is a compile error here instead of silently inheriting whichever\n * branch happened to be the `else`.\n */\nexport function resolveDefaultLocalDataStorage(locationType: WildoLocationType): WildoLocalDataStorage {\n switch (locationType) {\n case WildoLocationType.LOCAL:\n return WildoLocalDataStorage.DOCKER_VOLUME;\n case WildoLocationType.REMOTE:\n return WildoLocalDataStorage.HOST_PATH;\n }\n}\n\n/**\n * Ingress controller installed by Wildo's local and remote Kubernetes workflows.\n * Import from `@wildo-ai/platform-config-lib`. Traefik owns both application\n * routing and HTTP-01 challenge routing; selecting another controller is not\n * supported by the generated installation contract.\n */\nexport enum WildoKubernetesIngressClass {\n TRAEFIK = 'traefik',\n}\n\n/**\n * K8s-internal cluster topology. Holds ONLY values that are genuinely\n * specific to a Kubernetes deployment: namespace, ingress class and\n * per-service workload replica counts.\n *\n * The external/public hostname (where browsers and reverse proxies hit\n * us) is NOT here — it lives at the top level of `WildoInfraEnvConfig`\n * as `publicDomain` because it applies to BOTH `KUBERNETES` and\n * `DOCKER_COMPOSE` runtimes. See `external-public-domain-rename.md`\n * for the rationale (the previous `baseDomain` field on this object\n * conflated K8s-internal and reverse-proxy concerns).\n */\nexport const WildoKubernetesConfigSchema = z.object({\n namespace: z.string().min(1),\n /**\n * Workload replica overrides keyed by authored SaaS service key (for example\n * backendApi, app or website), never by generated image/deployment name.\n * Platform service keys have their own renderer. Worker replicas remain in\n * the worker declaration; a key without a generated application target is\n * reported by application deployment generation rather than guessed.\n */\n services: z.record(z.string(), InfraServiceK8sSchema).optional(),\n // Derive the literal from the named runtime vocabulary while accepting the\n // natural authored spelling `ingressClass: 'traefik'` without an enum import.\n ingressClass: z.literal(`${WildoKubernetesIngressClass.TRAEFIK}`, {\n error: 'Wildo Kubernetes deployments support ingressClass traefik only; omit the field or select traefik.',\n }).optional(),\n});\nexport type WildoKubernetesConfig = z.infer<typeof WildoKubernetesConfigSchema>;\n\n/**\n * cert-manager `ClusterIssuer` selection for remote TLS. Both issuers are\n * always provisioned in the cluster (see `cluster-issuer.yaml.hbs`); this\n * picks which one an application's ingress annotation\n * (`cert-manager.io/cluster-issuer`) points at — i.e. which ACME endpoint\n * issues its per-ingress certificate.\n *\n * - `LETSENCRYPT_PROD` — real, browser-trusted certificates. The default,\n * because a remote deployment implies a real domain that browsers must\n * trust. Subject to Let's Encrypt production rate limits\n * (50 certs / registered domain / week).\n * - `LETSENCRYPT_STAGING` — untrusted test certificates with far higher\n * rate limits. Opt into this **while validating DNS + ingress on a new\n * cluster** so a misconfigured first deploy cannot exhaust the prod\n * quota, then flip to prod once issuance succeeds.\n */\nexport enum WildoTlsIssuer {\n LETSENCRYPT_PROD = 'letsencrypt-prod',\n LETSENCRYPT_STAGING = 'letsencrypt-staging',\n}\n\nexport const WildoRemoteProviderSchema = z.object({\n provider: z.string().min(1),\n registryEndpoint: z.string().min(1),\n region: z.string().min(1).optional(),\n /**\n * ACME registration email for Let's Encrypt (`ClusterIssuer.spec.acme.email`).\n * Optional at the schema level so non-TLS remote configs parse, but a\n * remote Kubernetes environment that terminates TLS should author it —\n * Let's Encrypt uses it for expiry warnings and account recovery.\n */\n acmeEmail: z.email().optional(),\n /**\n * Which cert-manager `ClusterIssuer` this environment's ingresses use.\n * Defaults to `LETSENCRYPT_PROD` downstream when unset. See {@link WildoTlsIssuer}.\n */\n tlsIssuer: z.enum(WildoTlsIssuer).optional(),\n});\nexport type WildoRemoteProvider = z.infer<typeof WildoRemoteProviderSchema>;\n\nexport const WildoLoggingConfigSchema = z.object({\n level: z.enum(['debug', 'info', 'warn', 'error']).default('info'),\n formattedConsoleErrors: z.boolean().optional(),\n});\nexport type WildoLoggingConfig = z.infer<typeof WildoLoggingConfigSchema>;\n\n/**\n * Per-environment OTLP telemetry (traces + metrics + logs) posture (Slice 2 Phase 5).\n *\n * `env-vars-builder` projects this block onto the standard `OTEL_*` env vars that the\n * `otel-preload.ts` SDK (in `saas-backend-lib`) reads BEFORE app code:\n * - `enabled` → `OTEL_ENABLED` (the master gate) + drives the `--import` preload wiring.\n * - `endpoint` → `OTEL_EXPORTER_OTLP_ENDPOINT` (the OTLP/HTTP collector/ingest URL).\n * The provider auth header (`OTEL_EXPORTER_OTLP_HEADERS`) is NOT authored here — it is\n * derived by `env-vars-builder` from the selected `OBSERVABILITY_TELEMETRY` provider's\n * secret (e.g. a BetterStack source token). Persisted into `PlatformEnvConfigJson.observability`\n * and hydrated back by `hydrateEnvironmentFromConfig`, mirroring `logging`.\n */\nexport const WildoObservabilityConfigSchema = z.object({\n /**\n * Master switch for OTLP telemetry. `true` → emit `OTEL_ENABLED=true` + wire the\n * `--import @wildo-ai/saas-backend-lib/otel-preload` preload; the preload starts the SDK.\n * `false`/omitted → a complete no-op (the preload self-gates).\n */\n enabled: z.boolean().default(false),\n /**\n * OTLP/HTTP endpoint (`OTEL_EXPORTER_OTLP_ENDPOINT`). Local dev: the local `otel-collector`\n * (`http://localhost:4318`). Remote: the selected provider's ingesting host (e.g. a BetterStack\n * source URL). When omitted, the OTLP exporters fall back to their own default\n * (`http://localhost:4318`), which is the local collector — convenient for local dev.\n */\n endpoint: z.string().optional(),\n /**\n * LLM-call observability env-layer posture — a SEPARATE signal from OTLP\n * telemetry (fed by the engine `AgentCallTraceSink` into the selected\n * `LLM_OBSERVABILITY` provider, e.g. PostHog `$ai_generation`), colocated\n * here because both are per-environment observability posture. Projected\n * onto the `WILDO_LLM_OBS_*` env vars INDEPENDENTLY of the OTLP `enabled`\n * gate — LLM-obs activation is provider-selection-driven, not\n * `OTEL_ENABLED`-driven.\n */\n llmObservability: z.object({\n /**\n * Forward prompt + completion content (`$ai_input` / `$ai_output_choices`)\n * to the LLM-observability provider (→ `WILDO_LLM_OBS_CAPTURE_CONTENT`).\n * Default FALSE: content is user/app data (PII) shipped to a third party —\n * opt in per environment (local dev typically true; production a\n * deliberate decision).\n */\n captureContent: z.boolean().default(false),\n /**\n * Fraction (0..1) of agent calls forwarded (→ `WILDO_LLM_OBS_SAMPLE_RATE`).\n * Omitted = capture every call.\n */\n sampleRate: z.number().min(0).max(1).optional(),\n /**\n * NON-SECRET env for the selected LLM-observability provider — connection\n * details the provider module reads from the runtime env (e.g. PostHog's\n * `POSTHOG_HOST` ingestion host and `POSTHOG_PROJECT_ID`). Projected\n * verbatim into the runtime env; the env-key names are provider-owned,\n * same vocabulary as `secrets.json → providerEnv`. Secrets (API keys)\n * do NOT belong here — they stay in `secrets.json → providerEnv`, which\n * also WINS on a key collision (secrets are the more specific layer).\n * This is the checked-in home for provider config that is not sensitive.\n */\n providerEnv: z.record(z.string(), z.string()).optional(),\n }).optional(),\n});\nexport type WildoObservabilityConfig = z.infer<typeof WildoObservabilityConfigSchema>;\n\n/**\n * Per-environment external-provider SELECTION override (2026-07-10).\n *\n * The app-wide primary/substitute selection for an `EngineCapability` lives in\n * `wildo.saas.config.ts` (`providers.scopes.backend.selection[capability]`) —\n * a single value shared by every environment. This block lets an environment\n * OVERRIDE that primary (and its substitutes) without touching the shared SaaS\n * config, so e.g. LOCAL can select the non-sending `email-preview` provider\n * for `EMAIL_TRANSACTIONAL` while staging/production keep `resend`.\n *\n * Semantics (mirrors the SaaS-side selection policy):\n * - `primary` — the ref that wins for this capability in this environment.\n * - `whenUnavailable` — ordered substitutes, used when a preceding ref is not AVAILABLE at\n * resolution time (undeclared, disabled, unconfigured). NOT failover: nothing retries a\n * second provider when a call to the first one fails.\n *\n * The referenced provider must still be DECLARED in\n * `providers.scopes.backend.providers` and available for the capability — the\n * backend's availability/enabled filtering is unchanged, so an override that\n * names an undeclared or capability-disabled provider resolves to nothing\n * (same fail-closed behaviour as an equivalent SaaS-side selection). FAN_OUT\n * capabilities ignore the override (every declared provider is active — a\n * primary/substitute is meaningless), matching the SaaS-side rule.\n *\n * `env-vars-builder` serializes this block to the `WILDO_PROVIDER_SELECTION_OVERRIDES`\n * backend env var (JSON); `ExternalProvidersRegistryBackendService` reads it and\n * applies it over the SaaS-config selection at capability-resolution time.\n * Persisted into `PlatformEnvConfigJson.providerSelection` and hydrated back by\n * `hydrateEnvironmentFromConfig`, mirroring `logging` / `observability`.\n */\nexport const WildoProviderSelectionOverrideEntrySchema = z.strictObject({\n primary: z.string().min(1),\n whenUnavailable: z.array(z.string().min(1)).optional(),\n});\nexport type WildoProviderSelectionOverrideEntry = z.infer<typeof WildoProviderSelectionOverrideEntrySchema>;\n\nexport const WildoProviderSelectionOverridesSchema = z.partialRecord(\n z.enum(EngineCapability),\n WildoProviderSelectionOverrideEntrySchema,\n);\nexport type WildoProviderSelectionOverrides = z.infer<typeof WildoProviderSelectionOverridesSchema>;\n\n/**\n * Per-environment provider CONFIGURATION values — the half of `providerConfigurations` that exists once per\n * DEPLOYMENT rather than once per application.\n *\n * `wildo.saas.config.ts > providerConfigurations` is authored once and reaches every environment. That is right for\n * application POLICY a provider reads (an agent execution profile, which environments it may run in). It is wrong\n * for an IDENTITY the vendor issued against one deployment: an OAuth client ID registered with the authorized\n * redirect URIs of one environment, a frontend SDK DSN or site key, a picker `appId`. Authored in the SaaS config, the\n * local development Google client — whose only redirect URI is `localhost` — would be the client staging and\n * production send users to.\n *\n * This block carries those values for ONE environment, in exactly the SaaS block's\n * `providerRef → protocolKind → key` shape, and {@link overlayEnvironmentProviderConfigurations} lays it over the\n * SaaS block KEY BY KEY. An environment therefore states only what differs and inherits the rest, so the policy half\n * is never restated per environment.\n *\n * It reaches both places a provider configuration is read, because the CLI applies the overlay where it knows the\n * environment: the managed declaration each environment's apps-manager stores (backend readers — the OAuth2\n * connection resolver, email/SMS senders, the provider registry) and the provider runtime artifacts a build bakes in\n * (frontend `publicConfig`, the backend's generated provider module).\n *\n * NOT for secrets. This file is committed; a client secret, API key or signing secret stays in\n * `secrets.json → providerEnv`. The CLI refuses a key named like one of the provider's declared secrets.\n */\nexport const WildoEnvironmentProviderConfigurationsSchema = z.record(\n z.string().min(1),\n z.record(z.string().min(1), z.record(z.string().min(1), z.unknown())),\n);\nexport type WildoEnvironmentProviderConfigurations = z.infer<typeof WildoEnvironmentProviderConfigurationsSchema>;\n\n/**\n * The provider configuration ONE environment runs with: the application-level `providerConfigurations`, with the\n * environment's {@link WildoEnvironmentProviderConfigurationsSchema} values laid over it key by key.\n *\n * Precedence is per key inside one `providerRef → protocolKind` bag, and the environment wins — the more specific\n * layer, as `secrets.json → providerEnv` wins over `observability.llmObservability.providerEnv`. A bag the\n * environment does not mention is carried unchanged; a bag only the environment declares is added. Neither input is\n * mutated.\n *\n * Rejected: replacing a whole provider or protocol bag. That would force an environment to restate every\n * environment-invariant key it shares with the application (an agent execution profile beside a client ID), and a\n * restated copy is one that drifts from the original.\n *\n * Throws when the application layer holds a non-object at a protocol key the environment overlays: there is no key\n * to lay a value over, and silently replacing it would discard the application's value without saying so.\n */\nexport function overlayEnvironmentProviderConfigurations(\n applicationProviderConfigurations: Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>> | undefined,\n environmentProviderConfigurations: WildoEnvironmentProviderConfigurations | undefined,\n): Record<string, Record<string, unknown> | undefined> {\n const resolved: Record<string, Record<string, unknown> | undefined> = {};\n for (const [providerRef, protocols] of Object.entries(applicationProviderConfigurations ?? {})) {\n resolved[providerRef] = protocols === undefined ? undefined : { ...protocols };\n }\n for (const [providerRef, environmentProtocols] of Object.entries(environmentProviderConfigurations ?? {})) {\n const merged: Record<string, unknown> = { ...(resolved[providerRef] ?? {}) };\n for (const [protocolKind, environmentValues] of Object.entries(environmentProtocols)) {\n const applicationValues = merged[protocolKind];\n if (applicationValues !== undefined && (applicationValues === null || typeof applicationValues !== 'object' || Array.isArray(applicationValues))) {\n throw new Error(\n `providerConfigurations.${providerRef}.${protocolKind} is not an object in wildo.saas.config.ts, so the `\n + 'environment\\'s values for it cannot be laid over it key by key.',\n );\n }\n merged[protocolKind] = { ...(applicationValues as Record<string, unknown> | undefined), ...environmentValues };\n }\n resolved[providerRef] = merged;\n }\n return resolved;\n}\n\nexport enum DatabaseEngine {\n MONGODB = 'mongodb',\n POSTGRESQL = 'postgresql',\n}\n\n/**\n * The store an APPLICATION persists to when its environment authors no `applicationDatabase`.\n *\n * PostgreSQL — decided by Paul on 2026-09-24 (#1571), reversing 75cd1934f (\"absence means MongoDB\")\n * and restoring the rule of 2e0194c41. This is the ONLY place the answer is written. Every reader of\n * an application's engine goes through {@link resolveApplicationDatabaseEngine}, because the\n * 2026-09-15 incident was two readers answering silence differently: provisioning chose PostgreSQL,\n * the runtime chose MongoDB, Mongo provisioning was skipped, registration reported success, and the\n * application died at boot with `Command update requires authentication`.\n *\n * Distinct from the PLATFORM's own store (`database` in the infra config) and from the engine's\n * `DEFAULT_PERSISTENCE_ADAPTER` / `DATABASE_DEFAULT_ADAPTER` env default, which also governs\n * platform services and is not what this decides. The application never falls through to that env\n * default: the CLI writes the resolved adapter explicitly.\n */\nexport const DEFAULT_APPLICATION_DATABASE_ENGINE: DatabaseEngine = DatabaseEngine.POSTGRESQL;\n\n/**\n * The engine an application persists to: its authored `applicationDatabase.engine`, or\n * {@link DEFAULT_APPLICATION_DATABASE_ENGINE} when the environment authors none.\n *\n * Takes the declaration rather than a whole config so every carrier of it — the parsed infra config,\n * `config.json`, a bootstrap request — answers through the same function.\n */\nexport function resolveApplicationDatabaseEngine(applicationDatabase: { readonly engine?: DatabaseEngine } | undefined): DatabaseEngine {\n return applicationDatabase?.engine ?? DEFAULT_APPLICATION_DATABASE_ENGINE;\n}\n\nexport enum WildoImageTagStrategy {\n COMMIT_SHA = 'commit-sha',\n BRANCH_NAME = 'branch-name',\n SEMVER = 'semver',\n}\n\n/**\n * Docker Compose deployment — no scaling, no K8s-specific fields.\n */\nexport const DockerComposeDeploymentSchema = z.strictObject({\n branch: z.string().min(1),\n runtime: z.literal(WildoDeploymentRuntime.DOCKER_COMPOSE),\n imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),\n});\n\n/**\n * Kubernetes deployment — branch, namespace and tagging.\n *\n * No `registry`: an environment's images live at `remoteProvider.registryEndpoint`, the registry every deploy\n * manifest pulls from and the deploy workflow pushes to. A separate field here could only repeat that value or\n * contradict it — and it did contradict it, sending CI pushes to GHCR while the cluster pulled from the endpoint\n * (#1165). Both deployment shapes are strict, so a leftover `registry` is refused rather than silently ignored.\n */\nexport const KubernetesDeploymentSchema = z.strictObject({\n branch: z.string().min(1),\n runtime: z.literal(WildoDeploymentRuntime.KUBERNETES),\n namespace: z.string().min(1).optional(),\n imageTagStrategy: z.enum(WildoImageTagStrategy).default(WildoImageTagStrategy.COMMIT_SHA),\n});\n\n/**\n * Deployment configuration for CI/CD pipeline integration.\n * Discriminated on `runtime`: the K8s-specific field (`namespace`)\n * is only available when `runtime` is `KUBERNETES`.\n */\nexport const WildoDeploymentConfigSchema = z.discriminatedUnion('runtime', [\n DockerComposeDeploymentSchema,\n KubernetesDeploymentSchema,\n]);\nexport type WildoDeploymentConfig = z.infer<typeof WildoDeploymentConfigSchema>;\n/** @wildo_source:part:end platform.config.environment.deployment */\n\n/**\n * Canonical namespace derivation for platform-managed application resources.\n *\n * Environment ids are part of the namespace because local and arbitrary remote\n * deployments must be isolated through generated names instead of hand-authored\n * checked-in values.\n */\nexport function buildApplicationNamespace(\n appSlug: string,\n environmentId: string,\n): string {\n const normalizedAppSlug = appSlug.trim();\n const normalizedEnvironmentId = environmentId.trim();\n\n if (!normalizedAppSlug) {\n throw new Error('appSlug is required to derive an application namespace');\n }\n if (!normalizedEnvironmentId) {\n throw new Error('environmentId is required to derive an application namespace');\n }\n\n return `${normalizedAppSlug}-${normalizedEnvironmentId}`;\n}\n\nexport function buildApplicationDatabaseUsername(\n appSlug: string,\n environmentId: string,\n): string {\n return `${buildApplicationNamespace(appSlug, environmentId)}_user`;\n}\n\n/**\n * Per-environment origins the DOCUMENTATION site must be built against.\n *\n * ## Why these are authored per environment rather than inferred\n *\n * A documentation bundle is STATIC: whatever origin it is built with is compiled into\n * the shipped JavaScript. The docs site deep-links anonymous readers into the SaaS app to\n * sign in, and exchanges a token against the backend, so a bundle built with the wrong\n * origin does not degrade — it silently points every reader at the wrong host.\n *\n * That is why `docusaurus.config.ts` refuses to complete a PRODUCTION build when these are\n * unset, and falls back to local defaults otherwise. The guard is correct; what was missing\n * was a declared source, so the values had to be remembered on a command line and were\n * therefore absent from every environment definition. Authoring them here puts them where\n * every other per-environment posture already lives, and `wildo config sync` carries them.\n *\n * Projected onto `WILDO_DOCS_API_BASE_URL`, `WILDO_DOCS_APP_URL` and\n * `WILDO_DOCS_FRONTEND_SERVICE_NAME` by `env-vars-builder`, mirroring `providerSelection`.\n *\n * Every member is optional: an application with no documentation site authors nothing, and\n * a local environment relies on the config's own dev defaults rather than restating ports\n * that the runtime already knows.\n */\nexport const WildoDocumentationSiteConfigSchema = z.object({\n /**\n * Backend origin the docs bundle calls for `/auth/token/exchange` and\n * `/auth/cross-frontend-handoff` — e.g. `https://api.example.com`.\n */\n apiBaseUrl: z.string().trim().min(1).optional(),\n /**\n * SaaS application origin the docs site deep-links anonymous readers to for sign-in —\n * e.g. `https://app.example.com`.\n */\n appUrl: z.string().trim().min(1).optional(),\n /**\n * Frontend service name the docs site identifies as when resolving its own providers.\n * Must match the service key declared in `wildo.saas.config.ts#frontendServices`.\n */\n frontendServiceName: z.string().trim().min(1).optional(),\n});\n\nexport type WildoDocumentationSiteConfig = z.infer<typeof WildoDocumentationSiteConfigSchema>;\n"]}