@wildo-ai/wildo-cli 1.1.14 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/commands/context/journey.command.d.ts.map +1 -1
- package/dist/src/commands/context/journey.command.js +12 -0
- package/dist/src/commands/context/journey.command.js.map +1 -1
- package/dist/src/commands/creation/drive.command.d.ts.map +1 -1
- package/dist/src/commands/creation/drive.command.js +2 -1
- package/dist/src/commands/creation/drive.command.js.map +1 -1
- package/dist/src/commands/generate/email-command.utils.d.ts +2 -0
- package/dist/src/commands/generate/email-command.utils.d.ts.map +1 -1
- package/dist/src/commands/generate/email-command.utils.js +5 -0
- package/dist/src/commands/generate/email-command.utils.js.map +1 -1
- package/dist/src/commands/init.command.d.ts.map +1 -1
- package/dist/src/commands/init.command.js +7 -2
- package/dist/src/commands/init.command.js.map +1 -1
- package/dist/src/commands/local/deregister.command.d.ts.map +1 -1
- package/dist/src/commands/local/deregister.command.js +4 -0
- package/dist/src/commands/local/deregister.command.js.map +1 -1
- package/dist/src/commands/local/dev.command.d.ts +50 -0
- package/dist/src/commands/local/dev.command.d.ts.map +1 -1
- package/dist/src/commands/local/dev.command.js +144 -1
- package/dist/src/commands/local/dev.command.js.map +1 -1
- package/dist/src/commands/local/jobs-command.utils.d.ts +24 -0
- package/dist/src/commands/local/jobs-command.utils.d.ts.map +1 -0
- package/dist/src/commands/local/jobs-command.utils.js +44 -0
- package/dist/src/commands/local/jobs-command.utils.js.map +1 -0
- package/dist/src/commands/local/jobs-run.command.d.ts +7 -0
- package/dist/src/commands/local/jobs-run.command.d.ts.map +1 -0
- package/dist/src/commands/local/jobs-run.command.js +92 -0
- package/dist/src/commands/local/jobs-run.command.js.map +1 -0
- package/dist/src/commands/local/jobs.command.d.ts +7 -0
- package/dist/src/commands/local/jobs.command.d.ts.map +1 -0
- package/dist/src/commands/local/jobs.command.js +59 -0
- package/dist/src/commands/local/jobs.command.js.map +1 -0
- package/dist/src/commands/local/tunnel.command.d.ts +84 -0
- package/dist/src/commands/local/tunnel.command.d.ts.map +1 -0
- package/dist/src/commands/local/tunnel.command.js +274 -0
- package/dist/src/commands/local/tunnel.command.js.map +1 -0
- package/dist/src/commands/providers/grant-export.command.d.ts +16 -0
- package/dist/src/commands/providers/grant-export.command.d.ts.map +1 -0
- package/dist/src/commands/providers/grant-export.command.js +78 -0
- package/dist/src/commands/providers/grant-export.command.js.map +1 -0
- package/dist/src/commands/providers/grant-import.command.d.ts +15 -0
- package/dist/src/commands/providers/grant-import.command.d.ts.map +1 -0
- package/dist/src/commands/providers/grant-import.command.js +78 -0
- package/dist/src/commands/providers/grant-import.command.js.map +1 -0
- package/dist/src/kernel/command-runner.d.ts.map +1 -1
- package/dist/src/kernel/command-runner.js +4 -6
- package/dist/src/kernel/command-runner.js.map +1 -1
- package/dist/src/kernel/hooks.d.ts.map +1 -1
- package/dist/src/kernel/hooks.js +2 -1
- package/dist/src/kernel/hooks.js.map +1 -1
- package/dist/src/kernel/json-document-output.d.ts +7 -0
- package/dist/src/kernel/json-document-output.d.ts.map +1 -1
- package/dist/src/kernel/json-document-output.js +8 -0
- package/dist/src/kernel/json-document-output.js.map +1 -1
- package/dist/src/kernel/types.d.ts +8 -0
- package/dist/src/kernel/types.d.ts.map +1 -1
- package/dist/src/kernel/types.js.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.d.ts +65 -7
- package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.js +94 -15
- package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/app-local-runtime-addresses.service.d.ts +1 -1
- package/dist/src/services/application/app-local-runtime-addresses.service.d.ts.map +1 -1
- package/dist/src/services/application/app-local-runtime-addresses.service.js.map +1 -1
- package/dist/src/services/application/app-runtime-targets.service.d.ts.map +1 -1
- package/dist/src/services/application/app-runtime-targets.service.js +16 -2
- package/dist/src/services/application/app-runtime-targets.service.js.map +1 -1
- package/dist/src/services/application/application-dependency-alignment.service.d.ts +20 -0
- package/dist/src/services/application/application-dependency-alignment.service.d.ts.map +1 -1
- package/dist/src/services/application/application-dependency-alignment.service.js +32 -2
- package/dist/src/services/application/application-dependency-alignment.service.js.map +1 -1
- package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +13 -0
- package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/application-runtime-bootstrap.service.js +32 -0
- package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/environment-provider-configurations.service.d.ts +7 -0
- package/dist/src/services/application/environment-provider-configurations.service.d.ts.map +1 -1
- package/dist/src/services/application/environment-provider-configurations.service.js +1 -1
- package/dist/src/services/application/environment-provider-configurations.service.js.map +1 -1
- package/dist/src/services/application/local-tunnel.service.d.ts +153 -0
- package/dist/src/services/application/local-tunnel.service.d.ts.map +1 -0
- package/dist/src/services/application/local-tunnel.service.js +295 -0
- package/dist/src/services/application/local-tunnel.service.js.map +1 -0
- package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
- package/dist/src/services/application/provider-runtime-sync.service.js +3 -0
- package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.d.ts +7 -0
- package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.js +2 -0
- package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
- package/dist/src/services/catalog/service-address-resolver.service.d.ts +7 -1
- package/dist/src/services/catalog/service-address-resolver.service.d.ts.map +1 -1
- package/dist/src/services/catalog/service-address-resolver.service.js +6 -3
- package/dist/src/services/catalog/service-address-resolver.service.js.map +1 -1
- package/dist/src/services/companion/companion-client.service.d.ts +17 -0
- package/dist/src/services/companion/companion-client.service.d.ts.map +1 -1
- package/dist/src/services/companion/companion-client.service.js +21 -0
- package/dist/src/services/companion/companion-client.service.js.map +1 -1
- package/dist/src/services/companion/creation-drive.service.d.ts +18 -0
- package/dist/src/services/companion/creation-drive.service.d.ts.map +1 -1
- package/dist/src/services/companion/creation-drive.service.js +70 -1
- package/dist/src/services/companion/creation-drive.service.js.map +1 -1
- package/dist/src/services/credentials/application-secrets.service.d.ts +6 -0
- package/dist/src/services/credentials/application-secrets.service.d.ts.map +1 -1
- package/dist/src/services/credentials/application-secrets.service.js +1 -1
- package/dist/src/services/credentials/application-secrets.service.js.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.d.ts.map +1 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js +3 -1
- package/dist/src/services/credentials/provider-env-vars.utils.js.map +1 -1
- package/dist/src/services/credentials/secrets-writer.service.d.ts +11 -2
- package/dist/src/services/credentials/secrets-writer.service.d.ts.map +1 -1
- package/dist/src/services/credentials/secrets-writer.service.js +12 -3
- package/dist/src/services/credentials/secrets-writer.service.js.map +1 -1
- package/dist/src/services/deployment/ci-deploy-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/ci-deploy-generator.service.js +3 -3
- package/dist/src/services/deployment/ci-deploy-generator.service.js.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts +12 -3
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js +40 -22
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js.map +1 -1
- package/dist/src/services/deployment/framework-pod-network-membership.d.ts +6 -0
- package/dist/src/services/deployment/framework-pod-network-membership.d.ts.map +1 -1
- package/dist/src/services/deployment/framework-pod-network-membership.js +17 -3
- package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts +4 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js +17 -7
- package/dist/src/services/deployment/k8s/k8s-manifest-generator.service.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts +7 -0
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-manifest.schemas.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js +15 -9
- package/dist/src/services/deployment/k8s/k8s-secrets-generator.service.js.map +1 -1
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts +43 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.d.ts.map +1 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js +12 -0
- package/dist/src/services/deployment/k8s/kind-pod-host-gateway.js.map +1 -0
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts +3 -1
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/off-cluster-backing-services.js.map +1 -1
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +163 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +356 -0
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -0
- package/dist/src/services/environment/authored-infra-config.utils.d.ts +13 -3
- package/dist/src/services/environment/authored-infra-config.utils.d.ts.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.js +24 -4
- package/dist/src/services/environment/authored-infra-config.utils.js.map +1 -1
- package/dist/src/services/environment/container-host-gateway-listen-host.d.ts +6 -0
- package/dist/src/services/environment/container-host-gateway-listen-host.d.ts.map +1 -1
- package/dist/src/services/environment/container-host-gateway-listen-host.js +6 -0
- package/dist/src/services/environment/container-host-gateway-listen-host.js.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.d.ts +12 -0
- package/dist/src/services/environment/env-configuration-generator.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-configuration-generator.service.js +37 -5
- package/dist/src/services/environment/env-configuration-generator.service.js.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts +2 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.js +47 -32
- package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
- package/dist/src/services/environment/environment-lifecycle.service.d.ts +7 -4
- package/dist/src/services/environment/environment-lifecycle.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment-lifecycle.service.js +14 -18
- package/dist/src/services/environment/environment-lifecycle.service.js.map +1 -1
- package/dist/src/services/environment/environment-setup.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment-setup.service.js +17 -6
- package/dist/src/services/environment/environment-setup.service.js.map +1 -1
- package/dist/src/services/environment/environment.service.d.ts +4 -3
- package/dist/src/services/environment/environment.service.d.ts.map +1 -1
- package/dist/src/services/environment/environment.service.js +0 -1
- package/dist/src/services/environment/environment.service.js.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.d.ts +55 -15
- package/dist/src/services/framework/framework-docker-publish.service.d.ts.map +1 -1
- package/dist/src/services/framework/framework-docker-publish.service.js +115 -25
- package/dist/src/services/framework/framework-docker-publish.service.js.map +1 -1
- package/dist/src/services/framework/package-install.service.d.ts +7 -0
- package/dist/src/services/framework/package-install.service.d.ts.map +1 -1
- package/dist/src/services/framework/package-install.service.js +8 -1
- package/dist/src/services/framework/package-install.service.js.map +1 -1
- package/dist/src/services/registry/application-provider-connection.service.d.ts +16 -1
- package/dist/src/services/registry/application-provider-connection.service.d.ts.map +1 -1
- package/dist/src/services/registry/application-provider-connection.service.js +23 -0
- package/dist/src/services/registry/application-provider-connection.service.js.map +1 -1
- package/dist/src/services/registry/provider-grant-transfer.service.d.ts +48 -0
- package/dist/src/services/registry/provider-grant-transfer.service.d.ts.map +1 -0
- package/dist/src/services/registry/provider-grant-transfer.service.js +144 -0
- package/dist/src/services/registry/provider-grant-transfer.service.js.map +1 -0
- package/dist/src/services/registry/provider-module-scaffold.service.d.ts.map +1 -1
- package/dist/src/services/registry/provider-module-scaffold.service.js +10 -3
- package/dist/src/services/registry/provider-module-scaffold.service.js.map +1 -1
- package/dist/src/services/security/csp-sync.service.d.ts.map +1 -1
- package/dist/src/services/security/csp-sync.service.js +21 -2
- package/dist/src/services/security/csp-sync.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +16 -7
- package/templates/infra/k8s/platform/platform-crontabs-batches-manager/deployment.yaml.hbs +13 -0
- package/templates/saas/i18n/email/system/remote-agent-task-updated/labels.en.ts +11 -0
- package/templates/saas/i18n/email/system/remote-agent-task-updated/template.tsx +56 -0
- package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.ts +61 -0
- package/templates/saas/i18n/engine/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.ts +61 -0
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +5 -4
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/package.json.hbs +1 -1
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/scripts/substitute-api-origin.mjs +97 -32
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/plugins/api-reference-pages.ts +7 -6
- package/templates/saas/skeleton/.wildo-saas/wildo-dev-companion/scripts/dev-supervised.sh +18 -4
- package/templates/saas/skeleton/frontend/nginx-config/default.conf.hbs +1 -1
- package/templates/saas/skeleton/frontend/src/generated/csp.generated.json.hbs +4 -4
- package/templates/saas/skeleton/infrastructure/local/wildo.infra.local.config.ts.hbs +2 -0
- package/wildo-framework.info.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-dependency-alignment.service.js","sourceRoot":"","sources":["../../../../src/services/application/application-dependency-alignment.service.ts"],"names":[],"mappings":"AA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,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1J,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * ApplicationDependencyAlignmentService — align a STANDALONE application's dependency pins and\n * engine peer declarations against the `@wildo-ai/*` packages it actually has installed (issue #222).\n *\n * ## The problem this closes\n *\n * `wildo init` bakes three derived things into an application: the `@wildo-ai/*` version pins, the\n * third-party pins propagated from the framework's root `pnpm.overrides`, and the engine peer\n * declarations every workspace package must carry. All three are computed from the framework\n * CHECKOUT, at scaffold time. A standalone application has no checkout afterwards, so nothing\n * re-derives them: an application moved to a newer framework keeps the OLD third-party versions and\n * the OLD peer obligations — and the peer half cannot be corrected by reinstalling, because an\n * undeclared peer's resolution is sticky (issue #167).\n *\n * ## Why nothing new has to be published\n *\n * The publish lane already substitutes the framework's root override into every published manifest —\n * exact for `dependencies`, caret-widened for `peerDependencies`. So the pin set and the peer closure\n * are recoverable from the installed packages themselves. Measured against the real 1.1.1 packages in\n * a scaffolded application: of 150 recoverable propagated names, **143 reproduce the framework's own\n * root override exactly**; 5 differ only exact-vs-caret (names that appear ONLY as peers, where the\n * caret is the publish lane's deliberate widening for a consumer); and 2 differ by a major because\n * the framework's root moved AFTER 1.1.1 shipped — which is the point, not a defect. An application\n * aligns to the framework version it HAS, the only contract it can honour.\n *\n * That is why this service reads `node_modules` rather than a published manifest of pins: the data\n * cannot drift from the packages it describes, because it IS them.\n *\n * ## What it deliberately does NOT do\n *\n * It never changes a `@wildo-ai/*` version. Which framework release to adopt is the operator's\n * decision; everything else follows mechanically from it. The flow is:\n *\n * 1. bump the `@wildo-ai/*` entries in the application's overrides (pnpm-workspace.yaml)\n * 2. `pnpm install` (the new pin set cannot be read until the new version is on disk)\n * 3. `wildo align-deps --write`\n * 4. `pnpm install`\n *\n * `wildo update` runs that flow for a release upgrade (`update.command.ts`): the operator's decision\n * is its `--to <version>` / `--tag`, its step 1 is the bump, and its step 3 is the install → this\n * service → install. Use `align-deps` on its own only for the first alignment after `wildo init`.\n */\nimport { existsSync, readdirSync, readFileSync, writeFileSync } from 'fs';\nimport { dirname, join, relative } from 'path';\nimport {\n migrateApplicationPnpmSettings,\n PNPM_OWNED_SETTINGS,\n PnpmSettingsSource,\n readApplicationPnpmSettings,\n WILDO_SAAS_LOCK_RELATIVE_PATH,\n writeApplicationPnpmSettings,\n} from '@wildo-ai/platform-config-lib';\n\n/** Where an application declares the names its own toolchain owns. Seeded by `wildo init`. */\nexport const APPLICATION_DEPENDENCY_EXCLUSIONS_RELATIVE = '.wildo-saas/dependency-exclusions.json';\n\nconst FRAMEWORK_SCOPE_PREFIX = '@wildo-ai/';\nconst EXACT_SEMVER_PATTERN = /^\\d+\\.\\d+\\.\\d+$/;\n\ninterface PackageManifest {\n name?: string;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n peerDependenciesMeta?: Record<string, { optional?: boolean }>;\n optionalDependencies?: Record<string, string>;\n}\n\n/**\n * What is wrong with one manifest entry, and therefore what `--write` will do about it.\n *\n * The four are not degrees of the same thing — they split on TWO axes that need different repairs:\n * whether the name belongs in overrides (pnpm-workspace.yaml) or in the importer's own dependency list, and whether\n * it is ABSENT or present-and-wrong. `peer-pinned-in-place` is the one that reads oddly and matters\n * most: the peer IS declared, but at a concrete version rather than `\"*\"`, so the framework's override\n * cannot reach it and a later pin bump silently will not land.\n */\nexport enum ApplicationAlignmentFindingKind {\n /** The framework pins this name and the application's overrides (pnpm-workspace.yaml) does not carry it at all. */\n OVERRIDE_MISSING = 'override-missing',\n /** The application overrides the name, at a version the installed framework does not pin. */\n OVERRIDE_DRIFT = 'override-drift',\n /** A required engine peer the importer never declares, so `autoInstallPeers` resolves it unpinned. */\n PEER_MISSING = 'peer-missing',\n /** The peer is declared with a concrete version, which the override cannot rewrite. */\n PEER_PINNED_IN_PLACE = 'peer-pinned-in-place',\n /**\n * A pnpm setting Wildo owns (`overrides`, `onlyBuiltDependencies`, `neverBuiltDependencies`) still in `package.json` →\n * `pnpm`, which pnpm 11 does not read (#2808). `--write` moves it, value unchanged, into `pnpm-workspace.yaml`.\n */\n SETTING_IN_PACKAGE_JSON = 'setting-in-package-json',\n}\n\nexport interface ApplicationAlignmentFinding {\n /** Application-root-relative path of the manifest that needs the change. */\n manifestRelativePath: string;\n kind: ApplicationAlignmentFindingKind;\n name: string;\n current?: string;\n desired: string;\n}\n\n/**\n * What alignment REPORTS and never changes (#2789): removing a pin or a dependency needs to know who wrote it, and\n * nothing records that for these. The twin of `findDependencyOrphans` in the framework's alignment script, which this\n * published CLI cannot import.\n */\nexport enum ApplicationAlignmentReportKind {\n /** A root override no authority writes, no manifest declares, and the lockfile resolves nowhere: it pins nothing. */\n ORPHAN_OVERRIDE = 'orphan-override',\n /** An adopted provider module's vendor package, declared by a manifest outside that module's facets. */\n MISPLACED_DEPENDENCY = 'misplaced-dependency',\n}\n\nexport interface ApplicationAlignmentReport {\n manifestRelativePath: string;\n kind: ApplicationAlignmentReportKind;\n name: string;\n /** The override's value (orphan) or the module that owns the package (misplaced). */\n detail: string;\n}\n\nexport interface ApplicationAlignmentResult {\n /** `@wildo-ai/*` packages whose installed manifest was read, with the version found. */\n installedFrameworkPackages: Array<{ name: string; version: string }>;\n /** Third-party names the installed engine pins, after exclusions. */\n derivedOverrides: Record<string, string>;\n /** Per framework package, the transitive REQUIRED peers a consumer must declare. */\n enginePeerClosure: Record<string, string[]>;\n excludedNames: string[];\n findings: ApplicationAlignmentFinding[];\n /**\n * Workspace member patterns this reader cannot expand (`dir/**`, an interior `*`, a `!exclusion`).\n * The packages they cover were NOT aligned; a caller reports them rather than calling the run clean.\n */\n unsupportedWorkspacePatterns: string[];\n /** Report-only defects (#2789): never part of `findings`, never written. */\n reports: ApplicationAlignmentReport[];\n written: boolean;\n}\n\n/** The package an override key governs: `x>y@2` → `y`, `@s/n@^1` → `@s/n`. */\nexport function overrideTargetName(key: string): string {\n const target = key.includes('>') ? key.slice(key.lastIndexOf('>') + 1) : key;\n const at = target.lastIndexOf('@');\n return at > 0 ? target.slice(0, at) : target;\n}\n\n/**\n * Every package name a pnpm lockfile resolves. Only the `packages:` and `snapshots:` blocks are read: the lockfile's own\n * `overrides:` block carries keys like `foo@1`, which would count an orphan override as resolved (#2789 review F7).\n */\nexport function readResolvedPackageNames(lockText: string | undefined): Set<string> {\n const names = new Set<string>();\n if (lockText === undefined) return names;\n let inResolved = false;\n for (const line of lockText.split(/\\r?\\n/)) {\n if (/^\\S/.test(line)) {\n inResolved = /^(packages|snapshots):\\s*$/.test(line);\n continue;\n }\n if (!inResolved) continue;\n const match = /^ {2}'?((?:@[^/'\\s]+\\/)?[^@'\\s/]+)@/.exec(line);\n if (match) names.add(match[1]!);\n }\n return names;\n}\n\nconst DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'] as const;\n\n/**\n * The two report-only defects of ONE application (#2789), with the semantics of the framework script's twin:\n * an ORPHAN override (no authority writes it, no manifest declares it, the lockfile resolves it nowhere; a deliberate\n * pin on a transitive dependency is resolved, so it is never one) and a MISPLACED dependency (an adopted module's vendor\n * package declared outside that module's facets).\n */\nexport function findDependencyOrphans(input: {\n appOverrides: Record<string, unknown>;\n /** The application-root file the overrides were read from (#2808); `pnpm-workspace.yaml` when not given. */\n overridesRelativePath?: string;\n authoredKeys: ReadonlySet<string>;\n adoptedVendorPins: ReadonlyMap<string, { moduleId: string; ref?: string }>;\n manifests: ReadonlyArray<{ member: string; manifest: Record<string, unknown> | undefined }>;\n resolvedNames: ReadonlySet<string>;\n}): ApplicationAlignmentReport[] {\n const fieldsOf = (manifest: Record<string, unknown> | undefined) => DEPENDENCY_FIELDS\n .map((field) => manifest?.[field])\n .filter((value): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value));\n const declared = new Set(input.manifests.flatMap(({ manifest }) => fieldsOf(manifest).flatMap((field) => Object.keys(field))));\n const reports: ApplicationAlignmentReport[] = Object.keys(input.appOverrides)\n .filter((key) => !input.authoredKeys.has(key))\n .filter((key) => !overrideTargetName(key).startsWith('@wildo-ai/'))\n .filter((key) => !input.adoptedVendorPins.has(overrideTargetName(key)))\n .filter((key) => !declared.has(overrideTargetName(key)))\n .filter((key) => !input.resolvedNames.has(overrideTargetName(key)))\n .sort()\n .map((key) => ({ manifestRelativePath: input.overridesRelativePath ?? PnpmSettingsSource.WORKSPACE_FILE, kind: ApplicationAlignmentReportKind.ORPHAN_OVERRIDE, name: key, detail: String(input.appOverrides[key]) }));\n const misplaced: ApplicationAlignmentReport[] = [];\n for (const { member, manifest } of input.manifests) {\n for (const [name, owner] of input.adoptedVendorPins) {\n if (owner.ref !== undefined && member.startsWith(`providers/${owner.ref}/`)) continue;\n if (fieldsOf(manifest).some((field) => field[name] !== undefined)) {\n misplaced.push({ manifestRelativePath: join(member, 'package.json'), kind: ApplicationAlignmentReportKind.MISPLACED_DEPENDENCY, name, detail: owner.moduleId });\n }\n }\n }\n // Ordered like the framework script's report: by member, then name.\n return [...reports, ...misplaced.sort((a, b) => `${a.manifestRelativePath}/${a.name}`.localeCompare(`${b.manifestRelativePath}/${b.name}`))];\n}\n\nexport class ApplicationDependencyAlignmentService {\n /**\n * Compute (and optionally apply) the alignment for one application root.\n *\n * Reading is total and writing is per-manifest: a `--check` run touches nothing, and a `--write`\n * run rewrites only the manifests that actually have findings.\n */\n static align(input: { applicationRoot: string; write: boolean }): ApplicationAlignmentResult {\n const { members: workspaceMembers, unsupportedPatterns: unsupportedWorkspacePatterns } =\n ApplicationDependencyAlignmentService.discoverWorkspaceMembers(input.applicationRoot);\n const installed = ApplicationDependencyAlignmentService.readInstalledFrameworkManifests({\n applicationRoot: input.applicationRoot,\n workspaceMembers,\n });\n if (installed.size === 0) {\n throw new Error(\n 'No @wildo-ai/* package could be resolved from this application — run `pnpm install` first. '\n + 'Alignment derives every pin from the framework packages the application HAS installed, so '\n + 'an empty node_modules would silently produce an empty pin set.',\n );\n }\n\n const excludedNames = ApplicationDependencyAlignmentService.readExclusions(input.applicationRoot);\n const derivedOverrides = ApplicationDependencyAlignmentService.deriveOverrides({ installed, excludedNames });\n const enginePeerClosure = ApplicationDependencyAlignmentService.deriveEnginePeerClosure({ installed, excludedNames });\n\n const findings: ApplicationAlignmentFinding[] = [];\n findings.push(...ApplicationDependencyAlignmentService.reconcileRootOverrides({\n applicationRoot: input.applicationRoot, derivedOverrides, write: input.write,\n }));\n for (const member of workspaceMembers) {\n findings.push(...ApplicationDependencyAlignmentService.reconcileMemberPeers({\n applicationRoot: input.applicationRoot, member, enginePeerClosure, write: input.write,\n }));\n }\n\n // #2789: report-only. Read after the writes above, so a run that just added a pin does not report it.\n const lockPath = join(input.applicationRoot, 'pnpm-lock.yaml');\n const settingsAfterWrite = readApplicationPnpmSettings(input.applicationRoot);\n const reports = findDependencyOrphans({\n appOverrides: settingsAfterWrite.overrides ?? {},\n overridesRelativePath: settingsAfterWrite.sources.overrides,\n authoredKeys: new Set(Object.keys(derivedOverrides)),\n adoptedVendorPins: readAdoptedVendorPins(input.applicationRoot),\n manifests: workspaceMembers.map((member) => ({ member, manifest: readJsonObject(join(input.applicationRoot, member, 'package.json')) })),\n resolvedNames: readResolvedPackageNames(existsSync(lockPath) ? readFileSync(lockPath, 'utf8') : undefined),\n });\n\n return {\n reports,\n installedFrameworkPackages: [...installed.entries()]\n .map(([name, manifest]) => ({ name, version: (manifest as { version?: string }).version ?? 'unknown' }))\n .sort((a, b) => a.name.localeCompare(b.name)),\n derivedOverrides,\n enginePeerClosure,\n excludedNames,\n findings,\n unsupportedWorkspacePatterns,\n written: input.write && findings.length > 0,\n };\n }\n\n /**\n * The application's own workspace members, plus its root (`.`).\n *\n * GENERATED drops are skipped: `.wildo-saas/wildo-dev-companion` has its manifest written by the\n * companion delivery on every start, so a declaration reconciled into it is erased.\n *\n * A member may be a GLOB, and one kind always is: `wildo registry add` wires a provider module as\n * `providers/<ref>/*`, one member per facet package. Reading members as literal paths dropped every\n * glob (no directory is literally named `*`), so an installed provider package was never aligned\n * (#2019 review). {@link expandWorkspaceMemberPatterns} expands them with the framework reader's semantics.\n */\n static discoverWorkspaceMembers(applicationRoot: string): { members: string[]; unsupportedPatterns: string[] } {\n const { members, unsupportedPatterns } = expandWorkspaceMemberPatterns(\n applicationRoot,\n readWorkspacePackagePatterns(join(applicationRoot, 'pnpm-workspace.yaml')),\n );\n return {\n members: [...new Set(['.', ...members])]\n .filter((member) => !member.startsWith('.wildo-saas/'))\n .filter((member) => existsSync(join(applicationRoot, member, 'package.json'))),\n unsupportedPatterns,\n };\n }\n\n /**\n * Every `@wildo-ai/*` manifest the application can resolve, keyed by package name.\n *\n * Resolution goes through `createRequire` from each workspace member rather than by walking\n * `node_modules/.pnpm`: the virtual store's directory naming is a pnpm implementation detail, while\n * `require.resolve` is the contract every runtime in the application already uses. A member that\n * cannot resolve a name simply contributes nothing — under pnpm's isolated layout only a package's\n * own declared dependencies are reachable from it, and that is exactly the set that matters.\n */\n static readInstalledFrameworkManifests(input: {\n applicationRoot: string;\n workspaceMembers: string[];\n }): Map<string, PackageManifest> {\n const found = new Map<string, PackageManifest>();\n const candidateNames = new Set<string>();\n\n for (const member of input.workspaceMembers) {\n const manifest = ApplicationDependencyAlignmentService.readManifest(\n join(input.applicationRoot, member, 'package.json'),\n );\n if (!manifest) continue;\n for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] as const) {\n for (const name of Object.keys(manifest[field] ?? {})) {\n if (name.startsWith(FRAMEWORK_SCOPE_PREFIX)) candidateNames.add(name);\n }\n }\n }\n // The root `pnpm.overrides` names every framework package the scaffolder pinned, including ones\n // no member declares directly — they are still installed, and their peers still land on the app.\n for (const name of Object.keys(readApplicationPnpmSettings(input.applicationRoot).overrides ?? {})) {\n if (name.startsWith(FRAMEWORK_SCOPE_PREFIX)) candidateNames.add(name);\n }\n\n // A framework package's own `@wildo-ai/*` dependencies are followed too: the closure is\n // transitive, and an application need never name `presets-components` to inherit its peers.\n const pending = [...candidateNames];\n while (pending.length > 0) {\n const name = pending.pop() as string;\n if (found.has(name)) continue;\n const manifest = ApplicationDependencyAlignmentService.resolveFrameworkManifest({\n applicationRoot: input.applicationRoot,\n workspaceMembers: input.workspaceMembers,\n name,\n });\n if (!manifest) continue;\n found.set(name, manifest);\n for (const field of ['dependencies', 'peerDependencies', 'optionalDependencies'] as const) {\n for (const dependencyName of Object.keys(manifest[field] ?? {})) {\n if (dependencyName.startsWith(FRAMEWORK_SCOPE_PREFIX) && !found.has(dependencyName)) pending.push(dependencyName);\n }\n }\n }\n return found;\n }\n\n /**\n * Find a framework package's manifest by walking `node_modules` upward from each workspace member,\n * which is Node's own package-DIRECTORY lookup.\n *\n * NOT `require.resolve('<name>/package.json')`, which was the first attempt and does not work: a\n * published `@wildo-ai/*` package declares an `exports` map, and an exports map that does not list\n * `./package.json` makes that specifier unresolvable. Measured on a freshly scaffolded application —\n * every one of the twenty packages was installed and every resolve threw, so the service reported\n * \"no framework package installed\" on a perfectly healthy tree. A directory walk asks the question\n * actually being asked (where does this package LIVE) and is unaffected by what a package exports.\n */\n private static resolveFrameworkManifest(input: {\n applicationRoot: string;\n workspaceMembers: string[];\n name: string;\n }): PackageManifest | null {\n for (const member of input.workspaceMembers) {\n let directory = join(input.applicationRoot, member);\n for (;;) {\n const candidate = join(directory, 'node_modules', input.name, 'package.json');\n if (existsSync(candidate)) return JSON.parse(readFileSync(candidate, 'utf8')) as PackageManifest;\n const parent = dirname(directory);\n if (parent === directory || !parent.startsWith(input.applicationRoot)) break;\n directory = parent;\n }\n }\n return null;\n }\n\n /**\n * The third-party pin set the installed engine implies.\n *\n * When a name appears with several specifiers the EXACT one wins. That is not arbitrary: the\n * publish lane writes the tested version exactly into `dependencies` and widens it to a caret in\n * `peerDependencies`, so both describe the same version and the exact form is the one the framework\n * actually ran. Measured, it reproduces the framework's own root override for 143 of 150 names.\n *\n * ## Only a name the framework's ROOT pins is pinned — never a package's own private dependency\n *\n * The propagation contract (`toolchain-installation-baseline.md`) moves exactly the names the framework\n * root pins, and a manifest says which those are: the publish lane writes a root pin EXACT into\n * `dependencies` and as a caret into `peerDependencies`, and source form writes it `*`. A dependency\n * the root does NOT pin keeps the range its package authored — `platform-config-lib`'s `jiti ^2.6.1`.\n * This used to pin every such range application-wide, and an override reaches every edge that names\n * the package: on 2026-09-24 it forced jiti 2 onto Docusaurus (which loads its config through jiti 1),\n * the documentation site could no longer read `export default config`, and the failed service tore the\n * whole dev stack down on start. So a name is pinned when some framework package declares it exact,\n * `*`, or as a peer; a name only ever declared as a private range stays that package's business.\n */\n static deriveOverrides(input: { installed: Map<string, PackageManifest>; excludedNames: string[] }): Record<string, string> {\n const candidates = new Map<string, Set<string>>();\n const rootPinned = new Set<string>();\n for (const manifest of input.installed.values()) {\n for (const field of ['dependencies', 'peerDependencies'] as const) {\n for (const [name, specifier] of Object.entries(manifest[field] ?? {})) {\n if (name.startsWith(FRAMEWORK_SCOPE_PREFIX)) continue;\n if (ApplicationDependencyAlignmentService.isExcluded(name, input.excludedNames)) continue;\n if (!candidates.has(name)) candidates.set(name, new Set());\n (candidates.get(name) as Set<string>).add(specifier);\n if (field === 'peerDependencies' || specifier === '*' || EXACT_SEMVER_PATTERN.test(specifier)) rootPinned.add(name);\n }\n }\n }\n const overrides: Record<string, string> = {};\n for (const [name, specifiers] of candidates) {\n if (!rootPinned.has(name)) continue;\n const exact = [...specifiers].find((specifier) => EXACT_SEMVER_PATTERN.test(specifier));\n overrides[name] = exact ?? [...specifiers][0];\n }\n return Object.fromEntries(Object.keys(overrides).sort().map((name) => [name, overrides[name]]));\n }\n\n /**\n * Per framework package, the transitive REQUIRED peers a consumer must declare.\n *\n * Optional peers (`peerDependenciesMeta`) are excluded — an optional peer is not an obligation, and\n * `saas-technical-doc` / `saas-website` use that field to say exactly this.\n */\n static deriveEnginePeerClosure(input: {\n installed: Map<string, PackageManifest>;\n excludedNames: string[];\n }): Record<string, string[]> {\n const closureOf = new Map<string, Set<string>>();\n\n const walk = (packageName: string, visiting: Set<string>): Set<string> => {\n const cached = closureOf.get(packageName);\n if (cached) return cached;\n const manifest = input.installed.get(packageName);\n if (!manifest || visiting.has(packageName)) return new Set();\n visiting.add(packageName);\n\n const peers = new Set<string>();\n const optional = manifest.peerDependenciesMeta ?? {};\n for (const name of Object.keys(manifest.peerDependencies ?? {})) {\n if (name.startsWith(FRAMEWORK_SCOPE_PREFIX)) continue;\n if (optional[name]?.optional) continue;\n if (ApplicationDependencyAlignmentService.isExcluded(name, input.excludedNames)) continue;\n peers.add(name);\n }\n for (const field of ['dependencies', 'peerDependencies', 'optionalDependencies'] as const) {\n for (const dependencyName of Object.keys(manifest[field] ?? {})) {\n if (!dependencyName.startsWith(FRAMEWORK_SCOPE_PREFIX)) continue;\n for (const inherited of walk(dependencyName, visiting)) peers.add(inherited);\n }\n }\n visiting.delete(packageName);\n closureOf.set(packageName, peers);\n return peers;\n };\n\n const result: Record<string, string[]> = {};\n for (const packageName of [...input.installed.keys()].sort()) {\n result[packageName] = [...walk(packageName, new Set())].sort();\n }\n return result;\n }\n\n /**\n * Names this application's own toolchain owns, which alignment must never pin.\n *\n * APPLICATION-owned on purpose. The framework's equivalent list is a judgement about a typical\n * application's stack — `esbuild` follows vite, `express` follows webpack-dev-server, `mime`\n * follows express — and pinning those names was measured to break the docs toolchain. A real\n * application knows its own stack better than the framework does, so the list is seeded at\n * `wildo init` and owned from there. An absent file means no exclusions, which is honest for an\n * application that has never declared any.\n */\n static readExclusions(applicationRoot: string): string[] {\n const path = join(applicationRoot, APPLICATION_DEPENDENCY_EXCLUSIONS_RELATIVE);\n if (!existsSync(path)) return [];\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as { excludedNames?: Record<string, string> | string[] };\n const names = Array.isArray(parsed.excludedNames) ? parsed.excludedNames : Object.keys(parsed.excludedNames ?? {});\n return [...names].sort();\n }\n\n /** A key ending in `*` is a prefix match (`@astrojs/*`); anything else is exact. */\n static isExcluded(name: string, excludedNames: string[]): boolean {\n return excludedNames.some((key) => (key.endsWith('*') ? name.startsWith(key.slice(0, -1)) : key === name));\n }\n\n private static reconcileRootOverrides(input: {\n applicationRoot: string;\n derivedOverrides: Record<string, string>;\n write: boolean;\n }): ApplicationAlignmentFinding[] {\n if (!ApplicationDependencyAlignmentService.readManifest(join(input.applicationRoot, 'package.json'))) return [];\n // #2808: the effective settings, wherever pnpm 10 reads them; every write lands in pnpm-workspace.yaml.\n const settings = readApplicationPnpmSettings(input.applicationRoot);\n const current = settings.overrides ?? {};\n\n const findings: ApplicationAlignmentFinding[] = [];\n for (const setting of PNPM_OWNED_SETTINGS) {\n if (settings.sources[setting] !== PnpmSettingsSource.PACKAGE_JSON) continue;\n findings.push({\n manifestRelativePath: PnpmSettingsSource.PACKAGE_JSON,\n kind: ApplicationAlignmentFindingKind.SETTING_IN_PACKAGE_JSON,\n name: `pnpm.${setting}`,\n desired: PnpmSettingsSource.WORKSPACE_FILE,\n });\n }\n for (const [name, desired] of Object.entries(input.derivedOverrides)) {\n const existing = current[name];\n if (existing === desired) continue;\n findings.push({\n manifestRelativePath: PnpmSettingsSource.WORKSPACE_FILE,\n kind: existing === undefined ? ApplicationAlignmentFindingKind.OVERRIDE_MISSING : ApplicationAlignmentFindingKind.OVERRIDE_DRIFT,\n name,\n current: existing,\n desired,\n });\n }\n if (!findings.length || !input.write) return findings;\n\n // MERGE, never replace: the application's `@wildo-ai/*` pins, and any pin it authored itself,\n // are not this service's to decide — only the names the installed engine implies are.\n writeApplicationPnpmSettings(input.applicationRoot, { overrides: { ...current, ...input.derivedOverrides } });\n migrateApplicationPnpmSettings(input.applicationRoot);\n return findings;\n }\n\n private static reconcileMemberPeers(input: {\n applicationRoot: string;\n member: string;\n enginePeerClosure: Record<string, string[]>;\n write: boolean;\n }): ApplicationAlignmentFinding[] {\n const manifestPath = join(input.applicationRoot, input.member, 'package.json');\n const manifest = ApplicationDependencyAlignmentService.readManifest(manifestPath);\n if (!manifest) return [];\n\n const required = new Set<string>();\n for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] as const) {\n for (const name of Object.keys(manifest[field] ?? {})) {\n if (!name.startsWith(FRAMEWORK_SCOPE_PREFIX)) continue;\n for (const peerName of input.enginePeerClosure[name] ?? []) required.add(peerName);\n }\n }\n // A name already declared as a real dependency needs no peer entry — the override reaches it there.\n for (const field of ['dependencies', 'devDependencies', 'optionalDependencies'] as const) {\n for (const name of Object.keys(manifest[field] ?? {})) required.delete(name);\n }\n\n const peers = { ...(manifest.peerDependencies ?? {}) };\n const findings: ApplicationAlignmentFinding[] = [];\n const relativePath = input.member === '.' ? 'package.json' : `${relative('.', join(input.member, 'package.json'))}`;\n for (const name of [...required].sort()) {\n if (peers[name] === '*') continue;\n findings.push({\n manifestRelativePath: relativePath,\n kind: name in peers ? ApplicationAlignmentFindingKind.PEER_PINNED_IN_PLACE : ApplicationAlignmentFindingKind.PEER_MISSING,\n name,\n current: peers[name],\n desired: '*',\n });\n }\n if (!findings.length || !input.write) return findings;\n\n // `\"*\"` and never a version: the pin lives in overrides (pnpm-workspace.yaml), so a later framework bump reaches\n // the application without touching this block. Nothing is removed — a name the closure does not\n // require may still be the application's own.\n for (const finding of findings) peers[finding.name] = '*';\n manifest.peerDependencies = Object.fromEntries(Object.keys(peers).sort().map((name) => [name, peers[name]]));\n writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`, 'utf8');\n return findings;\n }\n\n private static readManifest(path: string): PackageManifest | null {\n if (!existsSync(path)) return null;\n return JSON.parse(readFileSync(path, 'utf8')) as PackageManifest;\n }\n\n /** Exposed for the scaffolder's exclusion seeding, which reads the framework's own list. */\n static readFrameworkExclusions(frameworkPath: string): Record<string, string> {\n const path = join(frameworkPath, 'scripts', 'app-dependency-alignment', 'propagated-engine-overrides.json');\n if (!existsSync(path)) return {};\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as { deliberatelyExcluded?: Record<string, string> };\n return parsed.deliberatelyExcluded ?? {};\n }\n\n}\n\n/**\n * The raw member patterns of a workspace file's `packages:` block, in authored order; `[]` when the file\n * is absent. Scoped to that block, as `scripts/pnpm-workspace-members.mjs` is: a scan of every `- ` line\n * also reads `onlyBuiltDependencies:` and the other list blocks as members.\n */\nexport function readWorkspacePackagePatterns(workspaceManifestPath: string): string[] {\n if (!existsSync(workspaceManifestPath)) return [];\n const patterns: string[] = [];\n let inPackages = false;\n for (const rawLine of readFileSync(workspaceManifestPath, 'utf8').split(/\\r?\\n/)) {\n if (/^packages:\\s*$/.test(rawLine)) {\n inPackages = true;\n continue;\n }\n // A new top-level key ends the block; comments and list items do not.\n if (inPackages && /^\\S/.test(rawLine)) break;\n if (!inPackages) continue;\n const item = rawLine.match(/^\\s*-\\s*['\"]?([^'\"#]+?)['\"]?\\s*(#.*)?$/);\n const pattern = item?.[1]?.trim();\n if (pattern) patterns.push(pattern);\n }\n return patterns;\n}\n\n/**\n * Expand `pnpm-workspace.yaml` member patterns into member directories, relative to the root.\n *\n * The same semantics as the framework's one reader, `scripts/pnpm-workspace-members.mjs` (#362),\n * which this published CLI cannot import (it ships without the framework's `scripts/`): a LITERAL\n * path, and a pattern with exactly ONE path segment that is `*` (a trailing `dir/*`, or an interior\n * one followed by a fixed tail, as in the providers-registry workspace's facet members, #2788), whose\n * matches count only when they hold a `package.json` (pnpm's own rule, and what keeps `dist/` and\n * `node_modules/` out). Anything else, such as `dir/**`, a `*` inside a segment, two wildcard\n * segments or a `!exclusion`, comes back in `unsupportedPatterns` for the caller to report, because a\n * member silently dropped makes every package it covers look aligned.\n */\nexport function expandWorkspaceMemberPatterns(\n root: string,\n patterns: readonly string[],\n): { members: string[]; unsupportedPatterns: string[] } {\n const members: string[] = [];\n const unsupportedPatterns: string[] = [];\n for (const raw of patterns) {\n const pattern = raw.replace(/^\\.\\//, '').replace(/\\/+$/, '');\n if (!pattern.includes('*') && !pattern.startsWith('!')) {\n members.push(pattern === '' ? '.' : pattern);\n continue;\n }\n const segments = pattern.split('/');\n const wildcardIndex = segments.indexOf('*');\n if (pattern.startsWith('!') || wildcardIndex === -1 || segments.some((segment, index) => index !== wildcardIndex && segment.includes('*'))) {\n unsupportedPatterns.push(raw);\n continue;\n }\n const parent = segments.slice(0, wildcardIndex).join('/');\n const tail = segments.slice(wildcardIndex + 1).join('/');\n let children: string[] = [];\n try {\n children = readdirSync(join(root, parent), { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => (tail === '' ? entry.name : `${entry.name}/${tail}`))\n .filter((member) => existsSync(join(root, parent, member, 'package.json')))\n .sort();\n } catch {\n // An absent parent directory expands to no members, as in pnpm.\n }\n members.push(...children.map((name) => (parent === '' ? name : `${parent}/${name}`)));\n }\n return { members, unsupportedPatterns };\n}\n\nfunction readJsonObject(path: string): Record<string, unknown> | undefined {\n try {\n const parsed: unknown = JSON.parse(readFileSync(path, 'utf8'));\n return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Each vendor pin an adopted provider module's recorded wiring wrote (#2789): name → its module, from the app lockfile. */\nfunction readAdoptedVendorPins(applicationRoot: string): Map<string, { moduleId: string; ref?: string }> {\n const owners = new Map<string, { moduleId: string; ref?: string }>();\n const lock = readJsonObject(join(applicationRoot, WILDO_SAAS_LOCK_RELATIVE_PATH)) as\n | { sections?: { modules?: { installed?: Record<string, { registration?: { moduleId?: string; providerWiring?: { vendorPins?: Record<string, string> } } }> } } }\n | undefined;\n for (const [moduleId, entry] of Object.entries(lock?.sections?.modules?.installed ?? {})) {\n for (const name of Object.keys(entry.registration?.providerWiring?.vendorPins ?? {})) owners.set(name, { moduleId, ref: entry.registration?.moduleId });\n }\n return owners;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"application-dependency-alignment.service.js","sourceRoot":"","sources":["../../../../src/services/application/application-dependency-alignment.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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AO,EAAE,mBAAmB,EAAE,CAAC;AAC1C,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC/D,OAAO,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAkC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnI,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,4HAA4H;AAC5H,SAAS,qBAAqB,CAAC,eAAuB;IACpD,MAAM,MAAM,GAAG,IAAI,GAAG,EAA8C,CAAC;IACrE,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,eAAe,EAAE,6BAA6B,CAAC,CAEnE,CAAC;IACd,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC;QACzF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,cAAc,EAAE,UAAU,IAAI,EAAE,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1J,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * ApplicationDependencyAlignmentService — align a STANDALONE application's dependency pins and\n * engine peer declarations against the `@wildo-ai/*` packages it actually has installed (issue #222).\n *\n * ## The problem this closes\n *\n * `wildo init` bakes three derived things into an application: the `@wildo-ai/*` version pins, the\n * third-party pins propagated from the framework's root `pnpm.overrides`, and the engine peer\n * declarations every workspace package must carry. All three are computed from the framework\n * CHECKOUT, at scaffold time. A standalone application has no checkout afterwards, so nothing\n * re-derives them: an application moved to a newer framework keeps the OLD third-party versions and\n * the OLD peer obligations — and the peer half cannot be corrected by reinstalling, because an\n * undeclared peer's resolution is sticky (issue #167).\n *\n * ## Why nothing new has to be published\n *\n * The publish lane already substitutes the framework's root override into every published manifest —\n * exact for `dependencies`, caret-widened for `peerDependencies`. So the pin set and the peer closure\n * are recoverable from the installed packages themselves. Measured against the real 1.1.1 packages in\n * a scaffolded application: of 150 recoverable propagated names, **143 reproduce the framework's own\n * root override exactly**; 5 differ only exact-vs-caret (names that appear ONLY as peers, where the\n * caret is the publish lane's deliberate widening for a consumer); and 2 differ by a major because\n * the framework's root moved AFTER 1.1.1 shipped — which is the point, not a defect. An application\n * aligns to the framework version it HAS, the only contract it can honour.\n *\n * That is why this service reads `node_modules` rather than a published manifest of pins: the data\n * cannot drift from the packages it describes, because it IS them.\n *\n * ## What it deliberately does NOT do\n *\n * It never changes a `@wildo-ai/*` version. Which framework release to adopt is the operator's\n * decision; everything else follows mechanically from it. The flow is:\n *\n * 1. bump the `@wildo-ai/*` entries in the application's overrides (pnpm-workspace.yaml)\n * 2. `pnpm install` (the new pin set cannot be read until the new version is on disk)\n * 3. `wildo align-deps --write`\n * 4. `pnpm install`\n *\n * `wildo update` runs that flow for a release upgrade (`update.command.ts`): the operator's decision\n * is its `--to <version>` / `--tag`, its step 1 is the bump, and its step 3 is the install → this\n * service → install. Use `align-deps` on its own only for the first alignment after `wildo init`.\n */\nimport { existsSync, readdirSync, readFileSync, writeFileSync } from 'fs';\nimport { dirname, join, relative } from 'path';\nimport {\n migrateApplicationPnpmSettings,\n PNPM_OWNED_SETTINGS,\n PnpmSettingsSource,\n readApplicationPnpmSettings,\n WILDO_SAAS_LOCK_RELATIVE_PATH,\n writeApplicationPnpmSettings,\n} from '@wildo-ai/platform-config-lib';\nimport { FRAMEWORK_OVERRIDES_MANIFEST_RELATIVE } from '@wildo-ai/application-creation-runtime';\n\nimport { resolveInstalledFrameworkAssetsRoot } from '~wildo-cli/services/framework/installed-framework-assets.service';\n\n/** Where an application declares the names its own toolchain owns. Seeded by `wildo init`. */\nexport const APPLICATION_DEPENDENCY_EXCLUSIONS_RELATIVE = '.wildo-saas/dependency-exclusions.json';\n\nconst FRAMEWORK_SCOPE_PREFIX = '@wildo-ai/';\nconst EXACT_SEMVER_PATTERN = /^\\d+\\.\\d+\\.\\d+$/;\n\ninterface PackageManifest {\n name?: string;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n peerDependenciesMeta?: Record<string, { optional?: boolean }>;\n optionalDependencies?: Record<string, string>;\n}\n\n/**\n * What is wrong with one manifest entry, and therefore what `--write` will do about it.\n *\n * The four are not degrees of the same thing — they split on TWO axes that need different repairs:\n * whether the name belongs in overrides (pnpm-workspace.yaml) or in the importer's own dependency list, and whether\n * it is ABSENT or present-and-wrong. `peer-pinned-in-place` is the one that reads oddly and matters\n * most: the peer IS declared, but at a concrete version rather than `\"*\"`, so the framework's override\n * cannot reach it and a later pin bump silently will not land.\n */\nexport enum ApplicationAlignmentFindingKind {\n /** The framework pins this name and the application's overrides (pnpm-workspace.yaml) does not carry it at all. */\n OVERRIDE_MISSING = 'override-missing',\n /** The application overrides the name, at a version the installed framework does not pin. */\n OVERRIDE_DRIFT = 'override-drift',\n /** A required engine peer the importer never declares, so `autoInstallPeers` resolves it unpinned. */\n PEER_MISSING = 'peer-missing',\n /** The peer is declared with a concrete version, which the override cannot rewrite. */\n PEER_PINNED_IN_PLACE = 'peer-pinned-in-place',\n /**\n * A pnpm setting Wildo owns (`overrides`, `onlyBuiltDependencies`, `neverBuiltDependencies`) still in `package.json` →\n * `pnpm`, which pnpm 11 does not read (#2808). `--write` moves it, value unchanged, into `pnpm-workspace.yaml`.\n */\n SETTING_IN_PACKAGE_JSON = 'setting-in-package-json',\n}\n\nexport interface ApplicationAlignmentFinding {\n /** Application-root-relative path of the manifest that needs the change. */\n manifestRelativePath: string;\n kind: ApplicationAlignmentFindingKind;\n name: string;\n current?: string;\n desired: string;\n}\n\n/**\n * What alignment REPORTS and never changes (#2789): removing a pin or a dependency needs to know who wrote it, and\n * nothing records that for these. The twin of `findDependencyOrphans` in the framework's alignment script, which this\n * published CLI cannot import.\n */\nexport enum ApplicationAlignmentReportKind {\n /** A root override no authority writes, no manifest declares, and the lockfile resolves nowhere: it pins nothing. */\n ORPHAN_OVERRIDE = 'orphan-override',\n /** An adopted provider module's vendor package, declared by a manifest outside that module's facets. */\n MISPLACED_DEPENDENCY = 'misplaced-dependency',\n}\n\nexport interface ApplicationAlignmentReport {\n manifestRelativePath: string;\n kind: ApplicationAlignmentReportKind;\n name: string;\n /** The override's value (orphan) or the module that owns the package (misplaced). */\n detail: string;\n}\n\nexport interface ApplicationAlignmentResult {\n /** `@wildo-ai/*` packages whose installed manifest was read, with the version found. */\n installedFrameworkPackages: Array<{ name: string; version: string }>;\n /** Third-party names the installed engine pins, after exclusions. */\n derivedOverrides: Record<string, string>;\n /** Per framework package, the transitive REQUIRED peers a consumer must declare. */\n enginePeerClosure: Record<string, string[]>;\n excludedNames: string[];\n findings: ApplicationAlignmentFinding[];\n /**\n * Workspace member patterns this reader cannot expand (`dir/**`, an interior `*`, a `!exclusion`).\n * The packages they cover were NOT aligned; a caller reports them rather than calling the run clean.\n */\n unsupportedWorkspacePatterns: string[];\n /** Report-only defects (#2789): never part of `findings`, never written. */\n reports: ApplicationAlignmentReport[];\n written: boolean;\n}\n\n/** The package an override key governs: `x>y@2` → `y`, `@s/n@^1` → `@s/n`. */\nexport function overrideTargetName(key: string): string {\n const target = key.includes('>') ? key.slice(key.lastIndexOf('>') + 1) : key;\n const at = target.lastIndexOf('@');\n return at > 0 ? target.slice(0, at) : target;\n}\n\n/**\n * Every package name a pnpm lockfile resolves. Only the `packages:` and `snapshots:` blocks are read: the lockfile's own\n * `overrides:` block carries keys like `foo@1`, which would count an orphan override as resolved (#2789 review F7).\n */\nexport function readResolvedPackageNames(lockText: string | undefined): Set<string> {\n const names = new Set<string>();\n if (lockText === undefined) return names;\n let inResolved = false;\n for (const line of lockText.split(/\\r?\\n/)) {\n if (/^\\S/.test(line)) {\n inResolved = /^(packages|snapshots):\\s*$/.test(line);\n continue;\n }\n if (!inResolved) continue;\n const match = /^ {2}'?((?:@[^/'\\s]+\\/)?[^@'\\s/]+)@/.exec(line);\n if (match) names.add(match[1]!);\n }\n return names;\n}\n\nconst DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'] as const;\n\n/**\n * The two report-only defects of ONE application (#2789), with the semantics of the framework script's twin:\n * an ORPHAN override (no authority writes it, no manifest declares it, the lockfile resolves it nowhere; a deliberate\n * pin on a transitive dependency is resolved, so it is never one) and a MISPLACED dependency (an adopted module's vendor\n * package declared outside that module's facets).\n */\nexport function findDependencyOrphans(input: {\n appOverrides: Record<string, unknown>;\n /** The application-root file the overrides were read from (#2808); `pnpm-workspace.yaml` when not given. */\n overridesRelativePath?: string;\n authoredKeys: ReadonlySet<string>;\n adoptedVendorPins: ReadonlyMap<string, { moduleId: string; ref?: string }>;\n manifests: ReadonlyArray<{ member: string; manifest: Record<string, unknown> | undefined }>;\n resolvedNames: ReadonlySet<string>;\n}): ApplicationAlignmentReport[] {\n const fieldsOf = (manifest: Record<string, unknown> | undefined) => DEPENDENCY_FIELDS\n .map((field) => manifest?.[field])\n .filter((value): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value));\n const declared = new Set(input.manifests.flatMap(({ manifest }) => fieldsOf(manifest).flatMap((field) => Object.keys(field))));\n const reports: ApplicationAlignmentReport[] = Object.keys(input.appOverrides)\n .filter((key) => !input.authoredKeys.has(key))\n .filter((key) => !overrideTargetName(key).startsWith('@wildo-ai/'))\n .filter((key) => !input.adoptedVendorPins.has(overrideTargetName(key)))\n .filter((key) => !declared.has(overrideTargetName(key)))\n .filter((key) => !input.resolvedNames.has(overrideTargetName(key)))\n .sort()\n .map((key) => ({ manifestRelativePath: input.overridesRelativePath ?? PnpmSettingsSource.WORKSPACE_FILE, kind: ApplicationAlignmentReportKind.ORPHAN_OVERRIDE, name: key, detail: String(input.appOverrides[key]) }));\n const misplaced: ApplicationAlignmentReport[] = [];\n for (const { member, manifest } of input.manifests) {\n for (const [name, owner] of input.adoptedVendorPins) {\n if (owner.ref !== undefined && member.startsWith(`providers/${owner.ref}/`)) continue;\n if (fieldsOf(manifest).some((field) => field[name] !== undefined)) {\n misplaced.push({ manifestRelativePath: join(member, 'package.json'), kind: ApplicationAlignmentReportKind.MISPLACED_DEPENDENCY, name, detail: owner.moduleId });\n }\n }\n }\n // Ordered like the framework script's report: by member, then name.\n return [...reports, ...misplaced.sort((a, b) => `${a.manifestRelativePath}/${a.name}`.localeCompare(`${b.manifestRelativePath}/${b.name}`))];\n}\n\nexport class ApplicationDependencyAlignmentService {\n /**\n * Compute (and optionally apply) the alignment for one application root.\n *\n * Reading is total and writing is per-manifest: a `--check` run touches nothing, and a `--write`\n * run rewrites only the manifests that actually have findings.\n */\n static align(input: {\n applicationRoot: string;\n write: boolean;\n /**\n * The framework-assets root whose alignment manifest names the pins `wildo init` writes (#3994). Defaults to the\n * running CLI's; `null` when there is none, and the orphan report then knows only the derived pins.\n */\n frameworkAssetsRoot?: string | null;\n }): ApplicationAlignmentResult {\n const { members: workspaceMembers, unsupportedPatterns: unsupportedWorkspacePatterns } =\n ApplicationDependencyAlignmentService.discoverWorkspaceMembers(input.applicationRoot);\n const installed = ApplicationDependencyAlignmentService.readInstalledFrameworkManifests({\n applicationRoot: input.applicationRoot,\n workspaceMembers,\n });\n if (installed.size === 0) {\n throw new Error(\n 'No @wildo-ai/* package could be resolved from this application — run `pnpm install` first. '\n + 'Alignment derives every pin from the framework packages the application HAS installed, so '\n + 'an empty node_modules would silently produce an empty pin set.',\n );\n }\n\n const excludedNames = ApplicationDependencyAlignmentService.readExclusions(input.applicationRoot);\n const derivedOverrides = ApplicationDependencyAlignmentService.deriveOverrides({ installed, excludedNames });\n const enginePeerClosure = ApplicationDependencyAlignmentService.deriveEnginePeerClosure({ installed, excludedNames });\n\n const findings: ApplicationAlignmentFinding[] = [];\n findings.push(...ApplicationDependencyAlignmentService.reconcileRootOverrides({\n applicationRoot: input.applicationRoot, derivedOverrides, write: input.write,\n }));\n for (const member of workspaceMembers) {\n findings.push(...ApplicationDependencyAlignmentService.reconcileMemberPeers({\n applicationRoot: input.applicationRoot, member, enginePeerClosure, write: input.write,\n }));\n }\n\n // #2789: report-only. Read after the writes above, so a run that just added a pin does not report it.\n const lockPath = join(input.applicationRoot, 'pnpm-lock.yaml');\n const settingsAfterWrite = readApplicationPnpmSettings(input.applicationRoot);\n const reports = findDependencyOrphans({\n appOverrides: settingsAfterWrite.overrides ?? {},\n overridesRelativePath: settingsAfterWrite.sources.overrides,\n authoredKeys: new Set([\n ...Object.keys(derivedOverrides),\n ...ApplicationDependencyAlignmentService.readFrameworkWrittenOverrideKeys(\n input.frameworkAssetsRoot === undefined ? resolveInstalledFrameworkAssetsRoot() : input.frameworkAssetsRoot,\n ),\n ]),\n adoptedVendorPins: readAdoptedVendorPins(input.applicationRoot),\n manifests: workspaceMembers.map((member) => ({ member, manifest: readJsonObject(join(input.applicationRoot, member, 'package.json')) })),\n resolvedNames: readResolvedPackageNames(existsSync(lockPath) ? readFileSync(lockPath, 'utf8') : undefined),\n });\n\n return {\n reports,\n installedFrameworkPackages: [...installed.entries()]\n .map(([name, manifest]) => ({ name, version: (manifest as { version?: string }).version ?? 'unknown' }))\n .sort((a, b) => a.name.localeCompare(b.name)),\n derivedOverrides,\n enginePeerClosure,\n excludedNames,\n findings,\n unsupportedWorkspacePatterns,\n written: input.write && findings.length > 0,\n };\n }\n\n /**\n * The application's own workspace members, plus its root (`.`).\n *\n * GENERATED drops are skipped: `.wildo-saas/wildo-dev-companion` has its manifest written by the\n * companion delivery on every start, so a declaration reconciled into it is erased.\n *\n * A member may be a GLOB, and one kind always is: `wildo registry add` wires a provider module as\n * `providers/<ref>/*`, one member per facet package. Reading members as literal paths dropped every\n * glob (no directory is literally named `*`), so an installed provider package was never aligned\n * (#2019 review). {@link expandWorkspaceMemberPatterns} expands them with the framework reader's semantics.\n */\n static discoverWorkspaceMembers(applicationRoot: string): { members: string[]; unsupportedPatterns: string[] } {\n const { members, unsupportedPatterns } = expandWorkspaceMemberPatterns(\n applicationRoot,\n readWorkspacePackagePatterns(join(applicationRoot, 'pnpm-workspace.yaml')),\n );\n return {\n members: [...new Set(['.', ...members])]\n .filter((member) => !member.startsWith('.wildo-saas/'))\n .filter((member) => existsSync(join(applicationRoot, member, 'package.json'))),\n unsupportedPatterns,\n };\n }\n\n /**\n * Every `@wildo-ai/*` manifest the application can resolve, keyed by package name.\n *\n * Resolution goes through `createRequire` from each workspace member rather than by walking\n * `node_modules/.pnpm`: the virtual store's directory naming is a pnpm implementation detail, while\n * `require.resolve` is the contract every runtime in the application already uses. A member that\n * cannot resolve a name simply contributes nothing — under pnpm's isolated layout only a package's\n * own declared dependencies are reachable from it, and that is exactly the set that matters.\n */\n static readInstalledFrameworkManifests(input: {\n applicationRoot: string;\n workspaceMembers: string[];\n }): Map<string, PackageManifest> {\n const found = new Map<string, PackageManifest>();\n const candidateNames = new Set<string>();\n\n for (const member of input.workspaceMembers) {\n const manifest = ApplicationDependencyAlignmentService.readManifest(\n join(input.applicationRoot, member, 'package.json'),\n );\n if (!manifest) continue;\n for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] as const) {\n for (const name of Object.keys(manifest[field] ?? {})) {\n if (name.startsWith(FRAMEWORK_SCOPE_PREFIX)) candidateNames.add(name);\n }\n }\n }\n // The root `pnpm.overrides` names every framework package the scaffolder pinned, including ones\n // no member declares directly — they are still installed, and their peers still land on the app.\n for (const name of Object.keys(readApplicationPnpmSettings(input.applicationRoot).overrides ?? {})) {\n if (name.startsWith(FRAMEWORK_SCOPE_PREFIX)) candidateNames.add(name);\n }\n\n // A framework package's own `@wildo-ai/*` dependencies are followed too: the closure is\n // transitive, and an application need never name `presets-components` to inherit its peers.\n const pending = [...candidateNames];\n while (pending.length > 0) {\n const name = pending.pop() as string;\n if (found.has(name)) continue;\n const manifest = ApplicationDependencyAlignmentService.resolveFrameworkManifest({\n applicationRoot: input.applicationRoot,\n workspaceMembers: input.workspaceMembers,\n name,\n });\n if (!manifest) continue;\n found.set(name, manifest);\n for (const field of ['dependencies', 'peerDependencies', 'optionalDependencies'] as const) {\n for (const dependencyName of Object.keys(manifest[field] ?? {})) {\n if (dependencyName.startsWith(FRAMEWORK_SCOPE_PREFIX) && !found.has(dependencyName)) pending.push(dependencyName);\n }\n }\n }\n return found;\n }\n\n /**\n * Find a framework package's manifest by walking `node_modules` upward from each workspace member,\n * which is Node's own package-DIRECTORY lookup.\n *\n * NOT `require.resolve('<name>/package.json')`, which was the first attempt and does not work: a\n * published `@wildo-ai/*` package declares an `exports` map, and an exports map that does not list\n * `./package.json` makes that specifier unresolvable. Measured on a freshly scaffolded application —\n * every one of the twenty packages was installed and every resolve threw, so the service reported\n * \"no framework package installed\" on a perfectly healthy tree. A directory walk asks the question\n * actually being asked (where does this package LIVE) and is unaffected by what a package exports.\n */\n private static resolveFrameworkManifest(input: {\n applicationRoot: string;\n workspaceMembers: string[];\n name: string;\n }): PackageManifest | null {\n for (const member of input.workspaceMembers) {\n let directory = join(input.applicationRoot, member);\n for (;;) {\n const candidate = join(directory, 'node_modules', input.name, 'package.json');\n if (existsSync(candidate)) return JSON.parse(readFileSync(candidate, 'utf8')) as PackageManifest;\n const parent = dirname(directory);\n if (parent === directory || !parent.startsWith(input.applicationRoot)) break;\n directory = parent;\n }\n }\n return null;\n }\n\n /**\n * The third-party pin set the installed engine implies.\n *\n * When a name appears with several specifiers the EXACT one wins. That is not arbitrary: the\n * publish lane writes the tested version exactly into `dependencies` and widens it to a caret in\n * `peerDependencies`, so both describe the same version and the exact form is the one the framework\n * actually ran. Measured, it reproduces the framework's own root override for 143 of 150 names.\n *\n * ## Only a name the framework's ROOT pins is pinned — never a package's own private dependency\n *\n * The propagation contract (`toolchain-installation-baseline.md`) moves exactly the names the framework\n * root pins, and a manifest says which those are: the publish lane writes a root pin EXACT into\n * `dependencies` and as a caret into `peerDependencies`, and source form writes it `*`. A dependency\n * the root does NOT pin keeps the range its package authored — `platform-config-lib`'s `jiti ^2.6.1`.\n * This used to pin every such range application-wide, and an override reaches every edge that names\n * the package: on 2026-09-24 it forced jiti 2 onto Docusaurus (which loads its config through jiti 1),\n * the documentation site could no longer read `export default config`, and the failed service tore the\n * whole dev stack down on start. So a name is pinned when some framework package declares it exact,\n * `*`, or as a peer; a name only ever declared as a private range stays that package's business.\n */\n static deriveOverrides(input: { installed: Map<string, PackageManifest>; excludedNames: string[] }): Record<string, string> {\n const candidates = new Map<string, Set<string>>();\n const rootPinned = new Set<string>();\n for (const manifest of input.installed.values()) {\n for (const field of ['dependencies', 'peerDependencies'] as const) {\n for (const [name, specifier] of Object.entries(manifest[field] ?? {})) {\n if (name.startsWith(FRAMEWORK_SCOPE_PREFIX)) continue;\n if (ApplicationDependencyAlignmentService.isExcluded(name, input.excludedNames)) continue;\n if (!candidates.has(name)) candidates.set(name, new Set());\n (candidates.get(name) as Set<string>).add(specifier);\n if (field === 'peerDependencies' || specifier === '*' || EXACT_SEMVER_PATTERN.test(specifier)) rootPinned.add(name);\n }\n }\n }\n const overrides: Record<string, string> = {};\n for (const [name, specifiers] of candidates) {\n if (!rootPinned.has(name)) continue;\n const exact = [...specifiers].find((specifier) => EXACT_SEMVER_PATTERN.test(specifier));\n overrides[name] = exact ?? [...specifiers][0];\n }\n return Object.fromEntries(Object.keys(overrides).sort().map((name) => [name, overrides[name]]));\n }\n\n /**\n * Per framework package, the transitive REQUIRED peers a consumer must declare.\n *\n * Optional peers (`peerDependenciesMeta`) are excluded — an optional peer is not an obligation, and\n * `saas-technical-doc` / `saas-website` use that field to say exactly this.\n */\n static deriveEnginePeerClosure(input: {\n installed: Map<string, PackageManifest>;\n excludedNames: string[];\n }): Record<string, string[]> {\n const closureOf = new Map<string, Set<string>>();\n\n const walk = (packageName: string, visiting: Set<string>): Set<string> => {\n const cached = closureOf.get(packageName);\n if (cached) return cached;\n const manifest = input.installed.get(packageName);\n if (!manifest || visiting.has(packageName)) return new Set();\n visiting.add(packageName);\n\n const peers = new Set<string>();\n const optional = manifest.peerDependenciesMeta ?? {};\n for (const name of Object.keys(manifest.peerDependencies ?? {})) {\n if (name.startsWith(FRAMEWORK_SCOPE_PREFIX)) continue;\n if (optional[name]?.optional) continue;\n if (ApplicationDependencyAlignmentService.isExcluded(name, input.excludedNames)) continue;\n peers.add(name);\n }\n for (const field of ['dependencies', 'peerDependencies', 'optionalDependencies'] as const) {\n for (const dependencyName of Object.keys(manifest[field] ?? {})) {\n if (!dependencyName.startsWith(FRAMEWORK_SCOPE_PREFIX)) continue;\n for (const inherited of walk(dependencyName, visiting)) peers.add(inherited);\n }\n }\n visiting.delete(packageName);\n closureOf.set(packageName, peers);\n return peers;\n };\n\n const result: Record<string, string[]> = {};\n for (const packageName of [...input.installed.keys()].sort()) {\n result[packageName] = [...walk(packageName, new Set())].sort();\n }\n return result;\n }\n\n /**\n * Names this application's own toolchain owns, which alignment must never pin.\n *\n * APPLICATION-owned on purpose. The framework's equivalent list is a judgement about a typical\n * application's stack — `esbuild` follows vite, `express` follows webpack-dev-server, `mime`\n * follows express — and pinning those names was measured to break the docs toolchain. A real\n * application knows its own stack better than the framework does, so the list is seeded at\n * `wildo init` and owned from there. An absent file means no exclusions, which is honest for an\n * application that has never declared any.\n */\n static readExclusions(applicationRoot: string): string[] {\n const path = join(applicationRoot, APPLICATION_DEPENDENCY_EXCLUSIONS_RELATIVE);\n if (!existsSync(path)) return [];\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as { excludedNames?: Record<string, string> | string[] };\n const names = Array.isArray(parsed.excludedNames) ? parsed.excludedNames : Object.keys(parsed.excludedNames ?? {});\n return [...names].sort();\n }\n\n /** A key ending in `*` is a prefix match (`@astrojs/*`); anything else is exact. */\n static isExcluded(name: string, excludedNames: string[]): boolean {\n return excludedNames.some((key) => (key.endsWith('*') ? name.startsWith(key.slice(0, -1)) : key === name));\n }\n\n private static reconcileRootOverrides(input: {\n applicationRoot: string;\n derivedOverrides: Record<string, string>;\n write: boolean;\n }): ApplicationAlignmentFinding[] {\n if (!ApplicationDependencyAlignmentService.readManifest(join(input.applicationRoot, 'package.json'))) return [];\n // #2808: the effective settings, wherever pnpm 10 reads them; every write lands in pnpm-workspace.yaml.\n const settings = readApplicationPnpmSettings(input.applicationRoot);\n const current = settings.overrides ?? {};\n\n const findings: ApplicationAlignmentFinding[] = [];\n for (const setting of PNPM_OWNED_SETTINGS) {\n if (settings.sources[setting] !== PnpmSettingsSource.PACKAGE_JSON) continue;\n findings.push({\n manifestRelativePath: PnpmSettingsSource.PACKAGE_JSON,\n kind: ApplicationAlignmentFindingKind.SETTING_IN_PACKAGE_JSON,\n name: `pnpm.${setting}`,\n desired: PnpmSettingsSource.WORKSPACE_FILE,\n });\n }\n for (const [name, desired] of Object.entries(input.derivedOverrides)) {\n const existing = current[name];\n if (existing === desired) continue;\n findings.push({\n manifestRelativePath: PnpmSettingsSource.WORKSPACE_FILE,\n kind: existing === undefined ? ApplicationAlignmentFindingKind.OVERRIDE_MISSING : ApplicationAlignmentFindingKind.OVERRIDE_DRIFT,\n name,\n current: existing,\n desired,\n });\n }\n if (!findings.length || !input.write) return findings;\n\n // MERGE, never replace: the application's `@wildo-ai/*` pins, and any pin it authored itself,\n // are not this service's to decide — only the names the installed engine implies are.\n writeApplicationPnpmSettings(input.applicationRoot, { overrides: { ...current, ...input.derivedOverrides } });\n migrateApplicationPnpmSettings(input.applicationRoot);\n return findings;\n }\n\n private static reconcileMemberPeers(input: {\n applicationRoot: string;\n member: string;\n enginePeerClosure: Record<string, string[]>;\n write: boolean;\n }): ApplicationAlignmentFinding[] {\n const manifestPath = join(input.applicationRoot, input.member, 'package.json');\n const manifest = ApplicationDependencyAlignmentService.readManifest(manifestPath);\n if (!manifest) return [];\n\n const required = new Set<string>();\n for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] as const) {\n for (const name of Object.keys(manifest[field] ?? {})) {\n if (!name.startsWith(FRAMEWORK_SCOPE_PREFIX)) continue;\n for (const peerName of input.enginePeerClosure[name] ?? []) required.add(peerName);\n }\n }\n // A name already declared as a real dependency needs no peer entry — the override reaches it there.\n for (const field of ['dependencies', 'devDependencies', 'optionalDependencies'] as const) {\n for (const name of Object.keys(manifest[field] ?? {})) required.delete(name);\n }\n\n const peers = { ...(manifest.peerDependencies ?? {}) };\n const findings: ApplicationAlignmentFinding[] = [];\n const relativePath = input.member === '.' ? 'package.json' : `${relative('.', join(input.member, 'package.json'))}`;\n for (const name of [...required].sort()) {\n if (peers[name] === '*') continue;\n findings.push({\n manifestRelativePath: relativePath,\n kind: name in peers ? ApplicationAlignmentFindingKind.PEER_PINNED_IN_PLACE : ApplicationAlignmentFindingKind.PEER_MISSING,\n name,\n current: peers[name],\n desired: '*',\n });\n }\n if (!findings.length || !input.write) return findings;\n\n // `\"*\"` and never a version: the pin lives in overrides (pnpm-workspace.yaml), so a later framework bump reaches\n // the application without touching this block. Nothing is removed — a name the closure does not\n // require may still be the application's own.\n for (const finding of findings) peers[finding.name] = '*';\n manifest.peerDependencies = Object.fromEntries(Object.keys(peers).sort().map((name) => [name, peers[name]]));\n writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`, 'utf8');\n return findings;\n }\n\n private static readManifest(path: string): PackageManifest | null {\n if (!existsSync(path)) return null;\n return JSON.parse(readFileSync(path, 'utf8')) as PackageManifest;\n }\n\n /**\n * The override keys `wildo init` writes into every application (#3994): `propagatedOverrideKeys` and\n * `additionalPropagatedOverrideKeys` of the alignment manifest that travels with the CLI.\n *\n * The orphan report needs them because derivation cannot see two kinds of pin the framework writes on purpose:\n * a name NO framework manifest declares (`stripe`: the engine lazily `require`s the SDK, #239), and a peer of a\n * framework package this application has not installed (`@mdx-js/react`, a peer of `saas-website`, in an\n * application with no website). Both were reported as \"no authority writes it — remove it\", which told the\n * operator to undo the framework's own pin. The manifest IS that authority. Opt-in package pins are not\n * included: they are written only beside the package, so once it is gone they really do pin nothing.\n *\n * Returns `[]` when no manifest is reachable: the report then falls back to the derived pins alone, which can\n * only over-report a warning, never hide one.\n */\n static readFrameworkWrittenOverrideKeys(frameworkAssetsRoot: string | null): string[] {\n if (frameworkAssetsRoot === null) return [];\n const path = join(frameworkAssetsRoot, FRAMEWORK_OVERRIDES_MANIFEST_RELATIVE);\n if (!existsSync(path)) return [];\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as { propagatedOverrideKeys?: unknown; additionalPropagatedOverrideKeys?: unknown };\n return [parsed.propagatedOverrideKeys, parsed.additionalPropagatedOverrideKeys]\n .flatMap((keys) => (Array.isArray(keys) ? keys : []))\n .filter((key): key is string => typeof key === 'string');\n }\n\n /** Exposed for the scaffolder's exclusion seeding, which reads the framework's own list. */\n static readFrameworkExclusions(frameworkPath: string): Record<string, string> {\n const path = join(frameworkPath, FRAMEWORK_OVERRIDES_MANIFEST_RELATIVE);\n if (!existsSync(path)) return {};\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as { deliberatelyExcluded?: Record<string, string> };\n return parsed.deliberatelyExcluded ?? {};\n }\n\n}\n\n/**\n * The raw member patterns of a workspace file's `packages:` block, in authored order; `[]` when the file\n * is absent. Scoped to that block, as `scripts/pnpm-workspace-members.mjs` is: a scan of every `- ` line\n * also reads `onlyBuiltDependencies:` and the other list blocks as members.\n */\nexport function readWorkspacePackagePatterns(workspaceManifestPath: string): string[] {\n if (!existsSync(workspaceManifestPath)) return [];\n const patterns: string[] = [];\n let inPackages = false;\n for (const rawLine of readFileSync(workspaceManifestPath, 'utf8').split(/\\r?\\n/)) {\n if (/^packages:\\s*$/.test(rawLine)) {\n inPackages = true;\n continue;\n }\n // A new top-level key ends the block; comments and list items do not.\n if (inPackages && /^\\S/.test(rawLine)) break;\n if (!inPackages) continue;\n const item = rawLine.match(/^\\s*-\\s*['\"]?([^'\"#]+?)['\"]?\\s*(#.*)?$/);\n const pattern = item?.[1]?.trim();\n if (pattern) patterns.push(pattern);\n }\n return patterns;\n}\n\n/**\n * Expand `pnpm-workspace.yaml` member patterns into member directories, relative to the root.\n *\n * The same semantics as the framework's one reader, `scripts/pnpm-workspace-members.mjs` (#362),\n * which this published CLI cannot import (it ships without the framework's `scripts/`): a LITERAL\n * path, and a pattern with exactly ONE path segment that is `*` (a trailing `dir/*`, or an interior\n * one followed by a fixed tail, as in the providers-registry workspace's facet members, #2788), whose\n * matches count only when they hold a `package.json` (pnpm's own rule, and what keeps `dist/` and\n * `node_modules/` out). Anything else, such as `dir/**`, a `*` inside a segment, two wildcard\n * segments or a `!exclusion`, comes back in `unsupportedPatterns` for the caller to report, because a\n * member silently dropped makes every package it covers look aligned.\n */\nexport function expandWorkspaceMemberPatterns(\n root: string,\n patterns: readonly string[],\n): { members: string[]; unsupportedPatterns: string[] } {\n const members: string[] = [];\n const unsupportedPatterns: string[] = [];\n for (const raw of patterns) {\n const pattern = raw.replace(/^\\.\\//, '').replace(/\\/+$/, '');\n if (!pattern.includes('*') && !pattern.startsWith('!')) {\n members.push(pattern === '' ? '.' : pattern);\n continue;\n }\n const segments = pattern.split('/');\n const wildcardIndex = segments.indexOf('*');\n if (pattern.startsWith('!') || wildcardIndex === -1 || segments.some((segment, index) => index !== wildcardIndex && segment.includes('*'))) {\n unsupportedPatterns.push(raw);\n continue;\n }\n const parent = segments.slice(0, wildcardIndex).join('/');\n const tail = segments.slice(wildcardIndex + 1).join('/');\n let children: string[] = [];\n try {\n children = readdirSync(join(root, parent), { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => (tail === '' ? entry.name : `${entry.name}/${tail}`))\n .filter((member) => existsSync(join(root, parent, member, 'package.json')))\n .sort();\n } catch {\n // An absent parent directory expands to no members, as in pnpm.\n }\n members.push(...children.map((name) => (parent === '' ? name : `${parent}/${name}`)));\n }\n return { members, unsupportedPatterns };\n}\n\nfunction readJsonObject(path: string): Record<string, unknown> | undefined {\n try {\n const parsed: unknown = JSON.parse(readFileSync(path, 'utf8'));\n return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Each vendor pin an adopted provider module's recorded wiring wrote (#2789): name → its module, from the app lockfile. */\nfunction readAdoptedVendorPins(applicationRoot: string): Map<string, { moduleId: string; ref?: string }> {\n const owners = new Map<string, { moduleId: string; ref?: string }>();\n const lock = readJsonObject(join(applicationRoot, WILDO_SAAS_LOCK_RELATIVE_PATH)) as\n | { sections?: { modules?: { installed?: Record<string, { registration?: { moduleId?: string; providerWiring?: { vendorPins?: Record<string, string> } } }> } } }\n | undefined;\n for (const [moduleId, entry] of Object.entries(lock?.sections?.modules?.installed ?? {})) {\n for (const name of Object.keys(entry.registration?.providerWiring?.vendorPins ?? {})) owners.set(name, { moduleId, ref: entry.registration?.moduleId });\n }\n return owners;\n}\n"]}
|
|
@@ -37,6 +37,19 @@ export interface ApplicationRuntimeBootstrapResult {
|
|
|
37
37
|
}
|
|
38
38
|
export declare class ApplicationRuntimeBootstrapService {
|
|
39
39
|
static initialize(input: ApplicationRuntimeBootstrapInput): Promise<ApplicationRuntimeBootstrapResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Refuse to report materialization when a minion or worker the declaration names got no target.
|
|
42
|
+
*
|
|
43
|
+
* {@link assertRuntimeEnvOnDisk} checks the targets that were BUILT, so it cannot see one that never was: on reference
|
|
44
|
+
* run 44255624884 the target builders read a cached declaration with no minions, the check verified the five targets
|
|
45
|
+
* it was given, and the run reported "0 worker, 0 minion target(s)" as a success while apps-manager had just minted
|
|
46
|
+
* five minions and a worker from the declaration this run resolved. This compares against THAT declaration
|
|
47
|
+
* (`prepared.runtimeTarget.managedDeclaration`, the one registration sent), so the two cannot disagree in silence again.
|
|
48
|
+
*
|
|
49
|
+
* A degraded registration may skip a runtime whose own secret could not be reconstructed offline: that skip is the
|
|
50
|
+
* documented degraded behaviour (its runtime keeps its existing `.env`), so it is not counted as missing here.
|
|
51
|
+
*/
|
|
52
|
+
private static assertEveryDeclaredRuntimeProjected;
|
|
40
53
|
/**
|
|
41
54
|
* Refuse to report materialization for a target whose `.env` is not on disk.
|
|
42
55
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-runtime-bootstrap.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/application-runtime-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"application-runtime-bootstrap.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/application-runtime-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAYH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAGlG,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAM5G,MAAM,WAAW,gCAAgC;IAC/C,GAAG,EAAE,gCAAgC,CAAC;IACtC,WAAW,EAAE,sBAAsB,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iCAAiC;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,kCAAkC;WAChC,UAAU,CACrB,KAAK,EAAE,gCAAgC,GACtC,OAAO,CAAC,iCAAiC,CAAC;IA4J7C;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,mCAAmC;IAwBlD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAoCtC"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { existsSync } from 'node:fs';
|
|
20
20
|
import { join, relative } from 'node:path';
|
|
21
|
+
import { ApplicationRuntimePrincipalKind, buildRuntimePrincipalKey, enumerateDeclaredRuntimePrincipals, } from '@wildo-ai/platform-config-lib';
|
|
21
22
|
import { FILE_NAMES } from '../../infrastructure/io/io.schemas.js';
|
|
22
23
|
import { AppBootstrapService } from '../../services/application/app-bootstrap.service.js';
|
|
23
24
|
import { sync as envSync } from '../../services/environment/env-sync.service.js';
|
|
@@ -138,6 +139,7 @@ export class ApplicationRuntimeBootstrapService {
|
|
|
138
139
|
* that never completed `wildo local init` now says so here instead of compiling happily and
|
|
139
140
|
* running nothing.
|
|
140
141
|
*/
|
|
142
|
+
ApplicationRuntimeBootstrapService.assertEveryDeclaredRuntimeProjected(prepared, applicationWorkers, applicationMinions);
|
|
141
143
|
ApplicationRuntimeBootstrapService.assertRuntimeEnvOnDisk([...applicationBackends, ...companionApis, ...applicationFrontends,
|
|
142
144
|
...applicationWorkers, ...applicationMinions], input.log);
|
|
143
145
|
input.log.success(` Application runtime materialized: ${result.backendCount} backend, `
|
|
@@ -145,6 +147,36 @@ export class ApplicationRuntimeBootstrapService {
|
|
|
145
147
|
+ `${result.workerCount} worker, ${result.minionCount} minion target(s).`);
|
|
146
148
|
return result;
|
|
147
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Refuse to report materialization when a minion or worker the declaration names got no target.
|
|
152
|
+
*
|
|
153
|
+
* {@link assertRuntimeEnvOnDisk} checks the targets that were BUILT, so it cannot see one that never was: on reference
|
|
154
|
+
* run 44255624884 the target builders read a cached declaration with no minions, the check verified the five targets
|
|
155
|
+
* it was given, and the run reported "0 worker, 0 minion target(s)" as a success while apps-manager had just minted
|
|
156
|
+
* five minions and a worker from the declaration this run resolved. This compares against THAT declaration
|
|
157
|
+
* (`prepared.runtimeTarget.managedDeclaration`, the one registration sent), so the two cannot disagree in silence again.
|
|
158
|
+
*
|
|
159
|
+
* A degraded registration may skip a runtime whose own secret could not be reconstructed offline: that skip is the
|
|
160
|
+
* documented degraded behaviour (its runtime keeps its existing `.env`), so it is not counted as missing here.
|
|
161
|
+
*/
|
|
162
|
+
static assertEveryDeclaredRuntimeProjected(prepared, workers, minions) {
|
|
163
|
+
const projected = new Set([
|
|
164
|
+
...workers.map((target) => buildRuntimePrincipalKey({ kind: ApplicationRuntimePrincipalKind.WORKER, name: target.workerName })),
|
|
165
|
+
...minions.map((target) => buildRuntimePrincipalKey({ kind: ApplicationRuntimePrincipalKind.MINION, name: target.minionName })),
|
|
166
|
+
]);
|
|
167
|
+
const missing = enumerateDeclaredRuntimePrincipals(prepared.runtimeTarget.managedDeclaration)
|
|
168
|
+
.filter((principal) => principal.kind === ApplicationRuntimePrincipalKind.MINION || principal.kind === ApplicationRuntimePrincipalKind.WORKER)
|
|
169
|
+
.map(buildRuntimePrincipalKey)
|
|
170
|
+
.filter((key) => !projected.has(key))
|
|
171
|
+
.filter((key) => !(prepared.degraded === true && prepared.runtimePrincipalCredentials?.[key] === undefined));
|
|
172
|
+
if (missing.length === 0)
|
|
173
|
+
return;
|
|
174
|
+
throw new Error(`The declaration names ${missing.length} runtime(s) that got no env target: ${missing.join(', ')}. `
|
|
175
|
+
+ 'Their identities were minted from wildo.saas.config.ts as registration read it, but no `.env` was written for '
|
|
176
|
+
+ 'them, so each would start without one and refuse its unset APPLICATION_ENV. The env targets were built from a '
|
|
177
|
+
+ 'different reading of the declaration than the one registration sent (it changed during this run, or a reader '
|
|
178
|
+
+ 'served an earlier evaluation of it); run the same command again.');
|
|
179
|
+
}
|
|
148
180
|
/**
|
|
149
181
|
* Refuse to report materialization for a target whose `.env` is not on disk.
|
|
150
182
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-runtime-bootstrap.service.js","sourceRoot":"","sources":["../../../../src/services/application/application-runtime-bootstrap.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uDAAuD,CAAC;AAE5F,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6DAA6D,CAAC;AAC3G,OAAO,EAAE,4CAA4C,EAAE,MAAM,mDAAmD,CAAC;AACjH,OAAO,EAAE,iDAAiD,EAAE,MAAM,yDAAyD,CAAC;AAoB5H,MAAM,OAAO,kCAAkC;IAC7C,MAAM,CAAC,KAAK,CAAC,UAAU,CACrB,KAAuC;QAEvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,GAAG,CAAC,IAAI,6BAA6B,CAAC,CAAC;QACjF,CAAC;QAED;;;;;;;WAOG;QACH,MAAM,WAAW,GAAG,4BAA4B,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAEpE,MAAM,qBAAqB,GAAG;YAC5B,GAAG,EAAE,WAAW;YAChB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,QAA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tB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;aACrF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAEvC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,CACN,sCAAsC,SAAS,CAAC,MAAM,aAAa;kBACjE,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,4DAA4D,CAAC,CAAC,CAAC,EAAE,CAAC,CAChG,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CACb,0CAA0C,OAAO,CAAC,MAAM,OAAO,OAAO,CAAC,MAAM,eAAe;cAC1F,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;cACzF,8FAA8F;cAC9F,qFAAqF;cACrF,6EAA6E,CAChF,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * Canonical application-runtime bootstrap orchestration.\n *\n * This service is the single local lifecycle seam that turns an authored SaaS\n * application declaration into runnable process configuration:\n *\n * apps-manager registration by stable slug\n * -> bootstrap credential fetch\n * -> derived APPLICATION_ID persistence\n * -> backend/companion/frontend/worker/minion target projection\n * -> generated env materialization\n * -> declaration convergence, when registration degraded and so did not apply it\n * -> postcondition: JWT door + stored config compared against the declaration\n *\n * Callers must make apps-manager ready before entering this service. Keeping\n * that boundary explicit prevents application processes from racing the\n * database-owned identity/config/secrets records they consume at startup.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\n\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport type { Logger } from '~wildo-cli/kernel/types';\nimport { AppBootstrapService } from '~wildo-cli/services/application/app-bootstrap.service';\nimport type { PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport { sync as envSync } from '~wildo-cli/services/environment/env-sync.service';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport { EnvironmentUtils } from '~wildo-cli/services/environment/environment.service';\nimport { hydrateEnvironmentFromConfig } from '~wildo-cli/services/environment/environment-hydration.utils';\nimport { ApplicationInitializationVerificationService } from './application-initialization-verification.service';\nimport { DegradedRegistrationDeclarationConvergenceService } from './degraded-registration-declaration-convergence.service';\n\nexport interface ApplicationRuntimeBootstrapInput {\n env: PlatformEnvironmentConfiguration;\n credentials: PlatformEnvSecretsJson;\n frameworkPath: string;\n saasRoot: string;\n isFrameworkDeveloper: boolean;\n requestedAppSlug?: string | undefined;\n log: Logger;\n}\n\nexport interface ApplicationRuntimeBootstrapResult {\n backendCount: number;\n companionCount: number;\n frontendCount: number;\n workerCount: number;\n minionCount: number;\n}\n\nexport class ApplicationRuntimeBootstrapService {\n static async initialize(\n input: ApplicationRuntimeBootstrapInput,\n ): Promise<ApplicationRuntimeBootstrapResult> {\n const config = EnvironmentUtils.loadConfigJson(input.env.name);\n if (!config) {\n throw new Error(`No config for '${input.env.name}'. Run 'wildo setup' first.`);\n }\n\n /**\n * Reconcile the caller's environment record against `config.json` before any target is\n * projected from it. The record is a registry CACHE that persists only a subset of the\n * authored environment, so an identity field authored since the last write reads as\n * `undefined` here and every generator silently takes its default — see the contract on\n * {@link hydrateEnvironmentFromConfig} for what that cost when the default was `http`\n * against a TLS dev edge.\n */\n const resolvedEnv = hydrateEnvironmentFromConfig(input.env, config);\n\n const registeredTargetInput = {\n env: resolvedEnv,\n credentials: input.credentials,\n saasRoot: input.saasRoot,\n config,\n requestedAppSlug: input.requestedAppSlug,\n };\n\n input.log.info(' Registering application once and materializing every runtime target from one snapshot...');\n\n const prepared = await AppBootstrapService.prepareApplicationEnvTargets(registeredTargetInput);\n if (!prepared) {\n throw new Error(\n 'Application bootstrap resolved no application target. Check wildo.saas.config.ts and the selected application slug.',\n );\n }\n const projectionInput = { ...registeredTargetInput, prepared };\n\n // These builders are projections over the same prepared registration/credential generation. They no\n // longer make independent initialize + credential-fetch requests, so a single logical bootstrap cannot\n // mix observations from multiple control-plane generations.\n const applicationBackends = await AppBootstrapService.buildApplicationBackendTargets(\n projectionInput,\n );\n const companionApis = await AppBootstrapService.buildApplicationCompanionTargets(\n projectionInput,\n );\n const applicationWorkers = await AppBootstrapService.buildApplicationWorkerTargets(\n projectionInput,\n );\n const applicationMinions = await AppBootstrapService.buildApplicationMinionTargets(\n projectionInput,\n );\n const applicationFrontends = await AppBootstrapService.buildApplicationFrontendTargets({\n saasRoot: input.saasRoot,\n requestedAppSlug: input.requestedAppSlug,\n prepared,\n });\n\n const result: ApplicationRuntimeBootstrapResult = {\n backendCount: applicationBackends.length,\n companionCount: companionApis.length,\n frontendCount: applicationFrontends.length,\n workerCount: applicationWorkers.length,\n minionCount: applicationMinions.length,\n };\n const targetCount = Object.values(result).reduce((total, count) => total + count, 0);\n if (targetCount === 0) {\n throw new Error(\n 'Application bootstrap resolved no runtime targets. Check wildo.saas.config.ts and the selected application slug.',\n );\n }\n\n await envSync(\n resolvedEnv,\n input.credentials,\n {\n frameworkPath: input.frameworkPath,\n isFrameworkDeveloper: input.isFrameworkDeveloper,\n // Without it the foreign-owner skip in `envSync` can never apply, so `--register-only` — whose contract is\n // \"no shared substrate is touched\" — rewrote every platform service's env from THIS application (#1112).\n invokingAppRoot: input.saasRoot,\n applicationBackends,\n companionApis,\n applicationFrontends,\n applicationWorkers,\n applicationMinions,\n },\n input.log,\n );\n\n /*\n * Converge, then verify. A non-degraded registration has already applied the declaration through\n * `/initialize`; a DEGRADED one never called it, so the postcondition below would report the\n * author's own edit as drift. Apply the missing step first — see the service for exactly what it\n * will and will not apply unattended.\n */\n // Name what registration applied, so an edited declaration is never applied silently.\n if (prepared.declarationConvergedFields !== undefined && prepared.declarationConvergedFields.length > 0) {\n input.log.info(\n ` Applied wildo.saas.config.ts to the stored config of '${prepared.runtimeTarget.appSlug}' `\n + `— ${prepared.declarationConvergedFields.length} slice(s):`,\n );\n for (const field of prepared.declarationConvergedFields) {\n input.log.info(` • ${field}`);\n }\n }\n if (prepared.degraded) {\n await DegradedRegistrationDeclarationConvergenceService.converge({\n env: resolvedEnv,\n credentials: input.credentials,\n appSlug: prepared.runtimeTarget.appSlug,\n managedDeclaration: prepared.runtimeTarget.managedDeclaration,\n log: input.log,\n });\n }\n\n input.log.info(' Verifying the registered platform JWT door and managed application config...');\n await ApplicationInitializationVerificationService.assertCoherent({\n env: resolvedEnv,\n credentials: input.credentials,\n appSlug: prepared.runtimeTarget.appSlug,\n // The audience of apps-manager's signed answer (#2950): the id this run's registration returned.\n applicationId: prepared.bootstrapCredentials.APPLICATION_ID,\n // The declaration this run initialized against — what makes the postcondition a COMPARISON\n // rather than an existence assertion (issue #97).\n managedDeclaration: prepared.runtimeTarget.managedDeclaration,\n });\n\n /*\n * The claim below says \"materialized\". Make it TRUE rather than hopeful.\n *\n * Every target here is a process that reads its `.env` at startup and fails without it, so\n * \"materialized\" has to mean the file is on disk — not that a writer was invoked. Until\n * 2026-09-10 it meant the second: the application env writes were gated on framework-developer\n * mode, so an app-creator application was told \"1 backend, 1 companion, 1 frontend materialized\"\n * with zero `.env` files written, and the failure surfaced much later and somewhere else — the\n * companion dying on `APPLICATION_ID ... undefined` inside `pnpm --parallel`, which took the\n * rest of the stack down with it and named nothing.\n *\n * A postcondition here is worth more than a checker: it fires in the run that caused it, names\n * the files, and cannot be true-by-accident. It also guards the reverse direction — a project\n * that never completed `wildo local init` now says so here instead of compiling happily and\n * running nothing.\n */\n ApplicationRuntimeBootstrapService.assertRuntimeEnvOnDisk(\n [...applicationBackends, ...companionApis, ...applicationFrontends,\n ...applicationWorkers, ...applicationMinions],\n input.log,\n );\n\n input.log.success(\n ` Application runtime materialized: ${result.backendCount} backend, `\n + `${result.companionCount} companion, ${result.frontendCount} frontend, `\n + `${result.workerCount} worker, ${result.minionCount} minion target(s).`,\n );\n return result;\n }\n\n /**\n * Refuse to report materialization for a target whose `.env` is not on disk.\n *\n * @see the note at the call site for the defect this exists to prevent.\n */\n private static assertRuntimeEnvOnDisk(\n targets: readonly { applicationRoot: string; relativeDir: string }[],\n log: Logger,\n ): void {\n /*\n * Only targets that actually carry both path fields are checkable. The type requires them, so a\n * target without them is a test double rather than a real runtime target — this postcondition\n * must not turn a partial mock into a crash (`join(undefined, ...)` throws a TypeError that\n * reads as a bug in the thing being verified). Anything skipped is REPORTED rather than hidden,\n * so a real target that somehow lost its anchor is still visible.\n */\n const checkable = targets.filter(\n (target) => typeof target?.applicationRoot === 'string' && typeof target?.relativeDir === 'string',\n );\n const skipped = targets.length - checkable.length;\n const missing = checkable\n .map((target) => join(target.applicationRoot, target.relativeDir, FILE_NAMES.DOT_ENV))\n .filter((path) => !existsSync(path));\n\n if (missing.length === 0) {\n log.info(\n ` Runtime env verified on disk for ${checkable.length} target(s).`\n + (skipped > 0 ? ` (${skipped} target(s) carried no path anchor and were not checkable.)` : ''),\n );\n return;\n }\n\n const applicationRoot = targets[0]?.applicationRoot ?? process.cwd();\n throw new Error(\n `Application runtime env is missing for ${missing.length} of ${targets.length} target(s):\\n`\n + `${missing.map((path) => ` - ${relative(applicationRoot, path) || path}`).join('\\n')}\\n`\n + 'Each of these is read at process startup, so the application would compile and then fail to '\n + 'run with an unrelated-looking validation error. Re-run `wildo local init` for this '\n + 'application; if it persists, the env generator did not receive this target.',\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"application-runtime-bootstrap.service.js","sourceRoot":"","sources":["../../../../src/services/application/application-runtime-bootstrap.service.ts"],"names":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OAAO,GAAG,SAAS;aACtB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;aACrF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAEvC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,CACN,sCAAsC,SAAS,CAAC,MAAM,aAAa;kBACjE,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,4DAA4D,CAAC,CAAC,CAAC,EAAE,CAAC,CAChG,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACrE,MAAM,IAAI,KAAK,CACb,0CAA0C,OAAO,CAAC,MAAM,OAAO,OAAO,CAAC,MAAM,eAAe;cAC1F,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;cACzF,8FAA8F;cAC9F,qFAAqF;cACrF,6EAA6E,CAChF,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * Canonical application-runtime bootstrap orchestration.\n *\n * This service is the single local lifecycle seam that turns an authored SaaS\n * application declaration into runnable process configuration:\n *\n * apps-manager registration by stable slug\n * -> bootstrap credential fetch\n * -> derived APPLICATION_ID persistence\n * -> backend/companion/frontend/worker/minion target projection\n * -> generated env materialization\n * -> declaration convergence, when registration degraded and so did not apply it\n * -> postcondition: JWT door + stored config compared against the declaration\n *\n * Callers must make apps-manager ready before entering this service. Keeping\n * that boundary explicit prevents application processes from racing the\n * database-owned identity/config/secrets records they consume at startup.\n */\n\nimport { existsSync } from 'node:fs';\nimport { join, relative } from 'node:path';\n\nimport {\n ApplicationRuntimePrincipalKind,\n buildRuntimePrincipalKey,\n enumerateDeclaredRuntimePrincipals,\n} from '@wildo-ai/platform-config-lib';\n\nimport { FILE_NAMES } from '~wildo-cli/infrastructure/io/io.schemas';\nimport type { Logger } from '~wildo-cli/kernel/types';\nimport { AppBootstrapService, type PreparedApplicationEnvTargets } from '~wildo-cli/services/application/app-bootstrap.service';\nimport type { PlatformEnvSecretsJson } from '~wildo-cli/services/credentials/credentials.schemas';\nimport { sync as envSync } from '~wildo-cli/services/environment/env-sync.service';\nimport type { ApplicationMinionEnvTarget, ApplicationWorkerEnvTarget } from '~wildo-cli/services/environment/env-configuration-generator.service';\nimport type { PlatformEnvironmentConfiguration } from '~wildo-cli/services/environment/environment.schemas';\nimport { EnvironmentUtils } from '~wildo-cli/services/environment/environment.service';\nimport { hydrateEnvironmentFromConfig } from '~wildo-cli/services/environment/environment-hydration.utils';\nimport { ApplicationInitializationVerificationService } from './application-initialization-verification.service';\nimport { DegradedRegistrationDeclarationConvergenceService } from './degraded-registration-declaration-convergence.service';\n\nexport interface ApplicationRuntimeBootstrapInput {\n env: PlatformEnvironmentConfiguration;\n credentials: PlatformEnvSecretsJson;\n frameworkPath: string;\n saasRoot: string;\n isFrameworkDeveloper: boolean;\n requestedAppSlug?: string | undefined;\n log: Logger;\n}\n\nexport interface ApplicationRuntimeBootstrapResult {\n backendCount: number;\n companionCount: number;\n frontendCount: number;\n workerCount: number;\n minionCount: number;\n}\n\nexport class ApplicationRuntimeBootstrapService {\n static async initialize(\n input: ApplicationRuntimeBootstrapInput,\n ): Promise<ApplicationRuntimeBootstrapResult> {\n const config = EnvironmentUtils.loadConfigJson(input.env.name);\n if (!config) {\n throw new Error(`No config for '${input.env.name}'. Run 'wildo setup' first.`);\n }\n\n /**\n * Reconcile the caller's environment record against `config.json` before any target is\n * projected from it. The record is a registry CACHE that persists only a subset of the\n * authored environment, so an identity field authored since the last write reads as\n * `undefined` here and every generator silently takes its default — see the contract on\n * {@link hydrateEnvironmentFromConfig} for what that cost when the default was `http`\n * against a TLS dev edge.\n */\n const resolvedEnv = hydrateEnvironmentFromConfig(input.env, config);\n\n const registeredTargetInput = {\n env: resolvedEnv,\n credentials: input.credentials,\n saasRoot: input.saasRoot,\n config,\n requestedAppSlug: input.requestedAppSlug,\n };\n\n input.log.info(' Registering application once and materializing every runtime target from one snapshot...');\n\n const prepared = await AppBootstrapService.prepareApplicationEnvTargets(registeredTargetInput);\n if (!prepared) {\n throw new Error(\n 'Application bootstrap resolved no application target. Check wildo.saas.config.ts and the selected application slug.',\n );\n }\n const projectionInput = { ...registeredTargetInput, prepared };\n\n // These builders are projections over the same prepared registration/credential generation. They no\n // longer make independent initialize + credential-fetch requests, so a single logical bootstrap cannot\n // mix observations from multiple control-plane generations.\n const applicationBackends = await AppBootstrapService.buildApplicationBackendTargets(\n projectionInput,\n );\n const companionApis = await AppBootstrapService.buildApplicationCompanionTargets(\n projectionInput,\n );\n const applicationWorkers = await AppBootstrapService.buildApplicationWorkerTargets(\n projectionInput,\n );\n const applicationMinions = await AppBootstrapService.buildApplicationMinionTargets(\n projectionInput,\n );\n const applicationFrontends = await AppBootstrapService.buildApplicationFrontendTargets({\n saasRoot: input.saasRoot,\n requestedAppSlug: input.requestedAppSlug,\n prepared,\n });\n\n const result: ApplicationRuntimeBootstrapResult = {\n backendCount: applicationBackends.length,\n companionCount: companionApis.length,\n frontendCount: applicationFrontends.length,\n workerCount: applicationWorkers.length,\n minionCount: applicationMinions.length,\n };\n const targetCount = Object.values(result).reduce((total, count) => total + count, 0);\n if (targetCount === 0) {\n throw new Error(\n 'Application bootstrap resolved no runtime targets. Check wildo.saas.config.ts and the selected application slug.',\n );\n }\n\n await envSync(\n resolvedEnv,\n input.credentials,\n {\n frameworkPath: input.frameworkPath,\n isFrameworkDeveloper: input.isFrameworkDeveloper,\n // Without it the foreign-owner skip in `envSync` can never apply, so `--register-only` — whose contract is\n // \"no shared substrate is touched\" — rewrote every platform service's env from THIS application (#1112).\n invokingAppRoot: input.saasRoot,\n applicationBackends,\n companionApis,\n applicationFrontends,\n applicationWorkers,\n applicationMinions,\n },\n input.log,\n );\n\n /*\n * Converge, then verify. A non-degraded registration has already applied the declaration through\n * `/initialize`; a DEGRADED one never called it, so the postcondition below would report the\n * author's own edit as drift. Apply the missing step first — see the service for exactly what it\n * will and will not apply unattended.\n */\n // Name what registration applied, so an edited declaration is never applied silently.\n if (prepared.declarationConvergedFields !== undefined && prepared.declarationConvergedFields.length > 0) {\n input.log.info(\n ` Applied wildo.saas.config.ts to the stored config of '${prepared.runtimeTarget.appSlug}' `\n + `— ${prepared.declarationConvergedFields.length} slice(s):`,\n );\n for (const field of prepared.declarationConvergedFields) {\n input.log.info(` • ${field}`);\n }\n }\n if (prepared.degraded) {\n await DegradedRegistrationDeclarationConvergenceService.converge({\n env: resolvedEnv,\n credentials: input.credentials,\n appSlug: prepared.runtimeTarget.appSlug,\n managedDeclaration: prepared.runtimeTarget.managedDeclaration,\n log: input.log,\n });\n }\n\n input.log.info(' Verifying the registered platform JWT door and managed application config...');\n await ApplicationInitializationVerificationService.assertCoherent({\n env: resolvedEnv,\n credentials: input.credentials,\n appSlug: prepared.runtimeTarget.appSlug,\n // The audience of apps-manager's signed answer (#2950): the id this run's registration returned.\n applicationId: prepared.bootstrapCredentials.APPLICATION_ID,\n // The declaration this run initialized against — what makes the postcondition a COMPARISON\n // rather than an existence assertion (issue #97).\n managedDeclaration: prepared.runtimeTarget.managedDeclaration,\n });\n\n /*\n * The claim below says \"materialized\". Make it TRUE rather than hopeful.\n *\n * Every target here is a process that reads its `.env` at startup and fails without it, so\n * \"materialized\" has to mean the file is on disk — not that a writer was invoked. Until\n * 2026-09-10 it meant the second: the application env writes were gated on framework-developer\n * mode, so an app-creator application was told \"1 backend, 1 companion, 1 frontend materialized\"\n * with zero `.env` files written, and the failure surfaced much later and somewhere else — the\n * companion dying on `APPLICATION_ID ... undefined` inside `pnpm --parallel`, which took the\n * rest of the stack down with it and named nothing.\n *\n * A postcondition here is worth more than a checker: it fires in the run that caused it, names\n * the files, and cannot be true-by-accident. It also guards the reverse direction — a project\n * that never completed `wildo local init` now says so here instead of compiling happily and\n * running nothing.\n */\n ApplicationRuntimeBootstrapService.assertEveryDeclaredRuntimeProjected(prepared, applicationWorkers, applicationMinions);\n ApplicationRuntimeBootstrapService.assertRuntimeEnvOnDisk(\n [...applicationBackends, ...companionApis, ...applicationFrontends,\n ...applicationWorkers, ...applicationMinions],\n input.log,\n );\n\n input.log.success(\n ` Application runtime materialized: ${result.backendCount} backend, `\n + `${result.companionCount} companion, ${result.frontendCount} frontend, `\n + `${result.workerCount} worker, ${result.minionCount} minion target(s).`,\n );\n return result;\n }\n\n /**\n * Refuse to report materialization when a minion or worker the declaration names got no target.\n *\n * {@link assertRuntimeEnvOnDisk} checks the targets that were BUILT, so it cannot see one that never was: on reference\n * run 44255624884 the target builders read a cached declaration with no minions, the check verified the five targets\n * it was given, and the run reported \"0 worker, 0 minion target(s)\" as a success while apps-manager had just minted\n * five minions and a worker from the declaration this run resolved. This compares against THAT declaration\n * (`prepared.runtimeTarget.managedDeclaration`, the one registration sent), so the two cannot disagree in silence again.\n *\n * A degraded registration may skip a runtime whose own secret could not be reconstructed offline: that skip is the\n * documented degraded behaviour (its runtime keeps its existing `.env`), so it is not counted as missing here.\n */\n private static assertEveryDeclaredRuntimeProjected(\n prepared: Pick<PreparedApplicationEnvTargets, 'degraded' | 'runtimePrincipalCredentials' | 'runtimeTarget'>,\n workers: readonly Pick<ApplicationWorkerEnvTarget, 'workerName'>[],\n minions: readonly Pick<ApplicationMinionEnvTarget, 'minionName'>[],\n ): void {\n const projected = new Set([\n ...workers.map((target) => buildRuntimePrincipalKey({ kind: ApplicationRuntimePrincipalKind.WORKER, name: target.workerName })),\n ...minions.map((target) => buildRuntimePrincipalKey({ kind: ApplicationRuntimePrincipalKind.MINION, name: target.minionName })),\n ]);\n const missing = enumerateDeclaredRuntimePrincipals(prepared.runtimeTarget.managedDeclaration)\n .filter((principal) => principal.kind === ApplicationRuntimePrincipalKind.MINION || principal.kind === ApplicationRuntimePrincipalKind.WORKER)\n .map(buildRuntimePrincipalKey)\n .filter((key) => !projected.has(key))\n .filter((key) => !(prepared.degraded === true && prepared.runtimePrincipalCredentials?.[key] === undefined));\n if (missing.length === 0) return;\n throw new Error(\n `The declaration names ${missing.length} runtime(s) that got no env target: ${missing.join(', ')}. `\n + 'Their identities were minted from wildo.saas.config.ts as registration read it, but no `.env` was written for '\n + 'them, so each would start without one and refuse its unset APPLICATION_ENV. The env targets were built from a '\n + 'different reading of the declaration than the one registration sent (it changed during this run, or a reader '\n + 'served an earlier evaluation of it); run the same command again.',\n );\n }\n\n /**\n * Refuse to report materialization for a target whose `.env` is not on disk.\n *\n * @see the note at the call site for the defect this exists to prevent.\n */\n private static assertRuntimeEnvOnDisk(\n targets: readonly { applicationRoot: string; relativeDir: string }[],\n log: Logger,\n ): void {\n /*\n * Only targets that actually carry both path fields are checkable. The type requires them, so a\n * target without them is a test double rather than a real runtime target — this postcondition\n * must not turn a partial mock into a crash (`join(undefined, ...)` throws a TypeError that\n * reads as a bug in the thing being verified). Anything skipped is REPORTED rather than hidden,\n * so a real target that somehow lost its anchor is still visible.\n */\n const checkable = targets.filter(\n (target) => typeof target?.applicationRoot === 'string' && typeof target?.relativeDir === 'string',\n );\n const skipped = targets.length - checkable.length;\n const missing = checkable\n .map((target) => join(target.applicationRoot, target.relativeDir, FILE_NAMES.DOT_ENV))\n .filter((path) => !existsSync(path));\n\n if (missing.length === 0) {\n log.info(\n ` Runtime env verified on disk for ${checkable.length} target(s).`\n + (skipped > 0 ? ` (${skipped} target(s) carried no path anchor and were not checkable.)` : ''),\n );\n return;\n }\n\n const applicationRoot = targets[0]?.applicationRoot ?? process.cwd();\n throw new Error(\n `Application runtime env is missing for ${missing.length} of ${targets.length} target(s):\\n`\n + `${missing.map((path) => ` - ${relative(applicationRoot, path) || path}`).join('\\n')}\\n`\n + 'Each of these is read at process startup, so the application would compile and then fail to '\n + 'run with an unrelated-looking validation error. Re-run `wildo local init` for this '\n + 'application; if it persists, the env generator did not receive this target.',\n );\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LoadConfigOptions } from '@wildo-ai/platform-config-lib';
|
|
1
2
|
type ProviderConfigurationsLayer = Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>>;
|
|
2
3
|
/**
|
|
3
4
|
* The provider configuration an application runs with IN ONE ENVIRONMENT — the single door both environment-aware
|
|
@@ -24,6 +25,12 @@ export declare function resolveEnvironmentProviderConfigurations(input: {
|
|
|
24
25
|
saasRoot: string;
|
|
25
26
|
applicationProviderConfigurations: ProviderConfigurationsLayer | undefined;
|
|
26
27
|
environmentName: string | null;
|
|
28
|
+
/**
|
|
29
|
+
* How the environment's `wildo.infra.<env>.config.ts` is evaluated. `AppRuntimeTargetsService.resolve` passes its own
|
|
30
|
+
* (fresh, #3985): its overlay goes into the declaration registration sends, and a cached evaluation inside a
|
|
31
|
+
* long-lived `wildo local dev` would send the file as that process first read it.
|
|
32
|
+
*/
|
|
33
|
+
infraConfigLoadOptions?: Pick<LoadConfigOptions, 'freshModuleCache' | 'moduleResolution'> | undefined;
|
|
27
34
|
}): Promise<Record<string, Record<string, unknown> | undefined>>;
|
|
28
35
|
export {};
|
|
29
36
|
//# sourceMappingURL=environment-provider-configurations.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-provider-configurations.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/environment-provider-configurations.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"environment-provider-configurations.service.d.ts","sourceRoot":"","sources":["../../../../src/services/application/environment-provider-configurations.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAuE,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAI5I,KAAK,2BAA2B,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,wCAAwC,CAAC,KAAK,EAAE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC,EAAE,2BAA2B,GAAG,SAAS,CAAC;IAC3E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,kBAAkB,CAAC,GAAG,SAAS,CAAC;CACvG,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,CAY/D"}
|
|
@@ -29,7 +29,7 @@ export async function resolveEnvironmentProviderConfigurations(input) {
|
|
|
29
29
|
if (input.environmentName === null) {
|
|
30
30
|
return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, undefined);
|
|
31
31
|
}
|
|
32
|
-
const authored = await loadAuthoredInfraEnvConfig(input.environmentName, input.saasRoot);
|
|
32
|
+
const authored = await loadAuthoredInfraEnvConfig(input.environmentName, input.saasRoot, input.infraConfigLoadOptions);
|
|
33
33
|
const environmentProviderConfigurations = authored?.config.providerConfigurations;
|
|
34
34
|
assertNoProviderSecretKeys(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);
|
|
35
35
|
assertConfiguredSecretRefsDeclared(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-provider-configurations.service.js","sourceRoot":"","sources":["../../../../src/services/application/environment-provider-configurations.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE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,KAAK,IAAI,mCAAmC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC;QACnE,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO;YAAE,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7E,CAAC;IACD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1G,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3H,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC/B,MAAM,IAAI,KAAK,CACb,GAAG,EAAE,UAAU,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,4BAA4B;UACjJ,kIAAkI;UAClI,4FAA4F,CAC/F,CAAC;AACJ,CAAC","sourcesContent":["import { ProviderConfigurationCredentialField, readProviderConfigurationCredentialFields } from '@wildo-ai/external-connectors-models';\nimport { isRuntimeSecretEnvVarName, overlayEnvironmentProviderConfigurations } from '@wildo-ai/platform-config-lib';\nimport { getComposedProviderEntry, getComposedProviderSecretsCatalogue } from '~wildo-cli/services/credentials/composed-provider-catalogue';\nimport { loadAuthoredInfraEnvConfig } from '~wildo-cli/services/environment/authored-infra-config.utils';\n\ntype ProviderConfigurationsLayer = Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>>;\n\n/**\n * The provider configuration an application runs with IN ONE ENVIRONMENT — the single door both environment-aware\n * producers go through.\n *\n * Two things carry a provider configuration out of the CLI, and before this existed both used\n * `wildo.saas.config.ts > providerConfigurations` verbatim, so every environment received one environment's values:\n *\n * | producer | consumer |\n * |---|---|\n * | the managed declaration (`AppRuntimeTargetsService.resolve`) | each environment's apps-manager, then the backend: OAuth2 client IDs, email/SMS senders, the provider registry |\n * | the provider runtime artifacts (`syncProviderRuntimeArtifactsForApp`) | baked into builds: frontend `publicConfig`, the backend's generated provider module |\n *\n * Both call this with the environment they are producing for, so the two cannot disagree about which value an\n * environment has.\n *\n * `environmentName: null` is a deliberate answer, not an omission: the caller produces nothing environment-bound (a\n * validation that reads only the services list). It yields the application layer alone.\n *\n * An environment with no authored `wildo.infra.<env>.config.ts` states no override, so it runs with the application\n * layer — the same reading every other per-environment block gets when absent.\n */\nexport async function resolveEnvironmentProviderConfigurations(input: {\n saasRoot: string;\n applicationProviderConfigurations: ProviderConfigurationsLayer | undefined;\n environmentName: string | null;\n}): Promise<Record<string, Record<string, unknown> | undefined>> {\n assertNoProviderSecretKeys(input.applicationProviderConfigurations, 'wildo.saas.config.ts');\n assertConfiguredSecretRefsDeclared(input.applicationProviderConfigurations, 'wildo.saas.config.ts');\n if (input.environmentName === null) {\n return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, undefined);\n }\n\n const authored = await loadAuthoredInfraEnvConfig(input.environmentName, input.saasRoot);\n const environmentProviderConfigurations = authored?.config.providerConfigurations;\n assertNoProviderSecretKeys(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);\n assertConfiguredSecretRefsDeclared(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);\n return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, environmentProviderConfigurations);\n}\n\n/**\n * Refuse a provider configuration key named like one of that provider's declared secrets.\n *\n * Both files carrying provider configuration are committed, and the key a leak would use is exactly the one an author\n * reaches for when a client ID and its client secret sit side by side in the vendor console\n * (`GOOGLE_OAUTH2_CLIENT_ID` → `GOOGLE_OAUTH2_CLIENT_SECRET`). The secret has one home, `secrets.json → providerEnv`,\n * and a value written here would be committed while the runtime kept reading the env var — a leak that also does\n * nothing.\n *\n * Matched on the secret's ENVIRONMENT-VARIABLE name only, from the composed provider catalogue — the same authority\n * the env writers use. Not on its contract slug: slugs are generic (`apiKey`), and a frontend SDK legitimately takes a\n * PUBLIC key under that same name (PostHog's `phc_` project key in `frontend_sdk.apiKey`), so a slug match would refuse\n * a correct configuration. The env-var name is the precise signal: it is exactly what an author copies out of the\n * secrets file. A provider the catalogue does not yet know (an application-owned package before discovery) is checked\n * on the call that runs after discovery — `syncProviderRuntimeArtifactsForApp` registers contributions before it\n * resolves — so `wildo config sync` covers it.\n */\nfunction assertNoProviderSecretKeys(layer: ProviderConfigurationsLayer | undefined, source: string): void {\n for (const [providerRef, protocols] of Object.entries(layer ?? {})) {\n const secrets = getComposedProviderEntry(providerRef)?.secrets ?? [];\n if (secrets.length === 0 || !protocols) continue;\n const secretNames = new Set(secrets.map((secret) => secret.envVarName));\n for (const [protocolKind, values] of Object.entries(protocols)) {\n if (!values || typeof values !== 'object' || Array.isArray(values)) continue;\n const leaked = Object.keys(values).filter((key) => secretNames.has(key));\n if (leaked.length > 0) {\n throw new Error(\n `${source}: providerConfigurations.${providerRef}.${protocolKind} names ${leaked.map((key) => `\"${key}\"`).join(', ')}, `\n + `which ${leaked.length === 1 ? 'is a secret' : 'are secrets'} of provider \"${providerRef}\". Secrets belong in `\n + '`infrastructure/<env>/secrets/secrets.json → providerEnv`, never in a committed configuration file.',\n );\n }\n }\n }\n}\n\n/**\n * Refuse a provider configuration that points a provider at a secret its module does not declare (#3002), or whose ACP\n * execution profile forwards a secret into the coding agent (#3018).\n *\n * The backend reads `authConfig.secretRef` as the variable sent to the vendor as the provider's key or client secret,\n * and an ACP execution profile's `secretEnvVarName` as the variable handed to the coding agent; it admits only a slot\n * the module's `secretsContract` declares, and refuses at startup and on every read. Refused here too, so `wildo config\n * sync` (and creation readiness, and every other caller of this door) stops before generating anything for a\n * configuration the backend would refuse to boot with, naming the file.\n *\n * The same reading as the backend: `authConfig.secretRef` names a slot by its variable or its slug; `secretEnvVarName`\n * names the variable the agent reads, so only a declared variable. Those two slot rules need the provider's declared\n * slots, so a provider the catalogue does not know yet is not held to them here, as above, and is held on the call that\n * runs after discovery registered it. The inherited-environment rule needs no provider and runs for every provider,\n * known or not ({@link assertInheritedEnvironmentVariablesAreNotSecrets}).\n *\n * The fields are read through `readProviderConfigurationCredentialFields` and branched on their\n * `ProviderConfigurationCredentialField`, the vocabulary the backend registry branches on too (#3022), so the two doors\n * cannot disagree about which fields name a credential or which bag carries execution profiles (the agent-client-protocol\n * bag, under its wire value or its member name).\n *\n * assurance-control: WILDO.SECRETS.CREDENTIAL_SCOPING — `wildo config sync`, creation readiness and every producer of an environment's provider configuration refuse a configuration naming a credential its provider module or the framework does not admit, naming the file.\n */\nfunction assertConfiguredSecretRefsDeclared(layer: ProviderConfigurationsLayer | undefined, source: string): void {\n for (const [providerRef, protocols] of Object.entries(layer ?? {})) {\n if (!protocols) continue;\n const entry = getComposedProviderEntry(providerRef);\n const envVarNames = new Set((entry?.secrets ?? []).map((secret) => secret.envVarName));\n const admitted = new Set([...envVarNames, ...(entry?.secrets ?? []).map((secret) => secret.slug)]);\n const declared = (entry?.secrets ?? []).map((secret) => `${secret.slug} (${secret.envVarName})`).sort().join(', ') || 'none';\n for (const [protocolKey, values] of Object.entries(protocols)) {\n const at = (path: string): string => `${source}: providerConfigurations.${providerRef}.${protocolKey}.${path}`;\n for (const reading of readProviderConfigurationCredentialFields(protocolKey, values)) {\n switch (reading.field) {\n case ProviderConfigurationCredentialField.EXECUTION_PROFILE_INHERITED_ENVIRONMENT:\n // A secret forwarded into the agent (#3018) is refused for every provider, known here or not: the forbidden set\n // does not depend on the provider.\n assertInheritedEnvironmentVariablesAreNotSecrets(reading.value, at(reading.path));\n break;\n case ProviderConfigurationCredentialField.AUTH_SECRET_REF:\n // The slot rules need the provider's declared slots: a provider the catalogue does not know yet is checked on the\n // call that runs after discovery registered it.\n if (entry === undefined || (typeof reading.value === 'string' && admitted.has(reading.value))) break;\n throw new Error(\n `${at(reading.path)} names '${String(reading.value)}', which provider `\n + `\"${providerRef}\" does not declare as a secret. A configuration may point a protocol only at a slot the provider declares, by its `\n + `variable or its slug (${declared}); the backend refuses this configuration and reads no such variable.`,\n );\n case ProviderConfigurationCredentialField.EXECUTION_PROFILE_SECRET_ENV_VAR_NAME:\n if (entry === undefined || (typeof reading.value === 'string' && envVarNames.has(reading.value))) break;\n throw new Error(\n `${at(reading.path)} names '${String(reading.value)}', which provider \"${providerRef}\" does not declare as a secret. `\n + `An execution profile may hand the agent only a variable the provider declares (${declared}); the backend refuses this `\n + 'configuration and reads no such variable.',\n );\n default: {\n const exhaustive: never = reading.field;\n return exhaustive;\n }\n }\n }\n }\n }\n}\n\n/**\n * Refuse an execution profile that forwards a secret into the coding agent (#3018), as the backend does at every read,\n * at startup and at dispatch (`assertAgentInheritedEnvironmentVariablesAreNotSecrets`).\n *\n * The same question as the backend's: a secret a Wildo runtime env declares (`isRuntimeSecretEnvVarName`: the runtime\n * env contracts' keys, every inbound endpoint secret, every system-of-record slot), or a secret any provider the CLI\n * can see declares (the composed catalogue, engine tier and discovered packages: a superset of one runtime's). A name\n * it admits is one the framework does not declare secret, which is not the same as harmless: a developer's own shell\n * may carry secrets the framework cannot know.\n *\n * assurance-control: WILDO.SECRETS.CREDENTIAL_SCOPING — the CLI refuses an execution profile forwarding a declared secret into a coding agent, before anything is generated.\n */\nfunction assertInheritedEnvironmentVariablesAreNotSecrets(inherited: unknown, at: string): void {\n if (!Array.isArray(inherited)) return;\n const providerSecrets = new Set<string>();\n for (const entry of getComposedProviderSecretsCatalogue().values()) {\n for (const secret of entry.secrets) providerSecrets.add(secret.envVarName);\n }\n const forbidden = (name: string): boolean => isRuntimeSecretEnvVarName(name) || providerSecrets.has(name);\n const named = [...new Set(inherited.filter((name): name is string => typeof name === 'string' && forbidden(name)))].sort();\n if (named.length === 0) return;\n throw new Error(\n `${at} names ${named.map((name) => `'${name}'`).join(', ')}, which ${named.length === 1 ? 'is a secret' : 'are secrets'} of this platform or of a `\n + 'provider. A coding agent may not inherit a secret the framework declares; a provider credential the agent needs is handed to it '\n + 'through the execution profile\\'s secretEnvVarName. The backend refuses this configuration.',\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"environment-provider-configurations.service.js","sourceRoot":"","sources":["../../../../src/services/application/environment-provider-configurations.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,yCAAyC,EAAE,MAAM,sCAAsC,CAAC;AACvI,OAAO,EAAE,yBAAyB,EAAE,wCAAwC,EAA0B,MAAM,+BAA+B,CAAC;AAC5I,OAAO,EAAE,wBAAwB,EAAE,mCAAmC,EAAE,MAAM,6DAA6D,CAAC;AAC5I,OAAO,EAAE,0BAA0B,EAAE,MAAM,6DAA6D,CAAC;AAIzG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAAC,KAU9D;IACC,0BAA0B,CAAC,KAAK,CAAC,iCAAiC,EAAE,sBAAsB,CAAC,CAAC;IAC5F,kCAAkC,CAAC,KAAK,CAAC,iCAAiC,EAAE,sBAAsB,CAAC,CAAC;IACpG,IAAI,KAAK,CAAC,eAAe,KAAK,IAAI,EAAE,CAAC;QACnC,OAAO,wCAAwC,CAAC,KAAK,CAAC,iCAAiC,EAAE,SAAS,CAAC,CAAC;IACtG,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,0BAA0B,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACvH,MAAM,iCAAiC,GAAG,QAAQ,EAAE,MAAM,CAAC,sBAAsB,CAAC;IAClF,0BAA0B,CAAC,iCAAiC,EAAE,QAAQ,EAAE,IAAI,IAAI,kBAA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4B;UACjJ,kIAAkI;UAClI,4FAA4F,CAC/F,CAAC;AACJ,CAAC","sourcesContent":["import { ProviderConfigurationCredentialField, readProviderConfigurationCredentialFields } from '@wildo-ai/external-connectors-models';\nimport { isRuntimeSecretEnvVarName, overlayEnvironmentProviderConfigurations, type LoadConfigOptions } from '@wildo-ai/platform-config-lib';\nimport { getComposedProviderEntry, getComposedProviderSecretsCatalogue } from '~wildo-cli/services/credentials/composed-provider-catalogue';\nimport { loadAuthoredInfraEnvConfig } from '~wildo-cli/services/environment/authored-infra-config.utils';\n\ntype ProviderConfigurationsLayer = Readonly<Record<string, Readonly<Record<string, unknown>> | undefined>>;\n\n/**\n * The provider configuration an application runs with IN ONE ENVIRONMENT — the single door both environment-aware\n * producers go through.\n *\n * Two things carry a provider configuration out of the CLI, and before this existed both used\n * `wildo.saas.config.ts > providerConfigurations` verbatim, so every environment received one environment's values:\n *\n * | producer | consumer |\n * |---|---|\n * | the managed declaration (`AppRuntimeTargetsService.resolve`) | each environment's apps-manager, then the backend: OAuth2 client IDs, email/SMS senders, the provider registry |\n * | the provider runtime artifacts (`syncProviderRuntimeArtifactsForApp`) | baked into builds: frontend `publicConfig`, the backend's generated provider module |\n *\n * Both call this with the environment they are producing for, so the two cannot disagree about which value an\n * environment has.\n *\n * `environmentName: null` is a deliberate answer, not an omission: the caller produces nothing environment-bound (a\n * validation that reads only the services list). It yields the application layer alone.\n *\n * An environment with no authored `wildo.infra.<env>.config.ts` states no override, so it runs with the application\n * layer — the same reading every other per-environment block gets when absent.\n */\nexport async function resolveEnvironmentProviderConfigurations(input: {\n saasRoot: string;\n applicationProviderConfigurations: ProviderConfigurationsLayer | undefined;\n environmentName: string | null;\n /**\n * How the environment's `wildo.infra.<env>.config.ts` is evaluated. `AppRuntimeTargetsService.resolve` passes its own\n * (fresh, #3985): its overlay goes into the declaration registration sends, and a cached evaluation inside a\n * long-lived `wildo local dev` would send the file as that process first read it.\n */\n infraConfigLoadOptions?: Pick<LoadConfigOptions, 'freshModuleCache' | 'moduleResolution'> | undefined;\n}): Promise<Record<string, Record<string, unknown> | undefined>> {\n assertNoProviderSecretKeys(input.applicationProviderConfigurations, 'wildo.saas.config.ts');\n assertConfiguredSecretRefsDeclared(input.applicationProviderConfigurations, 'wildo.saas.config.ts');\n if (input.environmentName === null) {\n return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, undefined);\n }\n\n const authored = await loadAuthoredInfraEnvConfig(input.environmentName, input.saasRoot, input.infraConfigLoadOptions);\n const environmentProviderConfigurations = authored?.config.providerConfigurations;\n assertNoProviderSecretKeys(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);\n assertConfiguredSecretRefsDeclared(environmentProviderConfigurations, authored?.path ?? `infrastructure/${input.environmentName}`);\n return overlayEnvironmentProviderConfigurations(input.applicationProviderConfigurations, environmentProviderConfigurations);\n}\n\n/**\n * Refuse a provider configuration key named like one of that provider's declared secrets.\n *\n * Both files carrying provider configuration are committed, and the key a leak would use is exactly the one an author\n * reaches for when a client ID and its client secret sit side by side in the vendor console\n * (`GOOGLE_OAUTH2_CLIENT_ID` → `GOOGLE_OAUTH2_CLIENT_SECRET`). The secret has one home, `secrets.json → providerEnv`,\n * and a value written here would be committed while the runtime kept reading the env var — a leak that also does\n * nothing.\n *\n * Matched on the secret's ENVIRONMENT-VARIABLE name only, from the composed provider catalogue — the same authority\n * the env writers use. Not on its contract slug: slugs are generic (`apiKey`), and a frontend SDK legitimately takes a\n * PUBLIC key under that same name (PostHog's `phc_` project key in `frontend_sdk.apiKey`), so a slug match would refuse\n * a correct configuration. The env-var name is the precise signal: it is exactly what an author copies out of the\n * secrets file. A provider the catalogue does not yet know (an application-owned package before discovery) is checked\n * on the call that runs after discovery — `syncProviderRuntimeArtifactsForApp` registers contributions before it\n * resolves — so `wildo config sync` covers it.\n */\nfunction assertNoProviderSecretKeys(layer: ProviderConfigurationsLayer | undefined, source: string): void {\n for (const [providerRef, protocols] of Object.entries(layer ?? {})) {\n const secrets = getComposedProviderEntry(providerRef)?.secrets ?? [];\n if (secrets.length === 0 || !protocols) continue;\n const secretNames = new Set(secrets.map((secret) => secret.envVarName));\n for (const [protocolKind, values] of Object.entries(protocols)) {\n if (!values || typeof values !== 'object' || Array.isArray(values)) continue;\n const leaked = Object.keys(values).filter((key) => secretNames.has(key));\n if (leaked.length > 0) {\n throw new Error(\n `${source}: providerConfigurations.${providerRef}.${protocolKind} names ${leaked.map((key) => `\"${key}\"`).join(', ')}, `\n + `which ${leaked.length === 1 ? 'is a secret' : 'are secrets'} of provider \"${providerRef}\". Secrets belong in `\n + '`infrastructure/<env>/secrets/secrets.json → providerEnv`, never in a committed configuration file.',\n );\n }\n }\n }\n}\n\n/**\n * Refuse a provider configuration that points a provider at a secret its module does not declare (#3002), or whose ACP\n * execution profile forwards a secret into the coding agent (#3018).\n *\n * The backend reads `authConfig.secretRef` as the variable sent to the vendor as the provider's key or client secret,\n * and an ACP execution profile's `secretEnvVarName` as the variable handed to the coding agent; it admits only a slot\n * the module's `secretsContract` declares, and refuses at startup and on every read. Refused here too, so `wildo config\n * sync` (and creation readiness, and every other caller of this door) stops before generating anything for a\n * configuration the backend would refuse to boot with, naming the file.\n *\n * The same reading as the backend: `authConfig.secretRef` names a slot by its variable or its slug; `secretEnvVarName`\n * names the variable the agent reads, so only a declared variable. Those two slot rules need the provider's declared\n * slots, so a provider the catalogue does not know yet is not held to them here, as above, and is held on the call that\n * runs after discovery registered it. The inherited-environment rule needs no provider and runs for every provider,\n * known or not ({@link assertInheritedEnvironmentVariablesAreNotSecrets}).\n *\n * The fields are read through `readProviderConfigurationCredentialFields` and branched on their\n * `ProviderConfigurationCredentialField`, the vocabulary the backend registry branches on too (#3022), so the two doors\n * cannot disagree about which fields name a credential or which bag carries execution profiles (the agent-client-protocol\n * bag, under its wire value or its member name).\n *\n * assurance-control: WILDO.SECRETS.CREDENTIAL_SCOPING — `wildo config sync`, creation readiness and every producer of an environment's provider configuration refuse a configuration naming a credential its provider module or the framework does not admit, naming the file.\n */\nfunction assertConfiguredSecretRefsDeclared(layer: ProviderConfigurationsLayer | undefined, source: string): void {\n for (const [providerRef, protocols] of Object.entries(layer ?? {})) {\n if (!protocols) continue;\n const entry = getComposedProviderEntry(providerRef);\n const envVarNames = new Set((entry?.secrets ?? []).map((secret) => secret.envVarName));\n const admitted = new Set([...envVarNames, ...(entry?.secrets ?? []).map((secret) => secret.slug)]);\n const declared = (entry?.secrets ?? []).map((secret) => `${secret.slug} (${secret.envVarName})`).sort().join(', ') || 'none';\n for (const [protocolKey, values] of Object.entries(protocols)) {\n const at = (path: string): string => `${source}: providerConfigurations.${providerRef}.${protocolKey}.${path}`;\n for (const reading of readProviderConfigurationCredentialFields(protocolKey, values)) {\n switch (reading.field) {\n case ProviderConfigurationCredentialField.EXECUTION_PROFILE_INHERITED_ENVIRONMENT:\n // A secret forwarded into the agent (#3018) is refused for every provider, known here or not: the forbidden set\n // does not depend on the provider.\n assertInheritedEnvironmentVariablesAreNotSecrets(reading.value, at(reading.path));\n break;\n case ProviderConfigurationCredentialField.AUTH_SECRET_REF:\n // The slot rules need the provider's declared slots: a provider the catalogue does not know yet is checked on the\n // call that runs after discovery registered it.\n if (entry === undefined || (typeof reading.value === 'string' && admitted.has(reading.value))) break;\n throw new Error(\n `${at(reading.path)} names '${String(reading.value)}', which provider `\n + `\"${providerRef}\" does not declare as a secret. A configuration may point a protocol only at a slot the provider declares, by its `\n + `variable or its slug (${declared}); the backend refuses this configuration and reads no such variable.`,\n );\n case ProviderConfigurationCredentialField.EXECUTION_PROFILE_SECRET_ENV_VAR_NAME:\n if (entry === undefined || (typeof reading.value === 'string' && envVarNames.has(reading.value))) break;\n throw new Error(\n `${at(reading.path)} names '${String(reading.value)}', which provider \"${providerRef}\" does not declare as a secret. `\n + `An execution profile may hand the agent only a variable the provider declares (${declared}); the backend refuses this `\n + 'configuration and reads no such variable.',\n );\n default: {\n const exhaustive: never = reading.field;\n return exhaustive;\n }\n }\n }\n }\n }\n}\n\n/**\n * Refuse an execution profile that forwards a secret into the coding agent (#3018), as the backend does at every read,\n * at startup and at dispatch (`assertAgentInheritedEnvironmentVariablesAreNotSecrets`).\n *\n * The same question as the backend's: a secret a Wildo runtime env declares (`isRuntimeSecretEnvVarName`: the runtime\n * env contracts' keys, every inbound endpoint secret, every system-of-record slot), or a secret any provider the CLI\n * can see declares (the composed catalogue, engine tier and discovered packages: a superset of one runtime's). A name\n * it admits is one the framework does not declare secret, which is not the same as harmless: a developer's own shell\n * may carry secrets the framework cannot know.\n *\n * assurance-control: WILDO.SECRETS.CREDENTIAL_SCOPING — the CLI refuses an execution profile forwarding a declared secret into a coding agent, before anything is generated.\n */\nfunction assertInheritedEnvironmentVariablesAreNotSecrets(inherited: unknown, at: string): void {\n if (!Array.isArray(inherited)) return;\n const providerSecrets = new Set<string>();\n for (const entry of getComposedProviderSecretsCatalogue().values()) {\n for (const secret of entry.secrets) providerSecrets.add(secret.envVarName);\n }\n const forbidden = (name: string): boolean => isRuntimeSecretEnvVarName(name) || providerSecrets.has(name);\n const named = [...new Set(inherited.filter((name): name is string => typeof name === 'string' && forbidden(name)))].sort();\n if (named.length === 0) return;\n throw new Error(\n `${at} names ${named.map((name) => `'${name}'`).join(', ')}, which ${named.length === 1 ? 'is a secret' : 'are secrets'} of this platform or of a `\n + 'provider. A coding agent may not inherit a secret the framework declares; a provider credential the agent needs is handed to it '\n + 'through the execution profile\\'s secretEnvVarName. The backend refuses this configuration.',\n );\n}\n"]}
|