Skip to content

Commit 5c189e6

Browse files
committed
feat(spec): an explicit retryConfig in a connector save replaces the stored one whole
Ruling 6593804783: a save that sends retryConfig (the served form, {} or any object) replaces the stored container whole; a key the closed retryConfig does not declare is not carried forward into it, and the save names each key it dropped. A save that leaves retryConfig out removes it, as before. Pinned at the spec redactor, the metadata-protocol carry-forward and the HTTP save door, with controls: a withheld header map on the same save is still carried forward, omission still removes the container, and a non-object retryConfig is still kept at rest by a save that leaves it out. Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9a0d877 commit 5c189e6

5 files changed

Lines changed: 188 additions & 44 deletions

‎packages/metadata-protocol/src/metadata-redaction.connector-undeclared-keys.test.ts‎

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
//
33
// The write-path inverse of the connector read projection, for the keys a
44
// connector does not declare: a save of the served form keeps what the read
5-
// withheld (top level, `retryConfig`, and an `actions` element addressed by
6-
// its `key`), and a container the author removed is never minted back.
5+
// withheld at the top level and in an `actions` element addressed by its
6+
// `key`; a container the author removed is never minted back; and an
7+
// undeclared key of an object `retryConfig` is not carried forward — a save
8+
// that sends `retryConfig` replaces the stored one whole (ruling 6593804783).
79
//
810
// Every value below is an obviously-fake placeholder.
911

@@ -40,9 +42,9 @@ describe('carry-forward of the keys a connector does not declare', () => {
4042
expect(body.actions[0]).toEqual({ key: 'get_invoice', label: 'Get invoice' });
4143
});
4244

