From d5120168bf06e407335d656b274082875f5099c4 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Sun, 15 Nov 2026 02:35:10 -0600 Subject: [PATCH] fix(aggregator): alias OpenCode Zen door rows onto the Go pools (#10443) The Zen door (opencode.drewrypope/.popesdrew/.developing-today-0, the opencode-zen-plans door set) reads the same plan meters as the Go door: on the 2026-11-15T08:15Z and 08:30Z quota-current ticks its per-workspace rows carried windows and reset instants identical to the matching opencode-go.* rows (e.g. developing-today-0 monthly 54%, resets 2026-12-08T22:09:41Z in both). serviceIdFor now files Zen rows under the existing opencode-go.* pool ids instead of letting them pass through as unregistered service ids that overlayQuotaCurrent synthesized into duplicate pools. No new pools, no duplicate meters. Adds a measured-provider census test: every providerId in the verified 2026-11-15 tick must resolve via serviceIdFor to a registered pool (POOL_SPECS + SHELL_POOLS) or a documented non-pool id, so an unregistered measured provider fails the suite. --- pm-stack/aggregator/src/quota-gather-map.ts | 15 ++++ .../aggregator/test/quota-gather-map.test.ts | 83 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/pm-stack/aggregator/src/quota-gather-map.ts b/pm-stack/aggregator/src/quota-gather-map.ts index 6f61599a7d..b94cf168e4 100644 --- a/pm-stack/aggregator/src/quota-gather-map.ts +++ b/pm-stack/aggregator/src/quota-gather-map.ts @@ -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.`, 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.` 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) { @@ -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; } diff --git a/pm-stack/aggregator/test/quota-gather-map.test.ts b/pm-stack/aggregator/test/quota-gather-map.test.ts index 37ab86aec8..494f659353 100644 --- a/pm-stack/aggregator/test/quota-gather-map.test.ts +++ b/pm-stack/aggregator/test/quota-gather-map.test.ts @@ -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, @@ -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). @@ -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)", () => {