From 23c020bbfde4eccd74fddd518e9eab2053e86756 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Thu, 12 Nov 2026 20:18:02 -0600 Subject: [PATCH] fix(aggregator): attribute split Antigravity pools by leaf model in section membership (#9170) --- pm-stack/aggregator/src/aa.ts | 38 +++++++++++++++---- pm-stack/aggregator/src/quota-gather-map.ts | 2 +- .../aggregator/test/section-risk-8882.test.ts | 27 ++++++++++++- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/pm-stack/aggregator/src/aa.ts b/pm-stack/aggregator/src/aa.ts index b354147c1d..971e9e1e99 100644 --- a/pm-stack/aggregator/src/aa.ts +++ b/pm-stack/aggregator/src/aa.ts @@ -23,7 +23,7 @@ import type { AaThreshold, } from "./model.ts"; import { isIsoDate } from "./validate.ts"; -import { serviceIdFor } from "./quota-gather-map.ts"; +import { antigravityPoolForModel, serviceIdFor } from "./quota-gather-map.ts"; // --- scalar coercion --------------------------------------------------------- // The Supabase Management API serializes numeric columns as JSON @@ -808,8 +808,11 @@ export const SECTION_RISK_SECTIONS = ["workhorse", "speed", "specialist", "summi * pool id (serviceIdFor: _claude -> anthropic:claude-pro, * _muse/meta -> meta, _openai -> _openai.main); * - split pools: a pool id under the door with a dot suffix serves - * the door (_antigravity.gemini / _antigravity.claude-gpt serve - * _antigravity; opencode-go. serves opencode-go); + * the door (opencode-go. serves opencode-go). The + * _antigravity split is the exception: its pools split by MODEL, + * so sectionPoolIdsFromConfig attributes _antigravity leaves + * per-model via antigravityPoolForModel instead of this door + * join (#9170); * - plan doors: *-plan pseudo-providers in routes map to the pools * of their base provider (opencode-go-plans -> opencode-go.*, * openai-plan -> _openai.main/_openai.alt, mistral-plan -> mistral). */ @@ -844,10 +847,31 @@ export function sectionPoolIdsFromConfig(text: string, poolIds: readonly string[ out[section] = []; continue; } - const doors = new Set([...leaves].map((leaf) => leaf.split("/")[0])); - out[section] = [ - ...new Set(poolIds.filter((poolId) => [...doors].some((door) => poolServesDoor(poolId, door)))), - ].sort(); + const doors = new Set(); + const pools = new Set(); + for (const leaf of leaves) { + const slash = leaf.indexOf("/"); + const door = slash === -1 ? leaf : leaf.slice(0, slash); + // Split-pool exception (#9170): the _antigravity door fans out + // to two pools split BY MODEL, so door-level membership would + // join both pools to any section touching the door — a healthy + // _antigravity.claude-gpt would suppress the speed section's + // alert even when speed's only Antigravity leaf is a Gemini + // model. Preserve the leaf model and apply the gatherer's own + // attribution (antigravityPoolForModel): a Gemini leaf serves + // only _antigravity.gemini, any other leaf only + // _antigravity.claude-gpt. + if (door === "_antigravity" && slash !== -1) { + const pool = antigravityPoolForModel(leaf.slice(slash + 1)); + if (poolIds.includes(pool)) pools.add(pool); + continue; + } + doors.add(door); + } + for (const poolId of poolIds) { + if ([...doors].some((door) => poolServesDoor(poolId, door))) pools.add(poolId); + } + out[section] = [...pools].sort(); } return out; } diff --git a/pm-stack/aggregator/src/quota-gather-map.ts b/pm-stack/aggregator/src/quota-gather-map.ts index 528dc3d21a..80ba87c286 100644 --- a/pm-stack/aggregator/src/quota-gather-map.ts +++ b/pm-stack/aggregator/src/quota-gather-map.ts @@ -231,7 +231,7 @@ export function goPoolServiceId(entry: QuotaCurrentEntry): string | null { * Claude+GPT pool. Quota grouping must use the same rule, or burn and * quota would disagree about which pool a model draws from. */ -function antigravityPoolForModel(model: string, legacy = false): string { +export function antigravityPoolForModel(model: string, legacy = false): string { if (legacy) return model.startsWith("gemini") ? ANTIGRAVITY_LEGACY_GEMINI_SERVICE_ID : ANTIGRAVITY_LEGACY_CLAUDE_GPT_SERVICE_ID; return model.startsWith("gemini") ? ANTIGRAVITY_GEMINI_SERVICE_ID : ANTIGRAVITY_CLAUDE_GPT_SERVICE_ID; diff --git a/pm-stack/aggregator/test/section-risk-8882.test.ts b/pm-stack/aggregator/test/section-risk-8882.test.ts index fc5320f46d..1b5b0db27e 100644 --- a/pm-stack/aggregator/test/section-risk-8882.test.ts +++ b/pm-stack/aggregator/test/section-risk-8882.test.ts @@ -135,9 +135,12 @@ describe("section pool join from config leaf sets (#8882)", () => { test("doors join to pools: service-id spellings, split pools, and plan doors", () => { const membership = sectionPoolIdsFromConfig(CONFIG, POOLS); + // The workhorse fixture's only Antigravity leaf is a Claude + // model (_antigravity/claude-x), so per-model attribution + // (#9170) serves only _antigravity.claude-gpt — NOT the Gemini + // pool the old door-level join added. expect(membership.workhorse).toEqual([ "_antigravity.claude-gpt", - "_antigravity.gemini", "cline-pass", "opencode-go.drewrypope", "opencode-go.popesdrew", @@ -157,6 +160,28 @@ describe("section pool join from config leaf sets (#8882)", () => { expect(poolServesDoor("meta", "_claude")).toBe(false); }); + test("split Antigravity pools join by leaf model, not door (#9170)", () => { + // Mirrors the live config shape: speed reaches exactly one + // Antigravity leaf, a Gemini model, through a nested route. + const splitConfig = `{ + "provider": {}, + "experimental": { "model_routes": { + "speed": { "targets": ["opencode-route/gemini-hydrogen-plan"] }, + "gemini-hydrogen-plan": { "targets": ["_antigravity/gemini-4-hydrogen#high"] }, + "workhorse": { "targets": ["_antigravity/claude-sonnet-5-5"] }, + "summit": { "targets": ["_antigravity/gemini-4-argon", "_antigravity/claude-opus-5-5"] } + } } + }`; + const membership = sectionPoolIdsFromConfig(splitConfig, POOLS); + // Regression (task 15348): a Gemini-only section must NOT gain + // _antigravity.claude-gpt, whose health would suppress its alert. + expect(membership.speed).toEqual(["_antigravity.gemini"]); + // Mirror image: a Claude-only section gains only claude-gpt. + expect(membership.workhorse).toEqual(["_antigravity.claude-gpt"]); + // Both leaf kinds present -> both pools serve the section. + expect(membership.summit).toEqual(["_antigravity.claude-gpt", "_antigravity.gemini"]); + }); + test("unparseable config yields no membership", () => { expect(sectionPoolIdsFromConfig("{not json", POOLS)).toEqual({}); });