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
13 changes: 8 additions & 5 deletions pm-stack/aggregator/scripts/collect-fleet-feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,15 @@ function poolFor(provider: string, model: string): string | null {
case "_claude":
return "anthropic:claude-pro";
case "openai":
case "openai-codex":
case "chatgpt":
case "_openai":
case "_openai.main":
case "codex":
// Keep aligned with the pool IDs in ../src/quota-extract.ts; matching below is exact.
return "openai.main";
case "openai.alternate":
return "openai.alternate";
// ("codex" is the pre-rename fork quota id, fork PR #2261; a row
// still stamped with it files under the renamed pool.)
return "_openai.main";
case "_openai.alt":
return "_openai.alt";
Comment on lines +328 to +329

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve burn attribution for the active alternate provider

The checked-in .opencode/opencode.jsonc still defines openai.alternate and includes it in the active openai-plan route (lines 2022–2024). Replacing its case with _openai.alt makes poolFor("openai.alternate", ...) return null. The collector's exact-match attribution at line 869 consequently excludes those sessions from the alternate pool's active sessions and measured token burn. Keep the existing provider spelling as an alias returning the renamed _openai.alt pool until the routing configuration is migrated.

Useful? React with 👍 / 👎.

case "cline-pass":
return "cline-pass";
case "opendesign":
Expand Down
6 changes: 3 additions & 3 deletions pm-stack/aggregator/scripts/gather-quota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ function finalizeRun(id: string, entries: QuotaCurrentEntry[], t0: number): Prov
ms: Date.now() - t0,
entries,
// A partially-failed run still surfaces its first failure: a
// folded provider (codex answers one row per OpenAI credential)
// folded provider (_openai answers one row per OpenAI credential)
// must not let one credential's ok row hide a sibling credential's
// error from the heartbeat — 2026-11-10 the codex run read "ok"
// with no error while the openai.main and _openai credentials were
// error from the heartbeat — 2026-11-10 the _openai run read "ok"
// with no error while the main and self-contained credentials were
// both failing token_expired at the provider.
...(firstFailure?.error ? { error: firstFailure.error } : {}),
};
Expand Down
9 changes: 7 additions & 2 deletions pm-stack/aggregator/src/aa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,15 @@ export const AA_PLAN_FACTS: Record<string, AaPlanFact> = {
multiplier: null,
note: "OpenAI plan quota — the fleet's final reserve, spent last by design.",
},
"openai.alternate": {
"_openai.alt": {
plan: "ChatGPT plan (student)",
multiplier: null,
note: "Second ChatGPT account door; resolves through the fork's built-in catalog.",
note: "Second ChatGPT account door (popesdrew, self-contained _openai instance; renamed from openai.alternate 2026-11-10, code#8163).",
},
"_openai.main": {
plan: "ChatGPT plan",
multiplier: null,
note: "Main ChatGPT account door (drewrypope, self-contained _openai instance; renamed from openai.main 2026-11-10, code#8163).",
},
"_claude": {
plan: "Claude plan",
Expand Down
26 changes: 15 additions & 11 deletions pm-stack/aggregator/src/quota-extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// 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.main) and the
// alternate account (popesdrew) through the `openai.alternate` door
// (pool openai.alternate). Separate accounts, separate allowances:
// never collapse them into one pool.
// through the `_openai.main` door and the alternate account
// (popesdrew) through the `_openai.alt` door. Separate accounts,
// separate allowances: never collapse them into one pool. (Pool ids
// renamed to the door ids 2026-11-10, code#8163 — see POOL NAMING.)
import { poolState } from "./derive.ts";
import type { QuotaPool, QuotaWindow } from "./model.ts";
import { parseIsoDate } from "./validate.ts";
Expand Down Expand Up @@ -247,7 +247,7 @@ const extractCodex: Extractor = (s, now) => {
/**
* The alternate ChatGPT account (popesdrew). It has no dated-read
* section in the stewardship view yet — its live windows arrive
* through the quota gatherer (the openai.alternate credential) and
* through the quota gatherer (the _openai.alt credential) and
* are overlaid onto this pool by overlayQuotaCurrent. The extractor
* exists so a future "### ChatGPT (Alternate)" section is picked up
* like every other pool's dated read; until then it fail-softs to
Expand Down Expand Up @@ -504,8 +504,8 @@ interface PoolSpec {
}

// POOL NAMING (2026-11-03, Drew): a pool's id is its OpenCode config
// provider id whenever the config defines one — meta, openai.main,
// openai.alternate, opencode-go.drewrypope, opencode-go.popesdrew,
// provider id whenever the config defines one — meta, _openai.main,
// _openai.alt, opencode-go.drewrypope, opencode-go.popesdrew,
// opencode-go.developing-today-0, cline-pass,
// opendesign, deepseek, commandcode. The colon-suffixed spellings these
// replaced (meta:high-usage, openai:codex, opencode-go:drewrypope, ...)
Expand All @@ -523,7 +523,11 @@ interface PoolSpec {
// the Antigravity pools ride under _antigravity.gemini /
// _antigravity.claude-gpt. Per the rule above, each starts a NEW
// snapshot series; the pre-rename series stay in the store under
// their old ids, unrewritten.
// their old ids, unrewritten. (2026-11-10, code#8163, Drew: "update
// all old names to use equivalent new names": the two ChatGPT pools
// follow the same rule — openai.main -> _openai.main and
// openai.alternate -> _openai.alt, the self-contained door ids; the
// pre-rename series stay in the store under the old ids.)
// choice: the deployed config defines antigravity-agy,
// antigravity-direct and antigravity-ls (ls/agy are the disabled
// legacy doors; no antigravity-local provider exists), and
Expand Down Expand Up @@ -551,21 +555,21 @@ export const POOL_SPECS: PoolSpec[] = [
shellNote: "No current read (console-only usage).",
},
{
id: "openai.main",
id: "_openai.main",
provider: "OpenAI",
plan: "ChatGPT (Main — drewrypope)",
heading: /^### ChatGPT(?! \(Alternate\))/,
extract: extractCodex,
shellNote: "No current read. OpenAI is the fleet's final reserve pool.",
},
{
id: "openai.alternate",
id: "_openai.alt",
provider: "OpenAI",
plan: "ChatGPT (Alternate — popesdrew)",
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.main); the two are never combined.",
"No dated read. The fleet's second ChatGPT account (popesdrew), measured live by the quota gatherer through the _openai.alt credential — a separate pool from the main account (_openai.main); the two are never combined.",
},
{
id: "opencode-go.drewrypope",
Expand Down
59 changes: 34 additions & 25 deletions pm-stack/aggregator/src/quota-gather-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export function serviceIdFor(providerId: string): string {
case "claude":
case "_claude":
return "anthropic:claude-pro";
case "codex":
return "openai.main";
case "_openai":
return "_openai.main";
case "cline-pass":
return "cline-pass";
case "command-code":
Expand Down Expand Up @@ -121,13 +121,16 @@ export function serviceIdFor(providerId: string): string {
* (#1823, 2026-11-07): antigravity -> _antigravity, the claude-code door
* (module: "claude") -> _claude, commandcode (module: "command-code")
* -> _commandcode, and the muse-direct door (module: "meta", the Muse
* Code High Usage reading) -> _muse. Normalize here, at the one mapping
* Code High Usage reading) -> _muse. The OpenAI quota door (module:
* "codex" before fork PR #2261) -> _openai by the same rule (2026-11-10,
* code#8163). Normalize here, at the one mapping
* point every gathered result passes through. Pool/service ids are a
* separate contract and stay put: serviceIdFor carries the dual-spelling
* cases (both "claude" and "_claude" land on anthropic:claude-pro, and
* "_muse" keeps the "meta" pool).
*/
const CANONICAL_PROVIDER_IDS: Readonly<Record<string, string>> = {
codex: "_openai",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Canonicalize heartbeat keys alongside legacy OpenAI entries

When the pre-rename fork emits providerId: "codex", entries now use _openai, but scripts/gather-quota.ts still constructs runs with the raw provider ID and writes failures under heartbeat.perProvider.codex. After a successful tick followed by an all-credential failure, the retained entries therefore cannot recover the failure through quota-current.ts's legErrorFor, which checks only the entry's provider ID and service ID. For shell pools such as the alternate account, this suppresses the authentication/fetch error and displays only stale data. Normalize the heartbeat keys as well, or preserve the legacy alias in the lookup.

Useful? React with 👍 / 👎.

antigravity: "_antigravity",
claude: "_claude",
"command-code": "_commandcode",
Expand Down Expand Up @@ -162,35 +165,41 @@ export const ANTIGRAVITY_CLAUDE_GPT_SERVICE_ID = "_antigravity.claude-gpt";
export const ANTIGRAVITY_LEGACY_GEMINI_SERVICE_ID = "antigravity-direct.gemini";
export const ANTIGRAVITY_LEGACY_CLAUDE_GPT_SERVICE_ID = "antigravity-direct.claude-gpt";

export const OPENAI_MAIN_SERVICE_ID = "openai.main";
export const OPENAI_ALTERNATE_SERVICE_ID = "openai.alternate";
export const OPENAI_SELF_SERVICE_ID = "_openai";
export const OPENAI_MAIN_SERVICE_ID = "_openai.main";
export const OPENAI_ALTERNATE_SERVICE_ID = "_openai.alt";
export const OPENAI_SELF_SERVICE_ID = "_openai.main";

/**
* Which OpenAI pool a folded `codex` entry belongs to, from the
* Which OpenAI pool a folded `_openai` entry belongs to, from the
* credential's human label / the instance name the fork stamps on the
* folded result. The fork's codex provider folds every OpenAI instance
* credential (openai.main, openai.alternate, _openai) into its
* per-credential answer under the bare provider id "codex"
* (foldInstanceCredentials), and serviceIdFor historically filed ALL
* of those rows under "openai.main" — so the alternate account's 5h
* window landed in the snapshot store as openai.main|5h (its values
* mirror openai.alternate|5h tick-for-tick in usage-2026-11.jsonl)
* and its weekly competed under main's key in the #1624 max-collapse
* folded result. The fork's _openai provider folds every OpenAI instance
* credential into its per-credential answer under the bare provider id
* "_openai" (foldInstanceCredentials), and serviceIdFor historically
* filed ALL of those rows under the main pool — so the alternate
* account's 5h window landed in the snapshot store under main's key
* (its values mirror the alternate series tick-for-tick) and its
* weekly competed under main's key in the #1624 max-collapse
* (2026-11-04: main|weekly published 100 with the ALTERNATE window's
* reset label while main's own read was ~17). Like goPoolServiceId,
* the label is the only stable gatherer-side signal: instance ids are
* config names, credential ids are opaque row ids the mapping would
* have to hardcode. Unmatched entries yield null and keep the
* historical fallback (serviceIdFor: openai.main, the base provider's
* own pool) — never a fabricated pool row.
* have to hardcode. Unmatched entries yield null and keep the fallback
* (serviceIdFor: _openai.main, the base provider's own pool) — never a
* fabricated pool row.
*
* Service ids are the door ids (Drew, 2026-11-10, code#8163):
* _openai.main (drewrypope) and _openai.alt (popesdrew). The
* pre-rename ids (openai.main / openai.alternate) survive only in the
* historical snapshot series, unrewritten; the dedicated _openai door
* and the openai.main instance are the same account, so their rows
* file together under _openai.main.
*/
export function codexPoolServiceId(entry: {
export function openaiPoolServiceId(entry: {
credentialLabel?: string | null;
providerName?: string | null;
}): string | null {
const text = `${entry.credentialLabel ?? ""} ${entry.providerName ?? ""}`.toLowerCase();
if (text.includes("alternate")) return OPENAI_ALTERNATE_SERVICE_ID;
if (text.includes("alternate") || text.includes("_openai.alt")) return OPENAI_ALTERNATE_SERVICE_ID;
if (text.includes("_openai") || text.includes("self-contained") || text.includes("self contained"))
return OPENAI_SELF_SERVICE_ID;
if (text.includes("main")) return OPENAI_MAIN_SERVICE_ID;
Expand Down Expand Up @@ -462,13 +471,13 @@ export function entryFromResult(result: QuotaProviderResult, tickIso: string): Q
? "error"
: "unconfigured";
const providerId = canonicalProviderId(result.providerId);
// Folded codex rows carry one credential per OpenAI instance; file
// each under its own pool (codexPoolServiceId) instead of the base
// Folded _openai rows carry one credential per OpenAI instance; file
// each under its own pool (openaiPoolServiceId) instead of the base
// provider's pool, or a sibling account's windows contaminate
// openai.main's rows and snapshot series.
// _openai.main's rows and snapshot series.
const serviceId =
providerId === "codex"
? (codexPoolServiceId({ credentialLabel: result.credentialLabel, providerName: result.providerName }) ??
providerId === "_openai"
? (openaiPoolServiceId({ credentialLabel: result.credentialLabel, providerName: result.providerName }) ??
serviceIdFor(providerId))
: serviceIdFor(providerId);
const entry: QuotaCurrentEntry = {
Expand Down
2 changes: 1 addition & 1 deletion pm-stack/aggregator/src/snapshot-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export function recordsFromProviderUsage(snap: unknown, observedBy: string): Sna
if (!metricId) return;
out.push({
ts,
serviceId: "openai.main",
serviceId: "_openai.main",
metricId,
value: usedPercent,
unit: "pct",
Expand Down
8 changes: 4 additions & 4 deletions pm-stack/aggregator/test/provider-display.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ describe("providerDisplayNames (#6125)", () => {
});

test("non-direct names are untouched", () => {
const names = providerDisplayNames(["mistral", "openai.main", "cline-pass", "direct"]);
const names = providerDisplayNames(["mistral", "_openai.main", "cline-pass", "direct"]);
expect(names.get("mistral")).toBe("mistral");
expect(names.get("openai.main")).toBe("openai.main");
expect(names.get("_openai.main")).toBe("openai.main"); // Rule 0 (#1823): display strips the leading underscore
expect(names.get("cline-pass")).toBe("cline-pass");
expect(names.get("direct")).toBe("direct");
});

test("a base provider present only as a dotted sibling still blocks stripping", () => {
// "openai.main" is a non-direct openai provider in the set.
const names = providerDisplayNames(["openai.main", "openai-direct"]);
// "_openai.main" is a non-direct openai provider in the set.
const names = providerDisplayNames(["_openai.main", "openai-direct"]);
expect(names.get("openai-direct")).toBe("openai-direct");
});

Expand Down
10 changes: 5 additions & 5 deletions pm-stack/aggregator/test/quota-current.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,23 +748,23 @@ describe("stale-path newest pick is finite-gated (#2253)", () => {
});
});

describe("overlay: alternate ChatGPT pool (openai.alternate)", () => {
describe("overlay: alternate ChatGPT pool (_openai.alt)", () => {
test("gatherer windows land on the alternate pool, never on the main pool", () => {
const view = baseView();
view.pools.push(pool("openai.alternate", []));
view.pools.push(pool("_openai.alt", []));
const out = overlayQuotaCurrent(
view,
file([
entry({
providerId: "openai.alternate",
serviceId: "openai.alternate",
providerId: "_openai.alt",
serviceId: "_openai.alt",
credentialLabel: "OpenAI Alternate (Student - popesdrew)",
windows: [win("5h", 100, iso(5 * 60_000)), win("weekly", 42, iso(5 * 60_000))],
}),
]),
NOW,
);
const alt = out.pools.find((p) => p.id === "openai.alternate")!;
const alt = out.pools.find((p) => p.id === "_openai.alt")!;
expect(alt.windows.map((w) => [w.name, w.percent])).toEqual([
["5-hour", 100],
["weekly", 42],
Expand Down
Loading
Loading