diff --git a/pm-stack/aggregator/scripts/backfill-usage-snapshots.ts b/pm-stack/aggregator/scripts/backfill-usage-snapshots.ts index 520eab60f0..3bfdd3eb49 100644 --- a/pm-stack/aggregator/scripts/backfill-usage-snapshots.ts +++ b/pm-stack/aggregator/scripts/backfill-usage-snapshots.ts @@ -17,6 +17,13 @@ // of CNY 44.64; that is a different observation with no dated source // line here, so no record is invented for it. // +// NOTE (2026-11-03 config-name alignment): the service ids below are +// the pool ids in use on these records' 2026-10-20..25 observation +// dates (meta:high-usage, openai:codex, opencode-go:personal, ...). +// They are kept verbatim on purpose: this seed writes HISTORY, and +// the live rename starts new snapshot series under the config +// provider ids rather than rewriting the old series. +// // Usage: bun run scripts/backfill-usage-snapshots.ts [--dir ] // Env: PM_AGG_SNAPSHOTS_DIR, QUOTA_VIEW_PATH, QUOTA_REGISTRY_PATH. import { readFile } from "node:fs/promises"; diff --git a/pm-stack/aggregator/scripts/collect-fleet-feed.ts b/pm-stack/aggregator/scripts/collect-fleet-feed.ts index b91592a87a..0934b90bdb 100644 --- a/pm-stack/aggregator/scripts/collect-fleet-feed.ts +++ b/pm-stack/aggregator/scripts/collect-fleet-feed.ts @@ -184,21 +184,21 @@ const passwordFile = function poolFor(provider: string, model: string): string | null { switch (provider) { case "meta": - return "meta:high-usage"; + return "meta"; case "claude-code": return "anthropic:claude-pro"; case "openai": case "openai-codex": case "chatgpt": - return "openai:codex"; + return "openai"; case "openai.alternate": return "openai.alternate"; case "cline-pass": - return "cline-pass:cline-pass"; + return "cline-pass"; case "opendesign": - return "opendesign:go"; + return "opendesign"; case "deepseek": - return "deepseek:api"; + return "deepseek"; case "antigravity-ls": case "antigravity-agy": case "google": diff --git a/pm-stack/aggregator/src/quota-extract.ts b/pm-stack/aggregator/src/quota-extract.ts index 2ef2c8fe9c..b99ce3c3f4 100644 --- a/pm-stack/aggregator/src/quota-extract.ts +++ b/pm-stack/aggregator/src/quota-extract.ts @@ -12,7 +12,7 @@ // assistant's Power subscription is never a pool, so no extractor here // emits either. // exactly TWO ChatGPT pools — the main account (drewrypope) reached -// through the `codex` gatherer door (pool openai:codex) and the +// through the `codex` gatherer door (pool openai) and the // alternate account (popesdrew) through the `openai.alternate` door // (pool openai.alternate). Separate accounts, separate allowances: // never collapse them into one pool. @@ -467,9 +467,22 @@ interface PoolSpec { shellNote: string; } +// POOL NAMING (2026-11-03, Drew): a pool's id is its OpenCode config +// provider id whenever the config defines one — meta, openai, +// openai.alternate, opencode-go.drewrypope, opencode-go.popesdrew, cline-pass, +// opendesign, deepseek, commandcode. The colon-suffixed spellings these +// replaced (meta:high-usage, openai:codex, opencode-go:drewrypope, ...) +// survive only in the historical snapshot series and the one-shot +// backfill seed (scripts/backfill-usage-snapshots.ts), which keep the +// ids in use on their observation dates. Two pools keep colon ids +// because the config defines no provider with their name: +// anthropic:claude-pro (burned through the claude-code provider) and +// the antigravity:* splits (burned through antigravity-ls / +// antigravity-agy / google; the config's antigravity-direct is a +// different door and renaming would misattribute the pools). export const POOL_SPECS: PoolSpec[] = [ { - id: "meta:high-usage", + id: "meta", provider: "Meta Model API", plan: "Muse API High Usage", heading: /^### Meta Model API/, @@ -485,7 +498,7 @@ export const POOL_SPECS: PoolSpec[] = [ shellNote: "No current read (console-only usage).", }, { - id: "openai:codex", + id: "openai", provider: "OpenAI", plan: "ChatGPT (Codex pool)", heading: /^### ChatGPT/, @@ -499,10 +512,10 @@ export const POOL_SPECS: PoolSpec[] = [ heading: /^### ChatGPT \(Alternate\)/, extract: extractChatGptAlternate, shellNote: - "No dated read. The fleet's second ChatGPT account (popesdrew), measured live by the quota gatherer through the openai.alternate credential — a separate pool from the main account (openai:codex); the two are never combined.", + "No dated read. The fleet's second ChatGPT account (popesdrew), measured live by the quota gatherer through the openai.alternate credential — a separate pool from the main account (openai); the two are never combined.", }, { - id: "opencode-go:drewrypope", + id: "opencode-go.drewrypope", provider: "OpenCode Go", plan: "drewrypope account", heading: /^### OpenCode Go/, @@ -510,7 +523,7 @@ export const POOL_SPECS: PoolSpec[] = [ shellNote: "No current read.", }, { - id: "opencode-go:popesdrew", + id: "opencode-go.popesdrew", provider: "OpenCode Go", plan: "popesdrew account", heading: /^### OpenCode Go/, @@ -518,7 +531,7 @@ export const POOL_SPECS: PoolSpec[] = [ shellNote: "No current read.", }, { - id: "cline-pass:cline-pass", + id: "cline-pass", provider: "ClinePass", plan: "Cline Pass (Annual)", heading: /^### ClinePass/, @@ -526,7 +539,7 @@ export const POOL_SPECS: PoolSpec[] = [ shellNote: "No current read (dashboard-only source).", }, { - id: "commandcode:go", + id: "commandcode", provider: "Command Code", plan: "GO", heading: /^### Command Code/, @@ -554,7 +567,7 @@ export const POOL_SPECS: PoolSpec[] = [ /** Pools that render with identity only (no dated-read extractor). */ const SHELL_POOLS: QuotaPool[] = [ { - id: "opendesign:go", + id: "opendesign", provider: "Open Design", plan: "Go", state: "healthy", @@ -562,7 +575,7 @@ const SHELL_POOLS: QuotaPool[] = [ note: "No dated read. Live windows arrive through the quota gatherer (the OpenCode opendesign credential, read by the OpenChamber quota module) and are overlaid onto this pool by overlayQuotaCurrent.", }, { - id: "deepseek:api", + id: "deepseek", provider: "DeepSeek", plan: "API (PAYG)", state: "healthy", @@ -586,8 +599,11 @@ const POOL_DOOR_PROVIDER_ID: Record = { /** * The opencode provider id whose disablement filters a pool: the pool's - * door provider ("openai" in "openai:codex"; "claude-code" for - * "anthropic:claude-pro"). + * door provider. Since the 2026-11-03 config-name alignment the pool id + * IS the door provider id for every single-door pool ("openai", + * "meta", "cline-pass", "opendesign", "opencode-go.personal", ...); + * the one exception is "anthropic:claude-pro", whose door is + * "claude-code" (there is no `anthropic` provider in the config). */ export function poolProviderId(poolId: string): string { return POOL_DOOR_PROVIDER_ID[poolId] ?? poolId.split(":")[0]; @@ -630,13 +646,13 @@ export function poolFilteredByDisabled(poolId: string, disabledProviderIds: Read * hiding it would leave a live pool unreported. Drew, 2026-11-03: * meta and opendesign are standard report members and must show real * quotas gathered by asking OpenCode. Today the list holds only - * meta:high-usage: the deployed config disables the `meta` provider + * meta: the deployed config disables the `meta` provider * as a direct session door, which otherwise filtered the pool at * assembly and left the board with no Meta row at all, while the - * gatherer's module read (serviceId meta:high-usage) had no pool to + * gatherer's module read (serviceId meta) had no pool to * land on. */ -export const FILTER_EXEMPT_POOL_IDS: ReadonlySet = new Set(["meta:high-usage"]); +export const FILTER_EXEMPT_POOL_IDS: ReadonlySet = new Set(["meta"]); /** True when the disabled-door filter must not drop this pool. */ export function poolFilterExempt(poolId: string): boolean { diff --git a/pm-stack/aggregator/src/quota-gather-map.ts b/pm-stack/aggregator/src/quota-gather-map.ts index fe45284514..2855be5470 100644 --- a/pm-stack/aggregator/src/quota-gather-map.ts +++ b/pm-stack/aggregator/src/quota-gather-map.ts @@ -56,8 +56,11 @@ export function normalizeResetAt(v: unknown): string | null { /** * Hub pool/snapshot service id for a provider result. Mirrors - * POOL_SPECS (src/quota-extract.ts) where a pool exists, so gatherer - * records continue the series the dated-read writers started. + * POOL_SPECS (src/quota-extract.ts) where a pool exists. Pool ids are + * the OpenCode config provider ids (2026-11-03 alignment — see the + * POOL NAMING note in quota-extract.ts), so a renamed pool starts a + * NEW snapshot series under its config name; the pre-rename series + * stays in the store under the old colon id, unrewritten. * OpenCode Go answers one row per workspace credential (the module's * per-credential fetch); each row lands under the bare id, and * entriesWithPoolSplits below ALSO files attributable rows under @@ -69,15 +72,15 @@ export function serviceIdFor(providerId: string): string { case "claude": return "anthropic:claude-pro"; case "codex": - return "openai:codex"; + return "openai"; case "cline-pass": - return "cline-pass:cline-pass"; + return "cline-pass"; case "deepseek": - return "deepseek:api"; + return "deepseek"; case "meta": - return "meta:high-usage"; + return "meta"; case "opendesign": - return "opendesign:go"; + return "opendesign"; default: return providerId; } @@ -96,8 +99,8 @@ export const GATHERER_SOURCE = "openchamber-quota"; * These MUST mirror POOL_SPECS (src/quota-extract.ts) — the overlay side * of this contract. */ -export const GO_DREWRYPOPE_SERVICE_ID = "opencode-go:drewrypope"; -export const GO_POPESDREW_SERVICE_ID = "opencode-go:popesdrew"; +export const GO_DREWRYPOPE_SERVICE_ID = "opencode-go.drewrypope"; +export const GO_POPESDREW_SERVICE_ID = "opencode-go.popesdrew"; export const ANTIGRAVITY_GEMINI_SERVICE_ID = "antigravity:gemini"; export const ANTIGRAVITY_CLAUDE_GPT_SERVICE_ID = "antigravity:claude-gpt"; @@ -231,7 +234,7 @@ const FILE_EXPORT_WINDOW_SECONDS: Record = { "5h": 18_000, weekl /** * Map one file-export document onto a quota-current entry. The v1 - * producer was Meta (service meta:high-usage, ~/atlas/meta-quota- + * producer was Meta (service meta, ~/atlas/meta-quota- * export/latest.json on the laptop) — retired 2026-11-03 when the * gatherer began asking the OpenCode quota module for Meta * directly (PR #5040); the mapper stays as the #1301 convention's @@ -247,7 +250,7 @@ export function entryFromFileExport( const entry: QuotaCurrentEntry = { providerId: "meta", providerName: "Meta", - serviceId: "meta:high-usage", + serviceId: "meta", state: "error", measuredAt: opts.fileMtimeIso ?? new Date(0).toISOString(), source: doc?.source ?? "file-export", diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts index f467b4835b..7379706eea 100644 --- a/pm-stack/aggregator/src/render.ts +++ b/pm-stack/aggregator/src/render.ts @@ -2193,7 +2193,7 @@ function attentionStripHtml(usage: UsageView): string { * the yuan figure as read, never converted to dollars. */ function paygBalanceHtml(usage: UsageView): string { - const recs = (usage.history["deepseek:api"] ?? []).filter((r) => r.unit === "cny" && typeof r.value === "number"); + const recs = (usage.history["deepseek"] ?? []).filter((r) => r.unit === "cny" && typeof r.value === "number"); if (!recs.length) return ""; const last = recs[recs.length - 1]; return `
DeepSeek PAYG reserve balance: ¥${(last.value as number).toFixed(2)}
reserve only — never a routine route · measured ${esc(last.ts.slice(0, 10))} · ${esc(last.observedBy)}
`; diff --git a/pm-stack/aggregator/src/snapshot-records.ts b/pm-stack/aggregator/src/snapshot-records.ts index bf07f03da4..46e9c009c7 100644 --- a/pm-stack/aggregator/src/snapshot-records.ts +++ b/pm-stack/aggregator/src/snapshot-records.ts @@ -129,7 +129,7 @@ export function recordsFromPaygLines(lines: PaygLine[], observedBy: string): Sna if (line.accruedUsd != null) { out.push({ ts, - serviceId: line.id === "meta-payg" ? "meta:high-usage" : line.id, + serviceId: line.id === "meta-payg" ? "meta" : line.id, metricId: "payg-accrued", value: line.accruedUsd, unit: "usd", @@ -183,7 +183,7 @@ export function recordsFromDeepseekBalance(quotaViewText: string, observedBy: st return [ { ts: dayTs(date), - serviceId: "deepseek:api", + serviceId: "deepseek", metricId: "credits_balance", value, unit: "cny", @@ -308,7 +308,7 @@ export function recordsFromProviderUsage(snap: unknown, observedBy: string): Sna if (!metricId) return; out.push({ ts, - serviceId: "openai:codex", + serviceId: "openai", metricId, value: win.used_percent, unit: "pct", diff --git a/pm-stack/aggregator/src/sources/fixtures.ts b/pm-stack/aggregator/src/sources/fixtures.ts index b4158ed3ef..b79a5703f7 100644 --- a/pm-stack/aggregator/src/sources/fixtures.ts +++ b/pm-stack/aggregator/src/sources/fixtures.ts @@ -357,7 +357,7 @@ export const FIXTURE_QUOTA: QuotaView = { activeSessions: [], }, { - id: "opencode-go:drewrypope", + id: "opencode-go.drewrypope", provider: "OpenCode Go", plan: "drewrypope", state: "near", @@ -403,7 +403,7 @@ export const FIXTURE_QUOTA: QuotaView = { ], }, { - id: "deepseek:api", + id: "deepseek", provider: "DeepSeek", plan: "API balance", state: "healthy", @@ -439,7 +439,7 @@ export const FIXTURE_QUOTA: QuotaView = { choices: { hasHeadroom: ["antigravity:claude", "antigravity:gemini", "meta:model-api", "openai:chatgpt"], burnBeforeReset: ["antigravity:gemini", "antigravity:claude"], - doNotStart: ["anthropic:claude-subscription", "opencode-go:drewrypope"], + doNotStart: ["anthropic:claude-subscription", "opencode-go.drewrypope"], }, }; diff --git a/pm-stack/aggregator/test/clinepass-adapter.test.ts b/pm-stack/aggregator/test/clinepass-adapter.test.ts index 1d116dfcbe..c3d528161d 100644 --- a/pm-stack/aggregator/test/clinepass-adapter.test.ts +++ b/pm-stack/aggregator/test/clinepass-adapter.test.ts @@ -37,7 +37,7 @@ const PREVIOUS: PreviousValue = { value: { providerId: "cline-pass", providerName: "ClinePass", - serviceId: "cline-pass:cline-pass", + serviceId: "cline-pass", state: "ok", measuredAt: "2026-11-02T11:45:00Z", source: "token-adapter/cline-pass", @@ -117,7 +117,7 @@ describe("parseClinePassPayload (ported OpenChamber mapping)", () => { test("entry mapping lands on the cline-pass service id with pct windows", () => { const entry = entryFromClinePassReading(parseClinePassPayload(DOCUMENTED), NOW.toISOString()); expect(entry.providerId).toBe("cline-pass"); - expect(entry.serviceId).toBe("cline-pass:cline-pass"); + expect(entry.serviceId).toBe("cline-pass"); expect(entry.state).toBe("ok"); expect(entry.windows.map((w) => [w.name, w.pctOfLimit])).toEqual([ ["5h", 43], @@ -237,7 +237,7 @@ describe("gatherClinePass (gatherer registration path)", () => { fetchImpl: async () => ({ status: 200, text: async () => JSON.stringify(DOCUMENTED) }), }); expect(out.status).toBe("ok"); - expect(out.value?.serviceId).toBe("cline-pass:cline-pass"); + expect(out.value?.serviceId).toBe("cline-pass"); expect(out.value?.windows.map((w) => w.name)).toEqual(["5h", "weekly", "monthly"]); expect(JSON.stringify(out)).not.toContain("fixture-token"); }); diff --git a/pm-stack/aggregator/test/quota-current.test.ts b/pm-stack/aggregator/test/quota-current.test.ts index 7f71cde0d1..b9dba5eebb 100644 --- a/pm-stack/aggregator/test/quota-current.test.ts +++ b/pm-stack/aggregator/test/quota-current.test.ts @@ -26,20 +26,20 @@ function baseView(): QuotaView { pool("anthropic:claude-pro", [ { name: "weekly", unit: "other", limit: 100, used: 68, percent: 68, resetsAt: null }, ]), - pool("openai:codex", [{ name: "7-day", unit: "other", limit: 100, used: 11, percent: 11, resetsAt: null }]), + pool("openai", [{ name: "7-day", unit: "other", limit: 100, used: 11, percent: 11, resetsAt: null }]), pool( - "meta:high-usage", + "meta", [{ name: "weekly", unit: "other", limit: 100, used: 100, percent: 100, resetsAt: null }], "walled", ), - pool("deepseek:api", []), - pool("cline-pass:cline-pass", [ + pool("deepseek", []), + pool("cline-pass", [ { name: "monthly", unit: "other", limit: 100, used: 69, percent: 69, resetsAt: null }, ]), - pool("commandcode:go", [{ name: "monthly credits", unit: "usd", limit: 10, used: 6.57, resetsAt: null }]), + pool("commandcode", [{ name: "monthly credits", unit: "usd", limit: 10, used: 6.57, resetsAt: null }]), ], burn: [], - choices: { hasHeadroom: [], burnBeforeReset: [], doNotStart: ["meta:high-usage"] }, + choices: { hasHeadroom: [], burnBeforeReset: [], doNotStart: ["meta"] }, }; } @@ -85,14 +85,14 @@ describe("quota-current overlay", () => { baseView(), file([ entry({ - serviceId: "meta:high-usage", + serviceId: "meta", source: "file-export/meta-laptop", windows: [win("5h", 1.33, iso(5 * 60_000)), win("weekly", 8.93, iso(5 * 60_000))], }), ]), NOW, ); - const meta = out.pools.find((p) => p.id === "meta:high-usage")!; + const meta = out.pools.find((p) => p.id === "meta")!; expect(meta.windows.map((w) => [w.name, w.percent])).toEqual([ ["5-hour", 1.33], ["weekly", 8.93], @@ -103,7 +103,7 @@ describe("quota-current overlay", () => { source: "file-export/meta-laptop", state: "ok", }); - expect(out.choices.doNotStart).not.toContain("meta:high-usage"); + expect(out.choices.doNotStart).not.toContain("meta"); expect(out.gatherer?.providers).toHaveLength(1); }); @@ -112,14 +112,14 @@ describe("quota-current overlay", () => { baseView(), file([ entry({ - serviceId: "openai:codex", + serviceId: "openai", state: "error", measuredAt: iso(1 * 60_000), error: "Sign in with ChatGPT only", credentialLabel: "OpenAI 2", }), entry({ - serviceId: "openai:codex", + serviceId: "openai", measuredAt: iso(3 * 60_000), windows: [win("weekly", 17, iso(3 * 60_000))], credentialLabel: "OpenAI", @@ -127,7 +127,7 @@ describe("quota-current overlay", () => { ]), NOW, ); - const codex = out.pools.find((p) => p.id === "openai:codex")!; + const codex = out.pools.find((p) => p.id === "openai")!; expect(codex.freshness?.state).toBe("ok"); expect(codex.windows).toHaveLength(1); expect(codex.windows[0].percent).toBe(17); @@ -153,7 +153,7 @@ describe("quota-current overlay", () => { // The dated-read windows stay visible under the error badge — not // replaced by invented zeros. expect(claude.windows[0].percent).toBe(68); - expect(out.choices.doNotStart).toContain("meta:high-usage"); // choices untouched: no fresh windows anywhere + expect(out.choices.doNotStart).toContain("meta"); // choices untouched: no fresh windows anywhere }); test("an ok entry past the freshness bound surfaces as stale, windows untouched", () => { @@ -161,11 +161,11 @@ describe("quota-current overlay", () => { const out = overlayQuotaCurrent( baseView(), file([ - entry({ serviceId: "cline-pass:cline-pass", measuredAt: staleAt, windows: [win("monthly", 71, staleAt)] }), + entry({ serviceId: "cline-pass", measuredAt: staleAt, windows: [win("monthly", 71, staleAt)] }), ]), NOW, ); - const cline = out.pools.find((p) => p.id === "cline-pass:cline-pass")!; + const cline = out.pools.find((p) => p.id === "cline-pass")!; expect(cline.state).toBe("stale"); expect(cline.freshness).toEqual({ measuredAt: staleAt, source: "openchamber-quota", state: "stale" }); expect(cline.windows[0].percent).toBe(69); // dated read, not the aged gatherer value @@ -180,7 +180,7 @@ describe("quota-current overlay", () => { baseView(), file([ entry({ - serviceId: "cline-pass:cline-pass", + serviceId: "cline-pass", measuredAt: at, windows: [win("monthly", 71, at)], retainedFromFailedTick: iso(1 * 60_000), @@ -188,11 +188,11 @@ describe("quota-current overlay", () => { ]), NOW, ); - const cline = out.pools.find((p) => p.id === "cline-pass:cline-pass")!; + const cline = out.pools.find((p) => p.id === "cline-pass")!; expect(cline.state).toBe("stale"); expect(cline.freshness).toEqual({ measuredAt: at, source: "openchamber-quota", state: "stale" }); expect(cline.windows[0].percent).toBe(69); // dated read, not the retained gatherer value - expect(out.gatherer?.providers.find((p) => p.serviceId === "cline-pass:cline-pass")?.state).toBe("stale"); + expect(out.gatherer?.providers.find((p) => p.serviceId === "cline-pass")?.state).toBe("stale"); }); test("an ok entry dated past the future-skew tolerance is stale, windows untouched (#1541)", () => { @@ -201,15 +201,15 @@ describe("quota-current overlay", () => { const out = overlayQuotaCurrent( baseView(), file([ - entry({ serviceId: "cline-pass:cline-pass", measuredAt: futureAt, windows: [win("monthly", 71, futureAt)] }), + entry({ serviceId: "cline-pass", measuredAt: futureAt, windows: [win("monthly", 71, futureAt)] }), ]), NOW, ); - const cline = out.pools.find((p) => p.id === "cline-pass:cline-pass")!; + const cline = out.pools.find((p) => p.id === "cline-pass")!; expect(cline.state).toBe("stale"); expect(cline.freshness).toEqual({ measuredAt: futureAt, source: "openchamber-quota", state: "stale" }); expect(cline.windows[0].percent).toBe(69); // dated read, not the future-dated gatherer value - expect(out.gatherer?.providers.find((p) => p.serviceId === "cline-pass:cline-pass")?.state).toBe("stale"); + expect(out.gatherer?.providers.find((p) => p.serviceId === "cline-pass")?.state).toBe("stale"); } }); @@ -217,10 +217,10 @@ describe("quota-current overlay", () => { const at = iso(-(QUOTA_CURRENT_FUTURE_SKEW_MS - 30_000)); const out = overlayQuotaCurrent( baseView(), - file([entry({ serviceId: "cline-pass:cline-pass", measuredAt: at, windows: [win("monthly", 71, at)] })]), + file([entry({ serviceId: "cline-pass", measuredAt: at, windows: [win("monthly", 71, at)] })]), NOW, ); - const cline = out.pools.find((p) => p.id === "cline-pass:cline-pass")!; + const cline = out.pools.find((p) => p.id === "cline-pass")!; expect(cline.freshness?.state).toBe("ok"); expect(cline.windows[0].percent).toBe(71); }); @@ -230,16 +230,16 @@ describe("quota-current overlay", () => { const out = overlayQuotaCurrent( baseView(), file([ - entry({ serviceId: "cline-pass:cline-pass", measuredAt: futureAt, windows: [win("monthly", 99, futureAt)] }), + entry({ serviceId: "cline-pass", measuredAt: futureAt, windows: [win("monthly", 99, futureAt)] }), entry({ - serviceId: "cline-pass:cline-pass", + serviceId: "cline-pass", measuredAt: iso(5 * 60_000), windows: [win("monthly", 71, iso(5 * 60_000))], }), ]), NOW, ); - const cline = out.pools.find((p) => p.id === "cline-pass:cline-pass")!; + const cline = out.pools.find((p) => p.id === "cline-pass")!; expect(cline.freshness?.state).toBe("ok"); expect(cline.freshness?.measuredAt).toBe(iso(5 * 60_000)); expect(cline.windows[0].percent).toBe(71); // the genuinely fresh read, not the future-dated 99 @@ -250,21 +250,21 @@ describe("quota-current overlay", () => { baseView(), file([ entry({ - serviceId: "deepseek:api", + serviceId: "deepseek", windows: [{ ...win("credits_balance", null, iso(5 * 60_000)), valueLabel: "¥44.29" }], }), ]), NOW, ); - const ds = out.pools.find((p) => p.id === "deepseek:api")!; + const ds = out.pools.find((p) => p.id === "deepseek")!; expect(ds.freshness?.state).toBe("ok"); expect(ds.windows).toEqual([]); expect(ds.state).toBe("healthy"); }); test("pools with no gatherer entry are untouched and carry no freshness", () => { - const out = overlayQuotaCurrent(baseView(), file([entry({ serviceId: "meta:high-usage", windows: [] })]), NOW); - const cc = out.pools.find((p) => p.id === "commandcode:go")!; + const out = overlayQuotaCurrent(baseView(), file([entry({ serviceId: "meta", windows: [] })]), NOW); + const cc = out.pools.find((p) => p.id === "commandcode")!; expect(cc.freshness).toBeUndefined(); expect(cc.windows[0].used).toBe(6.57); expect(cc.state).toBe("healthy"); @@ -289,10 +289,10 @@ describe("quota-current overlay", () => { const view = baseView(); overlayQuotaCurrent( view, - file([entry({ serviceId: "meta:high-usage", windows: [win("weekly", 9, iso(60_000))] })]), + file([entry({ serviceId: "meta", windows: [win("weekly", 9, iso(60_000))] })]), NOW, ); - expect(view.pools.find((p) => p.id === "meta:high-usage")!.windows[0].percent).toBe(100); + expect(view.pools.find((p) => p.id === "meta")!.windows[0].percent).toBe(100); expect(view.gatherer).toBeUndefined(); }); @@ -300,8 +300,8 @@ describe("quota-current overlay", () => { const doc = JSON.parse( JSON.stringify( file([ - entry({ serviceId: "meta:high-usage", windows: [win("weekly", 42, iso(5 * 60_000))] }), - entry({ serviceId: "openai:codex", windows: [win("7-day", 17, iso(5 * 60_000))] }), + entry({ serviceId: "meta", windows: [win("weekly", 42, iso(5 * 60_000))] }), + entry({ serviceId: "openai", windows: [win("7-day", 17, iso(5 * 60_000))] }), ]), ), ); @@ -316,10 +316,10 @@ describe("quota-current overlay", () => { expect(parsed?.sanitized).toEqual({ droppedProviders: 1, droppedWindows: 3 }); expect(parsed?.providers).toHaveLength(2); const out = overlayQuotaCurrent(baseView(), parsed!, NOW); - expect(out.pools.find((p) => p.id === "meta:high-usage")?.windows.map((w) => [w.name, w.percent])).toEqual([ + expect(out.pools.find((p) => p.id === "meta")?.windows.map((w) => [w.name, w.percent])).toEqual([ ["weekly", 42], ]); - expect(out.pools.find((p) => p.id === "openai:codex")?.windows.map((w) => [w.name, w.percent])).toEqual([ + expect(out.pools.find((p) => p.id === "openai")?.windows.map((w) => [w.name, w.percent])).toEqual([ ["7-day", 17], ]); }); @@ -329,12 +329,12 @@ describe("quota-current overlay", () => { JSON.stringify( file([ entry({ - serviceId: "openai:codex", + serviceId: "openai", measuredAt: iso(1 * 60_000), windows: [win("7-day", 55, iso(1 * 60_000))], }), entry({ - serviceId: "openai:codex", + serviceId: "openai", measuredAt: iso(5 * 60_000), windows: [win("7-day", 80, iso(5 * 60_000))], }), @@ -346,7 +346,7 @@ describe("quota-current overlay", () => { const parsed = parseQuotaCurrent(doc); expect(parsed?.providers[0].state).toBe("error"); const out = overlayQuotaCurrent(baseView(), parsed!, NOW); - const pool = out.pools.find((p) => p.id === "openai:codex")!; + const pool = out.pools.find((p) => p.id === "openai")!; // The base pool's dated 11% must not be re-stamped as fresh, and the // older valid read (80%) supplies the headline instead. expect(pool.windows.map((w) => [w.name, w.percent])).toEqual([["7-day", 80]]); @@ -356,13 +356,13 @@ describe("quota-current overlay", () => { test("a sole ok entry whose windows are entirely malformed surfaces as an error, never as fresh provenance", () => { const doc = JSON.parse( - JSON.stringify(file([entry({ serviceId: "openai:codex", windows: [win("7-day", 55, iso(5 * 60_000))] })])), + JSON.stringify(file([entry({ serviceId: "openai", windows: [win("7-day", 55, iso(5 * 60_000))] })])), ); doc.providers[0].windows = [null, { bogus: true }]; const parsed = parseQuotaCurrent(doc); const out = overlayQuotaCurrent(baseView(), parsed!, NOW); - const pool = out.pools.find((p) => p.id === "openai:codex")!; + const pool = out.pools.find((p) => p.id === "openai")!; expect(pool.state).toBe("error"); expect(pool.freshness?.state).toBe("error"); expect(pool.windows.map((w) => w.percent)).toEqual([11]); @@ -371,7 +371,7 @@ describe("quota-current overlay", () => { describe("parseQuotaCurrent", () => { test("accepts a well-formed document", () => { - const doc = JSON.parse(JSON.stringify(file([entry({ serviceId: "meta:high-usage" })]))); + const doc = JSON.parse(JSON.stringify(file([entry({ serviceId: "meta" })]))); expect(parseQuotaCurrent(doc)?.providers).toHaveLength(1); }); @@ -485,13 +485,13 @@ describe("per-credential quota rows (#1113)", () => { const twoLogins = (aPct: number, bPct: number, bMeasured = iso(2 * 60_000)) => file([ entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-main", credentialLabel: "OpenAI", windows: [win("weekly", aPct, iso(5 * 60_000))], }), entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-second", credentialLabel: "OpenAI 2", measuredAt: bMeasured, @@ -501,7 +501,7 @@ describe("per-credential quota rows (#1113)", () => { test("two logins with genuinely differing quotas split into rows; headline stays the newest read", () => { const out = overlayQuotaCurrent(baseView(), twoLogins(30, 80), NOW); - const pool = out.pools.find((p) => p.id === "openai:codex")!; + const pool = out.pools.find((p) => p.id === "openai")!; expect(pool.windows.map((w) => w.percent)).toEqual([80]); expect(pool.credentials).toHaveLength(2); const byLabel = new Map(pool.credentials!.map((c) => [c.label, c])); @@ -512,7 +512,7 @@ describe("per-credential quota rows (#1113)", () => { test("two logins sharing one pool read do not split", () => { const out = overlayQuotaCurrent(baseView(), twoLogins(42, 42), NOW); - const pool = out.pools.find((p) => p.id === "openai:codex")!; + const pool = out.pools.find((p) => p.id === "openai")!; expect(pool.credentials).toBeUndefined(); }); @@ -521,13 +521,13 @@ describe("per-credential quota rows (#1113)", () => { baseView(), file([ entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-main", credentialLabel: "OpenAI", windows: [win("weekly", 30, iso(5 * 60_000))], }), entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-second", credentialLabel: "OpenAI 2", state: "error", @@ -537,7 +537,7 @@ describe("per-credential quota rows (#1113)", () => { ]), NOW, ); - const pool = out.pools.find((p) => p.id === "openai:codex")!; + const pool = out.pools.find((p) => p.id === "openai")!; expect(pool.windows.map((w) => w.percent)).toEqual([30]); // headline from the ok login const err = pool.credentials!.find((c) => c.label === "OpenAI 2")!; expect(err.freshness.state).toBe("error"); @@ -550,7 +550,7 @@ describe("per-credential quota rows (#1113)", () => { baseView(), file([ entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-main", credentialLabel: "OpenAI", windows: [win("weekly", 30, iso(5 * 60_000))], @@ -558,7 +558,7 @@ describe("per-credential quota rows (#1113)", () => { ]), NOW, ); - expect(out.pools.find((p) => p.id === "openai:codex")!.credentials).toBeUndefined(); + expect(out.pools.find((p) => p.id === "openai")!.credentials).toBeUndefined(); }); test("pool card renders one line per credential row", async () => { @@ -590,14 +590,14 @@ describe("per-credential rows: Codex findings on PR #2978", () => { baseView(), file([ entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-main", credentialId: "cred-a", credentialLabel: "OpenAI", windows: [win("weekly", 30, iso(5 * 60_000))], }), entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-main", credentialId: "cred-b", credentialLabel: "OpenAI", @@ -607,7 +607,7 @@ describe("per-credential rows: Codex findings on PR #2978", () => { ]), NOW, ); - const pool = out.pools.find((p) => p.id === "openai:codex")!; + const pool = out.pools.find((p) => p.id === "openai")!; expect(pool.credentials).toHaveLength(2); expect(pool.credentials!.map((c) => c.credentialId).sort()).toEqual(["cred-a", "cred-b"]); expect(pool.credentials!.map((c) => c.windows[0].percent).sort((a, b) => (a ?? 0) - (b ?? 0))).toEqual([30, 80]); @@ -616,7 +616,7 @@ describe("per-credential rows: Codex findings on PR #2978", () => { test("reset drift under the tolerance does not split a shared read", () => { const mk = (cred: string, label: string, resetsAt: string, measuredAt: string) => entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-main", credentialId: cred, credentialLabel: label, @@ -631,13 +631,13 @@ describe("per-credential rows: Codex findings on PR #2978", () => { ]), NOW, ); - expect(out.pools.find((p) => p.id === "openai:codex")!.credentials).toBeUndefined(); + expect(out.pools.find((p) => p.id === "openai")!.credentials).toBeUndefined(); }); test("resets genuinely apart still split even at equal percent", () => { const mk = (cred: string, label: string, resetsAt: string, measuredAt: string) => entry({ - serviceId: "openai:codex", + serviceId: "openai", providerId: "openai-main", credentialId: cred, credentialLabel: label, @@ -652,38 +652,38 @@ describe("per-credential rows: Codex findings on PR #2978", () => { ]), NOW, ); - expect(out.pools.find((p) => p.id === "openai:codex")!.credentials).toHaveLength(2); + expect(out.pools.find((p) => p.id === "openai")!.credentials).toHaveLength(2); }); }); describe("stale-path newest pick is finite-gated (#2253)", () => { const staleRead = () => - entry({ serviceId: "meta:high-usage", measuredAt: iso(2 * 3_600_000), source: "real-src", windows: [] }); + entry({ serviceId: "meta", measuredAt: iso(2 * 3_600_000), source: "real-src", windows: [] }); const garbageRead = () => - entry({ serviceId: "meta:high-usage", measuredAt: "not-a-date", source: "garbage-src", windows: [] }); + entry({ serviceId: "meta", measuredAt: "not-a-date", source: "garbage-src", windows: [] }); test("a garbage measuredAt listed first does not shadow the real stale read", () => { const out = overlayQuotaCurrent(baseView(), file([garbageRead(), staleRead()]), NOW); - const p = out.pools.find((x) => x.id === "meta:high-usage")!; + const p = out.pools.find((x) => x.id === "meta")!; expect(p.freshness).toEqual({ measuredAt: iso(2 * 3_600_000), source: "real-src", state: "stale" }); }); test("a garbage measuredAt listed last gives the same winner (order independence)", () => { const out = overlayQuotaCurrent(baseView(), file([staleRead(), garbageRead()]), NOW); - const p = out.pools.find((x) => x.id === "meta:high-usage")!; + const p = out.pools.find((x) => x.id === "meta")!; expect(p.freshness).toEqual({ measuredAt: iso(2 * 3_600_000), source: "real-src", state: "stale" }); }); test("a +30d future entry does not outrank a real 1h-old stale read", () => { const future = entry({ - serviceId: "meta:high-usage", + serviceId: "meta", measuredAt: new Date(NOW.getTime() + 30 * 86_400_000).toISOString(), source: "future-src", windows: [], }); - const real = entry({ serviceId: "meta:high-usage", measuredAt: iso(3_600_000), source: "real-src", windows: [] }); + const real = entry({ serviceId: "meta", measuredAt: iso(3_600_000), source: "real-src", windows: [] }); const out = overlayQuotaCurrent(baseView(), file([future, real]), NOW); - const p = out.pools.find((x) => x.id === "meta:high-usage")!; + const p = out.pools.find((x) => x.id === "meta")!; expect(p.freshness).toEqual({ measuredAt: iso(3_600_000), source: "real-src", state: "stale" }); }); @@ -715,7 +715,7 @@ describe("overlay: alternate ChatGPT pool (openai.alternate)", () => { ["weekly", 42], ]); // The main account's pool keeps its own read, untouched. - const main = out.pools.find((p) => p.id === "openai:codex")!; + const main = out.pools.find((p) => p.id === "openai")!; expect(main.windows[0].percent).toBe(11); }); }); @@ -724,8 +724,8 @@ describe("overlay: split gatherer rows land on the four split hub pools (#1331)" test("Go per-workspace + Antigravity per-pool rows map with freshness and values", () => { const view = baseView(); view.pools.push( - pool("opencode-go:drewrypope", []), - pool("opencode-go:popesdrew", []), + pool("opencode-go.drewrypope", []), + pool("opencode-go.popesdrew", []), pool("antigravity:gemini", []), pool("antigravity:claude-gpt", []), ); @@ -734,14 +734,14 @@ describe("overlay: split gatherer rows land on the four split hub pools (#1331)" file([ entry({ providerId: "opencode-go", - serviceId: "opencode-go:drewrypope", + serviceId: "opencode-go.drewrypope", credentialId: "cred_personal", credentialLabel: "drewrypope", windows: [win("monthly", 62.5, iso(5 * 60_000))], }), entry({ providerId: "opencode-go", - serviceId: "opencode-go:popesdrew", + serviceId: "opencode-go.popesdrew", credentialId: "cred_lab", credentialLabel: "popesdrew", windows: [win("monthly", 50, iso(5 * 60_000))], @@ -760,11 +760,11 @@ describe("overlay: split gatherer rows land on the four split hub pools (#1331)" NOW, ); const byId = new Map(out.pools.map((p) => [p.id, p])); - expect(byId.get("opencode-go:drewrypope")!.windows.map((w) => [w.name, w.percent])).toEqual([["monthly", 62.5]]); - expect(byId.get("opencode-go:popesdrew")!.windows.map((w) => [w.name, w.percent])).toEqual([["monthly", 50]]); + expect(byId.get("opencode-go.drewrypope")!.windows.map((w) => [w.name, w.percent])).toEqual([["monthly", 62.5]]); + expect(byId.get("opencode-go.popesdrew")!.windows.map((w) => [w.name, w.percent])).toEqual([["monthly", 50]]); expect(byId.get("antigravity:gemini")!.windows.map((w) => [w.name, w.percent])).toEqual([["weekly", 40]]); expect(byId.get("antigravity:claude-gpt")!.windows.map((w) => [w.name, w.percent])).toEqual([["weekly", 90]]); - for (const id of ["opencode-go:drewrypope", "opencode-go:popesdrew", "antigravity:gemini", "antigravity:claude-gpt"]) { + for (const id of ["opencode-go.drewrypope", "opencode-go.popesdrew", "antigravity:gemini", "antigravity:claude-gpt"]) { expect(byId.get(id)!.freshness).toEqual({ measuredAt: iso(5 * 60_000), source: "openchamber-quota", @@ -900,14 +900,14 @@ describe("parseQuotaCurrent measuredAt gates (#4987)", () => { const doc = JSON.parse( JSON.stringify( file([ - entry({ serviceId: "meta:high-usage", measuredAt: bad, windows: [win("weekly", 42, iso(5 * 60_000))] }), - entry({ serviceId: "openai:codex", windows: [win("7-day", 17, iso(5 * 60_000))] }), + entry({ serviceId: "meta", measuredAt: bad, windows: [win("weekly", 42, iso(5 * 60_000))] }), + entry({ serviceId: "openai", windows: [win("7-day", 17, iso(5 * 60_000))] }), ]), ), ); const parsed = parseQuotaCurrent(doc); expect(parsed?.sanitized?.droppedProviders).toBe(1); - expect(parsed?.providers.map((p) => p.serviceId)).toEqual(["openai:codex"]); + expect(parsed?.providers.map((p) => p.serviceId)).toEqual(["openai"]); } }); @@ -917,7 +917,7 @@ describe("parseQuotaCurrent measuredAt gates (#4987)", () => { JSON.stringify( file([ entry({ - serviceId: "openai:codex", + serviceId: "openai", windows: [win("7-day", 17, iso(5 * 60_000)), win("weekly", 42, bad)], }), ]), @@ -933,7 +933,7 @@ describe("parseQuotaCurrent measuredAt gates (#4987)", () => { const leap = "2024-02-29T07:00:00.000Z"; const doc = JSON.parse( JSON.stringify( - file([entry({ serviceId: "openai:codex", measuredAt: leap, windows: [win("7-day", 17, leap)] })]), + file([entry({ serviceId: "openai", measuredAt: leap, windows: [win("7-day", 17, leap)] })]), ), ); const parsed = parseQuotaCurrent(doc); diff --git a/pm-stack/aggregator/test/quota-gather-map.test.ts b/pm-stack/aggregator/test/quota-gather-map.test.ts index 5447ea24f2..f3fbfce184 100644 --- a/pm-stack/aggregator/test/quota-gather-map.test.ts +++ b/pm-stack/aggregator/test/quota-gather-map.test.ts @@ -64,7 +64,7 @@ describe("normalizeResetAt", () => { describe("entryFromResult", () => { test("maps windows onto the quota-current shape", () => { const entry = entryFromResult(OK_RESULT, "2026-10-27T05:00:00.000Z"); - expect(entry.serviceId).toBe("cline-pass:cline-pass"); + expect(entry.serviceId).toBe("cline-pass"); expect(entry.state).toBe("ok"); expect(entry.measuredAt).toBe(new Date(1793075143879).toISOString()); const weekly = entry.windows.find((w) => w.name === "weekly"); @@ -258,7 +258,7 @@ describe("recordsFromEntries", () => { const first = recordsFromEntries([entry], new Map(), "quota-gatherer"); expect(first.records).toHaveLength(1); expect(first.records[0]).toMatchObject({ - serviceId: "cline-pass:cline-pass", + serviceId: "cline-pass", metricId: "weekly", value: 29, unit: "pct", @@ -320,7 +320,7 @@ describe("recordsFromEntries — CNY balances (#1052)", () => { const first = recordsFromEntries([entry], new Map(), "quota-gatherer"); expect(first.records).toHaveLength(1); expect(first.records[0]).toMatchObject({ - serviceId: "deepseek:api", + serviceId: "deepseek", metricId: "credits_balance", value: 44.63, unit: "cny", @@ -456,7 +456,7 @@ describe("entryFromFileExport (Meta #1301 convention)", () => { }; test("success document maps windows + dollar labels", () => { const entry = entryFromFileExport(okDoc, { fileMtimeIso: "2026-10-27T05:30:05.000Z", stale: false }); - expect(entry.serviceId).toBe("meta:high-usage"); + expect(entry.serviceId).toBe("meta"); expect(entry.state).toBe("ok"); expect(entry.source).toBe("file-export/meta-laptop"); expect(entry.planLabel).toBe("PAID"); @@ -530,10 +530,10 @@ describe("entryFromFileExport (Meta #1301 convention)", () => { describe("serviceIdFor", () => { test("known pools map to hub ids; others pass through", () => { - expect(serviceIdFor("codex")).toBe("openai:codex"); - expect(serviceIdFor("deepseek")).toBe("deepseek:api"); - expect(serviceIdFor("meta")).toBe("meta:high-usage"); - expect(serviceIdFor("opendesign")).toBe("opendesign:go"); + expect(serviceIdFor("codex")).toBe("openai"); + expect(serviceIdFor("deepseek")).toBe("deepseek"); + expect(serviceIdFor("meta")).toBe("meta"); + expect(serviceIdFor("opendesign")).toBe("opendesign"); expect(serviceIdFor("openai.alternate")).toBe("openai.alternate"); }); }); @@ -714,10 +714,10 @@ describe("pool splits (#1331)", () => { // ...and the pool-level series continue in the snapshot records. const { records } = recordsFromEntries(split, new Map(), "quota-gatherer"); expect(records.map((r) => `${r.serviceId}|${r.metricId}`).sort()).toEqual([ - "opencode-go:drewrypope|5h", - "opencode-go:drewrypope|monthly", - "opencode-go:popesdrew|5h", - "opencode-go:popesdrew|monthly", + "opencode-go.drewrypope|5h", + "opencode-go.drewrypope|monthly", + "opencode-go.popesdrew|5h", + "opencode-go.popesdrew|monthly", "opencode-go|5h", "opencode-go|monthly", ]); diff --git a/pm-stack/aggregator/test/quota.test.ts b/pm-stack/aggregator/test/quota.test.ts index b14a33a975..ce6f059a8f 100644 --- a/pm-stack/aggregator/test/quota.test.ts +++ b/pm-stack/aggregator/test/quota.test.ts @@ -54,7 +54,7 @@ describe("quota extractors", () => { expect(claude.windows[0].resetsAt).toBeNull(); const metaView = `\n### Meta Model API\n- weekly quota 46% used at 03:20 CDT. Weekly reset today ${reset} CDT.\n`; - const meta = extractQuotaPools(metaView, NOW).find((p) => p.id === "meta:high-usage")!; + const meta = extractQuotaPools(metaView, NOW).find((p) => p.id === "meta")!; expect(meta.windows).toHaveLength(1); expect(meta.windows[0].percent).toBe(46); expect(meta.windows[0].resetsAt).toBeNull(); @@ -64,7 +64,7 @@ describe("quota extractors", () => { test("meta feb-30 reset neither discards the read nor invents a wall lift (#2470)", () => { const burnedView = `\n### Meta Model API\n- weekly quota 46% used at 03:20 CDT, then burned to empty by morning sessions. Weekly reset today 2026-02-30 19:00 CDT.\n`; - const meta = extractQuotaPools(burnedView, NOW).find((p) => p.id === "meta:high-usage")!; + const meta = extractQuotaPools(burnedView, NOW).find((p) => p.id === "meta")!; expect(meta.windows).toHaveLength(1); expect(meta.windows[0].percent).toBe(46); expect(meta.windows[0].resetsAt).toBeNull(); @@ -73,7 +73,7 @@ describe("quota extractors", () => { }); test("codex 7-day read", () => { - const p = byId.get("openai:codex")!; + const p = byId.get("openai")!; expect(p.windows[0].percent).toBe(11); expect(p.windows[0].resetsAt).toBe("2026-10-30T18:01:00.000Z"); }); @@ -81,20 +81,20 @@ describe("quota extractors", () => { test("month-based resets normalize month case and preserve reads for invalid dates across extractors", () => { const consumers = [ { - id: "openai:codex", + id: "openai", view: (reset: string) => `\n### ChatGPT — main account plans\n7-day 42% used; resets ${reset}, 18:01 UTC.\n`, window: { name: "7-day", percent: 42 }, extraWindows: 0, }, { - id: "opencode-go:drewrypope", + id: "opencode-go.drewrypope", view: (reset: string) => `\n### OpenCode Go ×2 workspaces\n- **drewrypope — monthly 60% used**; monthly reset ${reset}, 18:01 UTC.\n`, window: { name: "monthly", unit: "usd", limit: 60, used: 36, percent: 60 }, extraWindows: 0, }, { - id: "commandcode:go", + id: "commandcode", view: (reset: string) => `\n### Command Code\n$6.57 of $10 used; 5h 1.2%, weekly 8.8%; period ends ${reset}, 18:01 UTC.\n`, window: { name: "monthly credits", unit: "usd", limit: 10, used: 6.57, percent: 65.7 }, @@ -115,7 +115,7 @@ describe("quota extractors", () => { expect(pool.windows).toHaveLength(1 + consumer.extraWindows); expect(pool.windows[0]).toMatchObject(consumer.window); expect(pool.windows[0].resetsAt).toBe(reset.expected); - if (consumer.id === "commandcode:go") { + if (consumer.id === "commandcode") { expect(pool.windows.slice(1).map((window) => window.percent)).toEqual([1.2, 8.8]); } } @@ -126,15 +126,15 @@ describe("quota extractors", () => { const pastDate = "Sep 24"; const cases = [ { - id: "openai:codex", + id: "openai", view: `\n### ChatGPT — main account plans\n7-day 42% used; resets ${pastDate}, 18:01 UTC.\n`, }, { - id: "opencode-go:drewrypope", + id: "opencode-go.drewrypope", view: `\n### OpenCode Go ×2 workspaces\n- **drewrypope — monthly 60% used**; monthly reset ${pastDate}, 18:01 UTC.\n`, }, { - id: "commandcode:go", + id: "commandcode", view: `\n### Command Code\n$6.57 of $10 used; 5h 1.2%, weekly 8.8%; period ends ${pastDate}, 18:01 UTC.\n`, }, ]; @@ -156,10 +156,10 @@ describe("quota extractors", () => { }); test("meta is walled until the weekly reset — and it is the only Meta pool", () => { - const p = byId.get("meta:high-usage")!; + const p = byId.get("meta")!; expect(p.state).toBe("walled"); expect(p.wallLiftsAt).toBe("2026-10-25T19:00:00-05:00"); - expect(pools.some((x) => /muse plan|power/i.test(`${x.id} ${x.plan}`) && x.id !== "meta:high-usage")).toBe(false); + expect(pools.some((x) => /muse plan|power/i.test(`${x.id} ${x.plan}`) && x.id !== "meta")).toBe(false); expect(pools.filter((x) => x.provider.includes("Meta")).length).toBe(1); }); @@ -168,7 +168,7 @@ describe("quota extractors", () => { "weekly quota **46% used at 03:20 CDT**, then burned to empty by morning sessions and spilled to PAYG. **Weekly reset today 2026-10-25 19:00 CDT.**", "**Freshest dated read (2026-10-26, laptop meta-provider probes 14:30–14:42Z): API returns 402 billing_not_configured (billing-verification wall) on all 11 probes — pool BLOCKED, no usable quota.** Weekly reset was today 2026-10-25 19:00 CDT (that reset has since passed).", ); - const p = extractQuotaPools(blockedView, new Date("2026-10-26T17:00:00Z")).find((x) => x.id === "meta:high-usage")!; + const p = extractQuotaPools(blockedView, new Date("2026-10-26T17:00:00Z")).find((x) => x.id === "meta")!; expect(p.state).toBe("walled"); expect(p.note).toContain("billing_not_configured"); expect(p.note).toContain("2026-10-26"); @@ -179,7 +179,7 @@ describe("quota extractors", () => { const goView = (section: string) => "\n### OpenCode Go \u00d72 workspaces\n" + section + "\n"; const go = (view: string) => { const m = new Map(extractQuotaPools(view, NOW).map((p) => [p.id, p])); - return { personal: m.get("opencode-go:drewrypope")!, lab: m.get("opencode-go:popesdrew")! }; + return { personal: m.get("opencode-go.drewrypope")!, lab: m.get("opencode-go.popesdrew")! }; }; // Control: both paragraphs carry their own reset. @@ -216,23 +216,23 @@ describe("quota extractors", () => { }); test("opencode go workspaces are separate pools in USD", () => { - const personal = byId.get("opencode-go:drewrypope")!; + const personal = byId.get("opencode-go.drewrypope")!; expect(personal.windows[0]).toMatchObject({ unit: "usd", limit: 60, used: 36 }); expect(personal.windows[0].resetsAt).toBe("2026-11-03T03:02:00.000Z"); - const lab = byId.get("opencode-go:popesdrew")!; + const lab = byId.get("opencode-go.popesdrew")!; expect(lab.windows[0].used).toBe(30); expect(lab.windows[1]).toMatchObject({ name: "weekly", used: 0 }); }); test("clinepass windows with relative resets anchored to the measured read", () => { - const p = byId.get("cline-pass:cline-pass")!; + const p = byId.get("cline-pass")!; expect(p.windows.map((w) => w.percent)).toEqual([0, 26, 69]); expect(p.windows[1].resetsAt).toBe("2026-10-31T08:48:00.000Z"); expect(p.windows[2].resetsAt).toBe("2026-11-06T00:48:00.000Z"); }); test("command code credits + short windows", () => { - const p = byId.get("commandcode:go")!; + const p = byId.get("commandcode")!; expect(p.windows[0]).toMatchObject({ unit: "usd", used: 6.57, limit: 10 }); expect(p.windows[1].percent).toBe(1.2); expect(p.windows[2].percent).toBe(8.8); @@ -243,7 +243,7 @@ describe("quota extractors", () => { ### Command Code - **Usage / dates:** **Newer dated read (model-efficiency plan, freshest reads 2026-10-25 morning): $6.57 of $10 used ($3.43 left); 5h 1.2%, weekly 8.8%; period ends Nov 2, 23:04 UTC.** **Freshest dated read (console, 2026-10-27 10:05 CDT, commandcode.ai Settings): monthly limit 69% used, resets Nov 2; weekly limit 14% (resets in 4d); 5-hour limit 0% ("No usage in this window yet"); extra/top-up credits $0.00 balance.** `; - const p = extractQuotaPools(multi, NOW).find((x) => x.id === "commandcode:go")!; + const p = extractQuotaPools(multi, NOW).find((x) => x.id === "commandcode")!; expect(p.windows.map((w) => [w.name, w.percent])).toEqual([ ["monthly", 69], ["weekly", 14], @@ -258,7 +258,7 @@ describe("quota extractors", () => { ### Command Code - **Usage / dates:** **Dated read (2026-10-25): $6.57 of $10 used; 5h 1.2%, weekly 8.8%; period ends Nov 2, 23:04 UTC.** **Freshest dated read (2026-10-30): monthly limit 55 percent used (the console printed the figure in words this cycle).** `; - const p = extractQuotaPools(stale, NOW).find((x) => x.id === "commandcode:go")!; + const p = extractQuotaPools(stale, NOW).find((x) => x.id === "commandcode")!; expect(p.windows).toEqual([]); }); @@ -267,7 +267,7 @@ describe("quota extractors", () => { ### Command Code - **Usage / dates:** **Dated read (2026-10-30 09:00 CDT): monthly limit 55% used; weekly limit 20%; 5-hour limit 3%.** **Dated update (2026-10-30 12:00 CDT): monthly limit 100 percent used (the console printed the figure in words).** `; - const p = extractQuotaPools(sameDay, NOW).find((x) => x.id === "commandcode:go")!; + const p = extractQuotaPools(sameDay, NOW).find((x) => x.id === "commandcode")!; expect(p.windows).toEqual([]); }); @@ -276,7 +276,7 @@ describe("quota extractors", () => { ### Command Code - **Usage / dates:** **Dated read (2026-10-30): extra/top-up credits $0.10 balance; hub credits 0.1 flat.** `; - const p = extractQuotaPools(balanceOnly, NOW).find((x) => x.id === "commandcode:go")!; + const p = extractQuotaPools(balanceOnly, NOW).find((x) => x.id === "commandcode")!; expect(p.windows).toEqual([]); }); @@ -319,7 +319,7 @@ describe("America/Chicago dated reads", () => { test("Meta does not treat a winter reset as passed an hour early", () => { const view = `### Meta Model API\nweekly quota 46% used at 03:20 CDT, then burned to empty. Weekly reset today 2026-12-16 14:00 CDT.`; const pool = extractQuotaPools(view, new Date("2026-12-16T19:30:00.000Z")).find( - (candidate) => candidate.id === "meta:high-usage", + (candidate) => candidate.id === "meta", )!; expect(pool.state).toBe("walled"); expect(pool.wallLiftsAt).toBe("2026-12-16T14:00:00-06:00"); @@ -327,7 +327,7 @@ describe("America/Chicago dated reads", () => { test("ClinePass relative windows anchor to a winter read in CST", () => { const view = `### ClinePass\nMeasured 2026-12-16 ~14:00 CDT: 5-hour **0%** used; weekly **26%** used (resets in 0d 1h); monthly **69%** used (resets in 0d 2h).`; - const pool = extractQuotaPools(view).find((candidate) => candidate.id === "cline-pass:cline-pass")!; + const pool = extractQuotaPools(view).find((candidate) => candidate.id === "cline-pass")!; expect(pool.windows[1].resetsAt).toBe("2026-12-16T21:00:00.000Z"); expect(pool.windows[2].resetsAt).toBe("2026-12-16T22:00:00.000Z"); }); @@ -342,9 +342,9 @@ describe("windowPercent + guidance", () => { test("choices bucket pools by state and reset proximity", () => { const pools = extractQuotaPools(VIEW, NOW); const choices = computeChoices(pools, NOW.getTime()); - expect(choices.doNotStart).toContain("meta:high-usage"); - expect(choices.hasHeadroom).toContain("openai:codex"); - expect(choices.hasHeadroom).not.toContain("meta:high-usage"); + expect(choices.doNotStart).toContain("meta"); + expect(choices.hasHeadroom).toContain("openai"); + expect(choices.hasHeadroom).not.toContain("meta"); // Claude resets in >24h; nothing in this fixture resets within a day // with headroom, so burn-before-reset is empty. expect(choices.burnBeforeReset).toEqual([]); @@ -371,19 +371,19 @@ describe("disabled_providers enforcement (#1114)", () => { const disabled = new Set(["openrouter", "github-copilot", "openai", "meta"]); const pools = extractQuotaPools(VIEW, NOW, disabled, (poolId, providerId) => filtered.push([poolId, providerId])); const ids = pools.map((p) => p.id); - expect(ids).not.toContain("openai:codex"); - expect(filtered).toEqual([["openai:codex", "openai"]]); + expect(ids).not.toContain("openai"); + expect(filtered).toEqual([["openai", "openai"]]); const choices = computeChoices(pools, NOW.getTime()); const named = [...choices.hasHeadroom, ...choices.burnBeforeReset, ...choices.doNotStart]; - expect(named).not.toContain("openai:codex"); - // The one exemption (Drew, 2026-11-03): meta:high-usage is a + expect(named).not.toContain("openai"); + // The one exemption (Drew, 2026-11-03): meta is a // standard report member whose quota is gathered by asking // OpenCode; its disabled entry is the direct session door only, // so the pool stays on the board — and in guidance — while // every other named pool still answers to an enabled door. - expect(ids).toContain("meta:high-usage"); + expect(ids).toContain("meta"); for (const id of named) { - if (id === "meta:high-usage") continue; + if (id === "meta") continue; expect(disabled.has(poolProviderId(id))).toBe(false); } }); @@ -457,9 +457,9 @@ describe("disabled_providers enforcement (#1114)", () => { // open-design (not opendesign) and opencode (not opencode-go). const disabled = new Set(["openai-codex", "chatgpt", "open-design", "opencode"]); const ids = extractQuotaPools(VIEW, NOW, disabled).map((p) => p.id); - expect(ids).toContain("openai:codex"); - expect(ids).toContain("opendesign:go"); - expect(ids).toContain("opencode-go:drewrypope"); - expect(ids).toContain("opencode-go:popesdrew"); + expect(ids).toContain("openai"); + expect(ids).toContain("opendesign"); + expect(ids).toContain("opencode-go.drewrypope"); + expect(ids).toContain("opencode-go.popesdrew"); }); }); diff --git a/pm-stack/aggregator/test/snapshot-writers.test.ts b/pm-stack/aggregator/test/snapshot-writers.test.ts index 2c070991ed..adea404356 100644 --- a/pm-stack/aggregator/test/snapshot-writers.test.ts +++ b/pm-stack/aggregator/test/snapshot-writers.test.ts @@ -121,7 +121,7 @@ describe("recordsFromPaygLines", () => { ]; const recs = recordsFromPaygLines(lines, "fleet-feed-collector"); expect(recs.map((r) => `${r.serviceId}/${r.metricId}`)).toEqual([ - "meta:high-usage/payg-accrued", + "meta/payg-accrued", "cloudflare/gateway-accrual-est", ]); expect(recs[0]).toMatchObject({ value: 23.92, unit: "usd", source: "console" }); @@ -206,8 +206,8 @@ describe("recordsFromProviderUsage", () => { const recs = recordsFromProviderUsage(answered, "check-usage"); expect(recs.map((r) => `${r.serviceId}/${r.metricId}=${r.value}`)).toEqual([ "opencode-server/sessions-listed=0", - "openai:codex/7-day=12", - "openai:codex/5-hour=3", + "openai/7-day=12", + "openai/5-hour=3", ]); expect(recordsFromProviderUsage(null, "check-usage")).toEqual([]); expect(recordsFromProviderUsage({ sessions: [] }, "check-usage")).toEqual([]); @@ -229,7 +229,7 @@ describe("recordsFromProviderUsage", () => { expect( recordsFromProviderUsage(snapshot, "check-usage").map((r) => `${r.serviceId}/${r.metricId}=${r.value}`), - ).toEqual(["opencode-server/sessions-listed=1", "openai:codex/5-hour=100"]); + ).toEqual(["opencode-server/sessions-listed=1", "openai/5-hour=100"]); }); test("skips percentages above 100 and non-finite values", () => { @@ -266,7 +266,7 @@ describe("recordsFromProviderUsage", () => { expect( recordsFromProviderUsage(snapshot, "check-usage").map((r) => `${r.serviceId}/${r.metricId}=${r.value}`), - ).toEqual(["openai:codex/7-day=0", "openai:codex/5-hour=100"]); + ).toEqual(["openai/7-day=0", "openai/5-hour=100"]); }); }); @@ -288,7 +288,7 @@ describe("DeepSeek CNY balance (#1052)", () => { expect(recs).toHaveLength(1); expect(recs[0]).toMatchObject({ ts: dayTs("2026-10-25"), - serviceId: "deepseek:api", + serviceId: "deepseek", metricId: "credits_balance", value: 44.63, unit: "cny", @@ -343,7 +343,7 @@ describe("DeepSeek CNY balance (#1052)", () => { expect(isSnapshotRecord(recs[0])).toBe(true); expect(await store.append(recs)).toBe(1); expect(await store.append(recs)).toBe(0); // re-run dedupes - const stored = (await store.readAll()).filter((r) => r.serviceId === "deepseek:api"); + const stored = (await store.readAll()).filter((r) => r.serviceId === "deepseek"); expect(stored).toHaveLength(1); expect(stored[0].unit).toBe("cny"); expect(stored[0].value).toBe(44.63); diff --git a/pm-stack/aggregator/test/token-adapter.test.ts b/pm-stack/aggregator/test/token-adapter.test.ts index 49ba310343..f736a5bf2b 100644 --- a/pm-stack/aggregator/test/token-adapter.test.ts +++ b/pm-stack/aggregator/test/token-adapter.test.ts @@ -145,7 +145,7 @@ const PREV_ENTRY: PreviousValue = { value: { providerId: "meta", providerName: "Meta", - serviceId: "meta:high-usage", + serviceId: "meta", state: "ok", measuredAt: "2026-10-29T04:30:00Z", source: "file-export/meta-laptop", @@ -186,7 +186,7 @@ describe("file-export adapter (the framework's first adapter)", () => { }); expect(out.status).toBe("ok"); expect(out.value?.providerId).toBe("meta"); - expect(out.value?.serviceId).toBe("meta:high-usage"); + expect(out.value?.serviceId).toBe("meta"); expect(out.value?.source).toBe("file-export/meta-laptop"); expect(out.value?.windows.some((w) => w.name === "5h" && w.pctOfLimit === 12.5)).toBe(true); }); @@ -201,7 +201,7 @@ describe("file-export adapter (the framework's first adapter)", () => { }); expect(out.status).toBe("session-expired"); expect(out.needsRelogin).toBe(true); - expect(out.value?.serviceId).toBe("meta:high-usage"); + expect(out.value?.serviceId).toBe("meta"); expect(out.stale).toBe(true); }); @@ -270,7 +270,7 @@ describe("file-export adapter (the framework's first adapter)", () => { doc: { status: "ok" }, }); expect(stale.status).toBe("transport-unavailable"); - expect(stale.value?.serviceId).toBe("meta:high-usage"); + expect(stale.value?.serviceId).toBe("meta"); const missing = collectFileExportAdapter({ now: NOW, previous: null, fileMtimeIso: null, stale: false, doc: null }); expect(missing.status).toBe("fetch-failed"); expect(missing.value).toBeNull(); diff --git a/pm-stack/aggregator/test/usage.test.ts b/pm-stack/aggregator/test/usage.test.ts index e50e2c3f4f..fb8ad2d658 100644 --- a/pm-stack/aggregator/test/usage.test.ts +++ b/pm-stack/aggregator/test/usage.test.ts @@ -550,14 +550,14 @@ describe("hub renders", () => { const usage = await src.usage(); const rec: SnapshotRecord = { ts: "2026-10-25T12:00:00Z", - serviceId: "deepseek:api", + serviceId: "deepseek", metricId: "credits_balance", value: 44.63, unit: "cny", source: "api", observedBy: "backfill:quota-view.md", }; - usage.history = { ...usage.history, "deepseek:api": [rec] }; + usage.history = { ...usage.history, "deepseek": [rec] }; const html = renderQuota(await src.quota(), src.provenance(), usage); expect(html).toContain("DeepSeek PAYG reserve balance"); expect(html).toContain("¥44.63");