Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 14:45 UTC
test(core): make $ref contract holdout exclusive, flag polluting-key refs unresolvable
jkomyno committed
Aug 28, 2026 at 14:20 UTC
2777545a4c9532e5bc505088ead146a287114aa7
2 files changed
+33
-16
ts/packages/core/test/providers/refContract.test.ts
+21
-15
@@ -156,14 +156,19 @@ describe('cross-provider $ref handling contract', () => {
156
expect(stale).toEqual([]);
157
});
158
159
- describe.each(Object.entries(PROVIDER_PACKAGES).filter(([, c]) => c.treatment === 'needs-deref'))(
160
- '%s',
161
- (provider, classification) => {
162
- it(`dereferences before translation (${classification.reason})`, () => {
163
- expect(packageText(provider)).toContain(DEREF_MARK);
164
- });
165
- }
166
- );
159
+ const isPending = (c: Classification) => c.status?.startsWith('pending-plan') ?? false;
160
+
161
+ // Fixed needs-deref providers only: a `pending-plan-*` entry is asserted by
162
+ // the ratchet at the bottom instead, so the two blocks never both claim it.
163
+ describe.each(
164
+ Object.entries(PROVIDER_PACKAGES).filter(
165
+ ([, c]) => c.treatment === 'needs-deref' && !isPending(c)
166
+ )
167
+ )('%s', (provider, classification) => {
168
+ it(`dereferences before translation (${classification.reason})`, () => {
169
+ expect(packageText(provider)).toContain(DEREF_MARK);
170
+ });
171
+ });
172
173
describe.each(Object.entries(PROVIDER_PACKAGES).filter(([, c]) => c.treatment === 'passthrough'))(
174
'%s',
@@ -186,11 +191,12 @@ describe('cross-provider $ref handling contract', () => {
191
// fix, give it `status: 'pending-plan-NNN'` and it is asserted NOT to
192
// dereference here — so the fix cannot land and leave the taxonomy stale
193
// (the assertion flips the moment the dereference call appears).
189
- describe.each(
190
- Object.entries(PROVIDER_PACKAGES).filter(([, c]) => c.status?.startsWith('pending-plan'))
191
- )('%s', (provider, classification) => {
192
- it(`is still pending (${classification.status})`, () => {
193
- expect(packageText(provider)).not.toContain(DEREF_MARK);
194
- });
195
- });
194
+ describe.each(Object.entries(PROVIDER_PACKAGES).filter(([, c]) => isPending(c)))(
195
+ '%s',
196
+ (provider, classification) => {
197
+ it(`is still pending (${classification.status})`, () => {
198
+ expect(packageText(provider)).not.toContain(DEREF_MARK);
199
+ });
200
+ }
201
+ );
202
});
ts/packages/core/test/utils/jsonSchema.deref.property.test.ts
+12
-1
@@ -72,10 +72,21 @@ function generateDoc(rng: () => number, withInstanceValueRefs = false): Generate
72
const escapePointer = (name: string) => name.replace(/~/g, '~0').replace(/\//g, '~1');
73
74
const defsKey = chance(0.25) ? 'definitions' : '$defs';
75
- const pointerTo = (name: string) => `#/${defsKey}/${escapePointer(name)}`;
75
76
const state = { hasUnresolvable: false };
77
78
+ // Mirrors `POLLUTING_KEYS` in `jsonSchema.ts`. A definition under one of
79
+ // these names is never an own `$defs` entry (assigning `__proto__` sets the
80
+ // prototype; the clone step drops the rest), so any pointer to it is
81
+ // unresolvable exactly like a dangling one and must set the flag too —
82
+ // otherwise the throw-mode ratchet below could stay red for a reason
83
+ // unrelated to the instance-value bug it documents.
84
+ const POLLUTING_DEF_NAMES = new Set(['__proto__', 'constructor', 'prototype']);
85
+ const pointerTo = (name: string) => {
86
+ if (POLLUTING_DEF_NAMES.has(name)) state.hasUnresolvable = true;
87
+ return `#/${defsKey}/${escapePointer(name)}`;
88
+ };
89
+
90
const leaf = (): Json => {
91
const node: Json = { type: pick(rng, ['string', 'number', 'integer', 'boolean']) };
92
// `$ref`-shaped *data*. Only injected for the dedicated test block, so the