@wildo-ai/wildo-cli 1.1.15 → 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/local/dev.command.d.ts +44 -0
- package/dist/src/commands/local/dev.command.d.ts.map +1 -1
- package/dist/src/commands/local/dev.command.js +74 -3
- package/dist/src/commands/local/dev.command.js.map +1 -1
- 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 +24 -6
- package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.js +46 -13
- 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 +7 -1
- package/dist/src/services/application/app-runtime-targets.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.map +1 -1
- package/dist/src/services/application/local-tunnel.service.js +2 -1
- package/dist/src/services/application/local-tunnel.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/deployment/docker/docker-compose-generator.service.d.ts +10 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.d.ts.map +1 -1
- package/dist/src/services/deployment/docker/docker-compose-generator.service.js +24 -10
- 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.map +1 -1
- package/dist/src/services/deployment/framework-pod-network-membership.js +5 -0
- package/dist/src/services/deployment/framework-pod-network-membership.js.map +1 -1
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts +43 -4
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.d.ts.map +1 -1
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.js +116 -9
- package/dist/src/services/deployment/local-dev-late-workspace-members.service.js.map +1 -1
- package/dist/src/services/environment/authored-infra-config.utils.d.ts +4 -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 +4 -3
- package/dist/src/services/environment/authored-infra-config.utils.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/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +2 -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/wildo-framework.info.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-pod-network-membership.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/framework-pod-network-membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AAE/F,+FAA+F;AAC/F,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAE7E,6DAA6D;AAC7D,MAAM,WAAW,+BAA+B;IAC9C,mHAAmH;IACnH,QAAQ,CAAC,yBAAyB,EAAE,OAAO,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC;
|
|
1
|
+
{"version":3,"file":"framework-pod-network-membership.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/framework-pod-network-membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AAE/F,+FAA+F;AAC/F,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,qBAAqB,CAAC;AAE7E,6DAA6D;AAC7D,MAAM,WAAW,+BAA+B;IAC9C,mHAAmH;IACnH,QAAQ,CAAC,yBAAyB,EAAE,OAAO,CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC;AA4ED;;;;;;;;;GASG;AACH,eAAO,MAAM,kCAAkC,EAAE,WAAW,CAAC,iBAAiB,CAM5E,CAAC;AAEH;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,+BAA+B,GACvC,mBAAmB,EAAE,CAKvB;AAED,wHAAwH;AACxH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,+BAA+B,GACvC,mBAAmB,EAAE,CAIvB;AAED,4GAA4G;AAC5G,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAEjF"}
|
|
@@ -63,10 +63,15 @@ const FRAMEWORK_WORKLOAD_SEGMENTS = {
|
|
|
63
63
|
WildoRuntimeNetwork.DATA_TELEMETRY,
|
|
64
64
|
],
|
|
65
65
|
// No broker segment under any profile: the scheduler delivers over HTTP and holds no broker connection (#2303 slice B).
|
|
66
|
+
// The PostgreSQL segment: on a PostgreSQL platform its scheduling repositories and delivery outbox live in the
|
|
67
|
+
// platform database (`initializeSchedulingRepositories`). Without it an app-creator compose platform failed every
|
|
68
|
+
// delivery round with `getaddrinfo EAI_AGAIN postgresql-internal` and no minion ever ticked (finalization run
|
|
69
|
+
// 44310014583, #4025).
|
|
66
70
|
[PlatformWildoServices.CRONTABS_BATCHES_MANAGER]: [
|
|
67
71
|
WildoRuntimeNetwork.PLATFORM,
|
|
68
72
|
WildoRuntimeNetwork.DATA_MONGO,
|
|
69
73
|
WildoRuntimeNetwork.DATA_REDIS,
|
|
74
|
+
WildoRuntimeNetwork.DATA_POSTGRES,
|
|
70
75
|
WildoRuntimeNetwork.DATA_OBJECTS,
|
|
71
76
|
WildoRuntimeNetwork.DATA_TELEMETRY,
|
|
72
77
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-pod-network-membership.js","sourceRoot":"","sources":["../../../../src/services/deployment/framework-pod-network-membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AAiB/F;;;GAGG;AACH,MAAM,2BAA2B,GAA8D;IAC7F,qHAAqH;IACrH,4EAA4E;IAC5E,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IAChE,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IACrE,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IAC/D,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IAC/D,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,mBAAmB,CAAC,WAAW,CAAC;IAClE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC;IAChE,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC;IACrE,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC,mBAAmB,CAAC,aAAa,CAAC;IACtE,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,cAAc,CAAC;IACnE,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAA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**\n * The network segments each FRAMEWORK-owned workload belongs to (#3372): the backing services, the one-shot init jobs\n * and the platform services. Application runtimes are not here — their membership is derived from their principal and\n * declaration by `resolveRuntimeNetworkMembership` in `@wildo-ai/platform-config-lib`.\n *\n * ## Why this table exists\n *\n * The Kubernetes `NetworkPolicy` set is a namespace-wide default-deny plus one allow per segment, selecting on\n * `wildo.ai/net-<segment>` pod labels. Until #3372 only the application runtime pods carried those labels, so the\n * backing services they dial matched no allow rule and the policy set cut every runtime off its data plane. Every pod\n * the framework renders into the namespace therefore needs a membership, and this is where it is decided.\n *\n * ## Two lanes, one membership\n *\n * The compose lane expresses the same segments as network attachments written into\n * `templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs`. That template is hand-written, so this table\n * is the second statement of the same fact — the shape `.claude/rules/invariant-call-site-enumeration.md` row 23\n * records (one contract, two deployment lanes, one of them wrong). The coupling is pinned rather than trusted:\n * `docker-compose-generator.service.test.ts` renders the real compose template and requires every service's\n * `wildo-*` segment attachments to equal this table, so a segment added on either side alone fails a test.\n *\n * What the table deliberately does NOT copy from compose is the publish bridge (`wildo-host-access`). In compose every\n * container that publishes a port joins that non-internal bridge, which incidentally gives it a route off the host.\n * Kubernetes has no such side effect, so the route off the cluster is authored per workload as\n * {@link WildoRuntimeNetwork.EGRESS}, and is compared separately (see {@link FRAMEWORK_WORKLOAD_INTERNET_EGRESS}).\n */\nimport { PlatformWildoServices, WildoRuntimeNetwork } from '@wildo-ai/platform-config-lib';\n\nimport { PlatformDataServices } from '~wildo-cli/services/data-services/data-services.schemas';\n\n/** Every framework-owned workload that can be rendered into an environment, on either lane. */\nexport type FrameworkWorkload = PlatformDataServices | PlatformWildoServices;\n\n/** What membership depends on beyond the workload itself. */\nexport interface FrameworkWorkloadNetworkContext {\n /** Whether the environment self-hosts the platform Vault (#2933); only then does apps-manager join its segment. */\n readonly selfHostsPlatformKeyVault: boolean;\n /**\n * Whether the environment runs a message broker (`environmentServiceProfileRunsMessageBroker`, #2303 slice D); only then\n * do the platform's broker clients join its segment. Under a profile whose queue lives in the application's database\n * there is no broker, and a segment with no server is a membership that grants nothing and claims a dependency.\n */\n readonly runsMessageBroker: boolean;\n}\n\n/**\n * The INTERNAL segments of each workload. Total over both vocabularies, so a new backing or platform service is a\n * compile error here rather than a pod the default-deny silently isolates.\n */\nconst FRAMEWORK_WORKLOAD_SEGMENTS: Record<FrameworkWorkload, readonly WildoRuntimeNetwork[]> = {\n // mongod and its search sidecar dial EACH OTHER (`mongotHost` one way, the sync source the other), which is why both\n // are plain members of the Mongo segment rather than one serving the other.\n [PlatformDataServices.MONGODB]: [WildoRuntimeNetwork.DATA_MONGO],\n [PlatformDataServices.MONGODB_INIT]: [WildoRuntimeNetwork.DATA_MONGO],\n [PlatformDataServices.MONGOT]: [WildoRuntimeNetwork.DATA_MONGO],\n [PlatformDataServices.VALKEY]: [WildoRuntimeNetwork.DATA_REDIS],\n [PlatformDataServices.RABBITMQ]: [WildoRuntimeNetwork.DATA_RABBIT],\n [PlatformDataServices.MINIO]: [WildoRuntimeNetwork.DATA_OBJECTS],\n [PlatformDataServices.MINIO_INIT]: [WildoRuntimeNetwork.DATA_OBJECTS],\n [PlatformDataServices.POSTGRESQL]: [WildoRuntimeNetwork.DATA_POSTGRES],\n [PlatformDataServices.CLAMAV]: [WildoRuntimeNetwork.DATA_ANTIVIRUS],\n [PlatformDataServices.IMMUDB]: [WildoRuntimeNetwork.DATA_AUDIT],\n [PlatformDataServices.OPENBAO]: [WildoRuntimeNetwork.DATA_KEYS],\n // The platform services: the control plane every runtime fetches its bootstrap material from, plus the stores each\n // one writes. apps-manager's key-custodian segment is added by `resolveFrameworkWorkloadNetworks` when there is one.\n // The broker segment is added by `resolveFrameworkWorkloadSegments` while the environment runs one (#2303 slice D).\n [PlatformWildoServices.PLATFORM_INIT]: [\n WildoRuntimeNetwork.PLATFORM,\n WildoRuntimeNetwork.DATA_MONGO,\n WildoRuntimeNetwork.DATA_REDIS,\n WildoRuntimeNetwork.DATA_POSTGRES,\n WildoRuntimeNetwork.DATA_OBJECTS,\n ],\n [PlatformWildoServices.APPS_MANAGER]: [\n WildoRuntimeNetwork.PLATFORM,\n WildoRuntimeNetwork.DATA_MONGO,\n WildoRuntimeNetwork.DATA_REDIS,\n WildoRuntimeNetwork.DATA_POSTGRES,\n WildoRuntimeNetwork.DATA_OBJECTS,\n WildoRuntimeNetwork.DATA_TELEMETRY,\n ],\n // No broker segment under any profile: the scheduler delivers over HTTP and holds no broker connection (#2303 slice B).\n [PlatformWildoServices.CRONTABS_BATCHES_MANAGER]: [\n WildoRuntimeNetwork.PLATFORM,\n WildoRuntimeNetwork.DATA_MONGO,\n WildoRuntimeNetwork.DATA_REDIS,\n WildoRuntimeNetwork.DATA_OBJECTS,\n WildoRuntimeNetwork.DATA_TELEMETRY,\n ],\n [PlatformWildoServices.MODULE_REGISTRY]: [\n WildoRuntimeNetwork.PLATFORM,\n WildoRuntimeNetwork.DATA_MONGO,\n WildoRuntimeNetwork.DATA_POSTGRES,\n WildoRuntimeNetwork.DATA_REDIS,\n WildoRuntimeNetwork.DATA_OBJECTS,\n WildoRuntimeNetwork.DATA_TELEMETRY,\n ],\n};\n\n/**\n * The workloads that join the broker's segment while the environment runs one: platform-init and apps-manager provision\n * the broker's users and vhosts through its management API (#2303 slice D).\n */\nconst MESSAGE_BROKER_CLIENTS: ReadonlySet<FrameworkWorkload> = new Set<FrameworkWorkload>([\n PlatformWildoServices.PLATFORM_INIT,\n PlatformWildoServices.APPS_MANAGER,\n]);\n\n/** The workloads that join the platform Vault's segment when the environment self-hosts one. */\nconst PLATFORM_KEY_VAULT_CLIENTS: ReadonlySet<FrameworkWorkload> = new Set<FrameworkWorkload>([\n PlatformWildoServices.APPS_MANAGER,\n PlatformWildoServices.PLATFORM_INIT,\n]);\n\n/**\n * The framework workloads that need a route off the cluster, with the reason. Everything else has none: a database, a\n * cache, a broker or a key custodian answers connections and opens none to the outside.\n *\n * - **ClamAV** refreshes its signature database from the ClamAV mirrors (`freshclam`, run by the image itself); cut off,\n * it keeps scanning against signatures that age from the day the pod started.\n * - **The platform services** reach every backing service an environment declares MANAGED — those live outside the\n * cluster, so no in-namespace segment reaches them — and the external providers apps-manager calls (cloud key\n * management, provider credential checks). In compose they have the same route, through the publish bridge.\n */\nexport const FRAMEWORK_WORKLOAD_INTERNET_EGRESS: ReadonlySet<FrameworkWorkload> = new Set<FrameworkWorkload>([\n PlatformDataServices.CLAMAV,\n PlatformWildoServices.PLATFORM_INIT,\n PlatformWildoServices.APPS_MANAGER,\n PlatformWildoServices.CRONTABS_BATCHES_MANAGER,\n PlatformWildoServices.MODULE_REGISTRY,\n]);\n\n/**\n * The INTERNAL segments a framework workload joins: the set the compose lane attaches it to (pinned against the\n * rendered compose file) and the set its Kubernetes pod labels name, minus the route off the cluster.\n */\nexport function resolveFrameworkWorkloadSegments(\n workload: FrameworkWorkload,\n context: FrameworkWorkloadNetworkContext,\n): WildoRuntimeNetwork[] {\n const segments = [...FRAMEWORK_WORKLOAD_SEGMENTS[workload]];\n if (context.runsMessageBroker && MESSAGE_BROKER_CLIENTS.has(workload)) segments.push(WildoRuntimeNetwork.DATA_RABBIT);\n if (context.selfHostsPlatformKeyVault && PLATFORM_KEY_VAULT_CLIENTS.has(workload)) segments.push(WildoRuntimeNetwork.DATA_KEYS);\n return segments;\n}\n\n/** Everything a framework workload's Kubernetes pod labels name: its segments plus, where authored, the egress door. */\nexport function resolveFrameworkWorkloadNetworks(\n workload: FrameworkWorkload,\n context: FrameworkWorkloadNetworkContext,\n): WildoRuntimeNetwork[] {\n const networks = resolveFrameworkWorkloadSegments(workload, context);\n if (FRAMEWORK_WORKLOAD_INTERNET_EGRESS.has(workload)) networks.push(WildoRuntimeNetwork.EGRESS);\n return networks;\n}\n\n/** Narrow a rendered service name to a framework workload, or `null` for a name the table does not know. */\nexport function asFrameworkWorkload(serviceName: string): FrameworkWorkload | null {\n return Object.prototype.hasOwnProperty.call(FRAMEWORK_WORKLOAD_SEGMENTS, serviceName) ? (serviceName as FrameworkWorkload) : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"framework-pod-network-membership.js","sourceRoot":"","sources":["../../../../src/services/deployment/framework-pod-network-membership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AAiB/F;;;GAGG;AACH,MAAM,2BAA2B,GAA8D;IAC7F,qHAAqH;IACrH,4EAA4E;IAC5E,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IAChE,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IACrE,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IAC/D,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IAC/D,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,mBAAmB,CAAC,WAAW,CAAC;IAClE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC;IAChE,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC;IACrE,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC,mBAAmB,CAAC,aAAa,CAAC;IACtE,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,cAAc,CAAC;IACnE,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,UAAU,CAAC;IAC/D,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC,mBAAmB,CAAC,SAAS,CAAC;I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ongs to (#3372): the backing services, the one-shot init jobs\n * and the platform services. Application runtimes are not here — their membership is derived from their principal and\n * declaration by `resolveRuntimeNetworkMembership` in `@wildo-ai/platform-config-lib`.\n *\n * ## Why this table exists\n *\n * The Kubernetes `NetworkPolicy` set is a namespace-wide default-deny plus one allow per segment, selecting on\n * `wildo.ai/net-<segment>` pod labels. Until #3372 only the application runtime pods carried those labels, so the\n * backing services they dial matched no allow rule and the policy set cut every runtime off its data plane. Every pod\n * the framework renders into the namespace therefore needs a membership, and this is where it is decided.\n *\n * ## Two lanes, one membership\n *\n * The compose lane expresses the same segments as network attachments written into\n * `templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs`. That template is hand-written, so this table\n * is the second statement of the same fact — the shape `.claude/rules/invariant-call-site-enumeration.md` row 23\n * records (one contract, two deployment lanes, one of them wrong). The coupling is pinned rather than trusted:\n * `docker-compose-generator.service.test.ts` renders the real compose template and requires every service's\n * `wildo-*` segment attachments to equal this table, so a segment added on either side alone fails a test.\n *\n * What the table deliberately does NOT copy from compose is the publish bridge (`wildo-host-access`). In compose every\n * container that publishes a port joins that non-internal bridge, which incidentally gives it a route off the host.\n * Kubernetes has no such side effect, so the route off the cluster is authored per workload as\n * {@link WildoRuntimeNetwork.EGRESS}, and is compared separately (see {@link FRAMEWORK_WORKLOAD_INTERNET_EGRESS}).\n */\nimport { PlatformWildoServices, WildoRuntimeNetwork } from '@wildo-ai/platform-config-lib';\n\nimport { PlatformDataServices } from '~wildo-cli/services/data-services/data-services.schemas';\n\n/** Every framework-owned workload that can be rendered into an environment, on either lane. */\nexport type FrameworkWorkload = PlatformDataServices | PlatformWildoServices;\n\n/** What membership depends on beyond the workload itself. */\nexport interface FrameworkWorkloadNetworkContext {\n /** Whether the environment self-hosts the platform Vault (#2933); only then does apps-manager join its segment. */\n readonly selfHostsPlatformKeyVault: boolean;\n /**\n * Whether the environment runs a message broker (`environmentServiceProfileRunsMessageBroker`, #2303 slice D); only then\n * do the platform's broker clients join its segment. Under a profile whose queue lives in the application's database\n * there is no broker, and a segment with no server is a membership that grants nothing and claims a dependency.\n */\n readonly runsMessageBroker: boolean;\n}\n\n/**\n * The INTERNAL segments of each workload. Total over both vocabularies, so a new backing or platform service is a\n * compile error here rather than a pod the default-deny silently isolates.\n */\nconst FRAMEWORK_WORKLOAD_SEGMENTS: Record<FrameworkWorkload, readonly WildoRuntimeNetwork[]> = {\n // mongod and its search sidecar dial EACH OTHER (`mongotHost` one way, the sync source the other), which is why both\n // are plain members of the Mongo segment rather than one serving the other.\n [PlatformDataServices.MONGODB]: [WildoRuntimeNetwork.DATA_MONGO],\n [PlatformDataServices.MONGODB_INIT]: [WildoRuntimeNetwork.DATA_MONGO],\n [PlatformDataServices.MONGOT]: [WildoRuntimeNetwork.DATA_MONGO],\n [PlatformDataServices.VALKEY]: [WildoRuntimeNetwork.DATA_REDIS],\n [PlatformDataServices.RABBITMQ]: [WildoRuntimeNetwork.DATA_RABBIT],\n [PlatformDataServices.MINIO]: [WildoRuntimeNetwork.DATA_OBJECTS],\n [PlatformDataServices.MINIO_INIT]: [WildoRuntimeNetwork.DATA_OBJECTS],\n [PlatformDataServices.POSTGRESQL]: [WildoRuntimeNetwork.DATA_POSTGRES],\n [PlatformDataServices.CLAMAV]: [WildoRuntimeNetwork.DATA_ANTIVIRUS],\n [PlatformDataServices.IMMUDB]: [WildoRuntimeNetwork.DATA_AUDIT],\n [PlatformDataServices.OPENBAO]: [WildoRuntimeNetwork.DATA_KEYS],\n // The platform services: the control plane every runtime fetches its bootstrap material from, plus the stores each\n // one writes. apps-manager's key-custodian segment is added by `resolveFrameworkWorkloadNetworks` when there is one.\n // The broker segment is added by `resolveFrameworkWorkloadSegments` while the environment runs one (#2303 slice D).\n [PlatformWildoServices.PLATFORM_INIT]: [\n WildoRuntimeNetwork.PLATFORM,\n WildoRuntimeNetwork.DATA_MONGO,\n WildoRuntimeNetwork.DATA_REDIS,\n WildoRuntimeNetwork.DATA_POSTGRES,\n WildoRuntimeNetwork.DATA_OBJECTS,\n ],\n [PlatformWildoServices.APPS_MANAGER]: [\n WildoRuntimeNetwork.PLATFORM,\n WildoRuntimeNetwork.DATA_MONGO,\n WildoRuntimeNetwork.DATA_REDIS,\n WildoRuntimeNetwork.DATA_POSTGRES,\n WildoRuntimeNetwork.DATA_OBJECTS,\n WildoRuntimeNetwork.DATA_TELEMETRY,\n ],\n // No broker segment under any profile: the scheduler delivers over HTTP and holds no broker connection (#2303 slice B).\n // The PostgreSQL segment: on a PostgreSQL platform its scheduling repositories and delivery outbox live in the\n // platform database (`initializeSchedulingRepositories`). Without it an app-creator compose platform failed every\n // delivery round with `getaddrinfo EAI_AGAIN postgresql-internal` and no minion ever ticked (finalization run\n // 44310014583, #4025).\n [PlatformWildoServices.CRONTABS_BATCHES_MANAGER]: [\n WildoRuntimeNetwork.PLATFORM,\n WildoRuntimeNetwork.DATA_MONGO,\n WildoRuntimeNetwork.DATA_REDIS,\n WildoRuntimeNetwork.DATA_POSTGRES,\n WildoRuntimeNetwork.DATA_OBJECTS,\n WildoRuntimeNetwork.DATA_TELEMETRY,\n ],\n [PlatformWildoServices.MODULE_REGISTRY]: [\n WildoRuntimeNetwork.PLATFORM,\n WildoRuntimeNetwork.DATA_MONGO,\n WildoRuntimeNetwork.DATA_POSTGRES,\n WildoRuntimeNetwork.DATA_REDIS,\n WildoRuntimeNetwork.DATA_OBJECTS,\n WildoRuntimeNetwork.DATA_TELEMETRY,\n ],\n};\n\n/**\n * The workloads that join the broker's segment while the environment runs one: platform-init and apps-manager provision\n * the broker's users and vhosts through its management API (#2303 slice D).\n */\nconst MESSAGE_BROKER_CLIENTS: ReadonlySet<FrameworkWorkload> = new Set<FrameworkWorkload>([\n PlatformWildoServices.PLATFORM_INIT,\n PlatformWildoServices.APPS_MANAGER,\n]);\n\n/** The workloads that join the platform Vault's segment when the environment self-hosts one. */\nconst PLATFORM_KEY_VAULT_CLIENTS: ReadonlySet<FrameworkWorkload> = new Set<FrameworkWorkload>([\n PlatformWildoServices.APPS_MANAGER,\n PlatformWildoServices.PLATFORM_INIT,\n]);\n\n/**\n * The framework workloads that need a route off the cluster, with the reason. Everything else has none: a database, a\n * cache, a broker or a key custodian answers connections and opens none to the outside.\n *\n * - **ClamAV** refreshes its signature database from the ClamAV mirrors (`freshclam`, run by the image itself); cut off,\n * it keeps scanning against signatures that age from the day the pod started.\n * - **The platform services** reach every backing service an environment declares MANAGED — those live outside the\n * cluster, so no in-namespace segment reaches them — and the external providers apps-manager calls (cloud key\n * management, provider credential checks). In compose they have the same route, through the publish bridge.\n */\nexport const FRAMEWORK_WORKLOAD_INTERNET_EGRESS: ReadonlySet<FrameworkWorkload> = new Set<FrameworkWorkload>([\n PlatformDataServices.CLAMAV,\n PlatformWildoServices.PLATFORM_INIT,\n PlatformWildoServices.APPS_MANAGER,\n PlatformWildoServices.CRONTABS_BATCHES_MANAGER,\n PlatformWildoServices.MODULE_REGISTRY,\n]);\n\n/**\n * The INTERNAL segments a framework workload joins: the set the compose lane attaches it to (pinned against the\n * rendered compose file) and the set its Kubernetes pod labels name, minus the route off the cluster.\n */\nexport function resolveFrameworkWorkloadSegments(\n workload: FrameworkWorkload,\n context: FrameworkWorkloadNetworkContext,\n): WildoRuntimeNetwork[] {\n const segments = [...FRAMEWORK_WORKLOAD_SEGMENTS[workload]];\n if (context.runsMessageBroker && MESSAGE_BROKER_CLIENTS.has(workload)) segments.push(WildoRuntimeNetwork.DATA_RABBIT);\n if (context.selfHostsPlatformKeyVault && PLATFORM_KEY_VAULT_CLIENTS.has(workload)) segments.push(WildoRuntimeNetwork.DATA_KEYS);\n return segments;\n}\n\n/** Everything a framework workload's Kubernetes pod labels name: its segments plus, where authored, the egress door. */\nexport function resolveFrameworkWorkloadNetworks(\n workload: FrameworkWorkload,\n context: FrameworkWorkloadNetworkContext,\n): WildoRuntimeNetwork[] {\n const networks = resolveFrameworkWorkloadSegments(workload, context);\n if (FRAMEWORK_WORKLOAD_INTERNET_EGRESS.has(workload)) networks.push(WildoRuntimeNetwork.EGRESS);\n return networks;\n}\n\n/** Narrow a rendered service name to a framework workload, or `null` for a name the table does not know. */\nexport function asFrameworkWorkload(serviceName: string): FrameworkWorkload | null {\n return Object.prototype.hasOwnProperty.call(FRAMEWORK_WORKLOAD_SEGMENTS, serviceName) ? (serviceName as FrameworkWorkload) : null;\n}\n"]}
|
|
@@ -66,9 +66,41 @@ export interface WorkspaceReconcileReads {
|
|
|
66
66
|
readonly installedAtMs: (root: string) => number | null;
|
|
67
67
|
readonly members: (root: string) => readonly WorkspaceDevMember[];
|
|
68
68
|
readonly now: () => number;
|
|
69
|
+
/**
|
|
70
|
+
* The application-relative directories of the declared RUNTIMES (services, minions, workers): the members that read a
|
|
71
|
+
* `.env` (#4019). `null` when the declaration cannot be read, and then every member is treated as one, as before.
|
|
72
|
+
* Absent, likewise.
|
|
73
|
+
*/
|
|
74
|
+
readonly runtimeDirectories?: (root: string) => Promise<ReadonlySet<string> | null>;
|
|
75
|
+
/** Whether a member's compiled output exists: every file its package `exports` names (#4019). Absent: always ready. */
|
|
76
|
+
readonly memberOutputReady?: (root: string, member: WorkspaceDevMember) => boolean;
|
|
69
77
|
}
|
|
70
78
|
/** After a failed regeneration, how long before the next attempt. */
|
|
71
79
|
export declare const ENV_REGENERATION_RETRY_MS = 60000;
|
|
80
|
+
/**
|
|
81
|
+
* How long a regeneration waits for a member started while it was owed to produce its compiled output (#4019). A provider
|
|
82
|
+
* facet's first compile takes seconds; past this, the regeneration is attempted anyway and its failure is reported.
|
|
83
|
+
*/
|
|
84
|
+
export declare const LATE_MEMBER_OUTPUT_WAIT_MS: number;
|
|
85
|
+
/** The declared runtimes' directories, from the declaration read fresh: services, minions and workers. */
|
|
86
|
+
export declare function declaredRuntimeDirectories(config: {
|
|
87
|
+
readonly services?: Record<string, {
|
|
88
|
+
readonly path: string;
|
|
89
|
+
}>;
|
|
90
|
+
readonly minions?: Record<string, {
|
|
91
|
+
readonly path: string;
|
|
92
|
+
}>;
|
|
93
|
+
readonly workers?: Record<string, {
|
|
94
|
+
readonly path: string;
|
|
95
|
+
}>;
|
|
96
|
+
}): ReadonlySet<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Whether every file a member's package `exports` names exists: its compiled output, which a sync resolving the member's
|
|
99
|
+
* declared runtime export reads (a provider facet's `./app` → `./dist/app.js`). The `source` condition is not output, and
|
|
100
|
+
* a `require` target is a CommonJS build a dev watcher need not emit. A member with no readable manifest or no
|
|
101
|
+
* file-shaped export has nothing to wait for.
|
|
102
|
+
*/
|
|
103
|
+
export declare function memberCompiledOutputExists(appRoot: string, member: WorkspaceDevMember): boolean;
|
|
72
104
|
export declare const DEFAULT_WORKSPACE_RECONCILE_READS: WorkspaceReconcileReads;
|
|
73
105
|
/**
|
|
74
106
|
* One reconcile of the running stack with the workspace and the declaration (#3985, #3986), as `wildo local dev` runs it
|
|
@@ -79,10 +111,17 @@ export declare const DEFAULT_WORKSPACE_RECONCILE_READS: WorkspaceReconcileReads;
|
|
|
79
111
|
* (or that is unknown), the env files are OWED, and `regenerate` (the startup bootstrap) runs. A failure keeps them
|
|
80
112
|
* owed and retries after {@link ENV_REGENERATION_RETRY_MS}. A declaration that does not load (an edit in progress)
|
|
81
113
|
* owes nothing yet and is read again on the next change.
|
|
82
|
-
* 2. The members
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
114
|
+
* 2. The members. Each member a finished install brought gets its dev process, once. A member that is a declared
|
|
115
|
+
* RUNTIME (a service, a minion, a worker) reads a `.env`, so it starts only once no regeneration is owed. Any other
|
|
116
|
+
* member (a provider facet, a library) reads none and starts at once, even while one is owed (#4019).
|
|
117
|
+
* 3. A regeneration owed while such a member compiles WAITS for its output, up to {@link LATE_MEMBER_OUTPUT_WAIT_MS},
|
|
118
|
+
* and is attempted the moment the output exists rather than on the next retry.
|
|
119
|
+
*
|
|
120
|
+
* Why 2 and 3 (#4019): the regeneration resolves every frontend provider entry a scope binds, and an installed module's
|
|
121
|
+
* browser facet resolves only once compiled. On reference run 44052185141 the PostHog facet joined at 11:00 and the
|
|
122
|
+
* regeneration failed on "cannot resolve declared runtime export …/provider-posthog-frontend/app" 85 times, while it
|
|
123
|
+
* held back the very dev process that would have compiled the facet: until #4019, every member waited for a successful
|
|
124
|
+
* regeneration, which was the trade #3986 accepted and recorded. A member reading no `.env` never needed to wait.
|
|
86
125
|
*/
|
|
87
126
|
export declare function createWorkspaceReconciler(input: {
|
|
88
127
|
readonly appRoot: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-dev-late-workspace-members.service.d.ts","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-late-workspace-members.service.ts"],"names":[],"mappings":"AA6BA,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAiB7E;AAED,qGAAqG;AACrG,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,0GAA0G;IAC1G,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,wBAAwB,EAC/B,KAAK,GAAE;IACL,QAAQ,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACxD,QAAQ,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACpD,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,kBAAkB,EAAE,CAAC;CACvC,GAC5B;IAAE,QA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,CAAC,gBAAgB,EAAE,MAAM,OAAO,CAAA;CAAE,CAwExF;AAYD,gGAAgG;AAChG,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,uBAA2D,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAS5J;AAKD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mCAAmC,CACvD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,OAAO,CAAmB,GAC5H,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { execFile } from 'node:child_process';
|
|
20
20
|
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
21
|
-
import { join } from 'node:path';
|
|
21
|
+
import { join, normalize } from 'node:path';
|
|
22
22
|
import { promisify } from 'node:util';
|
|
23
23
|
import { loadSaasConfig } from '@wildo-ai/platform-config-lib';
|
|
24
24
|
import { LocalDevDependencyInstallPhase } from '@wildo-ai/platform-core-shared';
|
|
@@ -122,6 +122,54 @@ export function declarationFingerprint(config) {
|
|
|
122
122
|
const SAAS_CONFIG_FILE = 'wildo.saas.config.ts';
|
|
123
123
|
/** After a failed regeneration, how long before the next attempt. */
|
|
124
124
|
export const ENV_REGENERATION_RETRY_MS = 60_000;
|
|
125
|
+
/**
|
|
126
|
+
* How long a regeneration waits for a member started while it was owed to produce its compiled output (#4019). A provider
|
|
127
|
+
* facet's first compile takes seconds; past this, the regeneration is attempted anyway and its failure is reported.
|
|
128
|
+
*/
|
|
129
|
+
export const LATE_MEMBER_OUTPUT_WAIT_MS = 5 * 60_000;
|
|
130
|
+
/** An application-relative directory, as the workspace lists a member and the declaration a runtime (`./frontend` → `frontend`). */
|
|
131
|
+
function applicationRelativeDirectory(path) {
|
|
132
|
+
return normalize(path).replace(/^\.\//u, '').replace(/\/+$/u, '');
|
|
133
|
+
}
|
|
134
|
+
/** The declared runtimes' directories, from the declaration read fresh: services, minions and workers. */
|
|
135
|
+
export function declaredRuntimeDirectories(config) {
|
|
136
|
+
return new Set([config.services, config.minions, config.workers]
|
|
137
|
+
.flatMap((owners) => Object.values(owners ?? {}))
|
|
138
|
+
.map((owner) => applicationRelativeDirectory(owner.path)));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Whether every file a member's package `exports` names exists: its compiled output, which a sync resolving the member's
|
|
142
|
+
* declared runtime export reads (a provider facet's `./app` → `./dist/app.js`). The `source` condition is not output, and
|
|
143
|
+
* a `require` target is a CommonJS build a dev watcher need not emit. A member with no readable manifest or no
|
|
144
|
+
* file-shaped export has nothing to wait for.
|
|
145
|
+
*/
|
|
146
|
+
export function memberCompiledOutputExists(appRoot, member) {
|
|
147
|
+
const memberRoot = join(appRoot, member.directory);
|
|
148
|
+
let exportsField;
|
|
149
|
+
try {
|
|
150
|
+
exportsField = JSON.parse(readFileSync(join(memberRoot, 'package.json'), 'utf8')).exports;
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
const targets = [];
|
|
156
|
+
const collect = (value, condition) => {
|
|
157
|
+
if (typeof value === 'string') {
|
|
158
|
+
if (condition !== 'source' && condition !== 'require' && value.startsWith('./') && !value.includes('*'))
|
|
159
|
+
targets.push(value);
|
|
160
|
+
}
|
|
161
|
+
else if (Array.isArray(value)) {
|
|
162
|
+
for (const entry of value)
|
|
163
|
+
collect(entry, condition);
|
|
164
|
+
}
|
|
165
|
+
else if (value !== null && typeof value === 'object') {
|
|
166
|
+
for (const [key, entry] of Object.entries(value))
|
|
167
|
+
collect(entry, key.startsWith('.') ? condition : key);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
collect(exportsField);
|
|
171
|
+
return targets.every((target) => existsSync(join(memberRoot, target)));
|
|
172
|
+
}
|
|
125
173
|
export const DEFAULT_WORKSPACE_RECONCILE_READS = {
|
|
126
174
|
installInFlight: isDependencyInstallInFlight,
|
|
127
175
|
configModifiedAtMs: (root) => {
|
|
@@ -140,6 +188,16 @@ export const DEFAULT_WORKSPACE_RECONCILE_READS = {
|
|
|
140
188
|
installedAtMs: readNodeModulesInstalledAtMs,
|
|
141
189
|
members: listWorkspaceDevMembers,
|
|
142
190
|
now: () => Date.now(),
|
|
191
|
+
runtimeDirectories: async (root) => {
|
|
192
|
+
try {
|
|
193
|
+
const config = await loadSaasConfig(join(root, SAAS_CONFIG_FILE), { freshModuleCache: true });
|
|
194
|
+
return config === null ? null : declaredRuntimeDirectories(config);
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
memberOutputReady: memberCompiledOutputExists,
|
|
143
201
|
};
|
|
144
202
|
/**
|
|
145
203
|
* One reconcile of the running stack with the workspace and the declaration (#3985, #3986), as `wildo local dev` runs it
|
|
@@ -150,10 +208,17 @@ export const DEFAULT_WORKSPACE_RECONCILE_READS = {
|
|
|
150
208
|
* (or that is unknown), the env files are OWED, and `regenerate` (the startup bootstrap) runs. A failure keeps them
|
|
151
209
|
* owed and retries after {@link ENV_REGENERATION_RETRY_MS}. A declaration that does not load (an edit in progress)
|
|
152
210
|
* owes nothing yet and is read again on the next change.
|
|
153
|
-
* 2. The members
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
211
|
+
* 2. The members. Each member a finished install brought gets its dev process, once. A member that is a declared
|
|
212
|
+
* RUNTIME (a service, a minion, a worker) reads a `.env`, so it starts only once no regeneration is owed. Any other
|
|
213
|
+
* member (a provider facet, a library) reads none and starts at once, even while one is owed (#4019).
|
|
214
|
+
* 3. A regeneration owed while such a member compiles WAITS for its output, up to {@link LATE_MEMBER_OUTPUT_WAIT_MS},
|
|
215
|
+
* and is attempted the moment the output exists rather than on the next retry.
|
|
216
|
+
*
|
|
217
|
+
* Why 2 and 3 (#4019): the regeneration resolves every frontend provider entry a scope binds, and an installed module's
|
|
218
|
+
* browser facet resolves only once compiled. On reference run 44052185141 the PostHog facet joined at 11:00 and the
|
|
219
|
+
* regeneration failed on "cannot resolve declared runtime export …/provider-posthog-frontend/app" 85 times, while it
|
|
220
|
+
* held back the very dev process that would have compiled the facet: until #4019, every member waited for a successful
|
|
221
|
+
* regeneration, which was the trade #3986 accepted and recorded. A member reading no `.env` never needed to wait.
|
|
157
222
|
*/
|
|
158
223
|
export function createWorkspaceReconciler(input) {
|
|
159
224
|
const reads = input.reads ?? DEFAULT_WORKSPACE_RECONCILE_READS;
|
|
@@ -162,6 +227,14 @@ export function createWorkspaceReconciler(input) {
|
|
|
162
227
|
let owed = null; // the fingerprint whose env files are owed
|
|
163
228
|
let retryAtMs = 0;
|
|
164
229
|
let running = false;
|
|
230
|
+
/** Members that read a `.env`, held until no regeneration is owed. */
|
|
231
|
+
let deferred = [];
|
|
232
|
+
/** Members started without waiting for the env files, whose compiled output a regeneration waits for, by start time. */
|
|
233
|
+
const awaitingOutput = new Map();
|
|
234
|
+
const startNow = (member) => {
|
|
235
|
+
input.startMember(member);
|
|
236
|
+
awaitingOutput.set(member.name, { member, startedAtMs: reads.now() });
|
|
237
|
+
};
|
|
165
238
|
const reconcile = async () => {
|
|
166
239
|
if (running || input.isStopping() || reads.installInFlight(input.appRoot))
|
|
167
240
|
return;
|
|
@@ -183,7 +256,30 @@ export function createWorkspaceReconciler(input) {
|
|
|
183
256
|
declaration = { fingerprint, configModifiedAtMs: modifiedAtMs };
|
|
184
257
|
}
|
|
185
258
|
}
|
|
186
|
-
|
|
259
|
+
}
|
|
260
|
+
// The members a finished install brought. One that reads no `.env` starts at once; one that does waits for the env.
|
|
261
|
+
const decision = decideLateWorkspaceMembers(input.appRoot, members, reads);
|
|
262
|
+
members = decision.state;
|
|
263
|
+
if (decision.toStart.length > 0) {
|
|
264
|
+
const runtimeDirectories = input.canRegenerate ? await readRuntimeDirectories(reads, input.appRoot) : null;
|
|
265
|
+
for (const member of decision.toStart) {
|
|
266
|
+
if (runtimeDirectories !== null && !runtimeDirectories.has(applicationRelativeDirectory(member.directory)))
|
|
267
|
+
startNow(member);
|
|
268
|
+
else
|
|
269
|
+
deferred.push(member);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (input.canRegenerate) {
|
|
273
|
+
// Wait for what a member started without the env files compiles; the moment it is there, try at once.
|
|
274
|
+
if (awaitingOutput.size > 0) {
|
|
275
|
+
for (const [name, { member, startedAtMs }] of awaitingOutput) {
|
|
276
|
+
if ((reads.memberOutputReady?.(input.appRoot, member) ?? true) || reads.now() - startedAtMs >= LATE_MEMBER_OUTPUT_WAIT_MS)
|
|
277
|
+
awaitingOutput.delete(name);
|
|
278
|
+
}
|
|
279
|
+
if (awaitingOutput.size === 0)
|
|
280
|
+
retryAtMs = 0;
|
|
281
|
+
}
|
|
282
|
+
if (owed !== null && awaitingOutput.size === 0 && reads.now() >= retryAtMs) {
|
|
187
283
|
try {
|
|
188
284
|
await input.regenerate();
|
|
189
285
|
owed = null;
|
|
@@ -197,9 +293,9 @@ export function createWorkspaceReconciler(input) {
|
|
|
197
293
|
if (owed !== null || input.isStopping())
|
|
198
294
|
return;
|
|
199
295
|
}
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
for (const member of
|
|
296
|
+
const ready = deferred;
|
|
297
|
+
deferred = [];
|
|
298
|
+
for (const member of ready)
|
|
203
299
|
input.startMember(member);
|
|
204
300
|
}
|
|
205
301
|
finally {
|
|
@@ -208,6 +304,17 @@ export function createWorkspaceReconciler(input) {
|
|
|
208
304
|
};
|
|
209
305
|
return { reconcile, regenerationOwed: () => owed !== null };
|
|
210
306
|
}
|
|
307
|
+
/** The declared runtimes' directories, or `null` (every member then waits for the env files) when they cannot be read. */
|
|
308
|
+
async function readRuntimeDirectories(reads, appRoot) {
|
|
309
|
+
if (reads.runtimeDirectories === undefined)
|
|
310
|
+
return null;
|
|
311
|
+
try {
|
|
312
|
+
return await reads.runtimeDirectories(appRoot);
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
211
318
|
/** The declaration the stack started from: what its env files were written from moments ago. */
|
|
212
319
|
export async function initialDeclarationState(appRoot, reads = DEFAULT_WORKSPACE_RECONCILE_READS) {
|
|
213
320
|
const configModifiedAtMs = reads.configModifiedAtMs(appRoot);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-dev-late-workspace-members.service.js","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-late-workspace-members.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAElJ,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,0EAA0E,CAAC;AAUvJ;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,MAAM,EAAE,OAAO,EAAE,GAAG,6BAA6B,CAAC,OAAO,EAAE,4BAA4B,CAAC,IAAI,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC/H,MAAM,KAAK,GAAyB,EAA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AE,IAAuB,EAAE,OAAyC,EAAoB,EAAE,CAC7H,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC","sourcesContent":["/**\n * The workspace members that JOIN an application while `wildo local dev` runs, and the dev process each one is owed (#3986).\n *\n * The development tree is `pnpm dev`, which runs `pnpm -r run dev`: one `dev` process for every workspace member that\n * has the script, enumerated ONCE, when the stack starts. A member added later never gets one. The members that arrive\n * that way are real and routine: `wildo registry add` installs a provider as `providers/<ref>/backend`, and `wildo compose`\n * adds a website, a documentation site, a minion or a worker. Measured on reference run 43876218697: a coding run\n * installed the Brevo provider at 16:41, its package was never compiled, and the backend, which depends on it, sat paused\n * on `dependency-output-not-ready` for the rest of the run. A person routes around it by restarting `wildo local dev`; an\n * unattended creation cannot.\n *\n * So the stack watches for a FINISHED INSTALL (a new member is usable only once its dependencies are), and starts the dev\n * script of every member with one that it has not started yet. A member that is also a declared SERVICE needs its `.env`\n * first: {@link decideRuntimeTopologyRegeneration} says when the declared topology changed, and the command rewrites\n * every runtime's env files BEFORE it starts the new members (#3985). The decision is pure and lives here; the spawning stays in\n * the command. A member that LEAVES is not stopped: its process exits on its own when its files go, and a restart of the\n * stack reads the workspace afresh.\n */\nimport { execFile } from 'node:child_process';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { promisify } from 'node:util';\n\nimport { loadSaasConfig } from '@wildo-ai/platform-config-lib';\nimport { LocalDevDependencyInstallPhase } from '@wildo-ai/platform-core-shared';\nimport { classifyDependencyInstall, readDependencyInstallRecord, readNodeModulesInstalledAtMs } from '@wildo-ai/platform-core-shared/dev-runtime';\n\nimport { expandWorkspaceMemberPatterns, readWorkspacePackagePatterns } from '~wildo-cli/services/application/application-dependency-alignment.service';\n\n/** A workspace member that runs a `dev` script, as `pnpm -r run dev` would start it. */\nexport interface WorkspaceDevMember {\n /** Its package name: what `pnpm --filter` selects. */\n readonly name: string;\n /** Its directory, application-relative. */\n readonly directory: string;\n}\n\n/**\n * Every workspace member (the root excluded) whose `package.json` declares a `dev` script: the set `pnpm -r run dev`\n * starts. A member whose manifest does not parse, or that has no name, is left out, as pnpm cannot select it either.\n */\nexport function listWorkspaceDevMembers(appRoot: string): WorkspaceDevMember[] {\n const { members } = expandWorkspaceMemberPatterns(appRoot, readWorkspacePackagePatterns(join(appRoot, 'pnpm-workspace.yaml')));\n const found: WorkspaceDevMember[] = [];\n for (const directory of members) {\n if (directory === '.') continue;\n const manifestPath = join(appRoot, directory, 'package.json');\n if (!existsSync(manifestPath)) continue;\n try {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { readonly name?: unknown; readonly scripts?: Record<string, unknown> };\n if (typeof manifest.name === 'string' && manifest.name.length > 0 && typeof manifest.scripts?.dev === 'string') {\n found.push({ name: manifest.name, directory });\n }\n } catch {\n // An unreadable manifest is one pnpm cannot run either.\n }\n }\n return found;\n}\n\n/** What the stack knows between two looks: the members it runs, and the install it last acted on. */\nexport interface LateWorkspaceMemberState {\n readonly started: ReadonlySet<string>;\n /** When pnpm last finished an install in the application, as last seen (`node_modules/.modules.yaml`). */\n readonly installedAtMs: number | null;\n}\n\n/**\n * The members to start now, and the state to keep. Pure but for the reads, which a test replaces.\n *\n * Nothing starts while an install is IN FLIGHT (the member's dependencies are not there yet), and nothing is looked for\n * until pnpm has finished an install since the last look: a member is added by an install, and listing the workspace on\n * every tick would read every manifest every few seconds for nothing.\n */\nexport function decideLateWorkspaceMembers(\n appRoot: string,\n state: LateWorkspaceMemberState,\n reads: {\n readonly installedAtMs: (root: string) => number | null;\n readonly installInFlight: (root: string) => boolean;\n readonly members: (root: string) => readonly WorkspaceDevMember[];\n } = DEFAULT_LATE_MEMBER_READS,\n): { readonly toStart: readonly WorkspaceDevMember[]; readonly state: LateWorkspaceMemberState } {\n if (reads.installInFlight(appRoot)) return { toStart: [], state };\n const installedAtMs = reads.installedAtMs(appRoot);\n if (installedAtMs === null || (state.installedAtMs !== null && installedAtMs <= state.installedAtMs)) return { toStart: [], state };\n const toStart = reads.members(appRoot).filter((member) => !state.started.has(member.name));\n return {\n toStart,\n state: { started: new Set([...state.started, ...toStart.map((member) => member.name)]), installedAtMs },\n };\n}\n\n/** Whether a dependency install is running in the application right now (the stack-event record, #3552). */\nexport function isDependencyInstallInFlight(appRoot: string): boolean {\n return classifyDependencyInstall(readDependencyInstallRecord(appRoot), Date.now()).phase === LocalDevDependencyInstallPhase.IN_FLIGHT;\n}\n\nconst DEFAULT_LATE_MEMBER_READS = {\n installedAtMs: readNodeModulesInstalledAtMs,\n installInFlight: isDependencyInstallInFlight,\n members: listWorkspaceDevMembers,\n} as const;\n\n/** The state at the stack's start: every member `pnpm -r run dev` is starting, and the install already on disk. */\nexport function initialLateWorkspaceMemberState(appRoot: string): LateWorkspaceMemberState {\n return {\n started: new Set(listWorkspaceDevMembers(appRoot).map((member) => member.name)),\n installedAtMs: readNodeModulesInstalledAtMs(appRoot),\n };\n}\n\n/** How often the stack looks for a finished install. */\nexport const LATE_WORKSPACE_MEMBER_POLL_MS = 5_000;\n\n/**\n * What the runtimes' env files are written from, out of a `wildo.saas.config.ts` (#3985): the WHOLE declaration. The\n * runtime topology is the case measured — services, minions and workers become `APPLICATION_RUNTIME_ENDPOINTS`, and on\n * reference run 43876218697 `add-website` declared a website at 14:51, the companion restarted at 16:52 and crash-looped on\n * `frontendServices.<x> is declared but runtime.endPoints.<x> is missing` until the run ended. But the env writer also\n * derives from providers, systems of record, data services and key management, so a hand-picked subset of fields would be\n * a second list of what the writer reads, the kind that rots. Any change to the declaration therefore owes a regeneration,\n * which is what restarting `wildo local dev` would do.\n *\n * A canonical string: keys sorted at every depth (an edit that only reorders is not a change), functions and cycles named\n * rather than followed. It sees what is enumerable: a `Map`, a `Set` or a value kept on non-enumerable properties (a Zod\n * schema) serialises without its contents, so a change held only there is not seen. A declaration is plain data today.\n */\nexport function declarationFingerprint(config: unknown): string {\n const seen = new WeakSet<object>();\n const canonical = (value: unknown): unknown => {\n if (typeof value === 'function') return '[function]';\n if (typeof value === 'bigint') return value.toString();\n if (value === null || typeof value !== 'object') return value;\n if (seen.has(value)) return '[circular]';\n seen.add(value);\n const result = Array.isArray(value)\n ? value.map(canonical)\n : Object.fromEntries(Object.keys(value as Record<string, unknown>).sort().map((key) => [key, canonical((value as Record<string, unknown>)[key])]));\n seen.delete(value);\n return result;\n };\n return JSON.stringify(canonical(config));\n}\n\n/** The declaration the runtimes' env files were last written from, and the config file's state when it was read. */\nexport interface DeclarationState {\n /** `null` when the starting read failed: the first declaration read later is then owed a regeneration. */\n readonly fingerprint: string | null;\n /** The config file's modification time at that read: an unchanged file is never re-read. */\n readonly configModifiedAtMs: number | null;\n}\n\n/** The reads the reconcile pass makes, replaceable by a test. */\nexport interface WorkspaceReconcileReads {\n readonly installInFlight: (root: string) => boolean;\n readonly configModifiedAtMs: (root: string) => number | null;\n readonly loadFingerprint: (root: string) => Promise<string | null>;\n readonly installedAtMs: (root: string) => number | null;\n readonly members: (root: string) => readonly WorkspaceDevMember[];\n readonly now: () => number;\n}\n\nconst SAAS_CONFIG_FILE = 'wildo.saas.config.ts';\n\n/** After a failed regeneration, how long before the next attempt. */\nexport const ENV_REGENERATION_RETRY_MS = 60_000;\n\nexport const DEFAULT_WORKSPACE_RECONCILE_READS: WorkspaceReconcileReads = {\n installInFlight: isDependencyInstallInFlight,\n configModifiedAtMs: (root) => {\n try {\n return statSync(join(root, SAAS_CONFIG_FILE)).mtimeMs;\n } catch {\n return null;\n }\n },\n // Fresh: jiti's module cache is process-wide, and this process would otherwise read the declaration it started with.\n loadFingerprint: async (root) => {\n const config = await loadSaasConfig(join(root, SAAS_CONFIG_FILE), { freshModuleCache: true });\n return config === null ? null : declarationFingerprint(config);\n },\n installedAtMs: readNodeModulesInstalledAtMs,\n members: listWorkspaceDevMembers,\n now: () => Date.now(),\n};\n\n/**\n * One reconcile of the running stack with the workspace and the declaration (#3985, #3986), as `wildo local dev` runs it\n * every few seconds. Single-flight; nothing at all while an install runs. In ORDER, because a member that is also a\n * declared service needs a `.env` that knows it:\n *\n * 1. The declaration: when the config file changed and its fingerprint differs from what the env files were written from\n * (or that is unknown), the env files are OWED, and `regenerate` (the startup bootstrap) runs. A failure keeps them\n * owed and retries after {@link ENV_REGENERATION_RETRY_MS}. A declaration that does not load (an edit in progress)\n * owes nothing yet and is read again on the next change.\n * 2. The members: only when no regeneration is owed. Each member a finished install brought gets its dev process, once.\n * Accepted cost, recorded on #3986: a regeneration that KEEPS failing holds back every new member, a provider package\n * included (which reads no runtime `.env`). It is reported every minute, and restarting `wildo local dev` clears it;\n * telling the members that need a `.env` from those that do not would take a second reading of the declaration.\n */\nexport function createWorkspaceReconciler(input: {\n readonly appRoot: string;\n /** Whether the env files can be regenerated at all (startup regenerates only with a framework path). */\n readonly canRegenerate: boolean;\n readonly regenerate: () => Promise<void>;\n readonly startMember: (member: WorkspaceDevMember) => void;\n readonly isStopping: () => boolean;\n readonly reportRegenerationFailure: (error: unknown) => void;\n readonly initial: { readonly declaration: DeclarationState; readonly members: LateWorkspaceMemberState };\n readonly reads?: WorkspaceReconcileReads;\n}): { readonly reconcile: () => Promise<void>; readonly regenerationOwed: () => boolean } {\n const reads = input.reads ?? DEFAULT_WORKSPACE_RECONCILE_READS;\n let declaration = input.initial.declaration;\n let members = input.initial.members;\n let owed: string | null = null; // the fingerprint whose env files are owed\n let retryAtMs = 0;\n let running = false;\n const reconcile = async (): Promise<void> => {\n if (running || input.isStopping() || reads.installInFlight(input.appRoot)) return;\n running = true;\n try {\n if (input.canRegenerate) {\n const modifiedAtMs = reads.configModifiedAtMs(input.appRoot);\n if (modifiedAtMs !== null && modifiedAtMs !== declaration.configModifiedAtMs) {\n let fingerprint: string | null = null;\n try {\n fingerprint = await reads.loadFingerprint(input.appRoot);\n } catch {\n fingerprint = null;\n }\n if (fingerprint !== null) {\n if (fingerprint !== declaration.fingerprint) owed = fingerprint;\n declaration = { fingerprint, configModifiedAtMs: modifiedAtMs };\n }\n }\n if (owed !== null && reads.now() >= retryAtMs) {\n try {\n await input.regenerate();\n owed = null;\n } catch (error) {\n retryAtMs = reads.now() + ENV_REGENERATION_RETRY_MS;\n input.reportRegenerationFailure(error);\n }\n }\n // The env files first: a member started now would read a `.env` that may not know it.\n if (owed !== null || input.isStopping()) return;\n }\n const decision = decideLateWorkspaceMembers(input.appRoot, members, reads);\n members = decision.state;\n for (const member of decision.toStart) input.startMember(member);\n } finally {\n running = false;\n }\n };\n return { reconcile, regenerationOwed: () => owed !== null };\n}\n\n/** The declaration the stack started from: what its env files were written from moments ago. */\nexport async function initialDeclarationState(appRoot: string, reads: WorkspaceReconcileReads = DEFAULT_WORKSPACE_RECONCILE_READS): Promise<DeclarationState> {\n const configModifiedAtMs = reads.configModifiedAtMs(appRoot);\n try {\n const fingerprint = await reads.loadFingerprint(appRoot);\n return fingerprint === null ? { fingerprint: null, configModifiedAtMs: null } : { fingerprint, configModifiedAtMs };\n } catch {\n // Unknown: the first declaration read later is owed a regeneration rather than taken as the baseline.\n return { fingerprint: null, configModifiedAtMs: null };\n }\n}\n\n/** Bound on the provider-artifact sync: it reads configuration and writes generated files, and must not hold the reconcile. */\nconst PROVIDER_ARTIFACT_SYNC_TIMEOUT_MS = 5 * 60 * 1000;\n\n/**\n * Regenerate the application's provider runtime artifacts after a declaration change (#3985), as `wildo config sync\n * --domain config` writes them: the per-runtime provider lists, the generated provider modules, the CSP.\n *\n * The env files are not the only thing a declaration change leaves behind. Measured on reference run 43937787170: the\n * foundation declared `email-preview` and `stripe` at 20:31, the backend's provider artifact still listed none (written by\n * `wildo init` at 19:23), and the backend refused six times with \"Required engine capabilities resolve no active provider:\n * [BILLING, EMAIL_TRANSACTIONAL]\" and paused, with the build about to start. The same class as Wonder Procurement's on\n * 2026-10-07 (`findProviderRuntimeArtifactsBehindDeclaration`), which a restart repairs and a running stack never did.\n *\n * Run as a CHILD of this CLI: in this long-lived process the configuration loader's module cache still holds the\n * declaration the stack started with, and a sync reading it would regenerate the very artifacts that are behind. Rejects\n * when the child fails, so the reconcile keeps the regeneration owed and retries.\n */\nexport async function syncProviderRuntimeArtifactsInChild(\n saasRoot: string,\n envName: string,\n run: (file: string, args: readonly string[], options: { cwd: string; timeout: number }) => Promise<unknown> = defaultRunChild,\n): Promise<void> {\n const cliEntry = process.argv[1];\n if (cliEntry === undefined) throw new Error('The wildo CLI entry point is unknown, so the provider artifacts cannot be regenerated.');\n await run(process.execPath, [cliEntry, 'config', 'sync', '--domain', 'config', '--env', envName, '--non-interactive'], {\n cwd: saasRoot,\n timeout: PROVIDER_ARTIFACT_SYNC_TIMEOUT_MS,\n });\n}\n\nconst defaultRunChild = (file: string, args: readonly string[], options: { cwd: string; timeout: number }): Promise<unknown> =>\n promisify(execFile)(file, [...args], { ...options, maxBuffer: 16 * 1024 * 1024 });\n"]}
|
|
1
|
+
{"version":3,"file":"local-dev-late-workspace-members.service.js","sourceRoot":"","sources":["../../../../src/services/deployment/local-dev-late-workspace-members.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAElJ,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,0EAA0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CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;IACtH,CAAC;IAAC,MAAM,CAAC;QACP,sGAAsG;QACtG,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;IACzD,CAAC;AACH,CAAC;AAED,+HAA+H;AAC/H,MAAM,iCAAiC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,QAAgB,EAChB,OAAe,EACf,MAA8G,eAAe;IAE7H,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjC,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC;IACtI,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,EAAE;QACrH,GAAG,EAAE,QAAQ;QACb,OAAO,EAAE,iCAAiC;KAC3C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAuB,EAAE,OAAyC,EAAoB,EAAE,CAC7H,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC","sourcesContent":["/**\n * The workspace members that JOIN an application while `wildo local dev` runs, and the dev process each one is owed (#3986).\n *\n * The development tree is `pnpm dev`, which runs `pnpm -r run dev`: one `dev` process for every workspace member that\n * has the script, enumerated ONCE, when the stack starts. A member added later never gets one. The members that arrive\n * that way are real and routine: `wildo registry add` installs a provider as `providers/<ref>/backend`, and `wildo compose`\n * adds a website, a documentation site, a minion or a worker. Measured on reference run 43876218697: a coding run\n * installed the Brevo provider at 16:41, its package was never compiled, and the backend, which depends on it, sat paused\n * on `dependency-output-not-ready` for the rest of the run. A person routes around it by restarting `wildo local dev`; an\n * unattended creation cannot.\n *\n * So the stack watches for a FINISHED INSTALL (a new member is usable only once its dependencies are), and starts the dev\n * script of every member with one that it has not started yet. A member that is also a declared SERVICE needs its `.env`\n * first: {@link decideRuntimeTopologyRegeneration} says when the declared topology changed, and the command rewrites\n * every runtime's env files BEFORE it starts the new members (#3985). The decision is pure and lives here; the spawning stays in\n * the command. A member that LEAVES is not stopped: its process exits on its own when its files go, and a restart of the\n * stack reads the workspace afresh.\n */\nimport { execFile } from 'node:child_process';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { join, normalize } from 'node:path';\nimport { promisify } from 'node:util';\n\nimport { loadSaasConfig } from '@wildo-ai/platform-config-lib';\nimport { LocalDevDependencyInstallPhase } from '@wildo-ai/platform-core-shared';\nimport { classifyDependencyInstall, readDependencyInstallRecord, readNodeModulesInstalledAtMs } from '@wildo-ai/platform-core-shared/dev-runtime';\n\nimport { expandWorkspaceMemberPatterns, readWorkspacePackagePatterns } from '~wildo-cli/services/application/application-dependency-alignment.service';\n\n/** A workspace member that runs a `dev` script, as `pnpm -r run dev` would start it. */\nexport interface WorkspaceDevMember {\n /** Its package name: what `pnpm --filter` selects. */\n readonly name: string;\n /** Its directory, application-relative. */\n readonly directory: string;\n}\n\n/**\n * Every workspace member (the root excluded) whose `package.json` declares a `dev` script: the set `pnpm -r run dev`\n * starts. A member whose manifest does not parse, or that has no name, is left out, as pnpm cannot select it either.\n */\nexport function listWorkspaceDevMembers(appRoot: string): WorkspaceDevMember[] {\n const { members } = expandWorkspaceMemberPatterns(appRoot, readWorkspacePackagePatterns(join(appRoot, 'pnpm-workspace.yaml')));\n const found: WorkspaceDevMember[] = [];\n for (const directory of members) {\n if (directory === '.') continue;\n const manifestPath = join(appRoot, directory, 'package.json');\n if (!existsSync(manifestPath)) continue;\n try {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { readonly name?: unknown; readonly scripts?: Record<string, unknown> };\n if (typeof manifest.name === 'string' && manifest.name.length > 0 && typeof manifest.scripts?.dev === 'string') {\n found.push({ name: manifest.name, directory });\n }\n } catch {\n // An unreadable manifest is one pnpm cannot run either.\n }\n }\n return found;\n}\n\n/** What the stack knows between two looks: the members it runs, and the install it last acted on. */\nexport interface LateWorkspaceMemberState {\n readonly started: ReadonlySet<string>;\n /** When pnpm last finished an install in the application, as last seen (`node_modules/.modules.yaml`). */\n readonly installedAtMs: number | null;\n}\n\n/**\n * The members to start now, and the state to keep. Pure but for the reads, which a test replaces.\n *\n * Nothing starts while an install is IN FLIGHT (the member's dependencies are not there yet), and nothing is looked for\n * until pnpm has finished an install since the last look: a member is added by an install, and listing the workspace on\n * every tick would read every manifest every few seconds for nothing.\n */\nexport function decideLateWorkspaceMembers(\n appRoot: string,\n state: LateWorkspaceMemberState,\n reads: {\n readonly installedAtMs: (root: string) => number | null;\n readonly installInFlight: (root: string) => boolean;\n readonly members: (root: string) => readonly WorkspaceDevMember[];\n } = DEFAULT_LATE_MEMBER_READS,\n): { readonly toStart: readonly WorkspaceDevMember[]; readonly state: LateWorkspaceMemberState } {\n if (reads.installInFlight(appRoot)) return { toStart: [], state };\n const installedAtMs = reads.installedAtMs(appRoot);\n if (installedAtMs === null || (state.installedAtMs !== null && installedAtMs <= state.installedAtMs)) return { toStart: [], state };\n const toStart = reads.members(appRoot).filter((member) => !state.started.has(member.name));\n return {\n toStart,\n state: { started: new Set([...state.started, ...toStart.map((member) => member.name)]), installedAtMs },\n };\n}\n\n/** Whether a dependency install is running in the application right now (the stack-event record, #3552). */\nexport function isDependencyInstallInFlight(appRoot: string): boolean {\n return classifyDependencyInstall(readDependencyInstallRecord(appRoot), Date.now()).phase === LocalDevDependencyInstallPhase.IN_FLIGHT;\n}\n\nconst DEFAULT_LATE_MEMBER_READS = {\n installedAtMs: readNodeModulesInstalledAtMs,\n installInFlight: isDependencyInstallInFlight,\n members: listWorkspaceDevMembers,\n} as const;\n\n/** The state at the stack's start: every member `pnpm -r run dev` is starting, and the install already on disk. */\nexport function initialLateWorkspaceMemberState(appRoot: string): LateWorkspaceMemberState {\n return {\n started: new Set(listWorkspaceDevMembers(appRoot).map((member) => member.name)),\n installedAtMs: readNodeModulesInstalledAtMs(appRoot),\n };\n}\n\n/** How often the stack looks for a finished install. */\nexport const LATE_WORKSPACE_MEMBER_POLL_MS = 5_000;\n\n/**\n * What the runtimes' env files are written from, out of a `wildo.saas.config.ts` (#3985): the WHOLE declaration. The\n * runtime topology is the case measured — services, minions and workers become `APPLICATION_RUNTIME_ENDPOINTS`, and on\n * reference run 43876218697 `add-website` declared a website at 14:51, the companion restarted at 16:52 and crash-looped on\n * `frontendServices.<x> is declared but runtime.endPoints.<x> is missing` until the run ended. But the env writer also\n * derives from providers, systems of record, data services and key management, so a hand-picked subset of fields would be\n * a second list of what the writer reads, the kind that rots. Any change to the declaration therefore owes a regeneration,\n * which is what restarting `wildo local dev` would do.\n *\n * A canonical string: keys sorted at every depth (an edit that only reorders is not a change), functions and cycles named\n * rather than followed. It sees what is enumerable: a `Map`, a `Set` or a value kept on non-enumerable properties (a Zod\n * schema) serialises without its contents, so a change held only there is not seen. A declaration is plain data today.\n */\nexport function declarationFingerprint(config: unknown): string {\n const seen = new WeakSet<object>();\n const canonical = (value: unknown): unknown => {\n if (typeof value === 'function') return '[function]';\n if (typeof value === 'bigint') return value.toString();\n if (value === null || typeof value !== 'object') return value;\n if (seen.has(value)) return '[circular]';\n seen.add(value);\n const result = Array.isArray(value)\n ? value.map(canonical)\n : Object.fromEntries(Object.keys(value as Record<string, unknown>).sort().map((key) => [key, canonical((value as Record<string, unknown>)[key])]));\n seen.delete(value);\n return result;\n };\n return JSON.stringify(canonical(config));\n}\n\n/** The declaration the runtimes' env files were last written from, and the config file's state when it was read. */\nexport interface DeclarationState {\n /** `null` when the starting read failed: the first declaration read later is then owed a regeneration. */\n readonly fingerprint: string | null;\n /** The config file's modification time at that read: an unchanged file is never re-read. */\n readonly configModifiedAtMs: number | null;\n}\n\n/** The reads the reconcile pass makes, replaceable by a test. */\nexport interface WorkspaceReconcileReads {\n readonly installInFlight: (root: string) => boolean;\n readonly configModifiedAtMs: (root: string) => number | null;\n readonly loadFingerprint: (root: string) => Promise<string | null>;\n readonly installedAtMs: (root: string) => number | null;\n readonly members: (root: string) => readonly WorkspaceDevMember[];\n readonly now: () => number;\n /**\n * The application-relative directories of the declared RUNTIMES (services, minions, workers): the members that read a\n * `.env` (#4019). `null` when the declaration cannot be read, and then every member is treated as one, as before.\n * Absent, likewise.\n */\n readonly runtimeDirectories?: (root: string) => Promise<ReadonlySet<string> | null>;\n /** Whether a member's compiled output exists: every file its package `exports` names (#4019). Absent: always ready. */\n readonly memberOutputReady?: (root: string, member: WorkspaceDevMember) => boolean;\n}\n\nconst SAAS_CONFIG_FILE = 'wildo.saas.config.ts';\n\n/** After a failed regeneration, how long before the next attempt. */\nexport const ENV_REGENERATION_RETRY_MS = 60_000;\n\n/**\n * How long a regeneration waits for a member started while it was owed to produce its compiled output (#4019). A provider\n * facet's first compile takes seconds; past this, the regeneration is attempted anyway and its failure is reported.\n */\nexport const LATE_MEMBER_OUTPUT_WAIT_MS = 5 * 60_000;\n\n/** An application-relative directory, as the workspace lists a member and the declaration a runtime (`./frontend` → `frontend`). */\nfunction applicationRelativeDirectory(path: string): string {\n return normalize(path).replace(/^\\.\\//u, '').replace(/\\/+$/u, '');\n}\n\n/** The declared runtimes' directories, from the declaration read fresh: services, minions and workers. */\nexport function declaredRuntimeDirectories(config: { readonly services?: Record<string, { readonly path: string }>; readonly minions?: Record<string, { readonly path: string }>; readonly workers?: Record<string, { readonly path: string }> }): ReadonlySet<string> {\n return new Set([config.services, config.minions, config.workers]\n .flatMap((owners) => Object.values(owners ?? {}))\n .map((owner) => applicationRelativeDirectory(owner.path)));\n}\n\n/**\n * Whether every file a member's package `exports` names exists: its compiled output, which a sync resolving the member's\n * declared runtime export reads (a provider facet's `./app` → `./dist/app.js`). The `source` condition is not output, and\n * a `require` target is a CommonJS build a dev watcher need not emit. A member with no readable manifest or no\n * file-shaped export has nothing to wait for.\n */\nexport function memberCompiledOutputExists(appRoot: string, member: WorkspaceDevMember): boolean {\n const memberRoot = join(appRoot, member.directory);\n let exportsField: unknown;\n try {\n exportsField = (JSON.parse(readFileSync(join(memberRoot, 'package.json'), 'utf8')) as { readonly exports?: unknown }).exports;\n } catch {\n return true;\n }\n const targets: string[] = [];\n const collect = (value: unknown, condition?: string): void => {\n if (typeof value === 'string') {\n if (condition !== 'source' && condition !== 'require' && value.startsWith('./') && !value.includes('*')) targets.push(value);\n } else if (Array.isArray(value)) {\n for (const entry of value) collect(entry, condition);\n } else if (value !== null && typeof value === 'object') {\n for (const [key, entry] of Object.entries(value)) collect(entry, key.startsWith('.') ? condition : key);\n }\n };\n collect(exportsField);\n return targets.every((target) => existsSync(join(memberRoot, target)));\n}\n\nexport const DEFAULT_WORKSPACE_RECONCILE_READS: WorkspaceReconcileReads = {\n installInFlight: isDependencyInstallInFlight,\n configModifiedAtMs: (root) => {\n try {\n return statSync(join(root, SAAS_CONFIG_FILE)).mtimeMs;\n } catch {\n return null;\n }\n },\n // Fresh: jiti's module cache is process-wide, and this process would otherwise read the declaration it started with.\n loadFingerprint: async (root) => {\n const config = await loadSaasConfig(join(root, SAAS_CONFIG_FILE), { freshModuleCache: true });\n return config === null ? null : declarationFingerprint(config);\n },\n installedAtMs: readNodeModulesInstalledAtMs,\n members: listWorkspaceDevMembers,\n now: () => Date.now(),\n runtimeDirectories: async (root) => {\n try {\n const config = await loadSaasConfig(join(root, SAAS_CONFIG_FILE), { freshModuleCache: true });\n return config === null ? null : declaredRuntimeDirectories(config);\n } catch {\n return null;\n }\n },\n memberOutputReady: memberCompiledOutputExists,\n};\n\n/**\n * One reconcile of the running stack with the workspace and the declaration (#3985, #3986), as `wildo local dev` runs it\n * every few seconds. Single-flight; nothing at all while an install runs. In ORDER, because a member that is also a\n * declared service needs a `.env` that knows it:\n *\n * 1. The declaration: when the config file changed and its fingerprint differs from what the env files were written from\n * (or that is unknown), the env files are OWED, and `regenerate` (the startup bootstrap) runs. A failure keeps them\n * owed and retries after {@link ENV_REGENERATION_RETRY_MS}. A declaration that does not load (an edit in progress)\n * owes nothing yet and is read again on the next change.\n * 2. The members. Each member a finished install brought gets its dev process, once. A member that is a declared\n * RUNTIME (a service, a minion, a worker) reads a `.env`, so it starts only once no regeneration is owed. Any other\n * member (a provider facet, a library) reads none and starts at once, even while one is owed (#4019).\n * 3. A regeneration owed while such a member compiles WAITS for its output, up to {@link LATE_MEMBER_OUTPUT_WAIT_MS},\n * and is attempted the moment the output exists rather than on the next retry.\n *\n * Why 2 and 3 (#4019): the regeneration resolves every frontend provider entry a scope binds, and an installed module's\n * browser facet resolves only once compiled. On reference run 44052185141 the PostHog facet joined at 11:00 and the\n * regeneration failed on \"cannot resolve declared runtime export …/provider-posthog-frontend/app\" 85 times, while it\n * held back the very dev process that would have compiled the facet: until #4019, every member waited for a successful\n * regeneration, which was the trade #3986 accepted and recorded. A member reading no `.env` never needed to wait.\n */\nexport function createWorkspaceReconciler(input: {\n readonly appRoot: string;\n /** Whether the env files can be regenerated at all (startup regenerates only with a framework path). */\n readonly canRegenerate: boolean;\n readonly regenerate: () => Promise<void>;\n readonly startMember: (member: WorkspaceDevMember) => void;\n readonly isStopping: () => boolean;\n readonly reportRegenerationFailure: (error: unknown) => void;\n readonly initial: { readonly declaration: DeclarationState; readonly members: LateWorkspaceMemberState };\n readonly reads?: WorkspaceReconcileReads;\n}): { readonly reconcile: () => Promise<void>; readonly regenerationOwed: () => boolean } {\n const reads = input.reads ?? DEFAULT_WORKSPACE_RECONCILE_READS;\n let declaration = input.initial.declaration;\n let members = input.initial.members;\n let owed: string | null = null; // the fingerprint whose env files are owed\n let retryAtMs = 0;\n let running = false;\n /** Members that read a `.env`, held until no regeneration is owed. */\n let deferred: WorkspaceDevMember[] = [];\n /** Members started without waiting for the env files, whose compiled output a regeneration waits for, by start time. */\n const awaitingOutput = new Map<string, { readonly member: WorkspaceDevMember; readonly startedAtMs: number }>();\n const startNow = (member: WorkspaceDevMember): void => {\n input.startMember(member);\n awaitingOutput.set(member.name, { member, startedAtMs: reads.now() });\n };\n const reconcile = async (): Promise<void> => {\n if (running || input.isStopping() || reads.installInFlight(input.appRoot)) return;\n running = true;\n try {\n if (input.canRegenerate) {\n const modifiedAtMs = reads.configModifiedAtMs(input.appRoot);\n if (modifiedAtMs !== null && modifiedAtMs !== declaration.configModifiedAtMs) {\n let fingerprint: string | null = null;\n try {\n fingerprint = await reads.loadFingerprint(input.appRoot);\n } catch {\n fingerprint = null;\n }\n if (fingerprint !== null) {\n if (fingerprint !== declaration.fingerprint) owed = fingerprint;\n declaration = { fingerprint, configModifiedAtMs: modifiedAtMs };\n }\n }\n }\n // The members a finished install brought. One that reads no `.env` starts at once; one that does waits for the env.\n const decision = decideLateWorkspaceMembers(input.appRoot, members, reads);\n members = decision.state;\n if (decision.toStart.length > 0) {\n const runtimeDirectories = input.canRegenerate ? await readRuntimeDirectories(reads, input.appRoot) : null;\n for (const member of decision.toStart) {\n if (runtimeDirectories !== null && !runtimeDirectories.has(applicationRelativeDirectory(member.directory))) startNow(member);\n else deferred.push(member);\n }\n }\n if (input.canRegenerate) {\n // Wait for what a member started without the env files compiles; the moment it is there, try at once.\n if (awaitingOutput.size > 0) {\n for (const [name, { member, startedAtMs }] of awaitingOutput) {\n if ((reads.memberOutputReady?.(input.appRoot, member) ?? true) || reads.now() - startedAtMs >= LATE_MEMBER_OUTPUT_WAIT_MS) awaitingOutput.delete(name);\n }\n if (awaitingOutput.size === 0) retryAtMs = 0;\n }\n if (owed !== null && awaitingOutput.size === 0 && reads.now() >= retryAtMs) {\n try {\n await input.regenerate();\n owed = null;\n } catch (error) {\n retryAtMs = reads.now() + ENV_REGENERATION_RETRY_MS;\n input.reportRegenerationFailure(error);\n }\n }\n // The env files first: a member started now would read a `.env` that may not know it.\n if (owed !== null || input.isStopping()) return;\n }\n const ready = deferred;\n deferred = [];\n for (const member of ready) input.startMember(member);\n } finally {\n running = false;\n }\n };\n return { reconcile, regenerationOwed: () => owed !== null };\n}\n\n/** The declared runtimes' directories, or `null` (every member then waits for the env files) when they cannot be read. */\nasync function readRuntimeDirectories(reads: WorkspaceReconcileReads, appRoot: string): Promise<ReadonlySet<string> | null> {\n if (reads.runtimeDirectories === undefined) return null;\n try {\n return await reads.runtimeDirectories(appRoot);\n } catch {\n return null;\n }\n}\n\n/** The declaration the stack started from: what its env files were written from moments ago. */\nexport async function initialDeclarationState(appRoot: string, reads: WorkspaceReconcileReads = DEFAULT_WORKSPACE_RECONCILE_READS): Promise<DeclarationState> {\n const configModifiedAtMs = reads.configModifiedAtMs(appRoot);\n try {\n const fingerprint = await reads.loadFingerprint(appRoot);\n return fingerprint === null ? { fingerprint: null, configModifiedAtMs: null } : { fingerprint, configModifiedAtMs };\n } catch {\n // Unknown: the first declaration read later is owed a regeneration rather than taken as the baseline.\n return { fingerprint: null, configModifiedAtMs: null };\n }\n}\n\n/** Bound on the provider-artifact sync: it reads configuration and writes generated files, and must not hold the reconcile. */\nconst PROVIDER_ARTIFACT_SYNC_TIMEOUT_MS = 5 * 60 * 1000;\n\n/**\n * Regenerate the application's provider runtime artifacts after a declaration change (#3985), as `wildo config sync\n * --domain config` writes them: the per-runtime provider lists, the generated provider modules, the CSP.\n *\n * The env files are not the only thing a declaration change leaves behind. Measured on reference run 43937787170: the\n * foundation declared `email-preview` and `stripe` at 20:31, the backend's provider artifact still listed none (written by\n * `wildo init` at 19:23), and the backend refused six times with \"Required engine capabilities resolve no active provider:\n * [BILLING, EMAIL_TRANSACTIONAL]\" and paused, with the build about to start. The same class as Wonder Procurement's on\n * 2026-10-07 (`findProviderRuntimeArtifactsBehindDeclaration`), which a restart repairs and a running stack never did.\n *\n * Run as a CHILD of this CLI: in this long-lived process the configuration loader's module cache still holds the\n * declaration the stack started with, and a sync reading it would regenerate the very artifacts that are behind. Rejects\n * when the child fails, so the reconcile keeps the regeneration owed and retries.\n */\nexport async function syncProviderRuntimeArtifactsInChild(\n saasRoot: string,\n envName: string,\n run: (file: string, args: readonly string[], options: { cwd: string; timeout: number }) => Promise<unknown> = defaultRunChild,\n): Promise<void> {\n const cliEntry = process.argv[1];\n if (cliEntry === undefined) throw new Error('The wildo CLI entry point is unknown, so the provider artifacts cannot be regenerated.');\n await run(process.execPath, [cliEntry, 'config', 'sync', '--domain', 'config', '--env', envName, '--non-interactive'], {\n cwd: saasRoot,\n timeout: PROVIDER_ARTIFACT_SYNC_TIMEOUT_MS,\n });\n}\n\nconst defaultRunChild = (file: string, args: readonly string[], options: { cwd: string; timeout: number }): Promise<unknown> =>\n promisify(execFile)(file, [...args], { ...options, maxBuffer: 16 * 1024 * 1024 });\n"]}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* keeps the runtime artifacts written by `local up` byte-identical to the
|
|
10
10
|
* ones `wildo config sync --domain manifest` would produce later.
|
|
11
11
|
*/
|
|
12
|
-
import { type WildoInfraEnvConfig } from '@wildo-ai/platform-config-lib';
|
|
12
|
+
import { type LoadConfigOptions, type WildoInfraEnvConfig } from '@wildo-ai/platform-config-lib';
|
|
13
13
|
import type { PlatformEnvConfigJson } from '../../services/credentials/credentials.schemas';
|
|
14
14
|
export interface LoadedAuthoredInfraEnvConfig {
|
|
15
15
|
path: string;
|
|
@@ -20,9 +20,10 @@ export declare function resolveAuthoredInfraConfigPath(saasRoot: string, envName
|
|
|
20
20
|
/**
|
|
21
21
|
* The shared loader (`loadInfraEnvConfig` in platform-config-lib), kept under the CLI's historical name and argument
|
|
22
22
|
* order so its importers and the test that mocks this module are unchanged. The dev companion reads the same file
|
|
23
|
-
* through the shared loader.
|
|
23
|
+
* through the shared loader. `options` is the shared loader's (fresh evaluation, module resolution); omitted, the
|
|
24
|
+
* file is evaluated once per process and the loader infers its resolution.
|
|
24
25
|
*/
|
|
25
|
-
export declare function loadAuthoredInfraEnvConfig(envName: string, saasRoot: string): Promise<LoadedAuthoredInfraEnvConfig | null>;
|
|
26
|
+
export declare function loadAuthoredInfraEnvConfig(envName: string, saasRoot: string, options?: Pick<LoadConfigOptions, 'freshModuleCache' | 'moduleResolution'>): Promise<LoadedAuthoredInfraEnvConfig | null>;
|
|
26
27
|
/**
|
|
27
28
|
* Whether the platform a HOST application owns runs a message broker, from its authored `local` descriptor (#2303
|
|
28
29
|
* slice D): `environmentServiceProfileRunsMessageBroker` of its `serviceProfile`. Read by `wildo init` before scaffolding
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authored-infra-config.utils.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"authored-infra-config.utils.d.ts","sourceRoot":"","sources":["../../../../src/services/environment/authored-infra-config.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAGL,KAAK,iBAAiB,EAMtB,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAMjG,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED,uHAAuH;AACvH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAExF;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,kBAAkB,GAAG,kBAAkB,CAAC,GACzE,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CAE9C;AAED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ot, envName) {
|
|
|
19
19
|
/**
|
|
20
20
|
* The shared loader (`loadInfraEnvConfig` in platform-config-lib), kept under the CLI's historical name and argument
|
|
21
21
|
* order so its importers and the test that mocks this module are unchanged. The dev companion reads the same file
|
|
22
|
-
* through the shared loader.
|
|
22
|
+
* through the shared loader. `options` is the shared loader's (fresh evaluation, module resolution); omitted, the
|
|
23
|
+
* file is evaluated once per process and the loader infers its resolution.
|
|
23
24
|
*/
|
|
24
|
-
export async function loadAuthoredInfraEnvConfig(envName, saasRoot) {
|
|
25
|
-
return loadInfraEnvConfig(saasRoot, envName);
|
|
25
|
+
export async function loadAuthoredInfraEnvConfig(envName, saasRoot, options) {
|
|
26
|
+
return loadInfraEnvConfig(saasRoot, envName, options);
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Whether the platform a HOST application owns runs a message broker, from its authored `local` descriptor (#2303
|