diff --git a/pm-stack/aggregator/.gitignore b/pm-stack/aggregator/.gitignore new file mode 100644 index 0000000000..58f55ad22b --- /dev/null +++ b/pm-stack/aggregator/.gitignore @@ -0,0 +1,4 @@ +# Generated by the aggregator at runtime (PM_AGG_COVERAGE_SNAPSHOT_FILE +# default). The pm-git-sync deploy pipeline refuses to pull into a +# dirty tree, so this must never appear as untracked dirt. +coverage-snapshot.json diff --git a/pm-stack/aggregator/scripts/collect-fleet-feed.ts b/pm-stack/aggregator/scripts/collect-fleet-feed.ts index 4304306b18..c585da0a31 100644 --- a/pm-stack/aggregator/scripts/collect-fleet-feed.ts +++ b/pm-stack/aggregator/scripts/collect-fleet-feed.ts @@ -153,6 +153,8 @@ function poolFor(provider: string, model: string): string | null { case "openai-codex": case "chatgpt": return "openai:codex"; + case "openai.alternate": + return "openai.alternate"; case "cline-pass": return "cline-pass:cline-pass"; case "opendesign": diff --git a/pm-stack/aggregator/src/quota-extract.ts b/pm-stack/aggregator/src/quota-extract.ts index 2caea61f69..de4a6f1a9a 100644 --- a/pm-stack/aggregator/src/quota-extract.ts +++ b/pm-stack/aggregator/src/quota-extract.ts @@ -11,6 +11,11 @@ // via the `meta` provider. There is no "muse plan" pool and the // 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 +// alternate account (popesdrew) through the `openai.alternate` door +// (pool openai.alternate). Separate accounts, separate allowances: +// never collapse them into one pool. import { poolState } from "./derive.ts"; import type { QuotaPool, QuotaWindow } from "./model.ts"; @@ -112,6 +117,28 @@ 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 + * 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 + * the shell, like any extractor whose pattern stops matching. + */ +const extractChatGptAlternate: Extractor = (s) => { + const fiveHour = first(s, /5-hour\s+(\d+(?:\.\d+)?)%\s+used/i); + const weekly = first(s, /7-day\s+(\d+(?:\.\d+)?)%\s+used/i); + if (!fiveHour && !weekly) return null; + const windows: QuotaWindow[] = []; + if (fiveHour) windows.push(pctWindow("5-hour", Number(fiveHour[1]), null)); + if (weekly) windows.push(pctWindow("7-day", Number(weekly[1]), null)); + return { + windows, + note: "Alternate ChatGPT account (popesdrew) — a separate pool from the main account; the two are never combined.", + }; +}; + const extractMeta: Extractor = (s, now) => { // A dated billing-blocked read (402 billing_not_configured — the // billing-verification wall) outranks every window/reset read: the @@ -343,6 +370,15 @@ export const POOL_SPECS: PoolSpec[] = [ extract: extractCodex, shellNote: "No current read. OpenAI is the fleet's final reserve pool.", }, + { + id: "openai.alternate", + 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:codex); the two are never combined.", + }, { id: "opencode-go:personal", provider: "OpenCode Go", diff --git a/pm-stack/aggregator/test/quota-current.test.ts b/pm-stack/aggregator/test/quota-current.test.ts index 86252bac5c..4a48ee697e 100644 --- a/pm-stack/aggregator/test/quota-current.test.ts +++ b/pm-stack/aggregator/test/quota-current.test.ts @@ -596,3 +596,30 @@ describe("stale-path newest pick is finite-gated (#2253)", () => { expect(parseQuotaCurrent(JSON.parse(JSON.stringify(doc)))).not.toBeNull(); }); }); + +describe("overlay: alternate ChatGPT pool (openai.alternate)", () => { + test("gatherer windows land on the alternate pool, never on the main pool", () => { + const view = baseView(); + view.pools.push(pool("openai.alternate", [])); + const out = overlayQuotaCurrent( + view, + file([ + entry({ + providerId: "openai.alternate", + serviceId: "openai.alternate", + 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")!; + expect(alt.windows.map((w) => [w.name, w.percent])).toEqual([ + ["5-hour", 100], + ["weekly", 42], + ]); + // The main account's pool keeps its own read, untouched. + const main = out.pools.find((p) => p.id === "openai:codex")!; + expect(main.windows[0].percent).toBe(11); + }); +}); diff --git a/pm-stack/aggregator/test/quota.test.ts b/pm-stack/aggregator/test/quota.test.ts index 8c6ff7e09d..a04c8f0f20 100644 --- a/pm-stack/aggregator/test/quota.test.ts +++ b/pm-stack/aggregator/test/quota.test.ts @@ -50,6 +50,17 @@ describe("quota extractors", () => { expect(p.windows[0].resetsAt).toBe("2026-10-30T18:01:00.000Z"); }); + test("alternate ChatGPT account is its own pool — never merged into the main pool", () => { + const p = byId.get("openai.alternate")!; + expect(p).toBeDefined(); + expect(p.provider).toBe("OpenAI"); + // This view has no "### ChatGPT (Alternate)" dated-read section, so + // the pool renders as a shell; the gatherer overlay supplies the + // live windows (see quota-current.test.ts). + expect(p.windows).toEqual([]); + expect(poolProviderId("openai.alternate")).toBe("openai.alternate"); + }); + test("meta is walled until the weekly reset — and it is the only Meta pool", () => { const p = byId.get("meta:high-usage")!; expect(p.state).toBe("walled");