Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
test(core): make $ref contract holdout exclusive, flag polluting-key refs unresolvable
jkomyno2777545a4c95
diff --git a/ts/packages/core/test/providers/refContract.test.ts b/ts/packages/core/test/providers/refContract.test.tsindex 375e6df89..b9b5cf136 100644--- a/ts/packages/core/test/providers/refContract.test.ts+++ b/ts/packages/core/test/providers/refContract.test.ts@@ -156,14 +156,19 @@ describe('cross-provider $ref handling contract', () => {expect(stale).toEqual([]);});- describe.each(Object.entries(PROVIDER_PACKAGES).filter(([, c]) => c.treatment === 'needs-deref'))(- '%s',- (provider, classification) => {- it(`dereferences before translation (${classification.reason})`, () => {- expect(packageText(provider)).toContain(DEREF_MARK);- });- }- );+ const isPending = (c: Classification) => c.status?.startsWith('pending-plan') ?? false;++ // Fixed needs-deref providers only: a `pending-plan-*` entry is asserted by+ // the ratchet at the bottom instead, so the two blocks never both claim it.+ describe.each(+ Object.entries(PROVIDER_PACKAGES).filter(+ ([, c]) => c.treatment === 'needs-deref' && !isPending(c)+ )+ )('%s', (provider, classification) => {+ it(`dereferences before translation (${classification.reason})`, () => {+ expect(packageText(provider)).toContain(DEREF_MARK);+ });+ });describe.each(Object.entries(PROVIDER_PACKAGES).filter(([, c]) => c.treatment === 'passthrough'))('%s',@@ -186,11 +191,12 @@ describe('cross-provider $ref handling contract', () => {// fix, give it `status: 'pending-plan-NNN'` and it is asserted NOT to// dereference here — so the fix cannot land and leave the taxonomy stale// (the assertion flips the moment the dereference call appears).- describe.each(- Object.entries(PROVIDER_PACKAGES).filter(([, c]) => c.status?.startsWith('pending-plan'))- )('%s', (provider, classification) => {- it(`is still pending (${classification.status})`, () => {- expect(packageText(provider)).not.toContain(DEREF_MARK);- });- });+ describe.each(Object.entries(PROVIDER_PACKAGES).filter(([, c]) => isPending(c)))(+ '%s',+ (provider, classification) => {+ it(`is still pending (${classification.status})`, () => {+ expect(packageText(provider)).not.toContain(DEREF_MARK);+ });+ }+ );});diff --git a/ts/packages/core/test/utils/jsonSchema.deref.property.test.ts b/ts/packages/core/test/utils/jsonSchema.deref.property.test.tsindex b08c0c04a..486c8f1d3 100644--- a/ts/packages/core/test/utils/jsonSchema.deref.property.test.ts+++ b/ts/packages/core/test/utils/jsonSchema.deref.property.test.ts@@ -72,10 +72,21 @@ function generateDoc(rng: () => number, withInstanceValueRefs = false): Generateconst escapePointer = (name: string) => name.replace(/~/g, '~0').replace(/\//g, '~1');const defsKey = chance(0.25) ? 'definitions' : '$defs';- const pointerTo = (name: string) => `#/${defsKey}/${escapePointer(name)}`;const state = { hasUnresolvable: false };+ // Mirrors `POLLUTING_KEYS` in `jsonSchema.ts`. A definition under one of+ // these names is never an own `$defs` entry (assigning `__proto__` sets the+ // prototype; the clone step drops the rest), so any pointer to it is+ // unresolvable exactly like a dangling one and must set the flag too —+ // otherwise the throw-mode ratchet below could stay red for a reason+ // unrelated to the instance-value bug it documents.+ const POLLUTING_DEF_NAMES = new Set(['__proto__', 'constructor', 'prototype']);+ const pointerTo = (name: string) => {+ if (POLLUTING_DEF_NAMES.has(name)) state.hasUnresolvable = true;+ return `#/${defsKey}/${escapePointer(name)}`;+ };+const leaf = (): Json => {const node: Json = { type: pick(rng, ['string', 'number', 'integer', 'boolean']) };// `$ref`-shaped *data*. Only injected for the dedicated test block, so the