test(ai): pin antigravity ranking contract to bottleneck-as-primary

Rebase onto main collided with c9c2da9c8, whose contract test pinned the
old strategy shape (bottleneck in secondary, runner-up in primary). The
scoped strategy intentionally returns only the bottleneck counter as
primary and leaves secondary unset, so every candidate ties on the
secondary metrics and the bottleneck decides. Update the contract test
to assert the new invariant; the end-to-end ordering cases live in
auth-storage-antigravity-selection.test.ts.

Addresses review feedback on #2200.
This commit is contained in:
can1357
2026-06-10 08:04:34 +02:00
parent 8c3149e5a9
commit 864dd6448c
2 changed files with 10 additions and 6 deletions
+4 -1
View File
@@ -3551,7 +3551,10 @@ export class AuthStorage {
const message = error instanceof Error ? error.message : typeof error === "string" ? error : undefined;
if (message && isUsageLimitError(message)) {
return (
await this.markUsageLimitReached(provider, sessionId, { modelId: options?.modelId, signal: options?.signal })
await this.markUsageLimitReached(provider, sessionId, {
modelId: options?.modelId,
signal: options?.signal,
})
).switched;
}
@@ -257,11 +257,12 @@ describe("antigravity ranking strategy", () => {
};
}
it("maps the most-pressured counter to secondary because AuthStorage compares secondary first", () => {
it("maps the most-pressured counter to primary and leaves secondary unset", () => {
// fetchAntigravityUsage sorts ascending by remainingFraction, so a real
// report's limits[0] is always the bottleneck. AuthStorage compares the
// secondary ranking metrics before primary, so Antigravity must put the
// bottleneck there; otherwise [5%, 90%] remaining can beat [40%, 40%]
// secondary ranking metrics before primary; leaving secondary unset makes
// every Antigravity candidate tie there, so the bottleneck counter in
// primary decides — otherwise [5%, 90%] remaining can beat [40%, 40%]
// because the runner-up counter looks healthier.
const report = {
provider: "google-antigravity" as const,
@@ -269,8 +270,8 @@ describe("antigravity ranking strategy", () => {
limits: [makeLimit(0.05, "Anthropic"), makeLimit(0.4, "Google"), makeLimit(0.9, "OpenAI")],
};
const { primary, secondary } = antigravityRankingStrategy.findWindowLimits(report);
expect(secondary?.label).toBe("Anthropic");
expect(primary?.label).toBe("Google");
expect(primary?.label).toBe("Anthropic");
expect(secondary).toBeUndefined();
});
it("returns undefined windows when the credential has no usage limits", () => {