@wildo-ai/wildo-cli 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/src/commands/context/__tests__/assurance-basis.command.test.d.ts +2 -0
  2. package/dist/src/commands/context/__tests__/assurance-basis.command.test.d.ts.map +1 -0
  3. package/dist/src/commands/context/__tests__/assurance-basis.command.test.js +63 -0
  4. package/dist/src/commands/context/__tests__/assurance-basis.command.test.js.map +1 -0
  5. package/dist/src/commands/context/assurance-basis.command.d.ts +61 -0
  6. package/dist/src/commands/context/assurance-basis.command.d.ts.map +1 -0
  7. package/dist/src/commands/context/assurance-basis.command.js +166 -0
  8. package/dist/src/commands/context/assurance-basis.command.js.map +1 -0
  9. package/dist/src/commands/dev/charts-audit.command.d.ts +5 -3
  10. package/dist/src/commands/dev/charts-audit.command.d.ts.map +1 -1
  11. package/dist/src/commands/dev/charts-audit.command.js +35 -6
  12. package/dist/src/commands/dev/charts-audit.command.js.map +1 -1
  13. package/dist/src/commands/fwk/generate-providers.command.d.ts.map +1 -1
  14. package/dist/src/commands/fwk/generate-providers.command.js +18 -2
  15. package/dist/src/commands/fwk/generate-providers.command.js.map +1 -1
  16. package/dist/src/commands/generate/email-preview.command.d.ts +8 -0
  17. package/dist/src/commands/generate/email-preview.command.d.ts.map +1 -1
  18. package/dist/src/commands/generate/email-preview.command.js +57 -0
  19. package/dist/src/commands/generate/email-preview.command.js.map +1 -1
  20. package/dist/src/commands/init.command.d.ts.map +1 -1
  21. package/dist/src/commands/init.command.js +32 -0
  22. package/dist/src/commands/init.command.js.map +1 -1
  23. package/dist/src/commands/lock/check.command.d.ts.map +1 -1
  24. package/dist/src/commands/lock/check.command.js +3 -2
  25. package/dist/src/commands/lock/check.command.js.map +1 -1
  26. package/dist/src/commands/registry/login.command.d.ts.map +1 -1
  27. package/dist/src/commands/registry/login.command.js +2 -0
  28. package/dist/src/commands/registry/login.command.js.map +1 -1
  29. package/dist/src/commands/registry/publish.command.d.ts.map +1 -1
  30. package/dist/src/commands/registry/publish.command.js +2 -0
  31. package/dist/src/commands/registry/publish.command.js.map +1 -1
  32. package/dist/src/commands/registry/registry-transport.constants.d.ts +33 -0
  33. package/dist/src/commands/registry/registry-transport.constants.d.ts.map +1 -0
  34. package/dist/src/commands/registry/registry-transport.constants.js +33 -0
  35. package/dist/src/commands/registry/registry-transport.constants.js.map +1 -0
  36. package/dist/src/commands/registry/whoami.command.d.ts.map +1 -1
  37. package/dist/src/commands/registry/whoami.command.js +2 -0
  38. package/dist/src/commands/registry/whoami.command.js.map +1 -1
  39. package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.d.ts +2 -0
  40. package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.d.ts.map +1 -0
  41. package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.js +146 -0
  42. package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.js.map +1 -0
  43. package/dist/src/modules/domain/credentials/approver-user.module.d.ts +85 -0
  44. package/dist/src/modules/domain/credentials/approver-user.module.d.ts.map +1 -0
  45. package/dist/src/modules/domain/credentials/approver-user.module.js +92 -0
  46. package/dist/src/modules/domain/credentials/approver-user.module.js.map +1 -0
  47. package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts +2 -0
  48. package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts.map +1 -0
  49. package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js +111 -0
  50. package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js.map +1 -0
  51. package/dist/src/services/application/__tests__/provider-package-links.service.test.js +68 -0
  52. package/dist/src/services/application/__tests__/provider-package-links.service.test.js.map +1 -1
  53. package/dist/src/services/application/app-bootstrap.service.d.ts +9 -0
  54. package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
  55. package/dist/src/services/application/app-bootstrap.service.js +30 -1
  56. package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
  57. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +6 -0
  58. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
  59. package/dist/src/services/application/application-runtime-bootstrap.service.js +41 -0
  60. package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
  61. package/dist/src/services/application/provider-package-links.service.d.ts +30 -0
  62. package/dist/src/services/application/provider-package-links.service.d.ts.map +1 -1
  63. package/dist/src/services/application/provider-package-links.service.js +35 -3
  64. package/dist/src/services/application/provider-package-links.service.js.map +1 -1
  65. package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
  66. package/dist/src/services/application/provider-runtime-sync.service.js +4 -3
  67. package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
  68. package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
  69. package/dist/src/services/application/saas-skeleton.service.js +22 -2
  70. package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
  71. package/dist/src/services/companion/workbench-cli.service.js +10 -1
  72. package/dist/src/services/companion/workbench-cli.service.js.map +1 -1
  73. package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.d.ts +2 -0
  74. package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.d.ts.map +1 -0
  75. package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.js +94 -0
  76. package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.js.map +1 -0
  77. package/dist/src/services/credentials/ci-secrets-adapter.service.d.ts.map +1 -1
  78. package/dist/src/services/credentials/ci-secrets-adapter.service.js +16 -0
  79. package/dist/src/services/credentials/ci-secrets-adapter.service.js.map +1 -1
  80. package/dist/src/services/credentials/composed-provider-catalogue.d.ts +34 -0
  81. package/dist/src/services/credentials/composed-provider-catalogue.d.ts.map +1 -1
  82. package/dist/src/services/credentials/composed-provider-catalogue.js +35 -0
  83. package/dist/src/services/credentials/composed-provider-catalogue.js.map +1 -1
  84. package/dist/src/services/credentials/credentials.schemas.d.ts +27 -0
  85. package/dist/src/services/credentials/credentials.schemas.d.ts.map +1 -1
  86. package/dist/src/services/credentials/credentials.schemas.js +50 -0
  87. package/dist/src/services/credentials/credentials.schemas.js.map +1 -1
  88. package/dist/src/services/credentials/framework-managed-secrets.d.ts +1 -1
  89. package/dist/src/services/credentials/framework-managed-secrets.d.ts.map +1 -1
  90. package/dist/src/services/credentials/framework-managed-secrets.js +49 -8
  91. package/dist/src/services/credentials/framework-managed-secrets.js.map +1 -1
  92. package/dist/src/services/deployment/infra-writer.service.d.ts.map +1 -1
  93. package/dist/src/services/deployment/infra-writer.service.js +23 -4
  94. package/dist/src/services/deployment/infra-writer.service.js.map +1 -1
  95. package/dist/src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.js +45 -2
  96. package/dist/src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.js.map +1 -1
  97. package/dist/src/services/deployment/k8s/k8s-bootstrap.service.d.ts +23 -0
  98. package/dist/src/services/deployment/k8s/k8s-bootstrap.service.d.ts.map +1 -1
  99. package/dist/src/services/deployment/k8s/k8s-bootstrap.service.js +49 -6
  100. package/dist/src/services/deployment/k8s/k8s-bootstrap.service.js.map +1 -1
  101. package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
  102. package/dist/src/services/environment/env-vars-builder.service.js +19 -0
  103. package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
  104. package/dist/src/services/framework/__tests__/engine-provider-specifications.reconciliation.test.js +8 -0
  105. package/dist/src/services/framework/__tests__/engine-provider-specifications.reconciliation.test.js.map +1 -1
  106. package/dist/src/services/framework/__tests__/framework-knowledge-audit.live.contract.test.js +17 -0
  107. package/dist/src/services/framework/__tests__/framework-knowledge-audit.live.contract.test.js.map +1 -1
  108. package/dist/src/services/framework/__tests__/framework-knowledge-audit.service.test.js +51 -0
  109. package/dist/src/services/framework/__tests__/framework-knowledge-audit.service.test.js.map +1 -1
  110. package/dist/src/services/framework/framework-knowledge-audit.service.d.ts +41 -1
  111. package/dist/src/services/framework/framework-knowledge-audit.service.d.ts.map +1 -1
  112. package/dist/src/services/framework/framework-knowledge-audit.service.js +90 -0
  113. package/dist/src/services/framework/framework-knowledge-audit.service.js.map +1 -1
  114. package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.d.ts +2 -0
  115. package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.d.ts.map +1 -0
  116. package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.js +100 -0
  117. package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.js.map +1 -0
  118. package/dist/src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.js +55 -2
  119. package/dist/src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.js.map +1 -1
  120. package/dist/src/services/framework/provider-transposition/provider-package.emitter.d.ts +9 -0
  121. package/dist/src/services/framework/provider-transposition/provider-package.emitter.d.ts.map +1 -1
  122. package/dist/src/services/framework/provider-transposition/provider-package.emitter.js +139 -19
  123. package/dist/src/services/framework/provider-transposition/provider-package.emitter.js.map +1 -1
  124. package/dist/src/services/frontend/cloudflare-cdn.service.d.ts.map +1 -1
  125. package/dist/src/services/frontend/cloudflare-cdn.service.js +33 -2
  126. package/dist/src/services/frontend/cloudflare-cdn.service.js.map +1 -1
  127. package/dist/tsconfig.build.tsbuildinfo +1 -1
  128. package/dist/tsconfig.tsbuildinfo +1 -1
  129. package/package.json +17 -17
  130. package/scripts/app-dependency-alignment/propagated-engine-overrides.json +13 -0
  131. package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +64 -16
  132. package/templates/saas/engine-peer-closure.json +12 -0
  133. package/templates/saas/scenarios/add-provider/scenario.json +11 -11
  134. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +34 -0
  135. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/pages/auth/exchange.tsx +24 -1
  136. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/theme/Root.tsx +22 -2
  137. package/templates/saas/skeleton/backend-api/package.json.hbs +1 -1
  138. package/templates/saas/skeleton/backend-api/src/companion-exports.ts +13 -2
  139. package/wildo-framework.info.json +1 -1
  140. package/templates/saas/scenarios/add-backend-provider/scenario.json +0 -17
  141. package/templates/saas/skeleton/backend-api/src/provider-contributions.ts +0 -44
