@wildo-ai/platform-config-lib 1.1.14 → 1.1.16

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 (39) hide show
  1. package/dist/esm/bootstrap/application-scheduled-jobs.contracts.d.ts +187 -0
  2. package/dist/esm/bootstrap/application-scheduled-jobs.contracts.d.ts.map +1 -0
  3. package/dist/esm/bootstrap/application-scheduled-jobs.contracts.js +250 -0
  4. package/dist/esm/bootstrap/application-scheduled-jobs.contracts.js.map +1 -0
  5. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts +12 -0
  6. package/dist/esm/bootstrap/platform-runtime-env.contracts.d.ts.map +1 -1
  7. package/dist/esm/bootstrap/platform-runtime-env.contracts.js +12 -0
  8. package/dist/esm/bootstrap/platform-runtime-env.contracts.js.map +1 -1
  9. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts +23 -2
  10. package/dist/esm/bootstrap/runtime-backing-service-access.d.ts.map +1 -1
  11. package/dist/esm/bootstrap/runtime-backing-service-access.js +23 -4
  12. package/dist/esm/bootstrap/runtime-backing-service-access.js.map +1 -1
  13. package/dist/esm/index.d.ts +1 -0
  14. package/dist/esm/index.d.ts.map +1 -1
  15. package/dist/esm/index.js +1 -0
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/project-config/define-infra-env-config.d.ts.map +1 -1
  18. package/dist/esm/project-config/define-infra-env-config.js +12 -1
  19. package/dist/esm/project-config/define-infra-env-config.js.map +1 -1
  20. package/dist/esm/project-config/hosted-infra-env-config.js +8 -1
  21. package/dist/esm/project-config/hosted-infra-env-config.js.map +1 -1
  22. package/dist/esm/project-config/provider-companion-discovery.d.ts +45 -0
  23. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  24. package/dist/esm/project-config/provider-companion-discovery.js +53 -3
  25. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  26. package/dist/esm/project-config/provider-runtime-artifacts.d.ts +13 -0
  27. package/dist/esm/project-config/provider-runtime-artifacts.d.ts.map +1 -1
  28. package/dist/esm/project-config/provider-runtime-artifacts.js +43 -1
  29. package/dist/esm/project-config/provider-runtime-artifacts.js.map +1 -1
  30. package/dist/esm/project-config/shared/csp-defaults.d.ts +7 -3
  31. package/dist/esm/project-config/shared/csp-defaults.d.ts.map +1 -1
  32. package/dist/esm/project-config/shared/csp-defaults.js +10 -4
  33. package/dist/esm/project-config/shared/csp-defaults.js.map +1 -1
  34. package/dist/esm/project-config/shared/environment.schemas.d.ts +18 -4
  35. package/dist/esm/project-config/shared/environment.schemas.d.ts.map +1 -1
  36. package/dist/esm/project-config/shared/environment.schemas.js +26 -4
  37. package/dist/esm/project-config/shared/environment.schemas.js.map +1 -1
  38. package/dist/tsconfig.build.tsbuildinfo +1 -1
  39. package/package.json +7 -7
@@ -40,9 +40,13 @@
40
40
  *
41
41
  * - `default-src 'self'` — block by default; everything else opts
42
42
  * in explicitly via specific directives.
43
- * - `frame-ancestors 'none'` — refuse iframe embedding. Header-only
44
- * directive (meta channel ignores it; the `csp-emit.ts` serializer
45
- * strips it from the meta tag automatically).
43
+ * - `frame-ancestors` — refuse iframe embedding by any other origin:
44
+ * `'none'` for the docs site and the website, `'self'` for the SaaS
45
+ * application, which frames its OWN signing-return page while a signer
46
+ * signs at a vendor inside a frame (embedded signing). `'self'` still
47
+ * refuses every other origin, so it keeps the clickjacking defence.
48
+ * Header-only directive (meta channel ignores it; the `csp-emit.ts`
49
+ * serializer strips it from the meta tag automatically).
46
50
  * - `object-src 'none'` — block `<object>` / `<embed>` plugin loading
47
51
  * entirely. None of the three frontend kinds have a use case for
48
52
  * legacy plugins.
