@wildo-ai/wildo-cli 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/src/commands/context/__tests__/assurance-basis.command.test.d.ts +2 -0
  2. package/dist/src/commands/context/__tests__/assurance-basis.command.test.d.ts.map +1 -0
  3. package/dist/src/commands/context/__tests__/assurance-basis.command.test.js +63 -0
  4. package/dist/src/commands/context/__tests__/assurance-basis.command.test.js.map +1 -0
  5. package/dist/src/commands/context/assurance-basis.command.d.ts +61 -0
  6. package/dist/src/commands/context/assurance-basis.command.d.ts.map +1 -0
  7. package/dist/src/commands/context/assurance-basis.command.js +166 -0
  8. package/dist/src/commands/context/assurance-basis.command.js.map +1 -0
  9. package/dist/src/commands/dev/charts-audit.command.d.ts +5 -3
  10. package/dist/src/commands/dev/charts-audit.command.d.ts.map +1 -1
  11. package/dist/src/commands/dev/charts-audit.command.js +35 -6
  12. package/dist/src/commands/dev/charts-audit.command.js.map +1 -1
  13. package/dist/src/commands/fwk/generate-providers.command.d.ts.map +1 -1
  14. package/dist/src/commands/fwk/generate-providers.command.js +18 -2
  15. package/dist/src/commands/fwk/generate-providers.command.js.map +1 -1
  16. package/dist/src/commands/generate/email-preview.command.d.ts +8 -0
  17. package/dist/src/commands/generate/email-preview.command.d.ts.map +1 -1
  18. package/dist/src/commands/generate/email-preview.command.js +57 -0
  19. package/dist/src/commands/generate/email-preview.command.js.map +1 -1
  20. package/dist/src/commands/init.command.d.ts.map +1 -1
  21. package/dist/src/commands/init.command.js +32 -0
  22. package/dist/src/commands/init.command.js.map +1 -1
  23. package/dist/src/commands/lock/check.command.d.ts.map +1 -1
  24. package/dist/src/commands/lock/check.command.js +3 -2
  25. package/dist/src/commands/lock/check.command.js.map +1 -1
  26. package/dist/src/commands/registry/login.command.d.ts.map +1 -1
  27. package/dist/src/commands/registry/login.command.js +2 -0
  28. package/dist/src/commands/registry/login.command.js.map +1 -1
  29. package/dist/src/commands/registry/publish.command.d.ts.map +1 -1
  30. package/dist/src/commands/registry/publish.command.js +2 -0
  31. package/dist/src/commands/registry/publish.command.js.map +1 -1
  32. package/dist/src/commands/registry/registry-transport.constants.d.ts +33 -0
  33. package/dist/src/commands/registry/registry-transport.constants.d.ts.map +1 -0
  34. package/dist/src/commands/registry/registry-transport.constants.js +33 -0
  35. package/dist/src/commands/registry/registry-transport.constants.js.map +1 -0
  36. package/dist/src/commands/registry/whoami.command.d.ts.map +1 -1
  37. package/dist/src/commands/registry/whoami.command.js +2 -0
  38. package/dist/src/commands/registry/whoami.command.js.map +1 -1
  39. package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.d.ts +2 -0
  40. package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.d.ts.map +1 -0
  41. package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.js +146 -0
  42. package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.js.map +1 -0
  43. package/dist/src/modules/domain/credentials/approver-user.module.d.ts +85 -0
  44. package/dist/src/modules/domain/credentials/approver-user.module.d.ts.map +1 -0
  45. package/dist/src/modules/domain/credentials/approver-user.module.js +92 -0
  46. package/dist/src/modules/domain/credentials/approver-user.module.js.map +1 -0
  47. package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts +2 -0
  48. package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts.map +1 -0
  49. package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js +111 -0
  50. package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js.map +1 -0
  51. package/dist/src/services/application/__tests__/provider-package-links.service.test.js +68 -0
  52. package/dist/src/services/application/__tests__/provider-package-links.service.test.js.map +1 -1
  53. package/dist/src/services/application/app-bootstrap.service.d.ts +9 -0
  54. package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
  55. package/dist/src/services/application/app-bootstrap.service.js +30 -1
  56. package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
  57. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +6 -0
  58. package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
  59. package/dist/src/services/application/application-runtime-bootstrap.service.js +41 -0
  60. package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
  61. package/dist/src/services/application/provider-package-links.service.d.ts +30 -0
  62. package/dist/src/services/application/provider-package-links.service.d.ts.map +1 -1
  63. package/dist/src/services/application/provider-package-links.service.js +35 -3
  64. package/dist/src/services/application/provider-package-links.service.js.map +1 -1
  65. package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
  66. package/dist/src/services/application/provider-runtime-sync.service.js +4 -3
  67. package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
  68. package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
  69. package/dist/src/services/application/saas-skeleton.service.js +22 -2
  70. package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
  71. package/dist/src/services/companion/workbench-cli.service.js +10 -1
  72. package/dist/src/services/companion/workbench-cli.service.js.map +1 -1
  73. package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.d.ts +2 -0
  74. package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.d.ts.map +1 -0
  75. package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.js +94 -0
  76. package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.js.map +1 -0
  77. package/dist/src/services/credentials/ci-secrets-adapter.service.d.ts.map +1 -1
  78. package/dist/src/services/credentials/ci-secrets-adapter.service.js +16 -0
  79. package/dist/src/services/credentials/ci-secrets-adapter.service.js.map +1 -1
  80. package/dist/src/services/credentials/composed-provider-catalogue.d.ts +34 -0
  81. package/dist/src/services/credentials/composed-provider-catalogue.d.ts.map +1 -1
  82. package/dist/src/services/credentials/composed-provider-catalogue.js +35 -0
  83. package/dist/src/services/credentials/composed-provider-catalogue.js.map +1 -1
  84. package/dist/src/services/credentials/credentials.schemas.d.ts +27 -0
  85. package/dist/src/services/credentials/credentials.schemas.d.ts.map +1 -1
  86. package/dist/src/services/credentials/credentials.schemas.js +50 -0
  87. package/dist/src/services/credentials/credentials.schemas.js.map +1 -1
  88. package/dist/src/services/credentials/framework-managed-secrets.d.ts +1 -1
  89. package/dist/src/services/credentials/framework-managed-secrets.d.ts.map +1 -1
  90. package/dist/src/services/credentials/framework-managed-secrets.js +49 -8
  91. package/dist/src/services/credentials/framework-managed-secrets.js.map +1 -1
  92. package/dist/src/services/deployment/infra-writer.service.d.ts.map +1 -1
  93. package/dist/src/services/deployment/infra-writer.service.js +23 -4
  94. package/dist/src/services/deployment/infra-writer.service.js.map +1 -1
  95. package/dist/src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.js +45 -2
  96. package/dist/src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.js.map +1 -1
  97. package/dist/src/services/deployment/k8s/k8s-bootstrap.service.d.ts +23 -0
  98. package/dist/src/services/deployment/k8s/k8s-bootstrap.service.d.ts.map +1 -1
  99. package/dist/src/services/deployment/k8s/k8s-bootstrap.service.js +49 -6
  100. package/dist/src/services/deployment/k8s/k8s-bootstrap.service.js.map +1 -1
  101. package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
  102. package/dist/src/services/environment/env-vars-builder.service.js +19 -0
  103. package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
  104. package/dist/src/services/framework/__tests__/engine-provider-specifications.reconciliation.test.js +8 -0
  105. package/dist/src/services/framework/__tests__/engine-provider-specifications.reconciliation.test.js.map +1 -1
  106. package/dist/src/services/framework/__tests__/framework-knowledge-audit.live.contract.test.js +17 -0
  107. package/dist/src/services/framework/__tests__/framework-knowledge-audit.live.contract.test.js.map +1 -1
  108. package/dist/src/services/framework/__tests__/framework-knowledge-audit.service.test.js +51 -0
  109. package/dist/src/services/framework/__tests__/framework-knowledge-audit.service.test.js.map +1 -1
  110. package/dist/src/services/framework/framework-knowledge-audit.service.d.ts +41 -1
  111. package/dist/src/services/framework/framework-knowledge-audit.service.d.ts.map +1 -1
  112. package/dist/src/services/framework/framework-knowledge-audit.service.js +90 -0
  113. package/dist/src/services/framework/framework-knowledge-audit.service.js.map +1 -1
  114. package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.d.ts +2 -0
  115. package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.d.ts.map +1 -0
  116. package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.js +100 -0
  117. package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.js.map +1 -0
  118. package/dist/src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.js +55 -2
  119. package/dist/src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.js.map +1 -1
  120. package/dist/src/services/framework/provider-transposition/provider-package.emitter.d.ts +9 -0
  121. package/dist/src/services/framework/provider-transposition/provider-package.emitter.d.ts.map +1 -1
  122. package/dist/src/services/framework/provider-transposition/provider-package.emitter.js +139 -19
  123. package/dist/src/services/framework/provider-transposition/provider-package.emitter.js.map +1 -1
  124. package/dist/src/services/frontend/cloudflare-cdn.service.d.ts.map +1 -1
  125. package/dist/src/services/frontend/cloudflare-cdn.service.js +33 -2
  126. package/dist/src/services/frontend/cloudflare-cdn.service.js.map +1 -1
  127. package/dist/tsconfig.build.tsbuildinfo +1 -1
  128. package/dist/tsconfig.tsbuildinfo +1 -1
  129. package/package.json +17 -17
  130. package/scripts/app-dependency-alignment/propagated-engine-overrides.json +13 -0
  131. package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +64 -16
  132. package/templates/saas/engine-peer-closure.json +12 -0
  133. package/templates/saas/scenarios/add-provider/scenario.json +11 -11
  134. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +34 -0
  135. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/pages/auth/exchange.tsx +24 -1
  136. package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/theme/Root.tsx +22 -2
  137. package/templates/saas/skeleton/backend-api/package.json.hbs +1 -1
  138. package/templates/saas/skeleton/backend-api/src/companion-exports.ts +13 -2
  139. package/wildo-framework.info.json +1 -1
  140. package/templates/saas/scenarios/add-backend-provider/scenario.json +0 -17
  141. package/templates/saas/skeleton/backend-api/src/provider-contributions.ts +0 -44
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=base-url-is-a-declared-env-slot.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-url-is-a-declared-env-slot.test.d.ts","sourceRoot":"","sources":["../../../../../../src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,100 @@
1
+ import { mkdtempSync, readFileSync } from 'node:fs';
2
+ import { tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { describe, expect, it } from 'vitest';
5
+ import { ProviderSecretContractShapeSchema } from '@wildo-ai/saas-models/companion';
6
+ import { emitProvidersPackage } from '../provider-package.emitter.js';
7
+ import { TransposedAuthKind, TransposedOperationResolution, } from '../transposed-provider.model.js';
8
+ /**
9
+ * A vendor whose BASE URL the deployment names must DECLARE that variable, or it never arrives.
10
+ *
11
+ * `filterProviderEnvToScope` builds its allow-list from the declared secret slots and drops every
12
+ * `providerEnv` key no slot names. A base URL declared only as `baseUrlEnvVarName` on the runtime
13
+ * contract is named by nothing that builder reads — so it was stripped from every runtime, for
14
+ * 465 of the 684 generated vendors, none of which declared the slot.
15
+ *
16
+ * Measured on the running stack, 2026-09-10: `ASANA_BASE_URL` was authored in the application's
17
+ * secrets and absent from the generated `backend-api/.env`, while `ASANA_CLIENT_ID` and
18
+ * `ASANA_CLIENT_SECRET` sitting beside it in the same file came through. A connection could be
19
+ * minted and its operations then had no address to call.
20
+ *
21
+ * ## Fixtures rather than the source catalogues, deliberately
22
+ *
23
+ * The neighbouring contract pins read a SIBLING checkout and skip without it. This claim is about
24
+ * the emitter's own rule, so it is pinned on a fixture and runs everywhere — a pin that skips on
25
+ * the machine where somebody edits the emitter is not a pin.
26
+ */
27
+ describe('a base URL the deployment names is a declared env slot', () => {
28
+ const provenance = { source: 'SIM', sourceRef: 'fixture', sourceVersion: 'test' };
29
+ const vendor = (over) => ({
30
+ ref: 'vendorco',
31
+ vendor: 'vendorco',
32
+ auth: { kind: TransposedAuthKind.SECRET_TEXT },
33
+ provenances: [provenance],
34
+ operations: [{
35
+ operationId: 'read_thing',
36
+ domain: 'default',
37
+ resolution: TransposedOperationResolution.RESOLVED,
38
+ method: 'GET',
39
+ pathTemplate: '/things',
40
+ classification: 'READ',
41
+ parameters: [],
42
+ inputFields: [],
43
+ hasRequestBody: false,
44
+ provenance,
45
+ }],
46
+ ...over,
47
+ });
48
+ const emit = (provider) => {
49
+ const root = mkdtempSync(join(tmpdir(), 'wildo-base-url-'));
50
+ emitProvidersPackage({ packageRoot: root, providers: [provider], unreadableByVendor: new Map(), fullBatch: false });
51
+ return {
52
+ module: readFileSync(join(root, 'src', provider.ref, 'backend.exports.ts'), 'utf8'),
53
+ barrel: readFileSync(join(root, 'src', 'companion-exports.ts'), 'utf8'),
54
+ };
55
+ };
56
+ it('declares the slot whenever it emits baseUrlEnvVarName — the two are one decision', () => {
57
+ // The condition that emits `baseUrlEnvVarName` is the condition that owes the slot. Pinning them
58
+ // together is the point: either alone is what shipped.
59
+ const { module } = emit(vendor({ baseUrl: undefined }));
60
+ expect(module).toContain('baseUrlEnvVarName: "VENDORCO_BASE_URL"');
61
+ expect(module).toContain('baseUrl: {');
62
+ expect(module).toContain('envVarName: "VENDORCO_BASE_URL"');
63
+ });
64
+ it('marks it REGISTRATION, because the derivation classifies anything it cannot see as a CREDENTIAL', () => {
65
+ // `getProviderSecretScope` answers REGISTRATION only for the two refs the OAuth2 block names and
66
+ // CREDENTIAL for everything else. Left underived, a base URL would be storable as a TENANT's own
67
+ // credential — the address every one of that provider's calls is sent to.
68
+ const { module } = emit(vendor({ baseUrl: undefined }));
69
+ expect(module).toContain('scope: ExternalProvider_SecretScope.REGISTRATION');
70
+ // Declared as data means the enum must actually be imported, or the emitted module does not compile.
71
+ expect(module).toContain('ExternalProvider_SecretScope');
72
+ });
73
+ it('emits NOTHING when the vendor carries a literal base URL', () => {
74
+ // The control. A slot naming an environment variable the runtime never reads would report a gap
75
+ // an operator can never close, which is worse than the silence it replaced.
76
+ const { module } = emit(vendor({ baseUrl: 'https://api.vendorco.test' }));
77
+ expect(module).toContain('baseUrl: "https://api.vendorco.test"');
78
+ expect(module).not.toContain('VENDORCO_BASE_URL');
79
+ expect(module).not.toContain('ExternalProvider_SecretScope');
80
+ });
81
+ it('says the same thing in the DISCOVERY contribution, sorted by slug', () => {
82
+ // The emitter's own rule: the contribution "must AGREE with renderSecretsContract" — it is what
83
+ // the CLI reads to build the allow-list before anything is loaded, so a module that declares the
84
+ // slot and a contribution that does not would deliver nothing while looking correct.
85
+ const { barrel } = emit(vendor({ baseUrl: undefined }));
86
+ expect(barrel).toContain('slug: "baseUrl"');
87
+ expect(barrel).toContain('envVarName: "VENDORCO_BASE_URL"');
88
+ // And it must be SORTED: `ProviderSecretContractShapeSchema.superRefine` refuses an unsorted
89
+ // list at parse, so appending where it reads naturally would fail discovery rather than a test.
90
+ const shape = [
91
+ { slug: 'apiKey', envVarName: 'VENDORCO_API_KEY', required: true, description: 'x' },
92
+ { slug: 'baseUrl', envVarName: 'VENDORCO_BASE_URL', required: true, description: 'y' },
93
+ ];
94
+ expect(ProviderSecretContractShapeSchema.safeParse(shape).success).toBe(true);
95
+ expect(ProviderSecretContractShapeSchema.safeParse([shape[1], shape[0]]).success).toBe(false);
96
+ // The emitted barrel puts them in that order, which is the half a schema check cannot see.
97
+ expect(barrel.indexOf('slug: "apiKey"')).toBeLessThan(barrel.indexOf('slug: "baseUrl"'));
98
+ });
99
+ });
100
+ //# sourceMappingURL=base-url-is-a-declared-env-slot.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-url-is-a-declared-env-slot.test.js","sourceRoot":"","sources":["../../../../../../src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,iCAAiC,EAAE,MAAM,iCAAiC,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EACL,kBAAkB,EAClB,6BAA6B,GAE9B,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAQ,CAAC,wDAAwD,EAAE,GAAG,EAAE;IACtE,MAAM,UAAU,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAW,CAAC;IAE3F,MAAM,MAAM,GAAG,CAAC,IAAiC,EAAsB,EAAE,CAAC,CAAC;QACzE,GAAG,EAAE,UAAU;QACf,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE,EAAE,IAAI,EAAE,kBAAkB,CAAC,WAAW,EAAE;QAC9C,WAAW,EAAE,CAAC,UAAU,CAAC;QACzB,UAAU,EAAE,CAAC;gBACX,WAAW,EAAE,YAAY;gBACzB,MAAM,EAAE,SAAS;gBACjB,UAAU,EAAE,6BAA6B,CAAC,QAAQ;gBAClD,MAAM,EAAE,KAAc;gBACtB,YAAY,EAAE,SAAS;gBACvB,cAAc,EAAE,MAAe;gBAC/B,UAAU,EAAE,EAAE;gBACd,WAAW,EAAE,EAAE;gBACf,cAAc,EAAE,KAAK;gBACrB,UAAU;aACX,CAAC;QACF,G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,CAAC,iCAAiC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9E,MAAM,CAAC,iCAAiC,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9F,2FAA2F;QAC3F,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mkdtempSync, readFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport { describe, expect, it } from 'vitest';\n\nimport { ProviderSecretContractShapeSchema } from '@wildo-ai/saas-models/companion';\n\nimport { emitProvidersPackage } from '../provider-package.emitter';\nimport {\n TransposedAuthKind,\n TransposedOperationResolution,\n type TransposedProvider,\n} from '../transposed-provider.model';\n\n/**\n * A vendor whose BASE URL the deployment names must DECLARE that variable, or it never arrives.\n *\n * `filterProviderEnvToScope` builds its allow-list from the declared secret slots and drops every\n * `providerEnv` key no slot names. A base URL declared only as `baseUrlEnvVarName` on the runtime\n * contract is named by nothing that builder reads — so it was stripped from every runtime, for\n * 465 of the 684 generated vendors, none of which declared the slot.\n *\n * Measured on the running stack, 2026-09-10: `ASANA_BASE_URL` was authored in the application's\n * secrets and absent from the generated `backend-api/.env`, while `ASANA_CLIENT_ID` and\n * `ASANA_CLIENT_SECRET` sitting beside it in the same file came through. A connection could be\n * minted and its operations then had no address to call.\n *\n * ## Fixtures rather than the source catalogues, deliberately\n *\n * The neighbouring contract pins read a SIBLING checkout and skip without it. This claim is about\n * the emitter's own rule, so it is pinned on a fixture and runs everywhere — a pin that skips on\n * the machine where somebody edits the emitter is not a pin.\n */\ndescribe('a base URL the deployment names is a declared env slot', () => {\n const provenance = { source: 'SIM', sourceRef: 'fixture', sourceVersion: 'test' } as const;\n\n const vendor = (over: Partial<TransposedProvider>): TransposedProvider => ({\n ref: 'vendorco',\n vendor: 'vendorco',\n auth: { kind: TransposedAuthKind.SECRET_TEXT },\n provenances: [provenance],\n operations: [{\n operationId: 'read_thing',\n domain: 'default',\n resolution: TransposedOperationResolution.RESOLVED,\n method: 'GET' as const,\n pathTemplate: '/things',\n classification: 'READ' as const,\n parameters: [],\n inputFields: [],\n hasRequestBody: false,\n provenance,\n }],\n ...over,\n });\n\n const emit = (provider: TransposedProvider): { module: string; barrel: string } => {\n const root = mkdtempSync(join(tmpdir(), 'wildo-base-url-'));\n emitProvidersPackage({ packageRoot: root, providers: [provider], unreadableByVendor: new Map(), fullBatch: false });\n return {\n module: readFileSync(join(root, 'src', provider.ref, 'backend.exports.ts'), 'utf8'),\n barrel: readFileSync(join(root, 'src', 'companion-exports.ts'), 'utf8'),\n };\n };\n\n it('declares the slot whenever it emits baseUrlEnvVarName — the two are one decision', () => {\n // The condition that emits `baseUrlEnvVarName` is the condition that owes the slot. Pinning them\n // together is the point: either alone is what shipped.\n const { module } = emit(vendor({ baseUrl: undefined }));\n\n expect(module).toContain('baseUrlEnvVarName: \"VENDORCO_BASE_URL\"');\n expect(module).toContain('baseUrl: {');\n expect(module).toContain('envVarName: \"VENDORCO_BASE_URL\"');\n });\n\n it('marks it REGISTRATION, because the derivation classifies anything it cannot see as a CREDENTIAL', () => {\n // `getProviderSecretScope` answers REGISTRATION only for the two refs the OAuth2 block names and\n // CREDENTIAL for everything else. Left underived, a base URL would be storable as a TENANT's own\n // credential — the address every one of that provider's calls is sent to.\n const { module } = emit(vendor({ baseUrl: undefined }));\n\n expect(module).toContain('scope: ExternalProvider_SecretScope.REGISTRATION');\n // Declared as data means the enum must actually be imported, or the emitted module does not compile.\n expect(module).toContain('ExternalProvider_SecretScope');\n });\n\n it('emits NOTHING when the vendor carries a literal base URL', () => {\n // The control. A slot naming an environment variable the runtime never reads would report a gap\n // an operator can never close, which is worse than the silence it replaced.\n const { module } = emit(vendor({ baseUrl: 'https://api.vendorco.test' }));\n\n expect(module).toContain('baseUrl: \"https://api.vendorco.test\"');\n expect(module).not.toContain('VENDORCO_BASE_URL');\n expect(module).not.toContain('ExternalProvider_SecretScope');\n });\n\n it('says the same thing in the DISCOVERY contribution, sorted by slug', () => {\n // The emitter's own rule: the contribution \"must AGREE with renderSecretsContract\" — it is what\n // the CLI reads to build the allow-list before anything is loaded, so a module that declares the\n // slot and a contribution that does not would deliver nothing while looking correct.\n const { barrel } = emit(vendor({ baseUrl: undefined }));\n\n expect(barrel).toContain('slug: \"baseUrl\"');\n expect(barrel).toContain('envVarName: \"VENDORCO_BASE_URL\"');\n\n // And it must be SORTED: `ProviderSecretContractShapeSchema.superRefine` refuses an unsorted\n // list at parse, so appending where it reads naturally would fail discovery rather than a test.\n const shape = [\n { slug: 'apiKey', envVarName: 'VENDORCO_API_KEY', required: true, description: 'x' },\n { slug: 'baseUrl', envVarName: 'VENDORCO_BASE_URL', required: true, description: 'y' },\n ];\n expect(ProviderSecretContractShapeSchema.safeParse(shape).success).toBe(true);\n expect(ProviderSecretContractShapeSchema.safeParse([shape[1], shape[0]]).success).toBe(false);\n // The emitted barrel puts them in that order, which is the half a schema check cannot see.\n expect(barrel.indexOf('slug: \"apiKey\"')).toBeLessThan(barrel.indexOf('slug: \"baseUrl\"'));\n });\n});\n"]}
@@ -3,8 +3,8 @@ import { tmpdir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import { describe, expect, it } from 'vitest';
5
5
  import { engineBackendProviderContributions } from '@wildo-ai/external-connectors-private/companion';
6
- import { emitProvidersPackage, planProvidersPackage, vendorIsExported } from '../provider-package.emitter.js';
7
- import { TransposedAuthKind, TransposedOperationResolution, } from '../transposed-provider.model.js';
6
+ import { EmitRefusalReason, emitProvidersPackage, planProvidersPackage, vendorIsExported } from '../provider-package.emitter.js';
7
+ import { TransposedAuthKind, TransposedOperationResolution, TransposedParameterLocation, } from '../transposed-provider.model.js';
8
8
  /**
9
9
  * `--dry-run` must predict the emit it is a dry run of.
10
10
  *
@@ -79,6 +79,59 @@ describe('a dry run predicts the emit', () => {
79
79
  expect(planned.executableOperations).toBe(5);
80
80
  expect(emitted.executableOperations).toBe(planned.executableOperations);
81
81
  });
82
+ it('reports the EXPORTED SET, and the plan and the emit name the same refs', () => {
83
+ /*
84
+ * The count was already pinned; the SET was not, and the difference is what the inventory got
85
+ * wrong. It rebuilt `vendorIsExported` from the two clauses it knew about — nothing executable,
86
+ * withheld by decision — and missed the third, `ENGINE_OWNED_PROVIDER_REFS`, reporting 707
87
+ * exports against 682 actually emitted.
88
+ *
89
+ * A count agreeing is weaker than it looks: two sets of the same size can name different vendors,
90
+ * and the failure that produced this reported MORE than shipped, which a total would have caught
91
+ * only by luck. So the pin is on the refs.
92
+ */
93
+ // `keptco` exports, `withheldco` is withheld by decision, `emptyco` has nothing executable — one
94
+ // ref from each of the three clauses, so a predicate that drops any of them shows up here.
95
+ const plannedResult = planProvidersPackage({
96
+ packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,
97
+ });
98
+ const emittedResult = emitProvidersPackage({
99
+ packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,
100
+ });
101
+ expect([...emittedResult.exportedOperationCounts.keys()]).toEqual(['keptco']);
102
+ expect(emittedResult.exportedOperationCounts.get('keptco')).toBe(2);
103
+ expect([...plannedResult.exportedOperationCounts.keys()].sort())
104
+ .toEqual([...emittedResult.exportedOperationCounts.keys()].sort());
105
+ });
106
+ it('refuses a POSITIONAL path hole even when the operation declares no input at all', () => {
107
+ /*
108
+ * The pass-through escape returns early for an operation with no input fields, on the sound
109
+ * reasoning that a BODY or QUERY it cannot see is the caller's to supply. A PATH hole is not that:
110
+ * the URL cannot be built without it, so pass-through is not an answer but a request the caller
111
+ * has no way to satisfy — and when the hole is positionally named, not even a reader of the
112
+ * vendor's docs can satisfy it.
113
+ *
114
+ * Exactly one operation reached the package this way: `ninox`'s `trigger.newRecord.poll`, shipped
115
+ * as `GET /{param2}` with a required path parameter called `param2`, while 856 operations were
116
+ * refused for the identical shape.
117
+ */
118
+ const base = vendorWith('pollco', 1);
119
+ const positional = {
120
+ ...base,
121
+ operations: [{
122
+ ...base.operations[0],
123
+ pathTemplate: '/{param2}',
124
+ parameters: [{ name: 'param2', in: TransposedParameterLocation.PATH, required: true }],
125
+ inputFields: [],
126
+ }],
127
+ };
128
+ const root = mkdtempSync(join(tmpdir(), 'wildo-plan-emit-'));
129
+ const result = planProvidersPackage({
130
+ packageRoot: root, providers: [positional], unreadableByVendor: new Map(), fullBatch: false,
131
+ });
132
+ expect(result.exportedOperationCounts.has('pollco')).toBe(false);
133
+ expect(result.refusedByVendor.get('pollco')?.get(EmitRefusalReason.UNFED_PATH_PARAMETER)).toBe(1);
134
+ });
82
135
  it('agrees with the emit when nothing is withheld', () => {
83
136
  // The control. Without it, a predicate that always returned false would pass the first case.
84
137
  const planned = planProvidersPackage({
@@ -1 +1 @@
1
- {"version":3,"file":"plan-matches-emit.test.js","sourceRoot":"","sources":["../../../../../../src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AAErG,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC3G,OAAO,EACL,kB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AAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport { describe, expect, it } from 'vitest';\n\nimport { engineBackendProviderContributions } from '@wildo-ai/external-connectors-private/companion';\n\nimport { emitProvidersPackage, planProvidersPackage, vendorIsExported } from '../provider-package.emitter';\nimport {\n TransposedAuthKind,\n TransposedOperationResolution,\n type TransposedProvider,\n} from '../transposed-provider.model';\n\n/**\n * `--dry-run` must predict the emit it is a dry run of.\n *\n * The flag exists so a batch can be inspected BEFORE it replaces every vendor directory in the\n * package, which is worth nothing if the two paths compute different things — and they have now\n * diverged twice, each time because one copy of an accounting rule was updated and the other was\n * not:\n *\n * - by 856 OPERATIONS (#393), when refusals were filtered in the emit and counted in the plan;\n * - by 9 VENDORS, found on 2026-09-08 by running a real regeneration against refreshed catalogues:\n * the dry run said 698 subpaths and the emit wrote 689. The plan applied the \"nothing executable\"\n * half of the export test and skipped `decisions.scrape !== false`, so it promised subpaths for\n * exactly the nine vendors withheld because they collide with an engine provider — the worst set\n * to over-report, because it tells the reader the collision is back.\n *\n * Both are now one predicate (`vendorIsExported`). This pins the agreement rather than the\n * predicate, so any future divergence fails here regardless of which copy is edited.\n */\ndescribe('a dry run predicts the emit', () => {\n const provenance = { source: 'SIM', sourceRef: 'fixture', sourceVersion: 'test' } as const;\n\n const vendorWith = (ref: string, operationCount: number): TransposedProvider => ({\n ref,\n vendor: ref,\n auth: { kind: TransposedAuthKind.SECRET_TEXT },\n provenances: [provenance],\n operations: Array.from({ length: operationCount }, (unused, index) => ({\n operationId: `read_thing_${index}`,\n domain: 'default',\n resolution: TransposedOperationResolution.RESOLVED,\n method: 'GET' as const,\n pathTemplate: `/things/${index}`,\n classification: 'READ' as const,\n parameters: [],\n inputFields: [],\n hasRequestBody: false,\n provenance,\n })),\n });\n\n /** A fresh package root carrying the given `scrape: false` withholdings. */\n const rootWithheld = (...refs: string[]): string => {\n const root = mkdtempSync(join(tmpdir(), 'wildo-plan-emit-'));\n if (refs.length > 0) mkdirSync(join(root, 'catalogue-record', 'decisions'), { recursive: true });\n for (const ref of refs) {\n writeFileSync(\n join(root, 'catalogue-record', 'decisions', `${ref}.json`),\n JSON.stringify({ ref, reason: 'collides with an engine provider', scrape: false }),\n 'utf8',\n );\n }\n return root;\n };\n\n const providers = [vendorWith('keptco', 2), vendorWith('withheldco', 3), vendorWith('emptyco', 0)];\n\n it('counts the same vendors as the emit when a vendor is withheld', () => {\n // Two roots, because the emit WRITES and the plan must not be handed a tree the emit already\n // replaced — the point is that both read the same decisions, not that they share a directory.\n const planned = planProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emitted = emitProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n expect(planned.vendors).toBe(emitted.vendors);\n // `keptco` only: `withheldco` is withheld by decision and `emptyco` has nothing executable.\n expect(emitted.vendors).toBe(1);\n });\n\n it('still counts a withheld vendor\\'s operations, because withholding takes the subpath and nothing else', () => {\n const planned = planProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emitted = emitProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n // 2 + 3: the withheld vendor is still transposed and its ledger still maintained, so its ids\n // cannot be renumbered by a later re-enabling. Only the subpath is withheld.\n expect(planned.executableOperations).toBe(5);\n expect(emitted.executableOperations).toBe(planned.executableOperations);\n });\n\n it('agrees with the emit when nothing is withheld', () => {\n // The control. Without it, a predicate that always returned false would pass the first case.\n const planned = planProvidersPackage({\n packageRoot: rootWithheld(), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emitted = emitProvidersPackage({\n packageRoot: rootWithheld(), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n expect(planned.vendors).toBe(emitted.vendors);\n expect(emitted.vendors).toBe(2);\n });\n});\n\n/**\n * A ref the ENGINE owns never becomes a catalogue subpath.\n *\n * The rule already existed on 2026-09-08 as nine hand-written `scrape: false` decision files, each\n * carrying the sentence *\"Nine of the engine's 23 providers collide this way.\"* Measured against the\n * engine registry a day later: **eleven** collide. `openai` and `google` were missed, and the count\n * in the reason recorded the miss as a fact — a list enumerating another party's catalogue by hand,\n * failing the way those always do.\n *\n * The cost was not theoretical. A ref is an application's whole address for a provider, so two\n * contributions carrying one make `wildo config sync` refuse — *\"discovered runtime owners disagree\n * on its secret-contract shape\"* — and the refusal lands on an application that never asked for the\n * catalogue's copy. Installing this package for `slack` was enough to make an unrelated `openai`\n * declaration unmaterializable, which is every application that wants an LLM and any integration.\n *\n * So the assertions below derive BOTH sides from `engineBackendProviderContributions` rather than\n * listing names: adding the 24th engine provider cannot leave this test asserting yesterday's set.\n */\ndescribe('the engine owns its refs, and the catalogue may not claim one', () => {\n const provenance = { source: 'SIM', sourceRef: 'fixture', sourceVersion: 'test' } as const;\n\n const vendorWith = (ref: string, operationCount: number): TransposedProvider => ({\n ref,\n vendor: ref,\n auth: { kind: TransposedAuthKind.SECRET_TEXT },\n provenances: [provenance],\n operations: Array.from({ length: operationCount }, (unused, index) => ({\n operationId: `read_thing_${index}`,\n domain: 'default',\n resolution: TransposedOperationResolution.RESOLVED,\n method: 'GET' as const,\n pathTemplate: `/things/${index}`,\n classification: 'READ' as const,\n parameters: [],\n inputFields: [],\n hasRequestBody: false,\n provenance,\n })),\n });\n\n const engineRefs = engineBackendProviderContributions.map((contribution) => contribution.ref);\n\n it('withholds the subpath of every engine-owned ref, with no decision file present', () => {\n // Every engine ref, given plenty of executable operations and NO `scrape: false` anywhere. The\n // hand-written mechanism this replaces could only withhold a ref somebody had written a file\n // for; this one must withhold all of them from the registry alone.\n for (const ref of engineRefs) {\n expect(vendorIsExported(ref, 12, undefined), `${ref} is an engine ref and must not be exported`).toBe(false);\n }\n expect(engineRefs.length).toBeGreaterThan(20);\n });\n\n it('exports a catalogue vendor whose ref the engine does not own — the control', () => {\n // Without this the assertion above is satisfied by a predicate that withholds everything, which\n // is exactly the shape a neutered rule takes.\n expect(vendorIsExported('slack', 12, undefined)).toBe(true);\n expect(vendorIsExported('hubspot', 12, undefined)).toBe(true);\n });\n\n it('counts an engine-owned ref out of the plan and the emit alike', () => {\n // The end-to-end form: the two accountings must agree about the withholding, which is the\n // divergence that produced this file. `stripe` is an engine ref; `keptco` is not.\n const engineOwned = engineRefs[0];\n const providers = [vendorWith('keptco', 2), vendorWith(engineOwned, 3)];\n\n const planned = planProvidersPackage({\n packageRoot: mkdtempSync(join(tmpdir(), 'wildo-engine-ref-')), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emitted = emitProvidersPackage({\n packageRoot: mkdtempSync(join(tmpdir(), 'wildo-engine-ref-')), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n expect(planned.vendors).toBe(emitted.vendors);\n expect(emitted.vendors).toBe(1);\n // Withheld takes the SUBPATH and nothing else: both operations are still transposed, so\n // re-enabling the vendor cannot renumber an id an application already called.\n expect(emitted.executableOperations).toBe(5);\n });\n});\n"]}
1
+ {"version":3,"file":"plan-matches-emit.test.js","sourceRoot":"","sources":["../../../../../../src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AAErG,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6B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AC,CAAC,CAAC;QAExE,MAAM,OAAO,GAAG,oBAAoB,CAAC;YACnC,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAE,KAAK;SAC1H,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,oBAAoB,CAAC;YACnC,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAE,KAAK;SAC1H,CAAC,CAAC;QAEH,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChC,wFAAwF;QACxF,8EAA8E;QAC9E,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nimport { describe, expect, it } from 'vitest';\n\nimport { engineBackendProviderContributions } from '@wildo-ai/external-connectors-private/companion';\n\nimport { EmitRefusalReason, emitProvidersPackage, planProvidersPackage, vendorIsExported } from '../provider-package.emitter';\nimport {\n TransposedAuthKind,\n TransposedOperationResolution,\n TransposedParameterLocation,\n type TransposedProvider,\n} from '../transposed-provider.model';\n\n/**\n * `--dry-run` must predict the emit it is a dry run of.\n *\n * The flag exists so a batch can be inspected BEFORE it replaces every vendor directory in the\n * package, which is worth nothing if the two paths compute different things — and they have now\n * diverged twice, each time because one copy of an accounting rule was updated and the other was\n * not:\n *\n * - by 856 OPERATIONS (#393), when refusals were filtered in the emit and counted in the plan;\n * - by 9 VENDORS, found on 2026-09-08 by running a real regeneration against refreshed catalogues:\n * the dry run said 698 subpaths and the emit wrote 689. The plan applied the \"nothing executable\"\n * half of the export test and skipped `decisions.scrape !== false`, so it promised subpaths for\n * exactly the nine vendors withheld because they collide with an engine provider — the worst set\n * to over-report, because it tells the reader the collision is back.\n *\n * Both are now one predicate (`vendorIsExported`). This pins the agreement rather than the\n * predicate, so any future divergence fails here regardless of which copy is edited.\n */\ndescribe('a dry run predicts the emit', () => {\n const provenance = { source: 'SIM', sourceRef: 'fixture', sourceVersion: 'test' } as const;\n\n const vendorWith = (ref: string, operationCount: number): TransposedProvider => ({\n ref,\n vendor: ref,\n auth: { kind: TransposedAuthKind.SECRET_TEXT },\n provenances: [provenance],\n operations: Array.from({ length: operationCount }, (unused, index) => ({\n operationId: `read_thing_${index}`,\n domain: 'default',\n resolution: TransposedOperationResolution.RESOLVED,\n method: 'GET' as const,\n pathTemplate: `/things/${index}`,\n classification: 'READ' as const,\n parameters: [],\n inputFields: [],\n hasRequestBody: false,\n provenance,\n })),\n });\n\n /** A fresh package root carrying the given `scrape: false` withholdings. */\n const rootWithheld = (...refs: string[]): string => {\n const root = mkdtempSync(join(tmpdir(), 'wildo-plan-emit-'));\n if (refs.length > 0) mkdirSync(join(root, 'catalogue-record', 'decisions'), { recursive: true });\n for (const ref of refs) {\n writeFileSync(\n join(root, 'catalogue-record', 'decisions', `${ref}.json`),\n JSON.stringify({ ref, reason: 'collides with an engine provider', scrape: false }),\n 'utf8',\n );\n }\n return root;\n };\n\n const providers = [vendorWith('keptco', 2), vendorWith('withheldco', 3), vendorWith('emptyco', 0)];\n\n it('counts the same vendors as the emit when a vendor is withheld', () => {\n // Two roots, because the emit WRITES and the plan must not be handed a tree the emit already\n // replaced — the point is that both read the same decisions, not that they share a directory.\n const planned = planProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emitted = emitProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n expect(planned.vendors).toBe(emitted.vendors);\n // `keptco` only: `withheldco` is withheld by decision and `emptyco` has nothing executable.\n expect(emitted.vendors).toBe(1);\n });\n\n it('still counts a withheld vendor\\'s operations, because withholding takes the subpath and nothing else', () => {\n const planned = planProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emitted = emitProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n // 2 + 3: the withheld vendor is still transposed and its ledger still maintained, so its ids\n // cannot be renumbered by a later re-enabling. Only the subpath is withheld.\n expect(planned.executableOperations).toBe(5);\n expect(emitted.executableOperations).toBe(planned.executableOperations);\n });\n\n it('reports the EXPORTED SET, and the plan and the emit name the same refs', () => {\n /*\n * The count was already pinned; the SET was not, and the difference is what the inventory got\n * wrong. It rebuilt `vendorIsExported` from the two clauses it knew about — nothing executable,\n * withheld by decision — and missed the third, `ENGINE_OWNED_PROVIDER_REFS`, reporting 707\n * exports against 682 actually emitted.\n *\n * A count agreeing is weaker than it looks: two sets of the same size can name different vendors,\n * and the failure that produced this reported MORE than shipped, which a total would have caught\n * only by luck. So the pin is on the refs.\n */\n // `keptco` exports, `withheldco` is withheld by decision, `emptyco` has nothing executable — one\n // ref from each of the three clauses, so a predicate that drops any of them shows up here.\n const plannedResult = planProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emittedResult = emitProvidersPackage({\n packageRoot: rootWithheld('withheldco'), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n expect([...emittedResult.exportedOperationCounts.keys()]).toEqual(['keptco']);\n expect(emittedResult.exportedOperationCounts.get('keptco')).toBe(2);\n expect([...plannedResult.exportedOperationCounts.keys()].sort())\n .toEqual([...emittedResult.exportedOperationCounts.keys()].sort());\n });\n\n it('refuses a POSITIONAL path hole even when the operation declares no input at all', () => {\n /*\n * The pass-through escape returns early for an operation with no input fields, on the sound\n * reasoning that a BODY or QUERY it cannot see is the caller's to supply. A PATH hole is not that:\n * the URL cannot be built without it, so pass-through is not an answer but a request the caller\n * has no way to satisfy — and when the hole is positionally named, not even a reader of the\n * vendor's docs can satisfy it.\n *\n * Exactly one operation reached the package this way: `ninox`'s `trigger.newRecord.poll`, shipped\n * as `GET /{param2}` with a required path parameter called `param2`, while 856 operations were\n * refused for the identical shape.\n */\n const base = vendorWith('pollco', 1);\n const positional: TransposedProvider = {\n ...base,\n operations: [{\n ...base.operations[0]!,\n pathTemplate: '/{param2}',\n parameters: [{ name: 'param2', in: TransposedParameterLocation.PATH, required: true }],\n inputFields: [],\n }],\n };\n const root = mkdtempSync(join(tmpdir(), 'wildo-plan-emit-'));\n const result = planProvidersPackage({\n packageRoot: root, providers: [positional], unreadableByVendor: new Map(), fullBatch: false,\n });\n\n expect(result.exportedOperationCounts.has('pollco')).toBe(false);\n expect(result.refusedByVendor.get('pollco')?.get(EmitRefusalReason.UNFED_PATH_PARAMETER)).toBe(1);\n });\n\n it('agrees with the emit when nothing is withheld', () => {\n // The control. Without it, a predicate that always returned false would pass the first case.\n const planned = planProvidersPackage({\n packageRoot: rootWithheld(), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emitted = emitProvidersPackage({\n packageRoot: rootWithheld(), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n expect(planned.vendors).toBe(emitted.vendors);\n expect(emitted.vendors).toBe(2);\n });\n});\n\n/**\n * A ref the ENGINE owns never becomes a catalogue subpath.\n *\n * The rule already existed on 2026-09-08 as nine hand-written `scrape: false` decision files, each\n * carrying the sentence *\"Nine of the engine's 23 providers collide this way.\"* Measured against the\n * engine registry a day later: **eleven** collide. `openai` and `google` were missed, and the count\n * in the reason recorded the miss as a fact — a list enumerating another party's catalogue by hand,\n * failing the way those always do.\n *\n * The cost was not theoretical. A ref is an application's whole address for a provider, so two\n * contributions carrying one make `wildo config sync` refuse — *\"discovered runtime owners disagree\n * on its secret-contract shape\"* — and the refusal lands on an application that never asked for the\n * catalogue's copy. Installing this package for `slack` was enough to make an unrelated `openai`\n * declaration unmaterializable, which is every application that wants an LLM and any integration.\n *\n * So the assertions below derive BOTH sides from `engineBackendProviderContributions` rather than\n * listing names: adding the 24th engine provider cannot leave this test asserting yesterday's set.\n */\ndescribe('the engine owns its refs, and the catalogue may not claim one', () => {\n const provenance = { source: 'SIM', sourceRef: 'fixture', sourceVersion: 'test' } as const;\n\n const vendorWith = (ref: string, operationCount: number): TransposedProvider => ({\n ref,\n vendor: ref,\n auth: { kind: TransposedAuthKind.SECRET_TEXT },\n provenances: [provenance],\n operations: Array.from({ length: operationCount }, (unused, index) => ({\n operationId: `read_thing_${index}`,\n domain: 'default',\n resolution: TransposedOperationResolution.RESOLVED,\n method: 'GET' as const,\n pathTemplate: `/things/${index}`,\n classification: 'READ' as const,\n parameters: [],\n inputFields: [],\n hasRequestBody: false,\n provenance,\n })),\n });\n\n const engineRefs = engineBackendProviderContributions.map((contribution) => contribution.ref);\n\n it('withholds the subpath of every engine-owned ref, with no decision file present', () => {\n // Every engine ref, given plenty of executable operations and NO `scrape: false` anywhere. The\n // hand-written mechanism this replaces could only withhold a ref somebody had written a file\n // for; this one must withhold all of them from the registry alone.\n for (const ref of engineRefs) {\n expect(vendorIsExported(ref, 12, undefined), `${ref} is an engine ref and must not be exported`).toBe(false);\n }\n expect(engineRefs.length).toBeGreaterThan(20);\n });\n\n it('exports a catalogue vendor whose ref the engine does not own — the control', () => {\n // Without this the assertion above is satisfied by a predicate that withholds everything, which\n // is exactly the shape a neutered rule takes.\n expect(vendorIsExported('slack', 12, undefined)).toBe(true);\n expect(vendorIsExported('hubspot', 12, undefined)).toBe(true);\n });\n\n it('counts an engine-owned ref out of the plan and the emit alike', () => {\n // The end-to-end form: the two accountings must agree about the withholding, which is the\n // divergence that produced this file. `stripe` is an engine ref; `keptco` is not.\n const engineOwned = engineRefs[0];\n const providers = [vendorWith('keptco', 2), vendorWith(engineOwned, 3)];\n\n const planned = planProvidersPackage({\n packageRoot: mkdtempSync(join(tmpdir(), 'wildo-engine-ref-')), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n const emitted = emitProvidersPackage({\n packageRoot: mkdtempSync(join(tmpdir(), 'wildo-engine-ref-')), providers, unreadableByVendor: new Map(), fullBatch: false,\n });\n\n expect(planned.vendors).toBe(emitted.vendors);\n expect(emitted.vendors).toBe(1);\n // Withheld takes the SUBPATH and nothing else: both operations are still transposed, so\n // re-enabling the vendor cannot renumber an id an application already called.\n expect(emitted.executableOperations).toBe(5);\n });\n});\n"]}
@@ -41,6 +41,15 @@ export interface EmitPackageOptions {
41
41
  }
42
42
  export interface EmitPackageResult {
43
43
  readonly vendors: number;
44
+ /**
45
+ * Which refs actually got a subpath, and how many operations each carries.
46
+ *
47
+ * Reported rather than left to be re-derived, because `vendorIsExported` has THREE clauses and a
48
+ * caller reconstructing it will miss one — the inventory did, on `ENGINE_OWNED_PROVIDER_REFS`, and
49
+ * over-reported 707 exports against 682 emitted. The same reason the plan and the emit share one
50
+ * predicate: a second implementation is a thing that disagrees.
51
+ */
52
+ readonly exportedOperationCounts: ReadonlyMap<string, number>;
44
53
  readonly executableOperations: number;
45
54
  readonly pendingOperations: number;
46
55
  readonly unreadableOperations: number;
@@ -1 +1 @@
1
- {"version":3,"file":"provider-package.emitter.d.ts","sourceRoot":"","sources":["../../../../../src/services/framework/provider-transposition/provider-package.emitter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,6BAA6B,CAAC;AAiBvF,OAAO,EAML,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EAExB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9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AO,EAAE,kBAAkB,GAAG,iBAAiB,CAqBnF"}
1
+ {"version":3,"file":"provider-package.emitter.d.ts","sourceRoot":"","sources":["../../../../../src/services/framework/provider-transposition/provider-package.emitter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,6BAA6B,CAAC;AAiBvF,OAAO,EAML,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EAExB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAClD,0FAA0F;IAC1F,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,mBAAmB,EAAE,CAAC,CAAC;IACjF;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,QAAQ,CAAC,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC;;;;;;;;OAQG;IACH,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;IACtF;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CACjF;AAED;;;;;;;;GAQG;AACH,oBAAY,iBAAiB;IAC3B,sEAAsE;IACtE,gBAAgB,qBAAqB;IACrC,gFAAgF;IAChF,oBAAoB,yBAAyB;IAC7C;;;;OAIG;IACH,oBAAoB,yBAAyB;IAC7C;;;;;;;;;;;;;;OAcG;IACH,2BAA2B,gCAAgC;CAC5D;AAuID,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CAoJnF;AA+ED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,GAAG,SAAS,GAAG,OAAO,CAEhI;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CAyBnF"}
@@ -1,4 +1,4 @@
1
- import { existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { engineBackendProviderContributions } from '@wildo-ai/external-connectors-private/companion';
4
4
  import { ProviderTier } from '@wildo-ai/saas-models';
@@ -153,6 +153,21 @@ function refusalReason(operation) {
153
153
  // Only checked when the operation HAS an input schema. An operation that declares no input at all
154
154
  // passes its input through unvalidated, which the contract permits, and there is nothing to
155
155
  // disagree with.
156
+ // A POSITIONALLY-NAMED path hole is refused whatever feeds it, and BEFORE the pass-through escape
157
+ // below. `{param2}` is not a parameter a caller can supply: the name carries no meaning, so even a
158
+ // correctly-wired input leaves the operation uncallable by anyone who did not read the vendor's
159
+ // own URL. This is the shape the reason code was written for, and 856 operations are refused for
160
+ // it — but exactly one reached the package, because it declares NO input fields and the escape
161
+ // below returned early. `ninox`'s `trigger.newRecord.poll` shipped as `GET /{param2}` with a
162
+ // required path parameter called `param2`.
163
+ //
164
+ // The escape is right for a BODY or QUERY it cannot see: pass-through is a real contract, and the
165
+ // caller supplies whatever the vendor wants. It is wrong for a PATH hole, which is structural —
166
+ // the URL cannot be built without it, so "unvalidated pass-through" is not an answer, it is a
167
+ // request the caller has no way to satisfy.
168
+ if ([...template.matchAll(/\{([^}]+)\}/g)].some((match) => /^param\d+$/.test(match[1]))) {
169
+ return EmitRefusalReason.UNFED_PATH_PARAMETER;
170
+ }
156
171
  if (operation.inputFields.length === 0)
157
172
  return undefined;
158
173
  const fields = new Set(operation.inputFields.map((field) => field.name));
@@ -254,12 +269,16 @@ export function emitProvidersPackage(options) {
254
269
  }, null, 2)}\n`, 'utf8');
255
270
  }
256
271
  writeFileSync(join(sourceRoot, 'companion-exports.ts'), renderCompanionExports(emitted, new Map(planned.filter((e) => e.decisions !== undefined).map((e) => [e.provider.ref, e.decisions]))), 'utf8');
257
- writeFileSync(join(options.packageRoot, 'package.json'), renderPackageJson(emitted), 'utf8');
272
+ writeFileSync(join(options.packageRoot, 'package.json'), renderPackageJson(emitted, readExistingPackageVersion(options.packageRoot)), 'utf8');
258
273
  writeFileSync(join(options.packageRoot, 'tsconfig.build.json'), renderBuildTsconfig(), 'utf8');
259
274
  writeFileSync(join(options.packageRoot, 'tsconfig.json'), renderTypecheckTsconfig(), 'utf8');
260
275
  writeFileSync(join(options.packageRoot, 'NOTICE'), renderNotice(emitted), 'utf8');
261
276
  return {
262
277
  vendors: emitted.length,
278
+ // Built from the same `exported` flag that decides whether a directory is written and whether the
279
+ // ref reaches the package manifest and the companion barrel, so this cannot disagree with what
280
+ // shipped. `emitted` itself carries no operation count, which is why this reads `planned`.
281
+ exportedOperationCounts: new Map(planned.filter((entry) => entry.exported).map((entry) => [entry.provider.ref, entry.resolved.length])),
263
282
  executableOperations: executable,
264
283
  pendingOperations: pending,
265
284
  unreadableOperations: unreadable,
@@ -366,6 +385,7 @@ export function vendorIsExported(ref, resolvedOperationCount, decisions) {
366
385
  }
367
386
  export function planProvidersPackage(options) {
368
387
  const refusedByVendor = new Map();
388
+ const exportedOperationCounts = new Map();
369
389
  let vendors = 0;
370
390
  let executable = 0;
371
391
  let pending = 0;
@@ -381,13 +401,15 @@ export function planProvidersPackage(options) {
381
401
  executable += resolved.length;
382
402
  // The SAME predicate the emit applies. Counting `resolved.length > 0` alone is what made a dry
383
403
  // run promise nine subpaths the emit withholds.
384
- if (vendorIsExported(provider.ref, resolved.length, readDecisions(options.packageRoot, provider.ref)))
404
+ if (vendorIsExported(provider.ref, resolved.length, readDecisions(options.packageRoot, provider.ref))) {
385
405
  vendors += 1;
406
+ exportedOperationCounts.set(provider.ref, resolved.length);
407
+ }
386
408
  }
387
409
  // A plan does not consult the ledger, so it cannot know what moved. Empty rather than absent: the
388
410
  // shape is the emit's, and a dry run that invented a movement would be reporting on a comparison
389
411
  // it never made.
390
- return { vendors, executableOperations: executable, pendingOperations: pending, unreadableOperations: unreadable, refusedByVendor, refusalMovement: new Map() };
412
+ return { vendors, exportedOperationCounts, executableOperations: executable, pendingOperations: pending, unreadableOperations: unreadable, refusedByVendor, refusalMovement: new Map() };
391
413
  }
392
414
  /**
393
415
  * Close the record against what this run actually produced, and REFUSE anything that matched
@@ -473,7 +495,29 @@ function subpathFor(ref) {
473
495
  * The version is a placeholder the publish lane sets. A generator cannot know which release a batch
474
496
  * belongs to, and inventing one would put a plausible wrong version on the whole catalogue.
475
497
  */
476
- function renderPackageJson(providers) {
498
+ /**
499
+ * The version is CARRIED OVER, never re-rendered.
500
+ *
501
+ * A regeneration rewrites this manifest wholesale, and a literal here means every regeneration
502
+ * silently un-releases the package: it reverts to `0.0.0` and the next publish either fails or
503
+ * republishes an old number. That is not hypothetical — `providers` was released as `1.1.3` and the
504
+ * very next regeneration, minutes later, reset it, which is how this was found.
505
+ *
506
+ * The version is a RELEASE decision and belongs to whoever cuts one; the transposer's business is
507
+ * the vendor surface. `0.0.0` remains the value for a package root that does not exist yet, which
508
+ * is the only case where nothing has decided.
509
+ */
510
+ function readExistingPackageVersion(packageRoot) {
511
+ try {
512
+ const manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'));
513
+ return typeof manifest.version === 'string' && manifest.version.length > 0 ? manifest.version : '0.0.0';
514
+ }
515
+ catch {
516
+ // No manifest yet, or an unreadable one. A first emit legitimately has nothing to carry over.
517
+ return '0.0.0';
518
+ }
519
+ }
520
+ function renderPackageJson(providers, version) {
477
521
  const exportsMap = {
478
522
  // The ONE door discovery opens. `resolvePackageCompanionEntryPath` reads this subpath from the
479
523
  // manifest and hands the resolved path to the loader, so no application ever writes the
@@ -498,7 +542,7 @@ function renderPackageJson(providers) {
498
542
  }
499
543
  return `${JSON.stringify({
500
544
  name: PACKAGE_NAME,
501
- version: '0.0.0',
545
+ version,
502
546
  type: 'module',
503
547
  description: `Wildo provider catalogue: ${providers.length} vendors transposed from open integration catalogues. Each vendor is a subpath export; there is no root barrel.`,
504
548
  license: 'MIT',
@@ -931,13 +975,11 @@ function renderBackendModule(provider, operations, authored, decisions) {
931
975
  // without importing them emits a module that reads correctly and does not compile.
932
976
  const admissible = renderAdmissibleConnections(decisions);
933
977
  const envPrefix = envPrefixFor(provider.ref);
934
- const secretEnvVar = `${envPrefix}_API_KEY`;
978
+ const secretEnvVar = accountSecretEnvVarFor(provider, envPrefix);
935
979
  const header = authHeaderFor(provider.auth.kind);
936
980
  return `${GENERATED_BANNER}
937
981
 
938
- import { z } from 'zod';
939
-
940
- import { ProviderProtocolRuntimeKind, ExternalProvider_ExchangeProtocol_Kind${admissible === '' ? '' : ', ExternalProvider_Connection_DelegationMode, ExternalProvider_Connection_OwnerScope'} } from '@wildo-ai/external-connectors-models';
982
+ import { ProviderProtocolRuntimeKind, ExternalProvider_ExchangeProtocol_Kind${provider.baseUrl === undefined ? ', ExternalProvider_SecretScope' : ''}${admissible === '' ? '' : ', ExternalProvider_Connection_DelegationMode, ExternalProvider_Connection_OwnerScope'} } from '@wildo-ai/external-connectors-models';
941
983
  import { defineProviderMetadata, ProviderCatalogueSource, ProviderOriginKind, ProviderTier } from '@wildo-ai/saas-models';
942
984
  import type { ProviderOperationExecute } from '@wildo-ai/external-connectors-models';
943
985
  import type { ExternalProvider_ConnectionTarget } from '@wildo-ai/external-connectors-models';
@@ -986,11 +1028,6 @@ ${renderSecretsContract(provider, secretEnvVar, envPrefix)} },
986
1028
  // \`TProtocol extends string\`, so the wrong one compiled — and every generated provider carried
987
1029
  // it, unloadable, until the chain was walked instead of doubled.
988
1030
  protocol: 'REST_API',
989
- // The operation catalogue is the authoring surface, and it is DATA rather than an editable
990
- // parameter shape, so the binding exposes nothing to the visual editor and validates nothing
991
- // at the binding level: each operation carries its own input schema, checked by the executor.
992
- designTimeExposed: false,
993
- parameterSchema: z.unknown(),
994
1031
  runtimeContract: {
995
1032
  kind: ProviderProtocolRuntimeKind.REST,
996
1033
  ${provider.baseUrl === undefined ? ` // No single base URL was recovered from the source; the deployment names it.
@@ -1336,13 +1373,96 @@ function renderContributionSecretShape(provider, envPrefix) {
1336
1373
  description: ${quote(description)},
1337
1374
  },
1338
1375
  `;
1376
+ // Sorted by slug, which `ProviderSecretContractShapeSchema.superRefine` enforces — so `baseUrl`
1377
+ // sits after `apiKey`/`accessToken` and before `clientId`, not at the end where it reads naturally.
1378
+ const baseUrl = provider.baseUrl !== undefined
1379
+ ? ''
1380
+ : entry('baseUrl', `${envPrefix}_BASE_URL`, true, baseUrlSlotDescription(provider.vendor));
1339
1381
  if (provider.auth.kind !== TransposedAuthKind.OAUTH2) {
1340
- return entry('apiKey', `${envPrefix}_API_KEY`, true, `Credential for ${provider.vendor}, transposed as ${provider.auth.kind}.`);
1382
+ return entry('apiKey', accountSecretEnvVarFor(provider, envPrefix), true, `Credential for ${provider.vendor}, transposed as ${provider.auth.kind}.`) + baseUrl;
1341
1383
  }
1342
- return (entry('accessToken', `${envPrefix}_API_KEY`, false, `Access token for ${provider.vendor}. Minted by the OAuth2 exchange, not authored — set it only if ${provider.vendor} issues a long-lived token.`)
1384
+ return (entry('accessToken', accountSecretEnvVarFor(provider, envPrefix), false, `Access token for ${provider.vendor}. Minted by the OAuth2 exchange, not authored — set it only if ${provider.vendor} issues a long-lived token.`)
1385
+ + baseUrl
1343
1386
  + entry('clientId', `${envPrefix}_CLIENT_ID`, true, `OAuth2 client id for the application's ${provider.vendor} registration.`)
1344
1387
  + entry('clientSecret', `${envPrefix}_CLIENT_SECRET`, true, `OAuth2 client secret for the application's ${provider.vendor} registration.`));
1345
1388
  }
1389
+ /**
1390
+ * The BASE URL slot, for a vendor whose base URL the deployment names.
1391
+ *
1392
+ * ## Why a base URL is in the SECRETS contract, which is not a contradiction
1393
+ *
1394
+ * `secretsContract` is the provider's declared ENVIRONMENT surface, not a list of things that are
1395
+ * secret. The env builder says so where it matters — "a provider whose configuration is a hostname
1396
+ * or a database name puts THAT in its contract too: immudb and odoo both do" — and immudb declares
1397
+ * `host` and `port` there for exactly this reason.
1398
+ *
1399
+ * It has to, because that contract is the ALLOW-LIST. `filterProviderEnvToScope` admits a
1400
+ * `providerEnv` key only when some declared slot names it, and drops the rest. A base URL declared
1401
+ * ONLY as `baseUrlEnvVarName` on the runtime contract is named by nothing the builder reads, so it
1402
+ * was stripped from every runtime — measured 2026-09-10, `ASANA_BASE_URL` was authored in the
1403
+ * application's secrets and absent from the generated `.env`, while `ASANA_CLIENT_ID` and
1404
+ * `ASANA_CLIENT_SECRET` beside it came through. 465 of the 684 generated vendors declare
1405
+ * `baseUrlEnvVarName` and NONE of them declared the matching slot, so this is the whole population:
1406
+ * a connection could be minted and its operations then had no base URL to call.
1407
+ *
1408
+ * ## REGISTRATION, declared explicitly, because the derivation cannot see this one
1409
+ *
1410
+ * `getProviderSecretScope` falls back to REGISTRATION only for the two refs the OAuth2 block names,
1411
+ * and CREDENTIAL for everything else. A base URL is neither, so an undeclared slot would classify as
1412
+ * CREDENTIAL — and the `scope` field's own JSDoc names that consequence: "a registration it cannot
1413
+ * see is one a tenant could store as if it were their own credential". A tenant-supplied base URL is
1414
+ * the address every one of that provider's calls is sent to, so it is the last thing that may be
1415
+ * per-tenant credential material. Declared REGISTRATION, the connect leg refuses it with
1416
+ * `SECRET_SLUG_NOT_A_CREDENTIAL` and the catalogue reports it under `missingRegistration`, where an
1417
+ * operator can see what is owed.
1418
+ *
1419
+ * `required: true` is the honest statement — such a provider cannot execute an operation without it
1420
+ * — and does not gate boot: `clientId` and `clientSecret` are required on all 684 vendors and most
1421
+ * deployments configure none of them. Connectability is unaffected too; `connectabilityBlocker`
1422
+ * reads the two OAuth2 refs and nothing else.
1423
+ *
1424
+ * Emitted only when no literal `baseUrl` was recovered, which is the same condition that emits
1425
+ * `baseUrlEnvVarName` — the two are one decision and must not drift apart.
1426
+ */
1427
+ function renderBaseUrlSecretSlot(provider, envPrefix) {
1428
+ if (provider.baseUrl !== undefined)
1429
+ return '';
1430
+ return ` baseUrl: {
1431
+ envVarName: ${quote(`${envPrefix}_BASE_URL`)},
1432
+ required: true,
1433
+ scope: ExternalProvider_SecretScope.REGISTRATION,
1434
+ description: ${quote(baseUrlSlotDescription(provider.vendor))},
1435
+ },
1436
+ `;
1437
+ }
1438
+ /** One wording, so the module and the discovery contribution cannot describe the slot differently. */
1439
+ function baseUrlSlotDescription(vendor) {
1440
+ return `API base URL for ${vendor}. No single base URL was recovered from the source catalogue, so the deployment names it; without it this provider's operations have no address to call.`;
1441
+ }
1442
+ /**
1443
+ * What the ACCOUNT slot is called — and for an OAuth2 vendor it is not an API key.
1444
+ *
1445
+ * Every vendor used to get `<PREFIX>_API_KEY`, including the 99 whose credential is a MINTED OAuth2
1446
+ * access token that no operator ever types. That name is the row's storage key and it is what a
1447
+ * person sees on their connected-accounts card, so Wonder Todos showed a delegated Asana grant as
1448
+ * `asana · ASANA_API_KEY` — and the first question anybody asked was "why apikey? we did it with
1449
+ * oauth". The name was answering wrongly, and a display-side relabel would have left the storage key
1450
+ * and the environment surface still saying "API key".
1451
+ *
1452
+ * The slot's AUTHORING slug already made the distinction — `accessToken` for OAuth2, `apiKey`
1453
+ * otherwise (see {@link renderSecretsContract}) — so this only brings the env-var name into
1454
+ * agreement with the slug beside it.
1455
+ *
1456
+ * Safe to rename for exactly the reason the slot exists: an OAuth2 vendor's account slot is
1457
+ * `required: false` and documented as "minted by the OAuth2 exchange, not authored", so no
1458
+ * deployment sets it and no operator instruction changes. A credential already stored under the old
1459
+ * name is keyed by it, so a tenant that connected before this reconnects once.
1460
+ */
1461
+ function accountSecretEnvVarFor(provider, envPrefix) {
1462
+ return provider.auth.kind === TransposedAuthKind.OAUTH2
1463
+ ? `${envPrefix}_ACCESS_TOKEN`
1464
+ : `${envPrefix}_API_KEY`;
1465
+ }
1346
1466
  /** The env-var prefix a vendor's credential takes. One derivation, used by both emitted files. */
1347
1467
  function envPrefixFor(ref) {
1348
1468
  return ref.replace(/[^a-zA-Z0-9]+/g, '_').toUpperCase();
@@ -1364,7 +1484,7 @@ function renderSecretsContract(provider, secretEnvVar, envPrefix) {
1364
1484
  required: true,
1365
1485
  description: ${quote(`Credential for ${provider.vendor}, transposed as ${provider.auth.kind}.`)},
1366
1486
  },
1367
- `;
1487
+ ` + renderBaseUrlSecretSlot(provider, envPrefix);
1368
1488
  }
1369
1489
  return ` clientId: {
1370
1490
  envVarName: ${quote(`${envPrefix}_CLIENT_ID`)},
@@ -1381,7 +1501,7 @@ function renderSecretsContract(provider, secretEnvVar, envPrefix) {
1381
1501
  required: false,
1382
1502
  description: ${quote(`Access token for ${provider.vendor}. Minted by the OAuth2 exchange, not authored — set it only if ${provider.vendor} issues a long-lived token.`)},
1383
1503
  },
1384
- `;
1504
+ ` + renderBaseUrlSecretSlot(provider, envPrefix);
1385
1505
  }
1386
1506
  /**
1387
1507
  * The OAuth2 declaration, emitted as DATA rather than as the JSDoc comment it used to be.