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
4 changes: 4 additions & 0 deletions pm-stack/aggregator/.gitignore
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions pm-stack/aggregator/scripts/collect-fleet-feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
36 changes: 36 additions & 0 deletions pm-stack/aggregator/src/quota-extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
27 changes: 27 additions & 0 deletions pm-stack/aggregator/test/quota-current.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
11 changes: 11 additions & 0 deletions pm-stack/aggregator/test/quota.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down