@@ -1 +1 @@
1
- {"version":3,"file":"csp-defaults.d.ts","sourceRoot":"","sources":["../../../../src/project-config/shared/csp-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,OA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GAOG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAClC,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAKjD,CAAC"}
@@ -40,9 +40,13 @@
40
40
  *
41
41
  * - `default-src 'self'` — block by default; everything else opts
42
42
  * in explicitly via specific directives.
43
- * - `frame-ancestors 'none'` — refuse iframe embedding. Header-only
44
- * directive (meta channel ignores it; the `csp-emit.ts` serializer
45
- * strips it from the meta tag automatically).
43
+ * - `frame-ancestors` — refuse iframe embedding by any other origin:
44
+ * `'none'` for the docs site and the website, `'self'` for the SaaS
45
+ * application, which frames its OWN signing-return page while a signer
46
+ * signs at a vendor inside a frame (embedded signing). `'self'` still
47
+ * refuses every other origin, so it keeps the clickjacking defence.
48
+ * Header-only directive (meta channel ignores it; the `csp-emit.ts`
49
+ * serializer strips it from the meta tag automatically).
46
50
  * - `object-src 'none'` — block `<object>` / `<embed>` plugin loading
47
51
  * entirely. None of the three frontend kinds have a use case for
48
52
  * legacy plugins.
@@ -163,7 +167,9 @@ const SAAS_APP_BASELINE = {
163
167
  'img-src': ["'self'", 'data:', 'blob:'],
164
168
  'connect-src': ["'self'"],
165
169
  'font-src': ["'self'", 'data:', 'https://fonts.gstatic.com'],
166
- 'frame-ancestors': ["'none'"],
170
+ // 'self', not 'none': an embedded signing frame returns to the application's own signing-return page once the signer is
171
+ // done, and that page must load inside the frame. Every other origin is still refused (the clickjacking defence).
172
+ 'frame-ancestors': ["'self'"],
167
173
  'object-src': ["'none'"],
168
174
  'form-action': ["'self'"],
169
175
  'base-uri': ["'self'"],
@@ -1 +1 @@
1
- {"version":3,"file":"csp-defaults.js","sourceRoot":"","sources":["../../../../src/project-config/shared/csp-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,OAAO,EACL,eAAe,EACf,qCAAqC,EACrC,0BAA0B,EAC1B,kBAA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7C,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,uBAAuB;IACzD,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,iBAAiB;CAC9C,CAAC","sourcesContent":["/**\n * Per-`AppFrontendType` Content-Security-Policy baselines (auth-hardening\n * Slice B, B-Step 1).\n *\n * # Why one baseline per frontend kind (vs a single platform-wide one)\n *\n * The three `AppFrontendType` kinds (`SAAS_APP` / `STATIC_WEBSITE` /\n * `TECH_DOC`) genuinely have different inline-script / inline-style\n * pressure:\n *\n * - `SAAS_APP` — React SPA built with Vite. Vite's production output\n * uses ESM `<script type=\"module\">` with no inline scripts, AND\n * the runtime emits no inline styles. So the `SAAS_APP` baseline\n * is the tightest of the three: NO `'unsafe-inline'` for scripts,\n * `'unsafe-inline'` for styles ONLY because Tailwind's runtime\n * style-injection (e.g., `@apply` with arbitrary values) emits\n * short-lived inline `<style>` tags.\n * - `TECH_DOC` — Docusaurus 3.x SSG. Its hydration shim and classic-theme\n * bootstrap inject inline `<script>` (theme detection, color-mode\n * restoration and route-state seed), while generated/theme markup uses\n * inline styles. So the `TECH_DOC` baseline MUST allow `'unsafe-inline'`\n * for both scripts AND styles. Tightening\n * to nonce-based `'self'` only is a post-Slice-B follow-up that\n * would require an upstream Docusaurus runtime change OR a\n * nonce-injecting build plugin.\n * - `STATIC_WEBSITE` — Astro SSG marketing site. The marketing\n * surface typically embeds analytics / advertising / chat-widget\n * pixels (each a third-party origin), so the baseline ships an\n * intentionally-empty `script-src` / `connect-src` extension list\n * (just `'self'`) and forces the per-app config to opt into every\n * third-party origin explicitly. Per-app `directives['script-src']`\n * overrides MUST list the third-party hostnames the marketing team\n * has actually whitelisted (no implicit `'unsafe-inline'`).\n *\n * A single platform-wide baseline would force the lowest common\n * denominator (`TECH_DOC`'s `'unsafe-inline'` for everyone) and lose\n * the SAAS_APP tightness for no gain.\n *\n * # Shared posture across all three baselines\n *\n * - `default-src 'self'` — block by default; everything else opts\n * in explicitly via specific directives.\n * - `frame-ancestors 'none'` — refuse iframe embedding. Header-only\n * directive (meta channel ignores it; the `csp-emit.ts` serializer\n * strips it from the meta tag automatically).\n * - `object-src 'none'` — block `<object>` / `<embed>` plugin loading\n * entirely. None of the three frontend kinds have a use case for\n * legacy plugins.\n * - `form-action 'self'` — block `<form action=\"…\">` from POSTing\n * to a third-party origin. Closes the cross-origin form-injection\n * surface even when the rest of the policy is permissive.\n * - `base-uri 'self'` — block `<base href=\"…\">` injection from\n * redirecting relative URLs to an attacker-controlled origin.\n *\n * # Connect-src\n *\n * Every baseline ships `connect-src 'self'` — the resolver merges in\n * additional origins via the app-static `directives['connect-src']`\n * override (e.g., the SaaS backend API hostname), and via Slice B\n * Step 2's env-layer override for per-env additions (Sentry, analytics\n * collectors). The baseline does NOT include any backend hostname\n * because the resolver does NOT know the deployment env at the engine\n * layer; per-env hostnames are an env-config concern.\n *\n * # Violation reporting is shared by every baseline (#2867)\n *\n * Every application backend serves a CSP violation collector, so every\n * baseline names it: `report-uri` and `report-to`, the latter defined by a\n * `Reporting-Endpoints` header. It is not in the directive maps below\n * because its URL is the main backend API's ORIGIN for the environment\n * being composed, which only the composer's caller knows — see\n * {@link CSP_PLATFORM_VIOLATION_COLLECTOR}.\n */\n\nimport {\n AppFrontendType,\n CSP_VIOLATION_REPORTING_ENDPOINT_NAME,\n CSP_VIOLATION_REPORTS_PATH,\n MAIN_API_BASE_PATH,\n} from '@wildo-ai/saas-models/public-runtime';\nimport type { CspDirectiveName } from './csp.schemas';\n\n/**\n * The violation collector every baseline names (#2867): the route each application backend serves, and the\n * Reporting API endpoint name the policy's `report-to` uses for it.\n *\n * The baselines cannot carry the URL itself: the collector lives on the main backend API, whose origin differs per\n * environment (`http://localhost:<port>` locally, `https://<host>.<publicDomain>` remotely) and is a different origin\n * from every frontend, so a relative `report-uri` would reach the frontend's own server. `resolveCspPolicy` composes the\n * URL from the origin its caller supplies, and only when the application authored no collector of its own.\n *\n * Both mechanisms are named because CSP Level 3 §5.5 skips `report-uri` whenever `report-to` is present: a browser that\n * implements the Reporting API batches through `report-to`, and one that does not still reports through `report-uri`.\n * spec-cite: CSP Level 3 (W3C Working Draft, 27 October 2026) §5.5 \"Report a violation\", §6.5.1, §6.5.2 — https://www.w3.org/TR/CSP3/\n */\nexport const CSP_PLATFORM_VIOLATION_COLLECTOR = {\n /** The collector's path from the backend origin: the API base path plus the route. */\n path: `${MAIN_API_BASE_PATH}${CSP_VIOLATION_REPORTS_PATH}`,\n /** The name `report-to` uses and the `Reporting-Endpoints` header defines. */\n reportingEndpointName: CSP_VIOLATION_REPORTING_ENDPOINT_NAME,\n} as const;\n\n/**\n * The platform collector's URL on a backend origin, or `undefined` when the origin is unknown — in which case the policy\n * names no collector rather than an invented one.\n *\n * @param backendApiOrigin - the main backend API's origin for the environment being composed (`http://localhost:4241`).\n * A trailing slash is tolerated; a path is not part of an origin and is refused.\n */\nexport function resolvePlatformCspViolationCollectorUrl(backendApiOrigin: string | undefined): string | undefined {\n if (backendApiOrigin === undefined || backendApiOrigin.trim() === '') return undefined;\n const parsed = new URL(backendApiOrigin.trim());\n if (parsed.pathname !== '/' || parsed.search !== '' || parsed.hash !== '') {\n throw new Error(`[csp] the violation collector needs a backend ORIGIN, got \"${backendApiOrigin}\" (it carries a path, query or fragment).`);\n }\n return `${parsed.origin}${CSP_PLATFORM_VIOLATION_COLLECTOR.path}`;\n}\n\n/**\n * Baseline directive map for one `AppFrontendType`. Internal shape — the\n * resolver in `platform-config-lib/src/project-config/shared/csp-emit.ts` produces\n * the same shape as its post-merge output. Distinct from the AUTHOR-side\n * `WildoCspConfig.directives` (which is partial; this is total).\n */\nexport type CspBaselineDirectiveMap = Readonly<\n Partial<Record<CspDirectiveName, readonly string[]>>\n>;\n\n/**\n * `SAAS_APP` baseline — tightest of the three. Vite-bundled React SPA\n * with no inline scripts (production builds emit `<script type=\"module\">`).\n * `style-src 'unsafe-inline'` covers Tailwind runtime style injection.\n *\n * # Google Fonts origins in `style-src` and `font-src`\n *\n * The design-token system (`saas-frontend-lib/src/core/ui/design-token.utils.ts`)\n * ships `applyGoogleFontPreset()` as the canonical web-font loader for\n * `SAAS_APP` shells. It builds a `https://fonts.googleapis.com/css2?...`\n * `<link rel=\"stylesheet\">` at runtime, which in turn pulls woff2 files\n * from `https://fonts.gstatic.com/...`. Both origins MUST be in the\n * baseline because:\n *\n * 1. The font loader is framework-shipped, not app-authored. An app\n * developer that simply uses an `OKLCH` design-token preset with a\n * Google Font family inherits the loader without writing any code,\n * and would hit CSP blocks on every shell render in production\n * (today they're masked because `reportOnly: true` is the typical\n * dev posture).\n * 2. Widening to two specific origins is dramatically safer than the\n * alternatives — `'unsafe-inline'` (which we already accept for\n * Tailwind) is orders of magnitude broader; nonces are not\n * compatible with a runtime-injected `<link>` that doesn't carry\n * our nonce attribute.\n * 3. Apps that prefer fully-local fonts (e.g., self-hosted woff2 in\n * `public/fonts/`) and never call `applyGoogleFontPreset()` can\n * tighten back via the per-app `directives['style-src']` /\n * `directives['font-src']` override — the resolver merges as a\n * union, so the per-app config can restate `[\"'self'\", \"'unsafe-inline'\"]`\n * without `fonts.googleapis.com` and CSP will warn (or block) any\n * stray Google-Fonts call.\n *\n * `preconnect` to both origins happens at the same site\n * (`design-token.utils.ts` lines 982–996). Preconnect is governed by\n * `connect-src`, not `style-src` / `font-src`, BUT modern browsers\n * treat `<link rel=\"preconnect\">` as a hint that doesn't require CSP\n * fetch directives — the actual fetch later in the pipeline carries\n * the resource type and is what CSP grades. No `connect-src` widening\n * is needed.\n */\n/*\n * `script-src` carries `'wasm-unsafe-eval'` because the application's animated icons and illustrations are drawn by\n * the dotLottie player, which is WebAssembly served from the application's own origin (#3095). An enforced policy\n * without it refuses to compile the player, and every animation (the loading spinner, the error pages, the\n * celebrations) draws nothing. The keyword permits compiling WebAssembly ONLY: it does not admit `eval()` or\n * `new Function()`, which `'unsafe-eval'` would, so the SAAS_APP baseline stays free of JavaScript string compilation.\n * spec-cite: CSP Level 3 §4.5.1 (WebAssembly compilation: blocked unless script-src holds 'unsafe-eval' or 'wasm-unsafe-eval') and §4.4.1 (JavaScript string compilation consults 'unsafe-eval' only), https://www.w3.org/TR/CSP3/\n */\nconst SAAS_APP_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\", \"'wasm-unsafe-eval'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\", 'https://fonts.googleapis.com'],\n 'img-src': [\"'self'\", 'data:', 'blob:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\", 'data:', 'https://fonts.gstatic.com'],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * `TECH_DOC` baseline — Docusaurus 3.x SSG. `'unsafe-inline'` on both\n * `script-src` AND `style-src` is required by the Docusaurus runtime\n * (classic-theme bootstrap and hydration shim). `img-src` retains `data:` and\n * `blob:` because the documentation product supports generated/MDX images\n * expressed with those browser-native URL schemes. Fonts are self-hosted; the\n * removed OpenAPI theme's inline icon-font allowance is deliberately gone.\n *\n * Tightening to nonce-based `'self'` only is a post-Slice-B follow-up\n * (would require an upstream Docusaurus runtime change OR a\n * nonce-injecting build plugin — out of scope today).\n */\nconst TECH_DOC_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'blob:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\"],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * `STATIC_WEBSITE` baseline — Astro SSG marketing site. Intentionally\n * narrow `script-src` / `connect-src` to force the per-app config to\n * opt into every third-party hostname (analytics, advertising, chat\n * widget) explicitly. NO implicit `'unsafe-inline'` — the marketing\n * team must opt in per origin (or use nonces / hashes once those are\n * wired by the marketing build plugin).\n *\n * `style-src 'unsafe-inline'` is included because Astro's view\n * transitions and inline scoped styles emit short-lived inline\n * `<style>` tags; stripping that would break the marketing animations\n * the website team relies on.\n *\n * `img-src` includes `https:` because marketing pages routinely embed\n * third-party imagery (case-study screenshots, partner logos hosted on\n * a CDN). Tightening to a closed allow-list per app is the per-app\n * `directives['img-src']` override's job.\n */\nconst STATIC_WEBSITE_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\", 'data:'],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * Per-`AppFrontendType` baseline registry. Total over the enum — adding\n * a new `AppFrontendType` value forces a baseline edit here at compile\n * time (TS error on the missing key). That coupling is the whole point\n * of the registry shape: a new frontend kind that ships without a CSP\n * baseline would silently get NO policy on any deployment until someone\n * notices.\n */\nexport const CSP_BASELINES: Readonly<\n Record<AppFrontendType, CspBaselineDirectiveMap>\n> = {\n [AppFrontendType.SAAS_APP]: SAAS_APP_BASELINE,\n [AppFrontendType.STATIC_WEBSITE]: STATIC_WEBSITE_BASELINE,\n [AppFrontendType.TECH_DOC]: TECH_DOC_BASELINE,\n};\n"]}
1
+ {"version":3,"file":"csp-defaults.js","sourceRoot":"","sources":["../../../../src/project-config/shared/csp-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AAEH,OAAO,EACL,eAAe,EACf,qCAAqC,EACrC,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,sCAAsC,CAAC;AAG9C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C,eAAe,CAAC,cAAc,CAAC,EAAE,uBAAuB;IACzD,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,iBAAiB;CAC9C,CAAC","sourcesContent":["/**\n * Per-`AppFrontendType` Content-Security-Policy baselines (auth-hardening\n * Slice B, B-Step 1).\n *\n * # Why one baseline per frontend kind (vs a single platform-wide one)\n *\n * The three `AppFrontendType` kinds (`SAAS_APP` / `STATIC_WEBSITE` /\n * `TECH_DOC`) genuinely have different inline-script / inline-style\n * pressure:\n *\n * - `SAAS_APP` — React SPA built with Vite. Vite's production output\n * uses ESM `<script type=\"module\">` with no inline scripts, AND\n * the runtime emits no inline styles. So the `SAAS_APP` baseline\n * is the tightest of the three: NO `'unsafe-inline'` for scripts,\n * `'unsafe-inline'` for styles ONLY because Tailwind's runtime\n * style-injection (e.g., `@apply` with arbitrary values) emits\n * short-lived inline `<style>` tags.\n * - `TECH_DOC` — Docusaurus 3.x SSG. Its hydration shim and classic-theme\n * bootstrap inject inline `<script>` (theme detection, color-mode\n * restoration and route-state seed), while generated/theme markup uses\n * inline styles. So the `TECH_DOC` baseline MUST allow `'unsafe-inline'`\n * for both scripts AND styles. Tightening\n * to nonce-based `'self'` only is a post-Slice-B follow-up that\n * would require an upstream Docusaurus runtime change OR a\n * nonce-injecting build plugin.\n * - `STATIC_WEBSITE` — Astro SSG marketing site. The marketing\n * surface typically embeds analytics / advertising / chat-widget\n * pixels (each a third-party origin), so the baseline ships an\n * intentionally-empty `script-src` / `connect-src` extension list\n * (just `'self'`) and forces the per-app config to opt into every\n * third-party origin explicitly. Per-app `directives['script-src']`\n * overrides MUST list the third-party hostnames the marketing team\n * has actually whitelisted (no implicit `'unsafe-inline'`).\n *\n * A single platform-wide baseline would force the lowest common\n * denominator (`TECH_DOC`'s `'unsafe-inline'` for everyone) and lose\n * the SAAS_APP tightness for no gain.\n *\n * # Shared posture across all three baselines\n *\n * - `default-src 'self'` — block by default; everything else opts\n * in explicitly via specific directives.\n * - `frame-ancestors` — refuse iframe embedding by any other origin:\n * `'none'` for the docs site and the website, `'self'` for the SaaS\n * application, which frames its OWN signing-return page while a signer\n * signs at a vendor inside a frame (embedded signing). `'self'` still\n * refuses every other origin, so it keeps the clickjacking defence.\n * Header-only directive (meta channel ignores it; the `csp-emit.ts`\n * serializer strips it from the meta tag automatically).\n * - `object-src 'none'` — block `<object>` / `<embed>` plugin loading\n * entirely. None of the three frontend kinds have a use case for\n * legacy plugins.\n * - `form-action 'self'` — block `<form action=\"…\">` from POSTing\n * to a third-party origin. Closes the cross-origin form-injection\n * surface even when the rest of the policy is permissive.\n * - `base-uri 'self'` — block `<base href=\"…\">` injection from\n * redirecting relative URLs to an attacker-controlled origin.\n *\n * # Connect-src\n *\n * Every baseline ships `connect-src 'self'` — the resolver merges in\n * additional origins via the app-static `directives['connect-src']`\n * override (e.g., the SaaS backend API hostname), and via Slice B\n * Step 2's env-layer override for per-env additions (Sentry, analytics\n * collectors). The baseline does NOT include any backend hostname\n * because the resolver does NOT know the deployment env at the engine\n * layer; per-env hostnames are an env-config concern.\n *\n * # Violation reporting is shared by every baseline (#2867)\n *\n * Every application backend serves a CSP violation collector, so every\n * baseline names it: `report-uri` and `report-to`, the latter defined by a\n * `Reporting-Endpoints` header. It is not in the directive maps below\n * because its URL is the main backend API's ORIGIN for the environment\n * being composed, which only the composer's caller knows — see\n * {@link CSP_PLATFORM_VIOLATION_COLLECTOR}.\n */\n\nimport {\n AppFrontendType,\n CSP_VIOLATION_REPORTING_ENDPOINT_NAME,\n CSP_VIOLATION_REPORTS_PATH,\n MAIN_API_BASE_PATH,\n} from '@wildo-ai/saas-models/public-runtime';\nimport type { CspDirectiveName } from './csp.schemas';\n\n/**\n * The violation collector every baseline names (#2867): the route each application backend serves, and the\n * Reporting API endpoint name the policy's `report-to` uses for it.\n *\n * The baselines cannot carry the URL itself: the collector lives on the main backend API, whose origin differs per\n * environment (`http://localhost:<port>` locally, `https://<host>.<publicDomain>` remotely) and is a different origin\n * from every frontend, so a relative `report-uri` would reach the frontend's own server. `resolveCspPolicy` composes the\n * URL from the origin its caller supplies, and only when the application authored no collector of its own.\n *\n * Both mechanisms are named because CSP Level 3 §5.5 skips `report-uri` whenever `report-to` is present: a browser that\n * implements the Reporting API batches through `report-to`, and one that does not still reports through `report-uri`.\n * spec-cite: CSP Level 3 (W3C Working Draft, 27 October 2026) §5.5 \"Report a violation\", §6.5.1, §6.5.2 — https://www.w3.org/TR/CSP3/\n */\nexport const CSP_PLATFORM_VIOLATION_COLLECTOR = {\n /** The collector's path from the backend origin: the API base path plus the route. */\n path: `${MAIN_API_BASE_PATH}${CSP_VIOLATION_REPORTS_PATH}`,\n /** The name `report-to` uses and the `Reporting-Endpoints` header defines. */\n reportingEndpointName: CSP_VIOLATION_REPORTING_ENDPOINT_NAME,\n} as const;\n\n/**\n * The platform collector's URL on a backend origin, or `undefined` when the origin is unknown — in which case the policy\n * names no collector rather than an invented one.\n *\n * @param backendApiOrigin - the main backend API's origin for the environment being composed (`http://localhost:4241`).\n * A trailing slash is tolerated; a path is not part of an origin and is refused.\n */\nexport function resolvePlatformCspViolationCollectorUrl(backendApiOrigin: string | undefined): string | undefined {\n if (backendApiOrigin === undefined || backendApiOrigin.trim() === '') return undefined;\n const parsed = new URL(backendApiOrigin.trim());\n if (parsed.pathname !== '/' || parsed.search !== '' || parsed.hash !== '') {\n throw new Error(`[csp] the violation collector needs a backend ORIGIN, got \"${backendApiOrigin}\" (it carries a path, query or fragment).`);\n }\n return `${parsed.origin}${CSP_PLATFORM_VIOLATION_COLLECTOR.path}`;\n}\n\n/**\n * Baseline directive map for one `AppFrontendType`. Internal shape — the\n * resolver in `platform-config-lib/src/project-config/shared/csp-emit.ts` produces\n * the same shape as its post-merge output. Distinct from the AUTHOR-side\n * `WildoCspConfig.directives` (which is partial; this is total).\n */\nexport type CspBaselineDirectiveMap = Readonly<\n Partial<Record<CspDirectiveName, readonly string[]>>\n>;\n\n/**\n * `SAAS_APP` baseline — tightest of the three. Vite-bundled React SPA\n * with no inline scripts (production builds emit `<script type=\"module\">`).\n * `style-src 'unsafe-inline'` covers Tailwind runtime style injection.\n *\n * # Google Fonts origins in `style-src` and `font-src`\n *\n * The design-token system (`saas-frontend-lib/src/core/ui/design-token.utils.ts`)\n * ships `applyGoogleFontPreset()` as the canonical web-font loader for\n * `SAAS_APP` shells. It builds a `https://fonts.googleapis.com/css2?...`\n * `<link rel=\"stylesheet\">` at runtime, which in turn pulls woff2 files\n * from `https://fonts.gstatic.com/...`. Both origins MUST be in the\n * baseline because:\n *\n * 1. The font loader is framework-shipped, not app-authored. An app\n * developer that simply uses an `OKLCH` design-token preset with a\n * Google Font family inherits the loader without writing any code,\n * and would hit CSP blocks on every shell render in production\n * (today they're masked because `reportOnly: true` is the typical\n * dev posture).\n * 2. Widening to two specific origins is dramatically safer than the\n * alternatives — `'unsafe-inline'` (which we already accept for\n * Tailwind) is orders of magnitude broader; nonces are not\n * compatible with a runtime-injected `<link>` that doesn't carry\n * our nonce attribute.\n * 3. Apps that prefer fully-local fonts (e.g., self-hosted woff2 in\n * `public/fonts/`) and never call `applyGoogleFontPreset()` can\n * tighten back via the per-app `directives['style-src']` /\n * `directives['font-src']` override — the resolver merges as a\n * union, so the per-app config can restate `[\"'self'\", \"'unsafe-inline'\"]`\n * without `fonts.googleapis.com` and CSP will warn (or block) any\n * stray Google-Fonts call.\n *\n * `preconnect` to both origins happens at the same site\n * (`design-token.utils.ts` lines 982–996). Preconnect is governed by\n * `connect-src`, not `style-src` / `font-src`, BUT modern browsers\n * treat `<link rel=\"preconnect\">` as a hint that doesn't require CSP\n * fetch directives — the actual fetch later in the pipeline carries\n * the resource type and is what CSP grades. No `connect-src` widening\n * is needed.\n */\n/*\n * `script-src` carries `'wasm-unsafe-eval'` because the application's animated icons and illustrations are drawn by\n * the dotLottie player, which is WebAssembly served from the application's own origin (#3095). An enforced policy\n * without it refuses to compile the player, and every animation (the loading spinner, the error pages, the\n * celebrations) draws nothing. The keyword permits compiling WebAssembly ONLY: it does not admit `eval()` or\n * `new Function()`, which `'unsafe-eval'` would, so the SAAS_APP baseline stays free of JavaScript string compilation.\n * spec-cite: CSP Level 3 §4.5.1 (WebAssembly compilation: blocked unless script-src holds 'unsafe-eval' or 'wasm-unsafe-eval') and §4.4.1 (JavaScript string compilation consults 'unsafe-eval' only), https://www.w3.org/TR/CSP3/\n */\nconst SAAS_APP_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\", \"'wasm-unsafe-eval'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\", 'https://fonts.googleapis.com'],\n 'img-src': [\"'self'\", 'data:', 'blob:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\", 'data:', 'https://fonts.gstatic.com'],\n // 'self', not 'none': an embedded signing frame returns to the application's own signing-return page once the signer is\n // done, and that page must load inside the frame. Every other origin is still refused (the clickjacking defence).\n 'frame-ancestors': [\"'self'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * `TECH_DOC` baseline — Docusaurus 3.x SSG. `'unsafe-inline'` on both\n * `script-src` AND `style-src` is required by the Docusaurus runtime\n * (classic-theme bootstrap and hydration shim). `img-src` retains `data:` and\n * `blob:` because the documentation product supports generated/MDX images\n * expressed with those browser-native URL schemes. Fonts are self-hosted; the\n * removed OpenAPI theme's inline icon-font allowance is deliberately gone.\n *\n * Tightening to nonce-based `'self'` only is a post-Slice-B follow-up\n * (would require an upstream Docusaurus runtime change OR a\n * nonce-injecting build plugin — out of scope today).\n */\nconst TECH_DOC_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'blob:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\"],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * `STATIC_WEBSITE` baseline — Astro SSG marketing site. Intentionally\n * narrow `script-src` / `connect-src` to force the per-app config to\n * opt into every third-party hostname (analytics, advertising, chat\n * widget) explicitly. NO implicit `'unsafe-inline'` — the marketing\n * team must opt in per origin (or use nonces / hashes once those are\n * wired by the marketing build plugin).\n *\n * `style-src 'unsafe-inline'` is included because Astro's view\n * transitions and inline scoped styles emit short-lived inline\n * `<style>` tags; stripping that would break the marketing animations\n * the website team relies on.\n *\n * `img-src` includes `https:` because marketing pages routinely embed\n * third-party imagery (case-study screenshots, partner logos hosted on\n * a CDN). Tightening to a closed allow-list per app is the per-app\n * `directives['img-src']` override's job.\n */\nconst STATIC_WEBSITE_BASELINE: CspBaselineDirectiveMap = {\n 'default-src': [\"'self'\"],\n 'script-src': [\"'self'\"],\n 'style-src': [\"'self'\", \"'unsafe-inline'\"],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https:'],\n 'connect-src': [\"'self'\"],\n 'font-src': [\"'self'\", 'data:'],\n 'frame-ancestors': [\"'none'\"],\n 'object-src': [\"'none'\"],\n 'form-action': [\"'self'\"],\n 'base-uri': [\"'self'\"],\n};\n\n/**\n * Per-`AppFrontendType` baseline registry. Total over the enum — adding\n * a new `AppFrontendType` value forces a baseline edit here at compile\n * time (TS error on the missing key). That coupling is the whole point\n * of the registry shape: a new frontend kind that ships without a CSP\n * baseline would silently get NO policy on any deployment until someone\n * notices.\n */\nexport const CSP_BASELINES: Readonly<\n Record<AppFrontendType, CspBaselineDirectiveMap>\n> = {\n [AppFrontendType.SAAS_APP]: SAAS_APP_BASELINE,\n [AppFrontendType.STATIC_WEBSITE]: STATIC_WEBSITE_BASELINE,\n [AppFrontendType.TECH_DOC]: TECH_DOC_BASELINE,\n};\n"]}
@@ -130,10 +130,12 @@ export declare function resolveDefaultLocalDataStorage(locationType: WildoLocati
130
130
  * HTTP rather than onto a broker. A minion is confined to its own queues there by a PostgreSQL row-level security policy;
131
131
  * MongoDB has none, so a MongoDB application's minions are refused under `SMALL` (`describeMinionsRefusedByEnvironmentServiceProfile`).
132
132
  *
133
- * ## What it does not change yet
133
+ * ## No broker
134
134
  *
135
- * The broker's provisioning: under every profile the environment still runs RabbitMQ and apps-manager still mints the
136
- * application's vhost and credentials, though a `SMALL` application's processes no longer use them. Tracked by #2303.
135
+ * Since #2303 slice D a `SMALL` environment runs no RabbitMQ at all (`environmentServiceProfileRunsMessageBroker`): neither
136
+ * lane renders it, no env file carries `RABBITMQ_*`, no runtime joins its network segment, and apps-manager (told through
137
+ * `PLATFORM_ENVIRONMENT_SERVICE_PROFILE`) initializes no admin client and mints, revokes or restores no vhost or credential.
138
+ * A `backingServices.rabbitmq` declaration beside it is refused.
137
139
  */
138
140
  export declare enum EnvironmentServiceProfile {
139
141
  /** Every service the environment's declarations ask for. The default when nothing is authored. */
@@ -141,7 +143,7 @@ export declare enum EnvironmentServiceProfile {
141
143
  /**
142
144
  * The footprint for a small deployment: no ClamAV, no immudb, no mongot
143
145
  * ({@link servicesOmittedByEnvironmentServiceProfile}), one database family, and background work on the application's
144
- * own database instead of RabbitMQ (minions only on PostgreSQL). Vector search remains available on PostgreSQL
146
+ * own database instead of RabbitMQ, which it does not run (minions only on PostgreSQL). Vector search remains available on PostgreSQL
145
147
  * (pgvector is part of the PostgreSQL image, not a separate service).
146
148
  */
147
149
  SMALL = "small"
@@ -185,6 +187,18 @@ export declare function environmentServiceProfileRunsOneDatabaseFamily(profile:
185
187
  * purpose; neither has a use, and a second field would let them be declared.
186
188
  */
187
189
  export declare function queueAdapterTypeOfEnvironmentServiceProfile(profile: EnvironmentServiceProfile): QueueAdapterType;
190
+ /**
191
+ * Whether an environment under `profile` runs a message broker at all (#2303 slice D). Derived from
192
+ * {@link queueAdapterTypeOfEnvironmentServiceProfile}, never authored: the broker exists to carry the RabbitMQ queue, and
193
+ * under the DATABASE queue nothing in the environment uses one (the platform scheduler delivers over HTTP). Absent profile
194
+ * ⇒ {@link DEFAULT_ENVIRONMENT_SERVICE_PROFILE}.
195
+ *
196
+ * The ONE answer every broker decision reads: whether a deployment lane renders RabbitMQ, whether an env file carries
197
+ * `RABBITMQ_*`, whether apps-manager initializes its RabbitMQ admin client and mints a vhost and credentials, and whether
198
+ * a `backingServices.rabbitmq` declaration contradicts the profile. Total over the queue vocabulary through the switch
199
+ * below, so a third queue adapter must decide here whether it needs a broker.
200
+ */
201
+ export declare function environmentServiceProfileRunsMessageBroker(profile: EnvironmentServiceProfile | undefined): boolean;
188
202
  /**
189
203
  * Why an application that declares minions cannot run under `profile` on `applicationDatabaseEngine`, or undefined when it
190
204
  * can (#2303).
@@ -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,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI3E;;;;;;;;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,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;;GAKG;AACH,oBAAY,sBAAsB;IAChC,cAAc,mBAAmB;IACjC,UAAU,eAAe;CAC1B;AAED,oBAAY,iBAAiB;IAC3B,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,oBAAY,qBAAqB;IAC/B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;CACxB;AAED;;;;;;GA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,EACtH,iCAAiC,EAAE,sCAAsC,GAAG,SAAS,GACpF,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAoBrD;AAED,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mCAAmC,EAAE,cAA0C,CAAC;AAE7F;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,mBAAmB,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAA;CAAE,GAAG,SAAS,GAAG,cAAc,CAEtI;AAED,oBAAY,qBAAqB;IAC/B,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;kBAIxC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B;;;;;kBAKrC,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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":"A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;IAC/B,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;kBAIxC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B;;;;;kBAKrC,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,kCAAkC;;;;iBAgB7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC"}
@@ -147,10 +147,12 @@ export function resolveDefaultLocalDataStorage(locationType) {
147
147
  * HTTP rather than onto a broker. A minion is confined to its own queues there by a PostgreSQL row-level security policy;
148
148
  * MongoDB has none, so a MongoDB application's minions are refused under `SMALL` (`describeMinionsRefusedByEnvironmentServiceProfile`).
149
149
  *
150
- * ## What it does not change yet
150
+ * ## No broker
151
151
  *
152
- * The broker's provisioning: under every profile the environment still runs RabbitMQ and apps-manager still mints the
153
- * application's vhost and credentials, though a `SMALL` application's processes no longer use them. Tracked by #2303.
152
+ * Since #2303 slice D a `SMALL` environment runs no RabbitMQ at all (`environmentServiceProfileRunsMessageBroker`): neither
153
+ * lane renders it, no env file carries `RABBITMQ_*`, no runtime joins its network segment, and apps-manager (told through
154
+ * `PLATFORM_ENVIRONMENT_SERVICE_PROFILE`) initializes no admin client and mints, revokes or restores no vhost or credential.
155
+ * A `backingServices.rabbitmq` declaration beside it is refused.
154
156
  */
155
157
  export var EnvironmentServiceProfile;
156
158
  (function (EnvironmentServiceProfile) {
@@ -159,7 +161,7 @@ export var EnvironmentServiceProfile;
159
161
  /**
160
162
  * The footprint for a small deployment: no ClamAV, no immudb, no mongot
161
163
  * ({@link servicesOmittedByEnvironmentServiceProfile}), one database family, and background work on the application's
162
- * own database instead of RabbitMQ (minions only on PostgreSQL). Vector search remains available on PostgreSQL
164
+ * own database instead of RabbitMQ, which it does not run (minions only on PostgreSQL). Vector search remains available on PostgreSQL
163
165
  * (pgvector is part of the PostgreSQL image, not a separate service).
164
166
  */
165
167
  EnvironmentServiceProfile["SMALL"] = "small";
@@ -229,6 +231,26 @@ export function queueAdapterTypeOfEnvironmentServiceProfile(profile) {
229
231
  return QueueAdapterType.DATABASE;
230
232
  }
231
233
  }
234
+ /**
235
+ * Whether an environment under `profile` runs a message broker at all (#2303 slice D). Derived from
236
+ * {@link queueAdapterTypeOfEnvironmentServiceProfile}, never authored: the broker exists to carry the RabbitMQ queue, and
237
+ * under the DATABASE queue nothing in the environment uses one (the platform scheduler delivers over HTTP). Absent profile
238
+ * ⇒ {@link DEFAULT_ENVIRONMENT_SERVICE_PROFILE}.
239
+ *
240
+ * The ONE answer every broker decision reads: whether a deployment lane renders RabbitMQ, whether an env file carries
241
+ * `RABBITMQ_*`, whether apps-manager initializes its RabbitMQ admin client and mints a vhost and credentials, and whether
242
+ * a `backingServices.rabbitmq` declaration contradicts the profile. Total over the queue vocabulary through the switch
243
+ * below, so a third queue adapter must decide here whether it needs a broker.
244
+ */
245
+ export function environmentServiceProfileRunsMessageBroker(profile) {
246
+ switch (queueAdapterTypeOfEnvironmentServiceProfile(profile ?? DEFAULT_ENVIRONMENT_SERVICE_PROFILE)) {
247
+ case QueueAdapterType.RABBITMQ:
248
+ return true;
249
+ case QueueAdapterType.DATABASE:
250
+ case QueueAdapterType.MEMORY:
251
+ return false;
252
+ }
253
+ }
232
254
  /**
233
255
  * Why an application that declares minions cannot run under `profile` on `applicationDatabaseEngine`, or undefined when it
234
256
  * can (#2303).
@@ -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,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,uCAAuC,EAAE,MAAM,sCAAsC,CAAC;AAC/F,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,CACJ,4BAA4B,EAC5B,wFAAwF,CACzF,CAAC;AAGJ;;;;;GAKG;AACH,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2DAAiC,CAAA;IACjC,mDAAyB,CAAA;AAC3B,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAED,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,oCAAe,CAAA;IACf,sCAAiB,CAAA;AACnB,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED,MAAM,UAAU,oBAAoB,CAAC,aAAqB;IACxD,OAAO,aAAa,KAAK,gBAAgB,CAAC,KAAK,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,CAAN,IAAY,qBAGX;AAHD,WA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AA8D,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,GAAG,iBAAiB,IAAI,uBAAuB,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,OAAe,EACf,aAAqB;IAErB,OAAO,GAAG,yBAAyB,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;AACrE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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, QueueAdapterType } from '@wildo-ai/saas-models';\nimport { refuseUnreadProviderConfigurationValues } from '@wildo-ai/external-connectors-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 * Which set of OPTIONAL backing services an environment runs — the deployment footprint (#2303).\n *\n * An environment always runs the services the platform cannot live without (a database, a cache, a\n * broker, an object store). On top of those, the full platform runs three services that each back ONE\n * engine capability: ClamAV (antivirus scanning of uploaded files), immudb (the tamper-evident audit\n * store) and mongot (MongoDB Search / Vector Search). A small internal tool for one team rarely needs any\n * of them, and they are the heaviest containers in the stack (mongot alone is a JVM holding Lucene\n * indexes). A profile states, per environment, whether they run at all.\n *\n * ## Named \"service profile\", not \"runtime profile\"\n *\n * `ApplicationRuntimeProfile` (`@wildo-ai/saas-backend-lib`) already names WHICH RUNTIME boots the\n * application lifecycle (the backend or a minion). This vocabulary answers a different question, about\n * the ENVIRONMENT's footprint, and must not be confused with it.\n *\n * ## What a profile does NOT do\n *\n * It never degrades a capability in silence. Each capability that depends on a service the profile omits\n * is REFUSED at the application's boot when the application declares it, by a message naming the profile\n * and the remedy (`describeServiceOmittedByEnvironmentServiceProfile`). And a declaration that would run\n * an omitted service (`backingServices.clamav: { source: SELF }` under `SMALL`) is refused when the\n * environment descriptor is parsed: the two statements contradict each other.\n *\n * ## One database family\n *\n * `SMALL` also runs ONE database family (`environmentServiceProfileRunsOneDatabaseFamily`): the platform's store and\n * the application's are the same engine, and only that store is declared. Which engine is the author's choice (both a\n * MongoDB and a PostgreSQL environment run in one family); the descriptor derives the families it runs from what it\n * declares and refuses two, naming the declarations that bring each.\n *\n * ## Lanes\n *\n * Both lanes render a profile: the Docker Compose generator, and the Kubernetes manifests (workloads, the mongod\n * routing parameters, secrets, persistent volumes and readiness) since #2303's second slice.\n *\n * ## The queue\n *\n * `SMALL`'s background work runs on the application's own database (`QueueAdapterType.DATABASE`, selected by\n * `queueAdapterTypeOfEnvironmentServiceProfile`), and the platform scheduler delivers its occurrences to the backend over\n * HTTP rather than onto a broker. A minion is confined to its own queues there by a PostgreSQL row-level security policy;\n * MongoDB has none, so a MongoDB application's minions are refused under `SMALL` (`describeMinionsRefusedByEnvironmentServiceProfile`).\n *\n * ## What it does not change yet\n *\n * The broker's provisioning: under every profile the environment still runs RabbitMQ and apps-manager still mints the\n * application's vhost and credentials, though a `SMALL` application's processes no longer use them. Tracked by #2303.\n */\nexport enum EnvironmentServiceProfile {\n /** Every service the environment's declarations ask for. The default when nothing is authored. */\n FULL = 'full',\n /**\n * The footprint for a small deployment: no ClamAV, no immudb, no mongot\n * ({@link servicesOmittedByEnvironmentServiceProfile}), one database family, and background work on the application's\n * own database instead of RabbitMQ (minions only on PostgreSQL). Vector search remains available on PostgreSQL\n * (pgvector is part of the PostgreSQL image, not a separate service).\n */\n SMALL = 'small',\n}\n\n/** The profile an environment gets when it authors none. */\nexport const DEFAULT_ENVIRONMENT_SERVICE_PROFILE: EnvironmentServiceProfile = EnvironmentServiceProfile.FULL;\n\n/**\n * The optional services a {@link EnvironmentServiceProfile} can omit. A closed vocabulary of its own rather\n * than `BackingServiceKind`, because mongot is not a backing-service kind an environment declares: it is a\n * sidecar of a self-hosted MongoDB. Values are the compose service names.\n */\nexport enum EnvironmentServiceProfileOptionalService {\n /** The ClamAV daemon that scans uploaded files (`z_file({ scanPolicy: 'required' })`). */\n ANTIVIRUS_SCANNER = 'clamav',\n /** immudb, the tamper-evident store of the `COMPLIANCE_AUDIT_TRAIL` capability's Layer-2 fan-out. */\n IMMUTABLE_AUDIT_STORE = 'immudb',\n /** mongot, which serves `$search` / `$vectorSearch` for MongoDB-persisted `.ragSource()` fields. */\n MONGODB_SEARCH = 'mongot',\n}\n\n/**\n * The services a profile omits. Total over {@link EnvironmentServiceProfile} (a member added tomorrow fails\n * the build here until somebody decides what it omits), and the ONE place the answer lives: the compose\n * generator, the descriptor refinement and the application's boot refusals all read it.\n */\nexport function servicesOmittedByEnvironmentServiceProfile(\n profile: EnvironmentServiceProfile,\n): readonly EnvironmentServiceProfileOptionalService[] {\n switch (profile) {\n case EnvironmentServiceProfile.FULL:\n return [];\n case EnvironmentServiceProfile.SMALL:\n return [\n EnvironmentServiceProfileOptionalService.ANTIVIRUS_SCANNER,\n EnvironmentServiceProfileOptionalService.IMMUTABLE_AUDIT_STORE,\n EnvironmentServiceProfileOptionalService.MONGODB_SEARCH,\n ];\n }\n}\n\n/**\n * Whether `profile` requires the environment to run ONE database family (#2303). Total over\n * {@link EnvironmentServiceProfile}: a member added tomorrow fails the build until somebody decides.\n */\nexport function environmentServiceProfileRunsOneDatabaseFamily(profile: EnvironmentServiceProfile): boolean {\n switch (profile) {\n case EnvironmentServiceProfile.FULL:\n return false;\n case EnvironmentServiceProfile.SMALL:\n return true;\n }\n}\n\n/**\n * The queue an environment's application processes share (#2303), as its profile decides it. Total over\n * {@link EnvironmentServiceProfile}: a member added tomorrow fails the build until somebody decides.\n *\n * `FULL` runs RabbitMQ; `SMALL` exists to run without a broker, so its processes share the DATABASE queue, kept in\n * the application's own database (`QueueAdapterType.DATABASE`). Read by the application's container when it binds its\n * queue adapter, so the backend and its minions (which receive the same profile) always choose the same queue.\n *\n * Derived rather than authored: a separate `queueTransport` field beside `serviceProfile` was considered and rejected.\n * `FULL` with the database queue would run a broker nothing uses, and `SMALL` with RabbitMQ would defeat the profile's\n * purpose; neither has a use, and a second field would let them be declared.\n */\nexport function queueAdapterTypeOfEnvironmentServiceProfile(profile: EnvironmentServiceProfile): QueueAdapterType {\n switch (profile) {\n case EnvironmentServiceProfile.FULL:\n return QueueAdapterType.RABBITMQ;\n case EnvironmentServiceProfile.SMALL:\n return QueueAdapterType.DATABASE;\n }\n}\n\n/**\n * Why an application that declares minions cannot run under `profile` on `applicationDatabaseEngine`, or undefined when it\n * can (#2303).\n *\n * Under the DATABASE queue a minion takes its ticks from the application's shared queue table, where a plain table grant\n * would let it read and delete every queued job of its application; its RabbitMQ credential is confined to its own\n * queues. On PostgreSQL the same confinement is a row-level security policy (`deriveMinionDatabaseQueueConfinement`,\n * applied through the owed-grants contract), so minions run. MongoDB has no row-level security, so a MongoDB\n * application's minions are refused under that queue, at render and at boot, with the remedy named. Both refusals read\n * this one function.\n */\nexport function describeMinionsRefusedByEnvironmentServiceProfile(\n profile: EnvironmentServiceProfile,\n applicationDatabaseEngine: DatabaseEngine,\n): string | undefined {\n if (queueAdapterTypeOfEnvironmentServiceProfile(profile) !== QueueAdapterType.DATABASE) return undefined;\n switch (applicationDatabaseEngine) {\n case DatabaseEngine.POSTGRESQL:\n return undefined;\n case DatabaseEngine.MONGODB:\n return `This environment runs the '${profile}' service profile (\\`serviceProfile\\` in wildo.infra.<env>.config.ts), whose `\n + 'background work runs on the application\\'s own database instead of RabbitMQ, and the application persists to '\n + 'MongoDB, which cannot confine a minion to its own queues there (only PostgreSQL row-level security can). Remove the '\n + `minions from wildo.saas.config.ts, set applicationDatabase.engine to '${DatabaseEngine.POSTGRESQL}', or set `\n + `serviceProfile to '${EnvironmentServiceProfile.FULL}'.`;\n }\n}\n\n/** Whether `profile` omits `service`. Absent profile ⇒ {@link DEFAULT_ENVIRONMENT_SERVICE_PROFILE}. */\nexport function environmentServiceProfileOmits(\n profile: EnvironmentServiceProfile | undefined,\n service: EnvironmentServiceProfileOptionalService,\n): boolean {\n return servicesOmittedByEnvironmentServiceProfile(profile ?? DEFAULT_ENVIRONMENT_SERVICE_PROFILE).includes(service);\n}\n\n/**\n * The sentence every refusal caused by a profile starts with, so the CLI and the application's boot name\n * the profile and the omitted service the same way. Callers append the capability-specific remedy.\n */\nexport function describeServiceOmittedByEnvironmentServiceProfile(\n profile: EnvironmentServiceProfile,\n service: EnvironmentServiceProfileOptionalService,\n): string {\n return `This environment runs the '${profile}' service profile (\\`serviceProfile\\` in wildo.infra.<env>.config.ts), `\n + `which does not run ${service}.`;\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. It replaced a `baseDomain` field on this\n * object, which 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.\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: a substitute is never\n * asked because a call to the provider before it failed. Call-time failover is the SaaS-side\n * selection's own `failover` list (#2301), which this override does not carry and does not\n * replace: the application's declared failover providers stay in force under it.\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 * The second level is a protocol kind for what a RUNTIME reads, and may also be a key the provider MODULE owns and\n * reads itself: `registration`, the vendor-side settings its `vendorRegistration` builds from (a Slack app's slash\n * commands, a Teams package's version), read only by `wildo providers register` (#2661, #2663). No runtime reader\n * looks it up, since each reads its own protocol kind, so it travels unused beside them; it lives here so that an\n * environment can lay its own registration over the application's, like any other value.\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 // Never a provider module's own keys (#2995): an environment cannot rewrite where a provider sends its credential any\n // more than the application can. A local double is reached through the environment-gated loopback host instead. And\n // never a key the protocol's reader does not read (#3003), the same refusal the application's own block gets.\n).superRefine(refuseUnreadProviderConfigurationValues);\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 * Passed as `WILDO_DOCS_API_BASE_URL`, `WILDO_DOCS_APP_URL` and `WILDO_DOCS_FRONTEND_SERVICE_NAME` to the\n * documentation image's build and to the CI workflow, read from the loaded descriptor (#2310). They are build\n * inputs: no runtime environment carries them.\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,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,uCAAuC,EAAE,MAAM,sCAAsC,CAAC;AAC/F,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,CACJ,4BAA4B,EAC5B,wFAAwF,CACzF,CAAC;AAGJ;;;;;GAKG;AACH,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2DAAiC,CAAA;IACjC,mDAAyB,CAAA;AAC3B,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAED,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,oCAAe,CAAA;IACf,sCAAiB,CAAA;AACn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AC,CAAC,QAAQ,EAAE;CACzD,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { EngineCapability, QueueAdapterType } from '@wildo-ai/saas-models';\nimport { refuseUnreadProviderConfigurationValues } from '@wildo-ai/external-connectors-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 * Which set of OPTIONAL backing services an environment runs — the deployment footprint (#2303).\n *\n * An environment always runs the services the platform cannot live without (a database, a cache, a\n * broker, an object store). On top of those, the full platform runs three services that each back ONE\n * engine capability: ClamAV (antivirus scanning of uploaded files), immudb (the tamper-evident audit\n * store) and mongot (MongoDB Search / Vector Search). A small internal tool for one team rarely needs any\n * of them, and they are the heaviest containers in the stack (mongot alone is a JVM holding Lucene\n * indexes). A profile states, per environment, whether they run at all.\n *\n * ## Named \"service profile\", not \"runtime profile\"\n *\n * `ApplicationRuntimeProfile` (`@wildo-ai/saas-backend-lib`) already names WHICH RUNTIME boots the\n * application lifecycle (the backend or a minion). This vocabulary answers a different question, about\n * the ENVIRONMENT's footprint, and must not be confused with it.\n *\n * ## What a profile does NOT do\n *\n * It never degrades a capability in silence. Each capability that depends on a service the profile omits\n * is REFUSED at the application's boot when the application declares it, by a message naming the profile\n * and the remedy (`describeServiceOmittedByEnvironmentServiceProfile`). And a declaration that would run\n * an omitted service (`backingServices.clamav: { source: SELF }` under `SMALL`) is refused when the\n * environment descriptor is parsed: the two statements contradict each other.\n *\n * ## One database family\n *\n * `SMALL` also runs ONE database family (`environmentServiceProfileRunsOneDatabaseFamily`): the platform's store and\n * the application's are the same engine, and only that store is declared. Which engine is the author's choice (both a\n * MongoDB and a PostgreSQL environment run in one family); the descriptor derives the families it runs from what it\n * declares and refuses two, naming the declarations that bring each.\n *\n * ## Lanes\n *\n * Both lanes render a profile: the Docker Compose generator, and the Kubernetes manifests (workloads, the mongod\n * routing parameters, secrets, persistent volumes and readiness) since #2303's second slice.\n *\n * ## The queue\n *\n * `SMALL`'s background work runs on the application's own database (`QueueAdapterType.DATABASE`, selected by\n * `queueAdapterTypeOfEnvironmentServiceProfile`), and the platform scheduler delivers its occurrences to the backend over\n * HTTP rather than onto a broker. A minion is confined to its own queues there by a PostgreSQL row-level security policy;\n * MongoDB has none, so a MongoDB application's minions are refused under `SMALL` (`describeMinionsRefusedByEnvironmentServiceProfile`).\n *\n * ## No broker\n *\n * Since #2303 slice D a `SMALL` environment runs no RabbitMQ at all (`environmentServiceProfileRunsMessageBroker`): neither\n * lane renders it, no env file carries `RABBITMQ_*`, no runtime joins its network segment, and apps-manager (told through\n * `PLATFORM_ENVIRONMENT_SERVICE_PROFILE`) initializes no admin client and mints, revokes or restores no vhost or credential.\n * A `backingServices.rabbitmq` declaration beside it is refused.\n */\nexport enum EnvironmentServiceProfile {\n /** Every service the environment's declarations ask for. The default when nothing is authored. */\n FULL = 'full',\n /**\n * The footprint for a small deployment: no ClamAV, no immudb, no mongot\n * ({@link servicesOmittedByEnvironmentServiceProfile}), one database family, and background work on the application's\n * own database instead of RabbitMQ, which it does not run (minions only on PostgreSQL). Vector search remains available on PostgreSQL\n * (pgvector is part of the PostgreSQL image, not a separate service).\n */\n SMALL = 'small',\n}\n\n/** The profile an environment gets when it authors none. */\nexport const DEFAULT_ENVIRONMENT_SERVICE_PROFILE: EnvironmentServiceProfile = EnvironmentServiceProfile.FULL;\n\n/**\n * The optional services a {@link EnvironmentServiceProfile} can omit. A closed vocabulary of its own rather\n * than `BackingServiceKind`, because mongot is not a backing-service kind an environment declares: it is a\n * sidecar of a self-hosted MongoDB. Values are the compose service names.\n */\nexport enum EnvironmentServiceProfileOptionalService {\n /** The ClamAV daemon that scans uploaded files (`z_file({ scanPolicy: 'required' })`). */\n ANTIVIRUS_SCANNER = 'clamav',\n /** immudb, the tamper-evident store of the `COMPLIANCE_AUDIT_TRAIL` capability's Layer-2 fan-out. */\n IMMUTABLE_AUDIT_STORE = 'immudb',\n /** mongot, which serves `$search` / `$vectorSearch` for MongoDB-persisted `.ragSource()` fields. */\n MONGODB_SEARCH = 'mongot',\n}\n\n/**\n * The services a profile omits. Total over {@link EnvironmentServiceProfile} (a member added tomorrow fails\n * the build here until somebody decides what it omits), and the ONE place the answer lives: the compose\n * generator, the descriptor refinement and the application's boot refusals all read it.\n */\nexport function servicesOmittedByEnvironmentServiceProfile(\n profile: EnvironmentServiceProfile,\n): readonly EnvironmentServiceProfileOptionalService[] {\n switch (profile) {\n case EnvironmentServiceProfile.FULL:\n return [];\n case EnvironmentServiceProfile.SMALL:\n return [\n EnvironmentServiceProfileOptionalService.ANTIVIRUS_SCANNER,\n EnvironmentServiceProfileOptionalService.IMMUTABLE_AUDIT_STORE,\n EnvironmentServiceProfileOptionalService.MONGODB_SEARCH,\n ];\n }\n}\n\n/**\n * Whether `profile` requires the environment to run ONE database family (#2303). Total over\n * {@link EnvironmentServiceProfile}: a member added tomorrow fails the build until somebody decides.\n */\nexport function environmentServiceProfileRunsOneDatabaseFamily(profile: EnvironmentServiceProfile): boolean {\n switch (profile) {\n case EnvironmentServiceProfile.FULL:\n return false;\n case EnvironmentServiceProfile.SMALL:\n return true;\n }\n}\n\n/**\n * The queue an environment's application processes share (#2303), as its profile decides it. Total over\n * {@link EnvironmentServiceProfile}: a member added tomorrow fails the build until somebody decides.\n *\n * `FULL` runs RabbitMQ; `SMALL` exists to run without a broker, so its processes share the DATABASE queue, kept in\n * the application's own database (`QueueAdapterType.DATABASE`). Read by the application's container when it binds its\n * queue adapter, so the backend and its minions (which receive the same profile) always choose the same queue.\n *\n * Derived rather than authored: a separate `queueTransport` field beside `serviceProfile` was considered and rejected.\n * `FULL` with the database queue would run a broker nothing uses, and `SMALL` with RabbitMQ would defeat the profile's\n * purpose; neither has a use, and a second field would let them be declared.\n */\nexport function queueAdapterTypeOfEnvironmentServiceProfile(profile: EnvironmentServiceProfile): QueueAdapterType {\n switch (profile) {\n case EnvironmentServiceProfile.FULL:\n return QueueAdapterType.RABBITMQ;\n case EnvironmentServiceProfile.SMALL:\n return QueueAdapterType.DATABASE;\n }\n}\n\n/**\n * Whether an environment under `profile` runs a message broker at all (#2303 slice D). Derived from\n * {@link queueAdapterTypeOfEnvironmentServiceProfile}, never authored: the broker exists to carry the RabbitMQ queue, and\n * under the DATABASE queue nothing in the environment uses one (the platform scheduler delivers over HTTP). Absent profile\n * ⇒ {@link DEFAULT_ENVIRONMENT_SERVICE_PROFILE}.\n *\n * The ONE answer every broker decision reads: whether a deployment lane renders RabbitMQ, whether an env file carries\n * `RABBITMQ_*`, whether apps-manager initializes its RabbitMQ admin client and mints a vhost and credentials, and whether\n * a `backingServices.rabbitmq` declaration contradicts the profile. Total over the queue vocabulary through the switch\n * below, so a third queue adapter must decide here whether it needs a broker.\n */\nexport function environmentServiceProfileRunsMessageBroker(profile: EnvironmentServiceProfile | undefined): boolean {\n switch (queueAdapterTypeOfEnvironmentServiceProfile(profile ?? DEFAULT_ENVIRONMENT_SERVICE_PROFILE)) {\n case QueueAdapterType.RABBITMQ:\n return true;\n case QueueAdapterType.DATABASE:\n case QueueAdapterType.MEMORY:\n return false;\n }\n}\n\n/**\n * Why an application that declares minions cannot run under `profile` on `applicationDatabaseEngine`, or undefined when it\n * can (#2303).\n *\n * Under the DATABASE queue a minion takes its ticks from the application's shared queue table, where a plain table grant\n * would let it read and delete every queued job of its application; its RabbitMQ credential is confined to its own\n * queues. On PostgreSQL the same confinement is a row-level security policy (`deriveMinionDatabaseQueueConfinement`,\n * applied through the owed-grants contract), so minions run. MongoDB has no row-level security, so a MongoDB\n * application's minions are refused under that queue, at render and at boot, with the remedy named. Both refusals read\n * this one function.\n */\nexport function describeMinionsRefusedByEnvironmentServiceProfile(\n profile: EnvironmentServiceProfile,\n applicationDatabaseEngine: DatabaseEngine,\n): string | undefined {\n if (queueAdapterTypeOfEnvironmentServiceProfile(profile) !== QueueAdapterType.DATABASE) return undefined;\n switch (applicationDatabaseEngine) {\n case DatabaseEngine.POSTGRESQL:\n return undefined;\n case DatabaseEngine.MONGODB:\n return `This environment runs the '${profile}' service profile (\\`serviceProfile\\` in wildo.infra.<env>.config.ts), whose `\n + 'background work runs on the application\\'s own database instead of RabbitMQ, and the application persists to '\n + 'MongoDB, which cannot confine a minion to its own queues there (only PostgreSQL row-level security can). Remove the '\n + `minions from wildo.saas.config.ts, set applicationDatabase.engine to '${DatabaseEngine.POSTGRESQL}', or set `\n + `serviceProfile to '${EnvironmentServiceProfile.FULL}'.`;\n }\n}\n\n/** Whether `profile` omits `service`. Absent profile ⇒ {@link DEFAULT_ENVIRONMENT_SERVICE_PROFILE}. */\nexport function environmentServiceProfileOmits(\n profile: EnvironmentServiceProfile | undefined,\n service: EnvironmentServiceProfileOptionalService,\n): boolean {\n return servicesOmittedByEnvironmentServiceProfile(profile ?? DEFAULT_ENVIRONMENT_SERVICE_PROFILE).includes(service);\n}\n\n/**\n * The sentence every refusal caused by a profile starts with, so the CLI and the application's boot name\n * the profile and the omitted service the same way. Callers append the capability-specific remedy.\n */\nexport function describeServiceOmittedByEnvironmentServiceProfile(\n profile: EnvironmentServiceProfile,\n service: EnvironmentServiceProfileOptionalService,\n): string {\n return `This environment runs the '${profile}' service profile (\\`serviceProfile\\` in wildo.infra.<env>.config.ts), `\n + `which does not run ${service}.`;\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. It replaced a `baseDomain` field on this\n * object, which 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.\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: a substitute is never\n * asked because a call to the provider before it failed. Call-time failover is the SaaS-side\n * selection's own `failover` list (#2301), which this override does not carry and does not\n * replace: the application's declared failover providers stay in force under it.\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 * The second level is a protocol kind for what a RUNTIME reads, and may also be a key the provider MODULE owns and\n * reads itself: `registration`, the vendor-side settings its `vendorRegistration` builds from (a Slack app's slash\n * commands, a Teams package's version), read only by `wildo providers register` (#2661, #2663). No runtime reader\n * looks it up, since each reads its own protocol kind, so it travels unused beside them; it lives here so that an\n * environment can lay its own registration over the application's, like any other value.\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 // Never a provider module's own keys (#2995): an environment cannot rewrite where a provider sends its credential any\n // more than the application can. A local double is reached through the environment-gated loopback host instead. And\n // never a key the protocol's reader does not read (#3003), the same refusal the application's own block gets.\n).superRefine(refuseUnreadProviderConfigurationValues);\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 * Passed as `WILDO_DOCS_API_BASE_URL`, `WILDO_DOCS_APP_URL` and `WILDO_DOCS_FRONTEND_SERVICE_NAME` to the\n * documentation image's build and to the CI workflow, read from the loaded descriptor (#2310). They are build\n * inputs: no runtime environment carries them.\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"]}