Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions pm-stack/aggregator/src/aa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.<workspace> serves opencode-go);
* the door (opencode-go.<workspace> 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). */
Expand Down Expand Up @@ -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<string>();
const pools = new Set<string>();
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;
}
Expand Down
2 changes: 1 addition & 1 deletion pm-stack/aggregator/src/quota-gather-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 26 additions & 1 deletion pm-stack/aggregator/test/section-risk-8882.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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({});
});
Expand Down
Loading