@wildo-ai/platform-config-lib 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/esm/bootstrap/bootstrap.schemas.d.ts +12 -5
  2. package/dist/esm/bootstrap/bootstrap.schemas.d.ts.map +1 -1
  3. package/dist/esm/bootstrap/bootstrap.schemas.js +21 -5
  4. package/dist/esm/bootstrap/bootstrap.schemas.js.map +1 -1
  5. package/dist/esm/index.d.ts +1 -0
  6. package/dist/esm/index.d.ts.map +1 -1
  7. package/dist/esm/index.js +1 -0
  8. package/dist/esm/index.js.map +1 -1
  9. package/dist/esm/lockfile/file-lock-hold.d.ts +87 -0
  10. package/dist/esm/lockfile/file-lock-hold.d.ts.map +1 -0
  11. package/dist/esm/lockfile/file-lock-hold.js +279 -0
  12. package/dist/esm/lockfile/file-lock-hold.js.map +1 -0
  13. package/dist/esm/lockfile/lockfile-io.d.ts +21 -3
  14. package/dist/esm/lockfile/lockfile-io.d.ts.map +1 -1
  15. package/dist/esm/lockfile/lockfile-io.js +8 -16
  16. package/dist/esm/lockfile/lockfile-io.js.map +1 -1
  17. package/dist/esm/project-config/loader.d.ts +16 -1
  18. package/dist/esm/project-config/loader.d.ts.map +1 -1
  19. package/dist/esm/project-config/loader.js +35 -1
  20. package/dist/esm/project-config/loader.js.map +1 -1
  21. package/dist/esm/project-config/provider-companion-discovery.d.ts.map +1 -1
  22. package/dist/esm/project-config/provider-companion-discovery.js +1 -0
  23. package/dist/esm/project-config/provider-companion-discovery.js.map +1 -1
  24. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts +13 -0
  25. package/dist/esm/project-config/shared/infra-providers.schemas.d.ts.map +1 -1
  26. package/dist/esm/project-config/shared/infra-providers.schemas.js.map +1 -1
  27. package/dist/tsconfig.build.tsbuildinfo +1 -1
  28. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"provider-companion-discovery.js","sourceRo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resolve } from 'node:path';\nimport {\n BUILTIN_PROVIDER_PROTOCOL,\n SYSTEM_OF_RECORD_FACET_MODULE_NOT_DISCOVERED,\n ProviderAugmentationContributionSchema,\n ProviderCompanionContributionSchema,\n type ProviderAugmentationContribution,\n type ProviderCompanionContribution,\n type ProviderComplianceProfile,\n type ProviderCompanionRuntimeTarget,\n type RuntimeOwnerCompanionExports, describeCaughtError,\n findProviderSharedConnectionConflicts } from '@wildo-ai/saas-models';\nimport { providerOAuth2TokenEndpointHostsIntersect } from '@wildo-ai/external-connectors-models';\nimport { satisfiesNpmVersionRange } from './npm-version-range';\nimport type { WildoSaasConfig } from './define-saas-config';\nimport { loadPackageCompanionExport, resolvePackageCompanionEntryPath } from './loader';\n\n/**\n * `providerPackage` was added by #330 and is the point of that slice on this file.\n *\n * The other four owner kinds are RUNTIME OWNERS declared in `wildo.saas.config.ts` — an application's\n * own services, libraries, minions and workers. Walking only those is what made a provider shipped as\n * its own npm package invisible to discovery (audit finding PL-1): the package is a DEPENDENCY, not a\n * runtime owner, so nothing ever asked it what it contributes, and an application had to hand-author a\n * contribution for a provider whose own package already knew everything about it.\n */\nexport enum ProviderContributionOwnerKind {\n /** A service package declared in `wildo.saas.config.ts` — the application's backend or a frontend. */\n SERVICE = 'service',\n /** A shared library package of the application. */\n LIBRARY = 'library',\n /** A minion runtime, keyed by its minion name. */\n MINION = 'minion',\n /** A Node worker runtime, keyed by its worker name. */\n WORKER = 'worker',\n /**\n * A provider shipped as its own npm package (#330) — a DEPENDENCY rather than a runtime owner,\n * which is why it needed its own walk and its own member. The value stays camelCase because it is\n * substituted into operator-facing diagnostics beside the four above.\n */\n PROVIDER_PACKAGE = 'providerPackage',\n}\n\n/**\n * Package-name prefixes whose dependencies are treated as provider packages.\n *\n * `@wildo-ai/provider-` is the framework convention (#337 D3), and the name a registry provider's facet packages\n * carry in `providers-registry/<ref>/` before an install renames them into the application's scope. An application's OWN provider packages\n * are admitted through the scope of its root manifest — an application published as `@acme/…` gets\n * `@acme/provider-…` for free — so a private provider needs no configuration to be discovered, and any other\n * dependency is never executed by this walk unless the application lists it in `providers.packages` (#1676).\n */\nexport const FRAMEWORK_PROVIDER_PACKAGE_PREFIX = '@wildo-ai/provider-';\n\n/**\n * The ENGINE's own provider barrel, admitted by exact NAME.\n *\n * The engine ships 23 providers and exports them through `./companion` — the same shape every\n * provider package uses. Discovery did not admit it, so an application that wanted `resend` declared\n * it THREE times: the scope, a hand-authored `provider-contributions.ts` projecting the engine's own\n * metadata back at it, and the package dependency. The middle one carried no information the other\n * two lacked; config sync refused a scoped-but-uncontributed provider, so it was not optional either\n * (#358).\n *\n * A NAME rather than a loosened prefix (`@wildo-ai/provider`, no hyphen, or `@wildo-ai/external-connectors-`): this\n * is one known package, not a family, and a prefix wide enough to reach it would also admit whatever else is later\n * published under it.\n *\n * Until #2019 the transposed provider catalogue was admitted by exact name beside this one — ONE package with a subpath\n * per vendor, whose name did not start with `@wildo-ai/provider-` (the `s` is not a `-`). It is archived; a provider\n * the framework distributes now lives in `providers-registry/<ref>/` and reaches an application as its own copy, a\n * `<scope>/provider-<ref>` package the scope prefix admits.\n */\nexport const FRAMEWORK_ENGINE_PROVIDER_PACKAGE = '@wildo-ai/external-connectors-private';\n\n/**\n * The framework's SYSTEM-OF-RECORD library (#2013): the vendor facets — Odoo, SAP S/4HANA, Dataverse, Business\n * Central, NetSuite, Salesforce, generic OData — as an opt-in package, admitted by exact NAME like the engine barrel above.\n *\n * The facets used to ride inside the provider catalogue, and discovery found them only because the catalogue was\n * admitted by name. Moving them out without this line would have dropped Odoo's facet from the provider-runtime\n * artifact, and the backend refuses a declared instance whose vendor has no facet (`VENDOR_HAS_NO_FACET`).\n *\n * It is also the ONLY package whose `./systems-of-record` module is recorded without an instance asking for it —\n * see {@link isAdmittedSystemOfRecordFacetModule}.\n */\nexport const FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE = '@wildo-ai/systems-of-record';\n\n/**\n * What discovery found for one package the application LISTS in `providers.packages` (#1676). Only\n * {@link ProviderPackageListingStatus.ADMITTED} is acceptable: every other status is a `wildo config sync` refusal\n * naming the package, because a listing is an explicit decision and a listing that admits nothing is a mistake the\n * author believes is working.\n */\nexport enum ProviderPackageListingStatus {\n /** Walked, and it ships a provider contribution, an augmentation or a `./systems-of-record` module. */\n ADMITTED = 'admitted',\n /** Neither the application root nor any runtime owner depends on it, so nothing could install or import it. */\n NOT_A_DEPENDENCY = 'not-a-dependency',\n /** Declared as a dependency but not found under `node_modules` — run the package manager's install. */\n NOT_INSTALLED = 'not-installed',\n /** Its `./companion` door exists and could not be read; the reason is carried. */\n UNREADABLE = 'unreadable',\n /** Walked, and it ships nothing discovery reads: no provider contribution, no augmentation, no facet module. */\n CONTRIBUTES_NOTHING = 'contributes-nothing',\n /**\n * A name discovery walks by itself (`@wildo-ai/provider-*`, the engine barrel, the systems-of-record library, the\n * application's own scope named `<scope>/provider-*`). Refused rather than recorded: the listing changes nothing, and recording it would put framework code in\n * the lock as a third-party admission.\n */\n ALREADY_WALKED = 'already-walked',\n /** One of the application's own runtime packages — walked as a runtime owner, never as a provider package. */\n RUNTIME_OWNER = 'runtime-owner',\n}\n\n/** One listed package, as discovery found it (#1676). */\nexport interface ListedProviderPackage {\n readonly packageName: string;\n readonly status: ProviderPackageListingStatus;\n /** The version its installed manifest states, when it was installed. */\n readonly packageVersion?: string;\n /** Why it could not be read ({@link ProviderPackageListingStatus.UNREADABLE}). */\n readonly reason?: string;\n}\n\n/** A listed package discovery admitted (#1676) — what `config sync` prints and the provider lock records. */\nexport interface AdmittedProviderPackage {\n readonly packageName: string;\n /** Absent only when its manifest states no version. */\n readonly packageVersion?: string;\n}\n\ninterface ProviderContributionOwner {\n kind: ProviderContributionOwnerKind;\n key: string;\n packageRoot: string;\n}\n\ninterface ProviderContributionTarget extends ProviderContributionOwner {\n ownerLabel: string;\n}\n\nexport interface DiscoveredProviderCompanionContribution extends ProviderCompanionContribution {\n owner: ProviderContributionOwner;\n}\n\n/**\n * A package's declaration that it adds operations to a provider it does not own (#1672), as discovery\n * found it: the companion record plus WHO declared it and at WHICH installed version.\n *\n * Kept apart from {@link DiscoveredProviderCompanionContribution} for the reason\n * `ProviderAugmentationContributionSchema` gives: an augmentation owns nothing a contribution describes, so\n * counting it as a second contribution of the base ref would make the secrets-shape comparison treat it as a\n * second owner and let the import map pick between the two by sort order.\n *\n * `packageVersion` is the version the owner's own manifest states, read at discovery. It is what the\n * `PROVIDER_OPERATION_CALL` audit row names beside the package, so it must be the INSTALLED version rather\n * than anything the package claims about itself; absent only when the manifest states none, which\n * validation refuses for an opted-in augmentation.\n */\nexport interface DiscoveredProviderAugmentation extends ProviderAugmentationContribution {\n owner: ProviderContributionOwner;\n packageVersion?: string;\n}\n\n/**\n * An owner that DECLARES a `./companion` door and could not be read through it.\n *\n * Distinct from an owner that declares none, which is the ordinary case for most packages and is not\n * reported: the walk asks every candidate and expects most to answer nothing.\n */\nexport interface UnreadableProviderCompanionOwner {\n readonly ownerLabel: string;\n readonly packageRoot: string;\n readonly reason: string;\n}\n\nexport interface DiscoverSaasProviderCompanionContributionsResult {\n contributions: DiscoveredProviderCompanionContribution[];\n /**\n * Owners whose companion door exists and threw. EMPTY is the normal state.\n *\n * Reported because a walk that fails and a walk that finds nothing were previously the same\n * answer — both produced silence, and silence sums to a contribution COUNT (#1305). A count of\n * zero therefore read as a legitimate result rather than as a walk that failed, which is why\n * #1300 survived: a freshly scaffolded application reported 0 contributions and nothing\n * distinguished that from \"this application legitimately has no providers\".\n *\n * NOT a failure — `resolveProviderPackageTargets` argues correctly that a declared-but-uninstalled\n * package is an install problem `pnpm install` reports better than a config-sync stack trace. The\n * ask is visibility, so this is data a caller may render, not a refusal.\n */\n unreadableOwners: UnreadableProviderCompanionOwner[];\n /**\n * Every provider AUGMENTATION any walked package declares (#1672) — opted in or not. Discovery reports what\n * is INSTALLED; whether any of it applies is the application's `providers.augmentations`, which\n * {@link validateDiscoveredSaasProviderContributions} checks and {@link resolveValidatedSaasProviderContributions}\n * narrows to.\n */\n augmentations: DiscoveredProviderAugmentation[];\n /**\n * Every ADMITTED system-of-record facet module the walked packages declare (#1057, #1675, #2013):\n * `<package>/systems-of-record` for each walked package root whose manifest exports `./systems-of-record` AND\n * which is either the framework library ({@link FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE}) or a package an instance\n * names in `facetAugmentations` — see `isAdmittedSystemOfRecordFacetModule`. Sorted.\n *\n * Read from the walk's TARGETS — every package root it visited — not from its contribution RESULTS. A\n * package that ships facets or facet augmentations and NO provider contribution has no contribution to be\n * found through, and #1675's augmentation package (a partition declaration for a vendor someone else owns)\n * is exactly that package. Read from the MANIFEST, never by loading the module.\n */\n systemOfRecordFacetModules: string[];\n /**\n * Every package `providers.packages` lists (#1676), with what discovery found for it, in listing order. Empty when\n * the application lists none. Validation refuses every entry that is not\n * {@link ProviderPackageListingStatus.ADMITTED}.\n */\n listedProviderPackages: ListedProviderPackage[];\n}\n\n/**\n * The walk's validated answer: the contributions, and the augmentations the application OPTED IN (#1672).\n *\n * One object rather than the contribution array alone because both feed the same generated artifacts and the\n * same lock section, and a caller that received only the contributions would materialize an artifact that\n * silently omits every opted-in augmentation — the one-of-N call-site shape\n * `.claude/rules/invariant-call-site-enumeration.md` records.\n */\nexport interface ValidatedSaasProviderDiscovery {\n contributions: DiscoveredProviderCompanionContribution[];\n /** Only the augmentations `providers.augmentations` names — never merely installed ones. */\n augmentations: DiscoveredProviderAugmentation[];\n /** The facet modules the walk found — see {@link DiscoverSaasProviderCompanionContributionsResult.systemOfRecordFacetModules}. */\n systemOfRecordFacetModules: string[];\n /**\n * The packages `providers.packages` admitted (#1676), sorted by name — validation has already refused every listed\n * package discovery could not admit. Printed by `config sync` and recorded in the provider lock.\n */\n admittedProviderPackages: AdmittedProviderPackage[];\n /**\n * Facts `wildo config sync` REPORTS without refusing (#1725): a shared-connection member whose own OAuth2\n * client becomes inert, a vendor label that differs from its base's, a comparison that could not be made\n * from static declarations. Printed by the caller; never a reason to stop.\n */\n advisories: string[];\n}\n\n/**\n * The runtime targets an application's SCOPES imply for one provider ref.\n *\n * ## Why a package's declared targets cannot be the answer\n *\n * A provider PACKAGE is shipped once and installed by many applications, so it cannot know any of\n * their runtime topologies. Measured 2026-09-09: all 682 catalogue vendors declare\n * `[{ kind: 'backend' }]` and every engine contribution declares `backend` (plus `companion` for the\n * model-ish ones). Those are defaults standing in for an answer the package is not able to give —\n * a minion key or a worker key exists only in `wildo.saas.config.ts`.\n *\n * The consequence was latent rather than theoretical: a CATALOGUE provider scoped to a minion would\n * have failed materialization with \"no discovered contribution supplies its secret-contract shape\n * for this runtime\", because the package declares a `backend` target and the minion scope looks for\n * a `minion` one. No application had scoped one to a minion yet, so nothing had reported it.\n *\n * ## Why the scopes ARE the answer\n *\n * `providers.scopes` is where an application says which runtimes reach which provider — it is the\n * same decision, already authored, in the place the runtime artifact is built from. Measured against\n * Wonder Todos' hand-authored projections: the scopes reproduce 9 of 10 target sets EXACTLY, and the\n * tenth is a SURPLUS (a `companion` target for a provider the companion scope does not name) which\n * the artifact discards anyway, since it is built from scope INTERSECT contribution.\n *\n * So nothing is lost by deriving, and what is gained is that an application declares a provider once.\n *\n * Applies to contributions discovered from a PACKAGE. A runtime owner's own companion barrel keeps\n * whatever it declares: that is the application's own file talking about itself, and an application\n * package is entitled to state a target the scopes do not.\n *\n * ## A browser target is declared, then filtered by the scopes (#1700)\n *\n * A package CAN know one thing about a browser target: a facet's `frontendService` target names a service TYPE (the\n * application, the website, the documentation site), which is the facet's own contract. So a package contribution\n * keeps a declared `frontendService` target wherever a frontend service of that type scopes the ref, and the server\n * scopes are consulted for the server runtimes only — and only for a contribution that declares one. Deriving both\n * halves from the server scopes dropped a facet's frontend target (so no frontend scope could ever find it) and\n * gave the facet a `backend` target whenever the vendor's backend part was scoped, where it collided with that\n * part's secret contract. See {@link resolvePackageContributionRuntimeTargets}.\n */\nfunction resolveScopeImpliedRuntimeTargets(\n providerRef: string,\n saasConfig: Pick<WildoSaasConfig, 'providers'>,\n): ProviderCompanionContribution['runtimeTargets'] {\n const scopes = saasConfig.providers?.scopes;\n if (!scopes) return [];\n const targets: ProviderCompanionContribution['runtimeTargets'] = [];\n\n if (scopes.backend?.providers?.[providerRef]) targets.push({ kind: 'backend' });\n if (scopes.companion?.providers?.[providerRef]) targets.push({ kind: 'companion' });\n for (const [minionKey, scope] of Object.entries(scopes.minions ?? {})) {\n if (scope?.providers?.[providerRef]) targets.push({ kind: 'minion', minionKey });\n }\n for (const [workerKey, scope] of Object.entries(scopes.workers ?? {})) {\n if (scope?.providers?.[providerRef]) targets.push({ kind: 'worker', workerKey });\n }\n return targets;\n}\n\n/**\n * A PACKAGE contribution's runtime targets: server targets derived from the application's scopes (and none when it\n * declares no server target at all), and a declared browser target kept only where the application actually scopes\n * the ref on a frontend service of that TYPE. See {@link resolveScopeImpliedRuntimeTargets}.\n *\n * The browser half is filtered for the same reason the server half is derived: an installed package speaks for every\n * application, and a target no scope asked for is not this application's. Keeping an unscoped facet's target made\n * validation refuse `wildo config sync` for any application that installed a provider package without a service of the\n * facet's type — a backend-only application, or one with no website for a website facet.\n */\nexport function resolvePackageContributionRuntimeTargets(\n contribution: Pick<ProviderCompanionContribution, 'ref' | 'runtimeTargets'>,\n saasConfig: Pick<WildoSaasConfig, 'providers' | 'services'>,\n): ProviderCompanionContribution['runtimeTargets'] {\n const declaresServerTarget = contribution.runtimeTargets.some((target) => target.kind !== 'frontendService');\n const scopedFrontendTypes = new Set(\n Object.entries(saasConfig.providers?.scopes?.frontendServices ?? {})\n .filter(([, scope]) => scope?.providers?.[contribution.ref] !== undefined)\n .map(([serviceKey]) => saasConfig.services?.[serviceKey]?.frontendType)\n .filter((frontendType) => frontendType !== undefined),\n );\n const scopedFrontendTargets = contribution.runtimeTargets.filter(\n (target) => target.kind === 'frontendService' && scopedFrontendTypes.has(target.serviceType),\n );\n return [\n ...(declaresServerTarget ? resolveScopeImpliedRuntimeTargets(contribution.ref, saasConfig) : []),\n ...scopedFrontendTargets,\n ];\n}\n\nexport async function discoverSaasProviderCompanionContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'> & Partial<Pick<WildoSaasConfig, 'systemsOfRecord'>>;\n}): Promise<DiscoverSaasProviderCompanionContributionsResult> {\n const contributions: DiscoveredProviderCompanionContribution[] = [];\n const optedInFacetPackages = systemOfRecordFacetAugmentationPackages(input.saasConfig.systemsOfRecord);\n\n const runtimeOwnerTargets = resolveContributionTargets(input.saasRoot, input.saasConfig);\n\n const unreadableOwners: UnreadableProviderCompanionOwner[] = [];\n const augmentations: DiscoveredProviderAugmentation[] = [];\n const systemOfRecordFacetModules = new Set<string>();\n const listedPackageNames = input.saasConfig.providers?.packages ?? [];\n const packageTargets = resolveProviderPackageTargets(\n input.saasRoot,\n // Unfiltered roots, NOT `runtimeOwnerTargets` — see `resolveRuntimeOwnerPackageRoots` (#1300).\n resolveRuntimeOwnerPackageRoots(input.saasRoot, input.saasConfig),\n listedPackageNames,\n );\n /** What each walked PACKAGE target shipped, by package name — the evidence a listing's status is read from. */\n const packageFindings = new Map<string, { shipsSomething: boolean; unreadable?: string }>();\n\n for (const target of [...runtimeOwnerTargets, ...packageTargets.targets]) {\n // Before the companion door is read, so a package with facets and no companion exports is still found. Read for\n // EVERY walked target — the runtime owners included — and recorded only when admitted (#2013).\n const facetModule = readSystemOfRecordFacetModuleSpecifier(target.packageRoot);\n if (facetModule !== undefined && isAdmittedSystemOfRecordFacetModule(facetModule, optedInFacetPackages)) {\n systemOfRecordFacetModules.add(facetModule);\n }\n const isPackage = target.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE;\n if (isPackage) packageFindings.set(target.key, { shipsSomething: facetModule !== undefined });\n\n const loaded = await tryLoadRuntimeOwnerCompanionExports(target.packageRoot);\n if (loaded.unreadable !== undefined) {\n unreadableOwners.push({\n ownerLabel: target.ownerLabel,\n packageRoot: target.packageRoot,\n reason: loaded.unreadable,\n });\n if (isPackage) packageFindings.set(target.key, { shipsSomething: facetModule !== undefined, unreadable: loaded.unreadable });\n continue;\n }\n if (!loaded.exports) {\n continue;\n }\n\n const parsedContributions = ProviderCompanionContributionSchema.array().parse(\n loaded.exports.providerContributions ?? [],\n );\n if (isPackage && (parsedContributions.length > 0 || (loaded.exports.providerAugmentations ?? []).length > 0)) {\n packageFindings.set(target.key, { shipsSomething: true });\n }\n const owner = { kind: target.kind, key: target.key, packageRoot: target.packageRoot };\n const ownerVersion = readPackageVersion(target.packageRoot);\n augmentations.push(\n ...ProviderAugmentationContributionSchema.array().parse(loaded.exports.providerAugmentations ?? [])\n .map((augmentation) => ({\n ...augmentation,\n owner,\n ...(ownerVersion === undefined ? {} : { packageVersion: ownerVersion }),\n })),\n );\n\n // A PACKAGE cannot know this application's runtime topology, so its declared targets are a\n // default and the SCOPES are the answer. A runtime owner's own barrel keeps what it declares —\n // see `resolveScopeImpliedRuntimeTargets`.\n const derivesTargetsFromScopes = target.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE;\n\n contributions.push(\n ...parsedContributions.map((contribution) => ({\n ...contribution,\n runtimeTargets: derivesTargetsFromScopes\n ? resolvePackageContributionRuntimeTargets(contribution, input.saasConfig)\n : contribution.runtimeTargets,\n owner: {\n kind: target.kind,\n key: target.key,\n packageRoot: target.packageRoot,\n },\n })),\n );\n }\n\n return {\n contributions,\n unreadableOwners,\n augmentations,\n systemOfRecordFacetModules: [...systemOfRecordFacetModules].sort(),\n listedProviderPackages: listedPackageNames.map((packageName) => describeListedProviderPackage(packageName, packageTargets, packageFindings)),\n };\n}\n\n/** What discovery found for one listed package (#1676) — see {@link ProviderPackageListingStatus}. */\nfunction describeListedProviderPackage(\n packageName: string,\n packageTargets: ProviderPackageTargets,\n packageFindings: ReadonlyMap<string, { shipsSomething: boolean; unreadable?: string }>,\n): ListedProviderPackage {\n if (packageTargets.ownPackageNames.has(packageName)) return { packageName, status: ProviderPackageListingStatus.RUNTIME_OWNER };\n if (packageTargets.admittedByName(packageName)) return { packageName, status: ProviderPackageListingStatus.ALREADY_WALKED };\n if (!packageTargets.dependencyNames.has(packageName)) return { packageName, status: ProviderPackageListingStatus.NOT_A_DEPENDENCY };\n const target = packageTargets.targets.find((candidate) => candidate.key === packageName);\n if (target === undefined) return { packageName, status: ProviderPackageListingStatus.NOT_INSTALLED };\n const version = readPackageVersion(target.packageRoot);\n const versioned = version === undefined ? {} : { packageVersion: version };\n const finding = packageFindings.get(packageName);\n if (finding?.unreadable !== undefined) return { packageName, status: ProviderPackageListingStatus.UNREADABLE, reason: finding.unreadable, ...versioned };\n if (finding?.shipsSomething !== true) return { packageName, status: ProviderPackageListingStatus.CONTRIBUTES_NOTHING, ...versioned };\n return { packageName, status: ProviderPackageListingStatus.ADMITTED, ...versioned };\n}\n\n/**\n * The export a package declares to contribute system-of-record vendor facets or facet augmentations. The manifest\n * key of saas-models' `SYSTEM_OF_RECORD_FACET_MODULE_SUBPATH`, restated rather than imported so manifest discovery\n * does not load the external-data model graph to read one string; a test holds the two equal (#1675).\n */\nconst SYSTEM_OF_RECORD_FACET_SUBPATH = './systems-of-record';\n\n/**\n * Every package an instance opts into through `systemsOfRecord.<name>.facetAugmentations` — the application's OWN\n * augmentation packages, and the only ones besides {@link FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE} whose facet module\n * discovery records.\n */\nfunction systemOfRecordFacetAugmentationPackages(systemsOfRecord: WildoSaasConfig['systemsOfRecord'] | undefined): ReadonlySet<string> {\n const packages = new Set<string>();\n for (const declaration of Object.values(systemsOfRecord ?? {})) {\n for (const packageName of declaration?.facetAugmentations ?? []) packages.add(packageName);\n }\n return packages;\n}\n\n/**\n * Whether a walked package's `./systems-of-record` module may reach the provider-runtime artifact (#2013).\n *\n * A facet module is where a system of record's partition, credential kinds and dialect come from, so the modules\n * recorded decide how a tenant's rows are confined — and every one of them is IMPORTED by the backend at boot. Two\n * sources qualify, and nothing else:\n *\n * - the framework library, by its exact name — the base facets every declared instance reads;\n * - a package an instance of THIS application names in `facetAugmentations` — the application's own augmentation\n * packages. The opt-in is the admission: the package still has to be walked (named `<scope>/provider-*`, or listed\n * in `providers.packages`), and a named package discovery did not record is refused by\n * `describeUndiscoveredFacetAugmentationPackages`.\n *\n * Before #2013 any walked package exporting the subpath was recorded: the catalogue (which carried the facets), any\n * `@wildo-ai/provider-*` package, the application's own `<scope>/provider-*` copies, its runtime owners. With the\n * facets in their own library, that breadth only let a package the application never asked for present a BASE facet\n * — and a second base facet for a vendor refuses every instance of it (`FACET_BASE_CONFLICT`). Registry providers\n * copied into an application must never carry system-of-record content (#2012), so they are not admitted either.\n *\n * assurance-control: WILDO.SECURITY.FAIL_CLOSED — a facet module reaches the backend only from the framework library\n * or from a package the application's own system-of-record declaration names.\n */\nfunction isAdmittedSystemOfRecordFacetModule(facetModule: string, optedInFacetPackages: ReadonlySet<string>): boolean {\n const packageName = facetModule.slice(0, -SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1).length);\n return packageName === FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE || optedInFacetPackages.has(packageName);\n}\n\n/**\n * The facet module a package root declares — `<name>/systems-of-record` — or `undefined`. Read from the\n * MANIFEST, never by loading: a build-time consumer has no business evaluating a vendor facet to learn that\n * one exists, and loading would make discovery depend on the package compiling.\n */\nexport function readSystemOfRecordFacetModuleSpecifier(packageRoot: string): string | undefined {\n let manifest: { name?: unknown; exports?: Record<string, unknown> };\n try {\n manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf-8')) as typeof manifest;\n } catch {\n // Unreadable or absent: the companion walk already tolerates that, and a package we could not read is\n // not one we can say anything about.\n return undefined;\n }\n if (manifest.exports?.[SYSTEM_OF_RECORD_FACET_SUBPATH] === undefined) return undefined;\n if (typeof manifest.name !== 'string' || manifest.name.length === 0) return undefined;\n return `${manifest.name}${SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1)}`;\n}\n\n/**\n * Every discovered provider's COMPLIANCE PROFILE, keyed by ref (#1708) — the one door the compliance readers (the\n * evidence collector, the companion's drafting brief) learn profiles through, WITHOUT loading a provider module.\n *\n * A backend contribution's own `complianceProfile` is preferred; a frontend facet's `frontendEntry.complianceProfile`\n * (#1743) answers for a ref that has only a browser part. The first contribution that carries one wins, in discovery\n * order — the application's own runtime owners before packages — so an application shipping its own module for a\n * ref states that ref's facts. A ref whose contributions carry none is ABSENT from the map, which a reader reports as\n * \"declares no profile\", distinct from an UNDETERMINED one.\n */\nexport function providerComplianceProfilesFromContributions(\n contributions: readonly Pick<ProviderCompanionContribution, 'ref' | 'complianceProfile' | 'frontendEntry'>[],\n): Record<string, ProviderComplianceProfile> {\n const profiles: Record<string, ProviderComplianceProfile> = {};\n for (const contribution of contributions) {\n if (profiles[contribution.ref] === undefined && contribution.complianceProfile !== undefined) profiles[contribution.ref] = contribution.complianceProfile;\n }\n for (const contribution of contributions) {\n const frontendProfile = contribution.frontendEntry?.complianceProfile;\n if (profiles[contribution.ref] === undefined && frontendProfile !== undefined) profiles[contribution.ref] = frontendProfile;\n }\n return profiles;\n}\n\n/** See {@link providerComplianceProfilesFromContributions}. Discovery's unreadable owners are returned so a reader can say what it could not see. */\nexport async function resolveProviderComplianceProfiles(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<{ profilesByProviderRef: Record<string, ProviderComplianceProfile>; unreadableOwners: UnreadableProviderCompanionOwner[] }> {\n const { contributions, unreadableOwners } = await discoverSaasProviderCompanionContributions(input);\n return { profilesByProviderRef: providerComplianceProfilesFromContributions(contributions), unreadableOwners };\n}\n\n/**\n * Walk an application's provider contributions and VALIDATE them — one step, because the two must\n * never come apart (#334).\n *\n * The walk was already shared; what was duplicated is the PAIRING. `wildo config sync` and\n * `wildo lock check` each called the walker and then, separately, the validator — and the validator\n * sits outside the walker, so a consumer that forgot it would compute a lockfile section from\n * contributions nobody had checked against the authored scope. Three correct call sites with nothing\n * making a fourth correct is the shape `.claude/rules/invariant-call-site-enumeration.md` is about.\n *\n * The caller still LOADS the config. That is deliberate rather than an omission: loading is one line\n * each caller already owns with its own error handling, it is not the part that can silently come\n * apart, and folding it in here would put the load behind a seam that the sync service's own tests\n * mock — `loadSaasConfig` mocked as a module export is not seen by a caller INSIDE this module, so\n * those tests would have had to mock this function instead and would then no longer exercise the real\n * discovery and the real validation they exist to check.\n */\nexport async function resolveValidatedSaasProviderContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'services' | 'libraries' | 'minions' | 'providers' | 'workers' | 'systemsOfRecord'>;\n}): Promise<ValidatedSaasProviderDiscovery> {\n const { contributions, unreadableOwners, augmentations, systemOfRecordFacetModules, listedProviderPackages } = await discoverSaasProviderCompanionContributions(input);\n validateDiscoveredSaasProviderContributions({\n saasConfig: input.saasConfig,\n discoveredContributions: contributions,\n discoveredAugmentations: augmentations,\n unreadableOwners,\n listedProviderPackages,\n systemOfRecordFacetModules,\n });\n return {\n contributions,\n augmentations: selectOptedInProviderAugmentations(input.saasConfig, augmentations),\n systemOfRecordFacetModules,\n admittedProviderPackages: listedProviderPackages\n .filter((listed) => listed.status === ProviderPackageListingStatus.ADMITTED)\n .map(({ packageName, packageVersion }) => ({ packageName, ...(packageVersion === undefined ? {} : { packageVersion }) }))\n .sort((left, right) => left.packageName.localeCompare(right.packageName)),\n advisories: validateProviderSharedConnections({ saasConfig: input.saasConfig, discoveredContributions: contributions }).advisories,\n };\n}\n\n/**\n * The discovered augmentations the application names under `providers.augmentations` — the ONLY ones that may\n * reach an artifact (#1672). Installing a package decides nothing; this is where that sentence is enforced for\n * every caller, and {@link materializeSaasProviderRuntimeArtifacts} applies it again so an artifact can never be\n * built from an unfiltered list.\n *\n * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — third-party operations reach a provider's grant\n * only through the application's explicit, per-provider opt-in.\n */\nexport function selectOptedInProviderAugmentations(\n saasConfig: Pick<WildoSaasConfig, 'providers'>,\n augmentations: readonly DiscoveredProviderAugmentation[],\n): DiscoveredProviderAugmentation[] {\n const optIns = saasConfig.providers?.augmentations ?? {};\n return augmentations\n .filter((augmentation) => Object.hasOwn(optIns, augmentation.augments)\n && (optIns[augmentation.augments] ?? []).includes(augmentation.packageName))\n .sort((left, right) => left.augments.localeCompare(right.augments) || left.packageName.localeCompare(right.packageName));\n}\n\nexport function validateDiscoveredSaasProviderContributions(input: {\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services' | 'minions' | 'workers' | 'systemsOfRecord'>;\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n /**\n * The owners the walk could not read. They never decide the verdict — unreadable is DATA, not a\n * refusal (see `DiscoverSaasProviderCompanionContributionsResult.unreadableOwners`) — but when the\n * validation refuses anyway, they are usually WHY: their contributions are simply missing from what\n * was validated. So a refusal names them, with the reason each could not be read.\n */\n unreadableOwners?: readonly UnreadableProviderCompanionOwner[];\n /** Every augmentation the walk found (#1672); checked against `providers.augmentations`. Absent means none. */\n discoveredAugmentations?: readonly DiscoveredProviderAugmentation[];\n /** What discovery found for each package `providers.packages` lists (#1676). Absent means none were listed. */\n listedProviderPackages?: readonly ListedProviderPackage[];\n /**\n * The facet modules the walk recorded (#1675). When present, every package an instance names in\n * `systemsOfRecord.<name>.facetAugmentations` must be among them — the backend reads augmentations only from the\n * recorded modules, so an unrecorded one would refuse the boot; refusing here says so before anything starts.\n * Absent (a caller that did not run the walk) skips the check.\n */\n systemOfRecordFacetModules?: readonly string[];\n}): void {\n const { saasConfig, discoveredContributions } = input;\n const errors: string[] = [];\n errors.push(...describeRefusedProviderPackageListings(input.listedProviderPackages ?? []));\n if (input.systemOfRecordFacetModules !== undefined) {\n errors.push(...describeUndiscoveredSystemsOfRecordLibrary(saasConfig.systemsOfRecord ?? {}, input.systemOfRecordFacetModules));\n errors.push(...describeUndiscoveredFacetAugmentationPackages(saasConfig.systemsOfRecord ?? {}, input.systemOfRecordFacetModules));\n }\n const declaredModuleIds = new Set(Object.keys(saasConfig.modules ?? {}));\n const declaredServiceKeys = new Set(Object.keys(saasConfig.services ?? {}));\n const serviceKeyToFrontendType = new Map<string, string>(\n Object.entries(saasConfig.services ?? {})\n .filter(([, definition]) => definition.frontendType !== undefined)\n .map(([serviceKey, definition]) => [serviceKey, definition.frontendType as string]),\n );\n const declaredFrontendServiceKeys = new Set(serviceKeyToFrontendType.keys());\n const declaredFrontendTypes = new Set(serviceKeyToFrontendType.values());\n const declaredMinionKeys = new Set(Object.keys(saasConfig.minions ?? {}));\n const declaredWorkerKeys = new Set(Object.keys(saasConfig.workers ?? {}));\n\n for (const contribution of discoveredContributions) {\n if (contribution.sourceModuleId && !declaredModuleIds.has(contribution.sourceModuleId)) {\n errors.push(\n `${describeContribution(contribution)} references sourceModuleId \"${contribution.sourceModuleId}\" ` +\n 'but that module is not declared in wildo.saas.config.ts.',\n );\n }\n\n const dependencyNames = readRuntimeReachablePackageNames(contribution.owner.packageRoot);\n const runtimePackageName = extractPackageName(contribution.runtimeImportPath);\n if (!dependencyNames.has(runtimePackageName)) {\n errors.push(\n `${describeContribution(contribution)} declares runtimeImportPath \"${contribution.runtimeImportPath}\" ` +\n `but ${contribution.owner.kind} \"${contribution.owner.key}\" does not depend on \"${runtimePackageName}\".`,\n );\n }\n\n for (const target of contribution.runtimeTargets) {\n switch (target.kind) {\n case 'frontendService':\n if (!declaredFrontendTypes.has(target.serviceType)) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but no service with that frontendType is declared in wildo.saas.config.ts.',\n );\n } else if (!contribution.frontendEntry) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but does not provide a frontendEntry payload for bootstrap materialization.',\n );\n }\n break;\n case 'minion':\n if (!declaredMinionKeys.has(target.minionKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown minion \"${target.minionKey}\".`,\n );\n }\n break;\n case 'worker':\n if (!declaredWorkerKeys.has(target.workerKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown worker \"${target.workerKey}\".`,\n );\n }\n break;\n case 'backend':\n case 'companion':\n break;\n }\n }\n }\n\n const runtimeScopes = saasConfig.providers.scopes;\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'backend',\n providers: runtimeScopes.backend?.providers ?? {},\n matchesTarget: (target) => target.kind === 'backend',\n });\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'companion',\n providers: runtimeScopes.companion?.providers ?? {},\n matchesTarget: (target) => target.kind === 'companion',\n });\n\n for (const [serviceKey, scope] of Object.entries(runtimeScopes.frontendServices ?? {})) {\n if (!declaredServiceKeys.has(serviceKey)) {\n errors.push(`Provider scope references unknown frontend service \"${serviceKey}\".`);\n continue;\n }\n if (!declaredFrontendServiceKeys.has(serviceKey)) {\n errors.push(\n `Provider scope references non-frontend service \"${serviceKey}\". ` +\n 'Only services with a frontendType may appear under providers.scopes.frontendServices.',\n );\n continue;\n }\n const serviceType = serviceKeyToFrontendType.get(serviceKey);\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `frontendServices.${serviceKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'frontendService' && target.serviceType === serviceType,\n });\n }\n\n for (const [minionKey, scope] of Object.entries(runtimeScopes.minions ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `minions.${minionKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'minion' && target.minionKey === minionKey,\n });\n }\n\n for (const [workerKey, scope] of Object.entries(runtimeScopes.workers ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `workers.${workerKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'worker' && target.workerKey === workerKey,\n });\n }\n\n validateProviderAugmentationOptIns({\n errors,\n saasConfig,\n discoveredContributions,\n discoveredAugmentations: input.discoveredAugmentations ?? [],\n });\n\n errors.push(...validateProviderSharedConnections({ saasConfig, discoveredContributions }).errors);\n\n if (errors.length > 0) {\n throw new Error(\n `Provider companion-export discovery validation failed:\\n- ${errors.join('\\n- ')}`\n + describeUnreadableOwnersForRefusal(input.unreadableOwners ?? []),\n );\n }\n}\n\n/**\n * `wildo config sync`'s half of a declared shared connection (#1725): what can be decided from static\n * declarations, before anything is recorded or loaded.\n *\n * REFUSED, each naming both sides:\n * - a ref listed in two connections, or a base listed as a member (also refused by the schema; repeated here so\n * a configuration that reached discovery without passing the schema is judged by the same predicate);\n * - a runtime scope that declares a member and not its base — the base's module is what connects, refreshes\n * and revokes the grant, so a host holding only the member could spend it and never renew it;\n * - a system-of-record instance as a member or base — a system of record authenticates as the DEPLOYMENT's\n * service identity and is never a delegated grant (#1055, #1738);\n * - a base that declares no `REST_API` binding (no OAuth client to own);\n * - a member whose token endpoint can only resolve to hosts the base's cannot — a different authorization\n * server, whose refresh tokens the base's server would never honour.\n *\n * REPORTED (advisories): a member's own OAuth2 client, inert while it is a member; a vendor label that differs\n * from the base's (display only until #1673); an authorization-server comparison the static shapes cannot\n * make, which the registry repeats on the loaded modules at boot.\n *\n * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — refs are admitted to one delegated grant only\n * when they can genuinely share it.\n */\nexport function validateProviderSharedConnections(input: {\n saasConfig: Pick<WildoSaasConfig, 'providers' | 'systemsOfRecord'>;\n discoveredContributions: readonly DiscoveredProviderCompanionContribution[];\n}): { errors: string[]; advisories: string[] } {\n const errors: string[] = [];\n const advisories: string[] = [];\n const connections = input.saasConfig.providers?.sharedConnections ?? {};\n if (Object.keys(connections).length === 0) return { errors, advisories };\n\n errors.push(...findProviderSharedConnectionConflicts(connections).map((conflict) => `providers.sharedConnections: ${conflict.message}`));\n\n const scopes = input.saasConfig.providers?.scopes ?? {};\n const spendingScopes: Array<[string, Record<string, unknown> | undefined]> = [\n ['backend', scopes.backend?.providers],\n ['companion', scopes.companion?.providers],\n ...Object.entries(scopes.minions ?? {}).map(([key, scope]): [string, Record<string, unknown> | undefined] => [`minions.${key}`, scope.providers]),\n ...Object.entries(scopes.workers ?? {}).map(([key, scope]): [string, Record<string, unknown> | undefined] => [`workers.${key}`, scope.providers]),\n ];\n const systemsOfRecord = new Set(Object.keys(input.saasConfig.systemsOfRecord ?? {}));\n const contributionOf = (ref: string): DiscoveredProviderCompanionContribution | undefined =>\n input.discoveredContributions.find((contribution) => contribution.ref === ref);\n\n for (const [baseRef, connection] of Object.entries(connections).sort(([left], [right]) => left.localeCompare(right))) {\n for (const ref of [baseRef, ...connection.refs]) {\n if (systemsOfRecord.has(ref)) {\n errors.push(\n `providers.sharedConnections.\"${baseRef}\" names \"${ref}\", which is a system-of-record instance. A system of record `\n + 'authenticates as the deployment\\'s own service identity and is never a delegated connection; remove it.',\n );\n }\n }\n for (const [scopeLabel, providers] of spendingScopes) {\n if (providers === undefined) continue;\n const scopedMembers = connection.refs.filter((ref) => Object.hasOwn(providers, ref));\n if (scopedMembers.length > 0 && !Object.hasOwn(providers, baseRef)) {\n errors.push(\n `providers.scopes.${scopeLabel} declares ${scopedMembers.map((ref) => `\"${ref}\"`).join(', ')} of the shared connection \"${baseRef}\" `\n + `but not \"${baseRef}\" itself. The base's module connects, refreshes and revokes the connection's grant, so every runtime `\n + 'that spends it must load the base too; scope it there.',\n );\n }\n }\n\n const base = contributionOf(baseRef);\n if (base !== undefined && !base.protocols.includes(BUILTIN_PROVIDER_PROTOCOL.REST_API)) {\n errors.push(\n `providers.sharedConnections names \"${baseRef}\" as a base, and it declares no ${BUILTIN_PROVIDER_PROTOCOL.REST_API} binding. `\n + 'A shared connection is owned by the base\\'s connected-account OAuth2 client, which only a REST binding carries.',\n );\n continue;\n }\n for (const memberRef of connection.refs) {\n const member = contributionOf(memberRef);\n if (member === undefined || base === undefined) continue;\n const memberVendor = member.identity?.vendor;\n const baseVendor = base.identity?.vendor;\n if (memberVendor !== undefined && baseVendor !== undefined && memberVendor !== baseVendor) {\n advisories.push(\n `\"${memberRef}\" (vendor \"${memberVendor}\") is a member of the shared connection \"${baseRef}\" (vendor \"${baseVendor}\"). `\n + 'Membership is the declaration, not the vendor label, so this is reported only.',\n );\n }\n if (member.oauth2TokenEndpointHosts !== undefined) {\n advisories.push(\n `\"${memberRef}\" declares its own OAuth2 client; while it is a member of \"${baseRef}\" that client and its client-id and `\n + `client-secret slots are inert — \"${baseRef}\"'s client connects and refreshes the one grant.`,\n );\n }\n const baseHosts = base.oauth2TokenEndpointHosts;\n const memberHosts = member.oauth2TokenEndpointHosts;\n if (memberHosts === undefined) continue;\n const agrees = baseHosts === undefined ? undefined : providerOAuth2TokenEndpointHostsIntersect(baseHosts, memberHosts);\n if (agrees === false) {\n errors.push(\n `\"${memberRef}\" cannot join the shared connection \"${baseRef}\": its token endpoint resolves to `\n + `${describeTokenEndpointHosts(memberHosts)} and \"${baseRef}\"'s to ${describeTokenEndpointHosts(baseHosts!)}. `\n + 'Those are different authorization servers, and a grant one of them issued cannot be renewed by the other.',\n );\n } else if (agrees === undefined) {\n advisories.push(\n `Whether \"${memberRef}\" and \"${baseRef}\" share an authorization server cannot be decided from their declarations; `\n + 'the provider registry compares their token endpoints when the application boots.',\n );\n }\n }\n }\n return { errors, advisories };\n}\n\nfunction describeTokenEndpointHosts(hosts: { readonly exact: readonly string[]; readonly suffixes: readonly string[] }): string {\n const parts = [...hosts.exact, ...hosts.suffixes.map((suffix) => `*${suffix}`)];\n return parts.length === 0 ? '(no host)' : parts.join(', ');\n}\n\n/**\n * Keys a companion augmentation record may carry. `ProviderAugmentationContributionSchema` is LOOSE — a newer\n * producer's additive field must ride through an older consumer — so a key that belongs to the base provider\n * would pass the schema silently. These are refused by name here, at `config sync`, before anything is\n * recorded: the runtime reader refuses the same keys on the module itself, and the two refusals are\n * deliberately redundant, because the companion record is what a reviewer reads and the module is what runs.\n */\nconst BASE_OWNED_AUGMENTATION_RECORD_KEYS: Readonly<Record<string, string>> = {\n ref: 'the provider\\'s own ref (an augmentation names the base in `augments`)',\n identity: 'the provider\\'s identity',\n protocols: 'a protocol binding',\n baseUrl: 'a base URL',\n oauth2: 'an OAuth2 block',\n secretsContractShape: 'a secrets contract',\n secretsContract: 'a secrets contract',\n engineCapabilities: 'an engine capability',\n providerCapabilities: 'a provider capability',\n admissibleConnections: 'the connections a provider admits',\n runtimeTargets: 'the runtimes a provider reaches (an augmentation applies wherever its base is scoped)',\n frontendEntry: 'a frontend provider entry',\n};\n\n/**\n * `wildo config sync`'s half of the augmentation opt-in (#1672): every name under `providers.augmentations`\n * must be a package this walk discovered, declaring an admissible augmentation OF THAT REF, of a provider the\n * application scopes and that runs REST operations — and no two opted-in packages may add one operation id.\n *\n * Everything here is decided from STATIC declarations, without loading a line of the augmenting package: the\n * operation ids are stated in the companion record precisely so a collision is refused here rather than at the\n * first call. The runtime loader re-checks what the package actually delivers against these same ids.\n *\n * What it does NOT refuse, deliberately: an augmentation that is discovered and NOT opted in. That is the\n * ordinary state of a provider package augmenting many refs, and it contributes nothing.\n *\n * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — admitting third-party operations to a provider's\n * grant is checked against the application's explicit opt-in before any artifact records it.\n */\nfunction validateProviderAugmentationOptIns(input: {\n errors: string[];\n saasConfig: Pick<WildoSaasConfig, 'providers'>;\n discoveredContributions: readonly DiscoveredProviderCompanionContribution[];\n discoveredAugmentations: readonly DiscoveredProviderAugmentation[];\n}): void {\n const { errors, saasConfig, discoveredContributions, discoveredAugmentations } = input;\n const optIns = saasConfig.providers?.augmentations ?? {};\n const scopes = saasConfig.providers?.scopes ?? {};\n const scopedRefs = new Set<string>([\n ...Object.keys(scopes.backend?.providers ?? {}),\n ...Object.keys(scopes.companion?.providers ?? {}),\n ...Object.values(scopes.frontendServices ?? {}).flatMap((scope) => Object.keys(scope.providers ?? {})),\n ...Object.values(scopes.minions ?? {}).flatMap((scope) => Object.keys(scope.providers ?? {})),\n ...Object.values(scopes.workers ?? {}).flatMap((scope) => Object.keys(scope.providers ?? {})),\n ]);\n\n for (const [baseRef, packageNames] of Object.entries(optIns).sort(([left], [right]) => left.localeCompare(right))) {\n if (!scopedRefs.has(baseRef)) {\n errors.push(\n `providers.augmentations names \"${baseRef}\", which no providers.scopes entry declares. An augmentation adds `\n + 'operations to a provider the application uses; scope the provider first.',\n );\n continue;\n }\n const baseContributions = discoveredContributions.filter((contribution) => contribution.ref === baseRef);\n const baseRunsRest = baseContributions.some((contribution) => contribution.protocols.includes(BUILTIN_PROVIDER_PROTOCOL.REST_API));\n if (baseContributions.length > 0 && !baseRunsRest) {\n errors.push(\n `providers.augmentations opts ${packageNames.map((name) => `\"${name}\"`).join(', ')} into \"${baseRef}\", which `\n + `declares no ${BUILTIN_PROVIDER_PROTOCOL.REST_API} binding. An augmentation's operations run through the base `\n + 'provider\\'s REST contract — its base URL and credential — so a provider without one cannot be augmented.',\n );\n }\n\n const declaredBy = new Map<string, string>();\n for (const packageName of packageNames) {\n const fromPackage = discoveredAugmentations.filter((augmentation) => augmentation.packageName === packageName\n || augmentation.owner.key === packageName);\n if (fromPackage.length === 0) {\n errors.push(describeUndiscoveredAugmentationPackage(packageName, baseRef));\n continue;\n }\n const ofThisRef = fromPackage.filter((candidate) => candidate.augments === baseRef);\n if (ofThisRef.length > 1) {\n errors.push(\n `\"${packageName}\" declares ${ofThisRef.length} augmentations of \"${baseRef}\". A package augments a provider once; `\n + 'merge them into one record so the operation set the application opts into is one list.',\n );\n continue;\n }\n const augmentation = ofThisRef[0];\n if (augmentation === undefined) {\n const augmented = [...new Set(fromPackage.map((candidate) => candidate.augments))].sort();\n errors.push(\n `providers.augmentations opts \"${packageName}\" into \"${baseRef}\", but that package augments `\n + `${augmented.map((ref) => `\"${ref}\"`).join(', ')} and not \"${baseRef}\".`,\n );\n continue;\n }\n if (augmentation.packageName !== augmentation.owner.key && augmentation.owner.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE) {\n errors.push(\n `The augmentation of \"${baseRef}\" found in package \"${augmentation.owner.key}\" names itself \"${augmentation.packageName}\". `\n + 'An augmentation\\'s packageName must be its own manifest name — it is what the audit trail attributes calls to.',\n );\n continue;\n }\n if (augmentation.packageVersion === undefined) {\n errors.push(`\"${packageName}\" (augmenting \"${baseRef}\") states no version in its package.json; the audit trail records it beside every call it contributes.`);\n }\n const base = baseContributions.find((contribution) => contribution.protocols.includes(BUILTIN_PROVIDER_PROTOCOL.REST_API));\n const baseVersionRefusal = base === undefined ? undefined : describeAugmentationBaseVersionRefusal(augmentation, base);\n if (baseVersionRefusal !== undefined) errors.push(baseVersionRefusal);\n for (const key of Object.keys(augmentation)) {\n const owned = BASE_OWNED_AUGMENTATION_RECORD_KEYS[key];\n if (owned !== undefined) {\n errors.push(\n `\"${packageName}\" declares \\`${key}\\` in its augmentation of \"${baseRef}\", which would change ${owned} — only `\n + 'the provider\\'s owner declares that; an augmentation adds operations only.',\n );\n }\n }\n for (const operationId of augmentation.operationIds) {\n const earlier = declaredBy.get(operationId);\n if (earlier !== undefined) {\n errors.push(\n `\"${earlier}\" and \"${packageName}\" both add operation '${operationId}' to \"${baseRef}\". An operation id names `\n + 'one request; opt in only one of them.',\n );\n }\n declaredBy.set(operationId, packageName);\n }\n }\n }\n}\n\n/**\n * The package that ships a base provider, and its installed version when the walk read that package itself (#1672,\n * #1731). The version is `undefined` for a base an application's own runtime package contributes, which has no\n * installed version to hold an augmentation to.\n */\nexport function resolveProviderBasePackage(base: DiscoveredProviderCompanionContribution): { basePackageName: string; basePackageVersion?: string } {\n const importPath = base.runtimeImportPath;\n const basePackageName = importPath.startsWith('@') ? importPath.split('/').slice(0, 2).join('/') : importPath.split('/')[0]!;\n const basePackageVersion = base.owner.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE && base.owner.key === basePackageName\n ? readPackageVersion(base.owner.packageRoot)\n : undefined;\n return { basePackageName, ...(basePackageVersion === undefined ? {} : { basePackageVersion }) };\n}\n\n/**\n * The refusal, if any, of an opted-in augmentation whose peer range on its base's package does not admit the\n * installed base (#1731).\n *\n * An augmentation's operations run on the base provider's base URL, credential and operation-id namespace, all of\n * which move with the package that ships the base — for an engine ref, the engine. So the augmenting package states\n * the base versions it was written against the way npm states any such requirement: a `peerDependencies` range on\n * that package. Versioning stays at publication; there is no in-code compatibility table.\n *\n * - A range the installed version does not satisfy is refused, naming the augmentation, the range and the version.\n * - A MISSING range is refused too: an augmentation that says nothing about its base cannot be held to one, and an\n * engine upgrade would break it with nothing reporting it — the very failure this exists to catch.\n * - A range this reader cannot parse is refused rather than guessed.\n * - A `workspace:` range is admitted: inside one workspace the peer IS the linked base, whatever its version.\n * - A base with no installed version (an application's own runtime package) cannot be checked, and is not.\n *\n * assurance-control: WILDO.SECURITY.FAIL_CLOSED — third-party operations reach a provider's grant only when the\n * package declares, and the installed base satisfies, the base version it was written against.\n */\nfunction describeAugmentationBaseVersionRefusal(\n augmentation: DiscoveredProviderAugmentation,\n base: DiscoveredProviderCompanionContribution,\n): string | undefined {\n const { basePackageName, basePackageVersion } = resolveProviderBasePackage(base);\n if (basePackageVersion === undefined) return undefined;\n if (augmentation.owner.kind !== ProviderContributionOwnerKind.PROVIDER_PACKAGE || augmentation.owner.key === basePackageName) return undefined;\n const subject = `\"${augmentation.packageName}\" (augmenting \"${augmentation.augments}\")`;\n const range = readPeerDependencyRange(augmentation.owner.packageRoot, basePackageName);\n if (range === undefined) {\n return `${subject} declares no peerDependencies range on \"${basePackageName}\", the package that ships its base (installed `\n + `${basePackageVersion}). An augmentation states the base versions it was written against as a peer range, so an `\n + 'upgrade of the base cannot break it silently; add one to its package.json.';\n }\n if (range.startsWith('workspace:')) return undefined;\n const satisfied = satisfiesNpmVersionRange(basePackageVersion, range);\n if (satisfied === true) return undefined;\n if (satisfied === undefined) {\n return `${subject} declares the peer range \"${range}\" on \"${basePackageName}\", which cannot be read as an npm version range.`;\n }\n return `${subject} requires \"${basePackageName}\" ${range}, and ${basePackageVersion} is installed. Upgrade the augmenting `\n + `package to a version written against ${basePackageVersion}, or remove it from providers.augmentations.`;\n}\n\n/** The `peerDependencies` range a package's manifest states for `dependencyName`, or `undefined`. */\nfunction readPeerDependencyRange(packageRoot: string, dependencyName: string): string | undefined {\n try {\n const manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf-8')) as { peerDependencies?: Record<string, unknown> };\n const range = manifest.peerDependencies?.[dependencyName];\n return typeof range === 'string' ? range : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Why an opted-in package was not found, pointing at the right remedy: a package outside `@wildo-ai` and the\n * application's own scope is walked only when `providers.packages` lists it (#1676), while an own-scope package is\n * walked under the `<scope>/provider-` naming convention (or by being listed too).\n */\nfunction describeUndiscoveredAugmentationPackage(packageName: string, baseRef: string): string {\n const scope = packageName.startsWith('@') ? packageName.split('/')[0] : undefined;\n const prefix = `providers.augmentations opts \"${packageName}\" into \"${baseRef}\", but discovery found no augmentation from that package.`;\n if (scope === undefined || scope === '@wildo-ai') {\n return `${prefix} Check that it is a dependency of a runtime owner, is installed, and exports \\`providerAugmentations\\` from its \\`./companion\\` door.`;\n }\n return `${prefix} Discovery walks \\`@wildo-ai/provider-*\\`, the engine barrel and packages named `\n + `\\`<application-scope>/provider-*\\` by themselves; any other package is walked only when \\`providers.packages\\` lists it. `\n + `List \"${packageName}\" there, and make it a dependency of a runtime owner.`;\n}\n\n/**\n * The part of a refusal that says the walk was INCOMPLETE, or nothing when it was not.\n *\n * Measured 2026-09-24 (#1558): Wonder CRM's frontend companion could not be loaded — its injected\n * engine snapshot was missing a file — so it contributed nothing, and the refusal said only\n * `Provider \"sentry\" is authored in scope \"frontendServices.app\" but no companion export contributes\n * it`. That names the CATALOGUE; the cause was a LOAD. The first diagnosis recorded it as a provider\n * decision. Naming the unreadable owner and its reason beside the refusal points at the real remedy.\n */\nfunction describeUnreadableOwnersForRefusal(unreadableOwners: readonly UnreadableProviderCompanionOwner[]): string {\n if (unreadableOwners.length === 0) return '';\n return '\\nThese runtime owners could not be READ, so anything they contribute is missing above — '\n + 'repair the load before concluding a provider is uncontributed:\\n- '\n + unreadableOwners.map((owner) => `${owner.ownerLabel} (${owner.packageRoot}): ${owner.reason}`).join('\\n- ');\n}\n\n/**\n * Every runtime owner's package root, UNFILTERED — the roots a provider PACKAGE may be declared in.\n *\n * Distinct from {@link resolveContributionTargets} on purpose, and the distinction is the whole of\n * issue #1300. That function answers \"whose own companion exports should we LOAD\", and it correctly\n * skips an owner with nothing scoped to it: such an owner contributes nothing relevant. This one\n * answers \"whose MANIFEST may name a provider package\", and for that question the scopes are not\n * evidence — a manifest declares `@wildo-ai/external-connectors-private` whether or not the\n * application has yet scoped anything from it.\n *\n * Reusing the filtered set for both made provider discovery CIRCULAR: a backend service entered the\n * search only when `providers.scopes.backend` already had providers, so a freshly scaffolded\n * application — whose scopes are all empty — searched only its root manifest, found no provider\n * package, discovered ZERO contributions, and refused every provider it tried to scope with\n * \"no companion export contributes it for that runtime\". Scoping a provider required having already\n * scoped one. Measured on a fresh application: 0 contributions with empty scopes, 23 the moment one\n * provider was added to the backend scope, from the same manifests and the same installed packages.\n *\n * The cost of not filtering is reading a few more `package.json` files; `resolveProviderPackageTargets`\n * de-duplicates by resolved package root and skips what it cannot resolve.\n */\nfunction resolveRuntimeOwnerPackageRoots(\n saasRoot: string,\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'workers'>,\n): string[] {\n return [\n ...Object.values(saasConfig.services),\n ...Object.values(saasConfig.libraries ?? {}),\n ...Object.values(saasConfig.minions ?? {}),\n ...Object.values(saasConfig.workers ?? {}),\n ].map((definition) => resolve(saasRoot, definition.path));\n}\n\nfunction resolveContributionTargets(\n saasRoot: string,\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>,\n): ProviderContributionTarget[] {\n const shouldIncludeBackendServices = hasAnyProviders(saasConfig.providers.scopes.backend?.providers);\n const frontendServiceProviderScopes = Object.entries(saasConfig.providers.scopes.frontendServices ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([serviceKey]) => serviceKey);\n const minionProviderScopes = Object.entries(saasConfig.providers.scopes.minions ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([minionKey]) => minionKey);\n const workerProviderScopes = Object.entries(saasConfig.providers.scopes.workers ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([workerKey]) => workerKey);\n\n return [\n ...Object.entries(saasConfig.services)\n .filter(([key, definition]) => (\n definition.frontendType\n ? frontendServiceProviderScopes.includes(key)\n : shouldIncludeBackendServices\n ))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.SERVICE,\n key,\n ownerLabel: `service \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.libraries ?? {}).map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.LIBRARY,\n key,\n ownerLabel: `library \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.minions ?? {})\n .filter(([key]) => minionProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.MINION,\n key,\n ownerLabel: `minion \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.workers ?? {})\n .filter(([key]) => workerProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.WORKER,\n key,\n ownerLabel: `worker \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ];\n}\n\n/**\n * Every provider PACKAGE this application depends on, as a contribution target.\n *\n * Candidates come from the application root manifest AND from each runtime owner's manifest, because\n * both layouts are real: a scaffolded application declares its provider packages in the runtime owner\n * that imports them (`backend-api`), while a workspace root may hoist them. The union is deduplicated\n * by resolved package root, so a package declared in both places is walked once.\n *\n * A candidate that cannot be resolved on disk is SKIPPED rather than refused. The manifest is the\n * declaration and `node_modules` is the install; a name declared but not installed is an install\n * problem that `pnpm install` reports far better than a config-sync stack trace would, and refusing\n * here would make `wildo config sync` unrunnable in exactly the state where an operator runs it to\n * find out what is wrong.\n */\nfunction resolveProviderPackageTargets(\n saasRoot: string,\n runtimeOwnerPackageRoots: string[],\n listedPackageNames: readonly string[],\n): ProviderPackageTargets {\n const prefixes = resolveProviderPackagePrefixes(saasRoot);\n const searchRoots = [saasRoot, ...runtimeOwnerPackageRoots];\n const listed = new Set(listedPackageNames);\n const admittedByName = (dependencyName: string): boolean => dependencyName === FRAMEWORK_ENGINE_PROVIDER_PACKAGE\n || dependencyName === FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE\n || prefixes.some((prefix) => dependencyName.startsWith(prefix));\n // A search root's OWN name is in the set `readRuntimeReachablePackageNames` answers, and is never a dependency.\n const ownPackageNames = new Set(searchRoots.map((root) => readPackageName(root)).filter((name): name is string => name !== undefined));\n\n const candidateNames = new Set<string>();\n const dependencyNames = new Set<string>();\n for (const searchRoot of searchRoots) {\n for (const dependencyName of readRuntimeReachablePackageNames(searchRoot)) {\n dependencyNames.add(dependencyName);\n /*\n * assurance-control: WILDO.SECURITY.FAIL_CLOSED — a dependency is EXECUTED by this walk only when it carries a\n * framework name, the application's own `<scope>/provider-*` name, or the application LISTS it in `providers.packages` (#1676).\n * Installing a package from somebody else's scope admits nothing; the listing is reviewable in\n * `wildo.saas.config.ts`, and every admitted package is printed by `config sync` and recorded in the lock.\n */\n if (admittedByName(dependencyName) || (listed.has(dependencyName) && !ownPackageNames.has(dependencyName))) {\n candidateNames.add(dependencyName);\n }\n }\n }\n\n const targetsByRoot = new Map<string, ProviderContributionTarget>();\n for (const packageName of [...candidateNames].sort()) {\n const packageRoot = resolveProviderPackageRoot(packageName, searchRoots);\n if (!packageRoot || targetsByRoot.has(packageRoot)) {\n continue;\n }\n targetsByRoot.set(packageRoot, {\n kind: ProviderContributionOwnerKind.PROVIDER_PACKAGE,\n key: packageName,\n ownerLabel: `provider package \"${packageName}\"`,\n packageRoot,\n });\n }\n\n return { targets: [...targetsByRoot.values()], dependencyNames, ownPackageNames, admittedByName };\n}\n\n/** The walked provider packages, and what a listing is checked against. */\ninterface ProviderPackageTargets {\n readonly targets: ProviderContributionTarget[];\n /** Every name the search roots' manifests answer, their own names included. */\n readonly dependencyNames: ReadonlySet<string>;\n /** The application root's and the runtime owners' own package names. */\n readonly ownPackageNames: ReadonlySet<string>;\n /** Whether discovery walks this name without a listing. */\n readonly admittedByName: (packageName: string) => boolean;\n}\n\n/**\n * The refusal for an application that declares system-of-record instances and whose walk did not record the framework\n * library's facet module (#2013) — the library is declared but not installed, or not declared at all.\n *\n * Refused here, at sync, because the alternative is worse and later: an artifact without the library's module boots a\n * backend that refuses every instance whose vendor only the library describes (`VENDOR_HAS_NO_FACET`), and `wildo\n * secrets` cannot list those instances' credential slots. The remedy needs no running process: `wildo config sync`\n * declares the library on the backend service and links it (`declareSystemsOfRecordLibrary` in the CLI), and a\n * `pnpm install` installs it.\n */\nfunction describeUndiscoveredSystemsOfRecordLibrary(\n systemsOfRecord: NonNullable<WildoSaasConfig['systemsOfRecord']>,\n facetModules: readonly string[],\n): string[] {\n const instances = Object.keys(systemsOfRecord);\n if (instances.length === 0) return [];\n if (facetModules.includes(`${FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE}${SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1)}`)) return [];\n return [\n `systemsOfRecord declares ${instances.map((name) => `\"${name}\"`).join(', ')}, and ${FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE} — the vendor `\n + 'facets every instance reads — was not discovered. `wildo config sync` declares it on the backend service; run your package '\n + \"manager's install (pnpm install), then run `wildo config sync` again.\",\n ];\n}\n\n/**\n * One refusal per package an instance opts into (`facetAugmentations`) whose facet module the walk did not record\n * (#1675) — the sentence the backend's resolver refuses the boot with, said at sync instead.\n */\nfunction describeUndiscoveredFacetAugmentationPackages(\n systemsOfRecord: NonNullable<WildoSaasConfig['systemsOfRecord']>,\n facetModules: readonly string[],\n): string[] {\n const recordedPackages = new Set(facetModules.map((specifier) => (specifier.endsWith(SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1))\n ? specifier.slice(0, -SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1).length)\n : specifier)));\n const refusals: string[] = [];\n for (const [name, declaration] of Object.entries(systemsOfRecord)) {\n for (const packageName of declaration.facetAugmentations ?? []) {\n if (!recordedPackages.has(packageName)) {\n refusals.push(`systemsOfRecord.${name}.facetAugmentations names ${packageName}: ${SYSTEM_OF_RECORD_FACET_MODULE_NOT_DISCOVERED}.`);\n }\n }\n }\n return refusals;\n}\n\n/** One refusal per listed package discovery could not admit (#1676), each naming the package and the remedy. */\nfunction describeRefusedProviderPackageListings(listed: readonly ListedProviderPackage[]): string[] {\n const refusals: string[] = [];\n for (const entry of listed) {\n const subject = `providers.packages lists \"${entry.packageName}\"`;\n switch (entry.status) {\n case ProviderPackageListingStatus.ADMITTED:\n break;\n case ProviderPackageListingStatus.NOT_A_DEPENDENCY:\n refusals.push(`${subject}, but neither the application root nor any runtime owner depends on it — add it to the `\n + 'package.json of the runtime that uses it (usually backend-api), or remove the listing.');\n break;\n case ProviderPackageListingStatus.NOT_INSTALLED:\n refusals.push(`${subject}, which is declared as a dependency and is not installed — run your package manager's install.`);\n break;\n case ProviderPackageListingStatus.UNREADABLE:\n refusals.push(`${subject}, whose companion entry could not be read (${entry.reason ?? 'unknown error'}).`);\n break;\n case ProviderPackageListingStatus.ALREADY_WALKED:\n refusals.push(`${subject}, which discovery walks by name already — remove the listing; \\`providers.packages\\` is for `\n + 'a package discovery does not walk by itself: one from another scope, or one of the application\\'s own scope '\n + 'not named `<scope>/provider-*`.');\n break;\n case ProviderPackageListingStatus.RUNTIME_OWNER:\n refusals.push(`${subject}, which is one of this application's own runtime packages — it is walked as a runtime owner, `\n + 'not as a provider package; remove the listing.');\n break;\n case ProviderPackageListingStatus.CONTRIBUTES_NOTHING:\n refusals.push(`${subject}, which ships no provider contribution, no provider augmentation and no ./systems-of-record `\n + 'module — it is not a provider package, or the wrong package is listed.');\n break;\n }\n }\n return refusals;\n}\n\n/**\n * The framework prefix, plus the application's own scope when its root manifest has one.\n *\n * Deriving the second from the root package name rather than reading it from configuration keeps the\n * \"one declaration\" promise of #330 intact: installing `@acme/provider-thing` in an `@acme` application\n * and scoping the ref is the whole of it — there is no third place to remember.\n */\nfunction resolveProviderPackagePrefixes(saasRoot: string): string[] {\n const prefixes = [FRAMEWORK_PROVIDER_PACKAGE_PREFIX];\n const rootPackageName = readPackageName(saasRoot);\n const scope = rootPackageName?.startsWith('@') ? rootPackageName.split('/')[0] : undefined;\n if (scope && scope !== '@wildo-ai') {\n prefixes.push(`${scope}/provider-`);\n }\n return prefixes;\n}\n\n/**\n * Locate an installed package's ROOT DIRECTORY, which is what the companion-entry resolver needs.\n *\n * The direct `node_modules` probe comes first because it is what pnpm actually produces — a symlink\n * per importer — and because it works for a package whose `exports` map declares no `./package.json`,\n * which `require.resolve` cannot see past. `createRequire` is the fallback for hoisted or otherwise\n * unusual layouts; it resolves the companion subpath (the one door every provider package declares)\n * and walks up to the manifest that names the package.\n */\nfunction resolveProviderPackageRoot(packageName: string, searchRoots: string[]): string | undefined {\n /*\n * The name comes from a manifest and is spliced into a filesystem path, so a segment that is `.` or\n * `..` would walk OUT of `node_modules` — and the prefix gate would not stop it, since\n * `@wildo-ai/provider-x/../../elsewhere` starts with the framework prefix. npm forbids such a name,\n * which is precisely why nothing downstream would question it; the check costs one line and is the\n * only thing standing between an authored dependency name and an arbitrary directory whose\n * companion entry this walk EXECUTES.\n */\n const segments = packageName.split('/');\n if (segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {\n return undefined;\n }\n\n for (const searchRoot of searchRoots) {\n const candidate = join(searchRoot, 'node_modules', ...segments);\n if (existsSync(join(candidate, 'package.json'))) {\n return candidate;\n }\n }\n\n for (const searchRoot of searchRoots) {\n try {\n const resolved = createRequire(join(searchRoot, 'package.json')).resolve(`${packageName}/companion`);\n let directory = dirname(resolved);\n while (directory !== dirname(directory)) {\n if (readPackageName(directory) === packageName) {\n return directory;\n }\n directory = dirname(directory);\n }\n } catch {\n // Not resolvable from this root; try the next one, then give up quietly (see the JSDoc above).\n }\n }\n\n return undefined;\n}\n\n/** The installed version a package's own manifest states, or `undefined` when it states none or is unreadable. */\nexport function readPackageVersion(packageRoot: string): string | undefined {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return undefined;\n }\n try {\n const version = (JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { version?: unknown }).version;\n return typeof version === 'string' && version.length > 0 ? version : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction readPackageName(packageRoot: string): string | undefined {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return undefined;\n }\n try {\n return (JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { name?: string }).name;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Read one owner's companion barrel, separating the two answers that used to look identical.\n *\n * - `{ exports: undefined }` — the package declares no `./companion` door. Ordinary: most packages\n * do not, and the walk asks everything it can reach.\n * - `{ unreadable }` — the door EXISTS and reading it threw. A broken or unbuilt install, not an\n * absence, and the one case worth telling somebody about.\n */\nasync function tryLoadRuntimeOwnerCompanionExports(\n packageRoot: string,\n): Promise<{ exports?: RuntimeOwnerCompanionExports; unreadable?: string }> {\n try {\n resolvePackageCompanionEntryPath(packageRoot);\n } catch {\n return {};\n }\n\n try {\n return { exports: await loadPackageCompanionExport<RuntimeOwnerCompanionExports>(packageRoot) };\n } catch (error) {\n return { unreadable: describeCaughtError(error) };\n }\n}\n\nfunction validateRuntimeScopeAgainstDiscovery(input: {\n errors: string[];\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n scopeLabel: string;\n providers: NonNullable<WildoSaasConfig['providers']['scopes']['backend']>['providers'];\n matchesTarget: (target: ProviderCompanionRuntimeTarget) => boolean;\n}): void {\n const { errors, discoveredContributions, matchesTarget, providers, scopeLabel } = input;\n\n for (const [providerRef, authoredSelection] of Object.entries(providers)) {\n const matchingContributions = discoveredContributions.filter(\n (contribution) => contribution.ref === providerRef\n && contribution.runtimeTargets.some(matchesTarget),\n );\n\n if (matchingContributions.length === 0) {\n errors.push(\n `Provider \"${providerRef}\" is authored in scope \"${scopeLabel}\" but no companion export contributes it for that runtime.`,\n );\n continue;\n }\n\n const claimedTwice = describeProviderRefClaimedByMoreThanOneImportPath(providerRef, `scope \"${scopeLabel}\"`, matchingContributions);\n if (claimedTwice !== undefined) errors.push(claimedTwice);\n\n const discoveredEngineCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.engineCapabilities),\n );\n const discoveredProviderCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.providerCapabilities),\n );\n const discoveredProtocols = new Set(\n matchingContributions.flatMap((contribution) => contribution.protocols),\n );\n\n for (const capability of authoredSelection.engineCapabilities) {\n if (!discoveredEngineCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares engine capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const capability of authoredSelection.providerCapabilities) {\n if (!discoveredProviderCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares provider capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const protocol of authoredSelection.protocols) {\n if (!discoveredProtocols.has(protocol)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares protocol \"${protocol}\" ` +\n 'but discovery does not report that protocol for the same runtime.',\n );\n }\n }\n }\n}\n\n/**\n * The refusal for one provider ref claimed, for ONE runtime, through more than one import path (#2014, epic #2012).\n * `undefined` when the contributions agree.\n *\n * A runtime loads one module per ref, from the path its provider artifact records. When two packages contribute\n * the same ref for the same runtime, that path used to be the alphabetically first — so a second package contributing\n * a ref the application's own copy (`@<app>/provider-asana`) also contributes decided silently which module loaded.\n * The case that motivated it (#2014) was a leftover install of the since-archived catalogue, whose `asana` subpath\n * sorted first; the same holds for any framework `@wildo-ai/provider-<ref>` package installed beside the copy.\n *\n * Scoped to one runtime on purpose: the same ref legitimately has one path per FACET — `posthog` is\n * `@wildo-ai/external-connectors-public/app` for the SaaS frontend and `@wildo-ai/external-connectors-private/backend`\n * for the backend. Measured 2026-09-29 over Wonder Todos and Wonder CRM: six refs have several paths, and no ref has\n * two for the same runtime.\n *\n * Shared by discovery validation (`wildo config sync`, `wildo lock check`) and the artifact builder, so the two\n * cannot disagree about what counts as a second claimant.\n */\nexport function describeProviderRefClaimedByMoreThanOneImportPath(\n providerRef: string,\n runtimeLabel: string,\n contributions: readonly DiscoveredProviderCompanionContribution[],\n): string | undefined {\n const ownersByPath = new Map<string, Set<string>>();\n for (const contribution of contributions) {\n if (contribution.ref !== providerRef) continue;\n const owners = ownersByPath.get(contribution.runtimeImportPath) ?? new Set<string>();\n owners.add(`${contribution.owner.kind} \"${contribution.owner.key}\"`);\n ownersByPath.set(contribution.runtimeImportPath, owners);\n }\n if (ownersByPath.size <= 1) return undefined;\n const claims = [...ownersByPath]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([path, owners]) => `\"${path}\" (reached through ${[...owners].sort().join(', ')})`)\n .join(' and ');\n return `Provider \"${providerRef}\" is claimed for ${runtimeLabel} through more than one import path: ${claims}. `\n + 'A runtime loads one module per ref, so it cannot pick one. Keep one: uninstall the package that should not '\n + 'provide it, or remove its dependency from that runtime.';\n}\n\nfunction describeContribution(contribution: DiscoveredProviderCompanionContribution): string {\n return `Provider contribution \"${contribution.ref}\" from ${contribution.owner.kind} \"${contribution.owner.key}\"`;\n}\n\nfunction readRuntimeReachablePackageNames(packageRoot: string): Set<string> {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return new Set<string>();\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n };\n\n return new Set([\n ...(packageJson.name ? [packageJson.name] : []),\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ...Object.keys(packageJson.optionalDependencies ?? {}),\n ]);\n}\n\nfunction extractPackageName(importPath: string): string {\n if (importPath.startsWith('@')) {\n const [scope, pkg] = importPath.split('/');\n return `${scope}/${pkg}`;\n }\n return importPath.split('/')[0] ?? importPath;\n}\n\nfunction hasAnyProviders(\n providers: Record<string, unknown> | undefined,\n): boolean {\n return Boolean(providers && Object.keys(providers).length > 0);\n}\n"]}
