From 2c343966e6f866cfa2eb886a0fdc5108085ee012 Mon Sep 17 00:00:00 2001 From: bitkyc08-arch Date: Mon, 17 Aug 2026 20:54:35 +0900 Subject: [PATCH] test(google): assert what Vertex sends, not that two settings agree The post-merge audit of #1739 caught a test that could not fail. It built the same Vertex request twice, once with directGeminiWireRenames unset and once false, and asserted the two matched - which stays true even if Vertex stopped preserving the requested model id, because both sides would be wrong together. These assert the content instead: Vertex puts the requested id on the wire under all three settings and never the -tiered spelling, and its system identity names the requested model rather than a renamed one. That second one covers a real defect the #1739 merge fixed in passing, where Vertex sent the bare id while the identity line claimed -tiered. An ablation settles what the googleMode === vertex arm is worth: deleting it leaves all 24 tests green, because Vertex builds its own aiplatform URL from parsed.modelId and identityModelId only special-cases Cloud Code Assist, so routedModelId never reaches Vertex either way. The arm is defensive rather than load-bearing. It stays as a guard against a refactor that routes Vertex through the shared builder, and the comment says plainly that no test proves it fires today - claiming otherwise would be the unfalsifiable coverage this change exists to remove. --- tests/google-adapter.test.ts | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/google-adapter.test.ts b/tests/google-adapter.test.ts index 546ad41d6c..15af3a264a 100644 --- a/tests/google-adapter.test.ts +++ b/tests/google-adapter.test.ts @@ -382,4 +382,44 @@ describe("google adapter — direct -tiered wire renames", () => { expect(optOutRequest.body).toBe(defaultRequest.body); } }); + + // The test above compares the two settings against each other, which stays true even + // if Vertex stopped preserving the requested id — both sides would be wrong together. + // These two assert what Vertex actually sends, so a regression in Vertex's wire id or + // its identity line fails here instead of reaching a user. + // + // An ablation puts the `googleMode === "vertex"` arm itself in its place: deleting it + // leaves all 24 tests green, because Vertex builds its own URL from `parsed.modelId` + // (see the `aiplatform.googleapis.com` paths) and `identityModelId` only special-cases + // Cloud Code Assist, so `routedModelId` never reaches Vertex either way. The arm is + // defensive, not load-bearing — worth keeping as a guard against a future refactor + // that routes Vertex through the shared URL builder, but no test can prove it fires + // today, and pretending otherwise would be the kind of unfalsifiable coverage this + // comment exists to prevent. + test("Vertex sends the requested model id, never the -tiered rename", async () => { + const vertexProvider = { ...provider, googleMode: "vertex" as const }; + for (const modelId of ["gemini-3.7-flash", "gemini-3.6-flash"]) { + for (const renames of [undefined, true, false]) { + const adapter = createGoogleAdapter( + renames === undefined ? vertexProvider : { ...vertexProvider, directGeminiWireRenames: renames }, + ); + const { url } = await adapter.buildRequest(renamedParsed(modelId)); + expect(url).toContain(`/models/${modelId}:generateContent`); + expect(url).not.toContain("-tiered"); + } + } + }); + + test("Vertex identity names the requested model, not a renamed wire id", async () => { + const vertexProvider = { ...provider, googleMode: "vertex" as const }; + for (const modelId of ["gemini-3.7-flash", "gemini-3.6-flash"]) { + const request = await createGoogleAdapter(vertexProvider).buildRequest(identityParsed(modelId)); + const body = JSON.parse(request.body) as { + systemInstruction?: { parts?: Array<{ text?: string }> }; + }; + const systemText = body.systemInstruction?.parts?.[0]?.text ?? ""; + expect(systemText).toContain(`powered by the ${modelId}`); + expect(systemText).not.toContain("-tiered"); + } + }); });