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
15 changes: 15 additions & 0 deletions pm-stack/aggregator/src/quota-gather-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ export function normalizeResetAt(v: unknown): string | null {
* entriesWithPoolSplits below ALSO files attributable rows under
* their split pool ids. Antigravity's per-model windows likewise keep
* their flattened names here; the pool grouping is a split-row step.
* The OpenCode Zen door (provider ids `opencode.<workspace>`, the
* opencode-zen-plans door set in .opencode/route-fallbacks.md) reads
* the SAME plan meters as the Go door: on the 2026-11-15 ticks its
* per-workspace rows carried windows and reset instants identical to
* the matching `opencode-go.<workspace>` rows (#10443). Its rows
* therefore file under the Go pool ids below — aliasing, not three
* new pools, so the same meter is never double-counted. The provider
* id itself stays the Zen config id (canonicalProviderId is a
* separate contract; the router matches by exact provider id).
*/
export function serviceIdFor(providerId: string): string {
switch (providerId) {
Expand All @@ -106,6 +115,12 @@ export function serviceIdFor(providerId: string): string {
return "meta";
case "opendesign":
return "opendesign";
case "opencode.drewrypope":
return "opencode-go.drewrypope";
case "opencode.popesdrew":
return "opencode-go.popesdrew";
case "opencode.developing-today-0":
return "opencode-go.developing-today-0";
default:
return providerId;
}
Expand Down
83 changes: 83 additions & 0 deletions pm-stack/aggregator/test/quota-gather-map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test";
import {
ANTIGRAVITY_CLAUDE_GPT_SERVICE_ID,
ANTIGRAVITY_GEMINI_SERVICE_ID,
GO_DEVELOPING_TODAY_0_SERVICE_ID,
GO_POPESDREW_SERVICE_ID,
GO_DREWRYPOPE_SERVICE_ID,
OPENAI_ALTERNATE_SERVICE_ID,
Expand All @@ -22,6 +23,7 @@ import {
serviceIdFor,
type QuotaProviderResult,
} from "../src/quota-gather-map.ts";
import { extractQuotaPools } from "../src/quota-extract.ts";

// A cline-pass-shaped result, as the OpenChamber module answers it
// (resetAt in epoch milliseconds, fetchedAt likewise).
Expand Down Expand Up @@ -612,6 +614,87 @@ describe("serviceIdFor", () => {
expect(serviceIdFor("command-code")).toBe("commandcode");
expect(serviceIdFor("_openai.alt")).toBe("_openai.alt");
});

test("OpenCode Zen door ids alias onto the Go pools (#10443)", () => {
// The Zen door (opencode-zen-plans in .opencode/route-fallbacks.md)
// reads the same plan meters as the Go door — on the 2026-11-15
// ticks its rows carried windows and reset instants identical to
// the matching opencode-go.* rows — so its measured rows file
// under the existing Go pool ids, never as duplicate pools.
expect(serviceIdFor("opencode.drewrypope")).toBe(GO_DREWRYPOPE_SERVICE_ID);
expect(serviceIdFor("opencode.popesdrew")).toBe(GO_POPESDREW_SERVICE_ID);
expect(serviceIdFor("opencode.developing-today-0")).toBe(GO_DEVELOPING_TODAY_0_SERVICE_ID);
});

test("a Zen result keeps its provider id and files under the Go pool (#10443)", () => {
const zen: QuotaProviderResult = {
providerId: "opencode.developing-today-0",
providerName: "OpenCode Zen",
ok: true,
configured: true,
fetchedAt: 1763249446170,
usage: {
windows: {
monthly: {
usedPercent: 54,
remainingPercent: 46,
windowSeconds: 2592000,
resetAt: 1796779781000,
resetAfterSeconds: 3530335,
},
},
},
};
const entry = entryFromResult(zen, "2026-11-15T08:30:46.170Z");
expect(entry.providerId).toBe("opencode.developing-today-0");
expect(entry.serviceId).toBe(GO_DEVELOPING_TODAY_0_SERVICE_ID);
expect(entry.state).toBe("ok");
});
});

describe("measured-provider census (#10443)", () => {
// Oracle: the providerIds the gatherer actually published in the
// quota-current tick generatedAt 2026-11-15T08:30:15.319Z (verified
// live on the laptop aggregator state dir). Every measured provider
// must resolve, through serviceIdFor, to a registered pool
// (POOL_SPECS + SHELL_POOLS, via extractQuotaPools) or to one of the
// documented non-pool service ids (quota-current.ts
// NON_POOL_SERVICE_IDS: combined/SaaS rows that never render as
// pools of their own). An unregistered measured provider fails here
// instead of silently synthesizing a duplicate pool at serve time.
const MEASURED_PROVIDER_IDS_2026_11_15 = [
"_antigravity",
"_claude",
"cline-pass",
"_openai",
"_commandcode",
"mistral",
"opencode-go",
"opendesign",
"_openai.alt",
"_openai.main",
"opencode-go.drewrypope",
"opencode-go.popesdrew",
"opencode-go.developing-today-0",
"opencode.drewrypope",
"opencode.popesdrew",
"opencode.developing-today-0",
"turso",
"_muse",
"deepseek",
];
const NON_POOL_SERVICE_IDS = new Set(["turso", "antigravity", "_antigravity", "opencode-go"]);

test("every measured provider resolves to a registered pool or a documented non-pool id", () => {
const registered = new Set(extractQuotaPools("", new Date("2026-11-15T08:30:15.319Z")).map((pool) => pool.id));
for (const providerId of MEASURED_PROVIDER_IDS_2026_11_15) {
const serviceId = serviceIdFor(providerId);
expect(
registered.has(serviceId) || NON_POOL_SERVICE_IDS.has(serviceId),
`${providerId} -> ${serviceId} is not a registered pool`,
).toBe(true);
}
});
});

describe("entryFromTurso (#1049)", () => {
Expand Down