43-
it('a save of the served form keeps every withheld value, the edited label included', () => {
45+
it('a save of the served form keeps every carried-forward withheld value, the edited label included', () => {
4446
const out = carryForwardRedactedValues('connector', { ...served(), label: 'Vendor catalog (edited)' }, stored);
45-
expect(out).toEqual({ ...stored, label: 'Vendor catalog (edited)' });
47+
expect(out).toEqual({ ...stored, label: 'Vendor catalog (edited)', retryConfig: { strategy: 'exponential_backoff' } });
4648
});
4749

4850
it('an `actions` element is followed by its `key` when the author reorders the list', () => {
@@ -90,6 +92,35 @@ describe('carry-forward of the keys a connector does not declare', () => {
9092
});
9193
});
9294

95+
// [ruling 6593804783] An undeclared key of an object `retryConfig` is withheld
96+
// AND not carried forward: a save that sends `retryConfig` replaces the stored
97+
// container whole, and the drop is reported.
98+
describe('an undeclared `retryConfig` key is not carried forward', () => {
99+
it('a save of the served form drops it, names it, and still carries the top-level and `actions` values', () => {
100+
const { item, dropped } = carryForwardRedactedValuesReportingDrops('connector', served(), stored);
101+
expect(item).toEqual({ ...stored, retryConfig: { strategy: 'exponential_backoff' } });
102+
expect(dropped).toEqual(['retryConfig.secret']);
103+
});
104+
105+
it('`retryConfig: {}` replaces the stored container whole', () => {
106+
const { item, dropped } = carryForwardRedactedValuesReportingDrops('connector', { ...served(), retryConfig: {} }, stored);
107+
expect((item as Record<string, any>).retryConfig).toEqual({});
108+
expect(dropped).toEqual(['retryConfig.secret']);
109+
});
110+
111+
it('a body that removes `retryConfig` removes it, as before, and says so', () => {
112+
const body = served();
113+
delete body.retryConfig;
114+
const { item, dropped } = carryForwardRedactedValuesReportingDrops('connector', body, stored);
115+
expect(item).not.toHaveProperty('retryConfig');
116+
expect(dropped).toEqual(['retryConfig.secret']);
117+
});
118+
119+
it('the runtime gate is never told it will be restored', () => {
120+
expect(redactedPathsCarriedForward('connector', served(), stored).sort()).toEqual(['actions.0.token', 'apiKey']);
121+
});
122+
});
123+
93124
// [#28640 ②B] An undeclared `auth` key is withheld AND not carried forward: a
94125
// save of the served form drops it, and the drop is reported.
95126
describe('an undeclared `auth` key is not carried forward', () => {
@@ -136,8 +167,10 @@ describe('an undeclared `auth` key is not carried forward', () => {
136167
expect(dropped).toEqual(['auth.token']);
137168
});
138169

139-
it('CONTROL: a row with no undeclared `auth` key reports no drop', () => {
140-
const { dropped } = carryForwardRedactedValuesReportingDrops('connector', served(), stored);
170+
it('CONTROL: a row with no undeclared `auth` or `retryConfig` key reports no drop', () => {
171+
const atRest = { ...stored, retryConfig: { strategy: 'exponential_backoff' } };
172+
const body = JSON.parse(JSON.stringify(redactMetadataItem('connector', atRest)));
173+
const { dropped } = carryForwardRedactedValuesReportingDrops('connector', body, atRest);
141174
expect(dropped).toEqual([]);
142175
});
143176
});

‎packages/qa/dogfood/test/connector-meta-door-undeclared-keys-withheld.dogfood.test.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// reads, and on the published read of a package published twice (whose
1313
// second snapshot nests the first). The stored rows are never touched.
1414
// - CARRY-FORWARD: a save of the served form succeeds and keeps every stored
15-
// value; a `retryConfig` the author removes is removed.
15+
// value at the top level and in an `actions` element; a `retryConfig` sent
16+
// back as served replaces the stored one whole, and one the author removes
17+
// is removed.
1618
// - CONTROL: an instance that names its secret with `credentialRef` saves,
1719
// materializes and dispatches upstream with the reference resolved.
1820
//
@@ -272,11 +274,11 @@ describe('connector metadata doors: keys a connector does not declare are withhe
272274
]);
273275
});
274276

275-
it('a `retryConfig` the author removes is removed; one sent back as served keeps its stored key', async () => {
277+
it('a `retryConfig` sent back as served replaces the stored one whole; one the author removes is removed', async () => {
276278
const served = authorable((await read(admin, RETRY)).item);
277-
const kept = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY}`, { ...served, label: 'CUK retry (edited)' });
278-
expect(kept.status, await kept.clone().text()).toBe(200);
279-
expect(bodyOf((await stored(RETRY))[0]).retryConfig.secret).toBe(PLACEHOLDERS.retry);
279+
const replaced = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY}`, { ...served, label: 'CUK retry (edited)' });
280+
expect(replaced.status, await replaced.clone().text()).toBe(200);
281+
expect(bodyOf((await stored(RETRY))[0]).retryConfig).toEqual({ strategy: 'exponential_backoff', maxAttempts: 2 });
280282

281283
const { retryConfig: _removed, ...withoutRetry } = served;
282284
const cleared = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY}`, withoutRetry);

‎packages/qa/dogfood/test/connector-meta-door-url-and-nested-keys.dogfood.test.ts‎

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@
2121
// and to an administrator, in the item, layered and list reads. The stored
2222
// row is never touched.
2323
// - CARRY-FORWARD: a save of the served form keeps the stored values; an
24-
// author's own edit of a served URL is stored as the author wrote it; a
25-
// `retryConfig` the author removes is removed with its stored keys.
24+
// author's own edit of a served URL is stored as the author wrote it. An
25+
// explicit `retryConfig` — `{}` or the served form — replaces the stored
26+
// one whole: a key it does not declare is gone from the next read of the
27+
// stored row, and the answer names it, while a withheld header map on the
28+
// same row is kept (CONTROL). A `retryConfig` the author leaves out is
29+
// removed with its stored keys, as before (CONTROL), and one stored as a
30+
// non-object is still kept at rest by a save that leaves it out (CONTROL).
2631
//
2732
// Every credential below is an obviously-fake placeholder, and every assertion
2833
// on one is its absence from what a door served or stored, or its presence at
@@ -41,6 +46,7 @@ const PLACEHOLDERS = {
4146
urlToken: 'TEST_PLACEHOLDER_CUN_URL_TOKEN',
4247
urlQuery: 'TEST_PLACEHOLDER_CUN_URL_QUERY',
4348
nested: 'TEST_PLACEHOLDER_CUN_NESTED',
49+
header: 'TEST_PLACEHOLDER_CUN_HEADER',
4450
authEndpoint: 'TEST_PLACEHOLDER_CUN_AUTH_ENDPOINT',
4551
resolvedRef: 'TEST_PLACEHOLDER_CUN_RESOLVED_REFERENCE',
4652
} as const;
@@ -53,6 +59,9 @@ const DESCRIPTOR = 'cun_descriptor';
5359
const EXISTING = 'cun_existing';
5460
const OAUTH_ROW = 'cun_oauth_stored';
5561
const RETRY_ROW = 'cun_retry_stored';
62+
const RETRY_EMPTY = 'cun_retry_empty';
63+
const RETRY_OMIT = 'cun_retry_omit';
64+
const RETRY_MALFORMED = 'cun_retry_malformed';
5665

5766
const rowsOf = (r: any): any[] => (Array.isArray(r) ? r : Array.isArray(r?.records) ? r.records : Array.isArray(r?.value) ? r.value : []);
5867
const bodyOf = (row: any): Record<string, any> =>
@@ -184,10 +193,18 @@ describe('connector metadata doors: an authored connector keeps no credential in
184193
tokenUrl: `https://cun:${PLACEHOLDERS.authEndpoint}@auth.vendor.example.com/token`,
185194
authorizationUrl: `https://${PLACEHOLDERS.authEndpoint}@auth.vendor.example.com/authorize?region=eu`,
186195
}));
196+
// Each also holds a withheld header map, carried forward: the control on the same save.
197+
for (const name of [RETRY_ROW, RETRY_EMPTY, RETRY_OMIT]) {
198+
await seedOver(name, instance(name, { retryConfig: { maxAttempts: 2 } }), instance(name, {
199+
providerConfig: { baseUrl: `${upstreamUrl}/v1`, defaultHeaders: { Authorization: `Bearer ${PLACEHOLDERS.header}` } },
200+
retryConfig: { maxAttempts: 2, secret: PLACEHOLDERS.nested },
201+
}));
202+
}
203+
// Saved disabled: the pin is the door's answer, not a materialization of a policy no parse accepts.
187204
await seedOver(
188-
RETRY_ROW,
189-
instance(RETRY_ROW, { retryConfig: { maxAttempts: 2 } }),
190-
instance(RETRY_ROW, { retryConfig: { maxAttempts: 2, secret: PLACEHOLDERS.nested } }),
205+
RETRY_MALFORMED,
206+
instance(RETRY_MALFORMED, { enabled: false }),
207+
instance(RETRY_MALFORMED, { enabled: false, retryConfig: PLACEHOLDERS.nested }),
191208
);
192209
}, 180_000);
193210