@@ -1 +1 @@
1
- {"version":3,"file":"framework-managed-secrets.js","sourceRoot":"","sources":["../../../../src/services/credentials/framework-managed-secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EACL,yDAAyD,GAE1D,MAAM,qDAAqD,CAAC;AAkB7D;;;;GAIG;AACH,MAAM,CAAN,IAAY,iCAcX;AAdD,WAAY,iCAAiC;IAC3C,wFAAmD,CAAA;IACnD,wFAAmD,CAAA;IACnD,gGAA2D,CAAA;IAC3D,4FAAuD,CAAA;IACvD,sFAAiD,CAAA;IACjD,4FAAuD,CAAA;IACvD,wFAAmD,CAAA;IACnD,oFAA+C,CAAA;IAC/C,oHAA+E,CAAA;IAC/E,4IAAuG,CAAA;IACvG,kGAA6D,CAAA;IAC7D,oGAA+D,CAAA;IAC/D,sEAAiC,CAAA;AACnC,CAAC,EAdW,iCAAiC,KAAjC,iCAAiC,QAc5C;AA2BD,qGAAqG;AACrG,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD;QACE,GAAG,EAAE,iCAAiC,CAAC,uBAAuB;QAC9D,YAAY,EAAE,CAAC,kBAAkB,CAAC;QAClC,UAAU,EAAE,CAAC,sBAAs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,CAAC;QACzC,qBAAqB,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;AAChD,CAAC","sourcesContent":["/**\n * framework-managed-secrets — the ONE named source of truth for every piece of\n * credential material the framework generates for itself (as opposed to material an\n * operator types: admin identity, provider API keys, GitHub tokens, Atlas API keys).\n *\n * WHY this exists (root cause). Framework-generated material used to be minted in\n * exactly one place — `buildCredentials()`, which runs ONLY during the interactive\n * `wildo setup` of a BRAND-NEW environment. Every environment created before a given\n * material was introduced therefore never acquired it, and nothing ever backfilled it.\n * Worse, the list of \"what counts as auto-generated\" was hand-duplicated across four\n * sites that each drifted independently:\n *\n * 1. `buildCredentials()` — minted immudb + crontabs keypairs\n * 2. `SecretsRotation.rotate()` — rotated NEITHER of them\n * 3. `SecretsReader.AUTO_GENERATED_KEYS` — knew immudb, not crontabs\n * 4. (no backfill path existed at all)\n *\n * That produced two silent, security-relevant degradations in the wild:\n *\n * - the crontabs-batches-manager P2P signing keypair was absent, so crontabs signed\n * job tokens with a fallback key and every scheduled tick dead-lettered; and\n * - the immudb state-signing keypair was absent, so the self-hosted immudb ran\n * WITHOUT `--signingKey` and the audit client logged \"state-signature pinning is\n * OFF\" — a whole-server substitution of the tamper-evident audit store was not\n * cryptographically detectable.\n *\n * The fix is structural, not per-material: declare each material ONCE here, derive\n * minting / provisioning / rotation / classification from that declaration, and run the\n * idempotent {@link provisionFrameworkManagedSecrets} on the paths that already\n * regenerate derived artifacts. A material added in the future is then live in every\n * environment on the next `wildo local dev` / `wildo config sync`, with no per-material\n * migration to remember.\n *\n * ## Provisioning is ADDITIVE — it is not rotation\n *\n * Provisioning mints ONLY material that is absent (or blank) and never touches material\n * that is already present. That makes it safe to run unattended on every self-heal:\n * nothing that an existing deployment depends on can change underneath it. Rotation\n * ({@link rotateFrameworkManagedSecrets}) is the destructive counterpart and stays\n * behind the explicit `wildo config sync --rotate-secrets` opt-in.\n *\n * ## Identity halves vs secret halves\n *\n * A material can own more than one key. `identityKeys` are non-secret constants (service\n * usernames) written at provisioning time and PRESERVED across rotation; `secretKeys`\n * are the generated-secret halves — they are what rotation regenerates, what the CLI\n * masks on display, and what `SecretsReader.isAutoGenerated()` reports.\n */\n\nimport { CredentialGenerator } from '@wildo-ai/platform-config-lib';\n\nimport {\n DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME,\n type PlatformEnvSecretsJson,\n} from '~wildo-cli/services/credentials/credentials.schemas';\n\n/**\n * `secrets.json` as it exists BEFORE framework-managed material has been provisioned:\n * every framework-owned branch may be absent or partially filled, while the\n * operator-typed branches (`admin` identity, `providerEnv`, `atlas`, `github`) carry\n * whatever the caller already knows.\n *\n * One level of partiality is deliberate and sufficient: a material provisions its whole\n * leaf object at once (e.g. `platform.appsManager` is written as a complete keypair),\n * so no material ever observes a half-filled nested object.\n */\nexport type PlatformEnvSecretsDraft = {\n [K in keyof PlatformEnvSecretsJson]?: NonNullable<PlatformEnvSecretsJson[K]> extends Record<string, unknown>\n ? Partial<NonNullable<PlatformEnvSecretsJson[K]>>\n : PlatformEnvSecretsJson[K];\n};\n\n/**\n * Closed vocabulary of framework-generated credential materials. A material is the unit\n * of provisioning: the smallest set of keys that MUST be minted together (a keypair's two\n * halves are useless apart, a username is useless without its password).\n */\nexport enum FrameworkManagedSecretMaterialRef {\n MONGODB_ROOT_CREDENTIAL = 'mongodb-root-credential',\n VALKEY_ADMIN_CREDENTIAL = 'valkey-admin-credential',\n POSTGRESQL_ADMIN_CREDENTIAL = 'postgresql-admin-credential',\n RABBITMQ_ADMIN_CREDENTIAL = 'rabbitmq-admin-credential',\n RABBITMQ_ERLANG_COOKIE = 'rabbitmq-erlang-cookie',\n STORAGE_ACCESS_CREDENTIAL = 'storage-access-credential',\n PLATFORM_PRIMARY_SECRET = 'platform-primary-secret',\n PLATFORM_ADMIN_SECRET = 'platform-admin-secret',\n PLATFORM_APPS_MANAGER_SIGNING_KEYPAIR = 'platform-apps-manager-signing-keypair',\n PLATFORM_CRONTABS_BATCHES_MANAGER_SIGNING_KEYPAIR = 'platform-crontabs-batches-manager-signing-keypair',\n IMMUDB_STATE_SIGNING_KEYPAIR = 'immudb-state-signing-keypair',\n MONGOT_SYNC_SOURCE_CREDENTIAL = 'mongot-sync-source-credential',\n ADMIN_PASSWORD = 'admin-password',\n}\n\n/**\n * Declaration of one framework-generated credential material.\n *\n * Every material is rotatable — that IS the contract of \"auto-generated\" (the operator\n * never typed it, so regenerating it costs only a redeploy). Should a future material\n * ever be genuinely un-rotatable, add an explicit policy axis here rather than silently\n * omitting it from {@link rotateFrameworkManagedSecrets} — a silent omission is exactly\n * the drift this registry exists to prevent.\n */\nexport interface FrameworkManagedSecretMaterial {\n readonly ref: FrameworkManagedSecretMaterialRef;\n /** Non-secret identity keys (service usernames) — written on provisioning, preserved on rotation. */\n readonly identityKeys: readonly string[];\n /** Generated-secret keys — written on provisioning AND regenerated on rotation. */\n readonly secretKeys: readonly string[];\n /** Why this material exists, in one line (surfaced by CLI reporting). */\n readonly purpose: string;\n /** True when every key this material owns is present and non-blank. */\n isProvisioned(secrets: PlatformEnvSecretsDraft): boolean;\n /** Write the COMPLETE material (identity + secret halves). Called only when not provisioned. */\n provision(secrets: PlatformEnvSecretsDraft): void;\n /** Regenerate the secret halves in place, preserving identity halves. */\n rotate(secrets: PlatformEnvSecretsDraft): void;\n}\n\n/** A string counts as present only when it carries actual material — `''` is as broken as absent. */\nfunction isFilled(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0;\n}\n\nexport const FRAMEWORK_MANAGED_SECRET_MATERIALS = [\n {\n ref: FrameworkManagedSecretMaterialRef.MONGODB_ROOT_CREDENTIAL,\n identityKeys: ['mongodb.rootUser'],\n secretKeys: ['mongodb.rootPassword'],\n purpose: 'Root credential for the self-hosted MongoDB backing service.',\n isProvisioned: (s) => isFilled(s.mongodb?.rootUser) && isFilled(s.mongodb?.rootPassword),\n provision: (s) => {\n s.mongodb = {\n rootUser: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.MONGODB_ROOT_USER,\n rootPassword: CredentialGenerator.generatePassword(24),\n };\n },\n rotate: (s) => {\n if (s.mongodb) s.mongodb.rootPassword = CredentialGenerator.generatePassword(24);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.VALKEY_ADMIN_CREDENTIAL,\n identityKeys: ['valkey.adminUser'],\n secretKeys: ['valkey.adminPassword'],\n purpose: 'Admin credential for the self-hosted Valkey/Redis backing service.',\n isProvisioned: (s) => isFilled(s.valkey?.adminUser) && isFilled(s.valkey?.adminPassword),\n provision: (s) => {\n s.valkey = {\n adminUser: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.VALKEY_ADMIN_USER,\n adminPassword: CredentialGenerator.generatePassword(32),\n };\n },\n rotate: (s) => {\n if (s.valkey) s.valkey.adminPassword = CredentialGenerator.generatePassword(32);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.POSTGRESQL_ADMIN_CREDENTIAL,\n identityKeys: ['postgresql.adminUser'],\n secretKeys: ['postgresql.adminPassword'],\n purpose: 'Admin credential for the self-hosted PostgreSQL backing service.',\n isProvisioned: (s) => isFilled(s.postgresql?.adminUser) && isFilled(s.postgresql?.adminPassword),\n provision: (s) => {\n s.postgresql = {\n adminUser: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.PG_ADMIN_USER,\n adminPassword: CredentialGenerator.generatePassword(24),\n };\n },\n rotate: (s) => {\n if (s.postgresql) s.postgresql.adminPassword = CredentialGenerator.generatePassword(24);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.RABBITMQ_ADMIN_CREDENTIAL,\n identityKeys: ['rabbitmq.adminUsername'],\n secretKeys: ['rabbitmq.adminPassword'],\n purpose: 'Admin credential for the self-hosted RabbitMQ broker.',\n isProvisioned: (s) => isFilled(s.rabbitmq?.adminUsername) && isFilled(s.rabbitmq?.adminPassword),\n provision: (s) => {\n s.rabbitmq = {\n ...s.rabbitmq,\n adminUsername: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.RABBITMQ_ADMIN_USERNAME,\n adminPassword: CredentialGenerator.generatePassword(32),\n };\n },\n rotate: (s) => {\n if (s.rabbitmq) s.rabbitmq.adminPassword = CredentialGenerator.generatePassword(32);\n },\n },\n {\n // Separate material from the admin credential: the Erlang cookie is the CLUSTER\n // membership secret, not a login. It is provisioned/rotated independently so a\n // secrets.json that carries one but not the other self-heals to a complete broker\n // configuration instead of being silently half-configured.\n ref: FrameworkManagedSecretMaterialRef.RABBITMQ_ERLANG_COOKIE,\n identityKeys: [],\n secretKeys: ['rabbitmq.erlangCookie'],\n purpose: 'Erlang cluster cookie shared by every RabbitMQ node.',\n isProvisioned: (s) => isFilled(s.rabbitmq?.erlangCookie),\n provision: (s) => {\n s.rabbitmq = { ...s.rabbitmq, erlangCookie: CredentialGenerator.generateErlangCookie() };\n },\n rotate: (s) => {\n if (s.rabbitmq) s.rabbitmq.erlangCookie = CredentialGenerator.generateErlangCookie();\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.STORAGE_ACCESS_CREDENTIAL,\n identityKeys: ['storage.accessKey'],\n secretKeys: ['storage.secretKey'],\n purpose: 'Access key pair for the self-hosted MinIO object storage.',\n isProvisioned: (s) => isFilled(s.storage?.accessKey) && isFilled(s.storage?.secretKey),\n provision: (s) => {\n s.storage = {\n accessKey: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.MINIO_ACCESS_KEY,\n secretKey: CredentialGenerator.generatePassword(32),\n };\n },\n rotate: (s) => {\n if (s.storage) s.storage.secretKey = CredentialGenerator.generatePassword(32);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.PLATFORM_PRIMARY_SECRET,\n identityKeys: [],\n secretKeys: ['platform.primarySecret'],\n purpose: 'Primary shared platform secret.',\n isProvisioned: (s) => isFilled(s.platform?.primarySecret),\n provision: (s) => {\n s.platform = { ...s.platform, primarySecret: CredentialGenerator.generateSecret(48) };\n },\n rotate: (s) => {\n if (s.platform) s.platform.primarySecret = CredentialGenerator.generateSecret(48);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.PLATFORM_ADMIN_SECRET,\n identityKeys: [],\n secretKeys: ['platform.adminSecret'],\n purpose: 'Dedicated shared secret for admin operations (CLI <-> apps-manager).',\n isProvisioned: (s) => isFilled(s.platform?.adminSecret),\n provision: (s) => {\n s.platform = { ...s.platform, adminSecret: CredentialGenerator.generateSecret(48) };\n },\n rotate: (s) => {\n if (s.platform) s.platform.adminSecret = CredentialGenerator.generateSecret(48);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.PLATFORM_APPS_MANAGER_SIGNING_KEYPAIR,\n identityKeys: [],\n secretKeys: ['platform.appsManager.privateKey', 'platform.appsManager.publicKey'],\n purpose: \"apps-manager's P2P signing keypair (signs the JWTs it hands to every app).\",\n isProvisioned: (s) =>\n isFilled(s.platform?.appsManager?.privateKey) && isFilled(s.platform?.appsManager?.publicKey),\n provision: (s) => {\n const keys = CredentialGenerator.generateECKeyPair();\n s.platform = {\n ...s.platform,\n appsManager: { privateKey: keys.privateKey, publicKey: keys.publicKey },\n };\n },\n rotate: (s) => {\n if (!s.platform?.appsManager) return;\n const keys = CredentialGenerator.generateECKeyPair();\n s.platform.appsManager.privateKey = keys.privateKey;\n s.platform.appsManager.publicKey = keys.publicKey;\n },\n },\n {\n // Historically absent from `buildCredentials`, which is exactly why crontabs signed\n // every SCHEDULED_CRON / MINION_TICK token with a fallback key and apps handed out an\n // empty verify key — dead-lettering every tick. Declared here so an environment that\n // predates the keypair acquires it on the next self-heal.\n ref: FrameworkManagedSecretMaterialRef.PLATFORM_CRONTABS_BATCHES_MANAGER_SIGNING_KEYPAIR,\n identityKeys: [],\n secretKeys: [\n 'platform.crontabsBatchesManager.privateKey',\n 'platform.crontabsBatchesManager.publicKey',\n ],\n purpose: \"crontabs-batches-manager's P2P signing keypair (signs every scheduled job token).\",\n isProvisioned: (s) =>\n isFilled(s.platform?.crontabsBatchesManager?.privateKey)\n && isFilled(s.platform?.crontabsBatchesManager?.publicKey),\n provision: (s) => {\n const keys = CredentialGenerator.generateECKeyPair();\n s.platform = {\n ...s.platform,\n crontabsBatchesManager: { privateKey: keys.privateKey, publicKey: keys.publicKey },\n };\n },\n rotate: (s) => {\n if (!s.platform?.crontabsBatchesManager) return;\n const keys = CredentialGenerator.generateECKeyPair();\n s.platform.crontabsBatchesManager.privateKey = keys.privateKey;\n s.platform.crontabsBatchesManager.publicKey = keys.publicKey;\n },\n },\n {\n // The cryptographic whole-server-substitution defense for the tamper-evident audit\n // store. The PRIVATE half (SEC1 \"EC PRIVATE KEY\" PEM — the exact format immudb's\n // `--signingKey` parses) is mounted into the SELF-hosted immudb server ONLY; the\n // PUBLIC half (SPKI PEM) rides `IMMUDB_STATE_PUBLIC_KEY` into every app runtime so\n // the audit client can verify the server's signed `ImmutableState`. Absent material\n // means immudb runs UNSIGNED and the client degrades to \"pinning is OFF\".\n ref: FrameworkManagedSecretMaterialRef.IMMUDB_STATE_SIGNING_KEYPAIR,\n identityKeys: [],\n secretKeys: ['immudb.stateSigningPrivateKey', 'immudb.stateSigningPublicKey'],\n purpose: 'immudb state-signing keypair (audit-store whole-server-substitution defense).',\n isProvisioned: (s) =>\n isFilled(s.immudb?.stateSigningPrivateKey) && isFilled(s.immudb?.stateSigningPublicKey),\n provision: (s) => {\n const keys = CredentialGenerator.generateECKeyPair();\n s.immudb = { stateSigningPrivateKey: keys.privateKey, stateSigningPublicKey: keys.publicKey };\n },\n rotate: (s) => {\n if (!s.immudb) return;\n const keys = CredentialGenerator.generateECKeyPair();\n s.immudb.stateSigningPrivateKey = keys.privateKey;\n s.immudb.stateSigningPublicKey = keys.publicKey;\n },\n },\n {\n // Issue #74 — the SCRAM password `mongot` (the MongoDB 8.2 Search / Vector Search\n // sidecar) authenticates to mongod with. Declared as its OWN material rather than as a\n // third key on MONGODB_ROOT_CREDENTIAL, because `provision` REPLACES the whole section:\n // widening the root material's `isProvisioned` would make every existing environment\n // report unprovisioned and then re-mint `mongodb.rootPassword` on the next self-heal,\n // silently rotating the credential a running stack is already authenticated with.\n // Separate material ⇒ an environment that predates mongot acquires only what it lacks —\n // the same reasoning recorded on the crontabs-batches-manager keypair above.\n //\n // No identity key: the username is the code constant `MONGOT_SYNC_SOURCE.USERNAME`.\n // Alphanumeric + `_+-` (the shared password charset) is safe unquoted in the mongosh\n // `--eval` string, in a YAML scalar, and in a shell heredoc — all three of which this\n // value passes through before it reaches mongot.\n ref: FrameworkManagedSecretMaterialRef.MONGOT_SYNC_SOURCE_CREDENTIAL,\n identityKeys: [],\n secretKeys: ['mongot.syncSourcePassword'],\n purpose: \"mongot's SCRAM credential against mongod (the `searchCoordinator` sync-source user).\",\n isProvisioned: (s) => isFilled(s.mongot?.syncSourcePassword),\n provision: (s) => {\n s.mongot = { syncSourcePassword: CredentialGenerator.generatePassword(32) };\n },\n rotate: (s) => {\n if (s.mongot) s.mongot.syncSourcePassword = CredentialGenerator.generatePassword(32);\n },\n },\n {\n // The seeded admin user's password. The operator MAY type one at setup; when they do\n // not, the framework generates it. Only the password is framework-managed — the\n // identity fields (email / first / last name) are operator-authored and are NOT\n // declared here, so provisioning never invents an admin identity.\n ref: FrameworkManagedSecretMaterialRef.ADMIN_PASSWORD,\n identityKeys: [],\n secretKeys: ['admin.password'],\n purpose: 'Password of the seeded platform admin user (when not operator-supplied).',\n isProvisioned: (s) => isFilled(s.admin?.password),\n provision: (s) => {\n s.admin = { ...s.admin, password: CredentialGenerator.generatePassword(16) };\n },\n rotate: (s) => {\n if (s.admin) s.admin.password = CredentialGenerator.generatePassword(16);\n },\n },\n] as const satisfies readonly FrameworkManagedSecretMaterial[];\n\n/**\n * Compile-time assertion: every {@link FrameworkManagedSecretMaterialRef} member MUST be declared\n * in {@link FRAMEWORK_MANAGED_SECRET_MATERIALS}. Omitting one produces\n * `Type '\"…\"' is not assignable to type 'never'` pointing here.\n *\n * The enum was a closed vocabulary with no mechanical link to the list that realises it: the\n * annotation `readonly FrameworkManagedSecretMaterial[]` widened every `ref` back to the enum, so\n * declaring twelve of thirteen materials type-checked perfectly. `as const satisfies` keeps each\n * `ref` at its literal member type, which is what makes the `Exclude` below able to see a gap —\n * the same shape as `_AssertExhaustivePlatformServiceCoverage` in\n * `platform-infrastructure-manager.apps-manager.platform.service.ts`.\n *\n * This is the registry EVERY derived answer now reads — minting, rotation, auto-generated\n * classification, and (since the CI mapping was derived from it) which GitHub Secret a pipeline\n * must carry. A material declared here and forgotten there was exactly how the crontabs signing\n * keypair, the immudb state-signing keypair and the mongot sync-source credential were absent from\n * `FIXED_MAPPINGS`: minted on a developer machine, and silently never reconstructed in CI.\n */\ntype _DeclaredFrameworkManagedSecretMaterialRef = (typeof FRAMEWORK_MANAGED_SECRET_MATERIALS)[number]['ref'];\ntype _AssertExhaustiveFrameworkManagedSecretMaterialCoverage =\n Exclude<FrameworkManagedSecretMaterialRef, _DeclaredFrameworkManagedSecretMaterialRef> extends never ? true : never;\nconst _assertExhaustiveFrameworkManagedSecretMaterialCoverage: _AssertExhaustiveFrameworkManagedSecretMaterialCoverage = true;\nvoid _assertExhaustiveFrameworkManagedSecretMaterialCoverage;\n\n/**\n * Every generated-secret key across all materials, in declaration order. This is the\n * derived answer to \"is this key auto-generated?\" — consumed by `SecretsReader` for\n * masking and rotation reporting so that list can no longer drift from what is actually\n * minted. Identity keys (service usernames) are deliberately excluded: they are\n * non-secret constants, not generated material.\n */\nexport const FRAMEWORK_MANAGED_SECRET_KEYS: readonly string[] = FRAMEWORK_MANAGED_SECRET_MATERIALS\n .flatMap((material) => material.secretKeys);\n\n/** Outcome of {@link provisionFrameworkManagedSecrets}. */\nexport interface FrameworkManagedSecretsProvisioningResult {\n /** The same object that was passed in, now guaranteed complete. */\n secrets: PlatformEnvSecretsJson;\n /** Materials that were absent and have just been minted (empty ⇒ nothing changed). */\n mintedRefs: FrameworkManagedSecretMaterialRef[];\n /** Flattened keys written by `mintedRefs`, for operator-facing reporting. */\n mintedKeys: string[];\n}\n\n/**\n * Mint every framework-managed material that is absent (or blank) from `secrets`,\n * leaving everything already present untouched, and return what changed.\n *\n * IDEMPOTENT AND ADDITIVE by construction — running it twice mints nothing the second\n * time, and it can never invalidate a credential a running deployment already uses.\n * That is what makes it safe on unattended self-heal paths (`wildo local dev` /\n * `wildo local up` preflight, `wildo config sync`), unlike\n * {@link rotateFrameworkManagedSecrets}.\n *\n * Serves two callers with one code path:\n * - `buildCredentials()` passes a draft holding only operator-typed answers, and gets\n * back a complete `secrets.json`;\n * - the self-heal paths pass an already-parsed `secrets.json` and get back the same\n * object with the gaps filled.\n *\n * The returned `secrets` is narrowed to the complete `PlatformEnvSecretsJson` shape only\n * after a runtime completeness assertion over the registry — the narrowing is therefore\n * proven, not assumed. A material whose `provision()` fails to satisfy its own\n * `isProvisioned()` is a registry authoring bug and throws loudly here rather than\n * writing a half-provisioned secrets.json to disk.\n */\nexport function provisionFrameworkManagedSecrets(\n secrets: PlatformEnvSecretsDraft,\n): FrameworkManagedSecretsProvisioningResult {\n const mintedRefs: FrameworkManagedSecretMaterialRef[] = [];\n const mintedKeys: string[] = [];\n\n for (const material of FRAMEWORK_MANAGED_SECRET_MATERIALS) {\n if (material.isProvisioned(secrets)) continue;\n\n material.provision(secrets);\n\n if (!material.isProvisioned(secrets)) {\n throw new Error(\n `Framework-managed secret material '${material.ref}' did not satisfy its own provisioning check. `\n + 'This is a registry authoring bug in framework-managed-secrets.ts, not an environment problem.',\n );\n }\n\n mintedRefs.push(material.ref);\n mintedKeys.push(...material.identityKeys, ...material.secretKeys);\n }\n\n return { secrets: secrets as PlatformEnvSecretsJson, mintedRefs, mintedKeys };\n}\n\n/** Outcome of {@link rotateFrameworkManagedSecrets}. */\nexport interface FrameworkManagedSecretsRotationResult {\n /** Generated-secret keys that were regenerated. */\n rotatedKeys: string[];\n /** Identity keys deliberately preserved (service usernames). */\n preservedIdentityKeys: string[];\n}\n\n/**\n * Regenerate the secret half of every framework-managed material, preserving identity\n * halves (service usernames) and every operator-typed value (admin identity, provider\n * API keys, GitHub tokens, Atlas API keys) — those are simply not in the registry.\n *\n * DESTRUCTIVE: every rotated credential must be redeployed to the services that hold\n * the other end. Callers gate this behind an explicit operator opt-in.\n *\n * Any material still absent is provisioned first, so a rotation of a partially\n * provisioned environment yields a COMPLETE secrets.json rather than silently skipping\n * the gaps (the previous hand-written rotation skipped whatever it had not been taught\n * about, which is how the immudb and crontabs keypairs stayed missing through rotations).\n */\nexport function rotateFrameworkManagedSecrets(\n secrets: PlatformEnvSecretsDraft,\n): FrameworkManagedSecretsRotationResult {\n const { mintedKeys } = provisionFrameworkManagedSecrets(secrets);\n const mintedKeySet = new Set(mintedKeys);\n\n const rotatedKeys: string[] = [];\n const preservedIdentityKeys: string[] = [];\n\n for (const material of FRAMEWORK_MANAGED_SECRET_MATERIALS) {\n // A material minted moments ago by the provisioning pass above is already fresh —\n // rotating it again would only burn entropy and confuse the operator-facing report.\n const wasJustMinted = material.secretKeys.every((key) => mintedKeySet.has(key));\n if (!wasJustMinted) {\n material.rotate(secrets);\n }\n rotatedKeys.push(...material.secretKeys);\n preservedIdentityKeys.push(...material.identityKeys);\n }\n\n return { rotatedKeys, preservedIdentityKeys };\n}\n"]}
1
+ {"version":3,"file":"framework-managed-secrets.js","sourceRoot":"","sources":["../../../../src/services/credentials/framework-managed-secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EACL,yDAAyD,GAE1D,MAAM,qDAAqD,CAAC;AAkB7D;;;;GAIG;AACH,MAAM,CAAN,IAAY,iCAcX;AAdD,WAAY,iCAAiC;IAC3C,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CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;QACzC,qBAAqB,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;AAChD,CAAC","sourcesContent":["/**\n * framework-managed-secrets — the ONE named source of truth for every piece of\n * credential material the framework generates for itself (as opposed to material an\n * operator types: admin identity, provider API keys, GitHub tokens, Atlas API keys).\n *\n * WHY this exists (root cause). Framework-generated material used to be minted in\n * exactly one place — `buildCredentials()`, which runs ONLY during the interactive\n * `wildo setup` of a BRAND-NEW environment. Every environment created before a given\n * material was introduced therefore never acquired it, and nothing ever backfilled it.\n * Worse, the list of \"what counts as auto-generated\" was hand-duplicated across four\n * sites that each drifted independently:\n *\n * 1. `buildCredentials()` — minted immudb + crontabs keypairs\n * 2. `SecretsRotation.rotate()` — rotated NEITHER of them\n * 3. `SecretsReader.AUTO_GENERATED_KEYS` — knew immudb, not crontabs\n * 4. (no backfill path existed at all)\n *\n * That produced two silent, security-relevant degradations in the wild:\n *\n * - the crontabs-batches-manager P2P signing keypair was absent, so crontabs signed\n * job tokens with a fallback key and every scheduled tick dead-lettered; and\n * - the immudb state-signing keypair was absent, so the self-hosted immudb ran\n * WITHOUT `--signingKey` and the audit client logged \"state-signature pinning is\n * OFF\" — a whole-server substitution of the tamper-evident audit store was not\n * cryptographically detectable.\n *\n * The fix is structural, not per-material: declare each material ONCE here, derive\n * minting / provisioning / rotation / classification from that declaration, and run the\n * idempotent {@link provisionFrameworkManagedSecrets} on the paths that already\n * regenerate derived artifacts. A material added in the future is then live in every\n * environment on the next `wildo local dev` / `wildo config sync`, with no per-material\n * migration to remember.\n *\n * ## Provisioning is ADDITIVE — it is not rotation\n *\n * Provisioning mints ONLY material that is absent (or blank) and never touches material\n * that is already present. That makes it safe to run unattended on every self-heal:\n * nothing that an existing deployment depends on can change underneath it. Rotation\n * ({@link rotateFrameworkManagedSecrets}) is the destructive counterpart and stays\n * behind the explicit `wildo config sync --rotate-secrets` opt-in.\n *\n * ## Identity halves vs secret halves\n *\n * A material can own more than one key. `identityKeys` are non-secret constants (service\n * usernames) written at provisioning time and PRESERVED across rotation; `secretKeys`\n * are the generated-secret halves — they are what rotation regenerates, what the CLI\n * masks on display, and what `SecretsReader.isAutoGenerated()` reports.\n */\n\nimport { CredentialGenerator } from '@wildo-ai/platform-config-lib';\n\nimport {\n DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME,\n type PlatformEnvSecretsJson,\n} from '~wildo-cli/services/credentials/credentials.schemas';\n\n/**\n * `secrets.json` as it exists BEFORE framework-managed material has been provisioned:\n * every framework-owned branch may be absent or partially filled, while the\n * operator-typed branches (`admin` identity, `providerEnv`, `atlas`, `github`) carry\n * whatever the caller already knows.\n *\n * One level of partiality is deliberate and sufficient: a material provisions its whole\n * leaf object at once (e.g. `platform.appsManager` is written as a complete keypair),\n * so no material ever observes a half-filled nested object.\n */\nexport type PlatformEnvSecretsDraft = {\n [K in keyof PlatformEnvSecretsJson]?: NonNullable<PlatformEnvSecretsJson[K]> extends Record<string, unknown>\n ? Partial<NonNullable<PlatformEnvSecretsJson[K]>>\n : PlatformEnvSecretsJson[K];\n};\n\n/**\n * Closed vocabulary of framework-generated credential materials. A material is the unit\n * of provisioning: the smallest set of keys that MUST be minted together (a keypair's two\n * halves are useless apart, a username is useless without its password).\n */\nexport enum FrameworkManagedSecretMaterialRef {\n MONGODB_ROOT_CREDENTIAL = 'mongodb-root-credential',\n VALKEY_ADMIN_CREDENTIAL = 'valkey-admin-credential',\n POSTGRESQL_ADMIN_CREDENTIAL = 'postgresql-admin-credential',\n RABBITMQ_ADMIN_CREDENTIAL = 'rabbitmq-admin-credential',\n RABBITMQ_ERLANG_COOKIE = 'rabbitmq-erlang-cookie',\n STORAGE_ACCESS_CREDENTIAL = 'storage-access-credential',\n PLATFORM_PRIMARY_SECRET = 'platform-primary-secret',\n PLATFORM_ADMIN_SECRET = 'platform-admin-secret',\n PLATFORM_APPS_MANAGER_SIGNING_KEYPAIR = 'platform-apps-manager-signing-keypair',\n PLATFORM_CRONTABS_BATCHES_MANAGER_SIGNING_KEYPAIR = 'platform-crontabs-batches-manager-signing-keypair',\n IMMUDB_STATE_SIGNING_KEYPAIR = 'immudb-state-signing-keypair',\n MONGOT_SYNC_SOURCE_CREDENTIAL = 'mongot-sync-source-credential',\n ADMIN_PASSWORD = 'admin-password',\n}\n\n/**\n * Declaration of one framework-generated credential material.\n *\n * Every material is rotatable — that IS the contract of \"auto-generated\" (the operator\n * never typed it, so regenerating it costs only a redeploy). Should a future material\n * ever be genuinely un-rotatable, add an explicit policy axis here rather than silently\n * omitting it from {@link rotateFrameworkManagedSecrets} — a silent omission is exactly\n * the drift this registry exists to prevent.\n */\nexport interface FrameworkManagedSecretMaterial {\n readonly ref: FrameworkManagedSecretMaterialRef;\n /** Non-secret identity keys (service usernames) — written on provisioning, preserved on rotation. */\n readonly identityKeys: readonly string[];\n /** Generated-secret keys — written on provisioning AND regenerated on rotation. */\n readonly secretKeys: readonly string[];\n /** Why this material exists, in one line (surfaced by CLI reporting). */\n readonly purpose: string;\n /** True when every key this material owns is present and non-blank. */\n isProvisioned(secrets: PlatformEnvSecretsDraft): boolean;\n /** Write the COMPLETE material (identity + secret halves). Called only when not provisioned. */\n provision(secrets: PlatformEnvSecretsDraft): void;\n /** Regenerate the secret halves in place, preserving identity halves. */\n rotate(secrets: PlatformEnvSecretsDraft): void;\n}\n\n/** A string counts as present only when it carries actual material — `''` is as broken as absent. */\nfunction isFilled(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0;\n}\n\nexport const FRAMEWORK_MANAGED_SECRET_MATERIALS = [\n {\n ref: FrameworkManagedSecretMaterialRef.MONGODB_ROOT_CREDENTIAL,\n identityKeys: ['mongodb.rootUser'],\n secretKeys: ['mongodb.rootPassword'],\n purpose: 'Root credential for the self-hosted MongoDB backing service.',\n isProvisioned: (s) => isFilled(s.mongodb?.rootUser) && isFilled(s.mongodb?.rootPassword),\n provision: (s) => {\n s.mongodb = {\n rootUser: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.MONGODB_ROOT_USER,\n rootPassword: CredentialGenerator.generatePassword(24),\n };\n },\n rotate: (s) => {\n if (s.mongodb) s.mongodb.rootPassword = CredentialGenerator.generatePassword(24);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.VALKEY_ADMIN_CREDENTIAL,\n identityKeys: ['valkey.adminUser'],\n secretKeys: ['valkey.adminPassword'],\n purpose: 'Admin credential for the self-hosted Valkey/Redis backing service.',\n isProvisioned: (s) => isFilled(s.valkey?.adminUser) && isFilled(s.valkey?.adminPassword),\n provision: (s) => {\n s.valkey = {\n adminUser: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.VALKEY_ADMIN_USER,\n adminPassword: CredentialGenerator.generatePassword(32),\n };\n },\n rotate: (s) => {\n if (s.valkey) s.valkey.adminPassword = CredentialGenerator.generatePassword(32);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.POSTGRESQL_ADMIN_CREDENTIAL,\n identityKeys: ['postgresql.adminUser'],\n secretKeys: ['postgresql.adminPassword'],\n purpose: 'Admin credential for the self-hosted PostgreSQL backing service.',\n isProvisioned: (s) => isFilled(s.postgresql?.adminUser) && isFilled(s.postgresql?.adminPassword),\n provision: (s) => {\n s.postgresql = {\n adminUser: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.PG_ADMIN_USER,\n adminPassword: CredentialGenerator.generatePassword(24),\n };\n },\n rotate: (s) => {\n if (s.postgresql) s.postgresql.adminPassword = CredentialGenerator.generatePassword(24);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.RABBITMQ_ADMIN_CREDENTIAL,\n identityKeys: ['rabbitmq.adminUsername'],\n secretKeys: ['rabbitmq.adminPassword'],\n purpose: 'Admin credential for the self-hosted RabbitMQ broker.',\n isProvisioned: (s) => isFilled(s.rabbitmq?.adminUsername) && isFilled(s.rabbitmq?.adminPassword),\n provision: (s) => {\n s.rabbitmq = {\n ...s.rabbitmq,\n adminUsername: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.RABBITMQ_ADMIN_USERNAME,\n adminPassword: CredentialGenerator.generatePassword(32),\n };\n },\n rotate: (s) => {\n if (s.rabbitmq) s.rabbitmq.adminPassword = CredentialGenerator.generatePassword(32);\n },\n },\n {\n // Separate material from the admin credential: the Erlang cookie is the CLUSTER\n // membership secret, not a login. It is provisioned/rotated independently so a\n // secrets.json that carries one but not the other self-heals to a complete broker\n // configuration instead of being silently half-configured.\n ref: FrameworkManagedSecretMaterialRef.RABBITMQ_ERLANG_COOKIE,\n identityKeys: [],\n secretKeys: ['rabbitmq.erlangCookie'],\n purpose: 'Erlang cluster cookie shared by every RabbitMQ node.',\n isProvisioned: (s) => isFilled(s.rabbitmq?.erlangCookie),\n provision: (s) => {\n s.rabbitmq = { ...s.rabbitmq, erlangCookie: CredentialGenerator.generateErlangCookie() };\n },\n rotate: (s) => {\n if (s.rabbitmq) s.rabbitmq.erlangCookie = CredentialGenerator.generateErlangCookie();\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.STORAGE_ACCESS_CREDENTIAL,\n identityKeys: ['storage.accessKey'],\n secretKeys: ['storage.secretKey'],\n purpose: 'Access key pair for the self-hosted MinIO object storage.',\n isProvisioned: (s) => isFilled(s.storage?.accessKey) && isFilled(s.storage?.secretKey),\n provision: (s) => {\n s.storage = {\n accessKey: DEFAULT_PLATFORM_ENV_INTERNAL_SERVICE_CREDENTIAL_USERNAME.MINIO_ACCESS_KEY,\n secretKey: CredentialGenerator.generatePassword(32),\n };\n },\n rotate: (s) => {\n if (s.storage) s.storage.secretKey = CredentialGenerator.generatePassword(32);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.PLATFORM_PRIMARY_SECRET,\n identityKeys: [],\n secretKeys: ['platform.primarySecret'],\n purpose: 'Primary shared platform secret.',\n isProvisioned: (s) => isFilled(s.platform?.primarySecret),\n provision: (s) => {\n s.platform = { ...s.platform, primarySecret: CredentialGenerator.generateSecret(48) };\n },\n rotate: (s) => {\n if (s.platform) s.platform.primarySecret = CredentialGenerator.generateSecret(48);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.PLATFORM_ADMIN_SECRET,\n identityKeys: [],\n secretKeys: ['platform.adminSecret'],\n purpose: 'Dedicated shared secret for admin operations (CLI <-> apps-manager).',\n isProvisioned: (s) => isFilled(s.platform?.adminSecret),\n provision: (s) => {\n s.platform = { ...s.platform, adminSecret: CredentialGenerator.generateSecret(48) };\n },\n rotate: (s) => {\n if (s.platform) s.platform.adminSecret = CredentialGenerator.generateSecret(48);\n },\n },\n {\n ref: FrameworkManagedSecretMaterialRef.PLATFORM_APPS_MANAGER_SIGNING_KEYPAIR,\n identityKeys: [],\n secretKeys: ['platform.appsManager.privateKey', 'platform.appsManager.publicKey'],\n purpose: \"apps-manager's P2P signing keypair (signs the JWTs it hands to every app).\",\n isProvisioned: (s) =>\n isFilled(s.platform?.appsManager?.privateKey) && isFilled(s.platform?.appsManager?.publicKey),\n provision: (s) => {\n const keys = CredentialGenerator.generateECKeyPair();\n s.platform = {\n ...s.platform,\n appsManager: { privateKey: keys.privateKey, publicKey: keys.publicKey },\n };\n },\n rotate: (s) => {\n if (!s.platform?.appsManager) return;\n const keys = CredentialGenerator.generateECKeyPair();\n s.platform.appsManager.privateKey = keys.privateKey;\n s.platform.appsManager.publicKey = keys.publicKey;\n },\n },\n {\n // Historically absent from `buildCredentials`, which is exactly why crontabs signed\n // every SCHEDULED_CRON / MINION_TICK token with a fallback key and apps handed out an\n // empty verify key — dead-lettering every tick. Declared here so an environment that\n // predates the keypair acquires it on the next self-heal.\n ref: FrameworkManagedSecretMaterialRef.PLATFORM_CRONTABS_BATCHES_MANAGER_SIGNING_KEYPAIR,\n identityKeys: [],\n secretKeys: [\n 'platform.crontabsBatchesManager.privateKey',\n 'platform.crontabsBatchesManager.publicKey',\n ],\n purpose: \"crontabs-batches-manager's P2P signing keypair (signs every scheduled job token).\",\n isProvisioned: (s) =>\n isFilled(s.platform?.crontabsBatchesManager?.privateKey)\n && isFilled(s.platform?.crontabsBatchesManager?.publicKey),\n provision: (s) => {\n const keys = CredentialGenerator.generateECKeyPair();\n s.platform = {\n ...s.platform,\n crontabsBatchesManager: { privateKey: keys.privateKey, publicKey: keys.publicKey },\n };\n },\n rotate: (s) => {\n if (!s.platform?.crontabsBatchesManager) return;\n const keys = CredentialGenerator.generateECKeyPair();\n s.platform.crontabsBatchesManager.privateKey = keys.privateKey;\n s.platform.crontabsBatchesManager.publicKey = keys.publicKey;\n },\n },\n {\n // The cryptographic whole-server-substitution defense for the tamper-evident audit\n // store. The PRIVATE half (SEC1 \"EC PRIVATE KEY\" PEM — the exact format immudb's\n // `--signingKey` parses) is mounted into the SELF-hosted immudb server ONLY; the\n // PUBLIC half (SPKI PEM) rides `IMMUDB_STATE_PUBLIC_KEY` into every app runtime so\n // the audit client can verify the server's signed `ImmutableState`. Absent material\n // means immudb runs UNSIGNED and the client degrades to \"pinning is OFF\".\n ref: FrameworkManagedSecretMaterialRef.IMMUDB_STATE_SIGNING_KEYPAIR,\n identityKeys: [],\n secretKeys: ['immudb.stateSigningPrivateKey', 'immudb.stateSigningPublicKey'],\n purpose: 'immudb state-signing keypair (audit-store whole-server-substitution defense).',\n isProvisioned: (s) =>\n isFilled(s.immudb?.stateSigningPrivateKey) && isFilled(s.immudb?.stateSigningPublicKey),\n provision: (s) => {\n const keys = CredentialGenerator.generateECKeyPair();\n s.immudb = { stateSigningPrivateKey: keys.privateKey, stateSigningPublicKey: keys.publicKey };\n },\n rotate: (s) => {\n if (!s.immudb) return;\n const keys = CredentialGenerator.generateECKeyPair();\n s.immudb.stateSigningPrivateKey = keys.privateKey;\n s.immudb.stateSigningPublicKey = keys.publicKey;\n },\n },\n {\n // Issue #74 — the SCRAM password `mongot` (the MongoDB 8.2 Search / Vector Search\n // sidecar) authenticates to mongod with. Declared as its OWN material rather than as a\n // third key on MONGODB_ROOT_CREDENTIAL, because `provision` REPLACES the whole section:\n // widening the root material's `isProvisioned` would make every existing environment\n // report unprovisioned and then re-mint `mongodb.rootPassword` on the next self-heal,\n // silently rotating the credential a running stack is already authenticated with.\n // Separate material ⇒ an environment that predates mongot acquires only what it lacks —\n // the same reasoning recorded on the crontabs-batches-manager keypair above.\n //\n // No identity key: the username is the code constant `MONGOT_SYNC_SOURCE.USERNAME`.\n // Alphanumeric + `_+-` (the shared password charset) is safe unquoted in the mongosh\n // `--eval` string, in a YAML scalar, and in a shell heredoc — all three of which this\n // value passes through before it reaches mongot.\n ref: FrameworkManagedSecretMaterialRef.MONGOT_SYNC_SOURCE_CREDENTIAL,\n identityKeys: [],\n secretKeys: ['mongot.syncSourcePassword'],\n purpose: \"mongot's SCRAM credential against mongod (the `searchCoordinator` sync-source user).\",\n isProvisioned: (s) => isFilled(s.mongot?.syncSourcePassword),\n provision: (s) => {\n s.mongot = { syncSourcePassword: CredentialGenerator.generatePassword(32) };\n },\n rotate: (s) => {\n if (s.mongot) s.mongot.syncSourcePassword = CredentialGenerator.generatePassword(32);\n },\n },\n {\n /*\n * The seeded administrators' password. The operator MAY type one at setup; when they do not,\n * the framework generates it. Only the password is framework-managed — the identity fields\n * (email / first / last name) are operator-authored and are NOT declared here, so provisioning\n * never invents an administrator identity.\n *\n * ONE MATERIAL, TWO ACCOUNTS, and that is the local convention rather than an oversight (#575).\n * An application-wide access grant is approved by a SECOND administrator — the two-person rule\n * refuses an approver who is its own requester — so a platform provisions two. Locally the\n * approver is sub-addressed from the administrator (`ada+approver@…`, same mailbox) and SHARES\n * this password, which makes the two-person rule ceremonial there. That is the accepted trade:\n * the alternative is a developer who cannot exercise an application-wide read at all. A remote\n * deployment states its approver, including a password of its own, and `provision` below fills\n * only what is empty, so a stated password is never overwritten.\n *\n * `s.approver` may legitimately be absent — the block is `.optional()` so a `secrets.json`\n * written before it existed still parses — and this material must then behave exactly as it\n * always did rather than conjuring an approver with no identity behind it.\n */\n ref: FrameworkManagedSecretMaterialRef.ADMIN_PASSWORD,\n identityKeys: [],\n /*\n * `admin.password` ONLY, even though `provision` also fills `approver.password`.\n *\n * A declared key is a promise that the key EXISTS after provisioning — the registry's own pins\n * read every declared key back and require it populated and rotatable, and they are what caught\n * the first version of this. `approver` is `.optional()` so a `secrets.json` predating it still\n * parses, so `approver.password` cannot make that promise. The four approver paths reach a\n * CI-reconstructed secrets file through `OPERATOR_TYPED_SECRET_PATHS` instead, which is the\n * honest home: remotely the approver's password IS operator-typed, and locally it is copied from\n * the administrator's rather than minted on its own.\n */\n secretKeys: ['admin.password'],\n purpose: 'Password of the seeded platform administrators (when not operator-supplied).',\n isProvisioned: (s) => isFilled(s.admin?.password) && (s.approver === undefined || isFilled(s.approver.password)),\n provision: (s) => {\n // Reuse an already-provisioned administrator password rather than minting a second one, so\n // that a run which only has to fill the approver's half does not silently rotate the\n // administrator's — a \"provisioning\" pass that changes a working credential is an outage.\n const password = isFilled(s.admin?.password) ? s.admin!.password! : CredentialGenerator.generatePassword(16);\n s.admin = { ...s.admin, password };\n if (s.approver !== undefined && !isFilled(s.approver.password)) {\n s.approver = { ...s.approver, password };\n }\n },\n rotate: (s) => {\n // Both to the SAME new value, preserving the shared-password convention across a rotation:\n // the local approver exists so one developer can sign both legs, and a rotation that split\n // them would leave that developer hunting a second password for no gain. Rotation is an\n // explicit operator act, so overwriting a stated remote password here is its job, not a\n // surprise.\n const password = CredentialGenerator.generatePassword(16);\n if (s.admin) s.admin.password = password;\n if (s.approver) s.approver.password = password;\n },\n },\n] as const satisfies readonly FrameworkManagedSecretMaterial[];\n\n/**\n * Compile-time assertion: every {@link FrameworkManagedSecretMaterialRef} member MUST be declared\n * in {@link FRAMEWORK_MANAGED_SECRET_MATERIALS}. Omitting one produces\n * `Type '\"…\"' is not assignable to type 'never'` pointing here.\n *\n * The enum was a closed vocabulary with no mechanical link to the list that realises it: the\n * annotation `readonly FrameworkManagedSecretMaterial[]` widened every `ref` back to the enum, so\n * declaring twelve of thirteen materials type-checked perfectly. `as const satisfies` keeps each\n * `ref` at its literal member type, which is what makes the `Exclude` below able to see a gap —\n * the same shape as `_AssertExhaustivePlatformServiceCoverage` in\n * `platform-infrastructure-manager.apps-manager.platform.service.ts`.\n *\n * This is the registry EVERY derived answer now reads — minting, rotation, auto-generated\n * classification, and (since the CI mapping was derived from it) which GitHub Secret a pipeline\n * must carry. A material declared here and forgotten there was exactly how the crontabs signing\n * keypair, the immudb state-signing keypair and the mongot sync-source credential were absent from\n * `FIXED_MAPPINGS`: minted on a developer machine, and silently never reconstructed in CI.\n */\ntype _DeclaredFrameworkManagedSecretMaterialRef = (typeof FRAMEWORK_MANAGED_SECRET_MATERIALS)[number]['ref'];\ntype _AssertExhaustiveFrameworkManagedSecretMaterialCoverage =\n Exclude<FrameworkManagedSecretMaterialRef, _DeclaredFrameworkManagedSecretMaterialRef> extends never ? true : never;\nconst _assertExhaustiveFrameworkManagedSecretMaterialCoverage: _AssertExhaustiveFrameworkManagedSecretMaterialCoverage = true;\nvoid _assertExhaustiveFrameworkManagedSecretMaterialCoverage;\n\n/**\n * Every generated-secret key across all materials, in declaration order. This is the\n * derived answer to \"is this key auto-generated?\" — consumed by `SecretsReader` for\n * masking and rotation reporting so that list can no longer drift from what is actually\n * minted. Identity keys (service usernames) are deliberately excluded: they are\n * non-secret constants, not generated material.\n */\nexport const FRAMEWORK_MANAGED_SECRET_KEYS: readonly string[] = FRAMEWORK_MANAGED_SECRET_MATERIALS\n .flatMap((material) => material.secretKeys);\n\n/** Outcome of {@link provisionFrameworkManagedSecrets}. */\nexport interface FrameworkManagedSecretsProvisioningResult {\n /** The same object that was passed in, now guaranteed complete. */\n secrets: PlatformEnvSecretsJson;\n /** Materials that were absent and have just been minted (empty ⇒ nothing changed). */\n mintedRefs: FrameworkManagedSecretMaterialRef[];\n /** Flattened keys written by `mintedRefs`, for operator-facing reporting. */\n mintedKeys: string[];\n}\n\n/**\n * Mint every framework-managed material that is absent (or blank) from `secrets`,\n * leaving everything already present untouched, and return what changed.\n *\n * IDEMPOTENT AND ADDITIVE by construction — running it twice mints nothing the second\n * time, and it can never invalidate a credential a running deployment already uses.\n * That is what makes it safe on unattended self-heal paths (`wildo local dev` /\n * `wildo local up` preflight, `wildo config sync`), unlike\n * {@link rotateFrameworkManagedSecrets}.\n *\n * Serves two callers with one code path:\n * - `buildCredentials()` passes a draft holding only operator-typed answers, and gets\n * back a complete `secrets.json`;\n * - the self-heal paths pass an already-parsed `secrets.json` and get back the same\n * object with the gaps filled.\n *\n * The returned `secrets` is narrowed to the complete `PlatformEnvSecretsJson` shape only\n * after a runtime completeness assertion over the registry — the narrowing is therefore\n * proven, not assumed. A material whose `provision()` fails to satisfy its own\n * `isProvisioned()` is a registry authoring bug and throws loudly here rather than\n * writing a half-provisioned secrets.json to disk.\n */\nexport function provisionFrameworkManagedSecrets(\n secrets: PlatformEnvSecretsDraft,\n): FrameworkManagedSecretsProvisioningResult {\n const mintedRefs: FrameworkManagedSecretMaterialRef[] = [];\n const mintedKeys: string[] = [];\n\n for (const material of FRAMEWORK_MANAGED_SECRET_MATERIALS) {\n if (material.isProvisioned(secrets)) continue;\n\n material.provision(secrets);\n\n if (!material.isProvisioned(secrets)) {\n throw new Error(\n `Framework-managed secret material '${material.ref}' did not satisfy its own provisioning check. `\n + 'This is a registry authoring bug in framework-managed-secrets.ts, not an environment problem.',\n );\n }\n\n mintedRefs.push(material.ref);\n mintedKeys.push(...material.identityKeys, ...material.secretKeys);\n }\n\n return { secrets: secrets as PlatformEnvSecretsJson, mintedRefs, mintedKeys };\n}\n\n/** Outcome of {@link rotateFrameworkManagedSecrets}. */\nexport interface FrameworkManagedSecretsRotationResult {\n /** Generated-secret keys that were regenerated. */\n rotatedKeys: string[];\n /** Identity keys deliberately preserved (service usernames). */\n preservedIdentityKeys: string[];\n}\n\n/**\n * Regenerate the secret half of every framework-managed material, preserving identity\n * halves (service usernames) and every operator-typed value (admin identity, provider\n * API keys, GitHub tokens, Atlas API keys) — those are simply not in the registry.\n *\n * DESTRUCTIVE: every rotated credential must be redeployed to the services that hold\n * the other end. Callers gate this behind an explicit operator opt-in.\n *\n * Any material still absent is provisioned first, so a rotation of a partially\n * provisioned environment yields a COMPLETE secrets.json rather than silently skipping\n * the gaps (the previous hand-written rotation skipped whatever it had not been taught\n * about, which is how the immudb and crontabs keypairs stayed missing through rotations).\n */\nexport function rotateFrameworkManagedSecrets(\n secrets: PlatformEnvSecretsDraft,\n): FrameworkManagedSecretsRotationResult {\n const { mintedKeys } = provisionFrameworkManagedSecrets(secrets);\n const mintedKeySet = new Set(mintedKeys);\n\n const rotatedKeys: string[] = [];\n const preservedIdentityKeys: string[] = [];\n\n for (const material of FRAMEWORK_MANAGED_SECRET_MATERIALS) {\n // A material minted moments ago by the provisioning pass above is already fresh —\n // rotating it again would only burn entropy and confuse the operator-facing report.\n const wasJustMinted = material.secretKeys.every((key) => mintedKeySet.has(key));\n if (!wasJustMinted) {\n material.rotate(secrets);\n }\n rotatedKeys.push(...material.secretKeys);\n preservedIdentityKeys.push(...material.identityKeys);\n }\n\n return { rotatedKeys, preservedIdentityKeys };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"infra-writer.service.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/infra-writer.service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAG7F,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EACzC,MAAM,qEAAqE,CAAC;AAI7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,gCAAgC,EACrC,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,OAAO,EAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,WAAW,EAAE,sBAAsB,EACnC,GAAG,EAAE,MAAM,EACX,mBAAmB,CAAC,EAAE,2BAA2B,EAAE,EACnD,aAAa,CAAC,EAAE,0BAA0B,EAAE,EAC5C,oBAAoB,CAAC,EAAE,mCAAmC,EAAE,GAC3D,OAAO,CAAC,IAAI,CAAC,CAyEf"}
1
+ {"version":3,"file":"infra-writer.service.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/infra-writer.service.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAG7F,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EACzC,MAAM,qEAAqE,CAAC;AAI7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,gCAAgC,EACrC,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,OAAO,EAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,WAAW,EAAE,sBAAsB,EACnC,GAAG,EAAE,MAAM,EACX,mBAAmB,CAAC,EAAE,2BAA2B,EAAE,EACnD,aAAa,CAAC,EAAE,0BAA0B,EAAE,EAC5C,oBAAoB,CAAC,EAAE,mCAAmC,EAAE,GAC3D,OAAO,CAAC,IAAI,CAAC,CAkGf"}
@@ -25,10 +25,29 @@ export async function runInfraWrite(env, frameworkPath, isFrameworkDeveloper, im
25
25
  generateEnvWildoPlatform(env, isFrameworkDeveloper, credentials);
26
26
  log.success(chalk.green(' ✓ .env.wildo-platform written'));
27
27
  }
28
- if (isFrameworkDeveloper) {
29
- generatePlatformServiceEnvFiles(env, frameworkPath, credentials, log, applicationBackends, companionApis, applicationFrontends);
30
- log.success(chalk.green(' ✓ Platform service .env files generated'));
31
- }
28
+ /*
29
+ * ALWAYS write the APPLICATION's own runtime env; skip only the SHARED platform-service files.
30
+ *
31
+ * This whole call used to sit behind `if (isFrameworkDeveloper)`, and the gate is half right: the
32
+ * apps-manager / module-registry / crontabs `.env` files are anchored in the FRAMEWORK CHECKOUT
33
+ * and belong to that lane — an app creator runs those services as containers fed by
34
+ * `.env.wildo-platform`. But the application's own backend, companion and frontend targets are
35
+ * anchored on the APPLICATION root, and the gate took them down with the platform ones.
36
+ *
37
+ * The consequence was silent and total: an app-creator application got NO per-service `.env` at
38
+ * all (measured 2026-09-10 — `wonder-todos` has six, a freshly created app-creator application
39
+ * has zero). `wildo local dev` then compiled everything and started nothing usable: the companion
40
+ * died on `APPLICATION_ID / SERVICE_NAME / PLATFORM_ENVIRONMENT_ID` undefined, while `local init`
41
+ * had just reported "Application runtime materialized: 1 backend, 1 companion, 1 frontend".
42
+ *
43
+ * `skipPlatformServiceEnvs` is the seam for exactly this and already existed — it was added for
44
+ * the foreign-platform-owner case (issue #50), where the app's own targets must still be written
45
+ * while another session owns the shared files. Same shape, second caller.
46
+ */
47
+ generatePlatformServiceEnvFiles(env, frameworkPath, credentials, log, applicationBackends, companionApis, applicationFrontends, undefined, undefined, undefined, { skipPlatformServiceEnvs: !isFrameworkDeveloper });
48
+ log.success(chalk.green(isFrameworkDeveloper
49
+ ? ' ✓ Platform service .env files generated'
50
+ : ' ✓ Application runtime .env files generated'));
32
51
  if (runtime === WildoDeploymentRuntime.KUBERNETES) {
33
52
  // No `applicationMinions` / `applicationWorkers`, and that is a stated result rather than an
34
53
  // omission (#369): this writer is the interactive `wildo setup` lane, whose only caller passes
@@ -1 +1 @@
1
- {"version":3,"file":"infra-writer.service.js","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AAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnF,KAAK,MAAM,QAAQ,IAAI,cAAc,EAAE,CAAC;YACtC,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5D,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAClD,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,OAAO,CAAC,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxE,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,4BAA4B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC;IACtG,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { mkdirSync, rmSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport { PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport { generateEnvWildoPlatform, renderDockerComposeTemplate } from '~wildo-cli/services/deployment/docker/docker-compose-generator.service';\nimport {\n generatePlatformServiceEnvFiles,\n type ApplicationBackendEnvTarget,\n type CompanionPlatformEnvTarget,\n type ApplicationFrontendEnvExampleTarget,\n} from '~wildo-cli/services/environment/env-configuration-generator.service';\nimport { EnvironmentPaths } from '~wildo-cli/services/environment/environment-paths.service';\nimport { WildoDeploymentRuntime } from '@wildo-ai/platform-config-lib';\nimport { generateK8sSecrets } from '~wildo-cli/services/deployment/k8s/k8s-secrets-generator.service';\nimport type { Logger } from '~wildo-cli/kernel/types';\n\n/**\n * Phase 2 — infrastructure file write.\n *\n * Branches on `env.runtime`:\n * - Docker Compose → docker-compose template, .env.wildo-platform, service .env files\n * - Kubernetes → K8s secret YAMLs only (manifests are generated during bootstrap)\n *\n * Platform service .env files are generated for framework developers regardless\n * of runtime (they run services natively with hot-reload).\n */\nexport async function runInfraWrite(\n env: PlatformEnvironmentConfiguration,\n frameworkPath: string,\n isFrameworkDeveloper: boolean,\n imageTag: string | undefined,\n credentials: PlatformEnvSecretsJson,\n log: Logger,\n applicationBackends?: ApplicationBackendEnvTarget[],\n companionApis?: CompanionPlatformEnvTarget[],\n applicationFrontends?: ApplicationFrontendEnvExampleTarget[],\n): Promise<void> {\n const runtime = env.runtime;\n\n if (runtime === WildoDeploymentRuntime.DOCKER_COMPOSE) {\n await renderDockerComposeTemplate(env, frameworkPath, isFrameworkDeveloper, imageTag);\n log.success(chalk.green(` ✓ ${FILE_NAMES.DOCKER_COMPOSE_WILDO_PLATFORM} rendered`));\n\n generateEnvWildoPlatform(env, isFrameworkDeveloper, credentials);\n log.success(chalk.green(' ✓ .env.wildo-platform written'));\n }\n\n if (isFrameworkDeveloper) {\n generatePlatformServiceEnvFiles(\n env,\n frameworkPath,\n credentials,\n log,\n applicationBackends,\n companionApis,\n applicationFrontends,\n );\n log.success(chalk.green(' ✓ Platform service .env files generated'));\n }\n\n if (runtime === WildoDeploymentRuntime.KUBERNETES) {\n // No `applicationMinions` / `applicationWorkers`, and that is a stated result rather than an\n // omission (#369): this writer is the interactive `wildo setup` lane, whose only caller passes\n // no `applicationBackends` either, so it emits platform and infrastructure Secrets and no\n // application-tier ones at all. The lane that deploys an application's runtimes is\n // `ci-deploy-generator`, and that is where the per-runtime provider Secrets are wired.\n // Threading empty target lists through here would look wired and deliver nothing.\n const k8sResources = generateK8sSecrets(env, credentials, {\n applicationBackends,\n isFrameworkDeveloper,\n });\n const infraPath = EnvironmentPaths.resolveInfraDir(env.name);\n const secretsOutputDir = join(infraPath, 'secrets');\n const categoryDirs: Record<string, string> = {\n platform: join(secretsOutputDir, 'platform'),\n infrastructure: secretsOutputDir,\n application: join(secretsOutputDir, 'applications'),\n };\n\n // Always wipe the platform/ subdir so a previous run that emitted\n // platform-service Secrets/ConfigMaps doesn't leak stale files when\n // the framework-developer toggle (or runtime policy) flips and this\n // run no longer emits any platform-category resource. We don't wipe\n // application/ symmetrically because per-app Secret files are owned\n // jointly with apps-manager's dynamic lane and pruning belongs to a\n // dedicated reaper, not the writer.\n mkdirSync(secretsOutputDir, { recursive: true });\n rmSync(categoryDirs.platform, { recursive: true, force: true });\n\n // Create exactly the dirs the emitted resources need. Deriving from\n // `k8sResources` keeps the writer honest about category routing —\n // any future generator-side category relabel automatically routes\n // here without a parallel writer-side flag (the bug the M-2/HIGH-1\n // round-3 fix closed: the then-shared `providers-secret` was emitted as\n // 'platform' but landed in `secrets/platform/` only when\n // `includePlatformResources` happened to be true at the writer side —\n // that Secret no longer exists, replaced by one per runtime in #369, and\n // the routing lesson is what the derivation below preserves).\n const usedCategories = new Set(Object.values(k8sResources).map((r) => r.category));\n for (const category of usedCategories) {\n mkdirSync(categoryDirs[category], { recursive: true });\n }\n\n for (const [name, resource] of Object.entries(k8sResources)) {\n const targetDir = categoryDirs[resource.category];\n writeFileSync(join(targetDir, `${name}.yaml`), resource.yaml, 'utf8');\n }\n log.success(chalk.green(` ✓ K8s secrets written (${Object.keys(k8sResources).length} resources)`));\n }\n}\n"]}
1
+ {"version":3,"file":"infra-writer.service.js","sourceRoot":"","sources":["../../../../src/services/deployment/infra-writer.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM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AC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnF,KAAK,MAAM,QAAQ,IAAI,cAAc,EAAE,CAAC;YACtC,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5D,MAAM,SAAS,GAAG,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAClD,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,OAAO,CAAC,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxE,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,4BAA4B,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC;IACtG,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { mkdirSync, rmSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport { PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport { generateEnvWildoPlatform, renderDockerComposeTemplate } from '~wildo-cli/services/deployment/docker/docker-compose-generator.service';\nimport {\n generatePlatformServiceEnvFiles,\n type ApplicationBackendEnvTarget,\n type CompanionPlatformEnvTarget,\n type ApplicationFrontendEnvExampleTarget,\n} from '~wildo-cli/services/environment/env-configuration-generator.service';\nimport { EnvironmentPaths } from '~wildo-cli/services/environment/environment-paths.service';\nimport { WildoDeploymentRuntime } from '@wildo-ai/platform-config-lib';\nimport { generateK8sSecrets } from '~wildo-cli/services/deployment/k8s/k8s-secrets-generator.service';\nimport type { Logger } from '~wildo-cli/kernel/types';\n\n/**\n * Phase 2 — infrastructure file write.\n *\n * Branches on `env.runtime`:\n * - Docker Compose → docker-compose template, .env.wildo-platform, service .env files\n * - Kubernetes → K8s secret YAMLs only (manifests are generated during bootstrap)\n *\n * Platform service .env files are generated for framework developers regardless\n * of runtime (they run services natively with hot-reload).\n */\nexport async function runInfraWrite(\n env: PlatformEnvironmentConfiguration,\n frameworkPath: string,\n isFrameworkDeveloper: boolean,\n imageTag: string | undefined,\n credentials: PlatformEnvSecretsJson,\n log: Logger,\n applicationBackends?: ApplicationBackendEnvTarget[],\n companionApis?: CompanionPlatformEnvTarget[],\n applicationFrontends?: ApplicationFrontendEnvExampleTarget[],\n): Promise<void> {\n const runtime = env.runtime;\n\n if (runtime === WildoDeploymentRuntime.DOCKER_COMPOSE) {\n await renderDockerComposeTemplate(env, frameworkPath, isFrameworkDeveloper, imageTag);\n log.success(chalk.green(` ✓ ${FILE_NAMES.DOCKER_COMPOSE_WILDO_PLATFORM} rendered`));\n\n generateEnvWildoPlatform(env, isFrameworkDeveloper, credentials);\n log.success(chalk.green(' ✓ .env.wildo-platform written'));\n }\n\n /*\n * ALWAYS write the APPLICATION's own runtime env; skip only the SHARED platform-service files.\n *\n * This whole call used to sit behind `if (isFrameworkDeveloper)`, and the gate is half right: the\n * apps-manager / module-registry / crontabs `.env` files are anchored in the FRAMEWORK CHECKOUT\n * and belong to that lane — an app creator runs those services as containers fed by\n * `.env.wildo-platform`. But the application's own backend, companion and frontend targets are\n * anchored on the APPLICATION root, and the gate took them down with the platform ones.\n *\n * The consequence was silent and total: an app-creator application got NO per-service `.env` at\n * all (measured 2026-09-10 — `wonder-todos` has six, a freshly created app-creator application\n * has zero). `wildo local dev` then compiled everything and started nothing usable: the companion\n * died on `APPLICATION_ID / SERVICE_NAME / PLATFORM_ENVIRONMENT_ID` undefined, while `local init`\n * had just reported \"Application runtime materialized: 1 backend, 1 companion, 1 frontend\".\n *\n * `skipPlatformServiceEnvs` is the seam for exactly this and already existed — it was added for\n * the foreign-platform-owner case (issue #50), where the app's own targets must still be written\n * while another session owns the shared files. Same shape, second caller.\n */\n generatePlatformServiceEnvFiles(\n env,\n frameworkPath,\n credentials,\n log,\n applicationBackends,\n companionApis,\n applicationFrontends,\n undefined,\n undefined,\n undefined,\n { skipPlatformServiceEnvs: !isFrameworkDeveloper },\n );\n log.success(chalk.green(\n isFrameworkDeveloper\n ? ' ✓ Platform service .env files generated'\n : ' ✓ Application runtime .env files generated',\n ));\n\n if (runtime === WildoDeploymentRuntime.KUBERNETES) {\n // No `applicationMinions` / `applicationWorkers`, and that is a stated result rather than an\n // omission (#369): this writer is the interactive `wildo setup` lane, whose only caller passes\n // no `applicationBackends` either, so it emits platform and infrastructure Secrets and no\n // application-tier ones at all. The lane that deploys an application's runtimes is\n // `ci-deploy-generator`, and that is where the per-runtime provider Secrets are wired.\n // Threading empty target lists through here would look wired and deliver nothing.\n const k8sResources = generateK8sSecrets(env, credentials, {\n applicationBackends,\n isFrameworkDeveloper,\n });\n const infraPath = EnvironmentPaths.resolveInfraDir(env.name);\n const secretsOutputDir = join(infraPath, 'secrets');\n const categoryDirs: Record<string, string> = {\n platform: join(secretsOutputDir, 'platform'),\n infrastructure: secretsOutputDir,\n application: join(secretsOutputDir, 'applications'),\n };\n\n // Always wipe the platform/ subdir so a previous run that emitted\n // platform-service Secrets/ConfigMaps doesn't leak stale files when\n // the framework-developer toggle (or runtime policy) flips and this\n // run no longer emits any platform-category resource. We don't wipe\n // application/ symmetrically because per-app Secret files are owned\n // jointly with apps-manager's dynamic lane and pruning belongs to a\n // dedicated reaper, not the writer.\n mkdirSync(secretsOutputDir, { recursive: true });\n rmSync(categoryDirs.platform, { recursive: true, force: true });\n\n // Create exactly the dirs the emitted resources need. Deriving from\n // `k8sResources` keeps the writer honest about category routing —\n // any future generator-side category relabel automatically routes\n // here without a parallel writer-side flag (the bug the M-2/HIGH-1\n // round-3 fix closed: the then-shared `providers-secret` was emitted as\n // 'platform' but landed in `secrets/platform/` only when\n // `includePlatformResources` happened to be true at the writer side —\n // that Secret no longer exists, replaced by one per runtime in #369, and\n // the routing lesson is what the derivation below preserves).\n const usedCategories = new Set(Object.values(k8sResources).map((r) => r.category));\n for (const category of usedCategories) {\n mkdirSync(categoryDirs[category], { recursive: true });\n }\n\n for (const [name, resource] of Object.entries(k8sResources)) {\n const targetDir = categoryDirs[resource.category];\n writeFileSync(join(targetDir, `${name}.yaml`), resource.yaml, 'utf8');\n }\n log.success(chalk.green(` ✓ K8s secrets written (${Object.keys(k8sResources).length} resources)`));\n }\n}\n"]}
@@ -3,7 +3,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs';
3
3
  import { join } from 'path';
4
4
  import { tmpdir } from 'os';
5
5
  import { RuntimeEnvironment } from '@wildo-ai/saas-models';
6
- import { WildoDeploymentRuntime, WildoLocationType } from '@wildo-ai/platform-config-lib';
6
+ import { AppsManagerMode, WildoDeploymentRuntime, WildoLocationType } from '@wildo-ai/platform-config-lib';
7
7
  vi.mock('child_process', () => ({
8
8
  spawnSync: vi.fn(),
9
9
  }));
@@ -52,7 +52,7 @@ import { generateK8sSecrets } from '../../../../services/deployment/k8s/k8s-secr
52
52
  import { shouldDeployPlatformServicesInRuntime } from '../../../../services/deployment/platform-runtime-policy.service.js';
53
53
  import { EnvironmentPaths } from '../../../../services/environment/environment-paths.service.js';
54
54
  import { spawnSync } from 'child_process';
55
- import { runK8sBootstrap } from '../k8s-bootstrap.service.js';
55
+ import { buildAppsManagerInitEnv, runK8sBootstrap } from '../k8s-bootstrap.service.js';
56
56
  describe('runK8sBootstrap', () => {
57
57
  const tempDirs = [];
58
58
  const logger = {
@@ -232,4 +232,47 @@ describe('runK8sBootstrap', () => {
232
232
  }, logger)).rejects.toThrow('K8s bootstrap requires a targeted app root to resolve local runtime storage.');
233
233
  });
234
234
  });
235
+ /*
236
+ * The k8s lane's half of a contract apps-manager enforces FAIL-CLOSED.
237
+ *
238
+ * `init-mode-startup.apps-manager.service.ts` refuses INIT when `ADMIN_EMAIL`, `ADMIN_PASSWORD`,
239
+ * `ADMIN_FIRST_NAME` or `ADMIN_LAST_NAME` is absent, each with its own message. This lane wrote the
240
+ * first two and stopped; the compose lane (`env-vars-builder.service.ts`) has always written all
241
+ * four. Two hand-written mappings for one contract, and only the lane everyone runs was complete.
242
+ *
243
+ * Pinned on the BUILDER rather than through `runK8sBootstrap`, because phase 5 is unreachable in a
244
+ * unit test without standing up five earlier phases — which is precisely why an inline object
245
+ * literal there went unchecked for as long as it did.
246
+ */
247
+ describe('buildAppsManagerInitEnv', () => {
248
+ const credentials = {
249
+ admin: {
250
+ email: 'ada@example.com',
251
+ password: 'correct-horse-battery-staple',
252
+ firstName: 'Ada',
253
+ lastName: 'Lovelace',
254
+ },
255
+ };
256
+ it('carries every identity key apps-manager INIT requires fail-closed', () => {
257
+ expect(buildAppsManagerInitEnv(credentials)).toEqual({
258
+ APPS_MANAGER_MODE: AppsManagerMode.INIT,
259
+ ADMIN_EMAIL: 'ada@example.com',
260
+ ADMIN_PASSWORD: 'correct-horse-battery-staple',
261
+ ADMIN_FIRST_NAME: 'Ada',
262
+ ADMIN_LAST_NAME: 'Lovelace',
263
+ });
264
+ });
265
+ /*
266
+ * GUARDS THE GUARD. The assertion above is an `toEqual`, so it already fails on a dropped key —
267
+ * but it would also pass if someone renamed a key on BOTH sides at once. This states the
268
+ * requirement as a SET, in the words apps-manager's own refusals use, so the pin keeps meaning
269
+ * what it says even if the object literal above is rewritten.
270
+ */
271
+ it('names the four keys apps-manager refuses INIT without', () => {
272
+ const env = buildAppsManagerInitEnv(credentials);
273
+ for (const key of ['ADMIN_EMAIL', 'ADMIN_PASSWORD', 'ADMIN_FIRST_NAME', 'ADMIN_LAST_NAME']) {
274
+ expect(env[key], `${key} is required by init-mode-startup.apps-manager.service.ts`).toBeTruthy();
275
+ }
276
+ });
277
+ });
235
278
  //# sourceMappingURL=k8s-bootstrap.service.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"k8s-bootstrap.service.test.js","sourceRoot":"","sources":["../../../../../../../../src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAE1F,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9B,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;CACnB,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE,CAAC,CAAC;IAChE,WAAW,EAAE;QACX,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;QACtB,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE;QACjC,qBAAqB,EAAE,EAAE,CAAC,EAAE,EAAE;QAC9B,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;QACtB,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;QACzB,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;QACtB,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE,CAAC,EAAE,EAAE;QAC1B,oBAAoB,EAAE,EAAE,CAAC,EAAE,EAAE;KAC9B;CACF,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,mEAAmE,EAAE,GAAG,EAAE,CAAC,CAAC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ACzD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CACvC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAC/C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC3D,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,eAAe,CAAC,kCAAkC,CAAC,CAAC;QAEhG,MAAM,MAAM,CAAC,eAAe,CAC1B;YACE,IAAI,EAAE,OAAO;YACb,YAAY,EAAE,iBAAiB,CAAC,KAAK;YACrC,OAAO,EAAE,sBAAsB,CAAC,UAAU;YAC1C,kBAAkB,EAAE,kBAAkB,CAAC,WAAW;YAClD,YAAY,EAAE,kBAAkB;YAChC,UAAU,EAAE;gBACV,SAAS,EAAE,aAAa;aACzB;SACO,EACV,OAAO,EACP,EAAW,EACX;YACE,QAAQ,EAAE,KAAK;SACP,EACV,MAAM,CACP,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,8EAA8E,CAAC,CAAC;IACrG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { afterEach, describe, expect, it, vi } from 'vitest';\nimport { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { tmpdir } from 'os';\nimport { RuntimeEnvironment } from '@wildo-ai/saas-models';\nimport { WildoDeploymentRuntime, WildoLocationType } from '@wildo-ai/platform-config-lib';\n\nvi.mock('child_process', () => ({\n spawnSync: vi.fn(),\n}));\n\nvi.mock('~wildo-cli/services/deployment/k8s/kind.service', () => ({\n KindService: {\n clusterExists: vi.fn(),\n getMountedLocalDataRoots: vi.fn(),\n localDataMountMatches: vi.fn(),\n deleteCluster: vi.fn(),\n getClusterStatus: vi.fn(),\n createCluster: vi.fn(),\n startCluster: vi.fn(),\n waitForNodesReady: vi.fn(),\n checkImageInRegistry: vi.fn(),\n },\n}));\n\nvi.mock('~wildo-cli/services/deployment/k8s/k8s-manifest-generator.service', () => ({\n K8sManifestGenerator: {\n renderAllManifests: vi.fn(() => ({\n total: 0,\n dirs: {\n cluster: '/tmp/cluster',\n internal: '/tmp/internal',\n platform: '/tmp/platform',\n applications: '/tmp/applications',\n storage: '/tmp/storage',\n },\n })),\n },\n}));\n\nvi.mock('~wildo-cli/services/deployment/k8s/k8s-secrets-generator.service', () => ({\n generateK8sSecrets: vi.fn(() => ({})),\n}));\n\nvi.mock('~wildo-cli/services/deployment/platform-runtime-policy.service', () => ({\n shouldDeployPlatformServicesInRuntime: vi.fn(() => false),\n}));\n\nvi.mock('~wildo-cli/services/environment/environment-paths.service', () => ({\n EnvironmentPaths: {\n resolveInfraDir: vi.fn(),\n resolveScopedLocalDataDir: vi.fn(),\n },\n}));\n\nimport { KindService } from '~wildo-cli/services/deployment/k8s/kind.service';\nimport { K8sManifestGenerator } from '~wildo-cli/services/deployment/k8s/k8s-manifest-generator.service';\nimport { generateK8sSecrets } from '~wildo-cli/services/deployment/k8s/k8s-secrets-generator.service';\nimport { shouldDeployPlatformServicesInRuntime } from '~wildo-cli/services/deployment/platform-runtime-policy.service';\nimport { EnvironmentPaths } from '~wildo-cli/services/environment/environment-paths.service';\nimport { spawnSync } from 'child_process';\nimport { runK8sBootstrap } from '../k8s-bootstrap.service';\n\ndescribe('runK8sBootstrap', () => {\n const tempDirs: string[] = [];\n const logger = {\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n success: vi.fn(),\n };\n\n afterEach(() => {\n vi.restoreAllMocks();\n vi.clearAllMocks();\n for (const dir of tempDirs.splice(0)) {\n rmSync(dir, { recursive: true, force: true });\n }\n });\n\n it('recreates an existing cluster when reset applies the local_data mount cutover', async () => {\n const infraRoot = mkdtempSync(join(tmpdir(), 'wildo-k8s-bootstrap-'));\n tempDirs.push(infraRoot);\n const localDataRoot = '/repo/apps/wonder-todos/.wildo-saas/local_data';\n\n vi.mocked(EnvironmentPaths.resolveInfraDir).mockReturnValue(infraRoot);\n vi.mocked(EnvironmentPaths.resolveScopedLocalDataDir).mockReturnValue(localDataRoot);\n vi.mocked(KindService.checkImageInRegistry).mockReturnValue(true);\n vi.mocked(KindService.clusterExists).mockReturnValue(true);\n // Legacy hyphenated path (`.wildo-saas/local-data`) represents the\n // post-flattening / pre-Slice-4 mount the cluster was created with.\n // It MUST mismatch the current `local_data` (underscored) target so\n // the bootstrap takes the \"recreate cluster\" path.\n vi.mocked(KindService.getMountedLocalDataRoots).mockReturnValue([\n '/repo/apps/wonder-todos/.wildo-saas/local-data',\n ]);\n vi.mocked(KindService.localDataMountMatches).mockReturnValue(false);\n vi.mocked(KindService.deleteCluster).mockReturnValue({ success: true });\n vi.mocked(KindService.getClusterStatus).mockReturnValue({\n exists: false,\n running: false,\n nodesReady: false,\n nodes: [],\n registry: {\n exists: true,\n running: true,\n accessible: true,\n },\n });\n vi.mocked(KindService.createCluster).mockReturnValue({ success: true });\n vi.mocked(KindService.waitForNodesReady).mockResolvedValue(false);\n\n const result = await runK8sBootstrap(\n {\n name: 'local',\n locationType: WildoLocationType.LOCAL,\n runtime: WildoDeploymentRuntime.KUBERNETES,\n runtimeEnvironment: RuntimeEnvironment.DEVELOPMENT,\n publicDomain: 'local.wildo.test',\n kubernetes: {\n namespace: 'wildo-local',\n },\n } as never,\n '/repo',\n {} as never,\n {\n saasRoot: '/repo/apps/wonder-todos',\n reset: true,\n isFrameworkDeveloper: true,\n },\n logger,\n );\n\n expect(result.success).toBe(false);\n expect(K8sManifestGenerator.renderAllManifests).toHaveBeenCalled();\n expect(generateK8sSecrets).toHaveBeenCalled();\n expect(KindService.deleteCluster).toHaveBeenCalledTimes(1);\n expect(KindService.createCluster).toHaveBeenCalledWith(\n '/repo',\n localDataRoot,\n expect.any(Function),\n );\n expect(KindService.startCluster).not.toHaveBeenCalled();\n });\n\n it('builds the platform image from the framework repository root when local runtime includes platform services', async () => {\n const frameworkRoot = mkdtempSync(join(tmpdir(), 'wildo-k8s-bootstrap-framework-'));\n const infraRoot = mkdtempSync(join(tmpdir(), 'wildo-k8s-bootstrap-infra-'));\n const appRoot = join(frameworkRoot, 'examples', 'wonder-todos');\n const platformDockerfilePath = join(\n frameworkRoot,\n 'templates',\n 'infra',\n 'docker-images',\n 'platform',\n 'Dockerfile.platform-base',\n );\n tempDirs.push(frameworkRoot, infraRoot);\n\n mkdirSync(join(appRoot, '.wildo-saas'), { recursive: true });\n mkdirSync(join(frameworkRoot, 'templates', 'infra', 'docker-images', 'platform'), {\n recursive: true,\n });\n writeFileSync(platformDockerfilePath, 'FROM scratch\\n', 'utf8');\n\n vi.mocked(spawnSync).mockReturnValue({ status: 0 } as never);\n vi.mocked(shouldDeployPlatformServicesInRuntime).mockReturnValue(true);\n vi.mocked(EnvironmentPaths.resolveInfraDir).mockReturnValue(infraRoot);\n vi.mocked(EnvironmentPaths.resolveScopedLocalDataDir).mockReturnValue(\n join(appRoot, '.wildo-saas', 'local_data'),\n );\n vi.mocked(KindService.checkImageInRegistry).mockReturnValue(false);\n vi.mocked(KindService.clusterExists).mockReturnValue(false);\n vi.mocked(KindService.getClusterStatus).mockReturnValue({\n exists: false,\n running: false,\n nodesReady: false,\n nodes: [],\n registry: {\n exists: true,\n running: true,\n accessible: true,\n },\n });\n vi.mocked(KindService.createCluster).mockReturnValue({ success: true });\n vi.mocked(KindService.waitForNodesReady).mockResolvedValue(false);\n\n const result = await runK8sBootstrap(\n {\n name: 'local',\n locationType: WildoLocationType.LOCAL,\n runtime: WildoDeploymentRuntime.KUBERNETES,\n runtimeEnvironment: RuntimeEnvironment.DEVELOPMENT,\n publicDomain: 'local.wildo.test',\n kubernetes: {\n namespace: 'wildo-local',\n },\n } as never,\n frameworkRoot,\n {} as never,\n {\n saasRoot: appRoot,\n isFrameworkDeveloper: true,\n },\n logger,\n );\n\n expect(result.success).toBe(false);\n expect(spawnSync).toHaveBeenCalledWith(\n 'docker',\n [\n 'build',\n '--platform',\n 'linux/amd64',\n '-f',\n platformDockerfilePath,\n '-t',\n expect.stringContaining('/wildo-platform:latest'),\n frameworkRoot,\n ],\n expect.objectContaining({\n cwd: frameworkRoot,\n }),\n );\n });\n\n it('fails closed when resuming against a stale cluster without reset', async () => {\n const infraRoot = mkdtempSync(join(tmpdir(), 'wildo-k8s-bootstrap-resume-'));\n tempDirs.push(infraRoot);\n const localDataRoot = '/repo/apps/wonder-todos/.wildo-saas/local_data';\n\n mkdirSync(join(infraRoot, 'state'), { recursive: true });\n writeFileSync(\n join(infraRoot, 'state', 'k8s-bootstrap-state.json'),\n JSON.stringify({\n phase: 2,\n completed: ['prepare'],\n startedAt: new Date().toISOString(),\n envName: 'local',\n }),\n 'utf8',\n );\n\n vi.mocked(EnvironmentPaths.resolveInfraDir).mockReturnValue(infraRoot);\n vi.mocked(EnvironmentPaths.resolveScopedLocalDataDir).mockReturnValue(localDataRoot);\n vi.mocked(KindService.clusterExists).mockReturnValue(true);\n // Legacy hyphenated path representing the pre-Slice-4 mount layout —\n // mismatches the underscored `local_data` target, so resume must fail\n // closed instead of silently reusing the stale cluster.\n vi.mocked(KindService.getMountedLocalDataRoots).mockReturnValue([\n '/repo/apps/wonder-todos/.wildo-saas/local-data',\n ]);\n vi.mocked(KindService.localDataMountMatches).mockReturnValue(false);\n\n const result = await runK8sBootstrap(\n {\n name: 'local',\n locationType: WildoLocationType.LOCAL,\n runtime: WildoDeploymentRuntime.KUBERNETES,\n runtimeEnvironment: RuntimeEnvironment.DEVELOPMENT,\n publicDomain: 'local.wildo.test',\n kubernetes: {\n namespace: 'wildo-local',\n },\n } as never,\n '/repo',\n {} as never,\n {\n saasRoot: '/repo/apps/wonder-todos',\n resume: true,\n isFrameworkDeveloper: true,\n },\n logger,\n );\n\n expect(result.success).toBe(false);\n expect(KindService.deleteCluster).not.toHaveBeenCalled();\n expect(KindService.createCluster).not.toHaveBeenCalled();\n expect(logger.error).toHaveBeenCalledWith(\n expect.stringContaining('Re-run with --reset'),\n );\n });\n\n it('throws a clear error when saasRoot is empty', async () => {\n vi.mocked(EnvironmentPaths.resolveInfraDir).mockReturnValue('/tmp/wildo-k8s-bootstrap-invalid');\n\n await expect(runK8sBootstrap(\n {\n name: 'local',\n locationType: WildoLocationType.LOCAL,\n runtime: WildoDeploymentRuntime.KUBERNETES,\n runtimeEnvironment: RuntimeEnvironment.DEVELOPMENT,\n publicDomain: 'local.wildo.test',\n kubernetes: {\n namespace: 'wildo-local',\n },\n } as never,\n '/repo',\n {} as never,\n {\n saasRoot: ' ',\n } as never,\n logger,\n )).rejects.toThrow('K8s bootstrap requires a targeted app root to resolve local runtime storage.');\n });\n});\n"]}
1
+ {"version":3,"file":"k8s-bootstrap.service.test.js","sourceRoot":"","sources":["../../../../../../src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAE3G,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9B,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;CACnB,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE,CAAC,CAAC;IAChE,WAAW,EAAE;QACX,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;QACtB,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE;QACjC,qBAAqB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AAE;YACL,KAAK,EAAE,iBAAiB;YACxB,QAAQ,EAAE,8BAA8B;YACxC,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,UAAU;SACrB;KACO,CAAC;IAEX,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC;YACnD,iBAAiB,EAAE,eAAe,CAAC,IAAI;YACvC,WAAW,EAAE,iBAAiB;YAC9B,cAAc,EAAE,8BAA8B;YAC9C,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,UAAU;SAC5B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH;;;;;OAKG;IACH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,GAAG,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACjD,KAAK,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,CAAC,EAAE,CAAC;YAC3F,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,2DAA2D,CAAC,CAAC,UAAU,EAAE,CAAC;QACnG,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { afterEach, describe, expect, it, vi } from 'vitest';\nimport { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { tmpdir } from 'os';\nimport { RuntimeEnvironment } from '@wildo-ai/saas-models';\nimport { AppsManagerMode, WildoDeploymentRuntime, WildoLocationType } from '@wildo-ai/platform-config-lib';\n\nvi.mock('child_process', () => ({\n spawnSync: vi.fn(),\n}));\n\nvi.mock('~wildo-cli/services/deployment/k8s/kind.service', () => ({\n KindService: {\n clusterExists: vi.fn(),\n getMountedLocalDataRoots: vi.fn(),\n localDataMountMatches: vi.fn(),\n deleteCluster: vi.fn(),\n getClusterStatus: vi.fn(),\n createCluster: vi.fn(),\n startCluster: vi.fn(),\n waitForNodesReady: vi.fn(),\n checkImageInRegistry: vi.fn(),\n },\n}));\n\nvi.mock('~wildo-cli/services/deployment/k8s/k8s-manifest-generator.service', () => ({\n K8sManifestGenerator: {\n renderAllManifests: vi.fn(() => ({\n total: 0,\n dirs: {\n cluster: '/tmp/cluster',\n internal: '/tmp/internal',\n platform: '/tmp/platform',\n applications: '/tmp/applications',\n storage: '/tmp/storage',\n },\n })),\n },\n}));\n\nvi.mock('~wildo-cli/services/deployment/k8s/k8s-secrets-generator.service', () => ({\n generateK8sSecrets: vi.fn(() => ({})),\n}));\n\nvi.mock('~wildo-cli/services/deployment/platform-runtime-policy.service', () => ({\n shouldDeployPlatformServicesInRuntime: vi.fn(() => false),\n}));\n\nvi.mock('~wildo-cli/services/environment/environment-paths.service', () => ({\n EnvironmentPaths: {\n resolveInfraDir: vi.fn(),\n resolveScopedLocalDataDir: vi.fn(),\n },\n}));\n\nimport { KindService } from '~wildo-cli/services/deployment/k8s/kind.service';\nimport { K8sManifestGenerator } from '~wildo-cli/services/deployment/k8s/k8s-manifest-generator.service';\nimport { generateK8sSecrets } from '~wildo-cli/services/deployment/k8s/k8s-secrets-generator.service';\nimport { shouldDeployPlatformServicesInRuntime } from '~wildo-cli/services/deployment/platform-runtime-policy.service';\nimport { EnvironmentPaths } from '~wildo-cli/services/environment/environment-paths.service';\nimport { spawnSync } from 'child_process';\nimport { buildAppsManagerInitEnv, runK8sBootstrap } from '../k8s-bootstrap.service';\n\ndescribe('runK8sBootstrap', () => {\n const tempDirs: string[] = [];\n const logger = {\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n success: vi.fn(),\n };\n\n afterEach(() => {\n vi.restoreAllMocks();\n vi.clearAllMocks();\n for (const dir of tempDirs.splice(0)) {\n rmSync(dir, { recursive: true, force: true });\n }\n });\n\n it('recreates an existing cluster when reset applies the local_data mount cutover', async () => {\n const infraRoot = mkdtempSync(join(tmpdir(), 'wildo-k8s-bootstrap-'));\n tempDirs.push(infraRoot);\n const localDataRoot = '/repo/apps/wonder-todos/.wildo-saas/local_data';\n\n vi.mocked(EnvironmentPaths.resolveInfraDir).mockReturnValue(infraRoot);\n vi.mocked(EnvironmentPaths.resolveScopedLocalDataDir).mockReturnValue(localDataRoot);\n vi.mocked(KindService.checkImageInRegistry).mockReturnValue(true);\n vi.mocked(KindService.clusterExists).mockReturnValue(true);\n // Legacy hyphenated path (`.wildo-saas/local-data`) represents the\n // post-flattening / pre-Slice-4 mount the cluster was created with.\n // It MUST mismatch the current `local_data` (underscored) target so\n // the bootstrap takes the \"recreate cluster\" path.\n vi.mocked(KindService.getMountedLocalDataRoots).mockReturnValue([\n '/repo/apps/wonder-todos/.wildo-saas/local-data',\n ]);\n vi.mocked(KindService.localDataMountMatches).mockReturnValue(false);\n vi.mocked(KindService.deleteCluster).mockReturnValue({ success: true });\n vi.mocked(KindService.getClusterStatus).mockReturnValue({\n exists: false,\n running: false,\n nodesReady: false,\n nodes: [],\n registry: {\n exists: true,\n running: true,\n accessible: true,\n },\n });\n vi.mocked(KindService.createCluster).mockReturnValue({ success: true });\n vi.mocked(KindService.waitForNodesReady).mockResolvedValue(false);\n\n const result = await runK8sBootstrap(\n {\n name: 'local',\n locationType: WildoLocationType.LOCAL,\n runtime: WildoDeploymentRuntime.KUBERNETES,\n runtimeEnvironment: RuntimeEnvironment.DEVELOPMENT,\n publicDomain: 'local.wildo.test',\n kubernetes: {\n namespace: 'wildo-local',\n },\n } as never,\n '/repo',\n {} as never,\n {\n saasRoot: '/repo/apps/wonder-todos',\n reset: true,\n isFrameworkDeveloper: true,\n },\n logger,\n );\n\n expect(result.success).toBe(false);\n expect(K8sManifestGenerator.renderAllManifests).toHaveBeenCalled();\n expect(generateK8sSecrets).toHaveBeenCalled();\n expect(KindService.deleteCluster).toHaveBeenCalledTimes(1);\n expect(KindService.createCluster).toHaveBeenCalledWith(\n '/repo',\n localDataRoot,\n expect.any(Function),\n );\n expect(KindService.startCluster).not.toHaveBeenCalled();\n });\n\n it('builds the platform image from the framework repository root when local runtime includes platform services', async () => {\n const frameworkRoot = mkdtempSync(join(tmpdir(), 'wildo-k8s-bootstrap-framework-'));\n const infraRoot = mkdtempSync(join(tmpdir(), 'wildo-k8s-bootstrap-infra-'));\n const appRoot = join(frameworkRoot, 'examples', 'wonder-todos');\n const platformDockerfilePath = join(\n frameworkRoot,\n 'templates',\n 'infra',\n 'docker-images',\n 'platform',\n 'Dockerfile.platform-base',\n );\n tempDirs.push(frameworkRoot, infraRoot);\n\n mkdirSync(join(appRoot, '.wildo-saas'), { recursive: true });\n mkdirSync(join(frameworkRoot, 'templates', 'infra', 'docker-images', 'platform'), {\n recursive: true,\n });\n writeFileSync(platformDockerfilePath, 'FROM scratch\\n', 'utf8');\n\n vi.mocked(spawnSync).mockReturnValue({ status: 0 } as never);\n vi.mocked(shouldDeployPlatformServicesInRuntime).mockReturnValue(true);\n vi.mocked(EnvironmentPaths.resolveInfraDir).mockReturnValue(infraRoot);\n vi.mocked(EnvironmentPaths.resolveScopedLocalDataDir).mockReturnValue(\n join(appRoot, '.wildo-saas', 'local_data'),\n );\n vi.mocked(KindService.checkImageInRegistry).mockReturnValue(false);\n vi.mocked(KindService.clusterExists).mockReturnValue(false);\n vi.mocked(KindService.getClusterStatus).mockReturnValue({\n exists: false,\n running: false,\n nodesReady: false,\n nodes: [],\n registry: {\n exists: true,\n running: true,\n accessible: true,\n },\n });\n vi.mocked(KindService.createCluster).mockReturnValue({ success: true });\n vi.mocked(KindService.waitForNodesReady).mockResolvedValue(false);\n\n const result = await runK8sBootstrap(\n {\n name: 'local',\n locationType: WildoLocationType.LOCAL,\n runtime: WildoDeploymentRuntime.KUBERNETES,\n runtimeEnvironment: RuntimeEnvironment.DEVELOPMENT,\n publicDomain: 'local.wildo.test',\n kubernetes: {\n namespace: 'wildo-local',\n },\n } as never,\n frameworkRoot,\n {} as never,\n {\n saasRoot: appRoot,\n isFrameworkDeveloper: true,\n },\n logger,\n );\n\n expect(result.success).toBe(false);\n expect(spawnSync).toHaveBeenCalledWith(\n 'docker',\n [\n 'build',\n '--platform',\n 'linux/amd64',\n '-f',\n platformDockerfilePath,\n '-t',\n expect.stringContaining('/wildo-platform:latest'),\n frameworkRoot,\n ],\n expect.objectContaining({\n cwd: frameworkRoot,\n }),\n );\n });\n\n it('fails closed when resuming against a stale cluster without reset', async () => {\n const infraRoot = mkdtempSync(join(tmpdir(), 'wildo-k8s-bootstrap-resume-'));\n tempDirs.push(infraRoot);\n const localDataRoot = '/repo/apps/wonder-todos/.wildo-saas/local_data';\n\n mkdirSync(join(infraRoot, 'state'), { recursive: true });\n writeFileSync(\n join(infraRoot, 'state', 'k8s-bootstrap-state.json'),\n JSON.stringify({\n phase: 2,\n completed: ['prepare'],\n startedAt: new Date().toISOString(),\n envName: 'local',\n }),\n 'utf8',\n );\n\n vi.mocked(EnvironmentPaths.resolveInfraDir).mockReturnValue(infraRoot);\n vi.mocked(EnvironmentPaths.resolveScopedLocalDataDir).mockReturnValue(localDataRoot);\n vi.mocked(KindService.clusterExists).mockReturnValue(true);\n // Legacy hyphenated path representing the pre-Slice-4 mount layout —\n // mismatches the underscored `local_data` target, so resume must fail\n // closed instead of silently reusing the stale cluster.\n vi.mocked(KindService.getMountedLocalDataRoots).mockReturnValue([\n '/repo/apps/wonder-todos/.wildo-saas/local-data',\n ]);\n vi.mocked(KindService.localDataMountMatches).mockReturnValue(false);\n\n const result = await runK8sBootstrap(\n {\n name: 'local',\n locationType: WildoLocationType.LOCAL,\n runtime: WildoDeploymentRuntime.KUBERNETES,\n runtimeEnvironment: RuntimeEnvironment.DEVELOPMENT,\n publicDomain: 'local.wildo.test',\n kubernetes: {\n namespace: 'wildo-local',\n },\n } as never,\n '/repo',\n {} as never,\n {\n saasRoot: '/repo/apps/wonder-todos',\n resume: true,\n isFrameworkDeveloper: true,\n },\n logger,\n );\n\n expect(result.success).toBe(false);\n expect(KindService.deleteCluster).not.toHaveBeenCalled();\n expect(KindService.createCluster).not.toHaveBeenCalled();\n expect(logger.error).toHaveBeenCalledWith(\n expect.stringContaining('Re-run with --reset'),\n );\n });\n\n it('throws a clear error when saasRoot is empty', async () => {\n vi.mocked(EnvironmentPaths.resolveInfraDir).mockReturnValue('/tmp/wildo-k8s-bootstrap-invalid');\n\n await expect(runK8sBootstrap(\n {\n name: 'local',\n locationType: WildoLocationType.LOCAL,\n runtime: WildoDeploymentRuntime.KUBERNETES,\n runtimeEnvironment: RuntimeEnvironment.DEVELOPMENT,\n publicDomain: 'local.wildo.test',\n kubernetes: {\n namespace: 'wildo-local',\n },\n } as never,\n '/repo',\n {} as never,\n {\n saasRoot: ' ',\n } as never,\n logger,\n )).rejects.toThrow('K8s bootstrap requires a targeted app root to resolve local runtime storage.');\n });\n});\n\n/*\n * The k8s lane's half of a contract apps-manager enforces FAIL-CLOSED.\n *\n * `init-mode-startup.apps-manager.service.ts` refuses INIT when `ADMIN_EMAIL`, `ADMIN_PASSWORD`,\n * `ADMIN_FIRST_NAME` or `ADMIN_LAST_NAME` is absent, each with its own message. This lane wrote the\n * first two and stopped; the compose lane (`env-vars-builder.service.ts`) has always written all\n * four. Two hand-written mappings for one contract, and only the lane everyone runs was complete.\n *\n * Pinned on the BUILDER rather than through `runK8sBootstrap`, because phase 5 is unreachable in a\n * unit test without standing up five earlier phases — which is precisely why an inline object\n * literal there went unchecked for as long as it did.\n */\ndescribe('buildAppsManagerInitEnv', () => {\n const credentials = {\n admin: {\n email: 'ada@example.com',\n password: 'correct-horse-battery-staple',\n firstName: 'Ada',\n lastName: 'Lovelace',\n },\n } as never;\n\n it('carries every identity key apps-manager INIT requires fail-closed', () => {\n expect(buildAppsManagerInitEnv(credentials)).toEqual({\n APPS_MANAGER_MODE: AppsManagerMode.INIT,\n ADMIN_EMAIL: 'ada@example.com',\n ADMIN_PASSWORD: 'correct-horse-battery-staple',\n ADMIN_FIRST_NAME: 'Ada',\n ADMIN_LAST_NAME: 'Lovelace',\n });\n });\n\n /*\n * GUARDS THE GUARD. The assertion above is an `toEqual`, so it already fails on a dropped key —\n * but it would also pass if someone renamed a key on BOTH sides at once. This states the\n * requirement as a SET, in the words apps-manager's own refusals use, so the pin keeps meaning\n * what it says even if the object literal above is rewritten.\n */\n it('names the four keys apps-manager refuses INIT without', () => {\n const env = buildAppsManagerInitEnv(credentials);\n for (const key of ['ADMIN_EMAIL', 'ADMIN_PASSWORD', 'ADMIN_FIRST_NAME', 'ADMIN_LAST_NAME']) {\n expect(env[key], `${key} is required by init-mode-startup.apps-manager.service.ts`).toBeTruthy();\n }\n });\n});\n"]}
@@ -17,6 +17,29 @@
17
17
  import type { PlatformEnvSecretsJson } from '../../../services/credentials/credentials.schemas';
18
18
  import type { Logger } from '../../../kernel/types';
19
19
  import type { PlatformEnvironmentConfiguration } from '../../../services/environment/environment.schemas';
20
+ /**
21
+ * The environment an apps-manager INIT needs, on the KUBERNETES lane.
22
+ *
23
+ * A named builder rather than an inline object literal, because the same mapping is hand-written
24
+ * once per deployment lane and only one of the two was complete. `env-vars-builder.service.ts` has
25
+ * always written all four identity keys for the compose lane; this lane wrote `ADMIN_EMAIL` and
26
+ * `ADMIN_PASSWORD` and stopped — while `init-mode-startup.apps-manager.service.ts` refuses INIT
27
+ * FAIL-CLOSED on a missing name:
28
+ *
29
+ * ADMIN_FIRST_NAME environment variable is required for INIT mode
30
+ *
31
+ * Nothing else on this lane supplies one. The generated platform Secret carries infrastructure
32
+ * credentials only (`k8s-secrets-generator.service.ts` — no `PlatformAdminEnvKeys` member appears
33
+ * in it), so a key not set HERE does not reach the container at all.
34
+ *
35
+ * Two things follow for whoever adds the next required key. Enumerate by asking *who states the
36
+ * administrator identity*, not by reading the lane in front of you — two lanes for one contract is
37
+ * the shape `.claude/rules/invariant-call-site-enumeration.md` #23 records, and it is why this was
38
+ * invisible for as long as the compose lane was the one anyone ran. And keep the mapping in a
39
+ * function with a pin on it: an inline literal inside a six-phase bootstrap can only be checked by
40
+ * running a cluster, which is exactly why nobody checked it.
41
+ */
42
+ export declare function buildAppsManagerInitEnv(credentials: PlatformEnvSecretsJson): Record<string, string>;
20
43
  export interface K8sBootstrapOptions {
21
44
  saasRoot: string;
22
45
  resume?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"k8s-bootstrap.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/deployment/k8s/k8s-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAYtD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAwtB5G,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,gCAAgC,EACrC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,sBAAsB,EACnC,OAAO,EAAE,mBAAmB,EAC5B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuG/C"}
1
+ {"version":3,"file":"k8s-bootstrap.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/deployment/k8s/k8s-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAatD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAkf5G;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBnG;AAoOD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,gCAAgC,EACrC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,sBAAsB,EACnC,OAAO,EAAE,mBAAmB,EAC5B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuG/C"}
@@ -19,7 +19,7 @@ import { join } from 'path';
19
19
  import { spawnSync } from 'child_process';
20
20
  import chalk from 'chalk';
21
21
  import { BootstrapPhase } from '../../../services/deployment/k8s/k8s.schemas.js';
22
- import { AppsManagerMode, K8S_LOCAL_DEFAULTS, PUBLIC_DOMAIN_DEFAULTS, KIND_CLUSTER_DEFAULTS, PlatformWildoServices, resolveFrameworkLayout, WildoLocationType, } from '@wildo-ai/platform-config-lib';
22
+ import { AppsManagerMode, K8S_LOCAL_DEFAULTS, PUBLIC_DOMAIN_DEFAULTS, KIND_CLUSTER_DEFAULTS, PlatformAdminEnvKeys, PlatformWildoServices, resolveFrameworkLayout, WildoLocationType, } from '@wildo-ai/platform-config-lib';
23
23
  import { PLATFORM_SERVICE_CATALOG, getDeployableInfraServicesForK8s } from '../../../services/catalog/service-catalog.schemas.js';
24
24
  import { KindService } from '../../../services/deployment/k8s/kind.service.js';
25
25
  import { K8sOperations } from '../../../services/deployment/k8s/k8s-operations.service.js';
@@ -395,6 +395,53 @@ async function phaseInfraDeploy(env, state, log) {
395
395
  saveBootstrapState(infraPath, state);
396
396
  return true;
397
397
  }
398
+ /**
399
+ * The environment an apps-manager INIT needs, on the KUBERNETES lane.
400
+ *
401
+ * A named builder rather than an inline object literal, because the same mapping is hand-written
402
+ * once per deployment lane and only one of the two was complete. `env-vars-builder.service.ts` has
403
+ * always written all four identity keys for the compose lane; this lane wrote `ADMIN_EMAIL` and
404
+ * `ADMIN_PASSWORD` and stopped — while `init-mode-startup.apps-manager.service.ts` refuses INIT
405
+ * FAIL-CLOSED on a missing name:
406
+ *
407
+ * ADMIN_FIRST_NAME environment variable is required for INIT mode
408
+ *
409
+ * Nothing else on this lane supplies one. The generated platform Secret carries infrastructure
410
+ * credentials only (`k8s-secrets-generator.service.ts` — no `PlatformAdminEnvKeys` member appears
411
+ * in it), so a key not set HERE does not reach the container at all.
412
+ *
413
+ * Two things follow for whoever adds the next required key. Enumerate by asking *who states the
414
+ * administrator identity*, not by reading the lane in front of you — two lanes for one contract is
415
+ * the shape `.claude/rules/invariant-call-site-enumeration.md` #23 records, and it is why this was
416
+ * invisible for as long as the compose lane was the one anyone ran. And keep the mapping in a
417
+ * function with a pin on it: an inline literal inside a six-phase bootstrap can only be checked by
418
+ * running a cluster, which is exactly why nobody checked it.
419
+ */
420
+ export function buildAppsManagerInitEnv(credentials) {
421
+ return {
422
+ APPS_MANAGER_MODE: AppsManagerMode.INIT,
423
+ [PlatformAdminEnvKeys.ADMIN_EMAIL]: credentials.admin.email,
424
+ [PlatformAdminEnvKeys.ADMIN_PASSWORD]: credentials.admin.password,
425
+ [PlatformAdminEnvKeys.ADMIN_FIRST_NAME]: credentials.admin.firstName,
426
+ [PlatformAdminEnvKeys.ADMIN_LAST_NAME]: credentials.admin.lastName,
427
+ /*
428
+ * The SECOND administrator, who approves an application-wide access grant (#575). Conditional
429
+ * for the same reason as the compose lane's copy: `approver` is `.optional()` on the secrets
430
+ * schema, so an environment predating it emits nothing and INIT warns rather than refusing.
431
+ *
432
+ * This is the SECOND hand-written copy of the identity mapping — the reason `e33a657e` exists —
433
+ * so anything added to the compose lane's block belongs here in the same change.
434
+ */
435
+ ...(credentials.approver
436
+ ? {
437
+ [PlatformAdminEnvKeys.APPROVER_EMAIL]: credentials.approver.email,
438
+ [PlatformAdminEnvKeys.APPROVER_PASSWORD]: credentials.approver.password,
439
+ [PlatformAdminEnvKeys.APPROVER_FIRST_NAME]: credentials.approver.firstName,
440
+ [PlatformAdminEnvKeys.APPROVER_LAST_NAME]: credentials.approver.lastName,
441
+ }
442
+ : {}),
443
+ };
444
+ }
398
445
  async function phasePlatformBootstrap(env, credentials, isFrameworkDeveloper, state, log) {
399
446
  const infraPath = EnvironmentPaths.resolveInfraDir(env.name);
400
447
  if (!shouldDeployPlatformServicesInRuntime(env, isFrameworkDeveloper)) {
@@ -428,11 +475,7 @@ async function phasePlatformBootstrap(env, credentials, isFrameworkDeveloper, st
428
475
  log.info(' apps-manager deployed');
429
476
  // TODO(D8): Replace kubectl set env with ConfigMap regeneration approach.
430
477
  log.info(' Setting apps-manager to INIT mode with admin credentials...');
431
- const initResult = K8sOperations.kubectlSetEnv(containerName, namespace, {
432
- APPS_MANAGER_MODE: AppsManagerMode.INIT,
433
- ADMIN_EMAIL: credentials.admin.email,
434
- ADMIN_PASSWORD: credentials.admin.password,
435
- });
478
+ const initResult = K8sOperations.kubectlSetEnv(containerName, namespace, buildAppsManagerInitEnv(credentials));
436
479
  if (!initResult.success) {
437
480
  log.error(` Failed to set INIT mode: ${initResult.error}`);
438
481
  return false;