Skip to content

Commit eebd191

Browse files
committed
fix(google-antigravity): match the model component, not the whole Vertex identity
Ingwannu's review found the predicate scanned the entire raw replay identity. The Vertex key is vertex:<project>:<location>:<modelId> and the project id is operator-chosen, so a project named 'gemini-prod' armed the Gemini-only sentinel for a non-Gemini model: vertex:gemini-prod:global:gpt-oss-120b -> true (sentinel injected) vertex:gemini-team:us:claude-fable-5 -> true That is the same class of defect the predicate exists to prevent, reintroduced one layer up — and my own tests missed it because they used a neutral project name on the positive control. Now reduces to the model component first: last ':' segment for a Vertex identity, then last '/' segment for a namespaced id, anchored with ^. Positive controls unchanged (vertex:proj:global:gemini-3-pro, google/gemini-3-pro, gemini-3-pro, gemini-pro-agent all still true). Mutation-verified: restoring the whole-string scan fails exactly the new test (70/1); with the fix 71/0, and 160/0 across all four affected suites.
1 parent 3468cea commit eebd191

2 files changed

Lines changed: 37 additions & 8 deletions

File tree

‎src/adapters/google-antigravity-replay.ts‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -640,16 +640,22 @@ const THOUGHT_SIGNATURE_BYPASS = "skip_thought_signature_validator";
640640
* Gemini-only control token was observed being injected into `gpt-oss-120b-medium`. Replaying a
641641
* signature upstream gave us is harmless for any model; *fabricating* a Gemini token is not.
642642
*
643-
* The boundary alternation covers the namespaces this module actually receives: a bare CCA id
644-
* (`gemini-3-pro`), a slash-prefixed id (`google/gemini-3-pro`), and the Vertex replay key built
645-
* in `src/adapters/google.ts` as `vertex:<project>:<location>:<modelId>`, whose separator is a
646-
* COLON — matching only `/` would silently skip every Vertex Gemini request. The trailing
647-
* `[-.\d]` keeps `geminibot` and `my-gemini-clone` out. A model outside this set that genuinely
648-
* needs the sentinel must arrive with a captured accepted CCA contract, not by widening this
649-
* predicate on inference.
643+
* The identity must be REDUCED to its model component before matching, not scanned whole. The
644+
* Vertex replay key is built in `src/adapters/google.ts` as
645+
* `vertex:<project>:<location>:<modelId>`, and the project id is operator-chosen: a project
646+
* named `gemini-prod` made a whole-string scan return true for
647+
* `vertex:gemini-prod:global:gpt-oss-120b`, arming the Gemini-only sentinel for a non-Gemini
648+
* model — the exact class of defect this predicate exists to prevent, reintroduced one layer up.
649+
*
650+
* So: take the last `:` segment for a Vertex identity, then the last `/` segment for a
651+
* namespaced id (`google/gemini-3-pro`), and match only that. The trailing `[-.\d]` keeps
652+
* `geminibot` and `my-gemini-clone` out. A model outside this set that genuinely needs the
653+
* sentinel must arrive with a captured accepted CCA contract, not by widening this predicate.
650654
*/
651655
export function antigravitySupportsThoughtSignatureSentinel(model: string): boolean {
652-
return /(^|[/:])gemini[-.\d]/i.test(model);
656+
const afterTransport = model.slice(model.lastIndexOf(":") + 1);
657+
const wireModel = afterTransport.slice(afterTransport.lastIndexOf("/") + 1);
658+
return /^gemini[-.\d]/i.test(wireModel);
653659
}
654660

655661
/**

‎tests/google-antigravity-replay.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,29 @@ describe("thought-signature validator-bypass fallback (#2693)", () => {
11001100
expect(sigOf(other[0].parts[0])).toBeUndefined();
11011101
});
11021102

1103+
test("a gemini-named Vertex PROJECT does not arm the sentinel for a non-Gemini model", () => {
1104+
// The Vertex replay key is vertex:<project>:<location>:<modelId> and the project id is
1105+
// operator-chosen. Scanning the whole identity meant a project called "gemini-prod" armed
1106+
// the Gemini-only sentinel for gpt-oss-120b — the same class of defect the predicate exists
1107+
// to prevent, one layer up. Reduce to the model component before matching.
1108+
expect(antigravitySupportsThoughtSignatureSentinel("vertex:gemini-prod:global:gpt-oss-120b"))
1109+
.toBe(false);
1110+
expect(antigravitySupportsThoughtSignatureSentinel("vertex:gemini-team:us:claude-fable-5"))
1111+
.toBe(false);
1112+
1113+
const contents = [{
1114+
role: "model",
1115+
parts: [{ functionCall: { name: "get_x", args: {} } }],
1116+
}];
1117+
applyAntigravityThoughtSignatureFallback("vertex:gemini-prod:global:gpt-oss-120b", contents);
1118+
expect(sigOf(contents[0].parts[0])).toBeUndefined();
1119+
1120+
// The positive control still holds under the same parsing.
1121+
const gemini = [{ role: "model", parts: [{ functionCall: { name: "get_x", args: {} } }] }];
1122+
applyAntigravityThoughtSignatureFallback("vertex:gemini-prod:global:gemini-3-pro", gemini);
1123+
expect(sigOf(gemini[0].parts[0])).toBe(BYPASS);
1124+
});
1125+
11031126
test("a user-role turn is untouched", () => {
11041127
const contents = [{ role: "user", parts: [{ functionCall: { name: "get_x", args: {} } }] }];
11051128
applyAntigravityThoughtSignatureFallback(MODEL, contents);

0 commit comments

Comments
 (0)