1
+ {"version":3,"file":"provider-companion-discovery.js","sourceRoot":"","sources":["../../../../src/project-config/provider-companion-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,yBAAyB,EACzB,4CAA4C,EAC5C,sCAAsC,EACtC,mCAAmC,EAKA,mBAAmB,EACtD,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,yCAAyC,EAAE,MAAM,sCAAsC,CAAC;AACjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAExF;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,6BAeX;AAfD,WAAY,6BAA6B;IACvC,sGAAsG;IACtG,oDAAmB,CAAA;IACnB,mDAAmD;IACnD,oDAAmB,CAAA;IACnB,kDAAkD;IAClD,kDAAiB,CAAA;IACjB,uDAAuD;IACvD,kDAAiB,CAAA;I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,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,OAAO,GAAG,KAAK,IAAI,GAAG,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC;AAChD,CAAC;AAED,SAAS,eAAe,CACtB,SAA8C;IAE9C,OAAO,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import { createRequire } from 'node:module';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport {\n BUILTIN_PROVIDER_PROTOCOL,\n SYSTEM_OF_RECORD_FACET_MODULE_NOT_DISCOVERED,\n ProviderAugmentationContributionSchema,\n ProviderCompanionContributionSchema,\n type ProviderAugmentationContribution,\n type ProviderCompanionContribution,\n type ProviderComplianceProfile,\n type ProviderCompanionRuntimeTarget,\n type RuntimeOwnerCompanionExports, describeCaughtError,\n findProviderSharedConnectionConflicts } from '@wildo-ai/saas-models';\nimport { providerOAuth2TokenEndpointHostsIntersect } from '@wildo-ai/external-connectors-models';\nimport { satisfiesNpmVersionRange } from './npm-version-range';\nimport type { WildoSaasConfig } from './define-saas-config';\nimport { loadPackageCompanionExport, resolvePackageCompanionEntryPath } from './loader';\n\n/**\n * `providerPackage` was added by #330 and is the point of that slice on this file.\n *\n * The other four owner kinds are RUNTIME OWNERS declared in `wildo.saas.config.ts` — an application's\n * own services, libraries, minions and workers. Walking only those is what made a provider shipped as\n * its own npm package invisible to discovery (audit finding PL-1): the package is a DEPENDENCY, not a\n * runtime owner, so nothing ever asked it what it contributes, and an application had to hand-author a\n * contribution for a provider whose own package already knew everything about it.\n */\nexport enum ProviderContributionOwnerKind {\n /** A service package declared in `wildo.saas.config.ts` — the application's backend or a frontend. */\n SERVICE = 'service',\n /** A shared library package of the application. */\n LIBRARY = 'library',\n /** A minion runtime, keyed by its minion name. */\n MINION = 'minion',\n /** A Node worker runtime, keyed by its worker name. */\n WORKER = 'worker',\n /**\n * A provider shipped as its own npm package (#330) — a DEPENDENCY rather than a runtime owner,\n * which is why it needed its own walk and its own member. The value stays camelCase because it is\n * substituted into operator-facing diagnostics beside the four above.\n */\n PROVIDER_PACKAGE = 'providerPackage',\n}\n\n/**\n * Package-name prefixes whose dependencies are treated as provider packages.\n *\n * `@wildo-ai/provider-` is the framework convention (#337 D3), and the name a registry provider's facet packages\n * carry in `providers-registry/<ref>/` before an install renames them into the application's scope. An application's OWN provider packages\n * are admitted through the scope of its root manifest — an application published as `@acme/…` gets\n * `@acme/provider-…` for free — so a private provider needs no configuration to be discovered, and any other\n * dependency is never executed by this walk unless the application lists it in `providers.packages` (#1676).\n */\nexport const FRAMEWORK_PROVIDER_PACKAGE_PREFIX = '@wildo-ai/provider-';\n\n/**\n * The ENGINE's own provider barrel, admitted by exact NAME.\n *\n * The engine ships 23 providers and exports them through `./companion` — the same shape every\n * provider package uses. Discovery did not admit it, so an application that wanted `resend` declared\n * it THREE times: the scope, a hand-authored `provider-contributions.ts` projecting the engine's own\n * metadata back at it, and the package dependency. The middle one carried no information the other\n * two lacked; config sync refused a scoped-but-uncontributed provider, so it was not optional either\n * (#358).\n *\n * A NAME rather than a loosened prefix (`@wildo-ai/provider`, no hyphen, or `@wildo-ai/external-connectors-`): this\n * is one known package, not a family, and a prefix wide enough to reach it would also admit whatever else is later\n * published under it.\n *\n * Until #2019 the transposed provider catalogue was admitted by exact name beside this one — ONE package with a subpath\n * per vendor, whose name did not start with `@wildo-ai/provider-` (the `s` is not a `-`). It is archived; a provider\n * the framework distributes now lives in `providers-registry/<ref>/` and reaches an application as its own copy, a\n * `<scope>/provider-<ref>` package the scope prefix admits.\n */\nexport const FRAMEWORK_ENGINE_PROVIDER_PACKAGE = '@wildo-ai/external-connectors-private';\n\n/**\n * The framework's SYSTEM-OF-RECORD library (#2013): the vendor facets — Odoo, SAP S/4HANA, Dataverse, Business\n * Central, NetSuite, Salesforce, generic OData — as an opt-in package, admitted by exact NAME like the engine barrel above.\n *\n * The facets used to ride inside the provider catalogue, and discovery found them only because the catalogue was\n * admitted by name. Moving them out without this line would have dropped Odoo's facet from the provider-runtime\n * artifact, and the backend refuses a declared instance whose vendor has no facet (`VENDOR_HAS_NO_FACET`).\n *\n * It is also the ONLY package whose `./systems-of-record` module is recorded without an instance asking for it —\n * see {@link isAdmittedSystemOfRecordFacetModule}.\n */\nexport const FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE = '@wildo-ai/systems-of-record';\n\n/**\n * What discovery found for one package the application LISTS in `providers.packages` (#1676). Only\n * {@link ProviderPackageListingStatus.ADMITTED} is acceptable: every other status is a `wildo config sync` refusal\n * naming the package, because a listing is an explicit decision and a listing that admits nothing is a mistake the\n * author believes is working.\n */\nexport enum ProviderPackageListingStatus {\n /** Walked, and it ships a provider contribution, an augmentation or a `./systems-of-record` module. */\n ADMITTED = 'admitted',\n /** Neither the application root nor any runtime owner depends on it, so nothing could install or import it. */\n NOT_A_DEPENDENCY = 'not-a-dependency',\n /** Declared as a dependency but not found under `node_modules` — run the package manager's install. */\n NOT_INSTALLED = 'not-installed',\n /** Its `./companion` door exists and could not be read; the reason is carried. */\n UNREADABLE = 'unreadable',\n /** Walked, and it ships nothing discovery reads: no provider contribution, no augmentation, no facet module. */\n CONTRIBUTES_NOTHING = 'contributes-nothing',\n /**\n * A name discovery walks by itself (`@wildo-ai/provider-*`, the engine barrel, the systems-of-record library, the\n * application's own scope named `<scope>/provider-*`). Refused rather than recorded: the listing changes nothing, and recording it would put framework code in\n * the lock as a third-party admission.\n */\n ALREADY_WALKED = 'already-walked',\n /** One of the application's own runtime packages — walked as a runtime owner, never as a provider package. */\n RUNTIME_OWNER = 'runtime-owner',\n}\n\n/** One listed package, as discovery found it (#1676). */\nexport interface ListedProviderPackage {\n readonly packageName: string;\n readonly status: ProviderPackageListingStatus;\n /** The version its installed manifest states, when it was installed. */\n readonly packageVersion?: string;\n /** Why it could not be read ({@link ProviderPackageListingStatus.UNREADABLE}). */\n readonly reason?: string;\n}\n\n/** A listed package discovery admitted (#1676) — what `config sync` prints and the provider lock records. */\nexport interface AdmittedProviderPackage {\n readonly packageName: string;\n /** Absent only when its manifest states no version. */\n readonly packageVersion?: string;\n}\n\ninterface ProviderContributionOwner {\n kind: ProviderContributionOwnerKind;\n key: string;\n packageRoot: string;\n}\n\ninterface ProviderContributionTarget extends ProviderContributionOwner {\n ownerLabel: string;\n}\n\nexport interface DiscoveredProviderCompanionContribution extends ProviderCompanionContribution {\n owner: ProviderContributionOwner;\n}\n\n/**\n * A package's declaration that it adds operations to a provider it does not own (#1672), as discovery\n * found it: the companion record plus WHO declared it and at WHICH installed version.\n *\n * Kept apart from {@link DiscoveredProviderCompanionContribution} for the reason\n * `ProviderAugmentationContributionSchema` gives: an augmentation owns nothing a contribution describes, so\n * counting it as a second contribution of the base ref would make the secrets-shape comparison treat it as a\n * second owner and let the import map pick between the two by sort order.\n *\n * `packageVersion` is the version the owner's own manifest states, read at discovery. It is what the\n * `PROVIDER_OPERATION_CALL` audit row names beside the package, so it must be the INSTALLED version rather\n * than anything the package claims about itself; absent only when the manifest states none, which\n * validation refuses for an opted-in augmentation.\n */\nexport interface DiscoveredProviderAugmentation extends ProviderAugmentationContribution {\n owner: ProviderContributionOwner;\n packageVersion?: string;\n}\n\n/**\n * An owner that DECLARES a `./companion` door and could not be read through it.\n *\n * Distinct from an owner that declares none, which is the ordinary case for most packages and is not\n * reported: the walk asks every candidate and expects most to answer nothing.\n */\nexport interface UnreadableProviderCompanionOwner {\n readonly ownerLabel: string;\n readonly packageRoot: string;\n readonly reason: string;\n}\n\nexport interface DiscoverSaasProviderCompanionContributionsResult {\n contributions: DiscoveredProviderCompanionContribution[];\n /**\n * Owners whose companion door exists and threw. EMPTY is the normal state.\n *\n * Reported because a walk that fails and a walk that finds nothing were previously the same\n * answer — both produced silence, and silence sums to a contribution COUNT (#1305). A count of\n * zero therefore read as a legitimate result rather than as a walk that failed, which is why\n * #1300 survived: a freshly scaffolded application reported 0 contributions and nothing\n * distinguished that from \"this application legitimately has no providers\".\n *\n * NOT a failure — `resolveProviderPackageTargets` argues correctly that a declared-but-uninstalled\n * package is an install problem `pnpm install` reports better than a config-sync stack trace. The\n * ask is visibility, so this is data a caller may render, not a refusal.\n */\n unreadableOwners: UnreadableProviderCompanionOwner[];\n /**\n * Every provider AUGMENTATION any walked package declares (#1672) — opted in or not. Discovery reports what\n * is INSTALLED; whether any of it applies is the application's `providers.augmentations`, which\n * {@link validateDiscoveredSaasProviderContributions} checks and {@link resolveValidatedSaasProviderContributions}\n * narrows to.\n */\n augmentations: DiscoveredProviderAugmentation[];\n /**\n * Every ADMITTED system-of-record facet module the walked packages declare (#1057, #1675, #2013):\n * `<package>/systems-of-record` for each walked package root whose manifest exports `./systems-of-record` AND\n * which is either the framework library ({@link FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE}) or a package an instance\n * names in `facetAugmentations` — see `isAdmittedSystemOfRecordFacetModule`. Sorted.\n *\n * Read from the walk's TARGETS — every package root it visited — not from its contribution RESULTS. A\n * package that ships facets or facet augmentations and NO provider contribution has no contribution to be\n * found through, and #1675's augmentation package (a partition declaration for a vendor someone else owns)\n * is exactly that package. Read from the MANIFEST, never by loading the module.\n */\n systemOfRecordFacetModules: string[];\n /**\n * Every package `providers.packages` lists (#1676), with what discovery found for it, in listing order. Empty when\n * the application lists none. Validation refuses every entry that is not\n * {@link ProviderPackageListingStatus.ADMITTED}.\n */\n listedProviderPackages: ListedProviderPackage[];\n}\n\n/**\n * The walk's validated answer: the contributions, and the augmentations the application OPTED IN (#1672).\n *\n * One object rather than the contribution array alone because both feed the same generated artifacts and the\n * same lock section, and a caller that received only the contributions would materialize an artifact that\n * silently omits every opted-in augmentation — the one-of-N call-site shape\n * `.claude/rules/invariant-call-site-enumeration.md` records.\n */\nexport interface ValidatedSaasProviderDiscovery {\n contributions: DiscoveredProviderCompanionContribution[];\n /** Only the augmentations `providers.augmentations` names — never merely installed ones. */\n augmentations: DiscoveredProviderAugmentation[];\n /** The facet modules the walk found — see {@link DiscoverSaasProviderCompanionContributionsResult.systemOfRecordFacetModules}. */\n systemOfRecordFacetModules: string[];\n /**\n * The packages `providers.packages` admitted (#1676), sorted by name — validation has already refused every listed\n * package discovery could not admit. Printed by `config sync` and recorded in the provider lock.\n */\n admittedProviderPackages: AdmittedProviderPackage[];\n /**\n * Facts `wildo config sync` REPORTS without refusing (#1725): a shared-connection member whose own OAuth2\n * client becomes inert, a vendor label that differs from its base's, a comparison that could not be made\n * from static declarations. Printed by the caller; never a reason to stop.\n */\n advisories: string[];\n}\n\n/**\n * The runtime targets an application's SCOPES imply for one provider ref.\n *\n * ## Why a package's declared targets cannot be the answer\n *\n * A provider PACKAGE is shipped once and installed by many applications, so it cannot know any of\n * their runtime topologies. Measured 2026-09-09: all 682 catalogue vendors declare\n * `[{ kind: 'backend' }]` and every engine contribution declares `backend` (plus `companion` for the\n * model-ish ones). Those are defaults standing in for an answer the package is not able to give —\n * a minion key or a worker key exists only in `wildo.saas.config.ts`.\n *\n * The consequence was latent rather than theoretical: a CATALOGUE provider scoped to a minion would\n * have failed materialization with \"no discovered contribution supplies its secret-contract shape\n * for this runtime\", because the package declares a `backend` target and the minion scope looks for\n * a `minion` one. No application had scoped one to a minion yet, so nothing had reported it.\n *\n * ## Why the scopes ARE the answer\n *\n * `providers.scopes` is where an application says which runtimes reach which provider — it is the\n * same decision, already authored, in the place the runtime artifact is built from. Measured against\n * Wonder Todos' hand-authored projections: the scopes reproduce 9 of 10 target sets EXACTLY, and the\n * tenth is a SURPLUS (a `companion` target for a provider the companion scope does not name) which\n * the artifact discards anyway, since it is built from scope INTERSECT contribution.\n *\n * So nothing is lost by deriving, and what is gained is that an application declares a provider once.\n *\n * Applies to contributions discovered from a PACKAGE. A runtime owner's own companion barrel keeps\n * whatever it declares: that is the application's own file talking about itself, and an application\n * package is entitled to state a target the scopes do not.\n *\n * ## A browser target is declared, then filtered by the scopes (#1700)\n *\n * A package CAN know one thing about a browser target: a facet's `frontendService` target names a service TYPE (the\n * application, the website, the documentation site), which is the facet's own contract. So a package contribution\n * keeps a declared `frontendService` target wherever a frontend service of that type scopes the ref, and the server\n * scopes are consulted for the server runtimes only — and only for a contribution that declares one. Deriving both\n * halves from the server scopes dropped a facet's frontend target (so no frontend scope could ever find it) and\n * gave the facet a `backend` target whenever the vendor's backend part was scoped, where it collided with that\n * part's secret contract. See {@link resolvePackageContributionRuntimeTargets}.\n */\nfunction resolveScopeImpliedRuntimeTargets(\n providerRef: string,\n saasConfig: Pick<WildoSaasConfig, 'providers'>,\n): ProviderCompanionContribution['runtimeTargets'] {\n const scopes = saasConfig.providers?.scopes;\n if (!scopes) return [];\n const targets: ProviderCompanionContribution['runtimeTargets'] = [];\n\n if (scopes.backend?.providers?.[providerRef]) targets.push({ kind: 'backend' });\n if (scopes.companion?.providers?.[providerRef]) targets.push({ kind: 'companion' });\n for (const [minionKey, scope] of Object.entries(scopes.minions ?? {})) {\n if (scope?.providers?.[providerRef]) targets.push({ kind: 'minion', minionKey });\n }\n for (const [workerKey, scope] of Object.entries(scopes.workers ?? {})) {\n if (scope?.providers?.[providerRef]) targets.push({ kind: 'worker', workerKey });\n }\n return targets;\n}\n\n/**\n * A PACKAGE contribution's runtime targets: server targets derived from the application's scopes (and none when it\n * declares no server target at all), and a declared browser target kept only where the application actually scopes\n * the ref on a frontend service of that TYPE. See {@link resolveScopeImpliedRuntimeTargets}.\n *\n * The browser half is filtered for the same reason the server half is derived: an installed package speaks for every\n * application, and a target no scope asked for is not this application's. Keeping an unscoped facet's target made\n * validation refuse `wildo config sync` for any application that installed a provider package without a service of the\n * facet's type — a backend-only application, or one with no website for a website facet.\n */\nexport function resolvePackageContributionRuntimeTargets(\n contribution: Pick<ProviderCompanionContribution, 'ref' | 'runtimeTargets'>,\n saasConfig: Pick<WildoSaasConfig, 'providers' | 'services'>,\n): ProviderCompanionContribution['runtimeTargets'] {\n const declaresServerTarget = contribution.runtimeTargets.some((target) => target.kind !== 'frontendService');\n const scopedFrontendTypes = new Set(\n Object.entries(saasConfig.providers?.scopes?.frontendServices ?? {})\n .filter(([, scope]) => scope?.providers?.[contribution.ref] !== undefined)\n .map(([serviceKey]) => saasConfig.services?.[serviceKey]?.frontendType)\n .filter((frontendType) => frontendType !== undefined),\n );\n const scopedFrontendTargets = contribution.runtimeTargets.filter(\n (target) => target.kind === 'frontendService' && scopedFrontendTypes.has(target.serviceType),\n );\n return [\n ...(declaresServerTarget ? resolveScopeImpliedRuntimeTargets(contribution.ref, saasConfig) : []),\n ...scopedFrontendTargets,\n ];\n}\n\nexport async function discoverSaasProviderCompanionContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'> & Partial<Pick<WildoSaasConfig, 'systemsOfRecord'>>;\n}): Promise<DiscoverSaasProviderCompanionContributionsResult> {\n const contributions: DiscoveredProviderCompanionContribution[] = [];\n const optedInFacetPackages = systemOfRecordFacetAugmentationPackages(input.saasConfig.systemsOfRecord);\n\n const runtimeOwnerTargets = resolveContributionTargets(input.saasRoot, input.saasConfig);\n\n const unreadableOwners: UnreadableProviderCompanionOwner[] = [];\n const augmentations: DiscoveredProviderAugmentation[] = [];\n const systemOfRecordFacetModules = new Set<string>();\n const listedPackageNames = input.saasConfig.providers?.packages ?? [];\n const packageTargets = resolveProviderPackageTargets(\n input.saasRoot,\n // Unfiltered roots, NOT `runtimeOwnerTargets` — see `resolveRuntimeOwnerPackageRoots` (#1300).\n resolveRuntimeOwnerPackageRoots(input.saasRoot, input.saasConfig),\n listedPackageNames,\n );\n /** What each walked PACKAGE target shipped, by package name — the evidence a listing's status is read from. */\n const packageFindings = new Map<string, { shipsSomething: boolean; unreadable?: string }>();\n\n for (const target of [...runtimeOwnerTargets, ...packageTargets.targets]) {\n // Before the companion door is read, so a package with facets and no companion exports is still found. Read for\n // EVERY walked target — the runtime owners included — and recorded only when admitted (#2013).\n const facetModule = readSystemOfRecordFacetModuleSpecifier(target.packageRoot);\n if (facetModule !== undefined && isAdmittedSystemOfRecordFacetModule(facetModule, optedInFacetPackages)) {\n systemOfRecordFacetModules.add(facetModule);\n }\n const isPackage = target.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE;\n if (isPackage) packageFindings.set(target.key, { shipsSomething: facetModule !== undefined });\n\n const loaded = await tryLoadRuntimeOwnerCompanionExports(target.packageRoot);\n if (loaded.unreadable !== undefined) {\n unreadableOwners.push({\n ownerLabel: target.ownerLabel,\n packageRoot: target.packageRoot,\n reason: loaded.unreadable,\n });\n if (isPackage) packageFindings.set(target.key, { shipsSomething: facetModule !== undefined, unreadable: loaded.unreadable });\n continue;\n }\n if (!loaded.exports) {\n continue;\n }\n\n const parsedContributions = ProviderCompanionContributionSchema.array().parse(\n loaded.exports.providerContributions ?? [],\n );\n if (isPackage && (parsedContributions.length > 0 || (loaded.exports.providerAugmentations ?? []).length > 0)) {\n packageFindings.set(target.key, { shipsSomething: true });\n }\n const owner = { kind: target.kind, key: target.key, packageRoot: target.packageRoot };\n const ownerVersion = readPackageVersion(target.packageRoot);\n augmentations.push(\n ...ProviderAugmentationContributionSchema.array().parse(loaded.exports.providerAugmentations ?? [])\n .map((augmentation) => ({\n ...augmentation,\n owner,\n ...(ownerVersion === undefined ? {} : { packageVersion: ownerVersion }),\n })),\n );\n\n // A PACKAGE cannot know this application's runtime topology, so its declared targets are a\n // default and the SCOPES are the answer. A runtime owner's own barrel keeps what it declares —\n // see `resolveScopeImpliedRuntimeTargets`.\n const derivesTargetsFromScopes = target.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE;\n\n contributions.push(\n ...parsedContributions.map((contribution) => ({\n ...contribution,\n runtimeTargets: derivesTargetsFromScopes\n ? resolvePackageContributionRuntimeTargets(contribution, input.saasConfig)\n : contribution.runtimeTargets,\n owner: {\n kind: target.kind,\n key: target.key,\n packageRoot: target.packageRoot,\n },\n })),\n );\n }\n\n return {\n contributions,\n unreadableOwners,\n augmentations,\n systemOfRecordFacetModules: [...systemOfRecordFacetModules].sort(),\n listedProviderPackages: listedPackageNames.map((packageName) => describeListedProviderPackage(packageName, packageTargets, packageFindings)),\n };\n}\n\n/** What discovery found for one listed package (#1676) — see {@link ProviderPackageListingStatus}. */\nfunction describeListedProviderPackage(\n packageName: string,\n packageTargets: ProviderPackageTargets,\n packageFindings: ReadonlyMap<string, { shipsSomething: boolean; unreadable?: string }>,\n): ListedProviderPackage {\n if (packageTargets.ownPackageNames.has(packageName)) return { packageName, status: ProviderPackageListingStatus.RUNTIME_OWNER };\n if (packageTargets.admittedByName(packageName)) return { packageName, status: ProviderPackageListingStatus.ALREADY_WALKED };\n if (!packageTargets.dependencyNames.has(packageName)) return { packageName, status: ProviderPackageListingStatus.NOT_A_DEPENDENCY };\n const target = packageTargets.targets.find((candidate) => candidate.key === packageName);\n if (target === undefined) return { packageName, status: ProviderPackageListingStatus.NOT_INSTALLED };\n const version = readPackageVersion(target.packageRoot);\n const versioned = version === undefined ? {} : { packageVersion: version };\n const finding = packageFindings.get(packageName);\n if (finding?.unreadable !== undefined) return { packageName, status: ProviderPackageListingStatus.UNREADABLE, reason: finding.unreadable, ...versioned };\n if (finding?.shipsSomething !== true) return { packageName, status: ProviderPackageListingStatus.CONTRIBUTES_NOTHING, ...versioned };\n return { packageName, status: ProviderPackageListingStatus.ADMITTED, ...versioned };\n}\n\n/**\n * The export a package declares to contribute system-of-record vendor facets or facet augmentations. The manifest\n * key of saas-models' `SYSTEM_OF_RECORD_FACET_MODULE_SUBPATH`, restated rather than imported so manifest discovery\n * does not load the external-data model graph to read one string; a test holds the two equal (#1675).\n */\nconst SYSTEM_OF_RECORD_FACET_SUBPATH = './systems-of-record';\n\n/**\n * Every package an instance opts into through `systemsOfRecord.<name>.facetAugmentations` — the application's OWN\n * augmentation packages, and the only ones besides {@link FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE} whose facet module\n * discovery records.\n */\nfunction systemOfRecordFacetAugmentationPackages(systemsOfRecord: WildoSaasConfig['systemsOfRecord'] | undefined): ReadonlySet<string> {\n const packages = new Set<string>();\n for (const declaration of Object.values(systemsOfRecord ?? {})) {\n for (const packageName of declaration?.facetAugmentations ?? []) packages.add(packageName);\n }\n return packages;\n}\n\n/**\n * Whether a walked package's `./systems-of-record` module may reach the provider-runtime artifact (#2013).\n *\n * A facet module is where a system of record's partition, credential kinds and dialect come from, so the modules\n * recorded decide how a tenant's rows are confined — and every one of them is IMPORTED by the backend at boot. Two\n * sources qualify, and nothing else:\n *\n * - the framework library, by its exact name — the base facets every declared instance reads;\n * - a package an instance of THIS application names in `facetAugmentations` — the application's own augmentation\n * packages. The opt-in is the admission: the package still has to be walked (named `<scope>/provider-*`, or listed\n * in `providers.packages`), and a named package discovery did not record is refused by\n * `describeUndiscoveredFacetAugmentationPackages`.\n *\n * Before #2013 any walked package exporting the subpath was recorded: the catalogue (which carried the facets), any\n * `@wildo-ai/provider-*` package, the application's own `<scope>/provider-*` copies, its runtime owners. With the\n * facets in their own library, that breadth only let a package the application never asked for present a BASE facet\n * — and a second base facet for a vendor refuses every instance of it (`FACET_BASE_CONFLICT`). Registry providers\n * copied into an application must never carry system-of-record content (#2012), so they are not admitted either.\n *\n * assurance-control: WILDO.SECURITY.FAIL_CLOSED — a facet module reaches the backend only from the framework library\n * or from a package the application's own system-of-record declaration names.\n */\nfunction isAdmittedSystemOfRecordFacetModule(facetModule: string, optedInFacetPackages: ReadonlySet<string>): boolean {\n const packageName = facetModule.slice(0, -SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1).length);\n return packageName === FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE || optedInFacetPackages.has(packageName);\n}\n\n/**\n * The facet module a package root declares — `<name>/systems-of-record` — or `undefined`. Read from the\n * MANIFEST, never by loading: a build-time consumer has no business evaluating a vendor facet to learn that\n * one exists, and loading would make discovery depend on the package compiling.\n */\nexport function readSystemOfRecordFacetModuleSpecifier(packageRoot: string): string | undefined {\n let manifest: { name?: unknown; exports?: Record<string, unknown> };\n try {\n manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf-8')) as typeof manifest;\n } catch {\n // Unreadable or absent: the companion walk already tolerates that, and a package we could not read is\n // not one we can say anything about.\n return undefined;\n }\n if (manifest.exports?.[SYSTEM_OF_RECORD_FACET_SUBPATH] === undefined) return undefined;\n if (typeof manifest.name !== 'string' || manifest.name.length === 0) return undefined;\n return `${manifest.name}${SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1)}`;\n}\n\n/**\n * Every discovered provider's COMPLIANCE PROFILE, keyed by ref (#1708) — the one door the compliance readers (the\n * evidence collector, the companion's drafting brief) learn profiles through, WITHOUT loading a provider module.\n *\n * A backend contribution's own `complianceProfile` is preferred; a frontend facet's `frontendEntry.complianceProfile`\n * (#1743) answers for a ref that has only a browser part. The first contribution that carries one wins, in discovery\n * order — the application's own runtime owners before packages — so an application shipping its own module for a\n * ref states that ref's facts. A ref whose contributions carry none is ABSENT from the map, which a reader reports as\n * \"declares no profile\", distinct from an UNDETERMINED one.\n */\nexport function providerComplianceProfilesFromContributions(\n contributions: readonly Pick<ProviderCompanionContribution, 'ref' | 'complianceProfile' | 'frontendEntry'>[],\n): Record<string, ProviderComplianceProfile> {\n const profiles: Record<string, ProviderComplianceProfile> = {};\n for (const contribution of contributions) {\n if (profiles[contribution.ref] === undefined && contribution.complianceProfile !== undefined) profiles[contribution.ref] = contribution.complianceProfile;\n }\n for (const contribution of contributions) {\n const frontendProfile = contribution.frontendEntry?.complianceProfile;\n if (profiles[contribution.ref] === undefined && frontendProfile !== undefined) profiles[contribution.ref] = frontendProfile;\n }\n return profiles;\n}\n\n/** See {@link providerComplianceProfilesFromContributions}. Discovery's unreadable owners are returned so a reader can say what it could not see. */\nexport async function resolveProviderComplianceProfiles(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>;\n}): Promise<{ profilesByProviderRef: Record<string, ProviderComplianceProfile>; unreadableOwners: UnreadableProviderCompanionOwner[] }> {\n const { contributions, unreadableOwners } = await discoverSaasProviderCompanionContributions(input);\n return { profilesByProviderRef: providerComplianceProfilesFromContributions(contributions), unreadableOwners };\n}\n\n/**\n * Walk an application's provider contributions and VALIDATE them — one step, because the two must\n * never come apart (#334).\n *\n * The walk was already shared; what was duplicated is the PAIRING. `wildo config sync` and\n * `wildo lock check` each called the walker and then, separately, the validator — and the validator\n * sits outside the walker, so a consumer that forgot it would compute a lockfile section from\n * contributions nobody had checked against the authored scope. Three correct call sites with nothing\n * making a fourth correct is the shape `.claude/rules/invariant-call-site-enumeration.md` is about.\n *\n * The caller still LOADS the config. That is deliberate rather than an omission: loading is one line\n * each caller already owns with its own error handling, it is not the part that can silently come\n * apart, and folding it in here would put the load behind a seam that the sync service's own tests\n * mock — `loadSaasConfig` mocked as a module export is not seen by a caller INSIDE this module, so\n * those tests would have had to mock this function instead and would then no longer exercise the real\n * discovery and the real validation they exist to check.\n */\nexport async function resolveValidatedSaasProviderContributions(input: {\n saasRoot: string;\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'services' | 'libraries' | 'minions' | 'providers' | 'workers' | 'systemsOfRecord'>;\n}): Promise<ValidatedSaasProviderDiscovery> {\n const { contributions, unreadableOwners, augmentations, systemOfRecordFacetModules, listedProviderPackages } = await discoverSaasProviderCompanionContributions(input);\n validateDiscoveredSaasProviderContributions({\n saasConfig: input.saasConfig,\n discoveredContributions: contributions,\n discoveredAugmentations: augmentations,\n unreadableOwners,\n listedProviderPackages,\n systemOfRecordFacetModules,\n });\n return {\n contributions,\n augmentations: selectOptedInProviderAugmentations(input.saasConfig, augmentations),\n systemOfRecordFacetModules,\n admittedProviderPackages: listedProviderPackages\n .filter((listed) => listed.status === ProviderPackageListingStatus.ADMITTED)\n .map(({ packageName, packageVersion }) => ({ packageName, ...(packageVersion === undefined ? {} : { packageVersion }) }))\n .sort((left, right) => left.packageName.localeCompare(right.packageName)),\n advisories: validateProviderSharedConnections({ saasConfig: input.saasConfig, discoveredContributions: contributions }).advisories,\n };\n}\n\n/**\n * The discovered augmentations the application names under `providers.augmentations` — the ONLY ones that may\n * reach an artifact (#1672). Installing a package decides nothing; this is where that sentence is enforced for\n * every caller, and {@link materializeSaasProviderRuntimeArtifacts} applies it again so an artifact can never be\n * built from an unfiltered list.\n *\n * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — third-party operations reach a provider's grant\n * only through the application's explicit, per-provider opt-in.\n */\nexport function selectOptedInProviderAugmentations(\n saasConfig: Pick<WildoSaasConfig, 'providers'>,\n augmentations: readonly DiscoveredProviderAugmentation[],\n): DiscoveredProviderAugmentation[] {\n const optIns = saasConfig.providers?.augmentations ?? {};\n return augmentations\n .filter((augmentation) => Object.hasOwn(optIns, augmentation.augments)\n && (optIns[augmentation.augments] ?? []).includes(augmentation.packageName))\n .sort((left, right) => left.augments.localeCompare(right.augments) || left.packageName.localeCompare(right.packageName));\n}\n\nexport function validateDiscoveredSaasProviderContributions(input: {\n saasConfig: Pick<WildoSaasConfig, 'modules' | 'providers' | 'services' | 'minions' | 'workers' | 'systemsOfRecord'>;\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n /**\n * The owners the walk could not read. They never decide the verdict — unreadable is DATA, not a\n * refusal (see `DiscoverSaasProviderCompanionContributionsResult.unreadableOwners`) — but when the\n * validation refuses anyway, they are usually WHY: their contributions are simply missing from what\n * was validated. So a refusal names them, with the reason each could not be read.\n */\n unreadableOwners?: readonly UnreadableProviderCompanionOwner[];\n /** Every augmentation the walk found (#1672); checked against `providers.augmentations`. Absent means none. */\n discoveredAugmentations?: readonly DiscoveredProviderAugmentation[];\n /** What discovery found for each package `providers.packages` lists (#1676). Absent means none were listed. */\n listedProviderPackages?: readonly ListedProviderPackage[];\n /**\n * The facet modules the walk recorded (#1675). When present, every package an instance names in\n * `systemsOfRecord.<name>.facetAugmentations` must be among them — the backend reads augmentations only from the\n * recorded modules, so an unrecorded one would refuse the boot; refusing here says so before anything starts.\n * Absent (a caller that did not run the walk) skips the check.\n */\n systemOfRecordFacetModules?: readonly string[];\n}): void {\n const { saasConfig, discoveredContributions } = input;\n const errors: string[] = [];\n errors.push(...describeRefusedProviderPackageListings(input.listedProviderPackages ?? []));\n if (input.systemOfRecordFacetModules !== undefined) {\n errors.push(...describeUndiscoveredSystemsOfRecordLibrary(saasConfig.systemsOfRecord ?? {}, input.systemOfRecordFacetModules));\n errors.push(...describeUndiscoveredFacetAugmentationPackages(saasConfig.systemsOfRecord ?? {}, input.systemOfRecordFacetModules));\n }\n const declaredModuleIds = new Set(Object.keys(saasConfig.modules ?? {}));\n const declaredServiceKeys = new Set(Object.keys(saasConfig.services ?? {}));\n const serviceKeyToFrontendType = new Map<string, string>(\n Object.entries(saasConfig.services ?? {})\n .filter(([, definition]) => definition.frontendType !== undefined)\n .map(([serviceKey, definition]) => [serviceKey, definition.frontendType as string]),\n );\n const declaredFrontendServiceKeys = new Set(serviceKeyToFrontendType.keys());\n const declaredFrontendTypes = new Set(serviceKeyToFrontendType.values());\n const declaredMinionKeys = new Set(Object.keys(saasConfig.minions ?? {}));\n const declaredWorkerKeys = new Set(Object.keys(saasConfig.workers ?? {}));\n\n for (const contribution of discoveredContributions) {\n if (contribution.sourceModuleId && !declaredModuleIds.has(contribution.sourceModuleId)) {\n errors.push(\n `${describeContribution(contribution)} references sourceModuleId \"${contribution.sourceModuleId}\" ` +\n 'but that module is not declared in wildo.saas.config.ts.',\n );\n }\n\n const dependencyNames = readRuntimeReachablePackageNames(contribution.owner.packageRoot);\n const runtimePackageName = extractPackageName(contribution.runtimeImportPath);\n if (!dependencyNames.has(runtimePackageName)) {\n errors.push(\n `${describeContribution(contribution)} declares runtimeImportPath \"${contribution.runtimeImportPath}\" ` +\n `but ${contribution.owner.kind} \"${contribution.owner.key}\" does not depend on \"${runtimePackageName}\".`,\n );\n }\n\n for (const target of contribution.runtimeTargets) {\n switch (target.kind) {\n case 'frontendService':\n if (!declaredFrontendTypes.has(target.serviceType)) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but no service with that frontendType is declared in wildo.saas.config.ts.',\n );\n } else if (!contribution.frontendEntry) {\n errors.push(\n `${describeContribution(contribution)} targets frontendType \"${target.serviceType}\" ` +\n 'but does not provide a frontendEntry payload for bootstrap materialization.',\n );\n }\n break;\n case 'minion':\n if (!declaredMinionKeys.has(target.minionKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown minion \"${target.minionKey}\".`,\n );\n }\n break;\n case 'worker':\n if (!declaredWorkerKeys.has(target.workerKey)) {\n errors.push(\n `${describeContribution(contribution)} targets unknown worker \"${target.workerKey}\".`,\n );\n }\n break;\n case 'backend':\n case 'companion':\n break;\n }\n }\n }\n\n const runtimeScopes = saasConfig.providers.scopes;\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'backend',\n providers: runtimeScopes.backend?.providers ?? {},\n matchesTarget: (target) => target.kind === 'backend',\n });\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: 'companion',\n providers: runtimeScopes.companion?.providers ?? {},\n matchesTarget: (target) => target.kind === 'companion',\n });\n\n for (const [serviceKey, scope] of Object.entries(runtimeScopes.frontendServices ?? {})) {\n if (!declaredServiceKeys.has(serviceKey)) {\n errors.push(`Provider scope references unknown frontend service \"${serviceKey}\".`);\n continue;\n }\n if (!declaredFrontendServiceKeys.has(serviceKey)) {\n errors.push(\n `Provider scope references non-frontend service \"${serviceKey}\". ` +\n 'Only services with a frontendType may appear under providers.scopes.frontendServices.',\n );\n continue;\n }\n const serviceType = serviceKeyToFrontendType.get(serviceKey);\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `frontendServices.${serviceKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'frontendService' && target.serviceType === serviceType,\n });\n }\n\n for (const [minionKey, scope] of Object.entries(runtimeScopes.minions ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `minions.${minionKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'minion' && target.minionKey === minionKey,\n });\n }\n\n for (const [workerKey, scope] of Object.entries(runtimeScopes.workers ?? {})) {\n validateRuntimeScopeAgainstDiscovery({\n errors,\n discoveredContributions,\n scopeLabel: `workers.${workerKey}`,\n providers: scope.providers,\n matchesTarget: (target) => target.kind === 'worker' && target.workerKey === workerKey,\n });\n }\n\n validateProviderAugmentationOptIns({\n errors,\n saasConfig,\n discoveredContributions,\n discoveredAugmentations: input.discoveredAugmentations ?? [],\n });\n\n errors.push(...validateProviderSharedConnections({ saasConfig, discoveredContributions }).errors);\n\n if (errors.length > 0) {\n throw new Error(\n `Provider companion-export discovery validation failed:\\n- ${errors.join('\\n- ')}`\n + describeUnreadableOwnersForRefusal(input.unreadableOwners ?? []),\n );\n }\n}\n\n/**\n * `wildo config sync`'s half of a declared shared connection (#1725): what can be decided from static\n * declarations, before anything is recorded or loaded.\n *\n * REFUSED, each naming both sides:\n * - a ref listed in two connections, or a base listed as a member (also refused by the schema; repeated here so\n * a configuration that reached discovery without passing the schema is judged by the same predicate);\n * - a runtime scope that declares a member and not its base — the base's module is what connects, refreshes\n * and revokes the grant, so a host holding only the member could spend it and never renew it;\n * - a system-of-record instance as a member or base — a system of record authenticates as the DEPLOYMENT's\n * service identity and is never a delegated grant (#1055, #1738);\n * - a base that declares no `REST_API` binding (no OAuth client to own);\n * - a member whose token endpoint can only resolve to hosts the base's cannot — a different authorization\n * server, whose refresh tokens the base's server would never honour.\n *\n * REPORTED (advisories): a member's own OAuth2 client, inert while it is a member; a vendor label that differs\n * from the base's (display only until #1673); an authorization-server comparison the static shapes cannot\n * make, which the registry repeats on the loaded modules at boot.\n *\n * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — refs are admitted to one delegated grant only\n * when they can genuinely share it.\n */\nexport function validateProviderSharedConnections(input: {\n saasConfig: Pick<WildoSaasConfig, 'providers' | 'systemsOfRecord'>;\n discoveredContributions: readonly DiscoveredProviderCompanionContribution[];\n}): { errors: string[]; advisories: string[] } {\n const errors: string[] = [];\n const advisories: string[] = [];\n const connections = input.saasConfig.providers?.sharedConnections ?? {};\n if (Object.keys(connections).length === 0) return { errors, advisories };\n\n errors.push(...findProviderSharedConnectionConflicts(connections).map((conflict) => `providers.sharedConnections: ${conflict.message}`));\n\n const scopes = input.saasConfig.providers?.scopes ?? {};\n const spendingScopes: Array<[string, Record<string, unknown> | undefined]> = [\n ['backend', scopes.backend?.providers],\n ['companion', scopes.companion?.providers],\n ...Object.entries(scopes.minions ?? {}).map(([key, scope]): [string, Record<string, unknown> | undefined] => [`minions.${key}`, scope.providers]),\n ...Object.entries(scopes.workers ?? {}).map(([key, scope]): [string, Record<string, unknown> | undefined] => [`workers.${key}`, scope.providers]),\n ];\n const systemsOfRecord = new Set(Object.keys(input.saasConfig.systemsOfRecord ?? {}));\n const contributionOf = (ref: string): DiscoveredProviderCompanionContribution | undefined =>\n input.discoveredContributions.find((contribution) => contribution.ref === ref);\n\n for (const [baseRef, connection] of Object.entries(connections).sort(([left], [right]) => left.localeCompare(right))) {\n for (const ref of [baseRef, ...connection.refs]) {\n if (systemsOfRecord.has(ref)) {\n errors.push(\n `providers.sharedConnections.\"${baseRef}\" names \"${ref}\", which is a system-of-record instance. A system of record `\n + 'authenticates as the deployment\\'s own service identity and is never a delegated connection; remove it.',\n );\n }\n }\n for (const [scopeLabel, providers] of spendingScopes) {\n if (providers === undefined) continue;\n const scopedMembers = connection.refs.filter((ref) => Object.hasOwn(providers, ref));\n if (scopedMembers.length > 0 && !Object.hasOwn(providers, baseRef)) {\n errors.push(\n `providers.scopes.${scopeLabel} declares ${scopedMembers.map((ref) => `\"${ref}\"`).join(', ')} of the shared connection \"${baseRef}\" `\n + `but not \"${baseRef}\" itself. The base's module connects, refreshes and revokes the connection's grant, so every runtime `\n + 'that spends it must load the base too; scope it there.',\n );\n }\n }\n\n const base = contributionOf(baseRef);\n if (base !== undefined && !base.protocols.includes(BUILTIN_PROVIDER_PROTOCOL.REST_API)) {\n errors.push(\n `providers.sharedConnections names \"${baseRef}\" as a base, and it declares no ${BUILTIN_PROVIDER_PROTOCOL.REST_API} binding. `\n + 'A shared connection is owned by the base\\'s connected-account OAuth2 client, which only a REST binding carries.',\n );\n continue;\n }\n for (const memberRef of connection.refs) {\n const member = contributionOf(memberRef);\n if (member === undefined || base === undefined) continue;\n const memberVendor = member.identity?.vendor;\n const baseVendor = base.identity?.vendor;\n if (memberVendor !== undefined && baseVendor !== undefined && memberVendor !== baseVendor) {\n advisories.push(\n `\"${memberRef}\" (vendor \"${memberVendor}\") is a member of the shared connection \"${baseRef}\" (vendor \"${baseVendor}\"). `\n + 'Membership is the declaration, not the vendor label, so this is reported only.',\n );\n }\n if (member.oauth2TokenEndpointHosts !== undefined) {\n advisories.push(\n `\"${memberRef}\" declares its own OAuth2 client; while it is a member of \"${baseRef}\" that client and its client-id and `\n + `client-secret slots are inert — \"${baseRef}\"'s client connects and refreshes the one grant.`,\n );\n }\n const baseHosts = base.oauth2TokenEndpointHosts;\n const memberHosts = member.oauth2TokenEndpointHosts;\n if (memberHosts === undefined) continue;\n const agrees = baseHosts === undefined ? undefined : providerOAuth2TokenEndpointHostsIntersect(baseHosts, memberHosts);\n if (agrees === false) {\n errors.push(\n `\"${memberRef}\" cannot join the shared connection \"${baseRef}\": its token endpoint resolves to `\n + `${describeTokenEndpointHosts(memberHosts)} and \"${baseRef}\"'s to ${describeTokenEndpointHosts(baseHosts!)}. `\n + 'Those are different authorization servers, and a grant one of them issued cannot be renewed by the other.',\n );\n } else if (agrees === undefined) {\n advisories.push(\n `Whether \"${memberRef}\" and \"${baseRef}\" share an authorization server cannot be decided from their declarations; `\n + 'the provider registry compares their token endpoints when the application boots.',\n );\n }\n }\n }\n return { errors, advisories };\n}\n\nfunction describeTokenEndpointHosts(hosts: { readonly exact: readonly string[]; readonly suffixes: readonly string[] }): string {\n const parts = [...hosts.exact, ...hosts.suffixes.map((suffix) => `*${suffix}`)];\n return parts.length === 0 ? '(no host)' : parts.join(', ');\n}\n\n/**\n * Keys a companion augmentation record may carry. `ProviderAugmentationContributionSchema` is LOOSE — a newer\n * producer's additive field must ride through an older consumer — so a key that belongs to the base provider\n * would pass the schema silently. These are refused by name here, at `config sync`, before anything is\n * recorded: the runtime reader refuses the same keys on the module itself, and the two refusals are\n * deliberately redundant, because the companion record is what a reviewer reads and the module is what runs.\n */\nconst BASE_OWNED_AUGMENTATION_RECORD_KEYS: Readonly<Record<string, string>> = {\n ref: 'the provider\\'s own ref (an augmentation names the base in `augments`)',\n identity: 'the provider\\'s identity',\n protocols: 'a protocol binding',\n baseUrl: 'a base URL',\n oauth2: 'an OAuth2 block',\n secretsContractShape: 'a secrets contract',\n secretsContract: 'a secrets contract',\n protocolSecretRefs: 'the secret a protocol binding reads',\n engineCapabilities: 'an engine capability',\n providerCapabilities: 'a provider capability',\n admissibleConnections: 'the connections a provider admits',\n runtimeTargets: 'the runtimes a provider reaches (an augmentation applies wherever its base is scoped)',\n frontendEntry: 'a frontend provider entry',\n};\n\n/**\n * `wildo config sync`'s half of the augmentation opt-in (#1672): every name under `providers.augmentations`\n * must be a package this walk discovered, declaring an admissible augmentation OF THAT REF, of a provider the\n * application scopes and that runs REST operations — and no two opted-in packages may add one operation id.\n *\n * Everything here is decided from STATIC declarations, without loading a line of the augmenting package: the\n * operation ids are stated in the companion record precisely so a collision is refused here rather than at the\n * first call. The runtime loader re-checks what the package actually delivers against these same ids.\n *\n * What it does NOT refuse, deliberately: an augmentation that is discovered and NOT opted in. That is the\n * ordinary state of a provider package augmenting many refs, and it contributes nothing.\n *\n * assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — admitting third-party operations to a provider's\n * grant is checked against the application's explicit opt-in before any artifact records it.\n */\nfunction validateProviderAugmentationOptIns(input: {\n errors: string[];\n saasConfig: Pick<WildoSaasConfig, 'providers'>;\n discoveredContributions: readonly DiscoveredProviderCompanionContribution[];\n discoveredAugmentations: readonly DiscoveredProviderAugmentation[];\n}): void {\n const { errors, saasConfig, discoveredContributions, discoveredAugmentations } = input;\n const optIns = saasConfig.providers?.augmentations ?? {};\n const scopes = saasConfig.providers?.scopes ?? {};\n const scopedRefs = new Set<string>([\n ...Object.keys(scopes.backend?.providers ?? {}),\n ...Object.keys(scopes.companion?.providers ?? {}),\n ...Object.values(scopes.frontendServices ?? {}).flatMap((scope) => Object.keys(scope.providers ?? {})),\n ...Object.values(scopes.minions ?? {}).flatMap((scope) => Object.keys(scope.providers ?? {})),\n ...Object.values(scopes.workers ?? {}).flatMap((scope) => Object.keys(scope.providers ?? {})),\n ]);\n\n for (const [baseRef, packageNames] of Object.entries(optIns).sort(([left], [right]) => left.localeCompare(right))) {\n if (!scopedRefs.has(baseRef)) {\n errors.push(\n `providers.augmentations names \"${baseRef}\", which no providers.scopes entry declares. An augmentation adds `\n + 'operations to a provider the application uses; scope the provider first.',\n );\n continue;\n }\n const baseContributions = discoveredContributions.filter((contribution) => contribution.ref === baseRef);\n const baseRunsRest = baseContributions.some((contribution) => contribution.protocols.includes(BUILTIN_PROVIDER_PROTOCOL.REST_API));\n if (baseContributions.length > 0 && !baseRunsRest) {\n errors.push(\n `providers.augmentations opts ${packageNames.map((name) => `\"${name}\"`).join(', ')} into \"${baseRef}\", which `\n + `declares no ${BUILTIN_PROVIDER_PROTOCOL.REST_API} binding. An augmentation's operations run through the base `\n + 'provider\\'s REST contract — its base URL and credential — so a provider without one cannot be augmented.',\n );\n }\n\n const declaredBy = new Map<string, string>();\n for (const packageName of packageNames) {\n const fromPackage = discoveredAugmentations.filter((augmentation) => augmentation.packageName === packageName\n || augmentation.owner.key === packageName);\n if (fromPackage.length === 0) {\n errors.push(describeUndiscoveredAugmentationPackage(packageName, baseRef));\n continue;\n }\n const ofThisRef = fromPackage.filter((candidate) => candidate.augments === baseRef);\n if (ofThisRef.length > 1) {\n errors.push(\n `\"${packageName}\" declares ${ofThisRef.length} augmentations of \"${baseRef}\". A package augments a provider once; `\n + 'merge them into one record so the operation set the application opts into is one list.',\n );\n continue;\n }\n const augmentation = ofThisRef[0];\n if (augmentation === undefined) {\n const augmented = [...new Set(fromPackage.map((candidate) => candidate.augments))].sort();\n errors.push(\n `providers.augmentations opts \"${packageName}\" into \"${baseRef}\", but that package augments `\n + `${augmented.map((ref) => `\"${ref}\"`).join(', ')} and not \"${baseRef}\".`,\n );\n continue;\n }\n if (augmentation.packageName !== augmentation.owner.key && augmentation.owner.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE) {\n errors.push(\n `The augmentation of \"${baseRef}\" found in package \"${augmentation.owner.key}\" names itself \"${augmentation.packageName}\". `\n + 'An augmentation\\'s packageName must be its own manifest name — it is what the audit trail attributes calls to.',\n );\n continue;\n }\n if (augmentation.packageVersion === undefined) {\n errors.push(`\"${packageName}\" (augmenting \"${baseRef}\") states no version in its package.json; the audit trail records it beside every call it contributes.`);\n }\n const base = baseContributions.find((contribution) => contribution.protocols.includes(BUILTIN_PROVIDER_PROTOCOL.REST_API));\n const baseVersionRefusal = base === undefined ? undefined : describeAugmentationBaseVersionRefusal(augmentation, base);\n if (baseVersionRefusal !== undefined) errors.push(baseVersionRefusal);\n for (const key of Object.keys(augmentation)) {\n const owned = BASE_OWNED_AUGMENTATION_RECORD_KEYS[key];\n if (owned !== undefined) {\n errors.push(\n `\"${packageName}\" declares \\`${key}\\` in its augmentation of \"${baseRef}\", which would change ${owned} — only `\n + 'the provider\\'s owner declares that; an augmentation adds operations only.',\n );\n }\n }\n for (const operationId of augmentation.operationIds) {\n const earlier = declaredBy.get(operationId);\n if (earlier !== undefined) {\n errors.push(\n `\"${earlier}\" and \"${packageName}\" both add operation '${operationId}' to \"${baseRef}\". An operation id names `\n + 'one request; opt in only one of them.',\n );\n }\n declaredBy.set(operationId, packageName);\n }\n }\n }\n}\n\n/**\n * The package that ships a base provider, and its installed version when the walk read that package itself (#1672,\n * #1731). The version is `undefined` for a base an application's own runtime package contributes, which has no\n * installed version to hold an augmentation to.\n */\nexport function resolveProviderBasePackage(base: DiscoveredProviderCompanionContribution): { basePackageName: string; basePackageVersion?: string } {\n const importPath = base.runtimeImportPath;\n const basePackageName = importPath.startsWith('@') ? importPath.split('/').slice(0, 2).join('/') : importPath.split('/')[0]!;\n const basePackageVersion = base.owner.kind === ProviderContributionOwnerKind.PROVIDER_PACKAGE && base.owner.key === basePackageName\n ? readPackageVersion(base.owner.packageRoot)\n : undefined;\n return { basePackageName, ...(basePackageVersion === undefined ? {} : { basePackageVersion }) };\n}\n\n/**\n * The refusal, if any, of an opted-in augmentation whose peer range on its base's package does not admit the\n * installed base (#1731).\n *\n * An augmentation's operations run on the base provider's base URL, credential and operation-id namespace, all of\n * which move with the package that ships the base — for an engine ref, the engine. So the augmenting package states\n * the base versions it was written against the way npm states any such requirement: a `peerDependencies` range on\n * that package. Versioning stays at publication; there is no in-code compatibility table.\n *\n * - A range the installed version does not satisfy is refused, naming the augmentation, the range and the version.\n * - A MISSING range is refused too: an augmentation that says nothing about its base cannot be held to one, and an\n * engine upgrade would break it with nothing reporting it — the very failure this exists to catch.\n * - A range this reader cannot parse is refused rather than guessed.\n * - A `workspace:` range is admitted: inside one workspace the peer IS the linked base, whatever its version.\n * - A base with no installed version (an application's own runtime package) cannot be checked, and is not.\n *\n * assurance-control: WILDO.SECURITY.FAIL_CLOSED — third-party operations reach a provider's grant only when the\n * package declares, and the installed base satisfies, the base version it was written against.\n */\nfunction describeAugmentationBaseVersionRefusal(\n augmentation: DiscoveredProviderAugmentation,\n base: DiscoveredProviderCompanionContribution,\n): string | undefined {\n const { basePackageName, basePackageVersion } = resolveProviderBasePackage(base);\n if (basePackageVersion === undefined) return undefined;\n if (augmentation.owner.kind !== ProviderContributionOwnerKind.PROVIDER_PACKAGE || augmentation.owner.key === basePackageName) return undefined;\n const subject = `\"${augmentation.packageName}\" (augmenting \"${augmentation.augments}\")`;\n const range = readPeerDependencyRange(augmentation.owner.packageRoot, basePackageName);\n if (range === undefined) {\n return `${subject} declares no peerDependencies range on \"${basePackageName}\", the package that ships its base (installed `\n + `${basePackageVersion}). An augmentation states the base versions it was written against as a peer range, so an `\n + 'upgrade of the base cannot break it silently; add one to its package.json.';\n }\n if (range.startsWith('workspace:')) return undefined;\n const satisfied = satisfiesNpmVersionRange(basePackageVersion, range);\n if (satisfied === true) return undefined;\n if (satisfied === undefined) {\n return `${subject} declares the peer range \"${range}\" on \"${basePackageName}\", which cannot be read as an npm version range.`;\n }\n return `${subject} requires \"${basePackageName}\" ${range}, and ${basePackageVersion} is installed. Upgrade the augmenting `\n + `package to a version written against ${basePackageVersion}, or remove it from providers.augmentations.`;\n}\n\n/** The `peerDependencies` range a package's manifest states for `dependencyName`, or `undefined`. */\nfunction readPeerDependencyRange(packageRoot: string, dependencyName: string): string | undefined {\n try {\n const manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf-8')) as { peerDependencies?: Record<string, unknown> };\n const range = manifest.peerDependencies?.[dependencyName];\n return typeof range === 'string' ? range : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Why an opted-in package was not found, pointing at the right remedy: a package outside `@wildo-ai` and the\n * application's own scope is walked only when `providers.packages` lists it (#1676), while an own-scope package is\n * walked under the `<scope>/provider-` naming convention (or by being listed too).\n */\nfunction describeUndiscoveredAugmentationPackage(packageName: string, baseRef: string): string {\n const scope = packageName.startsWith('@') ? packageName.split('/')[0] : undefined;\n const prefix = `providers.augmentations opts \"${packageName}\" into \"${baseRef}\", but discovery found no augmentation from that package.`;\n if (scope === undefined || scope === '@wildo-ai') {\n return `${prefix} Check that it is a dependency of a runtime owner, is installed, and exports \\`providerAugmentations\\` from its \\`./companion\\` door.`;\n }\n return `${prefix} Discovery walks \\`@wildo-ai/provider-*\\`, the engine barrel and packages named `\n + `\\`<application-scope>/provider-*\\` by themselves; any other package is walked only when \\`providers.packages\\` lists it. `\n + `List \"${packageName}\" there, and make it a dependency of a runtime owner.`;\n}\n\n/**\n * The part of a refusal that says the walk was INCOMPLETE, or nothing when it was not.\n *\n * Measured 2026-09-24 (#1558): Wonder CRM's frontend companion could not be loaded — its injected\n * engine snapshot was missing a file — so it contributed nothing, and the refusal said only\n * `Provider \"sentry\" is authored in scope \"frontendServices.app\" but no companion export contributes\n * it`. That names the CATALOGUE; the cause was a LOAD. The first diagnosis recorded it as a provider\n * decision. Naming the unreadable owner and its reason beside the refusal points at the real remedy.\n */\nfunction describeUnreadableOwnersForRefusal(unreadableOwners: readonly UnreadableProviderCompanionOwner[]): string {\n if (unreadableOwners.length === 0) return '';\n return '\\nThese runtime owners could not be READ, so anything they contribute is missing above — '\n + 'repair the load before concluding a provider is uncontributed:\\n- '\n + unreadableOwners.map((owner) => `${owner.ownerLabel} (${owner.packageRoot}): ${owner.reason}`).join('\\n- ');\n}\n\n/**\n * Every runtime owner's package root, UNFILTERED — the roots a provider PACKAGE may be declared in.\n *\n * Distinct from {@link resolveContributionTargets} on purpose, and the distinction is the whole of\n * issue #1300. That function answers \"whose own companion exports should we LOAD\", and it correctly\n * skips an owner with nothing scoped to it: such an owner contributes nothing relevant. This one\n * answers \"whose MANIFEST may name a provider package\", and for that question the scopes are not\n * evidence — a manifest declares `@wildo-ai/external-connectors-private` whether or not the\n * application has yet scoped anything from it.\n *\n * Reusing the filtered set for both made provider discovery CIRCULAR: a backend service entered the\n * search only when `providers.scopes.backend` already had providers, so a freshly scaffolded\n * application — whose scopes are all empty — searched only its root manifest, found no provider\n * package, discovered ZERO contributions, and refused every provider it tried to scope with\n * \"no companion export contributes it for that runtime\". Scoping a provider required having already\n * scoped one. Measured on a fresh application: 0 contributions with empty scopes, 23 the moment one\n * provider was added to the backend scope, from the same manifests and the same installed packages.\n *\n * The cost of not filtering is reading a few more `package.json` files; `resolveProviderPackageTargets`\n * de-duplicates by resolved package root and skips what it cannot resolve.\n */\nfunction resolveRuntimeOwnerPackageRoots(\n saasRoot: string,\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'workers'>,\n): string[] {\n return [\n ...Object.values(saasConfig.services),\n ...Object.values(saasConfig.libraries ?? {}),\n ...Object.values(saasConfig.minions ?? {}),\n ...Object.values(saasConfig.workers ?? {}),\n ].map((definition) => resolve(saasRoot, definition.path));\n}\n\nfunction resolveContributionTargets(\n saasRoot: string,\n saasConfig: Pick<WildoSaasConfig, 'services' | 'libraries' | 'minions' | 'providers' | 'workers'>,\n): ProviderContributionTarget[] {\n const shouldIncludeBackendServices = hasAnyProviders(saasConfig.providers.scopes.backend?.providers);\n const frontendServiceProviderScopes = Object.entries(saasConfig.providers.scopes.frontendServices ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([serviceKey]) => serviceKey);\n const minionProviderScopes = Object.entries(saasConfig.providers.scopes.minions ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([minionKey]) => minionKey);\n const workerProviderScopes = Object.entries(saasConfig.providers.scopes.workers ?? {})\n .filter(([, scope]) => hasAnyProviders(scope.providers))\n .map(([workerKey]) => workerKey);\n\n return [\n ...Object.entries(saasConfig.services)\n .filter(([key, definition]) => (\n definition.frontendType\n ? frontendServiceProviderScopes.includes(key)\n : shouldIncludeBackendServices\n ))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.SERVICE,\n key,\n ownerLabel: `service \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.libraries ?? {}).map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.LIBRARY,\n key,\n ownerLabel: `library \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.minions ?? {})\n .filter(([key]) => minionProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.MINION,\n key,\n ownerLabel: `minion \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ...Object.entries(saasConfig.workers ?? {})\n .filter(([key]) => workerProviderScopes.includes(key))\n .map(([key, definition]) => ({\n kind: ProviderContributionOwnerKind.WORKER,\n key,\n ownerLabel: `worker \"${key}\"`,\n packageRoot: resolve(saasRoot, definition.path),\n })),\n ];\n}\n\n/**\n * Every provider PACKAGE this application depends on, as a contribution target.\n *\n * Candidates come from the application root manifest AND from each runtime owner's manifest, because\n * both layouts are real: a scaffolded application declares its provider packages in the runtime owner\n * that imports them (`backend-api`), while a workspace root may hoist them. The union is deduplicated\n * by resolved package root, so a package declared in both places is walked once.\n *\n * A candidate that cannot be resolved on disk is SKIPPED rather than refused. The manifest is the\n * declaration and `node_modules` is the install; a name declared but not installed is an install\n * problem that `pnpm install` reports far better than a config-sync stack trace would, and refusing\n * here would make `wildo config sync` unrunnable in exactly the state where an operator runs it to\n * find out what is wrong.\n */\nfunction resolveProviderPackageTargets(\n saasRoot: string,\n runtimeOwnerPackageRoots: string[],\n listedPackageNames: readonly string[],\n): ProviderPackageTargets {\n const prefixes = resolveProviderPackagePrefixes(saasRoot);\n const searchRoots = [saasRoot, ...runtimeOwnerPackageRoots];\n const listed = new Set(listedPackageNames);\n const admittedByName = (dependencyName: string): boolean => dependencyName === FRAMEWORK_ENGINE_PROVIDER_PACKAGE\n || dependencyName === FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE\n || prefixes.some((prefix) => dependencyName.startsWith(prefix));\n // A search root's OWN name is in the set `readRuntimeReachablePackageNames` answers, and is never a dependency.\n const ownPackageNames = new Set(searchRoots.map((root) => readPackageName(root)).filter((name): name is string => name !== undefined));\n\n const candidateNames = new Set<string>();\n const dependencyNames = new Set<string>();\n for (const searchRoot of searchRoots) {\n for (const dependencyName of readRuntimeReachablePackageNames(searchRoot)) {\n dependencyNames.add(dependencyName);\n /*\n * assurance-control: WILDO.SECURITY.FAIL_CLOSED — a dependency is EXECUTED by this walk only when it carries a\n * framework name, the application's own `<scope>/provider-*` name, or the application LISTS it in `providers.packages` (#1676).\n * Installing a package from somebody else's scope admits nothing; the listing is reviewable in\n * `wildo.saas.config.ts`, and every admitted package is printed by `config sync` and recorded in the lock.\n */\n if (admittedByName(dependencyName) || (listed.has(dependencyName) && !ownPackageNames.has(dependencyName))) {\n candidateNames.add(dependencyName);\n }\n }\n }\n\n const targetsByRoot = new Map<string, ProviderContributionTarget>();\n for (const packageName of [...candidateNames].sort()) {\n const packageRoot = resolveProviderPackageRoot(packageName, searchRoots);\n if (!packageRoot || targetsByRoot.has(packageRoot)) {\n continue;\n }\n targetsByRoot.set(packageRoot, {\n kind: ProviderContributionOwnerKind.PROVIDER_PACKAGE,\n key: packageName,\n ownerLabel: `provider package \"${packageName}\"`,\n packageRoot,\n });\n }\n\n return { targets: [...targetsByRoot.values()], dependencyNames, ownPackageNames, admittedByName };\n}\n\n/** The walked provider packages, and what a listing is checked against. */\ninterface ProviderPackageTargets {\n readonly targets: ProviderContributionTarget[];\n /** Every name the search roots' manifests answer, their own names included. */\n readonly dependencyNames: ReadonlySet<string>;\n /** The application root's and the runtime owners' own package names. */\n readonly ownPackageNames: ReadonlySet<string>;\n /** Whether discovery walks this name without a listing. */\n readonly admittedByName: (packageName: string) => boolean;\n}\n\n/**\n * The refusal for an application that declares system-of-record instances and whose walk did not record the framework\n * library's facet module (#2013) — the library is declared but not installed, or not declared at all.\n *\n * Refused here, at sync, because the alternative is worse and later: an artifact without the library's module boots a\n * backend that refuses every instance whose vendor only the library describes (`VENDOR_HAS_NO_FACET`), and `wildo\n * secrets` cannot list those instances' credential slots. The remedy needs no running process: `wildo config sync`\n * declares the library on the backend service and links it (`declareSystemsOfRecordLibrary` in the CLI), and a\n * `pnpm install` installs it.\n */\nfunction describeUndiscoveredSystemsOfRecordLibrary(\n systemsOfRecord: NonNullable<WildoSaasConfig['systemsOfRecord']>,\n facetModules: readonly string[],\n): string[] {\n const instances = Object.keys(systemsOfRecord);\n if (instances.length === 0) return [];\n if (facetModules.includes(`${FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE}${SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1)}`)) return [];\n return [\n `systemsOfRecord declares ${instances.map((name) => `\"${name}\"`).join(', ')}, and ${FRAMEWORK_SYSTEMS_OF_RECORD_PACKAGE} — the vendor `\n + 'facets every instance reads — was not discovered. `wildo config sync` declares it on the backend service; run your package '\n + \"manager's install (pnpm install), then run `wildo config sync` again.\",\n ];\n}\n\n/**\n * One refusal per package an instance opts into (`facetAugmentations`) whose facet module the walk did not record\n * (#1675) — the sentence the backend's resolver refuses the boot with, said at sync instead.\n */\nfunction describeUndiscoveredFacetAugmentationPackages(\n systemsOfRecord: NonNullable<WildoSaasConfig['systemsOfRecord']>,\n facetModules: readonly string[],\n): string[] {\n const recordedPackages = new Set(facetModules.map((specifier) => (specifier.endsWith(SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1))\n ? specifier.slice(0, -SYSTEM_OF_RECORD_FACET_SUBPATH.slice(1).length)\n : specifier)));\n const refusals: string[] = [];\n for (const [name, declaration] of Object.entries(systemsOfRecord)) {\n for (const packageName of declaration.facetAugmentations ?? []) {\n if (!recordedPackages.has(packageName)) {\n refusals.push(`systemsOfRecord.${name}.facetAugmentations names ${packageName}: ${SYSTEM_OF_RECORD_FACET_MODULE_NOT_DISCOVERED}.`);\n }\n }\n }\n return refusals;\n}\n\n/** One refusal per listed package discovery could not admit (#1676), each naming the package and the remedy. */\nfunction describeRefusedProviderPackageListings(listed: readonly ListedProviderPackage[]): string[] {\n const refusals: string[] = [];\n for (const entry of listed) {\n const subject = `providers.packages lists \"${entry.packageName}\"`;\n switch (entry.status) {\n case ProviderPackageListingStatus.ADMITTED:\n break;\n case ProviderPackageListingStatus.NOT_A_DEPENDENCY:\n refusals.push(`${subject}, but neither the application root nor any runtime owner depends on it — add it to the `\n + 'package.json of the runtime that uses it (usually backend-api), or remove the listing.');\n break;\n case ProviderPackageListingStatus.NOT_INSTALLED:\n refusals.push(`${subject}, which is declared as a dependency and is not installed — run your package manager's install.`);\n break;\n case ProviderPackageListingStatus.UNREADABLE:\n refusals.push(`${subject}, whose companion entry could not be read (${entry.reason ?? 'unknown error'}).`);\n break;\n case ProviderPackageListingStatus.ALREADY_WALKED:\n refusals.push(`${subject}, which discovery walks by name already — remove the listing; \\`providers.packages\\` is for `\n + 'a package discovery does not walk by itself: one from another scope, or one of the application\\'s own scope '\n + 'not named `<scope>/provider-*`.');\n break;\n case ProviderPackageListingStatus.RUNTIME_OWNER:\n refusals.push(`${subject}, which is one of this application's own runtime packages — it is walked as a runtime owner, `\n + 'not as a provider package; remove the listing.');\n break;\n case ProviderPackageListingStatus.CONTRIBUTES_NOTHING:\n refusals.push(`${subject}, which ships no provider contribution, no provider augmentation and no ./systems-of-record `\n + 'module — it is not a provider package, or the wrong package is listed.');\n break;\n }\n }\n return refusals;\n}\n\n/**\n * The framework prefix, plus the application's own scope when its root manifest has one.\n *\n * Deriving the second from the root package name rather than reading it from configuration keeps the\n * \"one declaration\" promise of #330 intact: installing `@acme/provider-thing` in an `@acme` application\n * and scoping the ref is the whole of it — there is no third place to remember.\n */\nfunction resolveProviderPackagePrefixes(saasRoot: string): string[] {\n const prefixes = [FRAMEWORK_PROVIDER_PACKAGE_PREFIX];\n const rootPackageName = readPackageName(saasRoot);\n const scope = rootPackageName?.startsWith('@') ? rootPackageName.split('/')[0] : undefined;\n if (scope && scope !== '@wildo-ai') {\n prefixes.push(`${scope}/provider-`);\n }\n return prefixes;\n}\n\n/**\n * Locate an installed package's ROOT DIRECTORY, which is what the companion-entry resolver needs.\n *\n * The direct `node_modules` probe comes first because it is what pnpm actually produces — a symlink\n * per importer — and because it works for a package whose `exports` map declares no `./package.json`,\n * which `require.resolve` cannot see past. `createRequire` is the fallback for hoisted or otherwise\n * unusual layouts; it resolves the companion subpath (the one door every provider package declares)\n * and walks up to the manifest that names the package.\n */\nfunction resolveProviderPackageRoot(packageName: string, searchRoots: string[]): string | undefined {\n /*\n * The name comes from a manifest and is spliced into a filesystem path, so a segment that is `.` or\n * `..` would walk OUT of `node_modules` — and the prefix gate would not stop it, since\n * `@wildo-ai/provider-x/../../elsewhere` starts with the framework prefix. npm forbids such a name,\n * which is precisely why nothing downstream would question it; the check costs one line and is the\n * only thing standing between an authored dependency name and an arbitrary directory whose\n * companion entry this walk EXECUTES.\n */\n const segments = packageName.split('/');\n if (segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {\n return undefined;\n }\n\n for (const searchRoot of searchRoots) {\n const candidate = join(searchRoot, 'node_modules', ...segments);\n if (existsSync(join(candidate, 'package.json'))) {\n return candidate;\n }\n }\n\n for (const searchRoot of searchRoots) {\n try {\n const resolved = createRequire(join(searchRoot, 'package.json')).resolve(`${packageName}/companion`);\n let directory = dirname(resolved);\n while (directory !== dirname(directory)) {\n if (readPackageName(directory) === packageName) {\n return directory;\n }\n directory = dirname(directory);\n }\n } catch {\n // Not resolvable from this root; try the next one, then give up quietly (see the JSDoc above).\n }\n }\n\n return undefined;\n}\n\n/** The installed version a package's own manifest states, or `undefined` when it states none or is unreadable. */\nexport function readPackageVersion(packageRoot: string): string | undefined {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return undefined;\n }\n try {\n const version = (JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { version?: unknown }).version;\n return typeof version === 'string' && version.length > 0 ? version : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction readPackageName(packageRoot: string): string | undefined {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return undefined;\n }\n try {\n return (JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as { name?: string }).name;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Read one owner's companion barrel, separating the two answers that used to look identical.\n *\n * - `{ exports: undefined }` — the package declares no `./companion` door. Ordinary: most packages\n * do not, and the walk asks everything it can reach.\n * - `{ unreadable }` — the door EXISTS and reading it threw. A broken or unbuilt install, not an\n * absence, and the one case worth telling somebody about.\n */\nasync function tryLoadRuntimeOwnerCompanionExports(\n packageRoot: string,\n): Promise<{ exports?: RuntimeOwnerCompanionExports; unreadable?: string }> {\n try {\n resolvePackageCompanionEntryPath(packageRoot);\n } catch {\n return {};\n }\n\n try {\n return { exports: await loadPackageCompanionExport<RuntimeOwnerCompanionExports>(packageRoot) };\n } catch (error) {\n return { unreadable: describeCaughtError(error) };\n }\n}\n\nfunction validateRuntimeScopeAgainstDiscovery(input: {\n errors: string[];\n discoveredContributions: DiscoveredProviderCompanionContribution[];\n scopeLabel: string;\n providers: NonNullable<WildoSaasConfig['providers']['scopes']['backend']>['providers'];\n matchesTarget: (target: ProviderCompanionRuntimeTarget) => boolean;\n}): void {\n const { errors, discoveredContributions, matchesTarget, providers, scopeLabel } = input;\n\n for (const [providerRef, authoredSelection] of Object.entries(providers)) {\n const matchingContributions = discoveredContributions.filter(\n (contribution) => contribution.ref === providerRef\n && contribution.runtimeTargets.some(matchesTarget),\n );\n\n if (matchingContributions.length === 0) {\n errors.push(\n `Provider \"${providerRef}\" is authored in scope \"${scopeLabel}\" but no companion export contributes it for that runtime.`,\n );\n continue;\n }\n\n const claimedTwice = describeProviderRefClaimedByMoreThanOneImportPath(providerRef, `scope \"${scopeLabel}\"`, matchingContributions);\n if (claimedTwice !== undefined) errors.push(claimedTwice);\n\n const discoveredEngineCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.engineCapabilities),\n );\n const discoveredProviderCapabilities = new Set(\n matchingContributions.flatMap((contribution) => contribution.providerCapabilities),\n );\n const discoveredProtocols = new Set(\n matchingContributions.flatMap((contribution) => contribution.protocols),\n );\n\n for (const capability of authoredSelection.engineCapabilities) {\n if (!discoveredEngineCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares engine capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const capability of authoredSelection.providerCapabilities) {\n if (!discoveredProviderCapabilities.has(capability)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares provider capability \"${capability}\" ` +\n 'but discovery does not report that capability for the same runtime.',\n );\n }\n }\n\n for (const protocol of authoredSelection.protocols) {\n if (!discoveredProtocols.has(protocol)) {\n errors.push(\n `Provider \"${providerRef}\" in scope \"${scopeLabel}\" declares protocol \"${protocol}\" ` +\n 'but discovery does not report that protocol for the same runtime.',\n );\n }\n }\n }\n}\n\n/**\n * The refusal for one provider ref claimed, for ONE runtime, through more than one import path (#2014, epic #2012).\n * `undefined` when the contributions agree.\n *\n * A runtime loads one module per ref, from the path its provider artifact records. When two packages contribute\n * the same ref for the same runtime, that path used to be the alphabetically first — so a second package contributing\n * a ref the application's own copy (`@<app>/provider-asana`) also contributes decided silently which module loaded.\n * The case that motivated it (#2014) was a leftover install of the since-archived catalogue, whose `asana` subpath\n * sorted first; the same holds for any framework `@wildo-ai/provider-<ref>` package installed beside the copy.\n *\n * Scoped to one runtime on purpose: the same ref legitimately has one path per FACET — `posthog` is\n * `@wildo-ai/external-connectors-public/app` for the SaaS frontend and `@wildo-ai/external-connectors-private/backend`\n * for the backend. Measured 2026-09-29 over Wonder Todos and Wonder CRM: six refs have several paths, and no ref has\n * two for the same runtime.\n *\n * Shared by discovery validation (`wildo config sync`, `wildo lock check`) and the artifact builder, so the two\n * cannot disagree about what counts as a second claimant.\n */\nexport function describeProviderRefClaimedByMoreThanOneImportPath(\n providerRef: string,\n runtimeLabel: string,\n contributions: readonly DiscoveredProviderCompanionContribution[],\n): string | undefined {\n const ownersByPath = new Map<string, Set<string>>();\n for (const contribution of contributions) {\n if (contribution.ref !== providerRef) continue;\n const owners = ownersByPath.get(contribution.runtimeImportPath) ?? new Set<string>();\n owners.add(`${contribution.owner.kind} \"${contribution.owner.key}\"`);\n ownersByPath.set(contribution.runtimeImportPath, owners);\n }\n if (ownersByPath.size <= 1) return undefined;\n const claims = [...ownersByPath]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([path, owners]) => `\"${path}\" (reached through ${[...owners].sort().join(', ')})`)\n .join(' and ');\n return `Provider \"${providerRef}\" is claimed for ${runtimeLabel} through more than one import path: ${claims}. `\n + 'A runtime loads one module per ref, so it cannot pick one. Keep one: uninstall the package that should not '\n + 'provide it, or remove its dependency from that runtime.';\n}\n\nfunction describeContribution(contribution: DiscoveredProviderCompanionContribution): string {\n return `Provider contribution \"${contribution.ref}\" from ${contribution.owner.kind} \"${contribution.owner.key}\"`;\n}\n\nfunction readRuntimeReachablePackageNames(packageRoot: string): Set<string> {\n const packageJsonPath = join(packageRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n return new Set<string>();\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n dependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n };\n\n return new Set([\n ...(packageJson.name ? [packageJson.name] : []),\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ...Object.keys(packageJson.optionalDependencies ?? {}),\n ]);\n}\n\nfunction extractPackageName(importPath: string): string {\n if (importPath.startsWith('@')) {\n const [scope, pkg] = importPath.split('/');\n return `${scope}/${pkg}`;\n }\n return importPath.split('/')[0] ?? importPath;\n}\n\nfunction hasAnyProviders(\n providers: Record<string, unknown> | undefined,\n): boolean {\n return Boolean(providers && Object.keys(providers).length > 0);\n}\n"]}