@@ -345,17 +362,53 @@ describe('connector metadata doors: an authored connector keeps no credential in
345362
expect(atRest.auth.authorizationUrl).toBe(`https://${PLACEHOLDERS.authEndpoint}@auth.vendor.example.com/authorize?region=eu`);
346363
});
347364

348-
it('a stored undeclared `retryConfig` key: kept on a save of the served form, cleared when the author removes `retryConfig`', async () => {
349-
const served = authorable((await read(admin, RETRY_ROW)).item);
365+
const HEADERS_AT_REST = () => ({ Authorization: `Bearer ${PLACEHOLDERS.header}` });
366+
367+
it('`retryConfig: {}` replaces the stored one whole: the next read of the stored row no longer has the undeclared key', async () => {
368+
expect(bodyOf((await stored(RETRY_EMPTY))[0]).retryConfig, 'guard the guard: the seeded row holds the key')
369+
.toEqual({ maxAttempts: 2, secret: PLACEHOLDERS.nested });
370+
const served = authorable((await read(admin, RETRY_EMPTY)).item);
350371
expect(served.retryConfig).toEqual({ maxAttempts: 2 });
351-
const kept = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY_ROW}`, { ...served, label: 'CUN retry (edited)' });
352-
expect(kept.status, await kept.clone().text()).toBe(200);
353-
expect(bodyOf((await stored(RETRY_ROW))[0]).retryConfig).toEqual({ maxAttempts: 2, secret: PLACEHOLDERS.nested });
354-
355-
const { retryConfig: _removed, ...withoutRetry } = served;
356-
const cleared = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY_ROW}`, withoutRetry);
357-
expect(cleared.status, await cleared.clone().text()).toBe(200);
358-
expect(bodyOf((await stored(RETRY_ROW))[0])).not.toHaveProperty('retryConfig');
372+
const res = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY_EMPTY}`, { ...served, retryConfig: {} });
373+
const text = await res.text();
374+
expect(res.status, text.slice(0, 300)).toBe(200);
375+
expect(JSON.parse(text).data.advisories, 'the save names the key it did not carry forward').toEqual([
376+
expect.objectContaining({ rule: 'withheld-key-dropped', severity: 'warning', path: 'connectors[0].retryConfig.secret' }),
377+
]);
378+
expect(text.includes(PLACEHOLDERS.nested), 'the answer names the key, never its value').toBe(false);
379+
const atRest = bodyOf((await stored(RETRY_EMPTY))[0]);
380+
expect(atRest.retryConfig).toEqual({});
381+
// CONTROL, the same save: a withheld position outside `retryConfig` is still carried forward.
382+
expect(atRest.providerConfig.defaultHeaders).toEqual(HEADERS_AT_REST());
383+
});
384+
385+
it('a save of the served form replaces the stored `retryConfig` whole too', async () => {
386+
const served = authorable((await read(admin, RETRY_ROW)).item);
387+
const res = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY_ROW}`, { ...served, label: 'CUN retry (edited)' });
388+
expect(res.status, await res.clone().text()).toBe(200);
389+
const atRest = bodyOf((await stored(RETRY_ROW))[0]);
390+
expect(atRest.label).toBe('CUN retry (edited)');
391+
expect(atRest.retryConfig).toEqual({ maxAttempts: 2 });
392+
expect(atRest.providerConfig.defaultHeaders).toEqual(HEADERS_AT_REST());
393+
});
394+
395+
it('CONTROL: a save that leaves `retryConfig` out removes it with its stored keys, as before', async () => {
396+
const { retryConfig: _removed, ...withoutRetry } = authorable((await read(admin, RETRY_OMIT)).item);
397+
const res = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY_OMIT}`, withoutRetry);
398+
expect(res.status, await res.clone().text()).toBe(200);
399+
const atRest = bodyOf((await stored(RETRY_OMIT))[0]);
400+
expect(atRest).not.toHaveProperty('retryConfig');
401+
expect(atRest.providerConfig.defaultHeaders).toEqual(HEADERS_AT_REST());
402+
});
403+
404+
it('CONTROL: a `retryConfig` stored as a non-object is withheld whole and still carried forward by a save that leaves it out', async () => {
405+
const served = authorable((await read(admin, RETRY_MALFORMED)).item);
406+
expect(served).not.toHaveProperty('retryConfig');
407+
const res = await stack.apiAs(admin, 'PUT', `/meta/connector/${RETRY_MALFORMED}`, { ...served, label: 'CUN retry malformed (edited)' });
408+
expect(res.status, await res.clone().text()).toBe(200);
409+
const atRest = bodyOf((await stored(RETRY_MALFORMED))[0]);
410+
expect(atRest.label).toBe('CUN retry malformed (edited)');
411+
expect(atRest.retryConfig).toBe(PLACEHOLDERS.nested);
359412
});
360413
});
361414
});

‎packages/spec/src/integration/connector-credential-redaction.test.ts‎

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,9 @@ describe('the connector redactor — purity and the untouched remainder', () =>
456456
});
457457
});
458458

459-
// [#28640 ②B, ruling 6566912252] Which withheld positions a save does NOT carry
460-
// forward: the undeclared `auth` keys, and nothing else.
459+
// [#28640 ②B, ruling 6566912252; ruling 6593804783] Which withheld positions a
460+
// save does NOT carry forward: the undeclared `auth` keys and the undeclared
461+
// keys of an object `retryConfig`, and nothing else.
461462
describe('the connector redactor — withheld and not carried forward', () => {
462463
it('names every undeclared `auth` key in `notCarriedForwardKeys` as well as in `redactedKeys`', () => {
463464
const { item: served, redactedKeys, notCarriedForwardKeys } = redactConnectorItem({
@@ -496,7 +497,6 @@ describe('the connector redactor — withheld and not carried forward', () => {
496497
...base,
497498
apiKey: P(73),
498499
authentication: { type: 'api-key', key: P(74) },
499-
retryConfig: { strategy: 'exponential_backoff', secret: P(75) },
500500
actions: [{ key: 'get_invoice', label: 'Get invoice', token: P(76) }],
501501
providerConfig: {
502502
baseUrl: `https://u:${P(77)}@v.example`,
@@ -508,11 +508,42 @@ describe('the connector redactor — withheld and not carried forward', () => {
508508
});
509509
expect(result.redactedKeys).toEqual([
510510
'actions.0.token', 'apiKey', 'authentication.key', 'providerConfig.baseUrl', 'providerConfig.defaultHeaders',
511-
'providerConfig.headers', 'providerConfig.transport.env', 'providerConfig.transport.headers', 'retryConfig.secret',
511+
'providerConfig.headers', 'providerConfig.transport.env', 'providerConfig.transport.headers',
512512
]);
513513
expect(result).not.toHaveProperty('notCarriedForwardKeys');
514514
});
515515

