Files
OmniRoute/tests/unit/antigravity-empty-project-selection.test.ts
Markus Hartung 04dba0460e fix(responses-continuation): recover a real id/output for passthrough and translate-mode replies (#11434)
Retargetado para release/v3.8.51 (release/v3.8.50 está congelada — freeze issue #11439). Validado em lote combinado (batch-0824h2, junto de #11435/#11436/#11437) contra o tip de release/v3.8.51: typecheck:core limpo, gates estáticos OK, 127/127 testes focados passando.

Investigação sólida com repro real via container isolado, três causas independentes identificadas e corrigidas com testes de regressão dedicados para cada uma. Obrigado pela contribuição!
2026-08-24 19:57:12 -03:00

65 lines
2.7 KiB
TypeScript

/**
* #11284 — Selection-side safety net for Antigravity accounts with no stored
* Cloud Code projectId.
*
* Production evidence (VPS docker `omniroute`, 2026-08-24): a pool can hold
* healthy accounts WITH projectIds alongside accounts whose projectId is
* empty and which were never confirmed missing (no errorCode) — those
* empty-but-unconfirmed rows still win round-robin slots, burn the request on
* loadCodeAssist discovery + 422, and drag the whole combo circuit down.
*
* Contract pinned here (`antigravityProjectPersist.ts`, quota-strategy copy):
* - connections with an EMPTY stored projectId are skipped whenever at
* least one sibling carries one;
* - when NO connection has a stored project the pool passes through
* unchanged (fresh installs keep their lazy-discovery path — #2334);
* - confirmed-missing rows (errorCode="missing_project_id") stay excluded
* even when they carry a stale stored id (regression guard for the
* persistence-module twin `antigravityProjectPersistence.ts`).
*
* Run: node --import tsx/esm --test tests/unit/antigravity-empty-project-selection.test.ts
*/
import { test } from "node:test";
import assert from "node:assert/strict";
import { preferAntigravityConnectionsWithStoredProject } from "../../open-sse/services/antigravityProjectPersist.ts";
const withProject = { id: "a", projectId: "proj-1" };
const withoutProject = { id: "d", projectId: null, providerSpecificData: {} };
const confirmedMissingWithStaleId = {
id: "f",
errorCode: "missing_project_id",
projectId: "stale-proj",
};
test("#11284: skips empty-projectId siblings when a healthier account exists", () => {
const pool = [withoutProject, withProject];
assert.deepEqual(
preferAntigravityConnectionsWithStoredProject(pool).map((c) => c.id),
["a"]
);
});
test("#11284: skips confirmed-missing rows even with a stale stored id", () => {
const pool = [confirmedMissingWithStaleId, withProject];
assert.deepEqual(
preferAntigravityConnectionsWithStoredProject(pool).map((c) => c.id),
["a"]
);
});
test("#11284: keeps the full pool when ONLY confirmed-missing rows exist (never empty)", () => {
const pool = [confirmedMissingWithStaleId];
assert.deepEqual(preferAntigravityConnectionsWithStoredProject(pool), pool);
});
test("#11284: never empties the pool when every row lacks a projectId", () => {
const pool = [withoutProject, { id: "e", providerSpecificData: {} }];
assert.deepEqual(preferAntigravityConnectionsWithStoredProject(pool), pool);
});
test("#11284: single connection passes through untouched (lazy discovery still applies)", () => {
const pool = [withoutProject];
assert.deepEqual(preferAntigravityConnectionsWithStoredProject(pool), pool);
});