@wildo-ai/wildo-cli 1.1.12 → 1.1.13
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.
- package/dist/src/commands/config/sync.command.d.ts.map +1 -1
- package/dist/src/commands/config/sync.command.js +1 -0
- package/dist/src/commands/config/sync.command.js.map +1 -1
- package/dist/src/commands/context/journey.command.d.ts.map +1 -1
- package/dist/src/commands/context/journey.command.js +8 -0
- package/dist/src/commands/context/journey.command.js.map +1 -1
- package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
- package/dist/src/commands/creation/drive.command.js +2 -0
- package/dist/src/commands/creation/drive.command.js.map +1 -1
- package/dist/src/commands/fwk/publish-all.command.d.ts.map +1 -1
- package/dist/src/commands/fwk/publish-all.command.js +8 -0
- package/dist/src/commands/fwk/publish-all.command.js.map +1 -1
- package/dist/src/commands/local/dev.command.d.ts +68 -0
- package/dist/src/commands/local/dev.command.d.ts.map +1 -1
- package/dist/src/commands/local/dev.command.js +216 -8
- package/dist/src/commands/local/dev.command.js.map +1 -1
- package/dist/src/commands/local/doctor.command.d.ts +22 -9
- package/dist/src/commands/local/doctor.command.d.ts.map +1 -1
- package/dist/src/commands/local/doctor.command.js +45 -42
- package/dist/src/commands/local/doctor.command.js.map +1 -1
- package/dist/src/commands/providers/connect.command.d.ts.map +1 -1
- package/dist/src/commands/providers/connect.command.js +11 -1
- package/dist/src/commands/providers/connect.command.js.map +1 -1
- package/dist/src/commands/seal/currency.command.d.ts +13 -0
- package/dist/src/commands/seal/currency.command.d.ts.map +1 -0
- package/dist/src/commands/seal/currency.command.js +52 -0
- package/dist/src/commands/seal/currency.command.js.map +1 -0
- package/dist/src/commands/seal/seal-admin-door.utils.d.ts.map +1 -1
- package/dist/src/commands/seal/seal-admin-door.utils.js +2 -0
- package/dist/src/commands/seal/seal-admin-door.utils.js.map +1 -1
- package/dist/src/commands/seal/verify.command.d.ts +5 -0
- package/dist/src/commands/seal/verify.command.d.ts.map +1 -1
- package/dist/src/commands/seal/verify.command.js +26 -2
- package/dist/src/commands/seal/verify.command.js.map +1 -1
- package/dist/src/services/application/content-guardrail-classifier.service.d.ts +19 -0
- package/dist/src/services/application/content-guardrail-classifier.service.d.ts.map +1 -1
- package/dist/src/services/application/content-guardrail-classifier.service.js +75 -11
- package/dist/src/services/application/content-guardrail-classifier.service.js.map +1 -1
- package/dist/src/services/application/local-provider-doubles.service.d.ts +98 -0
- package/dist/src/services/application/local-provider-doubles.service.d.ts.map +1 -0
- package/dist/src/services/application/local-provider-doubles.service.js +214 -0
- package/dist/src/services/application/local-provider-doubles.service.js.map +1 -0
- package/dist/src/services/application/system-of-record-simulators.service.d.ts +21 -2
- package/dist/src/services/application/system-of-record-simulators.service.d.ts.map +1 -1
- package/dist/src/services/application/system-of-record-simulators.service.js +21 -12
- package/dist/src/services/application/system-of-record-simulators.service.js.map +1 -1
- package/dist/src/services/companion/creation-drive.service.d.ts +32 -2
- package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
- package/dist/src/services/companion/creation-drive.service.js +61 -4
- package/dist/src/services/companion/creation-drive.service.js.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.d.ts +6 -0
- package/dist/src/services/credentials/credentials.schemas.d.ts.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.js +7 -1
- package/dist/src/services/credentials/credentials.schemas.js.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js +11 -3
- package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
- package/dist/src/services/data-services/data-services.schemas.d.ts +9 -0
- package/dist/src/services/data-services/data-services.schemas.d.ts.map +1 -1
- package/dist/src/services/data-services/data-services.schemas.js +9 -0
- package/dist/src/services/data-services/data-services.schemas.js.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js +7 -2
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.d.ts.map +1 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.js +22 -1
- package/dist/src/services/deployment/local-dev-session-lease.service.js.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.js +1 -0
- package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
- package/dist/src/services/environment/authored-infra-member-authority.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-member-authority.js +5 -0
- package/dist/src/services/environment/authored-infra-member-authority.js.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.js +6 -3
- package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts +6 -0
- package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.js +24 -1
- package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
- package/dist/src/services/environment/environment-hydration.utils.d.ts.map +1 -1
- package/dist/src/services/environment/environment-hydration.utils.js +1 -0
- package/dist/src/services/environment/environment-hydration.utils.js.map +1 -1
- package/dist/src/services/environment/environment.schemas.d.ts +7 -1
- package/dist/src/services/environment/environment.schemas.d.ts.map +1 -1
- package/dist/src/services/environment/environment.schemas.js.map +1 -1
- package/dist/src/services/environment/runtime-bootstrap.service.d.ts +2 -0
- package/dist/src/services/environment/runtime-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/environment/runtime-bootstrap.service.js +4 -0
- package/dist/src/services/environment/runtime-bootstrap.service.js.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.d.ts +13 -0
- package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.js +24 -7
- package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
- package/dist/src/services/registry/provider-connect.service.d.ts +57 -1
- package/dist/src/services/registry/provider-connect.service.d.ts.map +1 -1
- package/dist/src/services/registry/provider-connect.service.js +63 -2
- package/dist/src/services/registry/provider-connect.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/scripts/app-dependency-alignment/propagated-engine-overrides.json +1 -1
- package/wildo-framework.info.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-vars-builder.service.js","sourceRoot":"","sources":["../../../../src/services/environment/env-vars-builder.service.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,wFAAwF;AACxF,OAAO,EAAE,eAAe,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EACL,eAAe,EAGf,kBAAkB,EAClB,oBAAoB,EACpB,kCAAkC,EAElC,cAAc,EACd,gCAAgC,EAChC,uBAAuB,EACvB,0BAA0B,EAC1B,sCAAsC,EACtC,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,gCAAgC,EAChC,oBAAoB,EACpB,2BAA2B,EAC3B,sBAAsB,EACtB,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,+BAA+B,EAC/B,eAAe,EACf,kCAAkC,EAKlC,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kCAAkC,EAClC,6BAA6B,EAC7B,oCAAoC,EACpC,gCAAgC,EAChC,iCAAiC,EACjC,mCAAmC,EACnC,+BAA+B,EAC/B,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACtB,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAElB,qCAAqC,EACrC,8BAA8B,EAC9B,oCAA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;YAED,KAAK,qBAAqB,CAAC,eAAe,CAAC,CAAC,CAAC;gBAC3C,0FAA0F;gBAC1F,2FAA2F;gBAC3F,6FAA6F;gBAC7F,0FAA0F;gBAC1F,wFAAwF;gBACxF,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBAChE,GAAG,CAAC,6BAA6B,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;gBAC5D,GAAG,CAAC,6BAA6B,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACpE,YAAY,CACV,GAAG,EACH,6BAA6B,CAAC,cAAc,EAC5C,MAAM,CAAC,eAAe,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,QAAQ,CAC7D,CAAC;gBACF,MAAM;YACR,CAAC;YAED,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,WAAW,GAAU,OAAO,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,gCAAgC,WAAW,EAAE,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// The one MongoDB connection-string grammar, shared with apps-manager (#2000). The CLI already loads this package\n// at startup (every command module is imported by the registry), so this adds no graph.\nimport { MongoDBProtocol, readMongoConnectionStringTarget } from '@wildo-ai/saas-backend-lib';\nimport {\n AppsManagerMode,\n type AppBootstrapCredentials,\n type BackingServicesEnvConfig,\n BackingServiceKind,\n BackingServiceSource,\n resolvePlatformObjectStorageBucket,\n type BootstrapPlatformService,\n DatabaseEngine,\n resolveApplicationDatabaseEngine,\n PLATFORM_MONGO_DATABASE,\n PLATFORM_POSTGRES_DATABASE,\n PLATFORM_POSTGRES_MAINTENANCE_DATABASE,\n PlatformAdminEnvKeys,\n PlatformIngressEnvKeys,\n PlatformInfrastructureEnvKeys,\n PlatformKubernetesEnvKeys,\n PlatformLoggingEnvKeys,\n PlatformObservabilityEnvKeys,\n PlatformProviderSelectionEnvKeys,\n PlatformEmailEnvKeys,\n PlatformOwnershipDnsEnvKeys,\n PlatformProcessEnvKeys,\n PlatformGoogleKmsKeyProtection,\n PlatformSecurityEnvKeys,\n PlatformServiceUrlEnvKeys,\n PlatformWildoServices,\n WildoDeploymentRuntime,\n WildoLocationType,\n ApplicationRuntimePrincipalKind,\n InfraCapability,\n resolveRuntimeBackingServiceAccess,\n type ApplicationRuntimePrincipal,\n type RuntimeAccessDeclaration,\n type RuntimeBackingServiceAccess,\n type WorkerHttp,\n buildRuntimeResponseVerificationKeySet,\n DEFAULT_ENVIRONMENT_SERVICE_PROFILE,\n} from '@wildo-ai/platform-config-lib';\nimport {\n ApplicationBackendBootstrapEnvKeys,\n ApplicationBackendDataEnvKeys,\n ApplicationBackendPlatformUrlEnvKeys,\n ApplicationBackendRuntimeEnvKeys,\n ApplicationWorkerBootstrapEnvKeys,\n ApplicationWorkerHttpSurfaceEnvKeys,\n ApplicationWorkerRuntimeEnvKeys,\n HttpServerEnvKey,\n PlatformRuntimeEndpointKey,\n REMOTE_EDGE_PROXY_HOPS,\n serializeRuntimeEndpointsRecord,\n wildoWorkerUrlEnvKey,\n} from '@wildo-ai/platform-core-shared';\nimport {\n BackgroundRuntimeType,\n PersistenceAdapter,\n RuntimeEnvironment,\n deriveSystemOfRecordEnabledEnvVarName,\n deriveSystemOfRecordEnvVarName,\n parseInboundEndpointSecretEnvVarName,\n parseSystemOfRecordEnvVarName,\n} from '@wildo-ai/saas-models';\nimport {\n getComposedProviderEntry,\n getComposedProviderSecretsCatalogue,\n type ProviderSecretsCatalogueEntry,\n} from '~wildo-cli/services/credentials/composed-provider-catalogue';\nimport {\n VALKEY_CREDENTIAL_ENV_KEYS,\n RABBITMQ_CREDENTIAL_ENV_KEYS,\n MINIO_CREDENTIAL_ENV_KEYS,\n POSTGRESQL_CREDENTIAL_ENV_KEYS,\n IMMUDB_CREDENTIAL_ENV_KEYS,\n} from '~wildo-cli/services/data-services/data-services.schemas';\nimport { EnvironmentLifecycle } from '~wildo-cli/services/environment/environment-lifecycle.service';\nimport { PlatformDataServicesUtils } from '~wildo-cli/services/data-services/data-services.service';\nimport { LISTEN_HOST } from '~wildo-cli/services/environment/platform-runtime.schemas';\nimport { PLATFORM_SERVICE_CATALOG } from '~wildo-cli/services/catalog/service-catalog.schemas';\nimport type { PlatformEnvConfigJson, PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport { resolveApplicationBackingServiceAddressing } from '~wildo-cli/services/environment/application-backing-service-addressing.utils';\nimport type { ResolvedAddresses, ResolvedServiceAddress } from '~wildo-cli/services/catalog/service-address-resolver.service';\nimport {\n getProviderSecretEnvBindings,\n getProviderSensitiveEnvKeys,\n platformTierAllProvidersScope,\n RuntimeProviderScopeKind,\n type RuntimeProviderScope,\n} from '~wildo-cli/services/credentials/provider-env-vars.utils';\n\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * VALUE CONTRACT — every builder in this file emits **RAW, UNENCODED** values.\n *\n * A builder returns the true value (a multi-line PEM keeps its real newlines and carries no\n * surrounding quotes). ENCODING BELONGS TO THE SERIALIZER, because the sinks disagree on it:\n *\n * - `writeEnvFile` / `generateProviderSecretsEnvFile` → dotenv escaping (`encodeDotenvValue`);\n * - `formatEnvFile` (ci-deploy artifacts) → its own quote + `\\n` escaping;\n * - the k8s secrets generator → RAW (the value is base64'd verbatim into a `Secret`);\n * - the compose `.env.wildo-platform` writer → `encodeComposeEnvValue` (quote-if-multiline),\n * which keeps that file's historical bytes.\n *\n * A `quoteMultiline()` helper used to bake double quotes into the VALUES here. That was wrong in\n * both directions and produced two live defects: the immudb SPKI PEM injected by\n * {@link resolveRuntimeProviderEnv} was NOT quoted, so a bare `key=value` split it across physical\n * lines and dotenv truncated it to `-----BEGIN PUBLIC KEY-----` (the audit client then failed to\n * parse its pinned key and reported a FALSE \"TAMPER DETECTED\"); and the platform JWT PEMs that WERE\n * quoted carried those literal quotes into k8s `Secret` values, which are not dotenv-parsed.\n *\n * Do not reintroduce per-value quoting here. Add the encoding to the serializer that needs it.\n */\nfunction setIfDefined(env: Record<string, string>, key: string, value: string | number | undefined | null): void {\n if (value != null) {\n env[key] = String(value);\n }\n}\n\ndeclare const scopedProviderEnvBrand: unique symbol;\n\n/**\n * A `providerEnv` bag that has already passed through a runtime's declared scope.\n *\n * ## Why a BRAND rather than a convention (issue #360)\n *\n * The confinement invariant — \"a runtime receives only the providers its scope declares\" — has\n * TWO delivery paths in this file, not one: the per-key fan-out loop, and the OTLP auth header\n * composed by {@link resolveOtlpAuthHeader}. `filterProviderEnvToScope` covered the first. The\n * second took `credentials.providerEnv` verbatim, so a worker built with `declaredProviderScope([])`\n * correctly received no `BETTERSTACK_SOURCE_TOKEN` and then received that same token inside\n * `OTEL_EXPORTER_OTLP_HEADERS`. Reproduced 2026-09-06.\n *\n * Applying the filter a second time by hand would fix the two sites that exist and leave the\n * third to whoever writes it. `.claude/rules/invariant-call-site-enumeration.md` asks for the\n * unbypassable form where one is available, and here one is: the only producer of this type is\n * {@link resolveRuntimeProviderEnv}, so passing an unscoped bag is a COMPILE error rather than a\n * review question. There is no runtime cost and no runtime representation — the brand is a\n * `declare`d symbol that never exists.\n *\n * **Be exact about how far that reaches, because a comment claiming more protection than exists is\n * worse than none.** A parameter type guards the parameters that declare it, and today those are\n * exactly two: {@link emitObservabilityEnv}'s `telemetryProvider.providerEnv` and\n * {@link resolveOtlpAuthHeader}'s — the OTLP header path, which is what #360 was. The per-key\n * fan-out loops take a plain `Record<string, string>` and are correct for a different reason: they\n * iterate the value {@link resolveRuntimeProviderEnv} returned, in the same statement block.\n *\n * So this type does NOT make every future credential emitter safe by itself. **If you add one, give\n * its provider-env parameter this type** — that is the one line that puts it inside the guard, and\n * the reason the type is worth having is that it makes doing so free rather than a judgement call.\n *\n * The brand key is a `unique symbol`, which is what lets it coexist with the `string` index\n * signature: a string index signature does not constrain symbol-keyed members, so\n * `Object.entries`, `bag[name]` and spread all keep working on the branded type.\n */\ntype ScopedProviderEnv = Record<string, string> & { readonly [scopedProviderEnvBrand]: true };\n\n/**\n * Resolve the effective provider-env for a backend RUNTIME: the operator-authored\n * `credentials.providerEnv` PLUS framework-generated provider material that is not\n * operator-typed. Today that is exactly the immudb state-signing PUBLIC key.\n *\n * The audit client pins `IMMUDB_STATE_PUBLIC_KEY` to cryptographically detect a whole-server\n * substitution (a fresh immudb presenting a new uuid). That key is generated at `wildo setup`\n * (`credentials.immudb.stateSigningPublicKey`), never operator-typed, so it does not live in\n * the authored providerEnv — it is injected here, at runtime-env build time, so it always\n * reflects the current secrets.json regardless of when immudb was configured. Injection is\n * gated on the immudb audit provider actually being configured (its connection host is present\n * in providerEnv) so an env that does not use immudb carries no stray pinning key. The PRIVATE\n * half is deliberately absent from this map — it goes to the SELF-hosted immudb server only.\n *\n * Returns a fresh record (never mutates `credentials.providerEnv`).\n */\nfunction resolveRuntimeProviderEnv(\n credentials: PlatformEnvSecretsJson,\n /**\n * What this runtime is entitled to, as a decision rather than an absence — see\n * {@link RuntimeProviderScope} for why \"not stated\" is deliberately unrepresentable.\n *\n * Required, and positional rather than a field on an options bag, so the choice is visible and\n * MANDATORY at every call site. An optional field is how the whole provider bag got handed to\n * every application runtime in the first place, and then how the whole bag got taken away from\n * all of them: nobody had to decide, so nobody did.\n */\n scope: RuntimeProviderScope,\n): ScopedProviderEnv {\n const providerEnv: Record<string, string> = { ...(credentials.providerEnv ?? {}) };\n const statePublicKey = credentials.immudb?.stateSigningPublicKey;\n const immudbProviderConfigured = providerEnv[IMMUDB_CREDENTIAL_ENV_KEYS.PROVIDER.HOST] != null;\n if (\n statePublicKey &&\n immudbProviderConfigured &&\n providerEnv[IMMUDB_CREDENTIAL_ENV_KEYS.PROVIDER.STATE_PUBLIC_KEY] == null\n ) {\n providerEnv[IMMUDB_CREDENTIAL_ENV_KEYS.PROVIDER.STATE_PUBLIC_KEY] = statePublicKey;\n }\n\n // The two `as ScopedProviderEnv` casts are the ONLY place the brand is minted, which is what\n // makes the type meaningful: everything downstream receives a bag whose scope was decided here.\n if (scope.kind === RuntimeProviderScopeKind.PLATFORM_TIER_ALL_PROVIDERS) {\n return providerEnv as ScopedProviderEnv;\n }\n return filterProviderEnvToScope(providerEnv, scope.providerRefs) as ScopedProviderEnv;\n}\n\n/**\n * The remedy every dropped-key warning names. `wildo secrets list` reports such a key as UNUSED and the\n * workbench's Secrets section offers its removal, so the warning points somewhere a key can be removed\n * rather than at a JSON file (#1637).\n */\nconst REMOVE_UNUSED_SECRET_HINT = 'Remove it with `wildo secrets unset <NAME>` (the workbench\\'s Secrets section lists it as unused).';\n\n/** When this process last reported each `section:key` as dropped. */\nconst reportedDroppedSecretKeys = new Map<string, number>();\n\n/**\n * How long a dropped key stays reported. One `config sync` builds every runtime's env within seconds, and the\n * same orphan was reported once PER runtime — five keys became a screenful on every regeneration (#1637). A\n * window rather than \"once per process\" keeps a long-lived builder (the dev loop) reporting a key that is\n * still there an hour later, or that was removed and added back.\n */\nconst DROPPED_KEY_REPORT_WINDOW_MS = 10 * 60_000;\n\n/**\n * The keys of `dropped` not reported inside the window. The drop itself still happens for every runtime; only\n * the repetition of the finding goes.\n */\nfunction firstDropReport(section: string, dropped: readonly string[]): string[] {\n const nowMs = Date.now();\n const fresh = dropped.filter((key) => nowMs - (reportedDroppedSecretKeys.get(`${section}:${key}`) ?? -Infinity) >= DROPPED_KEY_REPORT_WINDOW_MS);\n for (const key of fresh) reportedDroppedSecretKeys.set(`${section}:${key}`, nowMs);\n return fresh;\n}\n\n/**\n * Drop every provider SECRET that the runtime's declared scope does not cover.\n *\n * ## The gap this closes\n *\n * `providers.scopes.{minions,workers}.<name>` has always declared which providers\n * a runtime may use, and that declaration was faithfully materialised into the\n * runtime topology artifact — while the SECRETS ignored it entirely. A minion\n * scoped to `openai` alone still received `STRIPE_SECRET_KEY`,\n * `STRIPE_WEBHOOK_SECRET`, `RESEND_API_KEY` and every other provider key, because\n * the whole `providerEnv` bag was copied verbatim into its environment. A worker\n * declaring `providers: {}` received them too.\n *\n * That is the provider-credential analogue of handing every workload the object\n * store's root key: an authored boundary the credential layer never read. It is\n * NOT mitigated by the container security floor — these live in the process\n * environment, which is exactly what LLM-driven minion code can read.\n *\n * ## Attribution comes from the COMPOSED catalogue, and an unattributable key is DROPPED\n *\n * Both halves of this filter used to read `EngineBackendProviderRegistry`, and both were wrong\n * the moment a provider could ship as its own package (#329, audit finding PL-3):\n *\n * - the ALLOW-LIST could not resolve a package provider's contract, so a runtime that legitimately\n * declared one would have had its credential stripped;\n * - the ATTRIBUTION set could not see that provider's keys either, so — by the rule this comment\n * used to state, that an unattributable key is \"configuration rather than a provider secret\" —\n * the key was KEPT and copied into every worker and minion environment. Silently. That inverts\n * the confinement into a leak precisely for the tier the confinement matters most for.\n *\n * So attribution now derives from {@link getComposedProviderSecretsCatalogue}, and a `DECLARED`\n * scope drops what it cannot attribute instead of keeping it. That is what the scope means:\n * exactly the providers this runtime authors, and nothing else. `providerEnv` is the\n * provider-secret bag, not a general config bag — the framework's own writers only ever put\n * attributable keys in it (`wildo setup` prompts straight off the secret contracts, and\n * {@link resolveRuntimeProviderEnv} injects one key that immudb's contract declares), and a\n * provider whose configuration is a hostname or a database name puts THAT in its contract too:\n * immudb and odoo both do.\n *\n * Measured before the trade was reversed: the live `providerEnv` of both dogfood applications\n * holds 13 keys and every one is attributable to an engine provider's contract, so failing\n * closed drops nothing today. The remaining writer that can produce an unattributable key is the\n * CI convention `WILDO_SECRET_PROVIDER_ENV_<NAME>`, which is open-ended — and is exactly the\n * vector this issue exists to close.\n *\n * The drop is REPORTED, never silent: a refusal nobody can see is the failure mode this whole\n * slice is about. `PLATFORM_TIER_ALL_PROVIDERS` is untouched — it receives everything by\n * deliberate declaration.\n */\nfunction filterProviderEnvToScope(\n providerEnv: Record<string, string>,\n scopedProviderRefs: readonly string[],\n): Record<string, string> {\n const allowedKeys = new Set<string>();\n for (const providerRef of scopedProviderRefs) {\n const entry = getComposedProviderEntry(providerRef);\n for (const secret of entry?.secrets ?? []) allowedKeys.add(secret.envVarName);\n for (const binding of getProviderSecretEnvBindings(providerRef)) allowedKeys.add(binding.envVarName);\n }\n\n const attributableKeys = getProviderSensitiveEnvKeys();\n const scoped: Record<string, string> = {};\n const unattributable: string[] = [];\n for (const [key, value] of Object.entries(providerEnv)) {\n if (allowedKeys.has(key)) {\n scoped[key] = value;\n continue;\n }\n if (!attributableKeys.has(key)) unattributable.push(key);\n }\n\n const newlyUnattributable = firstDropReport('providerEnv', unattributable);\n if (newlyUnattributable.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `[env-builder] ${newlyUnattributable.length} key(s) in providerEnv belong to no provider the CLI `\n + `can see, so every runtime that declares its providers drops them (first seen for one scoped to `\n + `[${scopedProviderRefs.join(', ') || 'no provider'}]); only the dev companion, which receives every provider key, `\n + `still carries them: ${newlyUnattributable.join(', ')}. `\n + 'A provider-secret key is delivered by declaring the provider (so its secrets contract is '\n + 'discoverable); anything that is not a provider secret does not belong in providerEnv. '\n + REMOVE_UNUSED_SECRET_HINT,\n );\n }\n\n return scoped;\n}\n\n/**\n * Every `WILDO_SOR_*` variable ONE runtime should receive, derived from the environment's authored\n * addresses and the operator's secrets (#1055 §2).\n *\n * ## Derived, so nothing authors a variable name\n *\n * The address half comes from `config.systemsOfRecord.<name>.address`, keyed by the facet's slot\n * slugs; the secret half is already keyed by the derived name in `secrets.json`. One function owns\n * the naming (`deriveSystemOfRecordEnvVarName`, exported from saas-models), which is what stops the\n * env writer, the k8s secrets generator, the CI collector and the backend registry from each\n * inventing their own spelling of the same variable.\n *\n * ## `ENABLED=false` is a DECLARATION, not the absence of one\n *\n * An environment with no access to the instance authors `{ enabled: false }` and gets\n * `WILDO_SOR_<NAME>__ENABLED=false`. The backend reads its PRESENCE as \"declared absent\" and boots,\n * refusing reads with a stable code; the different case — no marker and no address — is an\n * environment that simply forgot, and that refuses. The two need opposite behaviours, so they need\n * to be distinguishable, so silence cannot be either one (#1055 E3/E4, R6).\n *\n * ## An undeclared instance's secret is DROPPED, with a warning\n *\n * Same trade as `filterProviderEnvToScope` one function up, and for a stronger reason here: a secret\n * keyed for an instance the application does not declare cannot be reached by anything, so\n * delivering it only widens what a compromised runtime holds. The key is parsed back into its\n * `(instance, slot)` pair — which is what the `__` delimiter exists to make possible — and warned\n * about rather than dropped in silence, because a typo in an instance name would otherwise look\n * exactly like a credential that simply never arrived.\n */\nfunction resolveSystemsOfRecordEnv(\n config: PlatformEnvConfigJson,\n credentials: PlatformEnvSecretsJson,\n): Record<string, string> {\n const declaredInstances = config.systemsOfRecord ?? {};\n const env: Record<string, string> = {};\n\n for (const [instanceName, entry] of Object.entries(declaredInstances)) {\n if ('enabled' in entry) {\n env[deriveSystemOfRecordEnabledEnvVarName(instanceName)] = String(entry.enabled);\n continue;\n }\n for (const [slotSlug, value] of Object.entries(entry.address)) {\n env[deriveSystemOfRecordEnvVarName(instanceName, slotSlug)] = value;\n }\n }\n\n const undeliverable: string[] = [];\n for (const [envVarName, value] of Object.entries(credentials.systemsOfRecordEnv ?? {})) {\n const parts = parseSystemOfRecordEnvVarName(envVarName);\n if (parts && declaredInstances[parts.instanceName] !== undefined) {\n env[envVarName] = value;\n continue;\n }\n undeliverable.push(envVarName);\n }\n\n const newlyUndeliverable = firstDropReport('systemsOfRecordEnv', undeliverable);\n if (newlyUndeliverable.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `[env-builder] ${newlyUndeliverable.length} key(s) in systemsOfRecordEnv name no system of record this `\n + `environment declares and were dropped: ${newlyUndeliverable.join(', ')}. `\n + `Declared here: [${Object.keys(declaredInstances).join(', ') || 'none'}]. `\n + 'A credential is delivered by declaring its instance in `systemsOfRecord` and giving it an '\n + 'address in this environment; a key naming anything else reaches no runtime. If nothing should read it, '\n + 'remove it with `wildo secrets unset <NAME>` (one naming no declared instance is listed there as unused).',\n );\n }\n\n return env;\n}\n\n/**\n * The verification secrets of the application's inbound endpoints (#1596), delivered under the names the\n * backend reads them by (`WILDO_INBOUND_<ENDPOINT_KEY>__SECRET`).\n *\n * A key that is not such a name is DROPPED with a warning, for the reason {@link resolveSystemsOfRecordEnv}\n * gives: nothing reads it, so delivering it only widens what a compromised runtime holds, and a typo must\n * not look exactly like a secret that never arrived. Which endpoints the application declares is known only\n * to its backend code, so an unused-but-well-formed key is delivered; the backend is where an endpoint\n * without its secret is reported (the route is withheld and the log names the variable).\n */\nfunction resolveInboundEndpointEnv(credentials: PlatformEnvSecretsJson): Record<string, string> {\n const env: Record<string, string> = {};\n const undeliverable: string[] = [];\n for (const [envVarName, value] of Object.entries(credentials.inboundEndpointEnv ?? {})) {\n if (parseInboundEndpointSecretEnvVarName(envVarName)) env[envVarName] = value;\n else undeliverable.push(envVarName);\n }\n const newlyUndeliverable = firstDropReport('inboundEndpointEnv', undeliverable);\n if (newlyUndeliverable.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `[env-builder] ${newlyUndeliverable.length} key(s) in inboundEndpointEnv are not inbound endpoint secret names and were dropped: `\n + `${newlyUndeliverable.join(', ')}. A key is WILDO_INBOUND_<ENDPOINT_KEY>__SECRET, derived from the endpoint key `\n + '(`todo-intake` → WILDO_INBOUND_TODO_INTAKE__SECRET). '\n + REMOVE_UNUSED_SECRET_HINT,\n );\n }\n return env;\n}\n\n/** Refuse an inbound endpoint secret in an env that is not the application BACKEND's (#1596). */\nfunction assertNoInboundEndpointEnvInGeneratedEnv(env: Record<string, string>, builderName: string): void {\n const leaked = Object.keys(env).filter((key) => parseInboundEndpointSecretEnvVarName(key) !== null);\n if (leaked.length === 0) return;\n throw new Error(\n `[${builderName}] ${leaked.length} inbound endpoint secret(s) reached a runtime that must not have them: `\n + `${leaked.join(', ')}. Only the application backend mounts inbound endpoints (#1596).`,\n );\n}\n\n/**\n * Refuse a system-of-record variable in an env that is not the application BACKEND's (#1055 D2, R7).\n *\n * Mirrors {@link assertNoPlatformCredentialInGeneratedEnv}, and sits at the RETURN of each builder\n * for the same reason: a check placed beside the removal only proves that one line stayed deleted,\n * while this one catches an instance credential arriving through any path, named anything.\n *\n * \"Nothing\" is not the default here — minions and workers DO receive provider keys today, through\n * several builders, and this section escapes `filterProviderEnvToScope` entirely because a system of\n * record is not a provider. So the exclusion has to be stated, and stated where it cannot be\n * bypassed by a new delegating caller.\n */\nfunction assertNoSystemOfRecordEnvInGeneratedEnv(env: Record<string, string>, builderName: string): void {\n const leaked = Object.keys(env).filter((key) => parseSystemOfRecordEnvVarName(key) !== null);\n if (leaked.length === 0) return;\n throw new Error(\n `[${builderName}] ${leaked.length} system-of-record variable(s) reached a runtime that must not have them: `\n + `${leaked.join(', ')}. A system of record is read by the application BACKEND and by nothing else `\n + '(#1055 D2) — its address and credential are delivered to that runtime alone.',\n );\n}\n\n/**\n * Project the authored `infra.logging.*` block onto the runtime env-var\n * surface for any long-running platform/application process (Slice 3.5).\n *\n * Both keys are emitted only when the author explicitly set them — the\n * field is `.optional()` on `WildoLoggingConfigSchema`, so missing\n * authoring leaves `LoggerService.loadConfiguration` on its built-in\n * defaults (level `debug`, pino-pretty auto-detect by `APPLICATION_ENV`).\n *\n * The `LOG_LEVEL` enum is validated upstream by `WildoLoggingConfigSchema`\n * (`debug | info | warn | error`), so a corrupt value can never reach\n * this projection.\n */\nfunction emitLoggingEnv(\n env: Record<string, string>,\n logging: PlatformEnvConfigJson['logging'] | undefined,\n): void {\n if (!logging) return;\n setIfDefined(env, PlatformLoggingEnvKeys.LOG_LEVEL, logging.level);\n if (logging.formattedConsoleErrors !== undefined) {\n env[PlatformLoggingEnvKeys.LOG_FORMATTED_CONSOLE_ERRORS] = String(logging.formattedConsoleErrors);\n }\n}\n\n/**\n * Project the authored `infra.providerSelection` block onto the backend\n * runtime env-var surface as a single serialized JSON payload\n * (`WILDO_PROVIDER_SELECTION_OVERRIDES`) — mirroring how a structured payload\n * rides in one env var (`APPLICATION_RUNTIME_ENDPOINTS`). Emitted ONLY when the\n * author set at least one override; absent authoring leaves\n * `ExternalProvidersRegistryBackendService` on the app-wide\n * `wildo.saas.config.ts` selection. The shape is validated upstream by\n * `WildoProviderSelectionOverridesSchema`, so a corrupt value can never reach\n * this projection; the backend reader tolerates a malformed value defensively\n * regardless.\n */\nfunction emitProviderSelectionEnv(\n env: Record<string, string>,\n providerSelection: PlatformEnvConfigJson['providerSelection'] | undefined,\n): void {\n if (!providerSelection || Object.keys(providerSelection).length === 0) return;\n env[PlatformProviderSelectionEnvKeys.WILDO_PROVIDER_SELECTION_OVERRIDES] = JSON.stringify(providerSelection);\n}\n\n/**\n * Project the authored `infra.email` block onto an APPLICATION runtime's env surface: today the shared receiving\n * domain (`WILDO_INBOUND_EMAIL_SHARED_DOMAIN`), which the backend's inbound services prefer over the backend\n * configuration's `email.inbound.sharedDomain` (`resolveInboundEmailConfig`).\n *\n * Emitted only when authored, like the documentation-site values: an absent key is the plain statement of \"no override\"\n * (the backend also reads an empty value that way, `resolveInboundEmailConfig`, but writing one would put a meaningless\n * line in every `.env`). Called for the application backend (whose env each minion\n * inherits) and the application worker — the runtimes that receive mail or address an organization's mail — and\n * deliberately not for platform services or the companion, which do neither.\n */\nfunction emitEmailEnv(\n env: Record<string, string>,\n email: PlatformEnvConfigJson['email'] | undefined,\n): void {\n const sharedDomain = email?.inbound?.sharedDomain;\n if (sharedDomain) env[PlatformEmailEnvKeys.WILDO_INBOUND_EMAIL_SHARED_DOMAIN] = sharedDomain;\n}\n\n/**\n * Project the LOCAL-ONLY `infra.ownershipDnsStandIn` onto the application backend's env surface (#2519): the double that\n * answers domain-ownership challenges for names nobody can publish. Emitted only when authored — absent is \"public DNS\",\n * and the infra schema refuses it outside a local environment. Called for the application backend alone, the runtime\n * that serves the domain-ownership doors (its minions inherit the env and never ask).\n */\nfunction emitOwnershipDnsStandInEnv(\n env: Record<string, string>,\n ownershipDnsStandIn: PlatformEnvConfigJson['ownershipDnsStandIn'] | undefined,\n): void {\n if (ownershipDnsStandIn?.baseUrl) env[PlatformOwnershipDnsEnvKeys.WILDO_OWNERSHIP_DNS_STAND_IN_URL] = ownershipDnsStandIn.baseUrl;\n}\n\n/**\n * Emit the platform-standard MongoDB connection env trio (`MONGO_CONNECT_URL`, `MONGO_PLATFORM_URL`,\n * `BASE_MONGO_SERVER_URL`) onto a platform-service env map. The URL is the Atlas `connectionUrl` for a\n * MANAGED + `atlas` source, else built from the resolved local mongodb address + root credentials\n * against `PLATFORM_MONGO_DATABASE`. Shared by every platform service that opens the PLATFORM_MANAGEMENT\n * connection: apps-manager, the companion, and the bootstrap services that use the framework's\n * `StartApplicationBackendService` (module-registry) — previously this identical block was duplicated\n * across all three builders.\n */\n/**\n * Does this environment PROVIDE a MongoDB at all — as opposed to merely having an address for one?\n *\n * `addresses.infra.mongodb` answers the second question, and answers it for EVERY environment: the\n * resolver hands out a default address whether or not anything renders a server there. Harmless\n * while a mongod was mandatory; a live defect the moment it stopped being, because both env\n * emitters keyed off the address and so wrote a confident `mongodb://…:27017/…` for a container no\n * transport renders.\n *\n * ONE spelling for both emitters, deliberately. The platform emitter was fixed first and the\n * application emitter was not — which is how `wonder-crm` (PostgreSQL on both planes, no\n * `.ragSource()` field, no Mongo-pinned resource) still received `MONGODB_HOST` and spent its boot\n * dialling 127.0.0.1:27017. An invariant applied at one of its call sites is applied at none of the\n * others.\n *\n * The union mirrors `EnvironmentLifecycle.needsLocalMongoDB` — which decides whether a mongod is\n * RENDERED — and adds the two externally-hosted shapes, because a server we do not render is still\n * a server we can reach.\n */\nfunction environmentProvidesMongoDb(config: PlatformEnvConfigJson): boolean {\n if (config.database.source === BackingServiceSource.MANAGED && config.database.provider === 'atlas') return true;\n if (config.externalEndpoints?.mongodb?.connectionUrl) return true;\n if (config.database.engine === DatabaseEngine.MONGODB && config.database.source === BackingServiceSource.SELF) return true;\n return config.backingServices?.[BackingServiceKind.MONGODB] !== undefined;\n}\n\nfunction emitPlatformMongoEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n): void {\n const isAtlas = config.database.source === BackingServiceSource.MANAGED\n && config.database.provider === 'atlas';\n /**\n * Is a mongod actually REACHABLE for this environment — as opposed to merely ADDRESSABLE?\n *\n * `addresses.infra.mongodb` answers the second question and was, until 2026-08-28, the only gate\n * here: the resolver hands out a default address whether or not anything renders a server at it.\n * That was harmless while a mongod was mandatory, and became the live defect the moment it stopped\n * being — generation would emit a confident `mongodb://…:27017/…` for a container no transport\n * renders, and the boot would hang on it long after the real mistake. (The retired\n * `backingServices.mongodb` refusal in this file existed for exactly that trap; the trap is real,\n * so the answer is to emit honestly rather than to demand a mongod.)\n *\n * The UNION below deliberately mirrors `EnvironmentLifecycle.needsLocalMongoDB` — the predicate\n * that decides whether a mongod is RENDERED — plus the Atlas case, whose server is external. Only\n * the authored half was checked at first, and two pre-existing pins caught it immediately: a\n * platform whose OWN engine is self-hosted MongoDB renders a mongod without any\n * `backingServices.mongodb` entry, and would have been handed an empty URL for a server that is\n * definitely there.\n */\n const mongoIsDeclared = environmentProvidesMongoDb(config);\n const mongoConnectUrl = isAtlas\n ? (config.externalEndpoints?.mongodb?.connectionUrl ?? '')\n : mongoIsDeclared && addresses.infra.mongodb\n ? PlatformDataServicesUtils.buildMongoConnectionUrlFromAddress(\n addresses.infra.mongodb,\n {\n user: credentials.mongodb?.rootUser ?? '',\n password: credentials.mongodb?.rootPassword ?? '',\n },\n {\n databaseName: PLATFORM_MONGO_DATABASE,\n directConnection: environment.locationType === WildoLocationType.LOCAL,\n },\n )\n : '';\n env[PlatformInfrastructureEnvKeys.MONGO_CONNECT_URL] = mongoConnectUrl;\n env[PlatformInfrastructureEnvKeys.MONGO_PLATFORM_URL] = mongoConnectUrl;\n env[PlatformInfrastructureEnvKeys.BASE_MONGO_SERVER_URL] = mongoIsDeclared && addresses.infra.mongodb\n ? `${addresses.infra.mongodb.host}:${addresses.infra.mongodb.port}`\n : '';\n}\n\n/**\n * Emit the platform's OWN PostgreSQL connection env (`PG_CONNECT_URL` + the\n * `DATABASE_DEFAULT_ADAPTER` selection) — the PostgreSQL mirror of {@link emitPlatformMongoEnv},\n * for a platform whose `database.engine === POSTGRESQL` (Phase 5.3, D7).\n *\n * A NO-OP on every Mongo-engined environment: neither key is written, so `.env` material for\n * existing deployments is byte-identical. Note the gate is the platform ENGINE, deliberately NOT\n * `shouldProvisionPostgreSQL`'s union — an app-authored `backingServices.postgresql: SELF` on a\n * Mongo platform means PostgreSQL exists for an APPLICATION's resources, and handing the\n * PLATFORM a connect URL (let alone flipping its default adapter) for someone else's database\n * would be exactly the conflation the union predicate's two halves exist to keep apart.\n *\n * The URL targets the container's own initdb database (`infrastructure.postgresql.database`,\n * default `wildo_platform` — see the compose template's `POSTGRES_DB`), which exists by\n * construction; PostgreSQL does not create databases on connect, so pointing anywhere else\n * would require an init step the platform deliberately does not have.\n *\n * Site enumeration (invariant-call-site rule): of the three `emitPlatformMongoEnv` callers,\n * apps-manager AND module-registry call this (both carry the pre-connect + construction-time\n * adapter wiring — 5.3 and 5.6 respectively, and they MUST agree or a flipped platform splits\n * shared resources across services).\n *\n * THE COMPANION IS NOW THE THIRD CALLER (2026-08-28, issue #94). It was a deliberate N/A on\n * exactly the right grounds — \"it opens only the Mongo platform connection, and emitting an\n * adapter selection its startup cannot honor would be a lie in the env file\" — and that\n * refusal was correct for as long as it was true. The companion's startup now derives its\n * adapter from `DATABASE_DEFAULT_ADAPTER` and pre-connects PostgreSQL from `PG_CONNECT_URL`,\n * so the keys are honored rather than ignored and withholding them is what would now lie:\n * the companion would silently read platform rows from a Mongo database the platform stopped\n * using, and report every application as unregistered.\n *\n * Note the ORDER this was fixed in, because it is the general rule: the runtime learns to\n * honor a key BEFORE the generator emits it. Emitting first would have produced an env file\n * that looks correct and changes nothing.\n */\nfunction emitPlatformPostgresEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n): void {\n if (config.database.engine !== DatabaseEngine.POSTGRESQL) return;\n\n /**\n * RETIRED 2026-08-28, with its schema-side twin in `define-infra-env-config.ts` — see that file\n * for the full account. In short: this refused a PostgreSQL platform rendering no mongod because\n * `MONGO_CONNECT_URL` was an unconditionally REQUIRED key on the apps-manager env schema. It is\n * now engine-conditional (empty means absent, exactly as `PG_CONNECT_URL` has always been), and\n * the two reasons the refusal actually cited — the six MONGODB-pinned bootstrap resources, and a\n * Mongo-only crontabs-batches-manager — were both already gone when it was still refusing.\n *\n * What replaces it is weaker and truer: a platform must render AT LEAST ONE store. That check\n * lives on the env schema, beside the keys it is about, rather than here — a generator cannot see\n * a hand-authored env, and the schema refuses both.\n */\n\n const isManaged = config.database.source === BackingServiceSource.MANAGED;\n if (isManaged && !config.externalEndpoints?.postgresql?.connectionUrl) {\n // The Atlas-mirror slot is the ONLY channel for a managed endpoint, and it has no wizard\n // authoring path yet — emitting an empty URL here would surface as an opaque \"Invalid URL\"\n // at boot-time env validation, three layers from the cause (5.3 review F3).\n throw new Error(\n 'database.engine is POSTGRESQL with source MANAGED, but `externalEndpoints.postgresql.connectionUrl` '\n + 'is not set in the environment config. Add the managed endpoint URL '\n + '(externalEndpoints.postgresql: { connectionUrl: \"postgresql://...\" }) and re-run `wildo config sync`.',\n );\n }\n if (!isManaged && !addresses.infra.postgresql) {\n // Believed unreachable: a POSTGRESQL-engined SELF platform always resolves the postgres\n // address (the `needsLocalPostgreSQL` union includes the engine half, and the remote\n // resolvers throw earlier on missing infra). Asserted rather than silently emitting an empty\n // URL, so if a future resolver change makes it reachable it fails HERE with a name instead of\n // at boot-time env validation three layers away (5.3 review round 3, F7).\n throw new Error(\n 'database.engine is POSTGRESQL with source SELF, but no postgresql infra address resolved for this '\n + 'environment — the address resolver and the needsLocalPostgreSQL union disagree. This is a CLI bug; '\n + 'report it with the environment name and `wildo.infra.<env>.config.ts`.',\n );\n }\n const pgConnectUrl = isManaged\n ? config.externalEndpoints!.postgresql!.connectionUrl\n : buildPlatformPostgresConnectionUrl(\n addresses.infra.postgresql!,\n {\n user: credentials.postgresql.adminUser,\n password: credentials.postgresql.adminPassword,\n },\n /**\n * The PLATFORM's own database — deliberately NOT `infrastructure.postgresql.database`.\n * That field is mirrored from the author's `backingServices.postgresql.database`, which\n * names the APPLICATION's database and doubles as the compose container's initdb\n * database; using it put the platform's ~94 tables inside the application's database,\n * where `create table if not exists` would let the application silently adopt them. See\n * {@link PLATFORM_POSTGRES_DATABASE}.\n */\n PLATFORM_POSTGRES_DATABASE,\n config.infrastructure.postgresql.sslMode,\n );\n env[PlatformInfrastructureEnvKeys.PG_CONNECT_URL] = pgConnectUrl;\n env[ApplicationBackendDataEnvKeys.DATABASE_DEFAULT_ADAPTER] = PersistenceAdapter.POSTGRESQL;\n}\n\n/**\n * `postgresql://user:password@host:port/database?sslmode=...` from resolved parts. Credentials are\n * URL-encoded — an admin password with `@`/`:`/`#` would otherwise silently corrupt the authority\n * section. TLS rides IN the URL on purpose: the runtime's pre-connect door takes the URL as the\n * complete connection truth (an out-of-band SSL knob beside an explicit URL is two sources of\n * truth for one connection).\n */\nfunction buildPlatformPostgresConnectionUrl(\n address: { host: string; port: number },\n credentials: { user: string; password: string },\n databaseName: string,\n sslMode: string,\n): string {\n const user = encodeURIComponent(credentials.user);\n const password = encodeURIComponent(credentials.password);\n // The database name rides in a PATH segment, so it gets the same treatment as the credentials\n // (5.3 review F7): an authored name with a `?`/`#`/`/` would otherwise silently truncate the\n // URL at the wrong boundary. `sslmode` comes from a closed token vocabulary and stays literal.\n const database = encodeURIComponent(databaseName);\n return `postgresql://${user}:${password}@${address.host}:${address.port}/${database}?sslmode=${sslMode}`;\n}\n\n/**\n * Project the authored `infra.observability.*` block onto the standard `OTEL_*` env-var\n * surface read by the `otel-preload.ts` SDK (Slice 2 Phase 5). Emitted ONLY when telemetry\n * is enabled — a host with `observability` absent/disabled gets NO `OTEL_*`, so the preload\n * self-gates to a complete no-op.\n *\n * `service.name` goes in `OTEL_SERVICE_NAME` (NOT `service.name` inside\n * `OTEL_RESOURCE_ATTRIBUTES`), so the preload's `?? 'wildo-saas-backend'` default can never\n * clobber it (Phase 1 review note 4); `deployment.environment` goes in `OTEL_RESOURCE_ATTRIBUTES`.\n *\n * `OTEL_EXPORTER_OTLP_HEADERS` (provider auth) is derived PROVIDER-AGNOSTICALLY from the\n * SELECTED `OBSERVABILITY_TELEMETRY` provider's `otlpAuth` hint + its secret token (Slice 2\n * Phase 5b) — see `resolveOtlpAuthHeader`. Omitted for a no-auth endpoint (the local dev\n * collector) or an un-provisioned token, so the local-collector path stays a clean no-auth\n * export and telemetry still flows (just unauthenticated) before the secret lands.\n */\nfunction emitObservabilityEnv(\n env: Record<string, string>,\n observability: PlatformEnvConfigJson['observability'] | undefined,\n identity: { serviceName?: string; environment?: string; version?: string },\n telemetryProvider?: { ref?: string; providerEnv?: ScopedProviderEnv },\n): void {\n // LLM-call observability posture (`WILDO_LLM_OBS_*`) — a SEPARATE signal from\n // OTLP telemetry, projected INDEPENDENTLY of the `enabled` gate below: its\n // activation is `LLM_OBSERVABILITY` provider-selection-driven, so an env can\n // capture agent-call content with OTLP telemetry off (and vice versa).\n const llmObservability = observability?.llmObservability;\n if (llmObservability?.captureContent === true) {\n env[PlatformObservabilityEnvKeys.WILDO_LLM_OBS_CAPTURE_CONTENT] = 'true';\n }\n if (llmObservability?.sampleRate !== undefined) {\n env[PlatformObservabilityEnvKeys.WILDO_LLM_OBS_SAMPLE_RATE] = String(llmObservability.sampleRate);\n }\n // Non-secret provider connection env (e.g. POSTHOG_HOST / POSTHOG_PROJECT_ID),\n // authored in checked-in config. In the app-backend/companion/worker builders\n // this runs BEFORE the secrets `providerEnv` loop, so a same-key secret\n // deliberately overwrites it (secrets are the more specific layer). Platform\n // hosts have no secrets loop and simply receive these keys — harmless, since\n // the sink fail-closes without the secret API key.\n for (const [envVarName, value] of Object.entries(llmObservability?.providerEnv ?? {})) {\n setIfDefined(env, envVarName, value);\n }\n if (!observability?.enabled) return;\n env[PlatformObservabilityEnvKeys.OTEL_ENABLED] = 'true';\n setIfDefined(env, PlatformObservabilityEnvKeys.OTEL_EXPORTER_OTLP_ENDPOINT, observability.endpoint);\n setIfDefined(env, PlatformObservabilityEnvKeys.OTEL_SERVICE_NAME, identity.serviceName);\n // `OTEL_RESOURCE_ATTRIBUTES` is a comma-separated `key=value` list. `deployment.environment` is\n // present whenever the env is known; `service.version` (audit A-10) is added when the caller\n // threads the host's release version (the SaaS app's package.json `version`).\n const resourceAttributes: string[] = [];\n if (identity.environment) {\n resourceAttributes.push(`deployment.environment=${identity.environment}`);\n }\n if (identity.version) {\n resourceAttributes.push(`service.version=${identity.version}`);\n }\n if (resourceAttributes.length > 0) {\n env[PlatformObservabilityEnvKeys.OTEL_RESOURCE_ATTRIBUTES] = resourceAttributes.join(',');\n }\n setIfDefined(\n env,\n PlatformObservabilityEnvKeys.OTEL_EXPORTER_OTLP_HEADERS,\n resolveOtlpAuthHeader(telemetryProvider?.ref, telemetryProvider?.providerEnv),\n );\n}\n\n/**\n * Resolve the `OTEL_EXPORTER_OTLP_HEADERS` value (a single `name=value` OTLP/HTTP header) for\n * the SELECTED `OBSERVABILITY_TELEMETRY` provider — PROVIDER-AGNOSTICALLY. Reads the provider's\n * `otlpAuth` hint (header name + `{token}` value template) from the COMPOSED provider catalogue\n * and the secret token from the per-env `providerEnv` map, naming NO provider.\n *\n * Returns `undefined` (→ no header emitted) when: no provider is selected; the selected provider\n * declares no `otlpAuth` (a no-auth endpoint — e.g. the local dev collector); or the token is not provisioned in\n * `providerEnv` yet. All three are valid states — telemetry still exports, just unauthenticated —\n * so this never blocks the pipeline on a missing secret.\n *\n * ## The `providerEnv` reaching here IS the scoped bag — the confinement's second delivery path\n *\n * This function composes a provider CREDENTIAL into a header value, so it is a second site of the\n * per-runtime confinement invariant, not merely a formatter. Until 2026-09-06 both application-tier\n * builders handed it the raw `credentials.providerEnv`: a worker built with\n * `declaredProviderScope([])` correctly received NO `BETTERSTACK_SOURCE_TOKEN` and then received\n * `OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer <that same token>` — the withheld bytes,\n * delivered by the next line (#360).\n *\n * **Decided 2026-09-06 (Paul): `providers.scopes.<runtime>` MUST list the telemetry provider for\n * that runtime to receive its token.** The alternative — treating telemetry as a cross-cutting\n * platform concern exempt from the scope — was rejected because it would leave \"declared scope\"\n * meaning one thing on the key path and another here, and because the token stays readable in the\n * process environment of every worker and minion, which is exactly the surface LLM-driven minion\n * code reads. A third reading (silently widening the scope by the SELECTED telemetry provider) was\n * rejected as not a middle ground at all: the minion still receives the token, and the scope comes\n * to mean something its author did not write.\n *\n * The authoring consequence is real and small. A runtime that does not declare the provider still\n * exports telemetry — `OTEL_ENABLED` and the endpoint are unaffected — it exports it\n * UNAUTHENTICATED, the same state as a no-auth collector or an unprovisioned token. Measured before\n * the change, and the bound matters: `betterstack` was then the only provider declaring `otlpAuth` (a registry module since #2579),\n * and no `secrets.json` on this development machine — the two dogfood applications plus the\n * framework's own store — provisions `BETTERSTACK_SOURCE_TOKEN`, so NO RUNTIME IN THIS REPOSITORY\n * loses a header. That is not a claim about every application: an application elsewhere that HAS\n * provisioned the token, on a runtime that does not declare the provider, loses its header on\n * upgrade and must add the declaration. Wonder Todos' backend and companion already declare it; its\n * `myRustWorker`, `myNodeWorker` and `marketingScrapper` do not, and would have to the day a token\n * is provisioned — which is what this decision costs, stated rather than discovered.\n *\n * The scoping is enforced by the {@link ScopedProviderEnv} parameter type rather than by this\n * comment, so a future caller cannot reintroduce the bypass without a cast.\n */\nfunction resolveOtlpAuthHeader(\n providerRef: string | undefined,\n providerEnv: ScopedProviderEnv | undefined,\n): string | undefined {\n if (!providerEnv) return undefined;\n // The telemetry provider is the explicitly-selected ref when the caller threads one (the\n // forward hook); otherwise the single registry provider that BOTH declares `otlpAuth` AND has\n // its secret provisioned in this env — operators collect only the selected provider's token,\n // so the provisioned secret identifies it unambiguously without a saasConfig round-trip here.\n const provider = providerRef\n ? getComposedProviderEntry(providerRef)\n : findProvisionedTelemetryProvider(providerEnv);\n const otlpAuth = provider?.otlpAuth;\n if (!otlpAuth) return undefined;\n const tokenEnvVarName = resolveOtlpTokenEnvVarName(provider, otlpAuth);\n const token = tokenEnvVarName ? providerEnv[tokenEnvVarName] : undefined;\n if (!token) return undefined;\n // Audit A-13: `OTEL_EXPORTER_OTLP_HEADERS` is a comma-separated `name=value` list (W3C-baggage\n // style); the OTel SDK splits on `,` first, so a token containing a comma would be silently\n // truncated → a 401 from the ingest. Fail-closed: such a token is unusable in this transport.\n if (token.includes(',')) {\n throw new Error(\n `Telemetry provider token for the '${otlpAuth.headerName}' header contains a comma, which is ` +\n `invalid inside OTEL_EXPORTER_OTLP_HEADERS (a comma-separated header list). Re-provision a ` +\n `comma-free token.`,\n );\n }\n return `${otlpAuth.headerName}=${otlpAuth.valueTemplate.replace('{token}', token)}`;\n}\n\n/**\n * The `secretsContract` env-var name that feeds an `otlpAuth` `{token}`: the explicitly-named\n * `secretContractKey`, else the sole entry (unambiguous only when the provider declares exactly\n * one secret). `undefined` when the contract has multiple entries and none is named.\n */\nfunction resolveOtlpTokenEnvVarName(\n provider: ProviderSecretsCatalogueEntry,\n otlpAuth: NonNullable<ProviderSecretsCatalogueEntry['otlpAuth']>,\n): string | undefined {\n const secretKey = otlpAuth.secretContractKey\n ?? (provider.secrets.length === 1 ? provider.secrets[0].slug : undefined);\n return secretKey ? provider.secrets.find((secret) => secret.slug === secretKey)?.envVarName : undefined;\n}\n\n/**\n * Find the telemetry provider to authenticate as when no ref is explicitly threaded: the single\n * catalogue provider declaring `otlpAuth` whose secret token is present in `providerEnv`.\n *\n * `otlpAuth` is a field of a LOADABLE provider module, so a provider known only from a companion\n * contribution never matches here. That is the same outcome as an engine provider declaring no\n * hint — an unauthenticated export — and it is recorded rather than hidden: making the hint\n * companion-safe is owed to whichever slice ships a package-shipped telemetry sink. Operators\n * provision only the SELECTED provider's token, so the provisioned secret identifies it. Returns\n * `undefined` when none is provisioned (the no-auth / local-collector path).\n */\nfunction findProvisionedTelemetryProvider(\n providerEnv: Record<string, string>,\n): ProviderSecretsCatalogueEntry | undefined {\n const matches: ProviderSecretsCatalogueEntry[] = [];\n for (const provider of getComposedProviderSecretsCatalogue().values()) {\n if (!provider.otlpAuth) continue;\n const envVarName = resolveOtlpTokenEnvVarName(provider, provider.otlpAuth);\n if (envVarName && providerEnv[envVarName]) matches.push(provider);\n }\n if (matches.length === 0) return undefined;\n if (matches.length > 1) {\n // Audit A-8: the provisioned-secret heuristic is unambiguous only while exactly ONE otlpAuth\n // provider has a token. If two ever coexist, picking by iteration order is invisible to a\n // reader — warn loudly so the ambiguity surfaces. The real fix is to thread the SELECTED\n // provider ref (the `providerRef` forward hook in `resolveOtlpAuthHeader`) from the caller.\n // eslint-disable-next-line no-console\n console.warn(\n `[env-builder] ${matches.length} OBSERVABILITY_TELEMETRY providers have a provisioned token; ` +\n `the OTLP auth header is AMBIGUOUS. Using the first registered match — thread the selected ` +\n `provider ref to disambiguate.`,\n );\n }\n return matches[0];\n}\n\nfunction requireAddress(address: ResolvedServiceAddress | null, name: string): ResolvedServiceAddress {\n if (!address) {\n throw new Error(`Infrastructure address '${name}' is null — use CONTAINER_INTERNAL perspective for K8s remote`);\n }\n return address;\n}\n\nfunction resolveApplicationEnv(\n environment: PlatformEnvironmentConfiguration,\n config: PlatformEnvConfigJson,\n): string {\n const applicationEnv = config.runtimeEnvironment ?? environment.runtimeEnvironment;\n if (!applicationEnv) {\n throw new Error(\n `Environment '${environment.name}' is missing explicit runtime semantics for env generation.`,\n );\n }\n return applicationEnv;\n}\n\nfunction resolveKubernetesEnvVars(\n environment: PlatformEnvironmentConfiguration,\n): {\n namespace: string;\n} | null {\n if (environment.runtime !== WildoDeploymentRuntime.KUBERNETES) {\n return null;\n }\n\n if (environment.locationType === WildoLocationType.LOCAL) {\n return {\n namespace: environment.kubernetes?.namespace ?? 'wildo-local',\n };\n }\n\n const namespace = environment.kubernetes?.namespace;\n\n if (!namespace) {\n throw new Error(\n `Environment '${environment.name}' is missing explicit remote Kubernetes namespace metadata.`,\n );\n }\n\n return { namespace };\n}\n\n/**\n * The backend's MongoDB env, from an authored `externalEndpoints.mongodb.connectionUrl` — host list, database,\n * protocol, and the TLS and replica set the URL states (#2000).\n *\n * Read with the MongoDB connection-string grammar (`readMongoConnectionStringTarget`), never `new URL(...)`: a\n * replica-set seed list lists SEVERAL comma-separated hosts, which WHATWG URL parsing rejects (`ERR_INVALID_URL`), so\n * an Atlas cluster with no SRV address — whose address IS such a list — could not be given an env at all. And the\n * transport is carried, not dropped: that seed list states `ssl=true` and its `replicaSet`, and a `mongodb://`\n * string opened without them has no TLS, which Atlas refuses.\n *\n * Credentials in the URL are never copied into env: they reach the backend through its secrets.\n */\nfunction buildMongoEnvFromConnectionUrl(\n connectionUrl: string,\n appDatabaseName?: string | undefined,\n): { host: string; database: string; protocol: MongoDBProtocol; tls?: boolean; replicaSet?: string } {\n const target = readMongoConnectionStringTarget(connectionUrl);\n if (!target) {\n throw new Error(\n '`externalEndpoints.mongodb.connectionUrl` is not a MongoDB connection string with a host '\n + '(expected `mongodb://host[:port][,host[:port]…]/…` or `mongodb+srv://host/…`).',\n );\n }\n return {\n host: target.hosts,\n database: appDatabaseName ?? (target.database || 'wildo_app'),\n protocol: target.protocol,\n ...(target.tls !== undefined ? { tls: target.tls } : {}),\n ...(target.replicaSet ? { replicaSet: target.replicaSet } : {}),\n };\n}\n\n/**\n * Pick the canonical app-side MongoDB database name following the\n * documented precedence:\n * 1. Caller-supplied `appDatabaseName` (today only used for explicit\n * per-app overrides — kept first because it is the most specific signal).\n * 2. Authored `backingServices.mongodb.database` from `wildo.infra.<env>.config.ts`.\n * 3. Hard-coded `'wildo_app'` fallback.\n *\n * The same precedence is applied uniformly across local-MongoDB and Atlas\n * branches so toggling `BackingServiceSource` does not change which database\n * the application points at.\n *\n * Slice 3 closeout (L-5): the authored field is `database` for both\n * Mongo and Postgres now (was `name` on Mongo only) — symmetric naming\n * eliminates the cross-kind asymmetry that masked the meaning.\n */\nfunction pickAppMongoDatabase(\n backingServices: BackingServicesEnvConfig | undefined,\n appDatabaseName: string | undefined,\n): string {\n return appDatabaseName\n ?? backingServices?.[BackingServiceKind.MONGODB]?.database\n ?? 'wildo_app';\n}\n\n/**\n * Whether this environment's env files must carry the PostgreSQL admin credentials.\n *\n * The UNION rule, deliberately mirroring {@link EnvironmentLifecycle.needsLocalPostgreSQL}: the\n * platform's own engine being PostgreSQL is only HALF the question — an author may declare\n * `backingServices.postgresql: SELF` on a MongoDB-platform app (PostgreSQL for the application's\n * resources), and the compose generator then renders the postgres service from that same rule.\n *\n * This function used to be `config.database.engine === POSTGRESQL` alone, which is the exact\n * predicate the compose generator's `includePostgreSQL` JSDoc rejects — the widening had been\n * applied at ONE of the seam's two sides. Observed live 2026-08-11: the rendered compose declared\n * `wildo-postgresql` while `.env.wildo-platform` carried no `POSTGRES_ADMIN_PASSWORD`, so the\n * container crash-looped on a blank superuser password and `wildo local dev` failed at\n * infrastructure readiness. One predicate, both gates — keep them united here.\n */\nfunction shouldProvisionPostgreSQL(\n config: PlatformEnvConfigJson,\n env: { name: string; backingServices?: BackingServicesEnvConfig },\n): boolean {\n return config.database.engine === DatabaseEngine.POSTGRESQL || EnvironmentLifecycle.needsLocalPostgreSQL(env);\n}\n\nfunction assertSupportedStorageConfig(config: PlatformEnvConfigJson): void {\n if (config.infrastructure.storage.provider !== 'minio') {\n throw new Error(\n `Unsupported storage provider '${config.infrastructure.storage.provider}'. Only managed MinIO wiring is currently supported.`,\n );\n }\n\n if (config.externalEndpoints?.storage) {\n throw new Error(\n 'External storage wiring is not supported yet. Only managed MinIO addresses from the platform topology are expected.',\n );\n }\n\n if (\n config.externalServices?.storage\n && config.externalServices.storage.provider !== 'minio'\n ) {\n throw new Error(\n `Unsupported external storage provider '${config.externalServices.storage.provider}'. Only managed MinIO wiring is currently supported.`,\n );\n }\n}\n\n/**\n * Refuse to emit an application-tier environment that contains the object\n * store's ROOT credential.\n *\n * ## Why a value comparison and not a key check\n *\n * Checking for the KEY `STORAGE_ACCESS_KEY` would be trivially defeated by\n * emitting the same secret under a different name — and more importantly it would\n * miss the actual failure mode, which is a *value* leaking through a variable\n * nobody thought to audit. The root secret is what must not appear, whatever it\n * is called.\n *\n * ## Why the ACCESS KEY is not in the forbidden set\n *\n * Because it is not a secret, and treating it as one made the guard weaker.\n *\n * An access key is a principal *identifier*: for MinIO it is the account name\n * (conventionally the literal `minio`, which is also the provider name and the\n * compose service hostname), and in this repository's own generated secrets it is\n * a short shared admin username — byte-identical to `mongodb.rootUser` and\n * `rabbitmq.adminUsername`. Holding it alone grants nothing.\n *\n * Scanning for it therefore produced false positives on structurally public\n * values, and the first fix for that was a list of env-key NAMES exempted from\n * the scan. That list is exactly the key-based mechanism the paragraph above\n * rejects: it re-introduced a by-name escape hatch into a value-based guard, and\n * an over-broad guard invites deletion under deadline — which is how this control\n * would actually be lost.\n *\n * Forbidding only the SECRET removes both problems at once. A 32-character\n * high-entropy value cannot collide with a hostname, a bucket name or a provider\n * id, so no exemption list is needed and there is no name a builder can choose to\n * slip past the scan. The access key travelling in app env would be harmless; the\n * secret travelling with it is the entire exposure.\n *\n * ## Why it never logs the value\n *\n * The whole point is that this secret should not spread. An error message\n * containing it would write it into CI logs, which is a worse place than the env\n * file it was caught in. The message names the KEY only.\n *\n * Applies to application-tier env exclusively. Platform-tier builders\n * (`buildInfraCredentialEnv`, `buildAppsManagerFullEnv`) legitimately carry admin\n * material — apps-manager is the STS broker and cannot broker without it. Whether\n * those consumers should hold *root* specifically is still an open question for\n * THOSE two.\n *\n * `buildBootstrapEnv` left that list with #1761: the bootstrap services\n * (module-registry, crontabs-batches-manager) resolve storage through apps-manager's\n * STS like any application, so the root pair it handed them was never read.\n *\n * `buildCompanionPlatformEnv` was in that list and no longer is, for the storage\n * axis: the companion runs the app-tier storage provider and fetches STS sessions\n * like any application, so the root pair it was being handed was never read. It\n * remains platform-tier for Mongo/Redis/RabbitMQ, which is why the blanket guard is\n * still not applied to it — `omits the object storage ROOT credential` in the\n * builder tests pins the storage half specifically.\n */\nexport function assertNoStorageSecretInGeneratedEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n builderName: string,\n): void {\n assertNoPlatformCredentialInGeneratedEnv(env, credentials, builderName);\n}\n\n/**\n * Every PLATFORM-tier credential that must never appear in an application-tier\n * environment, with the label used to report it.\n *\n * ## Why the whole set and not just storage\n *\n * Object storage was the one backing service whose credential reached every\n * workload, and it was found by reading the code rather than by any check. The\n * other four — Mongo, PostgreSQL, Redis, RabbitMQ — are absent from app env only\n * because each mints per-application credentials that travel over the\n * authenticated apps-manager fetch. That is a property of how those providers\n * happen to be wired today, not something enforced anywhere. A future provider\n * that skips minting (exactly what `MinioSelfInfraProviderModule` did) would\n * reproduce the same exposure against a different service, and nothing would\n * catch it.\n *\n * Verified before this widened: with the set below, every generated Wonder Todos\n * application and minion env is clean.\n *\n * ## Why only SECRETS, never identifiers\n *\n * `mongodb.rootUser`, `rabbitmq.adminUsername`, `postgresql.adminUser` and\n * `storage.accessKey` are principal NAMES. In this repository's generated secrets\n * three of them are the SAME five-character string, which also appears as a\n * hostname and a provider id — scanning for those produced false positives on\n * correct configurations, and the first attempt to suppress them re-introduced a\n * by-name exemption list into a value-based guard. Only high-entropy secret\n * material belongs here.\n *\n * ## What is deliberately NOT here\n *\n * - `providerEnv` values (OpenAI, Stripe, …) — authored application credentials\n * that an application legitimately holds. They are constrained by DECLARED\n * SCOPE (`providers.scopes.*`), a different control with its own tests.\n * - The app's own `PLATFORM_APPLICATION_PRIMARY_SECRET` — minted per application\n * by apps-manager, and the one credential that MUST be in env because it is\n * what authenticates the fetch by which everything else arrives. Note\n * `platform.primarySecret` below is a different value: the PLATFORM's own\n * secret, which an application must never hold.\n */\n/**\n * apps-manager's response keys (#2921), or a loud refusal naming the remedy.\n *\n * Fail-loud rather than optional, like the crontabs keypair: apps-manager may not answer an application runtime unsigned,\n * and a runtime refuses to boot without the keys to verify it. A secrets.json that predates the keys acquires them on\n * the next provisioning self-heal (`wildo config sync`, `wildo local dev`, `wildo local up`).\n */\nfunction requireAppsManagerResponseSigning(\n credentials: PlatformEnvSecretsJson,\n): NonNullable<PlatformEnvSecretsJson['platform']['appsManagerResponseSigning']> {\n const keys = credentials.platform.appsManagerResponseSigning;\n if (!keys) {\n throw new Error(\n \"secrets.platform.appsManagerResponseSigning is missing: apps-manager's response keys are not available \" +\n '(#2921). Without them apps-manager cannot sign its answers and every application runtime refuses to start. ' +\n 'Locally, run `wildo config sync` (or `wildo local dev`), which mints them into secrets.json. In CI, the ' +\n 'secrets are rebuilt from the environment: regenerate the deploy workflows (`wildo config sync --domain cicd`) ' +\n 'so they forward the WILDO_SECRET_PLATFORM_APPS_MANAGER_RESPONSE_SIGNING_* secrets, and add those secrets to ' +\n 'the repository.',\n );\n }\n return keys;\n}\n\n/**\n * The verification key set every application runtime carries: current, then next (see\n * `buildRuntimeResponseVerificationKeySet`). One function so the backend, minion, worker and companion builders cannot\n * disagree about it.\n */\nfunction appsManagerResponseVerificationKeys(credentials: PlatformEnvSecretsJson): string {\n const keys = requireAppsManagerResponseSigning(credentials);\n return buildRuntimeResponseVerificationKeySet([keys.publicKey, keys.nextPublicKey]);\n}\n\n/**\n * The platform's key-encryption root (#2891). Fail-loud like the response keys: an apps-manager env generated without\n * it starts but cannot seal or use a single key, because a key it cannot seal must not be stored. The provisioning\n * self-heal mints it into secrets.json.\n */\nfunction requireKeyEncryptionRoot(\n credentials: PlatformEnvSecretsJson,\n): NonNullable<PlatformEnvSecretsJson['platform']['keyEncryptionRoot']> {\n const root = credentials.platform.keyEncryptionRoot;\n if (!root?.current) {\n throw new Error(\n \"secrets.platform.keyEncryptionRoot is missing: apps-manager's key-encryption root is not available (#2891). \"\n + 'Without it apps-manager cannot seal the keys it signs approval seals with, and refuses every signature. Locally, run '\n + '`wildo config sync` (or `wildo local dev`), which mints it into secrets.json. In CI, regenerate the deploy '\n + 'workflows (`wildo config sync --domain cicd`) so they forward WILDO_SECRET_PLATFORM_KEY_ENCRYPTION_ROOT_*, and '\n + 'add that secret to the repository.',\n );\n }\n return root;\n}\n\n/**\n * apps-manager's Vault (#2933), from `platformKeyManagement.vault`: the self-hosted OpenBao the lanes render (its\n * address and the framework-minted token ids) or the operator's own Vault (the authored address and layout, and the\n * operator-typed tokens under `secrets.platformKeyVaultManaged`). Nothing is emitted without a declaration, and nothing\n * when the tokens are missing: apps-manager then serves no Vault provider, and a binding naming one is refused\n * PROVIDER_UNAVAILABLE, which names the gap. A partial set is never emitted, because apps-manager refuses a partial\n * configuration and the operator would read a logged error instead of this one rule.\n */\nfunction emitPlatformKeyVaultEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n environment: PlatformEnvironmentConfiguration,\n): void {\n const vault = environment.platformKeyManagement?.vault;\n if (!vault) return;\n if (vault.source === BackingServiceSource.SELF) {\n const address = addresses.infra.openbao;\n const tokens = credentials.platformKeyVault;\n if (!address || !tokens?.signerToken || !tokens.operatorToken) return;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_ADDRESS] = address.url;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_SIGNER_TOKEN] = tokens.signerToken;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_OPERATOR_TOKEN] = tokens.operatorToken;\n return;\n }\n const tokens = credentials.platformKeyVaultManaged;\n if (!tokens) return;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_ADDRESS] = vault.address;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_SIGNER_TOKEN] = tokens.signerToken;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_OPERATOR_TOKEN] = tokens.operatorToken;\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_NAMESPACE, vault.namespace);\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_TRANSIT_MOUNT, vault.transitMount);\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_KV_MOUNT, vault.kvMount);\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_KEY_NAME_PREFIX, vault.keyNamePrefix);\n}\n\n/**\n * apps-manager's cloud KMS providers (#2896), from `platformKeyManagement.awsKms` / `googleCloudKms` / `azureKeyVault`:\n * the account, the key location and the two identities apps-manager acts as. Nothing here is a secret: apps-manager\n * authenticates with its workload identity, so the values come from the authored declaration alone, and every key of\n * one vendor is written together. The defaults (HSM-protected keys) are written explicitly, so apps-manager's\n * environment says what it will create.\n */\nfunction emitPlatformCloudKmsEnv(env: Record<string, string>, environment: PlatformEnvironmentConfiguration): void {\n const { awsKms, googleCloudKms, azureKeyVault } = environment.platformKeyManagement ?? {};\n if (awsKms) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AWS_KMS_REGION] = awsKms.region;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AWS_KMS_SIGNER_ROLE_ARN] = awsKms.signerRoleArn;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AWS_KMS_OPERATOR_ROLE_ARN] = awsKms.operatorRoleArn;\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_AWS_KMS_ENDPOINT, awsKms.endpoint);\n }\n if (googleCloudKms) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_GOOGLE_KMS_KEY_RING] = googleCloudKms.keyRing;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_GOOGLE_KMS_SIGNER_SERVICE_ACCOUNT] = googleCloudKms.signerServiceAccount;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_GOOGLE_KMS_OPERATOR_SERVICE_ACCOUNT] = googleCloudKms.operatorServiceAccount;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_GOOGLE_KMS_PROTECTION_LEVEL] = googleCloudKms.protectionLevel ?? PlatformGoogleKmsKeyProtection.HSM;\n }\n if (azureKeyVault) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_URL] = azureKeyVault.vaultUrl;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_SIGNER_CLIENT_ID] = azureKeyVault.signerClientId;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_OPERATOR_CLIENT_ID] = azureKeyVault.operatorClientId;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_HSM] = String(azureKeyVault.hsm ?? true);\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_LOG_ANALYTICS_WORKSPACE_ID, azureKeyVault.logAnalyticsWorkspaceId);\n }\n}\n\n/**\n * apps-manager's dedicated HSM over PKCS#11 (#2934), from `platformKeyManagement.pkcs11` and the operator-typed PIN under\n * `secrets.platformKeyPkcs11`. Nothing is emitted without both, for the Vault reason: apps-manager refuses a partial\n * configuration, and the operator would read a logged error instead of this one rule.\n */\n/** The shortest PKCS#11 PIN the platform-credential scan looks for (see `resolveForbiddenPlatformCredentials`). */\nconst PKCS11_PIN_NEEDLE_MINIMUM_LENGTH = 12;\n\nfunction emitPlatformPkcs11Env(env: Record<string, string>, credentials: PlatformEnvSecretsJson, environment: PlatformEnvironmentConfiguration): void {\n const pkcs11 = environment.platformKeyManagement?.pkcs11;\n const pin = credentials.platformKeyPkcs11?.pin;\n if (!pkcs11 || !pin) return;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_PKCS11_MODULE_PATH] = pkcs11.modulePath;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_PKCS11_TOKEN_LABEL] = pkcs11.tokenLabel;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_PKCS11_PIN] = pin;\n if ((pkcs11.hardwareTokenModels ?? []).length > 0) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_PKCS11_HARDWARE_TOKEN_MODELS] = (pkcs11.hardwareTokenModels ?? []).join(',');\n }\n}\n\nfunction resolveForbiddenPlatformCredentials(\n credentials: PlatformEnvSecretsJson,\n): ReadonlyArray<readonly [label: string, value: string]> {\n const candidates: ReadonlyArray<readonly [string, unknown]> = [\n ['the object storage ROOT credential', credentials.storage?.secretKey],\n ['the MongoDB root password', credentials.mongodb?.rootPassword],\n ['the PostgreSQL admin password', credentials.postgresql?.adminPassword],\n ['the Valkey/Redis admin password', credentials.valkey?.adminPassword],\n ['the RabbitMQ admin password', credentials.rabbitmq?.adminPassword],\n ['the RabbitMQ Erlang cookie', credentials.rabbitmq?.erlangCookie],\n // #1696 — the self-hosted immudb server's sysadmin: apps-manager's alone. Generated (never the operator's\n // `IMMUDB_PASSWORD`, which is exactly the copy that made it an application credential), so it is long and\n // unique and a containment match cannot fire on an unrelated value.\n ['the immudb server administrator password', credentials.immudb?.adminPassword],\n ['the PLATFORM primary secret', credentials.platform?.primarySecret],\n ['the PLATFORM admin secret', credentials.platform?.adminSecret],\n // #2921 — apps-manager's response keys sign what every runtime trusts; a runtime holding one could forge it.\n ['the apps-manager response signing key', credentials.platform?.appsManagerResponseSigning?.privateKey],\n ['the apps-manager next response signing key', credentials.platform?.appsManagerResponseSigning?.nextPrivateKey],\n // #2891 — every LOCAL private key is sealed under it; a runtime holding it could open the seal keys.\n ['the platform key-encryption root', credentials.platform?.keyEncryptionRoot?.current],\n ['the platform previous key-encryption root', credentials.platform?.keyEncryptionRoot?.previous],\n // #2933 — the platform Vault: its unseal key opens every key stored there, and its tokens sign with or manage them.\n ['the platform Vault unseal key', credentials.platformKeyVault?.unsealKey],\n ['the platform Vault signer token', credentials.platformKeyVault?.signerToken],\n ['the platform Vault operator token', credentials.platformKeyVault?.operatorToken],\n // #3006 — the break-glass recovery token mints signer tokens and re-wraps the server's root key; the previous unseal\n // key opens the storage until that re-wrap. Neither belongs to any runtime, apps-manager included.\n ['the platform Vault recovery token', credentials.platformKeyVault?.recoveryToken],\n ['the platform Vault previous unseal key', credentials.platformKeyVault?.previousUnsealKey],\n ['the platform Vault signer token (managed)', credentials.platformKeyVaultManaged?.signerToken],\n ['the platform Vault operator token (managed)', credentials.platformKeyVaultManaged?.operatorToken],\n // The PIN is the HSM owner's choice, not a generated string, and this check is CONTAINMENT: a four-digit PIN would be\n // found inside a port number. It is a needle only at a length where a match means it, which is also the only kind of\n // PIN worth guarding; the skill tells the operator to set a long one.\n ['the platform PKCS#11 token PIN', (credentials.platformKeyPkcs11?.pin?.length ?? 0) >= PKCS11_PIN_NEEDLE_MINIMUM_LENGTH ? credentials.platformKeyPkcs11?.pin : undefined],\n ];\n\n const present = candidates.filter(\n (entry): entry is readonly [string, string] =>\n typeof entry[1] === 'string' && entry[1].length > 0,\n );\n\n /**\n * Each credential is also forbidden in its PERCENT-ENCODED form (5.3 review F6): credentials now\n * legitimately travel URL-EMBEDDED on the platform tier (`PG_CONNECT_URL` carries the encoded\n * admin password), so a future application-tier builder that copies such a URL would smuggle the\n * credential past an exact-value comparison. The check below is containment, and this widens the\n * needle set to the encoded spelling too. Only added when encoding actually changes the value.\n */\n const encodedVariants = present\n .filter(([, value]) => encodeURIComponent(value) !== value)\n .map(([label, value]) => [`${label} (URL-encoded)`, encodeURIComponent(value)] as const);\n\n return [...present, ...encodedVariants];\n}\n\n/**\n * Refuse to emit an application-tier environment containing ANY platform-tier\n * credential. Generalises the storage-specific gate that preceded it; see\n * {@link resolveForbiddenPlatformCredentials} for the set and its exclusions, and\n * the JSDoc above for why this compares values rather than key names and never\n * prints the offending value.\n */\nexport function assertNoPlatformCredentialInGeneratedEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n builderName: string,\n): void {\n /*\n * A non-string value is a CONTRACT VIOLATION by the caller — the parameter is `Record<string,\n * string>` — and it is refused here, named, rather than left to crash the scan below.\n *\n * It crashed for real: a fixture predating `2fc51ec5a` omitted `APPLICATION_SLUG`, the builder\n * emitted the key as `undefined`, and `emitted.includes(value)` threw\n * `Cannot read properties of undefined (reading 'includes')` — a stack trace inside the\n * platform-credential guard, which reads as a leak-detection defect and says nothing about a\n * missing slug. Seven tests failed that way.\n *\n * Refusing rather than skipping, for the reason the scan below already gives: every emitted value\n * is compared, with no key exemptions. Silently skipping a non-string would be an exemption that\n * nobody declared — and an env var whose value is `undefined` reaches a real Secret as the string\n * \"undefined\" or not at all, so it is a defect in its own right wherever it appears.\n */\n const nonStringKeys = Object.entries(env).filter(([, value]) => typeof value !== 'string').map(([key]) => key);\n if (nonStringKeys.length > 0) {\n throw new Error(\n `${builderName} produced an environment whose value is not a string under: ${nonStringKeys.join(', ')}. `\n + 'Every emitted env var must be a string — an undefined value reaches a Secret as \"undefined\" or '\n + 'vanishes, and it cannot be scanned for platform credentials. Fix the contributor that emitted it.',\n );\n }\n\n const forbidden = resolveForbiddenPlatformCredentials(credentials);\n if (forbidden.length === 0) return;\n\n // No key exemptions, deliberately — see the JSDoc. Every emitted value is\n // compared, including the ones a future builder adds without reading this.\n // CONTAINMENT, not equality (5.3 review F6): a credential embedded inside a\n // connection URL is exactly as leaked as one standing alone, and equality was\n // blind to it. Credentials are long generated strings, so substring\n // false-positives are not a realistic concern.\n const findings: string[] = [];\n for (const [label, value] of forbidden) {\n const offendingKeys = Object.entries(env)\n .filter(([, emitted]) => emitted.includes(value))\n .map(([key]) => key);\n if (offendingKeys.length > 0) {\n findings.push(`${label} under: ${offendingKeys.join(', ')}`);\n }\n }\n\n if (findings.length > 0) {\n throw new Error(\n `${builderName} emitted platform-tier credentials into an application-tier environment — `\n + `${findings.join('; ')}. An application receives per-application credentials over the `\n + 'authenticated apps-manager fetch, never the platform\\'s own. '\n + '(The offending values are deliberately not printed.)',\n );\n }\n}\n\n// ============================================================================\n// Builder\n// ============================================================================\n\n/** The trusted reverse-proxy hops in front of an application backend in this deployment (#1788). */\nexport function trustedProxyHopsForApplicationBackend(locationType: WildoLocationType): number {\n switch (locationType) {\n case WildoLocationType.REMOTE:\n return REMOTE_EDGE_PROXY_HOPS;\n case WildoLocationType.LOCAL:\n return 0;\n }\n}\n\nexport class PlatformEnvVarsBuilder {\n /**\n * The EXACT provider-env map merged into every backend / companion / worker\n * runtime — the operator-authored `credentials.providerEnv` PLUS\n * framework-injected provider material (today: the immudb state-signing\n * public key). This is the single authority already used internally at the\n * three runtime merge sites (`buildApplicationBackendEnv`,\n * `buildCompanionPlatformEnv`, and the worker/minion path).\n *\n * Exposed so `wildo config sync` can project the SAME bytes into a\n * standalone provider-secrets `.env` sink for out-of-band consumers (the\n * framework-dev integration test harnesses that are NOT launched by\n * `wildo local dev`). Deriving the sink from this method — rather than\n * re-parsing `secrets.json` — keeps ONE composition authority and makes the\n * sink drift-free by construction (e.g. it never misses the framework-injected\n * immudb key that a naive `providerEnv` copy would drop).\n *\n * ## Confinement result: N/A, deliberately (#360)\n *\n * This is the one remaining path from `credentials.providerEnv` into an artifact that carries\n * VALUES and is not scoped, so it needs a stated result rather than silence — an unstated site\n * reads exactly like one nobody examined (`.claude/rules/invariant-call-site-enumeration.md`).\n *\n * It is not a per-runtime environment. It is the environment-level aggregate sink, written LOCAL\n * only, for framework-development harnesses that no runtime scope describes — so\n * `PLATFORM_TIER_ALL_PROVIDERS` is the honest answer rather than a missing filter. A runtime that\n * receives a scoped env does not read this file.\n *\n * Returns a fresh record (never mutates `credentials.providerEnv`).\n */\n static buildRuntimeProviderEnv(credentials: PlatformEnvSecretsJson): Record<string, string> {\n // Platform tier: the environment-level aggregate provider-secrets artifact,\n // not a per-runtime env. Unscoped by definition.\n return PlatformEnvVarsBuilder.buildScopedProviderEnv(credentials, platformTierAllProvidersScope());\n }\n\n /**\n * The provider-env map ONE runtime is entitled to — the same composition\n * {@link buildRuntimeProviderEnv} performs, through the runtime's declared scope.\n *\n * Exposed for the Kubernetes lane (#369), which delivers provider credentials as a per-runtime\n * `Secret` rather than as lines in a generated `.env`, and so needs the scoped bag as a VALUE\n * instead of as env-file bytes. Routing that lane through this method rather than through\n * `credentials.providerEnv` is the whole fix: it used to emit one cluster-wide `providers-secret`\n * holding everything, `envFrom`-mounted by every application pod, so a worker declaring\n * `providers: {}` received the application's entire provider bag.\n *\n * The scope is positional and required for the same reason it is everywhere else in this file:\n * an omitted scope is how the whole bag reached every runtime in the first place.\n *\n * Returns a fresh record (never mutates `credentials.providerEnv`).\n */\n static buildScopedProviderEnv(\n credentials: PlatformEnvSecretsJson,\n scope: RuntimeProviderScope,\n ): Record<string, string> {\n return resolveRuntimeProviderEnv(credentials, scope);\n }\n\n /**\n * Section A — env vars consumed by infra containers themselves\n * (MongoDB, Valkey, RabbitMQ, MinIO, PostgreSQL).\n */\n static buildInfraCredentialEnv(\n credentials: PlatformEnvSecretsJson,\n config: PlatformEnvConfigJson,\n /** Needed by the postgres UNION rule — `config.json` cannot express `backingServices.postgresql` (see {@link shouldProvisionPostgreSQL}). */\n environment: { name: string; backingServices?: BackingServicesEnvConfig },\n ): Record<string, string> {\n const env: Record<string, string> = {};\n\n if (credentials.mongodb) {\n env['MONGO_ROOT_USER'] = credentials.mongodb.rootUser;\n env['MONGO_ROOT_PASSWORD'] = credentials.mongodb.rootPassword;\n }\n\n if (credentials.valkey) {\n env[VALKEY_CREDENTIAL_ENV_KEYS.PASSWORD] = credentials.valkey.adminPassword;\n }\n\n env[RABBITMQ_CREDENTIAL_ENV_KEYS.DEFAULT_USER] = credentials.rabbitmq.adminUsername;\n env[RABBITMQ_CREDENTIAL_ENV_KEYS.DEFAULT_PASS] = credentials.rabbitmq.adminPassword;\n env[RABBITMQ_CREDENTIAL_ENV_KEYS.ERLANG_COOKIE] = credentials.rabbitmq.erlangCookie;\n\n env[MINIO_CREDENTIAL_ENV_KEYS.ROOT_USER] = credentials.storage.accessKey;\n env[MINIO_CREDENTIAL_ENV_KEYS.ROOT_PASSWORD] = credentials.storage.secretKey;\n // The PLATFORM bucket the compose `minio-init` creates (#1112) — not the application's. Application buckets\n // are created by apps-manager when it first issues that application a storage credential.\n env['STORAGE_BUCKET'] = resolvePlatformObjectStorageBucket(config.platformStorage);\n\n if (shouldProvisionPostgreSQL(config, environment)) {\n if (!credentials.postgresql) {\n // Loud, named failure instead of a TypeError: the compose file WILL render the postgres\n // service from the same rule, and an env file silently missing the credential produces a\n // container crash-looping on a blank superuser password — diagnosed the hard way 2026-08-11.\n throw new Error(\n 'PostgreSQL is part of this environment (platform engine or a SELF backing service) but '\n + 'secrets.json has no `postgresql` credentials. Run `wildo -y setup` to provision them.',\n );\n }\n env[POSTGRESQL_CREDENTIAL_ENV_KEYS.ADMIN_USER] = credentials.postgresql.adminUser;\n env[POSTGRESQL_CREDENTIAL_ENV_KEYS.ADMIN_PASSWORD] = credentials.postgresql.adminPassword;\n env[POSTGRESQL_CREDENTIAL_ENV_KEYS.ADMIN_DATABASE] = config.infrastructure.postgresql.database;\n }\n\n return env;\n }\n\n /**\n * Full env for apps-manager — includes bootstrap vars + all service connections.\n */\n static buildAppsManagerFullEnv(\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n options: {\n includeBootstrapAdminCredentials?: boolean;\n /** apps-manager's own `package.json` version → OTel `service.version` (audit A-10 parity). */\n serviceVersion?: string;\n } = {},\n ): Record<string, string> {\n assertSupportedStorageConfig(config);\n\n const env: Record<string, string> = {};\n\n const amCatalog = PLATFORM_SERVICE_CATALOG[PlatformWildoServices.APPS_MANAGER];\n env[PlatformProcessEnvKeys.HOST] = LISTEN_HOST;\n env[PlatformProcessEnvKeys.PORT] = String(amCatalog.defaultPort);\n env[PlatformProcessEnvKeys.APPS_MANAGER_MODE] = AppsManagerMode.NORMAL;\n env[PlatformProcessEnvKeys.SERVICE_NAME] = amCatalog.serviceEnvVarName;\n env[PlatformProcessEnvKeys.PLATFORM_ENVIRONMENT_ID] = environment.name;\n env[PlatformProcessEnvKeys.APPLICATION_ENV] = resolveApplicationEnv(environment, config);\n\n // -- MongoDB\n emitPlatformMongoEnv(env, credentials, addresses, config, environment);\n\n // -- The platform's OWN PostgreSQL (D7) — no-op unless `database.engine === POSTGRESQL`\n emitPlatformPostgresEnv(env, credentials, addresses, config, environment);\n\n const valkey = requireAddress(addresses.infra.valkey, 'valkey');\n const rabbitmq = requireAddress(addresses.infra.rabbitmq, 'rabbitmq');\n const rabbitmqMgmt = requireAddress(addresses.infra.rabbitmqManagement, 'rabbitmqManagement');\n const minio = requireAddress(addresses.infra.minio, 'minio');\n const postgresql = shouldProvisionPostgreSQL(config, environment)\n ? requireAddress(addresses.infra.postgresql, 'postgresql')\n : null;\n\n // -- Valkey\n env[PlatformInfrastructureEnvKeys.REDIS_HOST] = valkey.host;\n env[PlatformInfrastructureEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n if (credentials.valkey) {\n env[PlatformInfrastructureEnvKeys.REDIS_ADMIN_USER] = credentials.valkey.adminUser;\n env[PlatformInfrastructureEnvKeys.REDIS_ADMIN_PASSWORD] = credentials.valkey.adminPassword;\n }\n\n // -- RabbitMQ\n env[PlatformInfrastructureEnvKeys.RABBITMQ_HOST] = rabbitmq.host;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_PORT] = String(rabbitmq.port);\n env[PlatformInfrastructureEnvKeys.RABBITMQ_MANAGEMENT_PORT] = String(rabbitmqMgmt.port);\n // No RABBITMQ_VHOST (#1112). The platform tier's broker users hold permissions only on the default vhost `/`,\n // and a registered application's vhost travels with its registration (#1107). Rendering this application's\n // authored vhost here made it the platform's, for whichever application synced last.\n env[PlatformInfrastructureEnvKeys.RABBITMQ_ADMIN_USERNAME] = credentials.rabbitmq.adminUsername;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_ADMIN_PASSWORD] = credentials.rabbitmq.adminPassword;\n\n // -- Storage (MinIO)\n env[PlatformInfrastructureEnvKeys.STORAGE_PROVIDER] = config.infrastructure.storage.provider;\n env[PlatformInfrastructureEnvKeys.STORAGE_ENDPOINT] = minio.host;\n env[PlatformInfrastructureEnvKeys.STORAGE_PORT] = String(minio.port);\n env[PlatformInfrastructureEnvKeys.STORAGE_USE_SSL] = String(config.infrastructure.storage.useSsl);\n // apps-manager's OWN bucket: the platform services' storage and the platform application's. The platform\n // authors it (#1112) — never this application's `backingServices.s3.bucket`, which travels with its\n // registration (#1107). module-registry renders the same value below, and the two MUST agree: its\n // credential is confined to the bucket named here while it addresses objects in the one named there.\n env[PlatformInfrastructureEnvKeys.STORAGE_BUCKET] = resolvePlatformObjectStorageBucket(config.platformStorage);\n env[PlatformInfrastructureEnvKeys.STORAGE_ACCESS_KEY] = credentials.storage.accessKey;\n env[PlatformInfrastructureEnvKeys.STORAGE_SECRET_KEY] = credentials.storage.secretKey;\n // The role the STS broker names (#2172): apps-manager only, the one service that calls AssumeRole. Emitted only\n // when authored, because a MinIO-compatible store names no role.\n if (config.platformStorage?.stsRoleArn) {\n env[PlatformInfrastructureEnvKeys.STORAGE_STS_ROLE_ARN] = config.platformStorage.stsRoleArn;\n }\n\n // -- Platform service URLs\n env[PlatformServiceUrlEnvKeys.PLATFORM_APPS_MANAGER_URL] = addresses.platform.appsManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_URL] = addresses.platform.crontabsBatchesManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_MODULE_REGISTRY_URL] = addresses.platform.moduleRegistry.url;\n\n // -- Platform security\n env[PlatformSecurityEnvKeys.PLATFORM_APPS_MANAGER_PRIVATE_KEY] = credentials.platform.appsManager.privateKey;\n env[PlatformSecurityEnvKeys.PLATFORM_APPS_MANAGER_PUBLIC_KEY] = credentials.platform.appsManager.publicKey;\n // #2921 — the CURRENT response key's private half: apps-manager signs every answer to an application runtime with it.\n // The next key's private half stays in secrets.json until a rotation promotes it.\n env[PlatformSecurityEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_SIGNING_PRIVATE_KEY] = requireAppsManagerResponseSigning(credentials).privateKey;\n // #2891 — the key-encryption root, apps-manager only: every LOCAL private key is sealed under it. The previous root\n // rides along only between a rotation and the re-seal that retires it.\n const keyEncryptionRoot = requireKeyEncryptionRoot(credentials);\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_ENCRYPTION_ROOT] = keyEncryptionRoot.current;\n if (keyEncryptionRoot.previous && keyEncryptionRoot.previous !== keyEncryptionRoot.current) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_ENCRYPTION_PREVIOUS_ROOT] = keyEncryptionRoot.previous;\n }\n // The public set every runtime verifies against. apps-manager checks at startup that its signing key is in it, so a\n // mismatch is refused there rather than by every runtime; the compose runtimes also interpolate it from this env.\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n // The crontabs-batches-manager P2P signing keypair — apps-manager-env ONLY (the authority): it\n // imports this keypair at INIT (platform-owned setup material, NOT generated), serves the PRIVATE\n // half to crontabs (which signs every SCHEDULED_CRON / MINION_TICK tick) and distributes the PUBLIC\n // half into every app's verify slot. Both halves stay confined to this authority env; other services\n // never receive the private key. Fail-loud if absent (a secrets.json predating the scheduled-cron JWT\n // fix) — a silent empty key here is exactly what dead-lettered every tick.\n if (!credentials.platform.crontabsBatchesManager) {\n throw new Error(\n 'secrets.platform.crontabsBatchesManager is missing — the crontabs P2P signing keypair was never minted ' +\n '(secrets.json predates the scheduled-cron JWT fix). Re-run `wildo setup` or inject the keypair; without it ' +\n 'every SCHEDULED_CRON / MINION_TICK job dead-letters (apps receive an empty crontabs verify key).',\n );\n }\n env[PlatformSecurityEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_PRIVATE_KEY] = credentials.platform.crontabsBatchesManager.privateKey;\n env[PlatformSecurityEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_PUBLIC_KEY] = credentials.platform.crontabsBatchesManager.publicKey;\n env[PlatformSecurityEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] = credentials.platform.primarySecret;\n env[PlatformSecurityEnvKeys.PLATFORM_ADMIN_SECRET] = credentials.platform.adminSecret;\n\n // -- PostgreSQL\n if (postgresql) {\n env[PlatformInfrastructureEnvKeys.PG_HOST] = postgresql.host;\n env[PlatformInfrastructureEnvKeys.PG_PORT] = String(postgresql.port);\n env[PlatformInfrastructureEnvKeys.PG_ADMIN_USER] = credentials.postgresql.adminUser;\n env[PlatformInfrastructureEnvKeys.PG_ADMIN_PASSWORD] = credentials.postgresql.adminPassword;\n /**\n * The MAINTENANCE database, never `infrastructure.postgresql.database`. This key addresses\n * where the admin pool CONNECTS to run `CREATE DATABASE` / `CREATE ROLE`; the application's\n * database is a THING IT PROVISIONS, and dialling it made admin init fail on any machine\n * where it did not exist yet — silently, because the caller records `postgresql: 'failed'`\n * and continues behind a 200 `/health/ready`. The container's initdb database is a different\n * key entirely (`POSTGRES_ADMIN_DATABASE`, emitted by `buildInfraCredentialEnv`), so nothing\n * here was ever serving that meaning. Full contract on the constant.\n */\n env[PlatformInfrastructureEnvKeys.PG_ADMIN_DATABASE] = PLATFORM_POSTGRES_MAINTENANCE_DATABASE;\n env[PlatformInfrastructureEnvKeys.PG_SSL_MODE] = config.infrastructure.postgresql.sslMode;\n }\n\n // -- immudb (#1696): the self-hosted audit store's sysadmin, for apps-manager ONLY. apps-manager logs in with it\n // to give each application its own database and `READ_WRITE` user (`immudb-self` infra module); no other\n // platform service and no application runtime is handed it, and `resolveForbiddenPlatformCredentials` refuses\n // it in any application-tier env. Emitted exactly when this environment self-hosts immudb: that is what makes\n // apps-manager HOLD the `IMMUDB_SELF` admin client, so a platform with no self-hosted immudb refuses an\n // application declaring one instead of pointing at a server it does not run. A secrets.json without the\n // material (CI-reconstructed before it existed) emits nothing, which refuses the same way.\n const immudb = EnvironmentLifecycle.selfHostsBackingService(environment, BackingServiceKind.IMMUDB)\n ? addresses.infra.immudb\n : null;\n const immudbAdminPassword = credentials.immudb?.adminPassword;\n if (immudb && immudbAdminPassword) {\n env[PlatformInfrastructureEnvKeys.IMMUDB_ADMIN_HOST] = immudb.host;\n env[PlatformInfrastructureEnvKeys.IMMUDB_ADMIN_PORT] = String(immudb.port);\n env[PlatformInfrastructureEnvKeys.IMMUDB_ADMIN_PASSWORD] = immudbAdminPassword;\n }\n\n // -- The platform's Vault (#2933): where apps-manager keeps the keys it holds for applications, and the two tokens\n // it speaks there with. apps-manager's alone, like the immudb sysadmin above.\n emitPlatformKeyVaultEnv(env, credentials, addresses, environment);\n // -- The platform's cloud KMS accounts (#2896): identities and locations, no secret.\n emitPlatformCloudKmsEnv(env, environment);\n // -- The platform's dedicated HSM (#2934): the module, the token, and the operator-typed PIN.\n emitPlatformPkcs11Env(env, credentials, environment);\n\n // Admin bootstrap identity is only needed on flows that intentionally seed\n // the first platform admin. K8s steady-state manifests should not keep these\n // values in envFrom after INIT mode completes.\n if (options.includeBootstrapAdminCredentials !== false) {\n env[PlatformAdminEnvKeys.ADMIN_EMAIL] = credentials.admin.email;\n env[PlatformAdminEnvKeys.ADMIN_PASSWORD] = credentials.admin.password;\n env[PlatformAdminEnvKeys.ADMIN_FIRST_NAME] = credentials.admin.firstName;\n env[PlatformAdminEnvKeys.ADMIN_LAST_NAME] = credentials.admin.lastName;\n\n /*\n * The SECOND administrator, who approves an application-wide access grant (#575).\n *\n * Conditional because `approver` is `.optional()` on the secrets schema — an environment whose\n * `secrets.json` predates it still parses, and must still boot. INIT reads the absence as a\n * WARNING rather than a refusal for the same reason, so emitting nothing here is a supported\n * state and not a silent hole.\n *\n * Emitted beside the first administrator rather than in a block of its own, deliberately: this\n * mapping is hand-written once per deployment lane and the kubernetes lane's copy already\n * drifted from this one by two keys. Keeping the two identities adjacent is what makes the next\n * reader notice there are two lanes to update, not one.\n */\n if (credentials.approver) {\n env[PlatformAdminEnvKeys.APPROVER_EMAIL] = credentials.approver.email;\n env[PlatformAdminEnvKeys.APPROVER_PASSWORD] = credentials.approver.password;\n env[PlatformAdminEnvKeys.APPROVER_FIRST_NAME] = credentials.approver.firstName;\n env[PlatformAdminEnvKeys.APPROVER_LAST_NAME] = credentials.approver.lastName;\n }\n }\n\n // -- K8s\n const kubernetes = resolveKubernetesEnvVars(environment);\n setIfDefined(env, PlatformKubernetesEnvKeys.K8S_NAMESPACE, kubernetes?.namespace);\n\n // -- Public domain (runtime-agnostic — emitted for both K8s and Compose)\n env[PlatformIngressEnvKeys.WILDO_PUBLIC_DOMAIN] = environment.publicDomain;\n\n // -- Per-service subdomain map (serviceHosts) — lets apps-manager resolve\n // each customer-app service's public host from the operator's authored\n // subdomains (serviceHosts-driven ingress). Emitted only when authored.\n if (environment.serviceHosts && Object.keys(environment.serviceHosts).length > 0) {\n env[PlatformIngressEnvKeys.WILDO_SERVICE_HOSTS] = JSON.stringify(environment.serviceHosts);\n }\n\n // -- Logging posture (authored on infra config; LoggerService reads at boot)\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n\n // -- OTLP telemetry posture (Slice 2 Phase 5b — platform-host spread). The auth header is\n // resolved provider-agnostically from the platform's `providerEnv` (audit A-9): emitted in\n // PROD when a telemetry-provider token is provisioned for the platform, omitted for the\n // localhost dev collector (no token → no auth; telemetry still flows unauthenticated).\n emitObservabilityEnv(\n env,\n config.observability,\n {\n serviceName: amCatalog.serviceEnvVarName,\n environment: resolveApplicationEnv(environment, config),\n version: options.serviceVersion,\n },\n // Platform tier: entitled to every provider secret by deliberate declaration, so the scope\n // subtracts nothing here. Routed through `resolveRuntimeProviderEnv` anyway — #360 asks\n // that the telemetry header have ONE input shape across all five call sites, so that the\n // application-tier sites are not the only ones a reader has to check.\n { providerEnv: resolveRuntimeProviderEnv(credentials, platformTierAllProvidersScope()) },\n );\n\n // -- Optional GitHub\n if (credentials.github) {\n setIfDefined(env, PlatformAdminEnvKeys.GITHUB_WILDO_APPS_DEFAULT_ORG_URL, credentials.github.orgUrl);\n setIfDefined(env, PlatformAdminEnvKeys.GITHUB_WILDO_APPS_ADMIN_USER, credentials.github.adminUser);\n setIfDefined(env, PlatformAdminEnvKeys.GITHUB_WILDO_APPS_ADMIN_TOKEN, credentials.github.adminToken);\n }\n\n return env;\n }\n\n /**\n * Bootstrap env for non-apps-manager platform services.\n *\n * All platform service URLs and infrastructure addresses are sourced from env\n * vars. Services fetch only jwtPublicKeys + secrets from apps-manager.\n */\n static buildBootstrapEnv(\n service: BootstrapPlatformService,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n /** The bootstrap host's own `package.json` version → OTel `service.version` (audit A-10 parity). */\n serviceVersion?: string,\n ): Record<string, string> {\n assertSupportedStorageConfig(config);\n\n const env: Record<string, string> = {};\n\n const svcCatalog = PLATFORM_SERVICE_CATALOG[service];\n env[PlatformProcessEnvKeys.HOST] = LISTEN_HOST;\n env[svcCatalog.portEnvVarName] = String(svcCatalog.defaultPort);\n env[PlatformProcessEnvKeys.SERVICE_NAME] = svcCatalog.serviceEnvVarName;\n env[PlatformProcessEnvKeys.PLATFORM_ENVIRONMENT_ID] = environment.name;\n env[PlatformProcessEnvKeys.APPLICATION_ENV] = resolveApplicationEnv(environment, config);\n env[PlatformSecurityEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] = credentials.platform.primarySecret;\n // #2898 — a platform service verifies apps-manager's answers against the response key set; it no longer needs\n // apps-manager's P2P public key, which it only ever used for a response check that failed open.\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n\n // -- Platform service URLs (all services get all URLs for inter-service communication)\n env[PlatformServiceUrlEnvKeys.PLATFORM_APPS_MANAGER_URL] = addresses.platform.appsManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_URL] = addresses.platform.crontabsBatchesManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_MODULE_REGISTRY_URL] = addresses.platform.moduleRegistry.url;\n\n // -- Storage (MinIO) — the ADDRESS only. Both bootstrap services run backend-lib's file storage, and\n // both obtain short-lived, prefix-confined STS sessions from apps-manager\n // (`createPlatformServiceStsStorageCredentialResolver`, bound in each service's container, with\n // deliberately no env fallback).\n //\n // ⚠️ STORAGE_ACCESS_KEY / STORAGE_SECRET_KEY are deliberately ABSENT (#1761). They are the object\n // store's ROOT credential, and they were emitted here and never read: a compromise of the module\n // registry or the crontabs manager yielded the root of the whole storage plane for nothing. Only\n // apps-manager, the STS issuer, holds them (`buildAppsManagerFullEnv`).\n const minio = requireAddress(addresses.infra.minio, 'minio');\n env[PlatformInfrastructureEnvKeys.STORAGE_PROVIDER] = config.infrastructure.storage.provider;\n env[PlatformInfrastructureEnvKeys.STORAGE_ENDPOINT] = minio.host;\n env[PlatformInfrastructureEnvKeys.STORAGE_PORT] = String(minio.port);\n env[PlatformInfrastructureEnvKeys.STORAGE_USE_SSL] = String(config.infrastructure.storage.useSsl);\n // The platform bucket (#1112), the same value apps-manager's env carries — see `buildAppsManagerFullEnv`.\n env[PlatformInfrastructureEnvKeys.STORAGE_BUCKET] = resolvePlatformObjectStorageBucket(config.platformStorage);\n\n // -- Logging posture (authored on infra config; LoggerService reads at boot)\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n\n // -- OTLP telemetry posture (Slice 2 Phase 5b — platform-host spread; covers crontabs-batches-\n // manager + module-registry). Auth header resolved provider-agnostically from the platform's\n // `providerEnv` (audit A-9) — emitted in prod when a token is provisioned, omitted for the\n // localhost dev collector.\n emitObservabilityEnv(\n env,\n config.observability,\n {\n serviceName: svcCatalog.serviceEnvVarName,\n environment: resolveApplicationEnv(environment, config),\n version: serviceVersion,\n },\n // Platform tier — see the apps-manager site above for why this is routed through the scope\n // resolver even though `PLATFORM_TIER_ALL_PROVIDERS` subtracts nothing.\n { providerEnv: resolveRuntimeProviderEnv(credentials, platformTierAllProvidersScope()) },\n );\n\n // -- MongoDB connection — among the bootstrap services, ONLY module-registry rides the framework's\n // `StartApplicationBackendService`, which opens the PLATFORM_MANAGEMENT connection from\n // `MONGO_CONNECT_URL`. `crontabs-batches-manager` uses a custom two-phase startup that bridges\n // platform config for its Mongo access and never reads this var, so the emission is scoped to it.\n if (service === PlatformWildoServices.MODULE_REGISTRY) {\n emitPlatformMongoEnv(env, credentials, addresses, config, environment);\n // The platform's OWN PostgreSQL (D7/5.6): module-registry now carries the same\n // pre-connect + construction-time-adapter wiring as apps-manager, and BOTH must derive the\n // store from the same env truth — the whole point is that a flipped platform cannot split\n // a shared resource across services.\n emitPlatformPostgresEnv(env, credentials, addresses, config, environment);\n }\n\n // -- Per-service infra addresses + extras\n PlatformEnvVarsBuilder.addServiceExtras(service, env, credentials, addresses, config);\n\n return env;\n }\n\n /**\n * Build the local companion API env from platform-focused runtime material.\n *\n * The companion API is not an application backend anymore from an env-contract\n * perspective: it connects to the platform management database and backing\n * services, while still receiving the authored application runtime topology so\n * companion services can reason about the local app surfaces.\n */\n static buildCompanionPlatformEnv(\n bootstrapCredentials: AppBootstrapCredentials,\n serviceName: string,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n options?: {\n runtimeEndpoints?: Record<string, { publicUrl: string; internalUrl: string }>;\n host?: string;\n port?: number;\n /**\n * Selected `OBSERVABILITY_TELEMETRY` provider ref (Slice 2 Phase 5b) — resolved by the\n * caller from the `saasConfig` selection. `emitObservabilityEnv` uses it to derive the\n * OTLP auth header from the provider's secret token. Omitted = no-auth export.\n */\n observabilityProviderRef?: string;\n /**\n * Service version (Slice 2 A-10) — the companion host's `package.json` version, emitted as\n * the OTel `service.version` resource attribute. Threaded by the env-gen from the companion's\n * own `relativeDir` so traces/metrics/logs carry the running build version.\n */\n serviceVersion?: string;\n },\n ): Record<string, string> {\n assertSupportedStorageConfig(config);\n\n const env: Record<string, string> = {};\n\n env[ApplicationBackendBootstrapEnvKeys.APPLICATION_ID] = bootstrapCredentials.APPLICATION_ID;\n env[PlatformProcessEnvKeys.HOST] = options?.host ?? LISTEN_HOST;\n env[PlatformProcessEnvKeys.PORT] = String(options?.port ?? 4341);\n env[PlatformProcessEnvKeys.SERVICE_NAME] = serviceName;\n env[PlatformProcessEnvKeys.PLATFORM_ENVIRONMENT_ID] = environment.name;\n env[PlatformProcessEnvKeys.APPLICATION_ENV] =\n bootstrapCredentials.APPLICATION_ENV ?? resolveApplicationEnv(environment, config);\n // #1177 — the application this process belongs to. `SERVICE_NAME` names the PROCESS, so a logger\n // with no configuration yet could name neither the application nor the environment.\n env[PlatformProcessEnvKeys.APPLICATION_SLUG] = bootstrapCredentials.APPLICATION_SLUG;\n env[PlatformSecurityEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] =\n bootstrapCredentials.PLATFORM_APPLICATION_PRIMARY_SECRET;\n // #2898 — the companion verifies apps-manager's answers with the response key set (emitted below with the other\n // runtime bootstrap keys); apps-manager's P2P public key was required here and read by nothing.\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n /*\n * The RESOLVER, not the credential echo — the same source its two siblings below already use.\n *\n * `bootstrapCredentials.PLATFORM_APPS_MANAGER_URL` is apps-manager reporting its OWN address,\n * which is correct only when the reader shares its network. In framework-developer mode\n * apps-manager runs natively beside the application, so it reports `localhost:5151` and this\n * was invisible. In app-creator mode apps-manager is a CONTAINER: it reports its\n * container-internal address, and the application backend — which `wildo local dev` runs on the\n * HOST — died at startup with\n * Failed to load platform managed secrets: getaddrinfo ENOTFOUND platform-apps-manager-internal\n * while `REDIS_HOST` and `RABBITMQ_HOST` in the very same file were correctly `localhost`.\n * Measured 2026-09-11, on the first app-creator run that got far enough to write this file at all.\n *\n * `addresses.platform.*` is perspective-aware by construction (HOST_FACING → localhost + the\n * published port; CONTAINER_INTERNAL → the data-network alias), which is exactly the question\n * being asked here. Two of these three keys already trusted it; the third now does too.\n */\n env[PlatformServiceUrlEnvKeys.PLATFORM_APPS_MANAGER_URL] = addresses.platform.appsManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_URL] =\n addresses.platform.crontabsBatchesManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_MODULE_REGISTRY_URL] = addresses.platform.moduleRegistry.url;\n\n emitPlatformMongoEnv(env, credentials, addresses, config, environment);\n // The PostgreSQL mirror, and a NO-OP on a Mongo-engined platform (neither key is written,\n // so existing companion `.env` material is byte-identical). See the emitter's header for\n // why the companion became a caller only once its startup could honor these keys.\n emitPlatformPostgresEnv(env, credentials, addresses, config, environment);\n\n const valkey = requireAddress(addresses.infra.valkey, 'valkey');\n const rabbitmq = requireAddress(addresses.infra.rabbitmq, 'rabbitmq');\n const rabbitmqMgmt = requireAddress(addresses.infra.rabbitmqManagement, 'rabbitmqManagement');\n const minio = requireAddress(addresses.infra.minio, 'minio');\n\n /**\n * The APPLICATION's PostgreSQL topology — address only, and the companion needs it for a reason\n * that is easy to miss: it is not an application backend from an env-contract perspective (see\n * this method's header), but it DOES load the application's resource registry, and that registry\n * refuses to initialize when a resource declares `persistenceAdapter: 'postgresql'` while\n * `database.postgresql` is absent.\n *\n * The loader builds that branch only when a HOST arrives, so a companion that never received one\n * had `postgresql.enabled === false` by construction and rejected the resource with\n * \"PostgreSQL is not enabled in database config\" — a runtime enforcing an adapter constraint\n * against topology it was never given. Measured 2026-08-27: the backend and the minions booted\n * the same registry fine; only the companion crash-looped, which is exactly how a per-runtime env\n * gap presents.\n *\n * Emitted under the APPLICATION-backend keys, not the platform ones, because that is the contract\n * the app-configuration loader reads. Credentials stay out: they travel through\n * `secrets.database.postgresql`, as MongoDB's do. Address makes the adapter REACHABLE; it does\n * not make it SELECTED — selection remains `DATABASE_DEFAULT_ADAPTER`, per the rule stated at the\n * application-backend block.\n */\n const companionPostgresql = addresses.infra.postgresql;\n if (companionPostgresql) {\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_HOST] = companionPostgresql.host;\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_PORT] = String(companionPostgresql.port);\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.POSTGRESQL_DATABASE,\n config.backingServices?.[BackingServiceKind.POSTGRESQL]?.database,\n );\n }\n\n env[PlatformInfrastructureEnvKeys.REDIS_HOST] = valkey.host;\n env[PlatformInfrastructureEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n if (credentials.valkey) {\n env[PlatformInfrastructureEnvKeys.REDIS_ADMIN_USER] = credentials.valkey.adminUser;\n env[PlatformInfrastructureEnvKeys.REDIS_ADMIN_PASSWORD] = credentials.valkey.adminPassword;\n }\n\n env[PlatformInfrastructureEnvKeys.RABBITMQ_HOST] = rabbitmq.host;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_PORT] = String(rabbitmq.port);\n env[PlatformInfrastructureEnvKeys.RABBITMQ_MANAGEMENT_PORT] = String(rabbitmqMgmt.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.RABBITMQ_VHOST,\n resolveApplicationBackingServiceAddressing(config).rabbitmqVhost,\n );\n env[PlatformInfrastructureEnvKeys.RABBITMQ_ADMIN_USERNAME] = credentials.rabbitmq.adminUsername;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_ADMIN_PASSWORD] = credentials.rabbitmq.adminPassword;\n\n // -- Storage: TOPOLOGY only. The ROOT credential is deliberately ABSENT.\n //\n // The companion is platform-tier for Mongo/Redis/RabbitMQ — it is a local admin\n // tool and legitimately holds those. For STORAGE it is not: it runs the same\n // app-tier `WildoManagedStorageProvider` as backend-api (through\n // `FileStorageRouterBackendService`) and holds the full four-var bootstrap\n // contract, so it fetches short-lived, prefix-confined STS sessions exactly as\n // an application does.\n //\n // So this is not a tier judgment — the pair was emitted and NEVER READ. Its only\n // effect was to keep the object store's root credential in a `.env` on a\n // developer's disk for the lifetime of the dev stack. Measured before removal:\n // the companion source referenced `STORAGE_ACCESS_KEY` / `STORAGE_SECRET_KEY`\n // in its env SCHEMA and nowhere else.\n env[PlatformInfrastructureEnvKeys.STORAGE_PROVIDER] = config.infrastructure.storage.provider;\n env[PlatformInfrastructureEnvKeys.STORAGE_ENDPOINT] = minio.host;\n env[PlatformInfrastructureEnvKeys.STORAGE_PORT] = String(minio.port);\n env[PlatformInfrastructureEnvKeys.STORAGE_USE_SSL] = String(config.infrastructure.storage.useSsl);\n env[PlatformInfrastructureEnvKeys.STORAGE_BUCKET] = resolveApplicationBackingServiceAddressing(config).objectStorageBucket;\n\n // -- Logging posture (authored on infra config; LoggerService reads at boot)\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n\n // -- OTLP telemetry posture (Slice 2 Phase 5 — projected to OTEL_*, read by the preload).\n // Audit A-16: `bootstrapCredentials.APPLICATION_ENV` is the companion's environment source\n // (it's `resolveApplicationEnv`-derived and reliably set by the bootstrap pipeline). The\n // backend's `options.applicationEnv` override is not plumbed to the companion options — a\n // low-priority consistency gap, not a missing-env risk.\n //\n // The telemetry header and the provider fan-out below read the SAME resolved bag (#360):\n // one value per builder, so the two delivery paths cannot come to disagree about what this\n // runtime is entitled to. Platform tier, so nothing is subtracted.\n const companionProviderEnv = resolveRuntimeProviderEnv(credentials, platformTierAllProvidersScope());\n emitObservabilityEnv(\n env,\n config.observability,\n { serviceName, environment: bootstrapCredentials.APPLICATION_ENV, version: options?.serviceVersion },\n { ref: options?.observabilityProviderRef, providerEnv: companionProviderEnv },\n );\n\n const runtimeEndpoints = options?.runtimeEndpoints;\n if (runtimeEndpoints && Object.keys(runtimeEndpoints).length > 0) {\n const preservedCompanionEndpoint = runtimeEndpoints[serviceName];\n env[ApplicationBackendRuntimeEnvKeys.APPLICATION_RUNTIME_ENDPOINTS] =\n serializeRuntimeEndpointsRecord({\n ...runtimeEndpoints,\n [PlatformRuntimeEndpointKey.PLATFORM_APPS_MANAGER]: {\n publicUrl: addresses.platform.appsManager.url,\n internalUrl: addresses.platform.appsManager.url,\n },\n [PlatformRuntimeEndpointKey.PLATFORM_CRONTABS_BATCHES_MANAGER]: {\n publicUrl: addresses.platform.crontabsBatchesManager.url,\n internalUrl: addresses.platform.crontabsBatchesManager.url,\n },\n appsManager: {\n publicUrl: addresses.platform.appsManager.url,\n internalUrl: addresses.platform.appsManager.url,\n },\n crontabsBatchesManager: {\n publicUrl: addresses.platform.crontabsBatchesManager.url,\n internalUrl: addresses.platform.crontabsBatchesManager.url,\n },\n [serviceName]: {\n publicUrl: preservedCompanionEndpoint?.publicUrl ?? `http://localhost:${options?.port ?? 4341}`,\n internalUrl: preservedCompanionEndpoint?.internalUrl ?? `http://localhost:${options?.port ?? 4341}`,\n },\n });\n }\n\n // Platform tier: the companion is a declared platform-admin consumer and\n // mirrors the full provider surface for local tooling. Same bag the telemetry\n // header above resolved.\n for (const [envVarName, value] of Object.entries(companionProviderEnv)) {\n setIfDefined(env, envVarName, value);\n }\n\n return env;\n }\n\n /**\n * Build env vars for application backend services (e.g., wonder-todos backend-api).\n *\n * Application backends get their infra addresses and platform URLs from env\n * vars. Only jwtPublicKeys + secrets are fetched from apps-manager at startup.\n */\n static buildApplicationBackendEnv(\n bootstrapCredentials: AppBootstrapCredentials,\n serviceName: string,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environmentId: string,\n /**\n * What this runtime is entitled to. REQUIRED and positional — deliberately not a field on\n * `options` below, because an optional field is bypassable by omission and this decision must\n * not be. A new call site that does not decide does not compile.\n *\n * Application-tier callers pass `declaredProviderScope(refs)` with the refs authored under\n * `providers.scopes.{backend,workers.<name>,minions.<name>}.providers`. A caller that\n * legitimately needs the full provider surface is platform-tier and should not be using this\n * builder at all — `platformTierAllProvidersScope()` exists for those, and is unreachable from\n * here by construction of the call graph, not by convention.\n */\n providerScope: RuntimeProviderScope,\n options: {\n /** The app's release version (the host's package.json `version`), projected as\n * `service.version` in `OTEL_RESOURCE_ATTRIBUTES` (audit A-10). Omitted when absent. */\n serviceVersion?: string;\n appDatabaseName?: string;\n /**\n * WHICH backing services this runtime may reach (Step 5-egress / R-COHERENCE).\n *\n * Omitted means \"the application backend\" — which is what this builder is\n * NAMED for, not a permissive default. It is still derived from\n * `resolveRuntimeBackingServiceAccess` rather than written as a literal, so\n * there is exactly one description of what a backend may reach.\n *\n * A runtime kept OUT of a backing service's network must not receive that\n * service's topology either. Emitting it anyway makes `isConfigured()` true,\n * a probe or a first use runs, and an unroutable host fails as a timeout for\n * a runtime that was never supposed to have the service at all — which reads\n * as \"service down\" rather than \"not mine\". The two must derive from ONE\n * declaration, and this is how that reaches env generation.\n */\n runtimeAccess?: RuntimeBackingServiceAccess;\n /**\n * Authored `wildo.saas.config.dataServices.redis.keyPrefix` (Slice 3.6).\n * When provided, projected as `REDIS_KEY_PREFIX` in the generated\n * `.env`. Consumed at runtime by `RedisService` as the canonical\n * app-level key namespace (replaces the legacy username-derived\n * prefix). Omitted when undefined.\n */\n redisKeyPrefix?: string;\n /**\n * Authored `wildo.saas.config.dataServices.s3.bucketPrefix` (Slice\n * 3.6). When provided, projected as `STORAGE_BUCKET_PREFIX` in the\n * generated `.env`. Consumed at runtime by\n * `WildoManagedStorageProvider` and prepended to every application\n * object key. The actual MinIO bucket name (`STORAGE_BUCKET`) is\n * unaffected. Omitted when undefined.\n */\n storageBucketPrefix?: string;\n applicationEnv?: string;\n /** Canonical local/remote topology from the selected infra environment; never infer it from APPLICATION_ENV or the environment id. */\n deploymentLocationType: WildoLocationType;\n /** Exact shared runtime-signals home. Configure only for a local host lane where backend and companion see the same filesystem. */\n runtimeSignalsHome?: string;\n runtimeEndpoints?: Record<string, { publicUrl: string; internalUrl: string }>;\n mongodbDirectConnection?: boolean;\n /**\n * Selected `OBSERVABILITY_TELEMETRY` provider ref (Slice 2 Phase 5b) — resolved by the\n * caller from the `saasConfig` backend-scope selection; `emitObservabilityEnv` uses it to\n * derive the OTLP auth header from the provider's secret token. Omitted = no-auth export.\n */\n observabilityProviderRef?: string;\n /**\n * Backend→worker dispatch URLs (G-8 / MW4), keyed by the worker's\n * `wildo.saas.config.ts` bucket name. Each entry is emitted as\n * `WILDO_WORKER_<NAME>_URL` so the backend's `WorkerRemoteClientFactory`\n * can reach the worker's per-app k8s Service. Computed remote-only by\n * `buildApplicationBackendTargets`; omitted for local (no k8s Services).\n */\n workerUrls?: Record<string, string>;\n /**\n * The address this backend's HTTP server listens on, emitted as `HOST` (which overrides the host of its own\n * runtime endpoint). Set by the native LOCAL lane only (`LOCAL_APPLICATION_BACKEND_LISTEN_HOST`, #3382);\n * a containerised backend listens on whatever its container gives it and receives none.\n */\n listenHost?: string;\n /**\n * The host's Docker bridge gateway, emitted as `CONTAINER_HOST_GATEWAY_LISTEN_HOST`: a second address the HTTP\n * server accepts connections on, so a compose minion or worker on Docker Engine for Linux reaches this host-run\n * backend through `host.docker.internal` (#3387). Set by the native LOCAL lane only, and only when\n * `resolveContainerHostGatewayListenHost` found the gateway on an interface of this host; never with a containerised\n * backend, which is reached by its service name.\n */\n containerHostGatewayListenHost?: string;\n },\n ): Record<string, string> {\n if (options.runtimeSignalsHome !== undefined && options.deploymentLocationType !== WildoLocationType.LOCAL) {\n throw new Error('APPLICATION_RUNTIME_SIGNALS_HOME can only be emitted for explicit local deployment topology');\n }\n const env: Record<string, string> = {};\n\n // -- Bootstrap identity\n env[ApplicationBackendBootstrapEnvKeys.APPLICATION_ID] = bootstrapCredentials.APPLICATION_ID;\n env[ApplicationBackendBootstrapEnvKeys.SERVICE_NAME] = serviceName;\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_ENVIRONMENT_ID] = environmentId;\n env[ApplicationBackendBootstrapEnvKeys.DEPLOYMENT_LOCATION_TYPE] = options.deploymentLocationType;\n /*\n * #2303 — the environment's service profile, so the application's boot can refuse a capability whose service\n * the profile omits and say why. Emitted only for a non-default profile: absence means FULL on both sides, so an\n * environment that never declared one keeps a byte-identical env file. Minions inherit it through the\n * delegation in `buildApplicationMinionEnv`, and their boot asserts the same refusals.\n */\n const serviceProfile = config.serviceProfile ?? DEFAULT_ENVIRONMENT_SERVICE_PROFILE;\n if (serviceProfile !== DEFAULT_ENVIRONMENT_SERVICE_PROFILE) {\n env[ApplicationBackendBootstrapEnvKeys.ENVIRONMENT_SERVICE_PROFILE] = serviceProfile;\n }\n if (options.listenHost !== undefined) {\n env[PlatformProcessEnvKeys.HOST] = options.listenHost;\n }\n if (options.containerHostGatewayListenHost !== undefined) {\n if (options.listenHost === undefined) {\n // The second listener exists beside an explicit loopback bind; without one it would describe nothing coherent.\n throw new Error('containerHostGatewayListenHost is emitted only beside an explicit listenHost (the native LOCAL lane, #3387)');\n }\n env[HttpServerEnvKey.CONTAINER_HOST_GATEWAY_LISTEN_HOST] = options.containerHostGatewayListenHost;\n }\n /*\n * -- The reverse proxies in front of this backend (#1788)\n *\n * Every remote application lane fronts the backend with exactly one Traefik: the cluster ingress in the\n * Kubernetes lane, the TLS-terminating edge in the remote compose lane. Without this the engine trusted\n * no proxy, `req.ip` was Traefik's address for every caller, and every per-IP lockout and rate limit\n * became one shared bucket. A local backend is reached directly and gets nothing: zero hops is the\n * engine's default, and a trusted hop that is not there would let a client pick its own address.\n *\n * Only APPLICATION backends: the platform services have no ingress in any lane and are reached\n * cluster-internally, so trusting a hop there would be exactly that spoofable case.\n */\n const trustedProxyHops = trustedProxyHopsForApplicationBackend(options.deploymentLocationType);\n if (trustedProxyHops > 0) {\n env[HttpServerEnvKey.HTTP_TRUSTED_PROXY_HOPS] = String(trustedProxyHops);\n }\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] =\n bootstrapCredentials.PLATFORM_APPLICATION_PRIMARY_SECRET;\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_URL] =\n addresses.platform.appsManager.url;\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n env[ApplicationBackendBootstrapEnvKeys.APPLICATION_ENV] =\n options?.applicationEnv ?? bootstrapCredentials.APPLICATION_ENV;\n // #1177 — see the companion builder above.\n env[PlatformProcessEnvKeys.APPLICATION_SLUG] = bootstrapCredentials.APPLICATION_SLUG;\n\n /*\n * -- The application's OWN operator-door secret (#586)\n *\n * `credentials.application.adminSecret`, NOT anything under `credentials.platform`: this is the\n * one admin secret that must reach an application runtime, and the confinement guard below\n * (`assertNoPlatformCredentialInGeneratedEnv`) refuses every platform-tier credential in an\n * application-tier env. Filing it on the platform tier would have made it unemittable by the\n * guard that exists to protect this boundary.\n *\n * Emitted only when PRESENT. Absence is a working state with a defined meaning — both consuming\n * controllers answer `503 INFRASTRUCTURE` on an unset value, deliberately — so a `secrets.json`\n * predating this key yields an app that boots and simply has no operator doors, rather than one\n * that fails to render its env. The idempotent self-heal mints it on the next command.\n */\n if (credentials.application?.adminSecret) {\n env[ApplicationBackendRuntimeEnvKeys.APPLICATION_ADMIN_SECRET] = credentials.application.adminSecret;\n }\n\n // -- Platform service URLs\n env[ApplicationBackendPlatformUrlEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_URL] =\n addresses.platform.crontabsBatchesManager.url;\n env[ApplicationBackendPlatformUrlEnvKeys.PLATFORM_MODULE_REGISTRY_URL] =\n addresses.platform.moduleRegistry.url;\n\n // -- App runtime topology (local/backend bootstrap derived)\n const runtimeEndpoints = options?.runtimeEndpoints;\n if (runtimeEndpoints && Object.keys(runtimeEndpoints).length > 0) {\n env[ApplicationBackendRuntimeEnvKeys.APPLICATION_RUNTIME_ENDPOINTS] =\n serializeRuntimeEndpointsRecord(runtimeEndpoints);\n }\n setIfDefined(env, ApplicationBackendRuntimeEnvKeys.APPLICATION_RUNTIME_SIGNALS_HOME, options.runtimeSignalsHome);\n\n // -- Backend→worker dispatch URLs (G-8 / MW4). One `WILDO_WORKER_<NAME>_URL`\n // per declared worker so the backend's WorkerRemoteClientFactory can reach\n // each worker's per-app k8s Service. The env-key normalization lives in the\n // shared `wildoWorkerUrlEnvKey` helper that the backend read-side also uses,\n // so emit and read cannot drift.\n const workerUrls = options?.workerUrls;\n if (workerUrls) {\n for (const [workerName, url] of Object.entries(workerUrls)) {\n setIfDefined(env, wildoWorkerUrlEnvKey(workerName), url);\n }\n }\n\n // Which backing services MAY this runtime reach? One source, shared with the\n // network membership of both deployment lanes; the credential mint reaches the\n // same store through the same resolved engine, and a structural test holds the\n // three together (#3367).\n // Bounded by the application's own store (#3367): the topology of the OTHER store is withheld even when the\n // environment provides it, because no credential for it is ever minted to an application runtime.\n const runtimeAccess = options?.runtimeAccess\n ?? resolveRuntimeBackingServiceAccess(\n { kind: ApplicationRuntimePrincipalKind.APPLICATION_BACKEND } as ApplicationRuntimePrincipal,\n undefined,\n { applicationDatabaseEngine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n );\n const mayReach = (capability: InfraCapability): boolean => runtimeAccess.capabilities.has(capability);\n\n // -- Database addresses (same infra, app-specific database name)\n // `environmentProvidesMongoDb`, not merely `addresses.infra.mongodb` — see that helper. An\n // application whose environment renders no mongod must receive NO Mongo address at all, or its\n // backend spends every boot dialling a server that does not exist and fails its readiness gate\n // on a dependency it does not have.\n const mongodb = environmentProvidesMongoDb(config) ? addresses.infra.mongodb : undefined;\n const appMongoDatabase = pickAppMongoDatabase(config.backingServices, options?.appDatabaseName);\n if (mongodb && mayReach(InfraCapability.DOCUMENT_DATABASE)) {\n env[ApplicationBackendDataEnvKeys.MONGODB_HOST] = `${mongodb.host}:${mongodb.port}`;\n env[ApplicationBackendDataEnvKeys.MONGODB_DATABASE] = appMongoDatabase;\n env[ApplicationBackendDataEnvKeys.MONGODB_PROTOCOL] = MongoDBProtocol.MONGODB;\n if (options?.mongodbDirectConnection !== undefined) {\n env[ApplicationBackendDataEnvKeys.MONGODB_DIRECT_CONNECTION] = String(options.mongodbDirectConnection);\n }\n } else if (config.externalEndpoints?.mongodb?.connectionUrl && mayReach(InfraCapability.DOCUMENT_DATABASE)) {\n const atlasMongoEnv = buildMongoEnvFromConnectionUrl(\n config.externalEndpoints.mongodb.connectionUrl,\n appMongoDatabase,\n );\n env[ApplicationBackendDataEnvKeys.MONGODB_HOST] = atlasMongoEnv.host;\n env[ApplicationBackendDataEnvKeys.MONGODB_DATABASE] = atlasMongoEnv.database;\n env[ApplicationBackendDataEnvKeys.MONGODB_PROTOCOL] = atlasMongoEnv.protocol;\n if (atlasMongoEnv.tls !== undefined) {\n env[ApplicationBackendDataEnvKeys.MONGODB_TLS] = String(atlasMongoEnv.tls);\n }\n if (atlasMongoEnv.replicaSet) {\n env[ApplicationBackendDataEnvKeys.MONGODB_REPLICA_SET] = atlasMongoEnv.replicaSet;\n }\n }\n\n /**\n * PostgreSQL TOPOLOGY — emitted when the environment self-hosts or points at one AND it is the application's own\n * store (#3367: `mayReach` is bounded by the engine, so a MongoDB application's runtimes get no PostgreSQL host).\n *\n * ADDRESS ONLY, and the restraint is the point. The loader builds a `database.postgresql` branch\n * only when a host arrives, so these keys are what make the adapter REACHABLE; they do not make\n * it SELECTED. Selection is `DATABASE_DEFAULT_ADAPTER`, whose own contract rejects being derived\n * from key presence — \"which store an application persists to is a deployment decision that must\n * be legible in one place, not an emergent property of which variables happen to be set\". The\n * selection is written below, from the RESOLVED `applicationDatabase` (#1571).\n *\n * Credentials are deliberately absent: they travel through `secrets.database.postgresql`, exactly\n * as MongoDB's do. Env carries where the database is; secrets carry who may open it.\n */\n const postgresql = addresses.infra.postgresql;\n if (postgresql && mayReach(InfraCapability.RELATIONAL_DATABASE)) {\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_HOST] = postgresql.host;\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_PORT] = String(postgresql.port);\n // The app's own database, falling back to the authored backing-service name and then to the\n // Mongo-side app database name — one application, one logical database, whichever store holds it.\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_DATABASE] =\n config.backingServices?.[BackingServiceKind.POSTGRESQL]?.database ?? appMongoDatabase;\n }\n\n /**\n * PostgreSQL SELECTION for the application — a separate decision from the ADDRESS block above.\n *\n * The block above deliberately emits address keys only, on the rule stated beside it: *\"which\n * store an application persists to is a deployment decision that must be legible in one place,\n * not an emergent property of which variables happen to be set\"*. That rule is why selection is\n * NOT derived from the presence of a host, and why it needs an authored source.\n *\n * `applicationDatabase` is that source. Until it existed, the only way to move an application to\n * PostgreSQL was to hand-edit `backend-api/.env` — machine-local, ungitted, and not reproducible\n * on another developer's machine.\n *\n * Emitted for BOTH engines, from `resolveApplicationDatabaseEngine` — so an absent\n * `applicationDatabase` selects PostgreSQL here exactly as it does in apps-manager's provisioning\n * (#1571). Until then only POSTGRESQL was written and MongoDB was left to the env key's own\n * default; that default also governs PLATFORM services, so leaning on it made the application's\n * store a side effect of a platform contract. Now the application never reaches it.\n */\n const applicationEngine = resolveApplicationDatabaseEngine(config.applicationDatabase);\n /*\n * A runtime that may not reach the selected store gets NO selection: it has no database, and a\n * selection naming one would send it looking. Gated on the SAME capability as the address, so the\n * two cannot disagree — the throw below is reserved for a runtime that may reach PostgreSQL and was\n * given no address to reach it at.\n */\n if (applicationEngine === DatabaseEngine.MONGODB && mayReach(InfraCapability.DOCUMENT_DATABASE)) {\n env[ApplicationBackendDataEnvKeys.DATABASE_DEFAULT_ADAPTER] = PersistenceAdapter.MONGODB;\n }\n if (applicationEngine === DatabaseEngine.POSTGRESQL && mayReach(InfraCapability.RELATIONAL_DATABASE)) {\n if (!postgresql) {\n // Asserted rather than emitting a selection whose substrate is unreachable. `defineInfraEnvConfig`\n // already refuses this combination at authoring time, so reaching here means the address\n // resolver and that refinement disagree — a CLI bug, and one that would otherwise surface as\n // the application backend failing to open a connection three layers away.\n throw new Error(\n 'the application persists to PostgreSQL (declared, or selected because applicationDatabase is absent) '\n + 'but no postgresql address resolved for this '\n + 'environment. Declare `backingServices.postgresql` and re-run `wildo config sync`; if it IS '\n + 'declared, this is a CLI bug — report it with the environment name and `wildo.infra.<env>.config.ts`.',\n );\n }\n env[ApplicationBackendDataEnvKeys.DATABASE_DEFAULT_ADAPTER] = PersistenceAdapter.POSTGRESQL;\n }\n\n const valkey = addresses.infra.valkey;\n if (valkey && mayReach(InfraCapability.CACHE_MANAGER)) {\n env[ApplicationBackendDataEnvKeys.REDIS_HOST] = valkey.host;\n env[ApplicationBackendDataEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n }\n // App-level Redis key namespace (Slice 3.6 — sourced from\n // `wildo.saas.config.dataServices.redis.keyPrefix`). Independent of\n // whether a valkey address is wired so future external Redis paths\n // still receive the prefix.\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.REDIS_KEY_PREFIX,\n options?.redisKeyPrefix,\n );\n\n const rabbitmq = addresses.infra.rabbitmq;\n if (rabbitmq && mayReach(InfraCapability.QUEUING_SYSTEM)) {\n env[ApplicationBackendDataEnvKeys.RABBITMQ_HOST] = rabbitmq.host;\n env[ApplicationBackendDataEnvKeys.RABBITMQ_PORT] = String(rabbitmq.port);\n // The SAME derivation apps-manager is sent at registration (#1107), so the vhost this backend\n // connects to is the one its broker principal is granted on.\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.RABBITMQ_VHOST,\n resolveApplicationBackingServiceAddressing(config).rabbitmqVhost,\n );\n }\n\n /**\n * The virus scanner (#1910) — emitted when the environment declares ClamAV, at the address THIS runtime reaches\n * it on. The engine switches scanning on exactly when `CLAMAV_HOST` is present (\"presence of a host IS the\n * opt-in\", `ClamAVScannerBackendService.isConfigured`), so a runtime left without it scans nothing: every upload a\n * field requires scanned, and every attachment a received email carries, ends `scan_failed` and is withheld.\n *\n * Until #1910 nothing emitted it here. The `clamav-self` infra module states `CLAMAV_HOST: 'clamav'`, but only for\n * apps-manager and the companion, and that docker name is unreachable from a host-run process anyway — so a\n * `wildo local dev` backend ran with a healthy `clamav` container beside it and scanned nothing.\n */\n const clamav = config.backingServices?.[BackingServiceKind.CLAMAV] !== undefined ? addresses.infra.clamav : null;\n if (clamav && mayReach(InfraCapability.ANTIVIRUS_SCANNING)) {\n env[ApplicationBackendDataEnvKeys.CLAMAV_HOST] = clamav.host;\n env[ApplicationBackendDataEnvKeys.CLAMAV_PORT] = String(clamav.port);\n }\n\n // -- Storage (MinIO) — backend-lib needs storage access for z_file() operations\n const minio = addresses.infra.minio;\n if (minio && mayReach(InfraCapability.OBJECT_STORAGE)) {\n assertSupportedStorageConfig(config);\n env[ApplicationBackendDataEnvKeys.STORAGE_PROVIDER] = config.infrastructure.storage.provider;\n env[ApplicationBackendDataEnvKeys.STORAGE_ENDPOINT] = minio.host;\n env[ApplicationBackendDataEnvKeys.STORAGE_PORT] = String(minio.port);\n env[ApplicationBackendDataEnvKeys.STORAGE_USE_SSL] = String(config.infrastructure.storage.useSsl);\n // The bucket apps-manager confines this runtime's storage credential to (#1107) — one derivation.\n env[ApplicationBackendDataEnvKeys.STORAGE_BUCKET] = resolveApplicationBackingServiceAddressing(config).objectStorageBucket;\n // ⚠️ STORAGE_ACCESS_KEY / STORAGE_SECRET_KEY are deliberately ABSENT here.\n //\n // Those two values are the object store's ROOT credential — the very same\n // pair assigned to `MINIO_ROOT_USER` / `MINIO_ROOT_PASSWORD` in\n // `buildInfraCredentialEnv` above. Emitting them here handed the root\n // account to every application backend, every minion and every worker,\n // because `buildApplicationMinionEnv` delegates to this builder and the\n // k8s `{appSlug}-secret` is built from its output.\n //\n // Applications now obtain SHORT-LIVED, prefix-confined session credentials\n // from apps-manager at runtime (`GET /apps-to-manager/storage-session-credentials`),\n // so nothing in an application container needs a long-lived storage key.\n // The endpoint/bucket/provider values above are NOT secrets and stay.\n //\n // Do not re-add these \"so local dev works\" — that is the exact regression\n // `assertNoStorageSecretInGeneratedEnv` below exists to catch. If storage\n // fails, the STS route is the thing to fix.\n }\n // App-level object-key namespace prefix (Slice 3.6 — sourced from\n // `wildo.saas.config.dataServices.s3.bucketPrefix`). Independent of\n // whether managed MinIO is wired so future external storage paths\n // still receive the prefix.\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.STORAGE_BUCKET_PREFIX,\n options?.storageBucketPrefix,\n );\n\n // -- Logging posture (authored on infra config; LoggerService reads at boot)\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n emitEmailEnv(env, config.email);\n emitOwnershipDnsStandInEnv(env, config.ownershipDnsStandIn);\n\n // -- The runtime's entitled provider bag, resolved ONCE and read by both delivery paths\n // below: the OTLP auth header and the per-key fan-out. Two reads of one value, rather\n // than two derivations that can disagree — which is what #360 was (the header composed\n // from the raw bag while the fan-out was scoped, so a withheld token arrived anyway).\n const scopedProviderEnv = resolveRuntimeProviderEnv(credentials, providerScope);\n\n // -- OTLP telemetry posture (Slice 2 Phase 5 — projected to OTEL_*, read by the preload).\n // A runtime that does not declare the telemetry provider exports UNAUTHENTICATED (the\n // endpoint is still emitted) — see `resolveOtlpAuthHeader` for the decision and its cost.\n emitObservabilityEnv(\n env,\n config.observability,\n { serviceName, environment: options?.applicationEnv ?? bootstrapCredentials.APPLICATION_ENV, version: options?.serviceVersion },\n { ref: options?.observabilityProviderRef, providerEnv: scopedProviderEnv },\n );\n\n // -- Optional protocol-aware provider env bindings\n // Application tier: scoped to the runtime's declared providers. Covers\n // minions too — `buildApplicationMinionEnv` delegates here, and a minion\n // scoped to `openai` must not receive the application's Stripe key.\n for (const [envVarName, value] of Object.entries(scopedProviderEnv)) {\n setIfDefined(env, envVarName, value);\n }\n\n // -- Systems of record (#1055): the addresses this environment authored plus the operator's\n // credentials, both under names DERIVED from the instance name.\n //\n // Emitted HERE even though this builder also serves minions, because the alternative — a\n // flag on `options` — is bypassable by omission, which is exactly what this file refuses for\n // `providerScope`. The narrowing lives at the one delegating caller instead\n // (`buildApplicationMinionEnv`), where it is asserted rather than assumed.\n for (const [envVarName, value] of Object.entries(resolveSystemsOfRecordEnv(config, credentials))) {\n setIfDefined(env, envVarName, value);\n }\n\n // -- Inbound endpoint secrets (#1596): the backend mounts `/webhooks/app/{endpointKey}` and verifies with\n // these. Emitted here and stripped from minions at the one delegating caller, like the section above.\n for (const [envVarName, value] of Object.entries(resolveInboundEndpointEnv(credentials))) {\n setIfDefined(env, envVarName, value);\n }\n\n // Checked at the RETURN, after every contributor — including the provider\n // fan-out just above — rather than beside the storage block. A guard placed\n // next to the removal would only prove that one line stayed deleted; here it\n // catches the root credential arriving through any path, named anything.\n //\n // This is the gate for R5 of the storage plan, and it covers minions and\n // workers for free: `buildApplicationMinionEnv` delegates to this builder,\n // and the k8s `{appSlug}-secret` is built from its output.\n assertNoPlatformCredentialInGeneratedEnv(env, credentials, 'buildApplicationBackendEnv');\n\n return env;\n }\n\n /**\n * Build env vars for minion processes.\n *\n * Minions run the full backend pipeline (headless mode) via\n * `StartMinionApplicationBackendService`, so they receive the same env\n * contract as application backends: bootstrap identity, platform service\n * URLs, runtime topology, and all data-service wiring (MongoDB, Redis,\n * RabbitMQ, storage). The only semantic difference is the `serviceName`\n * field which carries the minion's service name (from `wildo.minion.config.ts`).\n */\n static buildApplicationMinionEnv(\n bootstrapCredentials: AppBootstrapCredentials,\n serviceName: string,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environmentId: string,\n /** The minion's declared scope — `providers.scopes.minions.<name>.providers`. Forwarded to the\n * backend builder below, which owns the filtering. Required for the same reason it is there. */\n providerScope: RuntimeProviderScope,\n /**\n * What this minion DECLARED — its authored `resourceAccess` and\n * `requiresInternetEgress`.\n *\n * REQUIRED for the same reason `providerScope` is: an omitted declaration and\n * a declaration of nothing are different statements, and only one of them may\n * be inferred. Absent `resourceAccess` means application-data access was never\n * requested, which withholds the object-storage topology (and every business\n * table from the credential). The DATABASE topology is still emitted: every\n * minion holds the engine-floor role and cannot boot without its store (#1771).\n */\n accessDeclaration: RuntimeAccessDeclaration,\n options: {\n /** The app's release version (the host's package.json `version`), projected as\n * `service.version` in `OTEL_RESOURCE_ATTRIBUTES` (audit A-10). Omitted when absent. */\n serviceVersion?: string;\n appDatabaseName?: string;\n redisKeyPrefix?: string;\n storageBucketPrefix?: string;\n applicationEnv?: string;\n deploymentLocationType: WildoLocationType;\n runtimeSignalsHome?: string;\n runtimeEndpoints?: Record<string, { publicUrl: string; internalUrl: string }>;\n mongodbDirectConnection?: boolean;\n },\n ): Record<string, string> {\n // Delegation is the trap this parameter exists for. The backend builder owns\n // the emission, so a minion inheriting it unchanged receives the BACKEND's\n // topology — every backing service, regardless of what it declared. Gating\n // inside that builder instead would narrow the application backend at the same\n // time, since this is its only delegating caller.\n const minionEnv = PlatformEnvVarsBuilder.buildApplicationBackendEnv(\n bootstrapCredentials,\n serviceName,\n credentials,\n addresses,\n config,\n environmentId,\n providerScope,\n {\n ...options,\n runtimeAccess: resolveRuntimeBackingServiceAccess(\n { kind: ApplicationRuntimePrincipalKind.MINION, name: serviceName } as ApplicationRuntimePrincipal,\n accessDeclaration,\n { applicationDatabaseEngine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n ),\n },\n );\n\n /*\n * The same delegation trap, one concern over (#1055 D2, R7).\n *\n * A system of record is read through the application's HTTP_API repositories, which only the\n * backend registers — a minion has no bound resource to read and no lane that would reach one.\n * So its address and credential are the backend's, and a minion inheriting them unchanged would\n * hold an ERP credential it can do nothing with, which is the definition of over-delivery.\n *\n * Stripped here rather than gated inside the builder, for the reason stated above the delegation:\n * gating there would narrow the application backend at the same time, and the backend is the one\n * runtime that must have them.\n */\n for (const envVarName of Object.keys(minionEnv)) {\n if (parseSystemOfRecordEnvVarName(envVarName) !== null) delete minionEnv[envVarName];\n // An inbound endpoint secret likewise: a minion mounts no route and could only leak it (#1596).\n if (parseInboundEndpointSecretEnvVarName(envVarName) !== null) delete minionEnv[envVarName];\n }\n // The backend's reverse-proxy hop count describes how its HTTP server is FRONTED (#1788). A minion\n // serves no HTTP and sits behind no proxy, so the fact does not describe it.\n delete minionEnv[HttpServerEnvKey.HTTP_TRUSTED_PROXY_HOPS];\n assertNoSystemOfRecordEnvInGeneratedEnv(minionEnv, 'buildApplicationMinionEnv');\n assertNoInboundEndpointEnvInGeneratedEnv(minionEnv, 'buildApplicationMinionEnv');\n\n return minionEnv;\n }\n\n /**\n * Build env vars for language-agnostic worker processes.\n *\n * Workers do NOT receive backend backing-service wiring. Their runtime\n * contract is the bootstrap identity plus optional provider/logging env\n * bindings so non-Node workers can stay env-driven without consuming the\n * generated TypeScript provider-runtime modules.\n */\n static buildApplicationWorkerEnv(\n bootstrapCredentials: AppBootstrapCredentials,\n workerName: string,\n serviceName: string,\n credentials: PlatformEnvSecretsJson,\n config: PlatformEnvConfigJson,\n environmentId: string,\n /** The worker's declared scope — `providers.scopes.workers.<name>.providers`. `myRustWorker`\n * authors `providers: {}`, so an EMPTY declared set is the correct answer there, and is a\n * different statement from \"the caller did not say\". Required for exactly that reason. */\n providerScope: RuntimeProviderScope,\n options?: {\n /**\n * The worker's authored inbound HTTP surface — `wildo.worker.config.ts >\n * http`, already default-applied by `WorkerHttpSchema`. Projected to the\n * canonical `WORKER_HTTP_PORT` / `WORKER_HEALTH_PATH` / `WORKER_READY_PATH`\n * (+ optional `WORKER_METRICS_PATH`) keys below so the running worker binds\n * the AUTHORED port and probe paths rather than a per-language hardcoded\n * default that only coincides with the authored value by luck. The env-gen\n * caller always threads this from the always-populated worker target; it is\n * `?`-optional only so the provider-env unit tests (which assert provider\n * fan-out, not the HTTP projection) can omit it. When omitted the worker\n * still binds its language-runtime default via `readWorkerHttpSurfaceEnv()`.\n */\n http?: WorkerHttp;\n applicationEnv?: string;\n /** The worker's release version (its package.json `version`) → `service.version` (audit A-10). */\n serviceVersion?: string;\n runtimeEndpoints?: Record<string, { publicUrl: string; internalUrl: string }>;\n /** Required with {@link runtimeSignalsHome}: the variable is a local filesystem handoff, never a remote one. */\n deploymentLocationType?: WildoLocationType;\n /** Where the worker records how its start ended (#3288); see `ApplicationWorkerRuntimeEnvKey.APPLICATION_RUNTIME_SIGNALS_HOME`. */\n runtimeSignalsHome?: string;\n /**\n * The addresses as THIS worker's process sees them (HOST_FACING for a host-run worker, CONTAINER_INTERNAL for\n * a container), so `PLATFORM_APPS_MANAGER_URL` is the resolver's answer, as for the application backend. Every\n * production caller passes it (#2955); without it the bootstrap echo below is used.\n */\n addresses?: ResolvedAddresses;\n },\n ): Record<string, string> {\n if (options?.runtimeSignalsHome !== undefined && options.deploymentLocationType !== WildoLocationType.LOCAL) {\n throw new Error('APPLICATION_RUNTIME_SIGNALS_HOME can only be emitted for explicit local deployment topology');\n }\n const env: Record<string, string> = {};\n\n env[ApplicationWorkerBootstrapEnvKeys.APPLICATION_ID] = bootstrapCredentials.APPLICATION_ID;\n // Worker IDENTITY — the canonical background-runtime pair (matches the k8s\n // worker/minion Deployment templates, the `BackgroundRuntimeType` model, and\n // the Rust worker's env read). `APP_OWNED_SERVICE_NAME` is the `workers`\n // bucket key the worker forwards as the apps-manager worker-bootstrap path\n // segment (`appConfig.workers[name]` lookup); `APP_OWNED_SERVICE_KIND` pins\n // it as a worker so the same contract disambiguates worker vs minion.\n env[ApplicationWorkerBootstrapEnvKeys.APP_OWNED_SERVICE_KIND] = BackgroundRuntimeType.WORKER;\n env[ApplicationWorkerBootstrapEnvKeys.APP_OWNED_SERVICE_NAME] = workerName;\n // SERVICE_NAME — the SEPARATE process/observability identity (also feeds\n // `OTEL_SERVICE_NAME` via `emitObservabilityEnv` below), distinct from the\n // routing identity above.\n env[ApplicationWorkerBootstrapEnvKeys.SERVICE_NAME] = serviceName;\n env[ApplicationWorkerBootstrapEnvKeys.PLATFORM_ENVIRONMENT_ID] = environmentId;\n env[ApplicationWorkerBootstrapEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] =\n bootstrapCredentials.PLATFORM_APPLICATION_PRIMARY_SECRET;\n // The RESOLVER when the caller passes addresses, as for the application backend above: the bootstrap echo is\n // apps-manager reporting its OWN address, right only for a reader on its network. Offline (degraded) it is even\n // rebuilt HOST-facing, so a compose worker container was handed `localhost:5151`, which inside the container is\n // the container itself (#2955 review). Every production caller passes addresses; the echo remains only for\n // callers that do not (unit fixtures).\n env[ApplicationWorkerBootstrapEnvKeys.PLATFORM_APPS_MANAGER_URL] =\n options?.addresses?.platform.appsManager.url ?? bootstrapCredentials.PLATFORM_APPS_MANAGER_URL;\n env[ApplicationWorkerBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n env[ApplicationWorkerBootstrapEnvKeys.APPLICATION_ENV] =\n options?.applicationEnv ?? bootstrapCredentials.APPLICATION_ENV;\n // #1177 — the worker is the runtime this issue was measured on: 1,530 of 1,530 of its records\n // named no application, because its kernel deliberately has no AppConfigurationService and\n // therefore never reaches the logger's `reinitialize`. Its env is the only thing that can say so.\n env[PlatformProcessEnvKeys.APPLICATION_SLUG] = bootstrapCredentials.APPLICATION_SLUG;\n\n // -- Inbound HTTP surface — projected from the authored `http` block so the\n // worker binds the authored port + probe paths (not a per-language\n // hardcoded default). Mirrors the Rust worker's WORKER_HTTP_PORT /\n // WORKER_HEALTH_PATH / WORKER_READY_PATH reads and the Node worker's\n // `readWorkerHttpSurfaceEnv()` helper. The env-gen caller always threads\n // `http`; the guard is only for the provider-env unit tests that omit options.\n if (options?.http) {\n env[ApplicationWorkerHttpSurfaceEnvKeys.WORKER_HTTP_PORT] = String(options.http.port);\n env[ApplicationWorkerHttpSurfaceEnvKeys.WORKER_HEALTH_PATH] = options.http.healthPath;\n env[ApplicationWorkerHttpSurfaceEnvKeys.WORKER_READY_PATH] = options.http.readyPath;\n // `metricsPath` is optional on `WorkerHttpSchema` — emitted only when the\n // author opts the worker into a Prometheus scrape surface.\n setIfDefined(env, ApplicationWorkerHttpSurfaceEnvKeys.WORKER_METRICS_PATH, options.http.metricsPath);\n }\n\n const runtimeEndpoints = options?.runtimeEndpoints;\n if (runtimeEndpoints && Object.keys(runtimeEndpoints).length > 0) {\n env[ApplicationWorkerRuntimeEnvKeys.APPLICATION_RUNTIME_ENDPOINTS] =\n serializeRuntimeEndpointsRecord(runtimeEndpoints);\n }\n setIfDefined(env, ApplicationWorkerRuntimeEnvKeys.APPLICATION_RUNTIME_SIGNALS_HOME, options?.runtimeSignalsHome);\n\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n emitEmailEnv(env, config.email);\n\n // Audit A-2: OTLP telemetry posture — workers emit OTEL_* like backends so a node worker with\n // the preload `--import` exports traces/metrics/logs (and a language-agnostic worker carries the\n // same env for a future native OTel SDK). The auth header, when a token is provisioned, is\n // resolved provider-agnostically from `providerEnv`, same as the backend.\n //\n // A worker builds its env from scratch rather than delegating, so this is the SECOND\n // application-tier site of the confinement invariant and resolves its own bag — once, read\n // by both the header and the fan-out below (#360).\n const scopedProviderEnv = resolveRuntimeProviderEnv(credentials, providerScope);\n emitObservabilityEnv(\n env,\n config.observability,\n {\n serviceName,\n environment: options?.applicationEnv ?? bootstrapCredentials.APPLICATION_ENV,\n version: options?.serviceVersion,\n },\n { providerEnv: scopedProviderEnv },\n );\n\n // Application tier: a worker receives only the providers its\n // `providers.scopes.workers.<name>` declares. `myRustWorker` declares none,\n // and must therefore receive none.\n for (const [envVarName, value] of Object.entries(scopedProviderEnv)) {\n setIfDefined(env, envVarName, value);\n }\n\n // Application tier — same guard as `buildApplicationBackendEnv`.\n //\n // A worker builds its env from scratch rather than delegating (unlike\n // `buildApplicationMinionEnv`, which inherits the guard by calling the\n // backend builder), so it is a SEPARATE call site for the same invariant and\n // was missed when the guard first landed. It emits no `STORAGE_*` today, but\n // `resolveRuntimeProviderEnv` fans provider values out of the same\n // `credentials` object the root pair lives in — so \"it happens not to leak\n // right now\" is a property of the current provider set, not of this builder.\n // See `.claude/rules/invariant-call-site-enumeration.md`.\n assertNoPlatformCredentialInGeneratedEnv(env, credentials, 'buildApplicationWorkerEnv');\n\n /*\n * A worker receives NOTHING of any system of record (#1055 D2, R7) — and \"nothing\" is not what a\n * worker gets by default, which is why this is asserted rather than assumed: this builder does\n * emit provider keys, and the system-of-record section escapes `filterProviderEnvToScope`\n * entirely because a system of record is deliberately not a provider.\n *\n * A worker has no application repository access at all, so it could not read a bound resource\n * even holding the credential. The assertion is what makes a future contributor to this builder\n * fail loudly rather than widen the delivery in silence.\n */\n assertNoSystemOfRecordEnvInGeneratedEnv(env, 'buildApplicationWorkerEnv');\n assertNoInboundEndpointEnvInGeneratedEnv(env, 'buildApplicationWorkerEnv');\n\n return env;\n }\n\n private static addServiceExtras(\n service: BootstrapPlatformService,\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n ): void {\n switch (service) {\n case PlatformWildoServices.CRONTABS_BATCHES_MANAGER: {\n const valkey = requireAddress(addresses.infra.valkey, 'valkey');\n const rabbitmq = requireAddress(addresses.infra.rabbitmq, 'rabbitmq');\n const rabbitmqMgmt = requireAddress(addresses.infra.rabbitmqManagement, 'rabbitmqManagement');\n env[PlatformInfrastructureEnvKeys.REDIS_HOST] = valkey.host;\n env[PlatformInfrastructureEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n env[PlatformInfrastructureEnvKeys.RABBITMQ_HOST] = rabbitmq.host;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_PORT] = String(rabbitmq.port);\n env[PlatformInfrastructureEnvKeys.RABBITMQ_MANAGEMENT_PORT] = String(rabbitmqMgmt.port);\n // No RABBITMQ_VHOST (#1112): nothing in crontabs-manager reads it. Its own connection takes the vhost from\n // its platform secret (`/`), and each application's vhost arrives in that application's JWT claim.\n break;\n }\n\n case PlatformWildoServices.MODULE_REGISTRY: {\n // The shared rate-limit store's ADDRESS (#2154). The registry's perimeter limiter and the\n // failed-credential lockout on its `sk_*` keys count there; the credential is the ACL user\n // apps-manager mints for `platform_module_registry`, fetched by the registry at boot. Before\n // this the registry received no address at all, so its lockout failed open in every lane.\n // (Object storage and the platform database are emitted by `buildBootstrapEnv` itself.)\n const valkey = requireAddress(addresses.infra.valkey, 'valkey');\n env[PlatformInfrastructureEnvKeys.REDIS_HOST] = valkey.host;\n env[PlatformInfrastructureEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n break;\n }\n\n default: {\n const _exhaustive: never = service;\n throw new Error(`Unhandled bootstrap service: ${_exhaustive}`);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"env-vars-builder.service.js","sourceRoot":"","sources":["../../../../src/services/environment/env-vars-builder.service.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,wFAAwF;AACxF,OAAO,EAAE,eAAe,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EACL,eAAe,EAGf,kBAAkB,EAClB,oBAAoB,EACpB,kCAAkC,EAElC,cAAc,EACd,gCAAgC,EAChC,uBAAuB,EACvB,0BAA0B,EAC1B,sCAAsC,EACtC,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,gCAAgC,EAChC,oBAAoB,EACpB,2BAA2B,EAC3B,sBAAsB,EACtB,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,+BAA+B,EAC/B,eAAe,EACf,kCAAkC,EAKlC,sCAAs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MAAM,CAAC,IAAI,CAAC,CAAC;gBACpE,YAAY,CACV,GAAG,EACH,6BAA6B,CAAC,cAAc,EAC5C,MAAM,CAAC,eAAe,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,QAAQ,CAC7D,CAAC;gBACF,MAAM;YACR,CAAC;YAED,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,WAAW,GAAU,OAAO,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,gCAAgC,WAAW,EAAE,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// The one MongoDB connection-string grammar, shared with apps-manager (#2000). The CLI already loads this package\n// at startup (every command module is imported by the registry), so this adds no graph.\nimport { MongoDBProtocol, readMongoConnectionStringTarget } from '@wildo-ai/saas-backend-lib';\nimport {\n AppsManagerMode,\n type AppBootstrapCredentials,\n type BackingServicesEnvConfig,\n BackingServiceKind,\n BackingServiceSource,\n resolvePlatformObjectStorageBucket,\n type BootstrapPlatformService,\n DatabaseEngine,\n resolveApplicationDatabaseEngine,\n PLATFORM_MONGO_DATABASE,\n PLATFORM_POSTGRES_DATABASE,\n PLATFORM_POSTGRES_MAINTENANCE_DATABASE,\n PlatformAdminEnvKeys,\n PlatformIngressEnvKeys,\n PlatformInfrastructureEnvKeys,\n PlatformKubernetesEnvKeys,\n PlatformLoggingEnvKeys,\n PlatformObservabilityEnvKeys,\n PlatformProviderSelectionEnvKeys,\n PlatformEmailEnvKeys,\n PlatformOwnershipDnsEnvKeys,\n PlatformProcessEnvKeys,\n PlatformGoogleKmsKeyProtection,\n PlatformSecurityEnvKeys,\n PlatformServiceUrlEnvKeys,\n PlatformWildoServices,\n WildoDeploymentRuntime,\n WildoLocationType,\n ApplicationRuntimePrincipalKind,\n InfraCapability,\n resolveRuntimeBackingServiceAccess,\n type ApplicationRuntimePrincipal,\n type RuntimeAccessDeclaration,\n type RuntimeBackingServiceAccess,\n type WorkerHttp,\n buildRuntimeResponseVerificationKeySet,\n DEFAULT_ENVIRONMENT_SERVICE_PROFILE,\n} from '@wildo-ai/platform-config-lib';\nimport {\n ApplicationBackendBootstrapEnvKeys,\n ApplicationBackendDataEnvKeys,\n ApplicationBackendPlatformUrlEnvKeys,\n ApplicationBackendRuntimeEnvKeys,\n ApplicationWorkerBootstrapEnvKeys,\n ApplicationWorkerHttpSurfaceEnvKeys,\n ApplicationWorkerRuntimeEnvKeys,\n HttpServerEnvKey,\n PlatformRuntimeEndpointKey,\n REMOTE_EDGE_PROXY_HOPS,\n serializeRuntimeEndpointsRecord,\n wildoWorkerUrlEnvKey,\n} from '@wildo-ai/platform-core-shared';\nimport {\n AGENT_CONTENT_GUARDRAILS_ENV_VAR,\n BackgroundRuntimeType,\n PersistenceAdapter,\n RuntimeEnvironment,\n deriveSystemOfRecordEnabledEnvVarName,\n deriveSystemOfRecordEnvVarName,\n parseInboundEndpointSecretEnvVarName,\n parseSystemOfRecordEnvVarName,\n} from '@wildo-ai/saas-models';\nimport {\n getComposedProviderEntry,\n getComposedProviderSecretsCatalogue,\n type ProviderSecretsCatalogueEntry,\n} from '~wildo-cli/services/credentials/composed-provider-catalogue';\nimport {\n VALKEY_CREDENTIAL_ENV_KEYS,\n RABBITMQ_CREDENTIAL_ENV_KEYS,\n MINIO_CREDENTIAL_ENV_KEYS,\n POSTGRESQL_CREDENTIAL_ENV_KEYS,\n IMMUDB_CREDENTIAL_ENV_KEYS,\n} from '~wildo-cli/services/data-services/data-services.schemas';\nimport { EnvironmentLifecycle } from '~wildo-cli/services/environment/environment-lifecycle.service';\nimport { PlatformDataServicesUtils } from '~wildo-cli/services/data-services/data-services.service';\nimport { LISTEN_HOST } from '~wildo-cli/services/environment/platform-runtime.schemas';\nimport { PLATFORM_SERVICE_CATALOG } from '~wildo-cli/services/catalog/service-catalog.schemas';\nimport type { PlatformEnvConfigJson, PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport { resolveApplicationBackingServiceAddressing } from '~wildo-cli/services/environment/application-backing-service-addressing.utils';\nimport type { ResolvedAddresses, ResolvedServiceAddress } from '~wildo-cli/services/catalog/service-address-resolver.service';\nimport {\n getProviderSecretEnvBindings,\n getProviderSensitiveEnvKeys,\n platformTierAllProvidersScope,\n RuntimeProviderScopeKind,\n type RuntimeProviderScope,\n} from '~wildo-cli/services/credentials/provider-env-vars.utils';\n\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * VALUE CONTRACT — every builder in this file emits **RAW, UNENCODED** values.\n *\n * A builder returns the true value (a multi-line PEM keeps its real newlines and carries no\n * surrounding quotes). ENCODING BELONGS TO THE SERIALIZER, because the sinks disagree on it:\n *\n * - `writeEnvFile` / `generateProviderSecretsEnvFile` → dotenv escaping (`encodeDotenvValue`);\n * - `formatEnvFile` (ci-deploy artifacts) → its own quote + `\\n` escaping;\n * - the k8s secrets generator → RAW (the value is base64'd verbatim into a `Secret`);\n * - the compose `.env.wildo-platform` writer → `encodeComposeEnvValue` (quote-if-multiline),\n * which keeps that file's historical bytes.\n *\n * A `quoteMultiline()` helper used to bake double quotes into the VALUES here. That was wrong in\n * both directions and produced two live defects: the immudb SPKI PEM injected by\n * {@link resolveRuntimeProviderEnv} was NOT quoted, so a bare `key=value` split it across physical\n * lines and dotenv truncated it to `-----BEGIN PUBLIC KEY-----` (the audit client then failed to\n * parse its pinned key and reported a FALSE \"TAMPER DETECTED\"); and the platform JWT PEMs that WERE\n * quoted carried those literal quotes into k8s `Secret` values, which are not dotenv-parsed.\n *\n * Do not reintroduce per-value quoting here. Add the encoding to the serializer that needs it.\n */\nfunction setIfDefined(env: Record<string, string>, key: string, value: string | number | undefined | null): void {\n if (value != null) {\n env[key] = String(value);\n }\n}\n\ndeclare const scopedProviderEnvBrand: unique symbol;\n\n/**\n * A `providerEnv` bag that has already passed through a runtime's declared scope.\n *\n * ## Why a BRAND rather than a convention (issue #360)\n *\n * The confinement invariant — \"a runtime receives only the providers its scope declares\" — has\n * TWO delivery paths in this file, not one: the per-key fan-out loop, and the OTLP auth header\n * composed by {@link resolveOtlpAuthHeader}. `filterProviderEnvToScope` covered the first. The\n * second took `credentials.providerEnv` verbatim, so a worker built with `declaredProviderScope([])`\n * correctly received no `BETTERSTACK_SOURCE_TOKEN` and then received that same token inside\n * `OTEL_EXPORTER_OTLP_HEADERS`. Reproduced 2026-09-06.\n *\n * Applying the filter a second time by hand would fix the two sites that exist and leave the\n * third to whoever writes it. `.claude/rules/invariant-call-site-enumeration.md` asks for the\n * unbypassable form where one is available, and here one is: the only producer of this type is\n * {@link resolveRuntimeProviderEnv}, so passing an unscoped bag is a COMPILE error rather than a\n * review question. There is no runtime cost and no runtime representation — the brand is a\n * `declare`d symbol that never exists.\n *\n * **Be exact about how far that reaches, because a comment claiming more protection than exists is\n * worse than none.** A parameter type guards the parameters that declare it, and today those are\n * exactly two: {@link emitObservabilityEnv}'s `telemetryProvider.providerEnv` and\n * {@link resolveOtlpAuthHeader}'s — the OTLP header path, which is what #360 was. The per-key\n * fan-out loops take a plain `Record<string, string>` and are correct for a different reason: they\n * iterate the value {@link resolveRuntimeProviderEnv} returned, in the same statement block.\n *\n * So this type does NOT make every future credential emitter safe by itself. **If you add one, give\n * its provider-env parameter this type** — that is the one line that puts it inside the guard, and\n * the reason the type is worth having is that it makes doing so free rather than a judgement call.\n *\n * The brand key is a `unique symbol`, which is what lets it coexist with the `string` index\n * signature: a string index signature does not constrain symbol-keyed members, so\n * `Object.entries`, `bag[name]` and spread all keep working on the branded type.\n */\ntype ScopedProviderEnv = Record<string, string> & { readonly [scopedProviderEnvBrand]: true };\n\n/**\n * Resolve the effective provider-env for a backend RUNTIME: the operator-authored\n * `credentials.providerEnv` PLUS framework-generated provider material that is not\n * operator-typed. Today that is exactly the immudb state-signing PUBLIC key.\n *\n * The audit client pins `IMMUDB_STATE_PUBLIC_KEY` to cryptographically detect a whole-server\n * substitution (a fresh immudb presenting a new uuid). That key is generated at `wildo setup`\n * (`credentials.immudb.stateSigningPublicKey`), never operator-typed, so it does not live in\n * the authored providerEnv — it is injected here, at runtime-env build time, so it always\n * reflects the current secrets.json regardless of when immudb was configured. Injection is\n * gated on the immudb audit provider actually being configured (its connection host is present\n * in providerEnv) so an env that does not use immudb carries no stray pinning key. The PRIVATE\n * half is deliberately absent from this map — it goes to the SELF-hosted immudb server only.\n *\n * Returns a fresh record (never mutates `credentials.providerEnv`).\n */\nfunction resolveRuntimeProviderEnv(\n credentials: PlatformEnvSecretsJson,\n /**\n * What this runtime is entitled to, as a decision rather than an absence — see\n * {@link RuntimeProviderScope} for why \"not stated\" is deliberately unrepresentable.\n *\n * Required, and positional rather than a field on an options bag, so the choice is visible and\n * MANDATORY at every call site. An optional field is how the whole provider bag got handed to\n * every application runtime in the first place, and then how the whole bag got taken away from\n * all of them: nobody had to decide, so nobody did.\n */\n scope: RuntimeProviderScope,\n): ScopedProviderEnv {\n const providerEnv: Record<string, string> = { ...(credentials.providerEnv ?? {}) };\n const statePublicKey = credentials.immudb?.stateSigningPublicKey;\n const immudbProviderConfigured = providerEnv[IMMUDB_CREDENTIAL_ENV_KEYS.PROVIDER.HOST] != null;\n if (\n statePublicKey &&\n immudbProviderConfigured &&\n providerEnv[IMMUDB_CREDENTIAL_ENV_KEYS.PROVIDER.STATE_PUBLIC_KEY] == null\n ) {\n providerEnv[IMMUDB_CREDENTIAL_ENV_KEYS.PROVIDER.STATE_PUBLIC_KEY] = statePublicKey;\n }\n\n // The two `as ScopedProviderEnv` casts are the ONLY place the brand is minted, which is what\n // makes the type meaningful: everything downstream receives a bag whose scope was decided here.\n if (scope.kind === RuntimeProviderScopeKind.PLATFORM_TIER_ALL_PROVIDERS) {\n return providerEnv as ScopedProviderEnv;\n }\n return filterProviderEnvToScope(providerEnv, scope.providerRefs) as ScopedProviderEnv;\n}\n\n/**\n * The remedy every dropped-key warning names. `wildo secrets list` reports such a key as UNUSED and the\n * workbench's Secrets section offers its removal, so the warning points somewhere a key can be removed\n * rather than at a JSON file (#1637).\n */\nconst REMOVE_UNUSED_SECRET_HINT = 'Remove it with `wildo secrets unset <NAME>` (the workbench\\'s Secrets section lists it as unused).';\n\n/** When this process last reported each `section:key` as dropped. */\nconst reportedDroppedSecretKeys = new Map<string, number>();\n\n/**\n * How long a dropped key stays reported. One `config sync` builds every runtime's env within seconds, and the\n * same orphan was reported once PER runtime — five keys became a screenful on every regeneration (#1637). A\n * window rather than \"once per process\" keeps a long-lived builder (the dev loop) reporting a key that is\n * still there an hour later, or that was removed and added back.\n */\nconst DROPPED_KEY_REPORT_WINDOW_MS = 10 * 60_000;\n\n/**\n * The keys of `dropped` not reported inside the window. The drop itself still happens for every runtime; only\n * the repetition of the finding goes.\n */\nfunction firstDropReport(section: string, dropped: readonly string[]): string[] {\n const nowMs = Date.now();\n const fresh = dropped.filter((key) => nowMs - (reportedDroppedSecretKeys.get(`${section}:${key}`) ?? -Infinity) >= DROPPED_KEY_REPORT_WINDOW_MS);\n for (const key of fresh) reportedDroppedSecretKeys.set(`${section}:${key}`, nowMs);\n return fresh;\n}\n\n/**\n * Drop every provider SECRET that the runtime's declared scope does not cover.\n *\n * ## The gap this closes\n *\n * `providers.scopes.{minions,workers}.<name>` has always declared which providers\n * a runtime may use, and that declaration was faithfully materialised into the\n * runtime topology artifact — while the SECRETS ignored it entirely. A minion\n * scoped to `openai` alone still received `STRIPE_SECRET_KEY`,\n * `STRIPE_WEBHOOK_SECRET`, `RESEND_API_KEY` and every other provider key, because\n * the whole `providerEnv` bag was copied verbatim into its environment. A worker\n * declaring `providers: {}` received them too.\n *\n * That is the provider-credential analogue of handing every workload the object\n * store's root key: an authored boundary the credential layer never read. It is\n * NOT mitigated by the container security floor — these live in the process\n * environment, which is exactly what LLM-driven minion code can read.\n *\n * ## Attribution comes from the COMPOSED catalogue, and an unattributable key is DROPPED\n *\n * Both halves of this filter used to read `EngineBackendProviderRegistry`, and both were wrong\n * the moment a provider could ship as its own package (#329, audit finding PL-3):\n *\n * - the ALLOW-LIST could not resolve a package provider's contract, so a runtime that legitimately\n * declared one would have had its credential stripped;\n * - the ATTRIBUTION set could not see that provider's keys either, so — by the rule this comment\n * used to state, that an unattributable key is \"configuration rather than a provider secret\" —\n * the key was KEPT and copied into every worker and minion environment. Silently. That inverts\n * the confinement into a leak precisely for the tier the confinement matters most for.\n *\n * So attribution now derives from {@link getComposedProviderSecretsCatalogue}, and a `DECLARED`\n * scope drops what it cannot attribute instead of keeping it. That is what the scope means:\n * exactly the providers this runtime authors, and nothing else. `providerEnv` is the\n * provider-secret bag, not a general config bag — the framework's own writers only ever put\n * attributable keys in it (`wildo setup` prompts straight off the secret contracts, and\n * {@link resolveRuntimeProviderEnv} injects one key that immudb's contract declares), and a\n * provider whose configuration is a hostname or a database name puts THAT in its contract too:\n * immudb and odoo both do.\n *\n * Measured before the trade was reversed: the live `providerEnv` of both dogfood applications\n * holds 13 keys and every one is attributable to an engine provider's contract, so failing\n * closed drops nothing today. The remaining writer that can produce an unattributable key is the\n * CI convention `WILDO_SECRET_PROVIDER_ENV_<NAME>`, which is open-ended — and is exactly the\n * vector this issue exists to close.\n *\n * The drop is REPORTED, never silent: a refusal nobody can see is the failure mode this whole\n * slice is about. `PLATFORM_TIER_ALL_PROVIDERS` is untouched — it receives everything by\n * deliberate declaration.\n */\nfunction filterProviderEnvToScope(\n providerEnv: Record<string, string>,\n scopedProviderRefs: readonly string[],\n): Record<string, string> {\n const allowedKeys = new Set<string>();\n for (const providerRef of scopedProviderRefs) {\n const entry = getComposedProviderEntry(providerRef);\n for (const secret of entry?.secrets ?? []) allowedKeys.add(secret.envVarName);\n for (const binding of getProviderSecretEnvBindings(providerRef)) allowedKeys.add(binding.envVarName);\n }\n\n const attributableKeys = getProviderSensitiveEnvKeys();\n const scoped: Record<string, string> = {};\n const unattributable: string[] = [];\n for (const [key, value] of Object.entries(providerEnv)) {\n if (allowedKeys.has(key)) {\n scoped[key] = value;\n continue;\n }\n if (!attributableKeys.has(key)) unattributable.push(key);\n }\n\n const newlyUnattributable = firstDropReport('providerEnv', unattributable);\n if (newlyUnattributable.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `[env-builder] ${newlyUnattributable.length} key(s) in providerEnv belong to no provider the CLI `\n + `can see, so every runtime that declares its providers drops them (first seen for one scoped to `\n + `[${scopedProviderRefs.join(', ') || 'no provider'}]); only the dev companion, which receives every provider key, `\n + `still carries them: ${newlyUnattributable.join(', ')}. `\n + 'A provider-secret key is delivered by declaring the provider (so its secrets contract is '\n + 'discoverable); anything that is not a provider secret does not belong in providerEnv. '\n + REMOVE_UNUSED_SECRET_HINT,\n );\n }\n\n return scoped;\n}\n\n/**\n * Every `WILDO_SOR_*` variable ONE runtime should receive, derived from the environment's authored\n * addresses and the operator's secrets (#1055 §2).\n *\n * ## Derived, so nothing authors a variable name\n *\n * The address half comes from `config.systemsOfRecord.<name>.address`, keyed by the facet's slot\n * slugs; the secret half is already keyed by the derived name in `secrets.json`. One function owns\n * the naming (`deriveSystemOfRecordEnvVarName`, exported from saas-models), which is what stops the\n * env writer, the k8s secrets generator, the CI collector and the backend registry from each\n * inventing their own spelling of the same variable.\n *\n * ## `ENABLED=false` is a DECLARATION, not the absence of one\n *\n * An environment with no access to the instance authors `{ enabled: false }` and gets\n * `WILDO_SOR_<NAME>__ENABLED=false`. The backend reads its PRESENCE as \"declared absent\" and boots,\n * refusing reads with a stable code; the different case — no marker and no address — is an\n * environment that simply forgot, and that refuses. The two need opposite behaviours, so they need\n * to be distinguishable, so silence cannot be either one (#1055 E3/E4, R6).\n *\n * ## An undeclared instance's secret is DROPPED, with a warning\n *\n * Same trade as `filterProviderEnvToScope` one function up, and for a stronger reason here: a secret\n * keyed for an instance the application does not declare cannot be reached by anything, so\n * delivering it only widens what a compromised runtime holds. The key is parsed back into its\n * `(instance, slot)` pair — which is what the `__` delimiter exists to make possible — and warned\n * about rather than dropped in silence, because a typo in an instance name would otherwise look\n * exactly like a credential that simply never arrived.\n */\nfunction resolveSystemsOfRecordEnv(\n config: PlatformEnvConfigJson,\n credentials: PlatformEnvSecretsJson,\n): Record<string, string> {\n const declaredInstances = config.systemsOfRecord ?? {};\n const env: Record<string, string> = {};\n\n for (const [instanceName, entry] of Object.entries(declaredInstances)) {\n if ('enabled' in entry) {\n env[deriveSystemOfRecordEnabledEnvVarName(instanceName)] = String(entry.enabled);\n continue;\n }\n for (const [slotSlug, value] of Object.entries(entry.address)) {\n env[deriveSystemOfRecordEnvVarName(instanceName, slotSlug)] = value;\n }\n }\n\n const undeliverable: string[] = [];\n for (const [envVarName, value] of Object.entries(credentials.systemsOfRecordEnv ?? {})) {\n const parts = parseSystemOfRecordEnvVarName(envVarName);\n if (parts && declaredInstances[parts.instanceName] !== undefined) {\n env[envVarName] = value;\n continue;\n }\n undeliverable.push(envVarName);\n }\n\n const newlyUndeliverable = firstDropReport('systemsOfRecordEnv', undeliverable);\n if (newlyUndeliverable.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `[env-builder] ${newlyUndeliverable.length} key(s) in systemsOfRecordEnv name no system of record this `\n + `environment declares and were dropped: ${newlyUndeliverable.join(', ')}. `\n + `Declared here: [${Object.keys(declaredInstances).join(', ') || 'none'}]. `\n + 'A credential is delivered by declaring its instance in `systemsOfRecord` and giving it an '\n + 'address in this environment; a key naming anything else reaches no runtime. If nothing should read it, '\n + 'remove it with `wildo secrets unset <NAME>` (one naming no declared instance is listed there as unused).',\n );\n }\n\n return env;\n}\n\n/**\n * The verification secrets of the application's inbound endpoints (#1596), delivered under the names the\n * backend reads them by (`WILDO_INBOUND_<ENDPOINT_KEY>__SECRET`).\n *\n * A key that is not such a name is DROPPED with a warning, for the reason {@link resolveSystemsOfRecordEnv}\n * gives: nothing reads it, so delivering it only widens what a compromised runtime holds, and a typo must\n * not look exactly like a secret that never arrived. Which endpoints the application declares is known only\n * to its backend code, so an unused-but-well-formed key is delivered; the backend is where an endpoint\n * without its secret is reported (the route is withheld and the log names the variable).\n */\nfunction resolveInboundEndpointEnv(credentials: PlatformEnvSecretsJson): Record<string, string> {\n const env: Record<string, string> = {};\n const undeliverable: string[] = [];\n for (const [envVarName, value] of Object.entries(credentials.inboundEndpointEnv ?? {})) {\n if (parseInboundEndpointSecretEnvVarName(envVarName)) env[envVarName] = value;\n else undeliverable.push(envVarName);\n }\n const newlyUndeliverable = firstDropReport('inboundEndpointEnv', undeliverable);\n if (newlyUndeliverable.length > 0) {\n // eslint-disable-next-line no-console\n console.warn(\n `[env-builder] ${newlyUndeliverable.length} key(s) in inboundEndpointEnv are not inbound endpoint secret names and were dropped: `\n + `${newlyUndeliverable.join(', ')}. A key is WILDO_INBOUND_<ENDPOINT_KEY>__SECRET, derived from the endpoint key `\n + '(`todo-intake` → WILDO_INBOUND_TODO_INTAKE__SECRET). '\n + REMOVE_UNUSED_SECRET_HINT,\n );\n }\n return env;\n}\n\n/** Refuse an inbound endpoint secret in an env that is not the application BACKEND's (#1596). */\nfunction assertNoInboundEndpointEnvInGeneratedEnv(env: Record<string, string>, builderName: string): void {\n const leaked = Object.keys(env).filter((key) => parseInboundEndpointSecretEnvVarName(key) !== null);\n if (leaked.length === 0) return;\n throw new Error(\n `[${builderName}] ${leaked.length} inbound endpoint secret(s) reached a runtime that must not have them: `\n + `${leaked.join(', ')}. Only the application backend mounts inbound endpoints (#1596).`,\n );\n}\n\n/**\n * Refuse a system-of-record variable in an env that is not the application BACKEND's (#1055 D2, R7).\n *\n * Mirrors {@link assertNoPlatformCredentialInGeneratedEnv}, and sits at the RETURN of each builder\n * for the same reason: a check placed beside the removal only proves that one line stayed deleted,\n * while this one catches an instance credential arriving through any path, named anything.\n *\n * \"Nothing\" is not the default here — minions and workers DO receive provider keys today, through\n * several builders, and this section escapes `filterProviderEnvToScope` entirely because a system of\n * record is not a provider. So the exclusion has to be stated, and stated where it cannot be\n * bypassed by a new delegating caller.\n */\nfunction assertNoSystemOfRecordEnvInGeneratedEnv(env: Record<string, string>, builderName: string): void {\n const leaked = Object.keys(env).filter((key) => parseSystemOfRecordEnvVarName(key) !== null);\n if (leaked.length === 0) return;\n throw new Error(\n `[${builderName}] ${leaked.length} system-of-record variable(s) reached a runtime that must not have them: `\n + `${leaked.join(', ')}. A system of record is read by the application BACKEND and by nothing else `\n + '(#1055 D2) — its address and credential are delivered to that runtime alone.',\n );\n}\n\n/**\n * Project the authored `infra.logging.*` block onto the runtime env-var\n * surface for any long-running platform/application process (Slice 3.5).\n *\n * Both keys are emitted only when the author explicitly set them — the\n * field is `.optional()` on `WildoLoggingConfigSchema`, so missing\n * authoring leaves `LoggerService.loadConfiguration` on its built-in\n * defaults (level `debug`, pino-pretty auto-detect by `APPLICATION_ENV`).\n *\n * The `LOG_LEVEL` enum is validated upstream by `WildoLoggingConfigSchema`\n * (`debug | info | warn | error`), so a corrupt value can never reach\n * this projection.\n */\nfunction emitLoggingEnv(\n env: Record<string, string>,\n logging: PlatformEnvConfigJson['logging'] | undefined,\n): void {\n if (!logging) return;\n setIfDefined(env, PlatformLoggingEnvKeys.LOG_LEVEL, logging.level);\n if (logging.formattedConsoleErrors !== undefined) {\n env[PlatformLoggingEnvKeys.LOG_FORMATTED_CONSOLE_ERRORS] = String(logging.formattedConsoleErrors);\n }\n}\n\n/**\n * Project the authored `infra.providerSelection` block onto the backend\n * runtime env-var surface as a single serialized JSON payload\n * (`WILDO_PROVIDER_SELECTION_OVERRIDES`) — mirroring how a structured payload\n * rides in one env var (`APPLICATION_RUNTIME_ENDPOINTS`). Emitted ONLY when the\n * author set at least one override; absent authoring leaves\n * `ExternalProvidersRegistryBackendService` on the app-wide\n * `wildo.saas.config.ts` selection. The shape is validated upstream by\n * `WildoProviderSelectionOverridesSchema`, so a corrupt value can never reach\n * this projection; the backend reader tolerates a malformed value defensively\n * regardless.\n */\nfunction emitProviderSelectionEnv(\n env: Record<string, string>,\n providerSelection: PlatformEnvConfigJson['providerSelection'] | undefined,\n): void {\n if (!providerSelection || Object.keys(providerSelection).length === 0) return;\n env[PlatformProviderSelectionEnvKeys.WILDO_PROVIDER_SELECTION_OVERRIDES] = JSON.stringify(providerSelection);\n}\n\n/**\n * Project the authored `infra.email` block onto an APPLICATION runtime's env surface: today the shared receiving\n * domain (`WILDO_INBOUND_EMAIL_SHARED_DOMAIN`), which the backend's inbound services prefer over the backend\n * configuration's `email.inbound.sharedDomain` (`resolveInboundEmailConfig`).\n *\n * Emitted only when authored, like the documentation-site values: an absent key is the plain statement of \"no override\"\n * (the backend also reads an empty value that way, `resolveInboundEmailConfig`, but writing one would put a meaningless\n * line in every `.env`). Called for the application backend (whose env each minion\n * inherits) and the application worker — the runtimes that receive mail or address an organization's mail — and\n * deliberately not for platform services or the companion, which do neither.\n */\nfunction emitEmailEnv(\n env: Record<string, string>,\n email: PlatformEnvConfigJson['email'] | undefined,\n): void {\n const sharedDomain = email?.inbound?.sharedDomain;\n if (sharedDomain) env[PlatformEmailEnvKeys.WILDO_INBOUND_EMAIL_SHARED_DOMAIN] = sharedDomain;\n}\n\n/**\n * Project the authored `infra.agentContentGuardrails` onto an APPLICATION runtime's env surface, as JSON in\n * `WILDO_AGENT_CONTENT_GUARDRAILS`: what the runtime does with an agent's classifier-backed content guardrails where no\n * classifier is selected. Read by `readEnvironmentAgentContentGuardrails` (`@wildo-ai/saas-models`).\n *\n * Emitted only when authored: absent is the default, REFUSE. Called for the application backend (whose env each minion\n * inherits) and the application worker, the runtimes that run agents, beside `providerSelection`, which decides whether a\n * classifier is selected at all; not for platform services or the companion, which run no application agent.\n */\nfunction emitAgentContentGuardrailsEnv(\n env: Record<string, string>,\n agentContentGuardrails: PlatformEnvConfigJson['agentContentGuardrails'] | undefined,\n): void {\n if (agentContentGuardrails) env[AGENT_CONTENT_GUARDRAILS_ENV_VAR] = encodeAgentContentGuardrailsEnvValue(agentContentGuardrails);\n}\n\n/**\n * The declaration as JSON whose free-text `reason` cannot defeat a dotenv writer: the JSON always holds `\"`, and a reason\n * holding both `'` and a backtick would leave the `.env` encoder no quote to use (it refuses such a value). Both are\n * written as JSON unicode escapes, which `JSON.parse` reads back to the same characters.\n */\nexport function encodeAgentContentGuardrailsEnvValue(agentContentGuardrails: NonNullable<PlatformEnvConfigJson['agentContentGuardrails']>): string {\n return JSON.stringify(agentContentGuardrails).replace(/'/g, '\\\\u0027').replace(/`/g, '\\\\u0060');\n}\n\n/**\n * Project the LOCAL-ONLY `infra.ownershipDnsStandIn` onto the application backend's env surface (#2519): the double that\n * answers domain-ownership challenges for names nobody can publish. Emitted only when authored — absent is \"public DNS\",\n * and the infra schema refuses it outside a local environment. Called for the application backend alone, the runtime\n * that serves the domain-ownership doors (its minions inherit the env and never ask).\n */\nfunction emitOwnershipDnsStandInEnv(\n env: Record<string, string>,\n ownershipDnsStandIn: PlatformEnvConfigJson['ownershipDnsStandIn'] | undefined,\n): void {\n if (ownershipDnsStandIn?.baseUrl) env[PlatformOwnershipDnsEnvKeys.WILDO_OWNERSHIP_DNS_STAND_IN_URL] = ownershipDnsStandIn.baseUrl;\n}\n\n/**\n * Emit the platform-standard MongoDB connection env trio (`MONGO_CONNECT_URL`, `MONGO_PLATFORM_URL`,\n * `BASE_MONGO_SERVER_URL`) onto a platform-service env map. The URL is the Atlas `connectionUrl` for a\n * MANAGED + `atlas` source, else built from the resolved local mongodb address + root credentials\n * against `PLATFORM_MONGO_DATABASE`. Shared by every platform service that opens the PLATFORM_MANAGEMENT\n * connection: apps-manager, the companion, and the bootstrap services that use the framework's\n * `StartApplicationBackendService` (module-registry) — previously this identical block was duplicated\n * across all three builders.\n */\n/**\n * Does this environment PROVIDE a MongoDB at all — as opposed to merely having an address for one?\n *\n * `addresses.infra.mongodb` answers the second question, and answers it for EVERY environment: the\n * resolver hands out a default address whether or not anything renders a server there. Harmless\n * while a mongod was mandatory; a live defect the moment it stopped being, because both env\n * emitters keyed off the address and so wrote a confident `mongodb://…:27017/…` for a container no\n * transport renders.\n *\n * ONE spelling for both emitters, deliberately. The platform emitter was fixed first and the\n * application emitter was not — which is how `wonder-crm` (PostgreSQL on both planes, no\n * `.ragSource()` field, no Mongo-pinned resource) still received `MONGODB_HOST` and spent its boot\n * dialling 127.0.0.1:27017. An invariant applied at one of its call sites is applied at none of the\n * others.\n *\n * The union mirrors `EnvironmentLifecycle.needsLocalMongoDB` — which decides whether a mongod is\n * RENDERED — and adds the two externally-hosted shapes, because a server we do not render is still\n * a server we can reach.\n */\nfunction environmentProvidesMongoDb(config: PlatformEnvConfigJson): boolean {\n if (config.database.source === BackingServiceSource.MANAGED && config.database.provider === 'atlas') return true;\n if (config.externalEndpoints?.mongodb?.connectionUrl) return true;\n if (config.database.engine === DatabaseEngine.MONGODB && config.database.source === BackingServiceSource.SELF) return true;\n return config.backingServices?.[BackingServiceKind.MONGODB] !== undefined;\n}\n\nfunction emitPlatformMongoEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n): void {\n const isAtlas = config.database.source === BackingServiceSource.MANAGED\n && config.database.provider === 'atlas';\n /**\n * Is a mongod actually REACHABLE for this environment — as opposed to merely ADDRESSABLE?\n *\n * `addresses.infra.mongodb` answers the second question and was, until 2026-08-28, the only gate\n * here: the resolver hands out a default address whether or not anything renders a server at it.\n * That was harmless while a mongod was mandatory, and became the live defect the moment it stopped\n * being — generation would emit a confident `mongodb://…:27017/…` for a container no transport\n * renders, and the boot would hang on it long after the real mistake. (The retired\n * `backingServices.mongodb` refusal in this file existed for exactly that trap; the trap is real,\n * so the answer is to emit honestly rather than to demand a mongod.)\n *\n * The UNION below deliberately mirrors `EnvironmentLifecycle.needsLocalMongoDB` — the predicate\n * that decides whether a mongod is RENDERED — plus the Atlas case, whose server is external. Only\n * the authored half was checked at first, and two pre-existing pins caught it immediately: a\n * platform whose OWN engine is self-hosted MongoDB renders a mongod without any\n * `backingServices.mongodb` entry, and would have been handed an empty URL for a server that is\n * definitely there.\n */\n const mongoIsDeclared = environmentProvidesMongoDb(config);\n const mongoConnectUrl = isAtlas\n ? (config.externalEndpoints?.mongodb?.connectionUrl ?? '')\n : mongoIsDeclared && addresses.infra.mongodb\n ? PlatformDataServicesUtils.buildMongoConnectionUrlFromAddress(\n addresses.infra.mongodb,\n {\n user: credentials.mongodb?.rootUser ?? '',\n password: credentials.mongodb?.rootPassword ?? '',\n },\n {\n databaseName: PLATFORM_MONGO_DATABASE,\n directConnection: environment.locationType === WildoLocationType.LOCAL,\n },\n )\n : '';\n env[PlatformInfrastructureEnvKeys.MONGO_CONNECT_URL] = mongoConnectUrl;\n env[PlatformInfrastructureEnvKeys.MONGO_PLATFORM_URL] = mongoConnectUrl;\n env[PlatformInfrastructureEnvKeys.BASE_MONGO_SERVER_URL] = mongoIsDeclared && addresses.infra.mongodb\n ? `${addresses.infra.mongodb.host}:${addresses.infra.mongodb.port}`\n : '';\n}\n\n/**\n * Emit the platform's OWN PostgreSQL connection env (`PG_CONNECT_URL` + the\n * `DATABASE_DEFAULT_ADAPTER` selection) — the PostgreSQL mirror of {@link emitPlatformMongoEnv},\n * for a platform whose `database.engine === POSTGRESQL` (Phase 5.3, D7).\n *\n * A NO-OP on every Mongo-engined environment: neither key is written, so `.env` material for\n * existing deployments is byte-identical. Note the gate is the platform ENGINE, deliberately NOT\n * `shouldProvisionPostgreSQL`'s union — an app-authored `backingServices.postgresql: SELF` on a\n * Mongo platform means PostgreSQL exists for an APPLICATION's resources, and handing the\n * PLATFORM a connect URL (let alone flipping its default adapter) for someone else's database\n * would be exactly the conflation the union predicate's two halves exist to keep apart.\n *\n * The URL targets the container's own initdb database (`infrastructure.postgresql.database`,\n * default `wildo_platform` — see the compose template's `POSTGRES_DB`), which exists by\n * construction; PostgreSQL does not create databases on connect, so pointing anywhere else\n * would require an init step the platform deliberately does not have.\n *\n * Site enumeration (invariant-call-site rule): of the three `emitPlatformMongoEnv` callers,\n * apps-manager AND module-registry call this (both carry the pre-connect + construction-time\n * adapter wiring — 5.3 and 5.6 respectively, and they MUST agree or a flipped platform splits\n * shared resources across services).\n *\n * THE COMPANION IS NOW THE THIRD CALLER (2026-08-28, issue #94). It was a deliberate N/A on\n * exactly the right grounds — \"it opens only the Mongo platform connection, and emitting an\n * adapter selection its startup cannot honor would be a lie in the env file\" — and that\n * refusal was correct for as long as it was true. The companion's startup now derives its\n * adapter from `DATABASE_DEFAULT_ADAPTER` and pre-connects PostgreSQL from `PG_CONNECT_URL`,\n * so the keys are honored rather than ignored and withholding them is what would now lie:\n * the companion would silently read platform rows from a Mongo database the platform stopped\n * using, and report every application as unregistered.\n *\n * Note the ORDER this was fixed in, because it is the general rule: the runtime learns to\n * honor a key BEFORE the generator emits it. Emitting first would have produced an env file\n * that looks correct and changes nothing.\n */\nfunction emitPlatformPostgresEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n): void {\n if (config.database.engine !== DatabaseEngine.POSTGRESQL) return;\n\n /**\n * RETIRED 2026-08-28, with its schema-side twin in `define-infra-env-config.ts` — see that file\n * for the full account. In short: this refused a PostgreSQL platform rendering no mongod because\n * `MONGO_CONNECT_URL` was an unconditionally REQUIRED key on the apps-manager env schema. It is\n * now engine-conditional (empty means absent, exactly as `PG_CONNECT_URL` has always been), and\n * the two reasons the refusal actually cited — the six MONGODB-pinned bootstrap resources, and a\n * Mongo-only crontabs-batches-manager — were both already gone when it was still refusing.\n *\n * What replaces it is weaker and truer: a platform must render AT LEAST ONE store. That check\n * lives on the env schema, beside the keys it is about, rather than here — a generator cannot see\n * a hand-authored env, and the schema refuses both.\n */\n\n const isManaged = config.database.source === BackingServiceSource.MANAGED;\n if (isManaged && !config.externalEndpoints?.postgresql?.connectionUrl) {\n // The Atlas-mirror slot is the ONLY channel for a managed endpoint, and it has no wizard\n // authoring path yet — emitting an empty URL here would surface as an opaque \"Invalid URL\"\n // at boot-time env validation, three layers from the cause (5.3 review F3).\n throw new Error(\n 'database.engine is POSTGRESQL with source MANAGED, but `externalEndpoints.postgresql.connectionUrl` '\n + 'is not set in the environment config. Add the managed endpoint URL '\n + '(externalEndpoints.postgresql: { connectionUrl: \"postgresql://...\" }) and re-run `wildo config sync`.',\n );\n }\n if (!isManaged && !addresses.infra.postgresql) {\n // Believed unreachable: a POSTGRESQL-engined SELF platform always resolves the postgres\n // address (the `needsLocalPostgreSQL` union includes the engine half, and the remote\n // resolvers throw earlier on missing infra). Asserted rather than silently emitting an empty\n // URL, so if a future resolver change makes it reachable it fails HERE with a name instead of\n // at boot-time env validation three layers away (5.3 review round 3, F7).\n throw new Error(\n 'database.engine is POSTGRESQL with source SELF, but no postgresql infra address resolved for this '\n + 'environment — the address resolver and the needsLocalPostgreSQL union disagree. This is a CLI bug; '\n + 'report it with the environment name and `wildo.infra.<env>.config.ts`.',\n );\n }\n const pgConnectUrl = isManaged\n ? config.externalEndpoints!.postgresql!.connectionUrl\n : buildPlatformPostgresConnectionUrl(\n addresses.infra.postgresql!,\n {\n user: credentials.postgresql.adminUser,\n password: credentials.postgresql.adminPassword,\n },\n /**\n * The PLATFORM's own database — deliberately NOT `infrastructure.postgresql.database`.\n * That field is mirrored from the author's `backingServices.postgresql.database`, which\n * names the APPLICATION's database and doubles as the compose container's initdb\n * database; using it put the platform's ~94 tables inside the application's database,\n * where `create table if not exists` would let the application silently adopt them. See\n * {@link PLATFORM_POSTGRES_DATABASE}.\n */\n PLATFORM_POSTGRES_DATABASE,\n config.infrastructure.postgresql.sslMode,\n );\n env[PlatformInfrastructureEnvKeys.PG_CONNECT_URL] = pgConnectUrl;\n env[ApplicationBackendDataEnvKeys.DATABASE_DEFAULT_ADAPTER] = PersistenceAdapter.POSTGRESQL;\n}\n\n/**\n * `postgresql://user:password@host:port/database?sslmode=...` from resolved parts. Credentials are\n * URL-encoded — an admin password with `@`/`:`/`#` would otherwise silently corrupt the authority\n * section. TLS rides IN the URL on purpose: the runtime's pre-connect door takes the URL as the\n * complete connection truth (an out-of-band SSL knob beside an explicit URL is two sources of\n * truth for one connection).\n */\nfunction buildPlatformPostgresConnectionUrl(\n address: { host: string; port: number },\n credentials: { user: string; password: string },\n databaseName: string,\n sslMode: string,\n): string {\n const user = encodeURIComponent(credentials.user);\n const password = encodeURIComponent(credentials.password);\n // The database name rides in a PATH segment, so it gets the same treatment as the credentials\n // (5.3 review F7): an authored name with a `?`/`#`/`/` would otherwise silently truncate the\n // URL at the wrong boundary. `sslmode` comes from a closed token vocabulary and stays literal.\n const database = encodeURIComponent(databaseName);\n return `postgresql://${user}:${password}@${address.host}:${address.port}/${database}?sslmode=${sslMode}`;\n}\n\n/**\n * Project the authored `infra.observability.*` block onto the standard `OTEL_*` env-var\n * surface read by the `otel-preload.ts` SDK (Slice 2 Phase 5). Emitted ONLY when telemetry\n * is enabled — a host with `observability` absent/disabled gets NO `OTEL_*`, so the preload\n * self-gates to a complete no-op.\n *\n * `service.name` goes in `OTEL_SERVICE_NAME` (NOT `service.name` inside\n * `OTEL_RESOURCE_ATTRIBUTES`), so the preload's `?? 'wildo-saas-backend'` default can never\n * clobber it (Phase 1 review note 4); `deployment.environment` goes in `OTEL_RESOURCE_ATTRIBUTES`.\n *\n * `OTEL_EXPORTER_OTLP_HEADERS` (provider auth) is derived PROVIDER-AGNOSTICALLY from the\n * SELECTED `OBSERVABILITY_TELEMETRY` provider's `otlpAuth` hint + its secret token (Slice 2\n * Phase 5b) — see `resolveOtlpAuthHeader`. Omitted for a no-auth endpoint (the local dev\n * collector) or an un-provisioned token, so the local-collector path stays a clean no-auth\n * export and telemetry still flows (just unauthenticated) before the secret lands.\n */\nfunction emitObservabilityEnv(\n env: Record<string, string>,\n observability: PlatformEnvConfigJson['observability'] | undefined,\n identity: { serviceName?: string; environment?: string; version?: string },\n telemetryProvider?: { ref?: string; providerEnv?: ScopedProviderEnv },\n): void {\n // LLM-call observability posture (`WILDO_LLM_OBS_*`) — a SEPARATE signal from\n // OTLP telemetry, projected INDEPENDENTLY of the `enabled` gate below: its\n // activation is `LLM_OBSERVABILITY` provider-selection-driven, so an env can\n // capture agent-call content with OTLP telemetry off (and vice versa).\n const llmObservability = observability?.llmObservability;\n if (llmObservability?.captureContent === true) {\n env[PlatformObservabilityEnvKeys.WILDO_LLM_OBS_CAPTURE_CONTENT] = 'true';\n }\n if (llmObservability?.sampleRate !== undefined) {\n env[PlatformObservabilityEnvKeys.WILDO_LLM_OBS_SAMPLE_RATE] = String(llmObservability.sampleRate);\n }\n // Non-secret provider connection env (e.g. POSTHOG_HOST / POSTHOG_PROJECT_ID),\n // authored in checked-in config. In the app-backend/companion/worker builders\n // this runs BEFORE the secrets `providerEnv` loop, so a same-key secret\n // deliberately overwrites it (secrets are the more specific layer). Platform\n // hosts have no secrets loop and simply receive these keys — harmless, since\n // the sink fail-closes without the secret API key.\n for (const [envVarName, value] of Object.entries(llmObservability?.providerEnv ?? {})) {\n setIfDefined(env, envVarName, value);\n }\n if (!observability?.enabled) return;\n env[PlatformObservabilityEnvKeys.OTEL_ENABLED] = 'true';\n setIfDefined(env, PlatformObservabilityEnvKeys.OTEL_EXPORTER_OTLP_ENDPOINT, observability.endpoint);\n setIfDefined(env, PlatformObservabilityEnvKeys.OTEL_SERVICE_NAME, identity.serviceName);\n // `OTEL_RESOURCE_ATTRIBUTES` is a comma-separated `key=value` list. `deployment.environment` is\n // present whenever the env is known; `service.version` (audit A-10) is added when the caller\n // threads the host's release version (the SaaS app's package.json `version`).\n const resourceAttributes: string[] = [];\n if (identity.environment) {\n resourceAttributes.push(`deployment.environment=${identity.environment}`);\n }\n if (identity.version) {\n resourceAttributes.push(`service.version=${identity.version}`);\n }\n if (resourceAttributes.length > 0) {\n env[PlatformObservabilityEnvKeys.OTEL_RESOURCE_ATTRIBUTES] = resourceAttributes.join(',');\n }\n setIfDefined(\n env,\n PlatformObservabilityEnvKeys.OTEL_EXPORTER_OTLP_HEADERS,\n resolveOtlpAuthHeader(telemetryProvider?.ref, telemetryProvider?.providerEnv),\n );\n}\n\n/**\n * Resolve the `OTEL_EXPORTER_OTLP_HEADERS` value (a single `name=value` OTLP/HTTP header) for\n * the SELECTED `OBSERVABILITY_TELEMETRY` provider — PROVIDER-AGNOSTICALLY. Reads the provider's\n * `otlpAuth` hint (header name + `{token}` value template) from the COMPOSED provider catalogue\n * and the secret token from the per-env `providerEnv` map, naming NO provider.\n *\n * Returns `undefined` (→ no header emitted) when: no provider is selected; the selected provider\n * declares no `otlpAuth` (a no-auth endpoint — e.g. the local dev collector); or the token is not provisioned in\n * `providerEnv` yet. All three are valid states — telemetry still exports, just unauthenticated —\n * so this never blocks the pipeline on a missing secret.\n *\n * ## The `providerEnv` reaching here IS the scoped bag — the confinement's second delivery path\n *\n * This function composes a provider CREDENTIAL into a header value, so it is a second site of the\n * per-runtime confinement invariant, not merely a formatter. Until 2026-09-06 both application-tier\n * builders handed it the raw `credentials.providerEnv`: a worker built with\n * `declaredProviderScope([])` correctly received NO `BETTERSTACK_SOURCE_TOKEN` and then received\n * `OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer <that same token>` — the withheld bytes,\n * delivered by the next line (#360).\n *\n * **Decided 2026-09-06 (Paul): `providers.scopes.<runtime>` MUST list the telemetry provider for\n * that runtime to receive its token.** The alternative — treating telemetry as a cross-cutting\n * platform concern exempt from the scope — was rejected because it would leave \"declared scope\"\n * meaning one thing on the key path and another here, and because the token stays readable in the\n * process environment of every worker and minion, which is exactly the surface LLM-driven minion\n * code reads. A third reading (silently widening the scope by the SELECTED telemetry provider) was\n * rejected as not a middle ground at all: the minion still receives the token, and the scope comes\n * to mean something its author did not write.\n *\n * The authoring consequence is real and small. A runtime that does not declare the provider still\n * exports telemetry — `OTEL_ENABLED` and the endpoint are unaffected — it exports it\n * UNAUTHENTICATED, the same state as a no-auth collector or an unprovisioned token. Measured before\n * the change, and the bound matters: `betterstack` was then the only provider declaring `otlpAuth` (a registry module since #2579),\n * and no `secrets.json` on this development machine — the two dogfood applications plus the\n * framework's own store — provisions `BETTERSTACK_SOURCE_TOKEN`, so NO RUNTIME IN THIS REPOSITORY\n * loses a header. That is not a claim about every application: an application elsewhere that HAS\n * provisioned the token, on a runtime that does not declare the provider, loses its header on\n * upgrade and must add the declaration. Wonder Todos' backend and companion already declare it; its\n * `myRustWorker`, `myNodeWorker` and `marketingScrapper` do not, and would have to the day a token\n * is provisioned — which is what this decision costs, stated rather than discovered.\n *\n * The scoping is enforced by the {@link ScopedProviderEnv} parameter type rather than by this\n * comment, so a future caller cannot reintroduce the bypass without a cast.\n */\nfunction resolveOtlpAuthHeader(\n providerRef: string | undefined,\n providerEnv: ScopedProviderEnv | undefined,\n): string | undefined {\n if (!providerEnv) return undefined;\n // The telemetry provider is the explicitly-selected ref when the caller threads one (the\n // forward hook); otherwise the single registry provider that BOTH declares `otlpAuth` AND has\n // its secret provisioned in this env — operators collect only the selected provider's token,\n // so the provisioned secret identifies it unambiguously without a saasConfig round-trip here.\n const provider = providerRef\n ? getComposedProviderEntry(providerRef)\n : findProvisionedTelemetryProvider(providerEnv);\n const otlpAuth = provider?.otlpAuth;\n if (!otlpAuth) return undefined;\n const tokenEnvVarName = resolveOtlpTokenEnvVarName(provider, otlpAuth);\n const token = tokenEnvVarName ? providerEnv[tokenEnvVarName] : undefined;\n if (!token) return undefined;\n // Audit A-13: `OTEL_EXPORTER_OTLP_HEADERS` is a comma-separated `name=value` list (W3C-baggage\n // style); the OTel SDK splits on `,` first, so a token containing a comma would be silently\n // truncated → a 401 from the ingest. Fail-closed: such a token is unusable in this transport.\n if (token.includes(',')) {\n throw new Error(\n `Telemetry provider token for the '${otlpAuth.headerName}' header contains a comma, which is ` +\n `invalid inside OTEL_EXPORTER_OTLP_HEADERS (a comma-separated header list). Re-provision a ` +\n `comma-free token.`,\n );\n }\n return `${otlpAuth.headerName}=${otlpAuth.valueTemplate.replace('{token}', token)}`;\n}\n\n/**\n * The `secretsContract` env-var name that feeds an `otlpAuth` `{token}`: the explicitly-named\n * `secretContractKey`, else the sole entry (unambiguous only when the provider declares exactly\n * one secret). `undefined` when the contract has multiple entries and none is named.\n */\nfunction resolveOtlpTokenEnvVarName(\n provider: ProviderSecretsCatalogueEntry,\n otlpAuth: NonNullable<ProviderSecretsCatalogueEntry['otlpAuth']>,\n): string | undefined {\n const secretKey = otlpAuth.secretContractKey\n ?? (provider.secrets.length === 1 ? provider.secrets[0].slug : undefined);\n return secretKey ? provider.secrets.find((secret) => secret.slug === secretKey)?.envVarName : undefined;\n}\n\n/**\n * Find the telemetry provider to authenticate as when no ref is explicitly threaded: the single\n * catalogue provider declaring `otlpAuth` whose secret token is present in `providerEnv`.\n *\n * `otlpAuth` is a field of a LOADABLE provider module, so a provider known only from a companion\n * contribution never matches here. That is the same outcome as an engine provider declaring no\n * hint — an unauthenticated export — and it is recorded rather than hidden: making the hint\n * companion-safe is owed to whichever slice ships a package-shipped telemetry sink. Operators\n * provision only the SELECTED provider's token, so the provisioned secret identifies it. Returns\n * `undefined` when none is provisioned (the no-auth / local-collector path).\n */\nfunction findProvisionedTelemetryProvider(\n providerEnv: Record<string, string>,\n): ProviderSecretsCatalogueEntry | undefined {\n const matches: ProviderSecretsCatalogueEntry[] = [];\n for (const provider of getComposedProviderSecretsCatalogue().values()) {\n if (!provider.otlpAuth) continue;\n const envVarName = resolveOtlpTokenEnvVarName(provider, provider.otlpAuth);\n if (envVarName && providerEnv[envVarName]) matches.push(provider);\n }\n if (matches.length === 0) return undefined;\n if (matches.length > 1) {\n // Audit A-8: the provisioned-secret heuristic is unambiguous only while exactly ONE otlpAuth\n // provider has a token. If two ever coexist, picking by iteration order is invisible to a\n // reader — warn loudly so the ambiguity surfaces. The real fix is to thread the SELECTED\n // provider ref (the `providerRef` forward hook in `resolveOtlpAuthHeader`) from the caller.\n // eslint-disable-next-line no-console\n console.warn(\n `[env-builder] ${matches.length} OBSERVABILITY_TELEMETRY providers have a provisioned token; ` +\n `the OTLP auth header is AMBIGUOUS. Using the first registered match — thread the selected ` +\n `provider ref to disambiguate.`,\n );\n }\n return matches[0];\n}\n\nfunction requireAddress(address: ResolvedServiceAddress | null, name: string): ResolvedServiceAddress {\n if (!address) {\n throw new Error(`Infrastructure address '${name}' is null — use CONTAINER_INTERNAL perspective for K8s remote`);\n }\n return address;\n}\n\nfunction resolveApplicationEnv(\n environment: PlatformEnvironmentConfiguration,\n config: PlatformEnvConfigJson,\n): string {\n const applicationEnv = config.runtimeEnvironment ?? environment.runtimeEnvironment;\n if (!applicationEnv) {\n throw new Error(\n `Environment '${environment.name}' is missing explicit runtime semantics for env generation.`,\n );\n }\n return applicationEnv;\n}\n\nfunction resolveKubernetesEnvVars(\n environment: PlatformEnvironmentConfiguration,\n): {\n namespace: string;\n} | null {\n if (environment.runtime !== WildoDeploymentRuntime.KUBERNETES) {\n return null;\n }\n\n if (environment.locationType === WildoLocationType.LOCAL) {\n return {\n namespace: environment.kubernetes?.namespace ?? 'wildo-local',\n };\n }\n\n const namespace = environment.kubernetes?.namespace;\n\n if (!namespace) {\n throw new Error(\n `Environment '${environment.name}' is missing explicit remote Kubernetes namespace metadata.`,\n );\n }\n\n return { namespace };\n}\n\n/**\n * The backend's MongoDB env, from an authored `externalEndpoints.mongodb.connectionUrl` — host list, database,\n * protocol, and the TLS and replica set the URL states (#2000).\n *\n * Read with the MongoDB connection-string grammar (`readMongoConnectionStringTarget`), never `new URL(...)`: a\n * replica-set seed list lists SEVERAL comma-separated hosts, which WHATWG URL parsing rejects (`ERR_INVALID_URL`), so\n * an Atlas cluster with no SRV address — whose address IS such a list — could not be given an env at all. And the\n * transport is carried, not dropped: that seed list states `ssl=true` and its `replicaSet`, and a `mongodb://`\n * string opened without them has no TLS, which Atlas refuses.\n *\n * Credentials in the URL are never copied into env: they reach the backend through its secrets.\n */\nfunction buildMongoEnvFromConnectionUrl(\n connectionUrl: string,\n appDatabaseName?: string | undefined,\n): { host: string; database: string; protocol: MongoDBProtocol; tls?: boolean; replicaSet?: string } {\n const target = readMongoConnectionStringTarget(connectionUrl);\n if (!target) {\n throw new Error(\n '`externalEndpoints.mongodb.connectionUrl` is not a MongoDB connection string with a host '\n + '(expected `mongodb://host[:port][,host[:port]…]/…` or `mongodb+srv://host/…`).',\n );\n }\n return {\n host: target.hosts,\n database: appDatabaseName ?? (target.database || 'wildo_app'),\n protocol: target.protocol,\n ...(target.tls !== undefined ? { tls: target.tls } : {}),\n ...(target.replicaSet ? { replicaSet: target.replicaSet } : {}),\n };\n}\n\n/**\n * Pick the canonical app-side MongoDB database name following the\n * documented precedence:\n * 1. Caller-supplied `appDatabaseName` (today only used for explicit\n * per-app overrides — kept first because it is the most specific signal).\n * 2. Authored `backingServices.mongodb.database` from `wildo.infra.<env>.config.ts`.\n * 3. Hard-coded `'wildo_app'` fallback.\n *\n * The same precedence is applied uniformly across local-MongoDB and Atlas\n * branches so toggling `BackingServiceSource` does not change which database\n * the application points at.\n *\n * Slice 3 closeout (L-5): the authored field is `database` for both\n * Mongo and Postgres now (was `name` on Mongo only) — symmetric naming\n * eliminates the cross-kind asymmetry that masked the meaning.\n */\nfunction pickAppMongoDatabase(\n backingServices: BackingServicesEnvConfig | undefined,\n appDatabaseName: string | undefined,\n): string {\n return appDatabaseName\n ?? backingServices?.[BackingServiceKind.MONGODB]?.database\n ?? 'wildo_app';\n}\n\n/**\n * Whether this environment's env files must carry the PostgreSQL admin credentials.\n *\n * The UNION rule, deliberately mirroring {@link EnvironmentLifecycle.needsLocalPostgreSQL}: the\n * platform's own engine being PostgreSQL is only HALF the question — an author may declare\n * `backingServices.postgresql: SELF` on a MongoDB-platform app (PostgreSQL for the application's\n * resources), and the compose generator then renders the postgres service from that same rule.\n *\n * This function used to be `config.database.engine === POSTGRESQL` alone, which is the exact\n * predicate the compose generator's `includePostgreSQL` JSDoc rejects — the widening had been\n * applied at ONE of the seam's two sides. Observed live 2026-08-11: the rendered compose declared\n * `wildo-postgresql` while `.env.wildo-platform` carried no `POSTGRES_ADMIN_PASSWORD`, so the\n * container crash-looped on a blank superuser password and `wildo local dev` failed at\n * infrastructure readiness. One predicate, both gates — keep them united here.\n */\nfunction shouldProvisionPostgreSQL(\n config: PlatformEnvConfigJson,\n env: { name: string; backingServices?: BackingServicesEnvConfig },\n): boolean {\n return config.database.engine === DatabaseEngine.POSTGRESQL || EnvironmentLifecycle.needsLocalPostgreSQL(env);\n}\n\nfunction assertSupportedStorageConfig(config: PlatformEnvConfigJson): void {\n if (config.infrastructure.storage.provider !== 'minio') {\n throw new Error(\n `Unsupported storage provider '${config.infrastructure.storage.provider}'. Only managed MinIO wiring is currently supported.`,\n );\n }\n\n if (config.externalEndpoints?.storage) {\n throw new Error(\n 'External storage wiring is not supported yet. Only managed MinIO addresses from the platform topology are expected.',\n );\n }\n\n if (\n config.externalServices?.storage\n && config.externalServices.storage.provider !== 'minio'\n ) {\n throw new Error(\n `Unsupported external storage provider '${config.externalServices.storage.provider}'. Only managed MinIO wiring is currently supported.`,\n );\n }\n}\n\n/**\n * Refuse to emit an application-tier environment that contains the object\n * store's ROOT credential.\n *\n * ## Why a value comparison and not a key check\n *\n * Checking for the KEY `STORAGE_ACCESS_KEY` would be trivially defeated by\n * emitting the same secret under a different name — and more importantly it would\n * miss the actual failure mode, which is a *value* leaking through a variable\n * nobody thought to audit. The root secret is what must not appear, whatever it\n * is called.\n *\n * ## Why the ACCESS KEY is not in the forbidden set\n *\n * Because it is not a secret, and treating it as one made the guard weaker.\n *\n * An access key is a principal *identifier*: for MinIO it is the account name\n * (conventionally the literal `minio`, which is also the provider name and the\n * compose service hostname), and in this repository's own generated secrets it is\n * a short shared admin username — byte-identical to `mongodb.rootUser` and\n * `rabbitmq.adminUsername`. Holding it alone grants nothing.\n *\n * Scanning for it therefore produced false positives on structurally public\n * values, and the first fix for that was a list of env-key NAMES exempted from\n * the scan. That list is exactly the key-based mechanism the paragraph above\n * rejects: it re-introduced a by-name escape hatch into a value-based guard, and\n * an over-broad guard invites deletion under deadline — which is how this control\n * would actually be lost.\n *\n * Forbidding only the SECRET removes both problems at once. A 32-character\n * high-entropy value cannot collide with a hostname, a bucket name or a provider\n * id, so no exemption list is needed and there is no name a builder can choose to\n * slip past the scan. The access key travelling in app env would be harmless; the\n * secret travelling with it is the entire exposure.\n *\n * ## Why it never logs the value\n *\n * The whole point is that this secret should not spread. An error message\n * containing it would write it into CI logs, which is a worse place than the env\n * file it was caught in. The message names the KEY only.\n *\n * Applies to application-tier env exclusively. Platform-tier builders\n * (`buildInfraCredentialEnv`, `buildAppsManagerFullEnv`) legitimately carry admin\n * material — apps-manager is the STS broker and cannot broker without it. Whether\n * those consumers should hold *root* specifically is still an open question for\n * THOSE two.\n *\n * `buildBootstrapEnv` left that list with #1761: the bootstrap services\n * (module-registry, crontabs-batches-manager) resolve storage through apps-manager's\n * STS like any application, so the root pair it handed them was never read.\n *\n * `buildCompanionPlatformEnv` was in that list and no longer is, for the storage\n * axis: the companion runs the app-tier storage provider and fetches STS sessions\n * like any application, so the root pair it was being handed was never read. It\n * remains platform-tier for Mongo/Redis/RabbitMQ, which is why the blanket guard is\n * still not applied to it — `omits the object storage ROOT credential` in the\n * builder tests pins the storage half specifically.\n */\nexport function assertNoStorageSecretInGeneratedEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n builderName: string,\n): void {\n assertNoPlatformCredentialInGeneratedEnv(env, credentials, builderName);\n}\n\n/**\n * Every PLATFORM-tier credential that must never appear in an application-tier\n * environment, with the label used to report it.\n *\n * ## Why the whole set and not just storage\n *\n * Object storage was the one backing service whose credential reached every\n * workload, and it was found by reading the code rather than by any check. The\n * other four — Mongo, PostgreSQL, Redis, RabbitMQ — are absent from app env only\n * because each mints per-application credentials that travel over the\n * authenticated apps-manager fetch. That is a property of how those providers\n * happen to be wired today, not something enforced anywhere. A future provider\n * that skips minting (exactly what `MinioSelfInfraProviderModule` did) would\n * reproduce the same exposure against a different service, and nothing would\n * catch it.\n *\n * Verified before this widened: with the set below, every generated Wonder Todos\n * application and minion env is clean.\n *\n * ## Why only SECRETS, never identifiers\n *\n * `mongodb.rootUser`, `rabbitmq.adminUsername`, `postgresql.adminUser` and\n * `storage.accessKey` are principal NAMES. In this repository's generated secrets\n * three of them are the SAME five-character string, which also appears as a\n * hostname and a provider id — scanning for those produced false positives on\n * correct configurations, and the first attempt to suppress them re-introduced a\n * by-name exemption list into a value-based guard. Only high-entropy secret\n * material belongs here.\n *\n * ## What is deliberately NOT here\n *\n * - `providerEnv` values (OpenAI, Stripe, …) — authored application credentials\n * that an application legitimately holds. They are constrained by DECLARED\n * SCOPE (`providers.scopes.*`), a different control with its own tests.\n * - The app's own `PLATFORM_APPLICATION_PRIMARY_SECRET` — minted per application\n * by apps-manager, and the one credential that MUST be in env because it is\n * what authenticates the fetch by which everything else arrives. Note\n * `platform.primarySecret` below is a different value: the PLATFORM's own\n * secret, which an application must never hold.\n */\n/**\n * apps-manager's response keys (#2921), or a loud refusal naming the remedy.\n *\n * Fail-loud rather than optional, like the crontabs keypair: apps-manager may not answer an application runtime unsigned,\n * and a runtime refuses to boot without the keys to verify it. A secrets.json that predates the keys acquires them on\n * the next provisioning self-heal (`wildo config sync`, `wildo local dev`, `wildo local up`).\n */\nfunction requireAppsManagerResponseSigning(\n credentials: PlatformEnvSecretsJson,\n): NonNullable<PlatformEnvSecretsJson['platform']['appsManagerResponseSigning']> {\n const keys = credentials.platform.appsManagerResponseSigning;\n if (!keys) {\n throw new Error(\n \"secrets.platform.appsManagerResponseSigning is missing: apps-manager's response keys are not available \" +\n '(#2921). Without them apps-manager cannot sign its answers and every application runtime refuses to start. ' +\n 'Locally, run `wildo config sync` (or `wildo local dev`), which mints them into secrets.json. In CI, the ' +\n 'secrets are rebuilt from the environment: regenerate the deploy workflows (`wildo config sync --domain cicd`) ' +\n 'so they forward the WILDO_SECRET_PLATFORM_APPS_MANAGER_RESPONSE_SIGNING_* secrets, and add those secrets to ' +\n 'the repository.',\n );\n }\n return keys;\n}\n\n/**\n * The verification key set every application runtime carries: current, then next (see\n * `buildRuntimeResponseVerificationKeySet`). One function so the backend, minion, worker and companion builders cannot\n * disagree about it.\n */\nfunction appsManagerResponseVerificationKeys(credentials: PlatformEnvSecretsJson): string {\n const keys = requireAppsManagerResponseSigning(credentials);\n return buildRuntimeResponseVerificationKeySet([keys.publicKey, keys.nextPublicKey]);\n}\n\n/**\n * The platform's key-encryption root (#2891). Fail-loud like the response keys: an apps-manager env generated without\n * it starts but cannot seal or use a single key, because a key it cannot seal must not be stored. The provisioning\n * self-heal mints it into secrets.json.\n */\nfunction requireKeyEncryptionRoot(\n credentials: PlatformEnvSecretsJson,\n): NonNullable<PlatformEnvSecretsJson['platform']['keyEncryptionRoot']> {\n const root = credentials.platform.keyEncryptionRoot;\n if (!root?.current) {\n throw new Error(\n \"secrets.platform.keyEncryptionRoot is missing: apps-manager's key-encryption root is not available (#2891). \"\n + 'Without it apps-manager cannot seal the keys it signs approval seals with, and refuses every signature. Locally, run '\n + '`wildo config sync` (or `wildo local dev`), which mints it into secrets.json. In CI, regenerate the deploy '\n + 'workflows (`wildo config sync --domain cicd`) so they forward WILDO_SECRET_PLATFORM_KEY_ENCRYPTION_ROOT_*, and '\n + 'add that secret to the repository.',\n );\n }\n return root;\n}\n\n/**\n * apps-manager's Vault (#2933), from `platformKeyManagement.vault`: the self-hosted OpenBao the lanes render (its\n * address and the framework-minted token ids) or the operator's own Vault (the authored address and layout, and the\n * operator-typed tokens under `secrets.platformKeyVaultManaged`). Nothing is emitted without a declaration, and nothing\n * when the tokens are missing: apps-manager then serves no Vault provider, and a binding naming one is refused\n * PROVIDER_UNAVAILABLE, which names the gap. A partial set is never emitted, because apps-manager refuses a partial\n * configuration and the operator would read a logged error instead of this one rule.\n */\nfunction emitPlatformKeyVaultEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n environment: PlatformEnvironmentConfiguration,\n): void {\n const vault = environment.platformKeyManagement?.vault;\n if (!vault) return;\n if (vault.source === BackingServiceSource.SELF) {\n const address = addresses.infra.openbao;\n const tokens = credentials.platformKeyVault;\n if (!address || !tokens?.signerToken || !tokens.operatorToken) return;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_ADDRESS] = address.url;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_SIGNER_TOKEN] = tokens.signerToken;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_OPERATOR_TOKEN] = tokens.operatorToken;\n return;\n }\n const tokens = credentials.platformKeyVaultManaged;\n if (!tokens) return;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_ADDRESS] = vault.address;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_SIGNER_TOKEN] = tokens.signerToken;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_OPERATOR_TOKEN] = tokens.operatorToken;\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_NAMESPACE, vault.namespace);\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_TRANSIT_MOUNT, vault.transitMount);\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_KV_MOUNT, vault.kvMount);\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_VAULT_KEY_NAME_PREFIX, vault.keyNamePrefix);\n}\n\n/**\n * apps-manager's cloud KMS providers (#2896), from `platformKeyManagement.awsKms` / `googleCloudKms` / `azureKeyVault`:\n * the account, the key location and the two identities apps-manager acts as. Nothing here is a secret: apps-manager\n * authenticates with its workload identity, so the values come from the authored declaration alone, and every key of\n * one vendor is written together. The defaults (HSM-protected keys) are written explicitly, so apps-manager's\n * environment says what it will create.\n */\nfunction emitPlatformCloudKmsEnv(env: Record<string, string>, environment: PlatformEnvironmentConfiguration): void {\n const { awsKms, googleCloudKms, azureKeyVault } = environment.platformKeyManagement ?? {};\n if (awsKms) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AWS_KMS_REGION] = awsKms.region;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AWS_KMS_SIGNER_ROLE_ARN] = awsKms.signerRoleArn;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AWS_KMS_OPERATOR_ROLE_ARN] = awsKms.operatorRoleArn;\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_AWS_KMS_ENDPOINT, awsKms.endpoint);\n }\n if (googleCloudKms) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_GOOGLE_KMS_KEY_RING] = googleCloudKms.keyRing;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_GOOGLE_KMS_SIGNER_SERVICE_ACCOUNT] = googleCloudKms.signerServiceAccount;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_GOOGLE_KMS_OPERATOR_SERVICE_ACCOUNT] = googleCloudKms.operatorServiceAccount;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_GOOGLE_KMS_PROTECTION_LEVEL] = googleCloudKms.protectionLevel ?? PlatformGoogleKmsKeyProtection.HSM;\n }\n if (azureKeyVault) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_URL] = azureKeyVault.vaultUrl;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_SIGNER_CLIENT_ID] = azureKeyVault.signerClientId;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_OPERATOR_CLIENT_ID] = azureKeyVault.operatorClientId;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_HSM] = String(azureKeyVault.hsm ?? true);\n setIfDefined(env, PlatformSecurityEnvKeys.PLATFORM_KEY_AZURE_KEY_VAULT_LOG_ANALYTICS_WORKSPACE_ID, azureKeyVault.logAnalyticsWorkspaceId);\n }\n}\n\n/**\n * apps-manager's dedicated HSM over PKCS#11 (#2934), from `platformKeyManagement.pkcs11` and the operator-typed PIN under\n * `secrets.platformKeyPkcs11`. Nothing is emitted without both, for the Vault reason: apps-manager refuses a partial\n * configuration, and the operator would read a logged error instead of this one rule.\n */\n/** The shortest PKCS#11 PIN the platform-credential scan looks for (see `resolveForbiddenPlatformCredentials`). */\nconst PKCS11_PIN_NEEDLE_MINIMUM_LENGTH = 12;\n\nfunction emitPlatformPkcs11Env(env: Record<string, string>, credentials: PlatformEnvSecretsJson, environment: PlatformEnvironmentConfiguration): void {\n const pkcs11 = environment.platformKeyManagement?.pkcs11;\n const pin = credentials.platformKeyPkcs11?.pin;\n if (!pkcs11 || !pin) return;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_PKCS11_MODULE_PATH] = pkcs11.modulePath;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_PKCS11_TOKEN_LABEL] = pkcs11.tokenLabel;\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_PKCS11_PIN] = pin;\n if ((pkcs11.hardwareTokenModels ?? []).length > 0) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_PKCS11_HARDWARE_TOKEN_MODELS] = (pkcs11.hardwareTokenModels ?? []).join(',');\n }\n}\n\nfunction resolveForbiddenPlatformCredentials(\n credentials: PlatformEnvSecretsJson,\n): ReadonlyArray<readonly [label: string, value: string]> {\n const candidates: ReadonlyArray<readonly [string, unknown]> = [\n ['the object storage ROOT credential', credentials.storage?.secretKey],\n ['the MongoDB root password', credentials.mongodb?.rootPassword],\n ['the PostgreSQL admin password', credentials.postgresql?.adminPassword],\n ['the Valkey/Redis admin password', credentials.valkey?.adminPassword],\n ['the RabbitMQ admin password', credentials.rabbitmq?.adminPassword],\n ['the RabbitMQ Erlang cookie', credentials.rabbitmq?.erlangCookie],\n // #1696 — the self-hosted immudb server's sysadmin: apps-manager's alone. Generated (never the operator's\n // `IMMUDB_PASSWORD`, which is exactly the copy that made it an application credential), so it is long and\n // unique and a containment match cannot fire on an unrelated value.\n ['the immudb server administrator password', credentials.immudb?.adminPassword],\n ['the PLATFORM primary secret', credentials.platform?.primarySecret],\n ['the PLATFORM admin secret', credentials.platform?.adminSecret],\n // #2921 — apps-manager's response keys sign what every runtime trusts; a runtime holding one could forge it.\n ['the apps-manager response signing key', credentials.platform?.appsManagerResponseSigning?.privateKey],\n ['the apps-manager next response signing key', credentials.platform?.appsManagerResponseSigning?.nextPrivateKey],\n // #2891 — every LOCAL private key is sealed under it; a runtime holding it could open the seal keys.\n ['the platform key-encryption root', credentials.platform?.keyEncryptionRoot?.current],\n ['the platform previous key-encryption root', credentials.platform?.keyEncryptionRoot?.previous],\n // #2933 — the platform Vault: its unseal key opens every key stored there, and its tokens sign with or manage them.\n ['the platform Vault unseal key', credentials.platformKeyVault?.unsealKey],\n ['the platform Vault signer token', credentials.platformKeyVault?.signerToken],\n ['the platform Vault operator token', credentials.platformKeyVault?.operatorToken],\n // #3006 — the break-glass recovery token mints signer tokens and re-wraps the server's root key; the previous unseal\n // key opens the storage until that re-wrap. Neither belongs to any runtime, apps-manager included.\n ['the platform Vault recovery token', credentials.platformKeyVault?.recoveryToken],\n ['the platform Vault previous unseal key', credentials.platformKeyVault?.previousUnsealKey],\n ['the platform Vault signer token (managed)', credentials.platformKeyVaultManaged?.signerToken],\n ['the platform Vault operator token (managed)', credentials.platformKeyVaultManaged?.operatorToken],\n // The PIN is the HSM owner's choice, not a generated string, and this check is CONTAINMENT: a four-digit PIN would be\n // found inside a port number. It is a needle only at a length where a match means it, which is also the only kind of\n // PIN worth guarding; the skill tells the operator to set a long one.\n ['the platform PKCS#11 token PIN', (credentials.platformKeyPkcs11?.pin?.length ?? 0) >= PKCS11_PIN_NEEDLE_MINIMUM_LENGTH ? credentials.platformKeyPkcs11?.pin : undefined],\n ];\n\n const present = candidates.filter(\n (entry): entry is readonly [string, string] =>\n typeof entry[1] === 'string' && entry[1].length > 0,\n );\n\n /**\n * Each credential is also forbidden in its PERCENT-ENCODED form (5.3 review F6): credentials now\n * legitimately travel URL-EMBEDDED on the platform tier (`PG_CONNECT_URL` carries the encoded\n * admin password), so a future application-tier builder that copies such a URL would smuggle the\n * credential past an exact-value comparison. The check below is containment, and this widens the\n * needle set to the encoded spelling too. Only added when encoding actually changes the value.\n */\n const encodedVariants = present\n .filter(([, value]) => encodeURIComponent(value) !== value)\n .map(([label, value]) => [`${label} (URL-encoded)`, encodeURIComponent(value)] as const);\n\n return [...present, ...encodedVariants];\n}\n\n/**\n * Refuse to emit an application-tier environment containing ANY platform-tier\n * credential. Generalises the storage-specific gate that preceded it; see\n * {@link resolveForbiddenPlatformCredentials} for the set and its exclusions, and\n * the JSDoc above for why this compares values rather than key names and never\n * prints the offending value.\n */\nexport function assertNoPlatformCredentialInGeneratedEnv(\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n builderName: string,\n): void {\n /*\n * A non-string value is a CONTRACT VIOLATION by the caller — the parameter is `Record<string,\n * string>` — and it is refused here, named, rather than left to crash the scan below.\n *\n * It crashed for real: a fixture predating `2fc51ec5a` omitted `APPLICATION_SLUG`, the builder\n * emitted the key as `undefined`, and `emitted.includes(value)` threw\n * `Cannot read properties of undefined (reading 'includes')` — a stack trace inside the\n * platform-credential guard, which reads as a leak-detection defect and says nothing about a\n * missing slug. Seven tests failed that way.\n *\n * Refusing rather than skipping, for the reason the scan below already gives: every emitted value\n * is compared, with no key exemptions. Silently skipping a non-string would be an exemption that\n * nobody declared — and an env var whose value is `undefined` reaches a real Secret as the string\n * \"undefined\" or not at all, so it is a defect in its own right wherever it appears.\n */\n const nonStringKeys = Object.entries(env).filter(([, value]) => typeof value !== 'string').map(([key]) => key);\n if (nonStringKeys.length > 0) {\n throw new Error(\n `${builderName} produced an environment whose value is not a string under: ${nonStringKeys.join(', ')}. `\n + 'Every emitted env var must be a string — an undefined value reaches a Secret as \"undefined\" or '\n + 'vanishes, and it cannot be scanned for platform credentials. Fix the contributor that emitted it.',\n );\n }\n\n const forbidden = resolveForbiddenPlatformCredentials(credentials);\n if (forbidden.length === 0) return;\n\n // No key exemptions, deliberately — see the JSDoc. Every emitted value is\n // compared, including the ones a future builder adds without reading this.\n // CONTAINMENT, not equality (5.3 review F6): a credential embedded inside a\n // connection URL is exactly as leaked as one standing alone, and equality was\n // blind to it. Credentials are long generated strings, so substring\n // false-positives are not a realistic concern.\n const findings: string[] = [];\n for (const [label, value] of forbidden) {\n const offendingKeys = Object.entries(env)\n .filter(([, emitted]) => emitted.includes(value))\n .map(([key]) => key);\n if (offendingKeys.length > 0) {\n findings.push(`${label} under: ${offendingKeys.join(', ')}`);\n }\n }\n\n if (findings.length > 0) {\n throw new Error(\n `${builderName} emitted platform-tier credentials into an application-tier environment — `\n + `${findings.join('; ')}. An application receives per-application credentials over the `\n + 'authenticated apps-manager fetch, never the platform\\'s own. '\n + '(The offending values are deliberately not printed.)',\n );\n }\n}\n\n// ============================================================================\n// Builder\n// ============================================================================\n\n/** The trusted reverse-proxy hops in front of an application backend in this deployment (#1788). */\nexport function trustedProxyHopsForApplicationBackend(locationType: WildoLocationType): number {\n switch (locationType) {\n case WildoLocationType.REMOTE:\n return REMOTE_EDGE_PROXY_HOPS;\n case WildoLocationType.LOCAL:\n return 0;\n }\n}\n\nexport class PlatformEnvVarsBuilder {\n /**\n * The EXACT provider-env map merged into every backend / companion / worker\n * runtime — the operator-authored `credentials.providerEnv` PLUS\n * framework-injected provider material (today: the immudb state-signing\n * public key). This is the single authority already used internally at the\n * three runtime merge sites (`buildApplicationBackendEnv`,\n * `buildCompanionPlatformEnv`, and the worker/minion path).\n *\n * Exposed so `wildo config sync` can project the SAME bytes into a\n * standalone provider-secrets `.env` sink for out-of-band consumers (the\n * framework-dev integration test harnesses that are NOT launched by\n * `wildo local dev`). Deriving the sink from this method — rather than\n * re-parsing `secrets.json` — keeps ONE composition authority and makes the\n * sink drift-free by construction (e.g. it never misses the framework-injected\n * immudb key that a naive `providerEnv` copy would drop).\n *\n * ## Confinement result: N/A, deliberately (#360)\n *\n * This is the one remaining path from `credentials.providerEnv` into an artifact that carries\n * VALUES and is not scoped, so it needs a stated result rather than silence — an unstated site\n * reads exactly like one nobody examined (`.claude/rules/invariant-call-site-enumeration.md`).\n *\n * It is not a per-runtime environment. It is the environment-level aggregate sink, written LOCAL\n * only, for framework-development harnesses that no runtime scope describes — so\n * `PLATFORM_TIER_ALL_PROVIDERS` is the honest answer rather than a missing filter. A runtime that\n * receives a scoped env does not read this file.\n *\n * Returns a fresh record (never mutates `credentials.providerEnv`).\n */\n static buildRuntimeProviderEnv(credentials: PlatformEnvSecretsJson): Record<string, string> {\n // Platform tier: the environment-level aggregate provider-secrets artifact,\n // not a per-runtime env. Unscoped by definition.\n return PlatformEnvVarsBuilder.buildScopedProviderEnv(credentials, platformTierAllProvidersScope());\n }\n\n /**\n * The provider-env map ONE runtime is entitled to — the same composition\n * {@link buildRuntimeProviderEnv} performs, through the runtime's declared scope.\n *\n * Exposed for the Kubernetes lane (#369), which delivers provider credentials as a per-runtime\n * `Secret` rather than as lines in a generated `.env`, and so needs the scoped bag as a VALUE\n * instead of as env-file bytes. Routing that lane through this method rather than through\n * `credentials.providerEnv` is the whole fix: it used to emit one cluster-wide `providers-secret`\n * holding everything, `envFrom`-mounted by every application pod, so a worker declaring\n * `providers: {}` received the application's entire provider bag.\n *\n * The scope is positional and required for the same reason it is everywhere else in this file:\n * an omitted scope is how the whole bag reached every runtime in the first place.\n *\n * Returns a fresh record (never mutates `credentials.providerEnv`).\n */\n static buildScopedProviderEnv(\n credentials: PlatformEnvSecretsJson,\n scope: RuntimeProviderScope,\n ): Record<string, string> {\n return resolveRuntimeProviderEnv(credentials, scope);\n }\n\n /**\n * Section A — env vars consumed by infra containers themselves\n * (MongoDB, Valkey, RabbitMQ, MinIO, PostgreSQL).\n */\n static buildInfraCredentialEnv(\n credentials: PlatformEnvSecretsJson,\n config: PlatformEnvConfigJson,\n /** Needed by the postgres UNION rule — `config.json` cannot express `backingServices.postgresql` (see {@link shouldProvisionPostgreSQL}). */\n environment: { name: string; backingServices?: BackingServicesEnvConfig },\n ): Record<string, string> {\n const env: Record<string, string> = {};\n\n if (credentials.mongodb) {\n env['MONGO_ROOT_USER'] = credentials.mongodb.rootUser;\n env['MONGO_ROOT_PASSWORD'] = credentials.mongodb.rootPassword;\n }\n\n if (credentials.valkey) {\n env[VALKEY_CREDENTIAL_ENV_KEYS.PASSWORD] = credentials.valkey.adminPassword;\n }\n\n env[RABBITMQ_CREDENTIAL_ENV_KEYS.DEFAULT_USER] = credentials.rabbitmq.adminUsername;\n env[RABBITMQ_CREDENTIAL_ENV_KEYS.DEFAULT_PASS] = credentials.rabbitmq.adminPassword;\n env[RABBITMQ_CREDENTIAL_ENV_KEYS.ERLANG_COOKIE] = credentials.rabbitmq.erlangCookie;\n\n env[MINIO_CREDENTIAL_ENV_KEYS.ROOT_USER] = credentials.storage.accessKey;\n env[MINIO_CREDENTIAL_ENV_KEYS.ROOT_PASSWORD] = credentials.storage.secretKey;\n // The PLATFORM bucket the compose `minio-init` creates (#1112) — not the application's. Application buckets\n // are created by apps-manager when it first issues that application a storage credential.\n env['STORAGE_BUCKET'] = resolvePlatformObjectStorageBucket(config.platformStorage);\n\n if (shouldProvisionPostgreSQL(config, environment)) {\n if (!credentials.postgresql) {\n // Loud, named failure instead of a TypeError: the compose file WILL render the postgres\n // service from the same rule, and an env file silently missing the credential produces a\n // container crash-looping on a blank superuser password — diagnosed the hard way 2026-08-11.\n throw new Error(\n 'PostgreSQL is part of this environment (platform engine or a SELF backing service) but '\n + 'secrets.json has no `postgresql` credentials. Run `wildo -y setup` to provision them.',\n );\n }\n env[POSTGRESQL_CREDENTIAL_ENV_KEYS.ADMIN_USER] = credentials.postgresql.adminUser;\n env[POSTGRESQL_CREDENTIAL_ENV_KEYS.ADMIN_PASSWORD] = credentials.postgresql.adminPassword;\n env[POSTGRESQL_CREDENTIAL_ENV_KEYS.ADMIN_DATABASE] = config.infrastructure.postgresql.database;\n }\n\n return env;\n }\n\n /**\n * Full env for apps-manager — includes bootstrap vars + all service connections.\n */\n static buildAppsManagerFullEnv(\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n options: {\n includeBootstrapAdminCredentials?: boolean;\n /** apps-manager's own `package.json` version → OTel `service.version` (audit A-10 parity). */\n serviceVersion?: string;\n } = {},\n ): Record<string, string> {\n assertSupportedStorageConfig(config);\n\n const env: Record<string, string> = {};\n\n const amCatalog = PLATFORM_SERVICE_CATALOG[PlatformWildoServices.APPS_MANAGER];\n env[PlatformProcessEnvKeys.HOST] = LISTEN_HOST;\n env[PlatformProcessEnvKeys.PORT] = String(amCatalog.defaultPort);\n env[PlatformProcessEnvKeys.APPS_MANAGER_MODE] = AppsManagerMode.NORMAL;\n env[PlatformProcessEnvKeys.SERVICE_NAME] = amCatalog.serviceEnvVarName;\n env[PlatformProcessEnvKeys.PLATFORM_ENVIRONMENT_ID] = environment.name;\n env[PlatformProcessEnvKeys.APPLICATION_ENV] = resolveApplicationEnv(environment, config);\n\n // -- MongoDB\n emitPlatformMongoEnv(env, credentials, addresses, config, environment);\n\n // -- The platform's OWN PostgreSQL (D7) — no-op unless `database.engine === POSTGRESQL`\n emitPlatformPostgresEnv(env, credentials, addresses, config, environment);\n\n const valkey = requireAddress(addresses.infra.valkey, 'valkey');\n const rabbitmq = requireAddress(addresses.infra.rabbitmq, 'rabbitmq');\n const rabbitmqMgmt = requireAddress(addresses.infra.rabbitmqManagement, 'rabbitmqManagement');\n const minio = requireAddress(addresses.infra.minio, 'minio');\n const postgresql = shouldProvisionPostgreSQL(config, environment)\n ? requireAddress(addresses.infra.postgresql, 'postgresql')\n : null;\n\n // -- Valkey\n env[PlatformInfrastructureEnvKeys.REDIS_HOST] = valkey.host;\n env[PlatformInfrastructureEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n if (credentials.valkey) {\n env[PlatformInfrastructureEnvKeys.REDIS_ADMIN_USER] = credentials.valkey.adminUser;\n env[PlatformInfrastructureEnvKeys.REDIS_ADMIN_PASSWORD] = credentials.valkey.adminPassword;\n }\n\n // -- RabbitMQ\n env[PlatformInfrastructureEnvKeys.RABBITMQ_HOST] = rabbitmq.host;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_PORT] = String(rabbitmq.port);\n env[PlatformInfrastructureEnvKeys.RABBITMQ_MANAGEMENT_PORT] = String(rabbitmqMgmt.port);\n // No RABBITMQ_VHOST (#1112). The platform tier's broker users hold permissions only on the default vhost `/`,\n // and a registered application's vhost travels with its registration (#1107). Rendering this application's\n // authored vhost here made it the platform's, for whichever application synced last.\n env[PlatformInfrastructureEnvKeys.RABBITMQ_ADMIN_USERNAME] = credentials.rabbitmq.adminUsername;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_ADMIN_PASSWORD] = credentials.rabbitmq.adminPassword;\n\n // -- Storage (MinIO)\n env[PlatformInfrastructureEnvKeys.STORAGE_PROVIDER] = config.infrastructure.storage.provider;\n env[PlatformInfrastructureEnvKeys.STORAGE_ENDPOINT] = minio.host;\n env[PlatformInfrastructureEnvKeys.STORAGE_PORT] = String(minio.port);\n env[PlatformInfrastructureEnvKeys.STORAGE_USE_SSL] = String(config.infrastructure.storage.useSsl);\n // apps-manager's OWN bucket: the platform services' storage and the platform application's. The platform\n // authors it (#1112) — never this application's `backingServices.s3.bucket`, which travels with its\n // registration (#1107). module-registry renders the same value below, and the two MUST agree: its\n // credential is confined to the bucket named here while it addresses objects in the one named there.\n env[PlatformInfrastructureEnvKeys.STORAGE_BUCKET] = resolvePlatformObjectStorageBucket(config.platformStorage);\n env[PlatformInfrastructureEnvKeys.STORAGE_ACCESS_KEY] = credentials.storage.accessKey;\n env[PlatformInfrastructureEnvKeys.STORAGE_SECRET_KEY] = credentials.storage.secretKey;\n // The role the STS broker names (#2172): apps-manager only, the one service that calls AssumeRole. Emitted only\n // when authored, because a MinIO-compatible store names no role.\n if (config.platformStorage?.stsRoleArn) {\n env[PlatformInfrastructureEnvKeys.STORAGE_STS_ROLE_ARN] = config.platformStorage.stsRoleArn;\n }\n\n // -- Platform service URLs\n env[PlatformServiceUrlEnvKeys.PLATFORM_APPS_MANAGER_URL] = addresses.platform.appsManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_URL] = addresses.platform.crontabsBatchesManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_MODULE_REGISTRY_URL] = addresses.platform.moduleRegistry.url;\n\n // -- Platform security\n env[PlatformSecurityEnvKeys.PLATFORM_APPS_MANAGER_PRIVATE_KEY] = credentials.platform.appsManager.privateKey;\n env[PlatformSecurityEnvKeys.PLATFORM_APPS_MANAGER_PUBLIC_KEY] = credentials.platform.appsManager.publicKey;\n // #2921 — the CURRENT response key's private half: apps-manager signs every answer to an application runtime with it.\n // The next key's private half stays in secrets.json until a rotation promotes it.\n env[PlatformSecurityEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_SIGNING_PRIVATE_KEY] = requireAppsManagerResponseSigning(credentials).privateKey;\n // #2891 — the key-encryption root, apps-manager only: every LOCAL private key is sealed under it. The previous root\n // rides along only between a rotation and the re-seal that retires it.\n const keyEncryptionRoot = requireKeyEncryptionRoot(credentials);\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_ENCRYPTION_ROOT] = keyEncryptionRoot.current;\n if (keyEncryptionRoot.previous && keyEncryptionRoot.previous !== keyEncryptionRoot.current) {\n env[PlatformSecurityEnvKeys.PLATFORM_KEY_ENCRYPTION_PREVIOUS_ROOT] = keyEncryptionRoot.previous;\n }\n // The public set every runtime verifies against. apps-manager checks at startup that its signing key is in it, so a\n // mismatch is refused there rather than by every runtime; the compose runtimes also interpolate it from this env.\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n // The crontabs-batches-manager P2P signing keypair — apps-manager-env ONLY (the authority): it\n // imports this keypair at INIT (platform-owned setup material, NOT generated), serves the PRIVATE\n // half to crontabs (which signs every SCHEDULED_CRON / MINION_TICK tick) and distributes the PUBLIC\n // half into every app's verify slot. Both halves stay confined to this authority env; other services\n // never receive the private key. Fail-loud if absent (a secrets.json predating the scheduled-cron JWT\n // fix) — a silent empty key here is exactly what dead-lettered every tick.\n if (!credentials.platform.crontabsBatchesManager) {\n throw new Error(\n 'secrets.platform.crontabsBatchesManager is missing — the crontabs P2P signing keypair was never minted ' +\n '(secrets.json predates the scheduled-cron JWT fix). Re-run `wildo setup` or inject the keypair; without it ' +\n 'every SCHEDULED_CRON / MINION_TICK job dead-letters (apps receive an empty crontabs verify key).',\n );\n }\n env[PlatformSecurityEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_PRIVATE_KEY] = credentials.platform.crontabsBatchesManager.privateKey;\n env[PlatformSecurityEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_PUBLIC_KEY] = credentials.platform.crontabsBatchesManager.publicKey;\n env[PlatformSecurityEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] = credentials.platform.primarySecret;\n env[PlatformSecurityEnvKeys.PLATFORM_ADMIN_SECRET] = credentials.platform.adminSecret;\n\n // -- PostgreSQL\n if (postgresql) {\n env[PlatformInfrastructureEnvKeys.PG_HOST] = postgresql.host;\n env[PlatformInfrastructureEnvKeys.PG_PORT] = String(postgresql.port);\n env[PlatformInfrastructureEnvKeys.PG_ADMIN_USER] = credentials.postgresql.adminUser;\n env[PlatformInfrastructureEnvKeys.PG_ADMIN_PASSWORD] = credentials.postgresql.adminPassword;\n /**\n * The MAINTENANCE database, never `infrastructure.postgresql.database`. This key addresses\n * where the admin pool CONNECTS to run `CREATE DATABASE` / `CREATE ROLE`; the application's\n * database is a THING IT PROVISIONS, and dialling it made admin init fail on any machine\n * where it did not exist yet — silently, because the caller records `postgresql: 'failed'`\n * and continues behind a 200 `/health/ready`. The container's initdb database is a different\n * key entirely (`POSTGRES_ADMIN_DATABASE`, emitted by `buildInfraCredentialEnv`), so nothing\n * here was ever serving that meaning. Full contract on the constant.\n */\n env[PlatformInfrastructureEnvKeys.PG_ADMIN_DATABASE] = PLATFORM_POSTGRES_MAINTENANCE_DATABASE;\n env[PlatformInfrastructureEnvKeys.PG_SSL_MODE] = config.infrastructure.postgresql.sslMode;\n }\n\n // -- immudb (#1696): the self-hosted audit store's sysadmin, for apps-manager ONLY. apps-manager logs in with it\n // to give each application its own database and `READ_WRITE` user (`immudb-self` infra module); no other\n // platform service and no application runtime is handed it, and `resolveForbiddenPlatformCredentials` refuses\n // it in any application-tier env. Emitted exactly when this environment self-hosts immudb: that is what makes\n // apps-manager HOLD the `IMMUDB_SELF` admin client, so a platform with no self-hosted immudb refuses an\n // application declaring one instead of pointing at a server it does not run. A secrets.json without the\n // material (CI-reconstructed before it existed) emits nothing, which refuses the same way.\n const immudb = EnvironmentLifecycle.selfHostsBackingService(environment, BackingServiceKind.IMMUDB)\n ? addresses.infra.immudb\n : null;\n const immudbAdminPassword = credentials.immudb?.adminPassword;\n if (immudb && immudbAdminPassword) {\n env[PlatformInfrastructureEnvKeys.IMMUDB_ADMIN_HOST] = immudb.host;\n env[PlatformInfrastructureEnvKeys.IMMUDB_ADMIN_PORT] = String(immudb.port);\n env[PlatformInfrastructureEnvKeys.IMMUDB_ADMIN_PASSWORD] = immudbAdminPassword;\n }\n\n // -- The platform's Vault (#2933): where apps-manager keeps the keys it holds for applications, and the two tokens\n // it speaks there with. apps-manager's alone, like the immudb sysadmin above.\n emitPlatformKeyVaultEnv(env, credentials, addresses, environment);\n // -- The platform's cloud KMS accounts (#2896): identities and locations, no secret.\n emitPlatformCloudKmsEnv(env, environment);\n // -- The platform's dedicated HSM (#2934): the module, the token, and the operator-typed PIN.\n emitPlatformPkcs11Env(env, credentials, environment);\n\n // Admin bootstrap identity is only needed on flows that intentionally seed\n // the first platform admin. K8s steady-state manifests should not keep these\n // values in envFrom after INIT mode completes.\n if (options.includeBootstrapAdminCredentials !== false) {\n env[PlatformAdminEnvKeys.ADMIN_EMAIL] = credentials.admin.email;\n env[PlatformAdminEnvKeys.ADMIN_PASSWORD] = credentials.admin.password;\n env[PlatformAdminEnvKeys.ADMIN_FIRST_NAME] = credentials.admin.firstName;\n env[PlatformAdminEnvKeys.ADMIN_LAST_NAME] = credentials.admin.lastName;\n\n /*\n * The SECOND administrator, who approves an application-wide access grant (#575).\n *\n * Conditional because `approver` is `.optional()` on the secrets schema — an environment whose\n * `secrets.json` predates it still parses, and must still boot. INIT reads the absence as a\n * WARNING rather than a refusal for the same reason, so emitting nothing here is a supported\n * state and not a silent hole.\n *\n * Emitted beside the first administrator rather than in a block of its own, deliberately: this\n * mapping is hand-written once per deployment lane and the kubernetes lane's copy already\n * drifted from this one by two keys. Keeping the two identities adjacent is what makes the next\n * reader notice there are two lanes to update, not one.\n */\n if (credentials.approver) {\n env[PlatformAdminEnvKeys.APPROVER_EMAIL] = credentials.approver.email;\n env[PlatformAdminEnvKeys.APPROVER_PASSWORD] = credentials.approver.password;\n env[PlatformAdminEnvKeys.APPROVER_FIRST_NAME] = credentials.approver.firstName;\n env[PlatformAdminEnvKeys.APPROVER_LAST_NAME] = credentials.approver.lastName;\n }\n }\n\n // -- K8s\n const kubernetes = resolveKubernetesEnvVars(environment);\n setIfDefined(env, PlatformKubernetesEnvKeys.K8S_NAMESPACE, kubernetes?.namespace);\n\n // -- Public domain (runtime-agnostic — emitted for both K8s and Compose)\n env[PlatformIngressEnvKeys.WILDO_PUBLIC_DOMAIN] = environment.publicDomain;\n\n // -- Per-service subdomain map (serviceHosts) — lets apps-manager resolve\n // each customer-app service's public host from the operator's authored\n // subdomains (serviceHosts-driven ingress). Emitted only when authored.\n if (environment.serviceHosts && Object.keys(environment.serviceHosts).length > 0) {\n env[PlatformIngressEnvKeys.WILDO_SERVICE_HOSTS] = JSON.stringify(environment.serviceHosts);\n }\n\n // -- Logging posture (authored on infra config; LoggerService reads at boot)\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n\n // -- OTLP telemetry posture (Slice 2 Phase 5b — platform-host spread). The auth header is\n // resolved provider-agnostically from the platform's `providerEnv` (audit A-9): emitted in\n // PROD when a telemetry-provider token is provisioned for the platform, omitted for the\n // localhost dev collector (no token → no auth; telemetry still flows unauthenticated).\n emitObservabilityEnv(\n env,\n config.observability,\n {\n serviceName: amCatalog.serviceEnvVarName,\n environment: resolveApplicationEnv(environment, config),\n version: options.serviceVersion,\n },\n // Platform tier: entitled to every provider secret by deliberate declaration, so the scope\n // subtracts nothing here. Routed through `resolveRuntimeProviderEnv` anyway — #360 asks\n // that the telemetry header have ONE input shape across all five call sites, so that the\n // application-tier sites are not the only ones a reader has to check.\n { providerEnv: resolveRuntimeProviderEnv(credentials, platformTierAllProvidersScope()) },\n );\n\n // -- Optional GitHub\n if (credentials.github) {\n setIfDefined(env, PlatformAdminEnvKeys.GITHUB_WILDO_APPS_DEFAULT_ORG_URL, credentials.github.orgUrl);\n setIfDefined(env, PlatformAdminEnvKeys.GITHUB_WILDO_APPS_ADMIN_USER, credentials.github.adminUser);\n setIfDefined(env, PlatformAdminEnvKeys.GITHUB_WILDO_APPS_ADMIN_TOKEN, credentials.github.adminToken);\n }\n\n return env;\n }\n\n /**\n * Bootstrap env for non-apps-manager platform services.\n *\n * All platform service URLs and infrastructure addresses are sourced from env\n * vars. Services fetch only jwtPublicKeys + secrets from apps-manager.\n */\n static buildBootstrapEnv(\n service: BootstrapPlatformService,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n /** The bootstrap host's own `package.json` version → OTel `service.version` (audit A-10 parity). */\n serviceVersion?: string,\n ): Record<string, string> {\n assertSupportedStorageConfig(config);\n\n const env: Record<string, string> = {};\n\n const svcCatalog = PLATFORM_SERVICE_CATALOG[service];\n env[PlatformProcessEnvKeys.HOST] = LISTEN_HOST;\n env[svcCatalog.portEnvVarName] = String(svcCatalog.defaultPort);\n env[PlatformProcessEnvKeys.SERVICE_NAME] = svcCatalog.serviceEnvVarName;\n env[PlatformProcessEnvKeys.PLATFORM_ENVIRONMENT_ID] = environment.name;\n env[PlatformProcessEnvKeys.APPLICATION_ENV] = resolveApplicationEnv(environment, config);\n env[PlatformSecurityEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] = credentials.platform.primarySecret;\n // #2898 — a platform service verifies apps-manager's answers against the response key set; it no longer needs\n // apps-manager's P2P public key, which it only ever used for a response check that failed open.\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n\n // -- Platform service URLs (all services get all URLs for inter-service communication)\n env[PlatformServiceUrlEnvKeys.PLATFORM_APPS_MANAGER_URL] = addresses.platform.appsManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_URL] = addresses.platform.crontabsBatchesManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_MODULE_REGISTRY_URL] = addresses.platform.moduleRegistry.url;\n\n // -- Storage (MinIO) — the ADDRESS only. Both bootstrap services run backend-lib's file storage, and\n // both obtain short-lived, prefix-confined STS sessions from apps-manager\n // (`createPlatformServiceStsStorageCredentialResolver`, bound in each service's container, with\n // deliberately no env fallback).\n //\n // ⚠️ STORAGE_ACCESS_KEY / STORAGE_SECRET_KEY are deliberately ABSENT (#1761). They are the object\n // store's ROOT credential, and they were emitted here and never read: a compromise of the module\n // registry or the crontabs manager yielded the root of the whole storage plane for nothing. Only\n // apps-manager, the STS issuer, holds them (`buildAppsManagerFullEnv`).\n const minio = requireAddress(addresses.infra.minio, 'minio');\n env[PlatformInfrastructureEnvKeys.STORAGE_PROVIDER] = config.infrastructure.storage.provider;\n env[PlatformInfrastructureEnvKeys.STORAGE_ENDPOINT] = minio.host;\n env[PlatformInfrastructureEnvKeys.STORAGE_PORT] = String(minio.port);\n env[PlatformInfrastructureEnvKeys.STORAGE_USE_SSL] = String(config.infrastructure.storage.useSsl);\n // The platform bucket (#1112), the same value apps-manager's env carries — see `buildAppsManagerFullEnv`.\n env[PlatformInfrastructureEnvKeys.STORAGE_BUCKET] = resolvePlatformObjectStorageBucket(config.platformStorage);\n\n // -- Logging posture (authored on infra config; LoggerService reads at boot)\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n\n // -- OTLP telemetry posture (Slice 2 Phase 5b — platform-host spread; covers crontabs-batches-\n // manager + module-registry). Auth header resolved provider-agnostically from the platform's\n // `providerEnv` (audit A-9) — emitted in prod when a token is provisioned, omitted for the\n // localhost dev collector.\n emitObservabilityEnv(\n env,\n config.observability,\n {\n serviceName: svcCatalog.serviceEnvVarName,\n environment: resolveApplicationEnv(environment, config),\n version: serviceVersion,\n },\n // Platform tier — see the apps-manager site above for why this is routed through the scope\n // resolver even though `PLATFORM_TIER_ALL_PROVIDERS` subtracts nothing.\n { providerEnv: resolveRuntimeProviderEnv(credentials, platformTierAllProvidersScope()) },\n );\n\n // -- MongoDB connection — among the bootstrap services, ONLY module-registry rides the framework's\n // `StartApplicationBackendService`, which opens the PLATFORM_MANAGEMENT connection from\n // `MONGO_CONNECT_URL`. `crontabs-batches-manager` uses a custom two-phase startup that bridges\n // platform config for its Mongo access and never reads this var, so the emission is scoped to it.\n if (service === PlatformWildoServices.MODULE_REGISTRY) {\n emitPlatformMongoEnv(env, credentials, addresses, config, environment);\n // The platform's OWN PostgreSQL (D7/5.6): module-registry now carries the same\n // pre-connect + construction-time-adapter wiring as apps-manager, and BOTH must derive the\n // store from the same env truth — the whole point is that a flipped platform cannot split\n // a shared resource across services.\n emitPlatformPostgresEnv(env, credentials, addresses, config, environment);\n }\n\n // -- Per-service infra addresses + extras\n PlatformEnvVarsBuilder.addServiceExtras(service, env, credentials, addresses, config);\n\n return env;\n }\n\n /**\n * Build the local companion API env from platform-focused runtime material.\n *\n * The companion API is not an application backend anymore from an env-contract\n * perspective: it connects to the platform management database and backing\n * services, while still receiving the authored application runtime topology so\n * companion services can reason about the local app surfaces.\n */\n static buildCompanionPlatformEnv(\n bootstrapCredentials: AppBootstrapCredentials,\n serviceName: string,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environment: PlatformEnvironmentConfiguration,\n options?: {\n runtimeEndpoints?: Record<string, { publicUrl: string; internalUrl: string }>;\n host?: string;\n port?: number;\n /**\n * Selected `OBSERVABILITY_TELEMETRY` provider ref (Slice 2 Phase 5b) — resolved by the\n * caller from the `saasConfig` selection. `emitObservabilityEnv` uses it to derive the\n * OTLP auth header from the provider's secret token. Omitted = no-auth export.\n */\n observabilityProviderRef?: string;\n /**\n * Service version (Slice 2 A-10) — the companion host's `package.json` version, emitted as\n * the OTel `service.version` resource attribute. Threaded by the env-gen from the companion's\n * own `relativeDir` so traces/metrics/logs carry the running build version.\n */\n serviceVersion?: string;\n },\n ): Record<string, string> {\n assertSupportedStorageConfig(config);\n\n const env: Record<string, string> = {};\n\n env[ApplicationBackendBootstrapEnvKeys.APPLICATION_ID] = bootstrapCredentials.APPLICATION_ID;\n env[PlatformProcessEnvKeys.HOST] = options?.host ?? LISTEN_HOST;\n env[PlatformProcessEnvKeys.PORT] = String(options?.port ?? 4341);\n env[PlatformProcessEnvKeys.SERVICE_NAME] = serviceName;\n env[PlatformProcessEnvKeys.PLATFORM_ENVIRONMENT_ID] = environment.name;\n env[PlatformProcessEnvKeys.APPLICATION_ENV] =\n bootstrapCredentials.APPLICATION_ENV ?? resolveApplicationEnv(environment, config);\n // #1177 — the application this process belongs to. `SERVICE_NAME` names the PROCESS, so a logger\n // with no configuration yet could name neither the application nor the environment.\n env[PlatformProcessEnvKeys.APPLICATION_SLUG] = bootstrapCredentials.APPLICATION_SLUG;\n env[PlatformSecurityEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] =\n bootstrapCredentials.PLATFORM_APPLICATION_PRIMARY_SECRET;\n // #2898 — the companion verifies apps-manager's answers with the response key set (emitted below with the other\n // runtime bootstrap keys); apps-manager's P2P public key was required here and read by nothing.\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n /*\n * The RESOLVER, not the credential echo — the same source its two siblings below already use.\n *\n * `bootstrapCredentials.PLATFORM_APPS_MANAGER_URL` is apps-manager reporting its OWN address,\n * which is correct only when the reader shares its network. In framework-developer mode\n * apps-manager runs natively beside the application, so it reports `localhost:5151` and this\n * was invisible. In app-creator mode apps-manager is a CONTAINER: it reports its\n * container-internal address, and the application backend — which `wildo local dev` runs on the\n * HOST — died at startup with\n * Failed to load platform managed secrets: getaddrinfo ENOTFOUND platform-apps-manager-internal\n * while `REDIS_HOST` and `RABBITMQ_HOST` in the very same file were correctly `localhost`.\n * Measured 2026-09-11, on the first app-creator run that got far enough to write this file at all.\n *\n * `addresses.platform.*` is perspective-aware by construction (HOST_FACING → localhost + the\n * published port; CONTAINER_INTERNAL → the data-network alias), which is exactly the question\n * being asked here. Two of these three keys already trusted it; the third now does too.\n */\n env[PlatformServiceUrlEnvKeys.PLATFORM_APPS_MANAGER_URL] = addresses.platform.appsManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_URL] =\n addresses.platform.crontabsBatchesManager.url;\n env[PlatformServiceUrlEnvKeys.PLATFORM_MODULE_REGISTRY_URL] = addresses.platform.moduleRegistry.url;\n\n emitPlatformMongoEnv(env, credentials, addresses, config, environment);\n // The PostgreSQL mirror, and a NO-OP on a Mongo-engined platform (neither key is written,\n // so existing companion `.env` material is byte-identical). See the emitter's header for\n // why the companion became a caller only once its startup could honor these keys.\n emitPlatformPostgresEnv(env, credentials, addresses, config, environment);\n\n const valkey = requireAddress(addresses.infra.valkey, 'valkey');\n const rabbitmq = requireAddress(addresses.infra.rabbitmq, 'rabbitmq');\n const rabbitmqMgmt = requireAddress(addresses.infra.rabbitmqManagement, 'rabbitmqManagement');\n const minio = requireAddress(addresses.infra.minio, 'minio');\n\n /**\n * The APPLICATION's PostgreSQL topology — address only, and the companion needs it for a reason\n * that is easy to miss: it is not an application backend from an env-contract perspective (see\n * this method's header), but it DOES load the application's resource registry, and that registry\n * refuses to initialize when a resource declares `persistenceAdapter: 'postgresql'` while\n * `database.postgresql` is absent.\n *\n * The loader builds that branch only when a HOST arrives, so a companion that never received one\n * had `postgresql.enabled === false` by construction and rejected the resource with\n * \"PostgreSQL is not enabled in database config\" — a runtime enforcing an adapter constraint\n * against topology it was never given. Measured 2026-08-27: the backend and the minions booted\n * the same registry fine; only the companion crash-looped, which is exactly how a per-runtime env\n * gap presents.\n *\n * Emitted under the APPLICATION-backend keys, not the platform ones, because that is the contract\n * the app-configuration loader reads. Credentials stay out: they travel through\n * `secrets.database.postgresql`, as MongoDB's do. Address makes the adapter REACHABLE; it does\n * not make it SELECTED — selection remains `DATABASE_DEFAULT_ADAPTER`, per the rule stated at the\n * application-backend block.\n */\n const companionPostgresql = addresses.infra.postgresql;\n if (companionPostgresql) {\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_HOST] = companionPostgresql.host;\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_PORT] = String(companionPostgresql.port);\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.POSTGRESQL_DATABASE,\n config.backingServices?.[BackingServiceKind.POSTGRESQL]?.database,\n );\n }\n\n env[PlatformInfrastructureEnvKeys.REDIS_HOST] = valkey.host;\n env[PlatformInfrastructureEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n if (credentials.valkey) {\n env[PlatformInfrastructureEnvKeys.REDIS_ADMIN_USER] = credentials.valkey.adminUser;\n env[PlatformInfrastructureEnvKeys.REDIS_ADMIN_PASSWORD] = credentials.valkey.adminPassword;\n }\n\n env[PlatformInfrastructureEnvKeys.RABBITMQ_HOST] = rabbitmq.host;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_PORT] = String(rabbitmq.port);\n env[PlatformInfrastructureEnvKeys.RABBITMQ_MANAGEMENT_PORT] = String(rabbitmqMgmt.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.RABBITMQ_VHOST,\n resolveApplicationBackingServiceAddressing(config).rabbitmqVhost,\n );\n env[PlatformInfrastructureEnvKeys.RABBITMQ_ADMIN_USERNAME] = credentials.rabbitmq.adminUsername;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_ADMIN_PASSWORD] = credentials.rabbitmq.adminPassword;\n\n // -- Storage: TOPOLOGY only. The ROOT credential is deliberately ABSENT.\n //\n // The companion is platform-tier for Mongo/Redis/RabbitMQ — it is a local admin\n // tool and legitimately holds those. For STORAGE it is not: it runs the same\n // app-tier `WildoManagedStorageProvider` as backend-api (through\n // `FileStorageRouterBackendService`) and holds the full four-var bootstrap\n // contract, so it fetches short-lived, prefix-confined STS sessions exactly as\n // an application does.\n //\n // So this is not a tier judgment — the pair was emitted and NEVER READ. Its only\n // effect was to keep the object store's root credential in a `.env` on a\n // developer's disk for the lifetime of the dev stack. Measured before removal:\n // the companion source referenced `STORAGE_ACCESS_KEY` / `STORAGE_SECRET_KEY`\n // in its env SCHEMA and nowhere else.\n env[PlatformInfrastructureEnvKeys.STORAGE_PROVIDER] = config.infrastructure.storage.provider;\n env[PlatformInfrastructureEnvKeys.STORAGE_ENDPOINT] = minio.host;\n env[PlatformInfrastructureEnvKeys.STORAGE_PORT] = String(minio.port);\n env[PlatformInfrastructureEnvKeys.STORAGE_USE_SSL] = String(config.infrastructure.storage.useSsl);\n env[PlatformInfrastructureEnvKeys.STORAGE_BUCKET] = resolveApplicationBackingServiceAddressing(config).objectStorageBucket;\n\n // -- Logging posture (authored on infra config; LoggerService reads at boot)\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n\n // -- OTLP telemetry posture (Slice 2 Phase 5 — projected to OTEL_*, read by the preload).\n // Audit A-16: `bootstrapCredentials.APPLICATION_ENV` is the companion's environment source\n // (it's `resolveApplicationEnv`-derived and reliably set by the bootstrap pipeline). The\n // backend's `options.applicationEnv` override is not plumbed to the companion options — a\n // low-priority consistency gap, not a missing-env risk.\n //\n // The telemetry header and the provider fan-out below read the SAME resolved bag (#360):\n // one value per builder, so the two delivery paths cannot come to disagree about what this\n // runtime is entitled to. Platform tier, so nothing is subtracted.\n const companionProviderEnv = resolveRuntimeProviderEnv(credentials, platformTierAllProvidersScope());\n emitObservabilityEnv(\n env,\n config.observability,\n { serviceName, environment: bootstrapCredentials.APPLICATION_ENV, version: options?.serviceVersion },\n { ref: options?.observabilityProviderRef, providerEnv: companionProviderEnv },\n );\n\n const runtimeEndpoints = options?.runtimeEndpoints;\n if (runtimeEndpoints && Object.keys(runtimeEndpoints).length > 0) {\n const preservedCompanionEndpoint = runtimeEndpoints[serviceName];\n env[ApplicationBackendRuntimeEnvKeys.APPLICATION_RUNTIME_ENDPOINTS] =\n serializeRuntimeEndpointsRecord({\n ...runtimeEndpoints,\n [PlatformRuntimeEndpointKey.PLATFORM_APPS_MANAGER]: {\n publicUrl: addresses.platform.appsManager.url,\n internalUrl: addresses.platform.appsManager.url,\n },\n [PlatformRuntimeEndpointKey.PLATFORM_CRONTABS_BATCHES_MANAGER]: {\n publicUrl: addresses.platform.crontabsBatchesManager.url,\n internalUrl: addresses.platform.crontabsBatchesManager.url,\n },\n appsManager: {\n publicUrl: addresses.platform.appsManager.url,\n internalUrl: addresses.platform.appsManager.url,\n },\n crontabsBatchesManager: {\n publicUrl: addresses.platform.crontabsBatchesManager.url,\n internalUrl: addresses.platform.crontabsBatchesManager.url,\n },\n [serviceName]: {\n publicUrl: preservedCompanionEndpoint?.publicUrl ?? `http://localhost:${options?.port ?? 4341}`,\n internalUrl: preservedCompanionEndpoint?.internalUrl ?? `http://localhost:${options?.port ?? 4341}`,\n },\n });\n }\n\n // Platform tier: the companion is a declared platform-admin consumer and\n // mirrors the full provider surface for local tooling. Same bag the telemetry\n // header above resolved.\n for (const [envVarName, value] of Object.entries(companionProviderEnv)) {\n setIfDefined(env, envVarName, value);\n }\n\n return env;\n }\n\n /**\n * Build env vars for application backend services (e.g., wonder-todos backend-api).\n *\n * Application backends get their infra addresses and platform URLs from env\n * vars. Only jwtPublicKeys + secrets are fetched from apps-manager at startup.\n */\n static buildApplicationBackendEnv(\n bootstrapCredentials: AppBootstrapCredentials,\n serviceName: string,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environmentId: string,\n /**\n * What this runtime is entitled to. REQUIRED and positional — deliberately not a field on\n * `options` below, because an optional field is bypassable by omission and this decision must\n * not be. A new call site that does not decide does not compile.\n *\n * Application-tier callers pass `declaredProviderScope(refs)` with the refs authored under\n * `providers.scopes.{backend,workers.<name>,minions.<name>}.providers`. A caller that\n * legitimately needs the full provider surface is platform-tier and should not be using this\n * builder at all — `platformTierAllProvidersScope()` exists for those, and is unreachable from\n * here by construction of the call graph, not by convention.\n */\n providerScope: RuntimeProviderScope,\n options: {\n /** The app's release version (the host's package.json `version`), projected as\n * `service.version` in `OTEL_RESOURCE_ATTRIBUTES` (audit A-10). Omitted when absent. */\n serviceVersion?: string;\n appDatabaseName?: string;\n /**\n * WHICH backing services this runtime may reach (Step 5-egress / R-COHERENCE).\n *\n * Omitted means \"the application backend\" — which is what this builder is\n * NAMED for, not a permissive default. It is still derived from\n * `resolveRuntimeBackingServiceAccess` rather than written as a literal, so\n * there is exactly one description of what a backend may reach.\n *\n * A runtime kept OUT of a backing service's network must not receive that\n * service's topology either. Emitting it anyway makes `isConfigured()` true,\n * a probe or a first use runs, and an unroutable host fails as a timeout for\n * a runtime that was never supposed to have the service at all — which reads\n * as \"service down\" rather than \"not mine\". The two must derive from ONE\n * declaration, and this is how that reaches env generation.\n */\n runtimeAccess?: RuntimeBackingServiceAccess;\n /**\n * Authored `wildo.saas.config.dataServices.redis.keyPrefix` (Slice 3.6).\n * When provided, projected as `REDIS_KEY_PREFIX` in the generated\n * `.env`. Consumed at runtime by `RedisService` as the canonical\n * app-level key namespace (replaces the legacy username-derived\n * prefix). Omitted when undefined.\n */\n redisKeyPrefix?: string;\n /**\n * Authored `wildo.saas.config.dataServices.s3.bucketPrefix` (Slice\n * 3.6). When provided, projected as `STORAGE_BUCKET_PREFIX` in the\n * generated `.env`. Consumed at runtime by\n * `WildoManagedStorageProvider` and prepended to every application\n * object key. The actual MinIO bucket name (`STORAGE_BUCKET`) is\n * unaffected. Omitted when undefined.\n */\n storageBucketPrefix?: string;\n applicationEnv?: string;\n /** Canonical local/remote topology from the selected infra environment; never infer it from APPLICATION_ENV or the environment id. */\n deploymentLocationType: WildoLocationType;\n /** Exact shared runtime-signals home. Configure only for a local host lane where backend and companion see the same filesystem. */\n runtimeSignalsHome?: string;\n runtimeEndpoints?: Record<string, { publicUrl: string; internalUrl: string }>;\n mongodbDirectConnection?: boolean;\n /**\n * Selected `OBSERVABILITY_TELEMETRY` provider ref (Slice 2 Phase 5b) — resolved by the\n * caller from the `saasConfig` backend-scope selection; `emitObservabilityEnv` uses it to\n * derive the OTLP auth header from the provider's secret token. Omitted = no-auth export.\n */\n observabilityProviderRef?: string;\n /**\n * Backend→worker dispatch URLs (G-8 / MW4), keyed by the worker's\n * `wildo.saas.config.ts` bucket name. Each entry is emitted as\n * `WILDO_WORKER_<NAME>_URL` so the backend's `WorkerRemoteClientFactory`\n * can reach the worker's per-app k8s Service. Computed remote-only by\n * `buildApplicationBackendTargets`; omitted for local (no k8s Services).\n */\n workerUrls?: Record<string, string>;\n /**\n * The address this backend's HTTP server listens on, emitted as `HOST` (which overrides the host of its own\n * runtime endpoint). Set by the native LOCAL lane only (`LOCAL_APPLICATION_BACKEND_LISTEN_HOST`, #3382);\n * a containerised backend listens on whatever its container gives it and receives none.\n */\n listenHost?: string;\n /**\n * The host's Docker bridge gateway, emitted as `CONTAINER_HOST_GATEWAY_LISTEN_HOST`: a second address the HTTP\n * server accepts connections on, so a compose minion or worker on Docker Engine for Linux reaches this host-run\n * backend through `host.docker.internal` (#3387). Set by the native LOCAL lane only, and only when\n * `resolveContainerHostGatewayListenHost` found the gateway on an interface of this host; never with a containerised\n * backend, which is reached by its service name.\n */\n containerHostGatewayListenHost?: string;\n },\n ): Record<string, string> {\n if (options.runtimeSignalsHome !== undefined && options.deploymentLocationType !== WildoLocationType.LOCAL) {\n throw new Error('APPLICATION_RUNTIME_SIGNALS_HOME can only be emitted for explicit local deployment topology');\n }\n const env: Record<string, string> = {};\n\n // -- Bootstrap identity\n env[ApplicationBackendBootstrapEnvKeys.APPLICATION_ID] = bootstrapCredentials.APPLICATION_ID;\n env[ApplicationBackendBootstrapEnvKeys.SERVICE_NAME] = serviceName;\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_ENVIRONMENT_ID] = environmentId;\n env[ApplicationBackendBootstrapEnvKeys.DEPLOYMENT_LOCATION_TYPE] = options.deploymentLocationType;\n /*\n * #2303 — the environment's service profile, so the application's boot can refuse a capability whose service\n * the profile omits and say why. Emitted only for a non-default profile: absence means FULL on both sides, so an\n * environment that never declared one keeps a byte-identical env file. Minions inherit it through the\n * delegation in `buildApplicationMinionEnv`, and their boot asserts the same refusals.\n */\n const serviceProfile = config.serviceProfile ?? DEFAULT_ENVIRONMENT_SERVICE_PROFILE;\n if (serviceProfile !== DEFAULT_ENVIRONMENT_SERVICE_PROFILE) {\n env[ApplicationBackendBootstrapEnvKeys.ENVIRONMENT_SERVICE_PROFILE] = serviceProfile;\n }\n if (options.listenHost !== undefined) {\n env[PlatformProcessEnvKeys.HOST] = options.listenHost;\n }\n if (options.containerHostGatewayListenHost !== undefined) {\n if (options.listenHost === undefined) {\n // The second listener exists beside an explicit loopback bind; without one it would describe nothing coherent.\n throw new Error('containerHostGatewayListenHost is emitted only beside an explicit listenHost (the native LOCAL lane, #3387)');\n }\n env[HttpServerEnvKey.CONTAINER_HOST_GATEWAY_LISTEN_HOST] = options.containerHostGatewayListenHost;\n }\n /*\n * -- The reverse proxies in front of this backend (#1788)\n *\n * Every remote application lane fronts the backend with exactly one Traefik: the cluster ingress in the\n * Kubernetes lane, the TLS-terminating edge in the remote compose lane. Without this the engine trusted\n * no proxy, `req.ip` was Traefik's address for every caller, and every per-IP lockout and rate limit\n * became one shared bucket. A local backend is reached directly and gets nothing: zero hops is the\n * engine's default, and a trusted hop that is not there would let a client pick its own address.\n *\n * Only APPLICATION backends: the platform services have no ingress in any lane and are reached\n * cluster-internally, so trusting a hop there would be exactly that spoofable case.\n */\n const trustedProxyHops = trustedProxyHopsForApplicationBackend(options.deploymentLocationType);\n if (trustedProxyHops > 0) {\n env[HttpServerEnvKey.HTTP_TRUSTED_PROXY_HOPS] = String(trustedProxyHops);\n }\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] =\n bootstrapCredentials.PLATFORM_APPLICATION_PRIMARY_SECRET;\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_URL] =\n addresses.platform.appsManager.url;\n env[ApplicationBackendBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n env[ApplicationBackendBootstrapEnvKeys.APPLICATION_ENV] =\n options?.applicationEnv ?? bootstrapCredentials.APPLICATION_ENV;\n // #1177 — see the companion builder above.\n env[PlatformProcessEnvKeys.APPLICATION_SLUG] = bootstrapCredentials.APPLICATION_SLUG;\n\n /*\n * -- The application's OWN operator-door secret (#586)\n *\n * `credentials.application.adminSecret`, NOT anything under `credentials.platform`: this is the\n * one admin secret that must reach an application runtime, and the confinement guard below\n * (`assertNoPlatformCredentialInGeneratedEnv`) refuses every platform-tier credential in an\n * application-tier env. Filing it on the platform tier would have made it unemittable by the\n * guard that exists to protect this boundary.\n *\n * Emitted only when PRESENT. Absence is a working state with a defined meaning — both consuming\n * controllers answer `503 INFRASTRUCTURE` on an unset value, deliberately — so a `secrets.json`\n * predating this key yields an app that boots and simply has no operator doors, rather than one\n * that fails to render its env. The idempotent self-heal mints it on the next command.\n */\n if (credentials.application?.adminSecret) {\n env[ApplicationBackendRuntimeEnvKeys.APPLICATION_ADMIN_SECRET] = credentials.application.adminSecret;\n }\n\n // -- Platform service URLs\n env[ApplicationBackendPlatformUrlEnvKeys.PLATFORM_CRONTABS_BATCHES_MANAGER_URL] =\n addresses.platform.crontabsBatchesManager.url;\n env[ApplicationBackendPlatformUrlEnvKeys.PLATFORM_MODULE_REGISTRY_URL] =\n addresses.platform.moduleRegistry.url;\n\n // -- App runtime topology (local/backend bootstrap derived)\n const runtimeEndpoints = options?.runtimeEndpoints;\n if (runtimeEndpoints && Object.keys(runtimeEndpoints).length > 0) {\n env[ApplicationBackendRuntimeEnvKeys.APPLICATION_RUNTIME_ENDPOINTS] =\n serializeRuntimeEndpointsRecord(runtimeEndpoints);\n }\n setIfDefined(env, ApplicationBackendRuntimeEnvKeys.APPLICATION_RUNTIME_SIGNALS_HOME, options.runtimeSignalsHome);\n\n // -- Backend→worker dispatch URLs (G-8 / MW4). One `WILDO_WORKER_<NAME>_URL`\n // per declared worker so the backend's WorkerRemoteClientFactory can reach\n // each worker's per-app k8s Service. The env-key normalization lives in the\n // shared `wildoWorkerUrlEnvKey` helper that the backend read-side also uses,\n // so emit and read cannot drift.\n const workerUrls = options?.workerUrls;\n if (workerUrls) {\n for (const [workerName, url] of Object.entries(workerUrls)) {\n setIfDefined(env, wildoWorkerUrlEnvKey(workerName), url);\n }\n }\n\n // Which backing services MAY this runtime reach? One source, shared with the\n // network membership of both deployment lanes; the credential mint reaches the\n // same store through the same resolved engine, and a structural test holds the\n // three together (#3367).\n // Bounded by the application's own store (#3367): the topology of the OTHER store is withheld even when the\n // environment provides it, because no credential for it is ever minted to an application runtime.\n const runtimeAccess = options?.runtimeAccess\n ?? resolveRuntimeBackingServiceAccess(\n { kind: ApplicationRuntimePrincipalKind.APPLICATION_BACKEND } as ApplicationRuntimePrincipal,\n undefined,\n { applicationDatabaseEngine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n );\n const mayReach = (capability: InfraCapability): boolean => runtimeAccess.capabilities.has(capability);\n\n // -- Database addresses (same infra, app-specific database name)\n // `environmentProvidesMongoDb`, not merely `addresses.infra.mongodb` — see that helper. An\n // application whose environment renders no mongod must receive NO Mongo address at all, or its\n // backend spends every boot dialling a server that does not exist and fails its readiness gate\n // on a dependency it does not have.\n const mongodb = environmentProvidesMongoDb(config) ? addresses.infra.mongodb : undefined;\n const appMongoDatabase = pickAppMongoDatabase(config.backingServices, options?.appDatabaseName);\n if (mongodb && mayReach(InfraCapability.DOCUMENT_DATABASE)) {\n env[ApplicationBackendDataEnvKeys.MONGODB_HOST] = `${mongodb.host}:${mongodb.port}`;\n env[ApplicationBackendDataEnvKeys.MONGODB_DATABASE] = appMongoDatabase;\n env[ApplicationBackendDataEnvKeys.MONGODB_PROTOCOL] = MongoDBProtocol.MONGODB;\n if (options?.mongodbDirectConnection !== undefined) {\n env[ApplicationBackendDataEnvKeys.MONGODB_DIRECT_CONNECTION] = String(options.mongodbDirectConnection);\n }\n } else if (config.externalEndpoints?.mongodb?.connectionUrl && mayReach(InfraCapability.DOCUMENT_DATABASE)) {\n const atlasMongoEnv = buildMongoEnvFromConnectionUrl(\n config.externalEndpoints.mongodb.connectionUrl,\n appMongoDatabase,\n );\n env[ApplicationBackendDataEnvKeys.MONGODB_HOST] = atlasMongoEnv.host;\n env[ApplicationBackendDataEnvKeys.MONGODB_DATABASE] = atlasMongoEnv.database;\n env[ApplicationBackendDataEnvKeys.MONGODB_PROTOCOL] = atlasMongoEnv.protocol;\n if (atlasMongoEnv.tls !== undefined) {\n env[ApplicationBackendDataEnvKeys.MONGODB_TLS] = String(atlasMongoEnv.tls);\n }\n if (atlasMongoEnv.replicaSet) {\n env[ApplicationBackendDataEnvKeys.MONGODB_REPLICA_SET] = atlasMongoEnv.replicaSet;\n }\n }\n\n /**\n * PostgreSQL TOPOLOGY — emitted when the environment self-hosts or points at one AND it is the application's own\n * store (#3367: `mayReach` is bounded by the engine, so a MongoDB application's runtimes get no PostgreSQL host).\n *\n * ADDRESS ONLY, and the restraint is the point. The loader builds a `database.postgresql` branch\n * only when a host arrives, so these keys are what make the adapter REACHABLE; they do not make\n * it SELECTED. Selection is `DATABASE_DEFAULT_ADAPTER`, whose own contract rejects being derived\n * from key presence — \"which store an application persists to is a deployment decision that must\n * be legible in one place, not an emergent property of which variables happen to be set\". The\n * selection is written below, from the RESOLVED `applicationDatabase` (#1571).\n *\n * Credentials are deliberately absent: they travel through `secrets.database.postgresql`, exactly\n * as MongoDB's do. Env carries where the database is; secrets carry who may open it.\n */\n const postgresql = addresses.infra.postgresql;\n if (postgresql && mayReach(InfraCapability.RELATIONAL_DATABASE)) {\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_HOST] = postgresql.host;\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_PORT] = String(postgresql.port);\n // The app's own database, falling back to the authored backing-service name and then to the\n // Mongo-side app database name — one application, one logical database, whichever store holds it.\n env[ApplicationBackendDataEnvKeys.POSTGRESQL_DATABASE] =\n config.backingServices?.[BackingServiceKind.POSTGRESQL]?.database ?? appMongoDatabase;\n }\n\n /**\n * PostgreSQL SELECTION for the application — a separate decision from the ADDRESS block above.\n *\n * The block above deliberately emits address keys only, on the rule stated beside it: *\"which\n * store an application persists to is a deployment decision that must be legible in one place,\n * not an emergent property of which variables happen to be set\"*. That rule is why selection is\n * NOT derived from the presence of a host, and why it needs an authored source.\n *\n * `applicationDatabase` is that source. Until it existed, the only way to move an application to\n * PostgreSQL was to hand-edit `backend-api/.env` — machine-local, ungitted, and not reproducible\n * on another developer's machine.\n *\n * Emitted for BOTH engines, from `resolveApplicationDatabaseEngine` — so an absent\n * `applicationDatabase` selects PostgreSQL here exactly as it does in apps-manager's provisioning\n * (#1571). Until then only POSTGRESQL was written and MongoDB was left to the env key's own\n * default; that default also governs PLATFORM services, so leaning on it made the application's\n * store a side effect of a platform contract. Now the application never reaches it.\n */\n const applicationEngine = resolveApplicationDatabaseEngine(config.applicationDatabase);\n /*\n * A runtime that may not reach the selected store gets NO selection: it has no database, and a\n * selection naming one would send it looking. Gated on the SAME capability as the address, so the\n * two cannot disagree — the throw below is reserved for a runtime that may reach PostgreSQL and was\n * given no address to reach it at.\n */\n if (applicationEngine === DatabaseEngine.MONGODB && mayReach(InfraCapability.DOCUMENT_DATABASE)) {\n env[ApplicationBackendDataEnvKeys.DATABASE_DEFAULT_ADAPTER] = PersistenceAdapter.MONGODB;\n }\n if (applicationEngine === DatabaseEngine.POSTGRESQL && mayReach(InfraCapability.RELATIONAL_DATABASE)) {\n if (!postgresql) {\n // Asserted rather than emitting a selection whose substrate is unreachable. `defineInfraEnvConfig`\n // already refuses this combination at authoring time, so reaching here means the address\n // resolver and that refinement disagree — a CLI bug, and one that would otherwise surface as\n // the application backend failing to open a connection three layers away.\n throw new Error(\n 'the application persists to PostgreSQL (declared, or selected because applicationDatabase is absent) '\n + 'but no postgresql address resolved for this '\n + 'environment. Declare `backingServices.postgresql` and re-run `wildo config sync`; if it IS '\n + 'declared, this is a CLI bug — report it with the environment name and `wildo.infra.<env>.config.ts`.',\n );\n }\n env[ApplicationBackendDataEnvKeys.DATABASE_DEFAULT_ADAPTER] = PersistenceAdapter.POSTGRESQL;\n }\n\n const valkey = addresses.infra.valkey;\n if (valkey && mayReach(InfraCapability.CACHE_MANAGER)) {\n env[ApplicationBackendDataEnvKeys.REDIS_HOST] = valkey.host;\n env[ApplicationBackendDataEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n }\n // App-level Redis key namespace (Slice 3.6 — sourced from\n // `wildo.saas.config.dataServices.redis.keyPrefix`). Independent of\n // whether a valkey address is wired so future external Redis paths\n // still receive the prefix.\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.REDIS_KEY_PREFIX,\n options?.redisKeyPrefix,\n );\n\n const rabbitmq = addresses.infra.rabbitmq;\n if (rabbitmq && mayReach(InfraCapability.QUEUING_SYSTEM)) {\n env[ApplicationBackendDataEnvKeys.RABBITMQ_HOST] = rabbitmq.host;\n env[ApplicationBackendDataEnvKeys.RABBITMQ_PORT] = String(rabbitmq.port);\n // The SAME derivation apps-manager is sent at registration (#1107), so the vhost this backend\n // connects to is the one its broker principal is granted on.\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.RABBITMQ_VHOST,\n resolveApplicationBackingServiceAddressing(config).rabbitmqVhost,\n );\n }\n\n /**\n * The virus scanner (#1910) — emitted when the environment declares ClamAV, at the address THIS runtime reaches\n * it on. The engine switches scanning on exactly when `CLAMAV_HOST` is present (\"presence of a host IS the\n * opt-in\", `ClamAVScannerBackendService.isConfigured`), so a runtime left without it scans nothing: every upload a\n * field requires scanned, and every attachment a received email carries, ends `scan_failed` and is withheld.\n *\n * Until #1910 nothing emitted it here. The `clamav-self` infra module states `CLAMAV_HOST: 'clamav'`, but only for\n * apps-manager and the companion, and that docker name is unreachable from a host-run process anyway — so a\n * `wildo local dev` backend ran with a healthy `clamav` container beside it and scanned nothing.\n */\n const clamav = config.backingServices?.[BackingServiceKind.CLAMAV] !== undefined ? addresses.infra.clamav : null;\n if (clamav && mayReach(InfraCapability.ANTIVIRUS_SCANNING)) {\n env[ApplicationBackendDataEnvKeys.CLAMAV_HOST] = clamav.host;\n env[ApplicationBackendDataEnvKeys.CLAMAV_PORT] = String(clamav.port);\n }\n\n // -- Storage (MinIO) — backend-lib needs storage access for z_file() operations\n const minio = addresses.infra.minio;\n if (minio && mayReach(InfraCapability.OBJECT_STORAGE)) {\n assertSupportedStorageConfig(config);\n env[ApplicationBackendDataEnvKeys.STORAGE_PROVIDER] = config.infrastructure.storage.provider;\n env[ApplicationBackendDataEnvKeys.STORAGE_ENDPOINT] = minio.host;\n env[ApplicationBackendDataEnvKeys.STORAGE_PORT] = String(minio.port);\n env[ApplicationBackendDataEnvKeys.STORAGE_USE_SSL] = String(config.infrastructure.storage.useSsl);\n // The bucket apps-manager confines this runtime's storage credential to (#1107) — one derivation.\n env[ApplicationBackendDataEnvKeys.STORAGE_BUCKET] = resolveApplicationBackingServiceAddressing(config).objectStorageBucket;\n // ⚠️ STORAGE_ACCESS_KEY / STORAGE_SECRET_KEY are deliberately ABSENT here.\n //\n // Those two values are the object store's ROOT credential — the very same\n // pair assigned to `MINIO_ROOT_USER` / `MINIO_ROOT_PASSWORD` in\n // `buildInfraCredentialEnv` above. Emitting them here handed the root\n // account to every application backend, every minion and every worker,\n // because `buildApplicationMinionEnv` delegates to this builder and the\n // k8s `{appSlug}-secret` is built from its output.\n //\n // Applications now obtain SHORT-LIVED, prefix-confined session credentials\n // from apps-manager at runtime (`GET /apps-to-manager/storage-session-credentials`),\n // so nothing in an application container needs a long-lived storage key.\n // The endpoint/bucket/provider values above are NOT secrets and stay.\n //\n // Do not re-add these \"so local dev works\" — that is the exact regression\n // `assertNoStorageSecretInGeneratedEnv` below exists to catch. If storage\n // fails, the STS route is the thing to fix.\n }\n // App-level object-key namespace prefix (Slice 3.6 — sourced from\n // `wildo.saas.config.dataServices.s3.bucketPrefix`). Independent of\n // whether managed MinIO is wired so future external storage paths\n // still receive the prefix.\n setIfDefined(\n env,\n ApplicationBackendDataEnvKeys.STORAGE_BUCKET_PREFIX,\n options?.storageBucketPrefix,\n );\n\n // -- Logging posture (authored on infra config; LoggerService reads at boot)\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n emitEmailEnv(env, config.email);\n emitAgentContentGuardrailsEnv(env, config.agentContentGuardrails);\n emitOwnershipDnsStandInEnv(env, config.ownershipDnsStandIn);\n\n // -- The runtime's entitled provider bag, resolved ONCE and read by both delivery paths\n // below: the OTLP auth header and the per-key fan-out. Two reads of one value, rather\n // than two derivations that can disagree — which is what #360 was (the header composed\n // from the raw bag while the fan-out was scoped, so a withheld token arrived anyway).\n const scopedProviderEnv = resolveRuntimeProviderEnv(credentials, providerScope);\n\n // -- OTLP telemetry posture (Slice 2 Phase 5 — projected to OTEL_*, read by the preload).\n // A runtime that does not declare the telemetry provider exports UNAUTHENTICATED (the\n // endpoint is still emitted) — see `resolveOtlpAuthHeader` for the decision and its cost.\n emitObservabilityEnv(\n env,\n config.observability,\n { serviceName, environment: options?.applicationEnv ?? bootstrapCredentials.APPLICATION_ENV, version: options?.serviceVersion },\n { ref: options?.observabilityProviderRef, providerEnv: scopedProviderEnv },\n );\n\n // -- Optional protocol-aware provider env bindings\n // Application tier: scoped to the runtime's declared providers. Covers\n // minions too — `buildApplicationMinionEnv` delegates here, and a minion\n // scoped to `openai` must not receive the application's Stripe key.\n for (const [envVarName, value] of Object.entries(scopedProviderEnv)) {\n setIfDefined(env, envVarName, value);\n }\n\n // -- Systems of record (#1055): the addresses this environment authored plus the operator's\n // credentials, both under names DERIVED from the instance name.\n //\n // Emitted HERE even though this builder also serves minions, because the alternative — a\n // flag on `options` — is bypassable by omission, which is exactly what this file refuses for\n // `providerScope`. The narrowing lives at the one delegating caller instead\n // (`buildApplicationMinionEnv`), where it is asserted rather than assumed.\n for (const [envVarName, value] of Object.entries(resolveSystemsOfRecordEnv(config, credentials))) {\n setIfDefined(env, envVarName, value);\n }\n\n // -- Inbound endpoint secrets (#1596): the backend mounts `/webhooks/app/{endpointKey}` and verifies with\n // these. Emitted here and stripped from minions at the one delegating caller, like the section above.\n for (const [envVarName, value] of Object.entries(resolveInboundEndpointEnv(credentials))) {\n setIfDefined(env, envVarName, value);\n }\n\n // Checked at the RETURN, after every contributor — including the provider\n // fan-out just above — rather than beside the storage block. A guard placed\n // next to the removal would only prove that one line stayed deleted; here it\n // catches the root credential arriving through any path, named anything.\n //\n // This is the gate for R5 of the storage plan, and it covers minions and\n // workers for free: `buildApplicationMinionEnv` delegates to this builder,\n // and the k8s `{appSlug}-secret` is built from its output.\n assertNoPlatformCredentialInGeneratedEnv(env, credentials, 'buildApplicationBackendEnv');\n\n return env;\n }\n\n /**\n * Build env vars for minion processes.\n *\n * Minions run the full backend pipeline (headless mode) via\n * `StartMinionApplicationBackendService`, so they receive the same env\n * contract as application backends: bootstrap identity, platform service\n * URLs, runtime topology, and all data-service wiring (MongoDB, Redis,\n * RabbitMQ, storage). The only semantic difference is the `serviceName`\n * field which carries the minion's service name (from `wildo.minion.config.ts`).\n */\n static buildApplicationMinionEnv(\n bootstrapCredentials: AppBootstrapCredentials,\n serviceName: string,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n environmentId: string,\n /** The minion's declared scope — `providers.scopes.minions.<name>.providers`. Forwarded to the\n * backend builder below, which owns the filtering. Required for the same reason it is there. */\n providerScope: RuntimeProviderScope,\n /**\n * What this minion DECLARED — its authored `resourceAccess` and\n * `requiresInternetEgress`.\n *\n * REQUIRED for the same reason `providerScope` is: an omitted declaration and\n * a declaration of nothing are different statements, and only one of them may\n * be inferred. Absent `resourceAccess` means application-data access was never\n * requested, which withholds the object-storage topology (and every business\n * table from the credential). The DATABASE topology is still emitted: every\n * minion holds the engine-floor role and cannot boot without its store (#1771).\n */\n accessDeclaration: RuntimeAccessDeclaration,\n options: {\n /** The app's release version (the host's package.json `version`), projected as\n * `service.version` in `OTEL_RESOURCE_ATTRIBUTES` (audit A-10). Omitted when absent. */\n serviceVersion?: string;\n appDatabaseName?: string;\n redisKeyPrefix?: string;\n storageBucketPrefix?: string;\n applicationEnv?: string;\n deploymentLocationType: WildoLocationType;\n runtimeSignalsHome?: string;\n runtimeEndpoints?: Record<string, { publicUrl: string; internalUrl: string }>;\n mongodbDirectConnection?: boolean;\n },\n ): Record<string, string> {\n // Delegation is the trap this parameter exists for. The backend builder owns\n // the emission, so a minion inheriting it unchanged receives the BACKEND's\n // topology — every backing service, regardless of what it declared. Gating\n // inside that builder instead would narrow the application backend at the same\n // time, since this is its only delegating caller.\n const minionEnv = PlatformEnvVarsBuilder.buildApplicationBackendEnv(\n bootstrapCredentials,\n serviceName,\n credentials,\n addresses,\n config,\n environmentId,\n providerScope,\n {\n ...options,\n runtimeAccess: resolveRuntimeBackingServiceAccess(\n { kind: ApplicationRuntimePrincipalKind.MINION, name: serviceName } as ApplicationRuntimePrincipal,\n accessDeclaration,\n { applicationDatabaseEngine: resolveApplicationDatabaseEngine(config.applicationDatabase) },\n ),\n },\n );\n\n /*\n * The same delegation trap, one concern over (#1055 D2, R7).\n *\n * A system of record is read through the application's HTTP_API repositories, which only the\n * backend registers — a minion has no bound resource to read and no lane that would reach one.\n * So its address and credential are the backend's, and a minion inheriting them unchanged would\n * hold an ERP credential it can do nothing with, which is the definition of over-delivery.\n *\n * Stripped here rather than gated inside the builder, for the reason stated above the delegation:\n * gating there would narrow the application backend at the same time, and the backend is the one\n * runtime that must have them.\n */\n for (const envVarName of Object.keys(minionEnv)) {\n if (parseSystemOfRecordEnvVarName(envVarName) !== null) delete minionEnv[envVarName];\n // An inbound endpoint secret likewise: a minion mounts no route and could only leak it (#1596).\n if (parseInboundEndpointSecretEnvVarName(envVarName) !== null) delete minionEnv[envVarName];\n }\n // The backend's reverse-proxy hop count describes how its HTTP server is FRONTED (#1788). A minion\n // serves no HTTP and sits behind no proxy, so the fact does not describe it.\n delete minionEnv[HttpServerEnvKey.HTTP_TRUSTED_PROXY_HOPS];\n assertNoSystemOfRecordEnvInGeneratedEnv(minionEnv, 'buildApplicationMinionEnv');\n assertNoInboundEndpointEnvInGeneratedEnv(minionEnv, 'buildApplicationMinionEnv');\n\n return minionEnv;\n }\n\n /**\n * Build env vars for language-agnostic worker processes.\n *\n * Workers do NOT receive backend backing-service wiring. Their runtime\n * contract is the bootstrap identity plus optional provider/logging env\n * bindings so non-Node workers can stay env-driven without consuming the\n * generated TypeScript provider-runtime modules.\n */\n static buildApplicationWorkerEnv(\n bootstrapCredentials: AppBootstrapCredentials,\n workerName: string,\n serviceName: string,\n credentials: PlatformEnvSecretsJson,\n config: PlatformEnvConfigJson,\n environmentId: string,\n /** The worker's declared scope — `providers.scopes.workers.<name>.providers`. `myRustWorker`\n * authors `providers: {}`, so an EMPTY declared set is the correct answer there, and is a\n * different statement from \"the caller did not say\". Required for exactly that reason. */\n providerScope: RuntimeProviderScope,\n options?: {\n /**\n * The worker's authored inbound HTTP surface — `wildo.worker.config.ts >\n * http`, already default-applied by `WorkerHttpSchema`. Projected to the\n * canonical `WORKER_HTTP_PORT` / `WORKER_HEALTH_PATH` / `WORKER_READY_PATH`\n * (+ optional `WORKER_METRICS_PATH`) keys below so the running worker binds\n * the AUTHORED port and probe paths rather than a per-language hardcoded\n * default that only coincides with the authored value by luck. The env-gen\n * caller always threads this from the always-populated worker target; it is\n * `?`-optional only so the provider-env unit tests (which assert provider\n * fan-out, not the HTTP projection) can omit it. When omitted the worker\n * still binds its language-runtime default via `readWorkerHttpSurfaceEnv()`.\n */\n http?: WorkerHttp;\n applicationEnv?: string;\n /** The worker's release version (its package.json `version`) → `service.version` (audit A-10). */\n serviceVersion?: string;\n runtimeEndpoints?: Record<string, { publicUrl: string; internalUrl: string }>;\n /** Required with {@link runtimeSignalsHome}: the variable is a local filesystem handoff, never a remote one. */\n deploymentLocationType?: WildoLocationType;\n /** Where the worker records how its start ended (#3288); see `ApplicationWorkerRuntimeEnvKey.APPLICATION_RUNTIME_SIGNALS_HOME`. */\n runtimeSignalsHome?: string;\n /**\n * The addresses as THIS worker's process sees them (HOST_FACING for a host-run worker, CONTAINER_INTERNAL for\n * a container), so `PLATFORM_APPS_MANAGER_URL` is the resolver's answer, as for the application backend. Every\n * production caller passes it (#2955); without it the bootstrap echo below is used.\n */\n addresses?: ResolvedAddresses;\n },\n ): Record<string, string> {\n if (options?.runtimeSignalsHome !== undefined && options.deploymentLocationType !== WildoLocationType.LOCAL) {\n throw new Error('APPLICATION_RUNTIME_SIGNALS_HOME can only be emitted for explicit local deployment topology');\n }\n const env: Record<string, string> = {};\n\n env[ApplicationWorkerBootstrapEnvKeys.APPLICATION_ID] = bootstrapCredentials.APPLICATION_ID;\n // Worker IDENTITY — the canonical background-runtime pair (matches the k8s\n // worker/minion Deployment templates, the `BackgroundRuntimeType` model, and\n // the Rust worker's env read). `APP_OWNED_SERVICE_NAME` is the `workers`\n // bucket key the worker forwards as the apps-manager worker-bootstrap path\n // segment (`appConfig.workers[name]` lookup); `APP_OWNED_SERVICE_KIND` pins\n // it as a worker so the same contract disambiguates worker vs minion.\n env[ApplicationWorkerBootstrapEnvKeys.APP_OWNED_SERVICE_KIND] = BackgroundRuntimeType.WORKER;\n env[ApplicationWorkerBootstrapEnvKeys.APP_OWNED_SERVICE_NAME] = workerName;\n // SERVICE_NAME — the SEPARATE process/observability identity (also feeds\n // `OTEL_SERVICE_NAME` via `emitObservabilityEnv` below), distinct from the\n // routing identity above.\n env[ApplicationWorkerBootstrapEnvKeys.SERVICE_NAME] = serviceName;\n env[ApplicationWorkerBootstrapEnvKeys.PLATFORM_ENVIRONMENT_ID] = environmentId;\n env[ApplicationWorkerBootstrapEnvKeys.PLATFORM_APPLICATION_PRIMARY_SECRET] =\n bootstrapCredentials.PLATFORM_APPLICATION_PRIMARY_SECRET;\n // The RESOLVER when the caller passes addresses, as for the application backend above: the bootstrap echo is\n // apps-manager reporting its OWN address, right only for a reader on its network. Offline (degraded) it is even\n // rebuilt HOST-facing, so a compose worker container was handed `localhost:5151`, which inside the container is\n // the container itself (#2955 review). Every production caller passes addresses; the echo remains only for\n // callers that do not (unit fixtures).\n env[ApplicationWorkerBootstrapEnvKeys.PLATFORM_APPS_MANAGER_URL] =\n options?.addresses?.platform.appsManager.url ?? bootstrapCredentials.PLATFORM_APPS_MANAGER_URL;\n env[ApplicationWorkerBootstrapEnvKeys.PLATFORM_APPS_MANAGER_RESPONSE_VERIFICATION_KEYS] = appsManagerResponseVerificationKeys(credentials);\n env[ApplicationWorkerBootstrapEnvKeys.APPLICATION_ENV] =\n options?.applicationEnv ?? bootstrapCredentials.APPLICATION_ENV;\n // #1177 — the worker is the runtime this issue was measured on: 1,530 of 1,530 of its records\n // named no application, because its kernel deliberately has no AppConfigurationService and\n // therefore never reaches the logger's `reinitialize`. Its env is the only thing that can say so.\n env[PlatformProcessEnvKeys.APPLICATION_SLUG] = bootstrapCredentials.APPLICATION_SLUG;\n\n // -- Inbound HTTP surface — projected from the authored `http` block so the\n // worker binds the authored port + probe paths (not a per-language\n // hardcoded default). Mirrors the Rust worker's WORKER_HTTP_PORT /\n // WORKER_HEALTH_PATH / WORKER_READY_PATH reads and the Node worker's\n // `readWorkerHttpSurfaceEnv()` helper. The env-gen caller always threads\n // `http`; the guard is only for the provider-env unit tests that omit options.\n if (options?.http) {\n env[ApplicationWorkerHttpSurfaceEnvKeys.WORKER_HTTP_PORT] = String(options.http.port);\n env[ApplicationWorkerHttpSurfaceEnvKeys.WORKER_HEALTH_PATH] = options.http.healthPath;\n env[ApplicationWorkerHttpSurfaceEnvKeys.WORKER_READY_PATH] = options.http.readyPath;\n // `metricsPath` is optional on `WorkerHttpSchema` — emitted only when the\n // author opts the worker into a Prometheus scrape surface.\n setIfDefined(env, ApplicationWorkerHttpSurfaceEnvKeys.WORKER_METRICS_PATH, options.http.metricsPath);\n }\n\n const runtimeEndpoints = options?.runtimeEndpoints;\n if (runtimeEndpoints && Object.keys(runtimeEndpoints).length > 0) {\n env[ApplicationWorkerRuntimeEnvKeys.APPLICATION_RUNTIME_ENDPOINTS] =\n serializeRuntimeEndpointsRecord(runtimeEndpoints);\n }\n setIfDefined(env, ApplicationWorkerRuntimeEnvKeys.APPLICATION_RUNTIME_SIGNALS_HOME, options?.runtimeSignalsHome);\n\n emitLoggingEnv(env, config.logging);\n emitProviderSelectionEnv(env, config.providerSelection);\n emitEmailEnv(env, config.email);\n emitAgentContentGuardrailsEnv(env, config.agentContentGuardrails);\n\n // Audit A-2: OTLP telemetry posture — workers emit OTEL_* like backends so a node worker with\n // the preload `--import` exports traces/metrics/logs (and a language-agnostic worker carries the\n // same env for a future native OTel SDK). The auth header, when a token is provisioned, is\n // resolved provider-agnostically from `providerEnv`, same as the backend.\n //\n // A worker builds its env from scratch rather than delegating, so this is the SECOND\n // application-tier site of the confinement invariant and resolves its own bag — once, read\n // by both the header and the fan-out below (#360).\n const scopedProviderEnv = resolveRuntimeProviderEnv(credentials, providerScope);\n emitObservabilityEnv(\n env,\n config.observability,\n {\n serviceName,\n environment: options?.applicationEnv ?? bootstrapCredentials.APPLICATION_ENV,\n version: options?.serviceVersion,\n },\n { providerEnv: scopedProviderEnv },\n );\n\n // Application tier: a worker receives only the providers its\n // `providers.scopes.workers.<name>` declares. `myRustWorker` declares none,\n // and must therefore receive none.\n for (const [envVarName, value] of Object.entries(scopedProviderEnv)) {\n setIfDefined(env, envVarName, value);\n }\n\n // Application tier — same guard as `buildApplicationBackendEnv`.\n //\n // A worker builds its env from scratch rather than delegating (unlike\n // `buildApplicationMinionEnv`, which inherits the guard by calling the\n // backend builder), so it is a SEPARATE call site for the same invariant and\n // was missed when the guard first landed. It emits no `STORAGE_*` today, but\n // `resolveRuntimeProviderEnv` fans provider values out of the same\n // `credentials` object the root pair lives in — so \"it happens not to leak\n // right now\" is a property of the current provider set, not of this builder.\n // See `.claude/rules/invariant-call-site-enumeration.md`.\n assertNoPlatformCredentialInGeneratedEnv(env, credentials, 'buildApplicationWorkerEnv');\n\n /*\n * A worker receives NOTHING of any system of record (#1055 D2, R7) — and \"nothing\" is not what a\n * worker gets by default, which is why this is asserted rather than assumed: this builder does\n * emit provider keys, and the system-of-record section escapes `filterProviderEnvToScope`\n * entirely because a system of record is deliberately not a provider.\n *\n * A worker has no application repository access at all, so it could not read a bound resource\n * even holding the credential. The assertion is what makes a future contributor to this builder\n * fail loudly rather than widen the delivery in silence.\n */\n assertNoSystemOfRecordEnvInGeneratedEnv(env, 'buildApplicationWorkerEnv');\n assertNoInboundEndpointEnvInGeneratedEnv(env, 'buildApplicationWorkerEnv');\n\n return env;\n }\n\n private static addServiceExtras(\n service: BootstrapPlatformService,\n env: Record<string, string>,\n credentials: PlatformEnvSecretsJson,\n addresses: ResolvedAddresses,\n config: PlatformEnvConfigJson,\n ): void {\n switch (service) {\n case PlatformWildoServices.CRONTABS_BATCHES_MANAGER: {\n const valkey = requireAddress(addresses.infra.valkey, 'valkey');\n const rabbitmq = requireAddress(addresses.infra.rabbitmq, 'rabbitmq');\n const rabbitmqMgmt = requireAddress(addresses.infra.rabbitmqManagement, 'rabbitmqManagement');\n env[PlatformInfrastructureEnvKeys.REDIS_HOST] = valkey.host;\n env[PlatformInfrastructureEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n env[PlatformInfrastructureEnvKeys.RABBITMQ_HOST] = rabbitmq.host;\n env[PlatformInfrastructureEnvKeys.RABBITMQ_PORT] = String(rabbitmq.port);\n env[PlatformInfrastructureEnvKeys.RABBITMQ_MANAGEMENT_PORT] = String(rabbitmqMgmt.port);\n // No RABBITMQ_VHOST (#1112): nothing in crontabs-manager reads it. Its own connection takes the vhost from\n // its platform secret (`/`), and each application's vhost arrives in that application's JWT claim.\n break;\n }\n\n case PlatformWildoServices.MODULE_REGISTRY: {\n // The shared rate-limit store's ADDRESS (#2154). The registry's perimeter limiter and the\n // failed-credential lockout on its `sk_*` keys count there; the credential is the ACL user\n // apps-manager mints for `platform_module_registry`, fetched by the registry at boot. Before\n // this the registry received no address at all, so its lockout failed open in every lane.\n // (Object storage and the platform database are emitted by `buildBootstrapEnv` itself.)\n const valkey = requireAddress(addresses.infra.valkey, 'valkey');\n env[PlatformInfrastructureEnvKeys.REDIS_HOST] = valkey.host;\n env[PlatformInfrastructureEnvKeys.REDIS_PORT] = String(valkey.port);\n setIfDefined(\n env,\n PlatformInfrastructureEnvKeys.REDIS_DATABASE,\n config.backingServices?.[BackingServiceKind.REDIS]?.database,\n );\n break;\n }\n\n default: {\n const _exhaustive: never = service;\n throw new Error(`Unhandled bootstrap service: ${_exhaustive}`);\n }\n }\n }\n}\n"]}
|