516+
it('names every undeclared key of an object `retryConfig` in `notCarriedForwardKeys` as well as in `redactedKeys`', () => {
517+
const { item: served, redactedKeys, notCarriedForwardKeys } = redactConnectorItem({
518+
...base, retryConfig: { strategy: 'exponential_backoff', maxAttempts: 2, secret: P(75), token: P(85) },
519+
});
520+
expect(redactedKeys).toEqual(['retryConfig.secret', 'retryConfig.token']);
521+
expect(notCarriedForwardKeys).toEqual(['retryConfig.secret', 'retryConfig.token']);
522+
expect(served.retryConfig).toEqual({ strategy: 'exponential_backoff', maxAttempts: 2 });
523+
});
524+
525+
it('a cleared undeclared `retryConfig` key is withheld and not carried forward too', () => {
526+
const { redactedKeys, notCarriedForwardKeys } = redactConnectorItem({ ...base, retryConfig: { maxAttempts: 2, secret: null } });
527+
expect(redactedKeys).toEqual(['retryConfig.secret']);
528+
expect(notCarriedForwardKeys).toEqual(['retryConfig.secret']);
529+
});
530+
531+
it('CONTROL: a `retryConfig` that is not an object is withheld whole and still carried forward', () => {
532+
const result = redactConnectorItem({ ...base, retryConfig: P(86) });
533+
expect(result.redactedKeys).toEqual(['retryConfig']);
534+
expect(result).not.toHaveProperty('notCarriedForwardKeys');
535+
});
536+
537+
it('beside an `actions` element\'s undeclared key, only the `retryConfig` key is marked', () => {
538+
const { redactedKeys, notCarriedForwardKeys } = redactConnectorItem({
539+
...base,
540+
retryConfig: { strategy: 'exponential_backoff', secret: P(87) },
541+
actions: [{ key: 'get_invoice', label: 'Get invoice', token: P(88) }],
542+
});
543+
expect(redactedKeys).toEqual(['actions.0.token', 'retryConfig.secret']);
544+
expect(notCarriedForwardKeys).toEqual(['retryConfig.secret']);
545+
});
546+
516547
it('CONTROL: `auth` that is not an object is withheld whole and still carried forward', () => {
517548
const result = redactConnectorItem({ ...base, auth: P(81) });
518549
expect(result.redactedKeys).toEqual(['auth']);

0 commit comments

Comments
 (0)