feat(client): accept a cached era verdict on ConnectOptions.prior (#2511)

This commit is contained in:
Felix Weinberger 2026-07-17 17:25:02 +01:00 • committed by GitHub
commit f60dff0674
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 523 additions and 86 deletions

View file

@ -175,10 +175,10 @@ export const REQUIREMENTS: Record<string, Requirement> = {
'typescript:client:connect:prior-zero-roundtrip': {
source: 'sdk',
behavior:
'connect(transport, { prior: DiscoverResult }) against a 2026-07-28 server is zero-round-trip: a fresh client supplied with a previously-obtained DiscoverResult connects without putting any HTTP exchange on the wire, adopts the modern era directly, and callTool round-trips immediately. prior is modern-only — no modern overlap throws SdkError(EraNegotiationFailed) (no legacy fallback).',
"connect(transport, { prior: { kind: 'modern', discover } }) against a 2026-07-28 server is zero-round-trip: a fresh client supplied with a previously-obtained DiscoverResult (wrapped as a PriorDiscovery verdict) connects without putting any HTTP exchange on the wire, adopts the modern era directly, and callTool round-trips immediately. The modern verdict requires a modern overlap — none throws SdkError(EraNegotiationFailed) (no legacy fallback).",
transports: ['entryModern'],
addedInSpecVersion: '2026-07-28',
note: 'Runs on the entryModern arm; the wired (negotiating) client is the bootstrap that obtains the DiscoverResult, then a fresh worker client connects to the same harness-hosted endpoint via wired.url + a fresh StreamableHTTPClientTransport over wired.fetch with { prior }. The zero-round-trip clause is asserted on the arm-recorded httpLog length.'
note: "Runs on the entryModern arm; the wired (negotiating) client is the bootstrap that obtains the DiscoverResult, then a fresh worker client connects to the same harness-hosted endpoint via wired.url + a fresh StreamableHTTPClientTransport over wired.fetch with { prior: { kind: 'modern', discover } }. The zero-round-trip clause is asserted on the arm-recorded httpLog length."
},
'typescript:client:raw-result-type-first': {
source: 'sdk',

View file

@ -92,14 +92,16 @@ verifies('typescript:client:connect:prior-zero-roundtrip', async ({ transport }:
// the modern revision) populates getDiscoverResult().
const bootstrap = new Client({ name: 'bootstrap', version: '1.0.0' }, { versionNegotiation: { mode: 'auto' } });
await using wired = await wire(transport, greetFactory, bootstrap);
const prior = bootstrap.getDiscoverResult();
expect(prior).toBeDefined();
expect(prior!.supportedVersions).toContain(MODERN);
const discover = bootstrap.getDiscoverResult();
expect(discover).toBeDefined();
expect(discover!.supportedVersions).toContain(MODERN);
// Fresh worker → SAME hosted server, connect({ prior }): zero round trips.
const before = wired.httpLog!.length;
const worker = new Client({ name: 'worker', version: '1.0.0' });
await worker.connect(new StreamableHTTPClientTransport(wired.url!, { fetch: wired.fetch }), { prior });
await worker.connect(new StreamableHTTPClientTransport(wired.url!, { fetch: wired.fetch }), {
prior: { kind: 'modern', discover: discover! }
});
try {
// No HTTP exchange was added by the worker's connect().
expect(wired.httpLog!.length).toBe(before);